| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * PTP 1588 clock using the EG20T PCH |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (C) 2011-2012 LAPIS SEMICONDUCTOR Co., LTD. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * This code was derived from the IXP46X driver. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; version 2 of the License. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License |
|---|
| 19 | | - * along with this program; if not, write to the Free Software |
|---|
| 20 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 21 | 9 | */ |
|---|
| 22 | 10 | |
|---|
| 23 | 11 | #include <linux/device.h> |
|---|
| .. | .. |
|---|
| 520 | 508 | .enable = ptp_pch_enable, |
|---|
| 521 | 509 | }; |
|---|
| 522 | 510 | |
|---|
| 523 | | - |
|---|
| 524 | | -#ifdef CONFIG_PM |
|---|
| 525 | | -static s32 pch_suspend(struct pci_dev *pdev, pm_message_t state) |
|---|
| 526 | | -{ |
|---|
| 527 | | - pci_disable_device(pdev); |
|---|
| 528 | | - pci_enable_wake(pdev, PCI_D3hot, 0); |
|---|
| 529 | | - |
|---|
| 530 | | - if (pci_save_state(pdev) != 0) { |
|---|
| 531 | | - dev_err(&pdev->dev, "could not save PCI config state\n"); |
|---|
| 532 | | - return -ENOMEM; |
|---|
| 533 | | - } |
|---|
| 534 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
|---|
| 535 | | - |
|---|
| 536 | | - return 0; |
|---|
| 537 | | -} |
|---|
| 538 | | - |
|---|
| 539 | | -static s32 pch_resume(struct pci_dev *pdev) |
|---|
| 540 | | -{ |
|---|
| 541 | | - s32 ret; |
|---|
| 542 | | - |
|---|
| 543 | | - pci_set_power_state(pdev, PCI_D0); |
|---|
| 544 | | - pci_restore_state(pdev); |
|---|
| 545 | | - ret = pci_enable_device(pdev); |
|---|
| 546 | | - if (ret) { |
|---|
| 547 | | - dev_err(&pdev->dev, "pci_enable_device failed\n"); |
|---|
| 548 | | - return ret; |
|---|
| 549 | | - } |
|---|
| 550 | | - pci_enable_wake(pdev, PCI_D3hot, 0); |
|---|
| 551 | | - return 0; |
|---|
| 552 | | -} |
|---|
| 553 | | -#else |
|---|
| 554 | 511 | #define pch_suspend NULL |
|---|
| 555 | 512 | #define pch_resume NULL |
|---|
| 556 | | -#endif |
|---|
| 557 | 513 | |
|---|
| 558 | 514 | static void pch_remove(struct pci_dev *pdev) |
|---|
| 559 | 515 | { |
|---|
| .. | .. |
|---|
| 697 | 653 | }; |
|---|
| 698 | 654 | MODULE_DEVICE_TABLE(pci, pch_ieee1588_pcidev_id); |
|---|
| 699 | 655 | |
|---|
| 656 | +static SIMPLE_DEV_PM_OPS(pch_pm_ops, pch_suspend, pch_resume); |
|---|
| 657 | + |
|---|
| 700 | 658 | static struct pci_driver pch_driver = { |
|---|
| 701 | 659 | .name = KBUILD_MODNAME, |
|---|
| 702 | 660 | .id_table = pch_ieee1588_pcidev_id, |
|---|
| 703 | 661 | .probe = pch_probe, |
|---|
| 704 | 662 | .remove = pch_remove, |
|---|
| 705 | | - .suspend = pch_suspend, |
|---|
| 706 | | - .resume = pch_resume, |
|---|
| 663 | + .driver.pm = &pch_pm_ops, |
|---|
| 707 | 664 | }; |
|---|
| 708 | 665 | |
|---|
| 709 | 666 | static void __exit ptp_pch_exit(void) |
|---|