Commit 348b2956 authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by Bartlomiej Zolnierkiewicz

fbdev: aty: use generic power management

Drivers should do only device-specific jobs. But in general, drivers using
legacy PCI PM framework for .suspend()/.resume() have to manage many PCI
PM-related tasks themselves which can be done by PCI Core itself. This
brings extra load on the driver and it directly calls PCI helper functions
to handle them.

Switch to the new generic framework by updating function signatures and
define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove
unnecessary calls to the PCI Helper functions along with the legacy
.suspend & .resume bindings.

Now,
- atyfb_pci_suspend() had a "pm_message_t" type parameter as per legacy
  PCI PM framework, that got deprecated in generic.
- Rename the callback as atyfb_pci_suspend_late() and preserve the
  parameter.
- Define 3 new callbacks as:
        * atyfb_pci_suspend()
        * atyfb_pci_freeze()
        * atyfb_pci_hibernate()
  which in turn call atyfb_pci_suspend_late() by passing appropriate
  value for "pm_message_t" type parameter.
- Bind the callbacks in "struct dev_pm_ops" type variable
  "atyfb_pci_pm_ops".
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Bjorn Helgaas <bjorn@helgaas.com>
Cc: Vaibhav Gupta <vaibhav.varodek@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Andres Salomon <dilinger@queued.net>
CC: Antonino Daplas <adaplas@gmail.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200819185654.151170-5-vaibhavgupta40@gmail.com
parent ab5fe88a
...@@ -132,8 +132,8 @@ ...@@ -132,8 +132,8 @@
#define PRINTKI(fmt, args...) printk(KERN_INFO "atyfb: " fmt, ## args) #define PRINTKI(fmt, args...) printk(KERN_INFO "atyfb: " fmt, ## args)
#define PRINTKE(fmt, args...) printk(KERN_ERR "atyfb: " fmt, ## args) #define PRINTKE(fmt, args...) printk(KERN_ERR "atyfb: " fmt, ## args)
#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \ #if defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_GENERIC_LCD) || \
defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT) defined(CONFIG_FB_ATY_BACKLIGHT)
static const u32 lt_lcd_regs[] = { static const u32 lt_lcd_regs[] = {
CNFG_PANEL_LG, CNFG_PANEL_LG,
LCD_GEN_CNTL_LG, LCD_GEN_CNTL_LG,
...@@ -175,7 +175,7 @@ u32 aty_ld_lcd(int index, const struct atyfb_par *par) ...@@ -175,7 +175,7 @@ u32 aty_ld_lcd(int index, const struct atyfb_par *par)
return aty_ld_le32(LCD_DATA, par); return aty_ld_le32(LCD_DATA, par);
} }
} }
#endif /* defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */ #endif /* defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */
#ifdef CONFIG_FB_ATY_GENERIC_LCD #ifdef CONFIG_FB_ATY_GENERIC_LCD
/* /*
...@@ -1989,7 +1989,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1989,7 +1989,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
#if defined(CONFIG_PM) && defined(CONFIG_PCI) #if defined(CONFIG_PCI)
#ifdef CONFIG_PPC_PMAC #ifdef CONFIG_PPC_PMAC
/* Power management routines. Those are used for PowerBook sleep. /* Power management routines. Those are used for PowerBook sleep.
...@@ -2050,8 +2050,9 @@ static int aty_power_mgmt(int sleep, struct atyfb_par *par) ...@@ -2050,8 +2050,9 @@ static int aty_power_mgmt(int sleep, struct atyfb_par *par)
} }
#endif /* CONFIG_PPC_PMAC */ #endif /* CONFIG_PPC_PMAC */
static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) static int atyfb_pci_suspend_late(struct device *dev, pm_message_t state)
{ {
struct pci_dev *pdev = to_pci_dev(dev);
struct fb_info *info = pci_get_drvdata(pdev); struct fb_info *info = pci_get_drvdata(pdev);
struct atyfb_par *par = (struct atyfb_par *) info->par; struct atyfb_par *par = (struct atyfb_par *) info->par;
...@@ -2077,7 +2078,6 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2077,7 +2078,6 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
* first save the config space content so the core can * first save the config space content so the core can
* restore it properly on resume. * restore it properly on resume.
*/ */
pci_save_state(pdev);
#ifdef CONFIG_PPC_PMAC #ifdef CONFIG_PPC_PMAC
/* Set chip to "suspend" mode */ /* Set chip to "suspend" mode */
...@@ -2089,8 +2089,6 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2089,8 +2089,6 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
console_unlock(); console_unlock();
return -EIO; return -EIO;
} }
#else
pci_set_power_state(pdev, pci_choose_state(pdev, state));
#endif #endif
console_unlock(); console_unlock();
...@@ -2100,6 +2098,21 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2100,6 +2098,21 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
return 0; return 0;
} }
static int __maybe_unused atyfb_pci_suspend(struct device *dev)
{
return atyfb_pci_suspend_late(dev, PMSG_SUSPEND);
}
static int __maybe_unused atyfb_pci_hibernate(struct device *dev)
{
return atyfb_pci_suspend_late(dev, PMSG_HIBERNATE);
}
static int __maybe_unused atyfb_pci_freeze(struct device *dev)
{
return atyfb_pci_suspend_late(dev, PMSG_FREEZE);
}
static void aty_resume_chip(struct fb_info *info) static void aty_resume_chip(struct fb_info *info)
{ {
struct atyfb_par *par = info->par; struct atyfb_par *par = info->par;
...@@ -2114,8 +2127,9 @@ static void aty_resume_chip(struct fb_info *info) ...@@ -2114,8 +2127,9 @@ static void aty_resume_chip(struct fb_info *info)
aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par); aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
} }
static int atyfb_pci_resume(struct pci_dev *pdev) static int __maybe_unused atyfb_pci_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev);
struct fb_info *info = pci_get_drvdata(pdev); struct fb_info *info = pci_get_drvdata(pdev);
struct atyfb_par *par = (struct atyfb_par *) info->par; struct atyfb_par *par = (struct atyfb_par *) info->par;
...@@ -2157,7 +2171,18 @@ static int atyfb_pci_resume(struct pci_dev *pdev) ...@@ -2157,7 +2171,18 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
return 0; return 0;
} }
#endif /* defined(CONFIG_PM) && defined(CONFIG_PCI) */ static const struct dev_pm_ops atyfb_pci_pm_ops = {
#ifdef CONFIG_PM_SLEEP
.suspend = atyfb_pci_suspend,
.resume = atyfb_pci_resume,
.freeze = atyfb_pci_freeze,
.thaw = atyfb_pci_resume,
.poweroff = atyfb_pci_hibernate,
.restore = atyfb_pci_resume,
#endif /* CONFIG_PM_SLEEP */
};
#endif /* defined(CONFIG_PCI) */
/* Backlight */ /* Backlight */
#ifdef CONFIG_FB_ATY_BACKLIGHT #ifdef CONFIG_FB_ATY_BACKLIGHT
...@@ -3796,10 +3821,7 @@ static struct pci_driver atyfb_driver = { ...@@ -3796,10 +3821,7 @@ static struct pci_driver atyfb_driver = {
.id_table = atyfb_pci_tbl, .id_table = atyfb_pci_tbl,
.probe = atyfb_pci_probe, .probe = atyfb_pci_probe,
.remove = atyfb_pci_remove, .remove = atyfb_pci_remove,
#ifdef CONFIG_PM .driver.pm = &atyfb_pci_pm_ops,
.suspend = atyfb_pci_suspend,
.resume = atyfb_pci_resume,
#endif /* CONFIG_PM */
}; };
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
......
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