Commit 47c362f1 authored by Y.C. Chen's avatar Y.C. Chen Committed by Greg Kroah-Hartman

drm/ast: Fixed system hanged if disable P2A


[ Upstream commit 6c971c09 ]

The original ast driver will access some BMC configuration through P2A bridge
that can be disabled since AST2300 and after.
It will cause system hanged if P2A bridge is disabled.
Here is the update to fix it.
Signed-off-by: default avatarY.C. Chen <yc_chen@aspeedtech.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bfa4d2e4
...@@ -113,6 +113,7 @@ struct ast_private { ...@@ -113,6 +113,7 @@ struct ast_private {
struct ttm_bo_kmap_obj cache_kmap; struct ttm_bo_kmap_obj cache_kmap;
int next_cursor; int next_cursor;
bool support_wide_screen; bool support_wide_screen;
bool DisableP2A;
enum ast_tx_chip tx_chip_type; enum ast_tx_chip tx_chip_type;
u8 dp501_maxclk; u8 dp501_maxclk;
......
...@@ -124,6 +124,12 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) ...@@ -124,6 +124,12 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
} else } else
*need_post = false; *need_post = false;
/* Check P2A Access */
ast->DisableP2A = true;
data = ast_read32(ast, 0xf004);
if (data != 0xFFFFFFFF)
ast->DisableP2A = false;
/* Check if we support wide screen */ /* Check if we support wide screen */
switch (ast->chip) { switch (ast->chip) {
case AST1180: case AST1180:
...@@ -140,6 +146,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) ...@@ -140,6 +146,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
ast->support_wide_screen = true; ast->support_wide_screen = true;
else { else {
ast->support_wide_screen = false; ast->support_wide_screen = false;
if (ast->DisableP2A == false) {
/* Read SCU7c (silicon revision register) */ /* Read SCU7c (silicon revision register) */
ast_write32(ast, 0xf004, 0x1e6e0000); ast_write32(ast, 0xf004, 0x1e6e0000);
ast_write32(ast, 0xf000, 0x1); ast_write32(ast, 0xf000, 0x1);
...@@ -150,6 +157,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) ...@@ -150,6 +157,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
if (ast->chip == AST2400 && data == 0x100) /* ast1400 */ if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
ast->support_wide_screen = true; ast->support_wide_screen = true;
} }
}
break; break;
} }
...@@ -216,16 +224,16 @@ static int ast_get_dram_info(struct drm_device *dev) ...@@ -216,16 +224,16 @@ static int ast_get_dram_info(struct drm_device *dev)
uint32_t data, data2; uint32_t data, data2;
uint32_t denum, num, div, ref_pll; uint32_t denum, num, div, ref_pll;
if (ast->DisableP2A)
{
ast->dram_bus_width = 16;
ast->dram_type = AST_DRAM_1Gx16;
ast->mclk = 396;
}
else
{
ast_write32(ast, 0xf004, 0x1e6e0000); ast_write32(ast, 0xf004, 0x1e6e0000);
ast_write32(ast, 0xf000, 0x1); ast_write32(ast, 0xf000, 0x1);
ast_write32(ast, 0x10000, 0xfc600309);
do {
if (pci_channel_offline(dev->pdev))
return -EIO;
} while (ast_read32(ast, 0x10000) != 0x01);
data = ast_read32(ast, 0x10004); data = ast_read32(ast, 0x10004);
if (data & 0x40) if (data & 0x40)
...@@ -290,6 +298,7 @@ static int ast_get_dram_info(struct drm_device *dev) ...@@ -290,6 +298,7 @@ static int ast_get_dram_info(struct drm_device *dev)
break; break;
} }
ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000); ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
}
return 0; return 0;
} }
......
...@@ -375,12 +375,20 @@ void ast_post_gpu(struct drm_device *dev) ...@@ -375,12 +375,20 @@ void ast_post_gpu(struct drm_device *dev)
ast_enable_mmio(dev); ast_enable_mmio(dev);
ast_set_def_ext_reg(dev); ast_set_def_ext_reg(dev);
if (ast->DisableP2A == false)
{
if (ast->chip == AST2300 || ast->chip == AST2400) if (ast->chip == AST2300 || ast->chip == AST2400)
ast_init_dram_2300(dev); ast_init_dram_2300(dev);
else else
ast_init_dram_reg(dev); ast_init_dram_reg(dev);
ast_init_3rdtx(dev); ast_init_3rdtx(dev);
}
else
{
if (ast->tx_chip_type != AST_TX_NONE)
ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xcf, 0x80); /* Enable DVO */
}
} }
/* AST 2300 DRAM settings */ /* AST 2300 DRAM settings */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment