pwm-lpss-platform.c 1.7 KB

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