pwm-lpss-platform.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 const struct acpi_device_id pwm_lpss_acpi_match[] = {
  44. { "80860F09", (unsigned long)&pwm_lpss_byt_info },
  45. { "80862288", (unsigned long)&pwm_lpss_bsw_info },
  46. { "80865AC8", (unsigned long)&pwm_lpss_bxt_info },
  47. { },
  48. };
  49. MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
  50. static struct platform_driver pwm_lpss_driver_platform = {
  51. .driver = {
  52. .name = "pwm-lpss",
  53. .acpi_match_table = pwm_lpss_acpi_match,
  54. },
  55. .probe = pwm_lpss_probe_platform,
  56. .remove = pwm_lpss_remove_platform,
  57. };
  58. module_platform_driver(pwm_lpss_driver_platform);
  59. MODULE_DESCRIPTION("PWM platform driver for Intel LPSS");
  60. MODULE_LICENSE("GPL v2");
  61. MODULE_ALIAS("platform:pwm-lpss");