Commit 226e6b86 authored by Andy Shevchenko's avatar Andy Shevchenko

gpio: pch: Convert to dev_pm_ops

Convert the legacy system PM callbacks to new ones. Meanwhile, remove the
redundant calls to the PCI for changing a power state since it's done by bus
code.

While here, remove weird indentation with backslash in use.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 9381fc5d
...@@ -171,11 +171,10 @@ static int pch_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) ...@@ -171,11 +171,10 @@ static int pch_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
return 0; return 0;
} }
#ifdef CONFIG_PM
/* /*
* Save register configuration and disable interrupts. * Save register configuration and disable interrupts.
*/ */
static void pch_gpio_save_reg_conf(struct pch_gpio *chip) static void __maybe_unused pch_gpio_save_reg_conf(struct pch_gpio *chip)
{ {
chip->pch_gpio_reg.ien_reg = ioread32(&chip->reg->ien); chip->pch_gpio_reg.ien_reg = ioread32(&chip->reg->ien);
chip->pch_gpio_reg.imask_reg = ioread32(&chip->reg->imask); chip->pch_gpio_reg.imask_reg = ioread32(&chip->reg->imask);
...@@ -185,14 +184,13 @@ static void pch_gpio_save_reg_conf(struct pch_gpio *chip) ...@@ -185,14 +184,13 @@ static void pch_gpio_save_reg_conf(struct pch_gpio *chip)
if (chip->ioh == INTEL_EG20T_PCH) if (chip->ioh == INTEL_EG20T_PCH)
chip->pch_gpio_reg.im1_reg = ioread32(&chip->reg->im1); chip->pch_gpio_reg.im1_reg = ioread32(&chip->reg->im1);
if (chip->ioh == OKISEMI_ML7223n_IOH) if (chip->ioh == OKISEMI_ML7223n_IOH)
chip->pch_gpio_reg.gpio_use_sel_reg =\ chip->pch_gpio_reg.gpio_use_sel_reg = ioread32(&chip->reg->gpio_use_sel);
ioread32(&chip->reg->gpio_use_sel);
} }
/* /*
* This function restores the register configuration of the GPIO device. * This function restores the register configuration of the GPIO device.
*/ */
static void pch_gpio_restore_reg_conf(struct pch_gpio *chip) static void __maybe_unused pch_gpio_restore_reg_conf(struct pch_gpio *chip)
{ {
iowrite32(chip->pch_gpio_reg.ien_reg, &chip->reg->ien); iowrite32(chip->pch_gpio_reg.ien_reg, &chip->reg->ien);
iowrite32(chip->pch_gpio_reg.imask_reg, &chip->reg->imask); iowrite32(chip->pch_gpio_reg.imask_reg, &chip->reg->imask);
...@@ -204,10 +202,8 @@ static void pch_gpio_restore_reg_conf(struct pch_gpio *chip) ...@@ -204,10 +202,8 @@ static void pch_gpio_restore_reg_conf(struct pch_gpio *chip)
if (chip->ioh == INTEL_EG20T_PCH) if (chip->ioh == INTEL_EG20T_PCH)
iowrite32(chip->pch_gpio_reg.im1_reg, &chip->reg->im1); iowrite32(chip->pch_gpio_reg.im1_reg, &chip->reg->im1);
if (chip->ioh == OKISEMI_ML7223n_IOH) if (chip->ioh == OKISEMI_ML7223n_IOH)
iowrite32(chip->pch_gpio_reg.gpio_use_sel_reg, iowrite32(chip->pch_gpio_reg.gpio_use_sel_reg, &chip->reg->gpio_use_sel);
&chip->reg->gpio_use_sel);
} }
#endif
static int pch_gpio_to_irq(struct gpio_chip *gpio, unsigned offset) static int pch_gpio_to_irq(struct gpio_chip *gpio, unsigned offset)
{ {
...@@ -431,10 +427,9 @@ static int pch_gpio_probe(struct pci_dev *pdev, ...@@ -431,10 +427,9 @@ static int pch_gpio_probe(struct pci_dev *pdev,
return pch_gpio_alloc_generic_chip(chip, irq_base, gpio_pins[chip->ioh]); return pch_gpio_alloc_generic_chip(chip, irq_base, gpio_pins[chip->ioh]);
} }
#ifdef CONFIG_PM static int __maybe_unused pch_gpio_suspend(struct device *dev)
static int pch_gpio_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
s32 ret; struct pci_dev *pdev = to_pci_dev(dev);
struct pch_gpio *chip = pci_get_drvdata(pdev); struct pch_gpio *chip = pci_get_drvdata(pdev);
unsigned long flags; unsigned long flags;
...@@ -442,36 +437,15 @@ static int pch_gpio_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -442,36 +437,15 @@ static int pch_gpio_suspend(struct pci_dev *pdev, pm_message_t state)
pch_gpio_save_reg_conf(chip); pch_gpio_save_reg_conf(chip);
spin_unlock_irqrestore(&chip->spinlock, flags); spin_unlock_irqrestore(&chip->spinlock, flags);
ret = pci_save_state(pdev);
if (ret) {
dev_err(&pdev->dev, "pci_save_state Failed-%d\n", ret);
return ret;
}
pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D0);
ret = pci_enable_wake(pdev, PCI_D0, 1);
if (ret)
dev_err(&pdev->dev, "pci_enable_wake Failed -%d\n", ret);
return 0; return 0;
} }
static int pch_gpio_resume(struct pci_dev *pdev) static int __maybe_unused pch_gpio_resume(struct device *dev)
{ {
s32 ret; struct pci_dev *pdev = to_pci_dev(dev);
struct pch_gpio *chip = pci_get_drvdata(pdev); struct pch_gpio *chip = pci_get_drvdata(pdev);
unsigned long flags; unsigned long flags;
ret = pci_enable_wake(pdev, PCI_D0, 0);
pci_set_power_state(pdev, PCI_D0);
ret = pci_enable_device(pdev);
if (ret) {
dev_err(&pdev->dev, "pci_enable_device Failed-%d ", ret);
return ret;
}
pci_restore_state(pdev);
spin_lock_irqsave(&chip->spinlock, flags); spin_lock_irqsave(&chip->spinlock, flags);
iowrite32(0x01, &chip->reg->reset); iowrite32(0x01, &chip->reg->reset);
iowrite32(0x00, &chip->reg->reset); iowrite32(0x00, &chip->reg->reset);
...@@ -480,10 +454,8 @@ static int pch_gpio_resume(struct pci_dev *pdev) ...@@ -480,10 +454,8 @@ static int pch_gpio_resume(struct pci_dev *pdev)
return 0; return 0;
} }
#else
#define pch_gpio_suspend NULL static SIMPLE_DEV_PM_OPS(pch_gpio_pm_ops, pch_gpio_suspend, pch_gpio_resume);
#define pch_gpio_resume NULL
#endif
#define PCI_VENDOR_ID_ROHM 0x10DB #define PCI_VENDOR_ID_ROHM 0x10DB
static const struct pci_device_id pch_gpio_pcidev_id[] = { static const struct pci_device_id pch_gpio_pcidev_id[] = {
...@@ -499,8 +471,9 @@ static struct pci_driver pch_gpio_driver = { ...@@ -499,8 +471,9 @@ static struct pci_driver pch_gpio_driver = {
.name = "pch_gpio", .name = "pch_gpio",
.id_table = pch_gpio_pcidev_id, .id_table = pch_gpio_pcidev_id,
.probe = pch_gpio_probe, .probe = pch_gpio_probe,
.suspend = pch_gpio_suspend, .driver = {
.resume = pch_gpio_resume .pm = &pch_gpio_pm_ops,
},
}; };
module_pci_driver(pch_gpio_driver); module_pci_driver(pch_gpio_driver);
......
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