22 #ifdef CONFIG_PPC_PMAC
23 #include <asm/machdep.h>
39 #if defined(CONFIG_PM) && defined(CONFIG_X86)
40 static void radeon_reinitialize_M10(
struct radeonfb_info *rinfo);
42 struct radeon_device_id {
44 const unsigned short subsystem_vendor;
45 const unsigned short subsystem_device;
50 #define BUGFIX(model, sv, sd, pm, fn) { \
52 .subsystem_vendor = sv, \
53 .subsystem_device = sd, \
54 .pm_mode_modifier = pm, \
55 .new_reinit_func = fn \
58 static struct radeon_device_id radeon_workaround_list[] = {
59 BUGFIX(
"IBM Thinkpad R32",
62 BUGFIX(
"IBM Thinkpad R40",
65 BUGFIX(
"IBM Thinkpad R40",
68 BUGFIX(
"IBM Thinkpad R50/R51/T40/T41",
71 BUGFIX(
"IBM Thinkpad R51/T40/T41/T42",
74 BUGFIX(
"IBM Thinkpad T30",
77 BUGFIX(
"IBM Thinkpad T40p",
80 BUGFIX(
"IBM Thinkpad T42",
83 BUGFIX(
"IBM Thinkpad X31/X32",
89 BUGFIX(
"Acer Aspire 2010",
92 BUGFIX(
"Acer Travelmate 290D/292LMi",
98 static int radeon_apply_workarounds(
struct radeonfb_info *rinfo)
100 struct radeon_device_id *
id;
102 for (
id = radeon_workaround_list;
id->ident !=
NULL;
id++ )
103 if ((id->subsystem_vendor == rinfo->
pdev->subsystem_vendor ) &&
104 (id->subsystem_device == rinfo->
pdev->subsystem_device )) {
108 ", enabling workaround\n", id->ident);
110 rinfo->
pm_mode |=
id->pm_mode_modifier;
112 if (id->new_reinit_func !=
NULL)
121 static inline int radeon_apply_workarounds(
struct radeonfb_info *rinfo)
129 static void radeon_pm_disable_dynamic_mode(
struct radeonfb_info *rinfo)
330 static void radeon_pm_enable_dynamic_mode(
struct radeonfb_info *rinfo)
424 tmp &= ~MCLK_CNTL__R300_DISABLE_MC_MCLKA;
426 tmp &= ~(MCLK_CNTL__R300_DISABLE_MC_MCLKA |
561 static void radeon_pm_save_regs(
struct radeonfb_info *rinfo,
int saving_for_d3)
687 static void radeon_pm_restore_regs(
struct radeonfb_info *rinfo)
733 static void radeon_pm_disable_iopad(
struct radeonfb_info *rinfo)
747 static void radeon_pm_program_v2clk(
struct radeonfb_info *rinfo)
777 static void radeon_pm_low_current(
struct radeonfb_info *rinfo)
821 static void radeon_pm_setup_for_suspend(
struct radeonfb_info *rinfo)
824 u32 sclk_cntl, mclk_cntl, sclk_more_cntl;
959 #ifdef CONFIG_PPC_PMAC
960 if (machine_is(powermac)) {
1059 static void radeon_pm_yclk_mclk_sync(
struct radeonfb_info *rinfo)
1061 u32 mc_chp_io_cntl_a1, mc_chp_io_cntl_b1;
1079 static void radeon_pm_yclk_mclk_sync_m10(
struct radeonfb_info *rinfo)
1081 u32 mc_chp_io_cntl_a1, mc_chp_io_cntl_b1;
1110 if (delay_required >= 2)
1115 if (delay_required >= 2)
1120 if (delay_required >= 2)
1123 if (delay_required) {
1125 if (delay_required >= 2)
1133 static void radeon_pm_m10_program_mode_wait(
struct radeonfb_info *rinfo)
1137 for (cnt = 0; cnt < 100; ++
cnt) {
1146 static void radeon_pm_enable_dll(
struct radeonfb_info *rinfo)
1148 #define DLL_RESET_DELAY 5
1149 #define DLL_SLEEP_DELAY 1
1165 mdelay(DLL_RESET_DELAY*2);
1189 #undef DLL_RESET_DELAY
1190 #undef DLL_SLEEP_DELAY
1193 static void radeon_pm_enable_dll_m10(
struct radeonfb_info *rinfo)
1196 u32 dll_sleep_mask = 0;
1197 u32 dll_reset_mask = 0;
1200 #define DLL_RESET_DELAY 5
1201 #define DLL_SLEEP_DELAY 1
1231 dll_value &= ~(dll_sleep_mask);
1233 mdelay( DLL_SLEEP_DELAY);
1235 dll_value &= ~(dll_reset_mask);
1237 mdelay( DLL_RESET_DELAY);
1239 #undef DLL_RESET_DELAY
1240 #undef DLL_SLEEP_DELAY
1244 static void radeon_pm_full_reset_sdram(
struct radeonfb_info *rinfo)
1246 u32 crtcGenCntl, crtcGenCntl2, memRefreshCntl, crtc_more_cntl,
1247 fp_gen_cntl, fp2_gen_cntl;
1267 static const u32 default_mrtable[] =
1269 0x21321000, 0xa1321000, 0x21321000, 0xffffffff,
1270 0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
1271 0x21321002, 0xa1321002, 0x21321002, 0xffffffff,
1272 0x21320132, 0xa1320132, 0x21320132, 0xffffffff,
1273 0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
1276 const u32 *mrtable = default_mrtable;
1277 int i, mrtable_size =
ARRAY_SIZE(default_mrtable);
1288 radeon_pm_enable_dll_m10(rinfo);
1289 radeon_pm_yclk_mclk_sync_m10(rinfo);
1291 #ifdef CONFIG_PPC_OF
1292 if (rinfo->of_node !=
NULL) {
1297 mrtable_size = size >> 2;
1299 mrtable = default_mrtable;
1304 sdram_mode_reg = mrtable[0];
1306 for (i = 0; i < mrtable_size; i++) {
1307 if (mrtable[i] == 0xffffffffu)
1308 radeon_pm_m10_program_mode_wait(rinfo);
1313 sdram_mode_reg |= mrtable[
i];
1338 radeon_pm_program_mode_reg(rinfo, 0x2002, 2);
1339 radeon_pm_program_mode_reg(rinfo, 0x0132, 2);
1340 radeon_pm_program_mode_reg(rinfo, 0x0032, 2);
1360 radeon_pm_enable_dll(rinfo);
1363 radeon_pm_yclk_mclk_sync(rinfo);
1366 radeon_pm_program_mode_reg(rinfo, 0x2000, 1);
1367 radeon_pm_program_mode_reg(rinfo, 0x2001, 1);
1368 radeon_pm_program_mode_reg(rinfo, 0x2002, 1);
1369 radeon_pm_program_mode_reg(rinfo, 0x0132, 1);
1370 radeon_pm_program_mode_reg(rinfo, 0x0032, 1);
1393 radeon_pm_enable_dll(rinfo);
1396 radeon_pm_yclk_mclk_sync(rinfo);
1400 radeon_pm_program_mode_reg(rinfo, 0x2000, 1);
1401 radeon_pm_program_mode_reg(rinfo, 0x2001, 1);
1402 radeon_pm_program_mode_reg(rinfo, 0x2002, 1);
1403 radeon_pm_program_mode_reg(rinfo, 0x0132, 1);
1404 radeon_pm_program_mode_reg(rinfo, 0x0032, 1);
1408 radeon_pm_program_mode_reg(rinfo, 0x2000, 1);
1409 radeon_pm_program_mode_reg(rinfo, 0x0132, 1);
1410 radeon_pm_program_mode_reg(rinfo, 0x0032, 1);
1430 static void radeon_pm_reset_pad_ctlr_strength(
struct radeonfb_info *rinfo)
1439 for (i = j = 0; i < 65; ++
i) {
1455 static void radeon_pm_all_ppls_off(
struct radeonfb_info *rinfo)
1469 static void radeon_pm_start_mclk_sclk(
struct radeonfb_info *rinfo)
1480 radeon_pll_errata_after_index(rinfo);
1482 radeon_pll_errata_after_data(rinfo);
1486 tmp = (tmp & 0xff00fffful) | (rinfo->
save_regs[77] & 0x00ff0000ul);
1515 radeon_pll_errata_after_index(rinfo);
1517 radeon_pll_errata_after_data(rinfo);
1521 tmp = (tmp & 0xffff00fful) | (rinfo->
save_regs[77] & 0x0000ff00ul);
1547 static void radeon_pm_m10_disable_spread_spectrum(
struct radeonfb_info *rinfo)
1576 static void radeon_pm_m10_enable_lvds_spread_spectrum(
struct radeonfb_info *rinfo)
1631 static void radeon_pm_restore_pixel_pll(
struct radeonfb_info *rinfo)
1636 radeon_pll_errata_after_index(rinfo);
1638 radeon_pll_errata_after_data(rinfo);
1654 radeon_pll_errata_after_index(rinfo);
1656 radeon_pll_errata_after_data(rinfo);
1681 radeon_pll_errata_after_index(rinfo);
1682 radeon_pll_errata_after_data(rinfo);
1685 static void radeon_pm_m10_reconfigure_mc(
struct radeonfb_info *rinfo)
1718 static void radeon_reinitialize_M10(
struct radeonfb_info *rinfo)
1742 radeon_pm_reset_pad_ctlr_strength(rinfo);
1748 radeon_pm_all_ppls_off(rinfo);
1784 radeon_pm_m10_reconfigure_mc(rinfo);
1887 radeon_pm_start_mclk_sclk(rinfo);
1890 radeon_pm_full_reset_sdram(rinfo);
1894 for (i=0; i<256; i++)
1898 for (i=0; i<256; i++)
1921 for (i = 0; i < 0x8000; ++
i)
1933 radeon_pm_m10_disable_spread_spectrum(rinfo);
1934 radeon_pm_restore_pixel_pll(rinfo);
1940 radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
1943 #ifdef CONFIG_PPC_OF
1945 static void radeon_pm_m9p_reconfigure_mc(
struct radeonfb_info *rinfo)
1971 static void radeon_reinitialize_M9P(
struct radeonfb_info *rinfo)
1992 radeon_pm_reset_pad_ctlr_strength(rinfo);
1998 radeon_pm_all_ppls_off(rinfo);
2115 radeon_pm_m9p_reconfigure_mc(rinfo);
2118 radeon_pm_start_mclk_sclk(rinfo);
2121 radeon_pm_full_reset_sdram(rinfo);
2125 for (i=0; i<256; i++)
2129 for (i=0; i<256; i++)
2152 tmp |= rinfo->
save_regs[34] & 0xffff0000;
2157 tmp |= rinfo->
save_regs[34] & 0xffff0000;
2168 for (i = 0; i < 0x8000; ++
i)
2171 OUTREG(0x2ec, 0x6332a020);
2186 OUTREG(0x2ec, 0x6332a3f0);
2201 radeon_pm_m10_disable_spread_spectrum(rinfo);
2202 radeon_pm_restore_pixel_pll(rinfo);
2203 radeon_pm_m10_enable_lvds_spread_spectrum(rinfo);
2207 static void radeon_reinitialize_QW(
struct radeonfb_info *rinfo)
2223 for (i = 0; i < 65; ++
i) {
2272 radeon_pll_errata_after_index(rinfo);
2274 radeon_pll_errata_after_data(rinfo);
2295 radeon_pll_errata_after_index(rinfo);
2297 radeon_pll_errata_after_data(rinfo);
2368 radeon_pm_full_reset_sdram(rinfo);
2425 radeon_pll_errata_after_index(rinfo);
2427 radeon_pll_errata_after_data(rinfo);
2449 radeon_pll_errata_after_index(rinfo);
2451 radeon_pll_errata_after_data(rinfo);
2454 radeon_pll_errata_after_index(rinfo);
2456 radeon_pll_errata_after_index(rinfo);
2457 radeon_pll_errata_after_data(rinfo);
2489 OUTREG(0x2a8, 0x0000061b);
2517 pci_read_config_word(rinfo->
pdev,
2523 pci_write_config_word(rinfo->
pdev,
2544 pci_name(rinfo->
pdev));
2549 radeon_pm_disable_dynamic_mode(rinfo);
2552 radeon_pm_save_regs(rinfo, 0);
2558 radeon_pm_program_v2clk(rinfo);
2561 radeon_pm_disable_iopad(rinfo);
2564 radeon_pm_low_current(rinfo);
2567 radeon_pm_setup_for_suspend(rinfo);
2586 radeonfb_whack_power_state(rinfo,
PCI_D2);
2590 pci_name(rinfo->
pdev));
2594 radeon_pm_full_reset_sdram(rinfo);
2597 radeon_pm_restore_regs(rinfo);
2600 radeon_pm_restore_regs(rinfo);
2602 radeon_pm_full_reset_sdram(rinfo);
2612 if (mesg.
event == pdev->
dev.power.power_state.event)
2616 pci_name(pdev), mesg.
event);
2623 switch (mesg.
event) {
2648 #ifdef CONFIG_PPC_PMAC
2671 radeon_pm_disable_dynamic_mode(rinfo);
2673 radeon_pm_save_regs(rinfo, 1);
2691 radeon_set_suspend(rinfo, 1);
2696 pdev->
dev.power.power_state = mesg;
2701 static int radeon_check_power_loss(
struct radeonfb_info *rinfo)
2710 struct fb_info *info = pci_get_drvdata(pdev);
2724 pci_name(pdev), pdev->
dev.power.power_state.event);
2737 " D3 cold, need softboot !", pci_name(pdev));
2747 radeon_set_suspend(rinfo, 0);
2768 #ifdef CONFIG_PPC_PMAC
2779 radeon_pm_enable_dynamic_mode(rinfo);
2780 else if (rinfo->
dynclk == 0)
2781 radeon_pm_disable_dynamic_mode(rinfo);
2791 #ifdef CONFIG_PPC_OF__disabled
2792 static void radeonfb_early_resume(
void *
data)
2816 if (rinfo->
dynclk == 1) {
2817 radeon_pm_enable_dynamic_mode(rinfo);
2818 printk(
"radeonfb: Dynamic Clock Power Management enabled\n");
2819 }
else if (rinfo->
dynclk == 0) {
2820 radeon_pm_disable_dynamic_mode(rinfo);
2821 printk(
"radeonfb: Dynamic Clock Power Management disabled\n");
2824 #if defined(CONFIG_PM)
2825 #if defined(CONFIG_PPC_PMAC)
2832 if (machine_is(powermac) && rinfo->of_node) {
2841 if (!
strcmp(rinfo->of_node->
name,
"ATY,JasperParent") ||
2842 !
strcmp(rinfo->of_node->
name,
"ATY,SnowyParent")) {
2847 if (!
strcmp(rinfo->of_node->
name,
"ATY,BlueStoneParent")) {
2852 if (!
strcmp(rinfo->of_node->
name,
"ATY,ViaParent")) {
2863 pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, rinfo->of_node, 0, 1);
2887 "radeonfb: skipping test for device workarounds\n");
2889 radeon_apply_workarounds(rinfo);
2893 "radeonfb: forcefully enabling D2 sleep mode\n");
2900 #if defined(CONFIG_PM) && defined(CONFIG_PPC_PMAC)