pwm-lpss-pci.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Intel Low Power Subsystem PWM controller PCI driver
  4. *
  5. * Copyright (C) 2014, Intel Corporation
  6. *
  7. * Derived from the original pwm-lpss.c
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <linux/pci.h>
  12. #include <linux/pm_runtime.h>
  13. #include "pwm-lpss.h"
  14. static int pwm_lpss_probe_pci(struct pci_dev *pdev,
  15. const struct pci_device_id *id)
  16. {
  17. const struct pwm_lpss_boardinfo *info;
  18. void __iomem *io_base;
  19. struct pwm_chip *chip;
  20. int err;
  21. err = pcim_enable_device(pdev);
  22. if (err < 0)
  23. return err;
  24. io_base = pcim_iomap_region(pdev, 0, "pwm-lpss");
  25. if (IS_ERR(io_base))
  26. return PTR_ERR(io_base);
  27. info = (struct pwm_lpss_boardinfo *)id->driver_data;
  28. chip = devm_pwm_lpss_probe(&pdev->dev, io_base, info);
  29. if (IS_ERR(chip))
  30. return PTR_ERR(chip);
  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. pm_runtime_forbid(&pdev->dev);
  38. pm_runtime_get_sync(&pdev->dev);
  39. }
  40. static const struct pci_device_id pwm_lpss_pci_ids[] = {
  41. { PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info},
  42. { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
  43. { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
  44. { PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info},
  45. { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
  46. { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
  47. { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
  48. { PCI_VDEVICE(INTEL, 0x31c8), (unsigned long)&pwm_lpss_bxt_info},
  49. { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info},
  50. { },
  51. };
  52. MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids);
  53. static struct pci_driver pwm_lpss_driver_pci = {
  54. .name = "pwm-lpss",
  55. .id_table = pwm_lpss_pci_ids,
  56. .probe = pwm_lpss_probe_pci,
  57. .remove = pwm_lpss_remove_pci,
  58. };
  59. module_pci_driver(pwm_lpss_driver_pci);
  60. MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS");
  61. MODULE_LICENSE("GPL v2");
  62. MODULE_IMPORT_NS("PWM_LPSS");