pwm-lpss-platform.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. static int pwm_lpss_probe_platform(struct platform_device *pdev)
  19. {
  20. const struct pwm_lpss_boardinfo *info;
  21. const struct acpi_device_id *id;
  22. struct pwm_lpss_chip *lpwm;
  23. struct resource *r;
  24. id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
  25. if (!id)
  26. return -ENODEV;
  27. info = (const struct pwm_lpss_boardinfo *)id->driver_data;
  28. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  29. lpwm = pwm_lpss_probe(&pdev->dev, r, info);
  30. if (IS_ERR(lpwm))
  31. return PTR_ERR(lpwm);
  32. platform_set_drvdata(pdev, lpwm);
  33. pm_runtime_set_active(&pdev->dev);
  34. pm_runtime_enable(&pdev->dev);
  35. return 0;
  36. }
  37. static int pwm_lpss_remove_platform(struct platform_device *pdev)
  38. {
  39. struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev);
  40. pm_runtime_disable(&pdev->dev);
  41. return pwm_lpss_remove(lpwm);
  42. }
  43. static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops,
  44. pwm_lpss_suspend,
  45. pwm_lpss_resume);
  46. static const struct acpi_device_id pwm_lpss_acpi_match[] = {
  47. { "80860F09", (unsigned long)&pwm_lpss_byt_info },
  48. { "80862288", (unsigned long)&pwm_lpss_bsw_info },
  49. { "80865AC8", (unsigned long)&pwm_lpss_bxt_info },
  50. { },
  51. };
  52. MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
  53. static struct platform_driver pwm_lpss_driver_platform = {
  54. .driver = {
  55. .name = "pwm-lpss",
  56. .acpi_match_table = pwm_lpss_acpi_match,
  57. .pm = &pwm_lpss_platform_pm_ops,
  58. },
  59. .probe = pwm_lpss_probe_platform,
  60. .remove = pwm_lpss_remove_platform,
  61. };
  62. module_platform_driver(pwm_lpss_driver_platform);
  63. MODULE_DESCRIPTION("PWM platform driver for Intel LPSS");
  64. MODULE_LICENSE("GPL v2");
  65. MODULE_ALIAS("platform:pwm-lpss");