pwm-lpss-platform.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. .bypass = true,
  36. };
  37. static int pwm_lpss_probe_platform(struct platform_device *pdev)
  38. {
  39. const struct pwm_lpss_boardinfo *info;
  40. const struct acpi_device_id *id;
  41. struct pwm_lpss_chip *lpwm;
  42. struct resource *r;
  43. id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
  44. if (!id)
  45. return -ENODEV;
  46. info = (const struct pwm_lpss_boardinfo *)id->driver_data;
  47. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  48. lpwm = pwm_lpss_probe(&pdev->dev, r, info);
  49. if (IS_ERR(lpwm))
  50. return PTR_ERR(lpwm);
  51. platform_set_drvdata(pdev, lpwm);
  52. pm_runtime_set_active(&pdev->dev);
  53. pm_runtime_enable(&pdev->dev);
  54. return 0;
  55. }
  56. static int pwm_lpss_remove_platform(struct platform_device *pdev)
  57. {
  58. struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev);
  59. pm_runtime_disable(&pdev->dev);
  60. return pwm_lpss_remove(lpwm);
  61. }
  62. static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops,
  63. pwm_lpss_suspend,
  64. pwm_lpss_resume);
  65. static const struct acpi_device_id pwm_lpss_acpi_match[] = {
  66. { "80860F09", (unsigned long)&pwm_lpss_byt_info },
  67. { "80862288", (unsigned long)&pwm_lpss_bsw_info },
  68. { "80865AC8", (unsigned long)&pwm_lpss_bxt_info },
  69. { },
  70. };
  71. MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
  72. static struct platform_driver pwm_lpss_driver_platform = {
  73. .driver = {
  74. .name = "pwm-lpss",
  75. .acpi_match_table = pwm_lpss_acpi_match,
  76. .pm = &pwm_lpss_platform_pm_ops,
  77. },
  78. .probe = pwm_lpss_probe_platform,
  79. .remove = pwm_lpss_remove_platform,
  80. };
  81. module_platform_driver(pwm_lpss_driver_platform);
  82. MODULE_DESCRIPTION("PWM platform driver for Intel LPSS");
  83. MODULE_LICENSE("GPL v2");
  84. MODULE_ALIAS("platform:pwm-lpss");