.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License as published by |
---|
6 | | - * the Free Software Foundation; version 2 of the License. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License |
---|
14 | | - * along with this program; if not, write to the Free Software |
---|
15 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
---|
16 | 4 | */ |
---|
17 | 5 | |
---|
18 | 6 | #include <linux/module.h> |
---|
.. | .. |
---|
147 | 135 | |
---|
148 | 136 | /** |
---|
149 | 137 | * pch_phub_read_modify_write_reg() - Reading modifying and writing register |
---|
| 138 | + * @chip: Pointer to the PHUB register structure |
---|
150 | 139 | * @reg_addr_offset: Register offset address value. |
---|
151 | 140 | * @data: Writing value. |
---|
152 | 141 | * @mask: Mask value. |
---|
.. | .. |
---|
159 | 148 | iowrite32(((ioread32(reg_addr) & ~mask)) | data, reg_addr); |
---|
160 | 149 | } |
---|
161 | 150 | |
---|
162 | | -#ifdef CONFIG_PM |
---|
163 | 151 | /* pch_phub_save_reg_conf - saves register configuration */ |
---|
164 | | -static void pch_phub_save_reg_conf(struct pci_dev *pdev) |
---|
| 152 | +static void __maybe_unused pch_phub_save_reg_conf(struct pci_dev *pdev) |
---|
165 | 153 | { |
---|
166 | 154 | unsigned int i; |
---|
167 | 155 | struct pch_phub_reg *chip = pci_get_drvdata(pdev); |
---|
.. | .. |
---|
222 | 210 | } |
---|
223 | 211 | |
---|
224 | 212 | /* pch_phub_restore_reg_conf - restore register configuration */ |
---|
225 | | -static void pch_phub_restore_reg_conf(struct pci_dev *pdev) |
---|
| 213 | +static void __maybe_unused pch_phub_restore_reg_conf(struct pci_dev *pdev) |
---|
226 | 214 | { |
---|
227 | 215 | unsigned int i; |
---|
228 | 216 | struct pch_phub_reg *chip = pci_get_drvdata(pdev); |
---|
.. | .. |
---|
282 | 270 | if ((chip->ioh_type == 2) || (chip->ioh_type == 4)) |
---|
283 | 271 | iowrite32(chip->funcsel_reg, p + FUNCSEL_REG_OFFSET); |
---|
284 | 272 | } |
---|
285 | | -#endif |
---|
286 | 273 | |
---|
287 | 274 | /** |
---|
288 | 275 | * pch_phub_read_serial_rom() - Reading Serial ROM |
---|
| 276 | + * @chip: Pointer to the PHUB register structure |
---|
289 | 277 | * @offset_address: Serial ROM offset address to read. |
---|
290 | 278 | * @data: Read buffer for specified Serial ROM value. |
---|
291 | 279 | */ |
---|
.. | .. |
---|
300 | 288 | |
---|
301 | 289 | /** |
---|
302 | 290 | * pch_phub_write_serial_rom() - Writing Serial ROM |
---|
| 291 | + * @chip: Pointer to the PHUB register structure |
---|
303 | 292 | * @offset_address: Serial ROM offset address. |
---|
304 | 293 | * @data: Serial ROM value to write. |
---|
305 | 294 | */ |
---|
.. | .. |
---|
338 | 327 | |
---|
339 | 328 | /** |
---|
340 | 329 | * pch_phub_read_serial_rom_val() - Read Serial ROM value |
---|
| 330 | + * @chip: Pointer to the PHUB register structure |
---|
341 | 331 | * @offset_address: Serial ROM address offset value. |
---|
342 | 332 | * @data: Serial ROM value to read. |
---|
343 | 333 | */ |
---|
.. | .. |
---|
354 | 344 | |
---|
355 | 345 | /** |
---|
356 | 346 | * pch_phub_write_serial_rom_val() - writing Serial ROM value |
---|
| 347 | + * @chip: Pointer to the PHUB register structure |
---|
357 | 348 | * @offset_address: Serial ROM address offset value. |
---|
358 | 349 | * @data: Serial ROM value. |
---|
359 | 350 | */ |
---|
.. | .. |
---|
455 | 446 | |
---|
456 | 447 | /** |
---|
457 | 448 | * pch_phub_read_gbe_mac_addr() - Read Gigabit Ethernet MAC address |
---|
458 | | - * @offset_address: Gigabit Ethernet MAC address offset value. |
---|
| 449 | + * @chip: Pointer to the PHUB register structure |
---|
459 | 450 | * @data: Buffer of the Gigabit Ethernet MAC address value. |
---|
460 | 451 | */ |
---|
461 | 452 | static void pch_phub_read_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data) |
---|
.. | .. |
---|
467 | 458 | |
---|
468 | 459 | /** |
---|
469 | 460 | * pch_phub_write_gbe_mac_addr() - Write MAC address |
---|
470 | | - * @offset_address: Gigabit Ethernet MAC address offset value. |
---|
| 461 | + * @chip: Pointer to the PHUB register structure |
---|
471 | 462 | * @data: Gigabit Ethernet MAC address value. |
---|
472 | 463 | */ |
---|
473 | 464 | static int pch_phub_write_gbe_mac_addr(struct pch_phub_reg *chip, u8 *data) |
---|
.. | .. |
---|
847 | 838 | kfree(chip); |
---|
848 | 839 | } |
---|
849 | 840 | |
---|
850 | | -#ifdef CONFIG_PM |
---|
851 | | - |
---|
852 | | -static int pch_phub_suspend(struct pci_dev *pdev, pm_message_t state) |
---|
| 841 | +static int __maybe_unused pch_phub_suspend(struct device *dev_d) |
---|
853 | 842 | { |
---|
854 | | - int ret; |
---|
855 | | - |
---|
856 | | - pch_phub_save_reg_conf(pdev); |
---|
857 | | - ret = pci_save_state(pdev); |
---|
858 | | - if (ret) { |
---|
859 | | - dev_err(&pdev->dev, |
---|
860 | | - " %s -pci_save_state returns %d\n", __func__, ret); |
---|
861 | | - return ret; |
---|
862 | | - } |
---|
863 | | - pci_enable_wake(pdev, PCI_D3hot, 0); |
---|
864 | | - pci_disable_device(pdev); |
---|
865 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
---|
| 843 | + device_wakeup_disable(dev_d); |
---|
866 | 844 | |
---|
867 | 845 | return 0; |
---|
868 | 846 | } |
---|
869 | 847 | |
---|
870 | | -static int pch_phub_resume(struct pci_dev *pdev) |
---|
| 848 | +static int __maybe_unused pch_phub_resume(struct device *dev_d) |
---|
871 | 849 | { |
---|
872 | | - int ret; |
---|
873 | | - |
---|
874 | | - pci_set_power_state(pdev, PCI_D0); |
---|
875 | | - pci_restore_state(pdev); |
---|
876 | | - ret = pci_enable_device(pdev); |
---|
877 | | - if (ret) { |
---|
878 | | - dev_err(&pdev->dev, |
---|
879 | | - "%s-pci_enable_device failed(ret=%d) ", __func__, ret); |
---|
880 | | - return ret; |
---|
881 | | - } |
---|
882 | | - |
---|
883 | | - pci_enable_wake(pdev, PCI_D3hot, 0); |
---|
884 | | - pch_phub_restore_reg_conf(pdev); |
---|
| 850 | + device_wakeup_disable(dev_d); |
---|
885 | 851 | |
---|
886 | 852 | return 0; |
---|
887 | 853 | } |
---|
888 | | -#else |
---|
889 | | -#define pch_phub_suspend NULL |
---|
890 | | -#define pch_phub_resume NULL |
---|
891 | | -#endif /* CONFIG_PM */ |
---|
892 | 854 | |
---|
893 | 855 | static const struct pci_device_id pch_phub_pcidev_id[] = { |
---|
894 | 856 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH1_PHUB), 1, }, |
---|
.. | .. |
---|
900 | 862 | }; |
---|
901 | 863 | MODULE_DEVICE_TABLE(pci, pch_phub_pcidev_id); |
---|
902 | 864 | |
---|
| 865 | +static SIMPLE_DEV_PM_OPS(pch_phub_pm_ops, pch_phub_suspend, pch_phub_resume); |
---|
| 866 | + |
---|
903 | 867 | static struct pci_driver pch_phub_driver = { |
---|
904 | 868 | .name = "pch_phub", |
---|
905 | 869 | .id_table = pch_phub_pcidev_id, |
---|
906 | 870 | .probe = pch_phub_probe, |
---|
907 | 871 | .remove = pch_phub_remove, |
---|
908 | | - .suspend = pch_phub_suspend, |
---|
909 | | - .resume = pch_phub_resume |
---|
| 872 | + .driver.pm = &pch_phub_pm_ops, |
---|
910 | 873 | }; |
---|
911 | 874 | |
---|
912 | 875 | module_pci_driver(pch_phub_driver); |
---|