drm/ast: add AST 2400 support.
authorDave Airlie <airlied@redhat.com>
Thu, 27 Mar 2014 23:18:45 +0000 (09:18 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 19 May 2014 01:13:55 +0000 (11:13 +1000)
This is ported from the userspace driver.

Untested on any ast2400 hw so far.

Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_main.c
drivers/gpu/drm/ast/ast_mode.c
drivers/gpu/drm/ast/ast_post.c

index fab4b173dc49bbfc81c6feae93b53c97a2fe88c8..561742793947212e2cfc59be97b238c54740ccfc 100644 (file)
@@ -61,6 +61,7 @@ enum ast_chip {
        AST2200,
        AST2150,
        AST2300,
+       AST2400,
        AST1180,
 };
 
index cd0a791e76c5ba91141d2e40d224ec3418684102..01ea4b6d4bf3ebbb054f9ff2713c4bb6da788401 100644 (file)
@@ -72,7 +72,10 @@ static int ast_detect_chip(struct drm_device *dev)
                ast->chip = AST1100;
                DRM_INFO("AST 1180 detected\n");
        } else {
-               if (dev->pdev->revision >= 0x20) {
+               if (dev->pdev->revision >= 0x30) {
+                       ast->chip = AST2400;
+                       DRM_INFO("AST 2400 detected\n");
+               } else if (dev->pdev->revision >= 0x20) {
                        ast->chip = AST2300;
                        DRM_INFO("AST 2300 detected\n");
                } else if (dev->pdev->revision >= 0x10) {
@@ -121,13 +124,14 @@ static int ast_detect_chip(struct drm_device *dev)
                        ast->support_wide_screen = true;
                else {
                        ast->support_wide_screen = false;
-                       if (ast->chip == AST2300) {
-                               ast_write32(ast, 0xf004, 0x1e6e0000);
-                               ast_write32(ast, 0xf000, 0x1);
-                               data = ast_read32(ast, 0x1207c);
-                               if ((data & 0x300) == 0) /* ast1300 */
-                                       ast->support_wide_screen = true;
-                       }
+                       ast_write32(ast, 0xf004, 0x1e6e0000);
+                       ast_write32(ast, 0xf000, 0x1);
+                       data = ast_read32(ast, 0x1207c);
+                       data &= 0x300;
+                       if (ast->chip == AST2300 && data == 0x0) /* ast1300 */
+                               ast->support_wide_screen = true;
+                       if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
+                               ast->support_wide_screen = true;
                }
                break;
        }
@@ -157,7 +161,7 @@ static int ast_get_dram_info(struct drm_device *dev)
        else
                ast->dram_bus_width = 32;
 
-       if (ast->chip == AST2300) {
+       if (ast->chip == AST2300 || ast->chip == AST2400) {
                switch (data & 0x03) {
                case 0:
                        ast->dram_type = AST_DRAM_512Mx16;
@@ -344,6 +348,7 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
        if (ast->chip == AST2100 ||
            ast->chip == AST2200 ||
            ast->chip == AST2300 ||
+           ast->chip == AST2400 ||
            ast->chip == AST1180) {
                dev->mode_config.max_width = 1920;
                dev->mode_config.max_height = 2048;
index 72bec23b66f40720c89baf7025bd388c268893c6..e9a14a14a02953511dab2cd0493ed36f0095b55f 100644 (file)
@@ -398,7 +398,7 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
        ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa8, 0xfd, jregA8);
 
        /* Set Threshold */
-       if (ast->chip == AST2300) {
+       if (ast->chip == AST2300 || ast->chip == AST2400) {
                ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa7, 0x78);
                ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa6, 0x60);
        } else if (ast->chip == AST2100 ||
@@ -771,7 +771,7 @@ static int ast_mode_valid(struct drm_connector *connector,
                if ((mode->hdisplay == 1600) && (mode->vdisplay == 900))
                        return MODE_OK;
 
-               if ((ast->chip == AST2100) || (ast->chip == AST2200) || (ast->chip == AST2300) || (ast->chip == AST1180)) {
+               if ((ast->chip == AST2100) || (ast->chip == AST2200) || (ast->chip == AST2300) || (ast->chip == AST2400) || (ast->chip == AST1180)) {
                        if ((mode->hdisplay == 1920) && (mode->vdisplay == 1080))
                                return MODE_OK;
 
index 977cfb35837a004b6078fb121125d239464df90a..4718e76847b0a6a4ecf0677e3dc7685c53d5fb87 100644 (file)
@@ -78,7 +78,7 @@ ast_set_def_ext_reg(struct drm_device *dev)
        for (i = 0x81; i <= 0x8f; i++)
                ast_set_index_reg(ast, AST_IO_CRTC_PORT, i, 0x00);
 
-       if (ast->chip == AST2300) {
+       if (ast->chip == AST2300 || ast->chip == AST2400) {
                if (dev->pdev->revision >= 0x20)
                        ext_reg_info = extreginfo_ast2300;
                else
@@ -102,7 +102,7 @@ ast_set_def_ext_reg(struct drm_device *dev)
 
        /* Enable RAMDAC for A1 */
        reg = 0x04;
-       if (ast->chip == AST2300)
+       if (ast->chip == AST2300 || ast->chip == AST2400)
                reg |= 0x20;
        ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff, reg);
 }
@@ -365,7 +365,7 @@ void ast_post_gpu(struct drm_device *dev)
        ast_open_key(ast);
        ast_set_def_ext_reg(dev);
 
-       if (ast->chip == AST2300)
+       if (ast->chip == AST2300 || ast->chip == AST2400)
                ast_init_dram_2300(dev);
        else
                ast_init_dram_reg(dev);