diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-02-04 20:06:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-02-08 13:48:56 -0500 |
commit | b746bb77627cba62765ff2afeec9cc9a8cbb926c (patch) | |
tree | d6a1b84104e0891d1d39d2968db3194e26b392d0 /drivers | |
parent | b7468168631e03c70105491a0236137868613436 (diff) |
aty128fb: Properly save PCI state before changing PCI PM level
This fixes aty128fb to properly save the PCI config space -before- it
potentially switches the PM state of the chip. This avoids a
warning with the new PM core and is the right thing to do anyway.
I also replaced the hand-coded switch to D2 with a call to the
genericc pci_set_power_state() and removed the code that switches it
back to D0 since the generic code is doing that for us nowadays.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/aty/aty128fb.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index fb2b0f5b23bd..e6e299feb51b 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c | |||
@@ -2374,6 +2374,8 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend) | |||
2374 | /* Set the chip into the appropriate suspend mode (we use D2, | 2374 | /* Set the chip into the appropriate suspend mode (we use D2, |
2375 | * D3 would require a complete re-initialisation of the chip, | 2375 | * D3 would require a complete re-initialisation of the chip, |
2376 | * including PCI config registers, clocks, AGP configuration, ...) | 2376 | * including PCI config registers, clocks, AGP configuration, ...) |
2377 | * | ||
2378 | * For resume, the core will have already brought us back to D0 | ||
2377 | */ | 2379 | */ |
2378 | if (suspend) { | 2380 | if (suspend) { |
2379 | /* Make sure CRTC2 is reset. Remove that the day we decide to | 2381 | /* Make sure CRTC2 is reset. Remove that the day we decide to |
@@ -2391,17 +2393,9 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend) | |||
2391 | aty_st_le32(BUS_CNTL1, 0x00000010); | 2393 | aty_st_le32(BUS_CNTL1, 0x00000010); |
2392 | aty_st_le32(MEM_POWER_MISC, 0x0c830000); | 2394 | aty_st_le32(MEM_POWER_MISC, 0x0c830000); |
2393 | mdelay(100); | 2395 | mdelay(100); |
2394 | pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); | 2396 | |
2395 | /* Switch PCI power management to D2 */ | 2397 | /* Switch PCI power management to D2 */ |
2396 | pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, | 2398 | pci_set_power_state(pdev, PCI_D2); |
2397 | (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | 2); | ||
2398 | pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); | ||
2399 | } else { | ||
2400 | /* Switch back PCI power management to D0 */ | ||
2401 | mdelay(100); | ||
2402 | pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 0); | ||
2403 | pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); | ||
2404 | mdelay(100); | ||
2405 | } | 2399 | } |
2406 | } | 2400 | } |
2407 | 2401 | ||
@@ -2410,6 +2404,12 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2410 | struct fb_info *info = pci_get_drvdata(pdev); | 2404 | struct fb_info *info = pci_get_drvdata(pdev); |
2411 | struct aty128fb_par *par = info->par; | 2405 | struct aty128fb_par *par = info->par; |
2412 | 2406 | ||
2407 | /* Because we may change PCI D state ourselves, we need to | ||
2408 | * first save the config space content so the core can | ||
2409 | * restore it properly on resume. | ||
2410 | */ | ||
2411 | pci_save_state(pdev); | ||
2412 | |||
2413 | /* We don't do anything but D2, for now we return 0, but | 2413 | /* We don't do anything but D2, for now we return 0, but |
2414 | * we may want to change that. How do we know if the BIOS | 2414 | * we may want to change that. How do we know if the BIOS |
2415 | * can properly take care of D3 ? Also, with swsusp, we | 2415 | * can properly take care of D3 ? Also, with swsusp, we |
@@ -2476,6 +2476,11 @@ static int aty128_do_resume(struct pci_dev *pdev) | |||
2476 | if (pdev->dev.power.power_state.event == PM_EVENT_ON) | 2476 | if (pdev->dev.power.power_state.event == PM_EVENT_ON) |
2477 | return 0; | 2477 | return 0; |
2478 | 2478 | ||
2479 | /* PCI state will have been restored by the core, so | ||
2480 | * we should be in D0 now with our config space fully | ||
2481 | * restored | ||
2482 | */ | ||
2483 | |||
2479 | /* Wakeup chip */ | 2484 | /* Wakeup chip */ |
2480 | aty128_set_suspend(par, 0); | 2485 | aty128_set_suspend(par, 0); |
2481 | par->asleep = 0; | 2486 | par->asleep = 0; |