simatic-ipc-leds-gpio-apollolake.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Siemens SIMATIC IPC driver for GPIO based LEDs
  4. *
  5. * Copyright (c) Siemens AG, 2023
  6. *
  7. * Author:
  8. * Henning Schild <henning.schild@siemens.com>
  9. */
  10. #include <linux/gpio/machine.h>
  11. #include <linux/gpio/consumer.h>
  12. #include <linux/leds.h>
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/platform_data/x86/simatic-ipc-base.h>
  16. #include "simatic-ipc-leds-gpio.h"
  17. static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
  18. .dev_id = "leds-gpio",
  19. .table = {
  20. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 52, NULL, 0, GPIO_ACTIVE_LOW),
  21. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 53, NULL, 1, GPIO_ACTIVE_LOW),
  22. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 57, NULL, 2, GPIO_ACTIVE_LOW),
  23. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 58, NULL, 3, GPIO_ACTIVE_LOW),
  24. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 60, NULL, 4, GPIO_ACTIVE_LOW),
  25. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 5, GPIO_ACTIVE_LOW),
  26. {} /* Terminating entry */
  27. },
  28. };
  29. static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = {
  30. .dev_id = NULL, /* Filled during initialization */
  31. .table = {
  32. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW),
  33. GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH),
  34. {} /* Terminating entry */
  35. },
  36. };
  37. static int simatic_ipc_leds_gpio_apollolake_probe(struct platform_device *pdev)
  38. {
  39. return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table,
  40. &simatic_ipc_led_gpio_table_extra);
  41. }
  42. static void simatic_ipc_leds_gpio_apollolake_remove(struct platform_device *pdev)
  43. {
  44. simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table,
  45. &simatic_ipc_led_gpio_table_extra);
  46. }
  47. static struct platform_driver simatic_ipc_led_gpio_apollolake_driver = {
  48. .probe = simatic_ipc_leds_gpio_apollolake_probe,
  49. .remove_new = simatic_ipc_leds_gpio_apollolake_remove,
  50. .driver = {
  51. .name = KBUILD_MODNAME,
  52. },
  53. };
  54. module_platform_driver(simatic_ipc_led_gpio_apollolake_driver);
  55. MODULE_DESCRIPTION("LED driver for Siemens Simatic IPCs based on Intel Apollo Lake GPIO");
  56. MODULE_LICENSE("GPL v2");
  57. MODULE_ALIAS("platform:" KBUILD_MODNAME);
  58. MODULE_SOFTDEP("pre: simatic-ipc-leds-gpio-core platform:apollolake-pinctrl");
  59. MODULE_AUTHOR("Henning Schild <henning.schild@siemens.com>");