pwm-lpss-pci.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Intel Low Power Subsystem PWM controller PCI driver
  3. *
  4. * Copyright (C) 2014, Intel Corporation
  5. *
  6. * Derived from the original pwm-lpss.c
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/pci.h>
  15. #include <linux/pm_runtime.h>
  16. #include "pwm-lpss.h"
  17. static int pwm_lpss_probe_pci(struct pci_dev *pdev,
  18. const struct pci_device_id *id)
  19. {
  20. const struct pwm_lpss_boardinfo *info;
  21. struct pwm_lpss_chip *lpwm;
  22. int err;
  23. err = pcim_enable_device(pdev);
  24. if (err < 0)
  25. return err;
  26. info = (struct pwm_lpss_boardinfo *)id->driver_data;
  27. lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info);
  28. if (IS_ERR(lpwm))
  29. return PTR_ERR(lpwm);
  30. pci_set_drvdata(pdev, lpwm);
  31. pm_runtime_put(&pdev->dev);
  32. pm_runtime_allow(&pdev->dev);
  33. return 0;
  34. }
  35. static void pwm_lpss_remove_pci(struct pci_dev *pdev)
  36. {
  37. struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev);
  38. pm_runtime_forbid(&pdev->dev);
  39. pm_runtime_get_sync(&pdev->dev);
  40. pwm_lpss_remove(lpwm);
  41. }
  42. #ifdef CONFIG_PM
  43. static int pwm_lpss_runtime_suspend_pci(struct device *dev)
  44. {
  45. /*
  46. * The PCI core will handle transition to D3 automatically. We only
  47. * need to provide runtime PM hooks for that to happen.
  48. */
  49. return 0;
  50. }
  51. static int pwm_lpss_runtime_resume_pci(struct device *dev)
  52. {
  53. return 0;
  54. }
  55. #endif
  56. static const struct dev_pm_ops pwm_lpss_pci_pm = {
  57. SET_RUNTIME_PM_OPS(pwm_lpss_runtime_suspend_pci,
  58. pwm_lpss_runtime_resume_pci, NULL)
  59. };
  60. static const struct pci_device_id pwm_lpss_pci_ids[] = {
  61. { PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info},
  62. { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
  63. { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
  64. { PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_bxt_info},
  65. { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
  66. { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
  67. { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
  68. { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info},
  69. { },
  70. };
  71. MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids);
  72. static struct pci_driver pwm_lpss_driver_pci = {
  73. .name = "pwm-lpss",
  74. .id_table = pwm_lpss_pci_ids,
  75. .probe = pwm_lpss_probe_pci,
  76. .remove = pwm_lpss_remove_pci,
  77. .driver = {
  78. .pm = &pwm_lpss_pci_pm,
  79. },
  80. };
  81. module_pci_driver(pwm_lpss_driver_pci);
  82. MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS");
  83. MODULE_LICENSE("GPL v2");