pwm-lpss-platform.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Intel Low Power Subsystem PWM controller 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/acpi.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/pm_runtime.h>
  17. #include "pwm-lpss.h"
  18. /* BayTrail */
  19. static const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
  20. .clk_rate = 25000000,
  21. .npwm = 1,
  22. .base_unit_bits = 16,
  23. };
  24. /* Braswell */
  25. static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
  26. .clk_rate = 19200000,
  27. .npwm = 1,
  28. .base_unit_bits = 16,
  29. };
  30. /* Broxton */
  31. static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
  32. .clk_rate = 19200000,
  33. .npwm = 4,
  34. .base_unit_bits = 22,
  35. };
  36. static int pwm_lpss_probe_platform(struct platform_device *pdev)
  37. {
  38. const struct pwm_lpss_boardinfo *info;
  39. const struct acpi_device_id *id;
  40. struct pwm_lpss_chip *lpwm;
  41. struct resource *r;
  42. id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
  43. if (!id)
  44. return -ENODEV;
  45. info = (const struct pwm_lpss_boardinfo *)id->driver_data;
  46. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  47. lpwm = pwm_lpss_probe(&pdev->dev, r, info);
  48. if (IS_ERR(lpwm))
  49. return PTR_ERR(lpwm);
  50. platform_set_drvdata(pdev, lpwm);
  51. pm_runtime_set_active(&pdev->dev);
  52. pm_runtime_enable(&pdev->dev);
  53. return 0;
  54. }
  55. static int pwm_lpss_remove_platform(struct platform_device *pdev)
  56. {
  57. struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev);
  58. pm_runtime_disable(&pdev->dev);
  59. return pwm_lpss_remove(lpwm);
  60. }
  61. static const struct acpi_device_id pwm_lpss_acpi_match[] = {
  62. { "80860F09", (unsigned long)&pwm_lpss_byt_info },
  63. { "80862288", (unsigned long)&pwm_lpss_bsw_info },
  64. { "80865AC8", (unsigned long)&pwm_lpss_bxt_info },
  65. { },
  66. };
  67. MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
  68. static struct platform_driver pwm_lpss_driver_platform = {
  69. .driver = {
  70. .name = "pwm-lpss",
  71. .acpi_match_table = pwm_lpss_acpi_match,
  72. },
  73. .probe = pwm_lpss_probe_platform,
  74. .remove = pwm_lpss_remove_platform,
  75. };
  76. module_platform_driver(pwm_lpss_driver_platform);
  77. MODULE_DESCRIPTION("PWM platform driver for Intel LPSS");
  78. MODULE_LICENSE("GPL v2");
  79. MODULE_ALIAS("platform:pwm-lpss");