leds-qci-backlight.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Quanta I2C Backlight Driver
  2. *
  3. * Copyright (C) 2009 Quanta Computer Inc.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. /*
  16. *
  17. * The Driver with I/O communications via the I2C Interface for ST15 platform.
  18. * And it is only working on the nuvoTon WPCE775x Embedded Controller.
  19. *
  20. */
  21. #include <linux/module.h>
  22. #include <linux/leds.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/delay.h>
  25. #include <linux/wpce775x.h>
  26. #define EC_CMD_SET_BACKLIGHT 0xB1
  27. static void qci_backlight_store(struct led_classdev *led_cdev,
  28. enum led_brightness val);
  29. static struct platform_device *bl_pdev;
  30. static struct led_classdev lcd_backlight = {
  31. .name = "lcd-backlight",
  32. .brightness = 147,
  33. .brightness_set = qci_backlight_store,
  34. };
  35. static void qci_backlight_store(struct led_classdev *led_cdev,
  36. enum led_brightness val)
  37. {
  38. u16 value = val;
  39. wpce_smbus_write_word_data(EC_CMD_SET_BACKLIGHT, value);
  40. msleep(10);
  41. dev_dbg(&bl_pdev->dev, "[backlight_store] : value = %d\n", value);
  42. }
  43. static int __init qci_backlight_init(void)
  44. {
  45. int err = 0;
  46. bl_pdev = platform_device_register_simple("backlight", 0, NULL, 0);
  47. err = led_classdev_register(&bl_pdev->dev, &lcd_backlight);
  48. return err;
  49. }
  50. static void __exit qci_backlight_exit(void)
  51. {
  52. led_classdev_unregister(&lcd_backlight);
  53. platform_device_unregister(bl_pdev);
  54. }
  55. module_init(qci_backlight_init);
  56. module_exit(qci_backlight_exit);
  57. MODULE_AUTHOR("Quanta Computer Inc.");
  58. MODULE_DESCRIPTION("Quanta Embedded Controller I2C Backlight Driver");
  59. MODULE_LICENSE("GPL v2");