Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | * |
| 18 | * The Driver with I/O communications via the I2C Interface for ST15 platform. |
| 19 | * And it is only working on the nuvoTon WPCE775x Embedded Controller. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/leds.h> |
| 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <linux/wpce775x.h> |
| 28 | |
| 29 | #define EC_CMD_SET_BACKLIGHT 0xB1 |
| 30 | |
| 31 | static void qci_backlight_store(struct led_classdev *led_cdev, |
| 32 | enum led_brightness val); |
| 33 | |
| 34 | static struct platform_device *bl_pdev; |
| 35 | static struct led_classdev lcd_backlight = { |
| 36 | .name = "lcd-backlight", |
| 37 | .brightness = 147, |
| 38 | .brightness_set = qci_backlight_store, |
| 39 | }; |
| 40 | |
| 41 | static void qci_backlight_store(struct led_classdev *led_cdev, |
| 42 | enum led_brightness val) |
| 43 | { |
| 44 | u16 value = val; |
| 45 | wpce_smbus_write_word_data(EC_CMD_SET_BACKLIGHT, value); |
| 46 | msleep(10); |
| 47 | |
| 48 | dev_dbg(&bl_pdev->dev, "[backlight_store] : value = %d\n", value); |
| 49 | } |
| 50 | |
| 51 | static int __init qci_backlight_init(void) |
| 52 | { |
| 53 | int err = 0; |
| 54 | bl_pdev = platform_device_register_simple("backlight", 0, NULL, 0); |
| 55 | err = led_classdev_register(&bl_pdev->dev, &lcd_backlight); |
| 56 | return err; |
| 57 | } |
| 58 | |
| 59 | static void __exit qci_backlight_exit(void) |
| 60 | { |
| 61 | led_classdev_unregister(&lcd_backlight); |
| 62 | platform_device_unregister(bl_pdev); |
| 63 | } |
| 64 | |
| 65 | module_init(qci_backlight_init); |
| 66 | module_exit(qci_backlight_exit); |
| 67 | |
| 68 | MODULE_AUTHOR("Quanta Computer Inc."); |
| 69 | MODULE_DESCRIPTION("Quanta Embedded Controller I2C Backlight Driver"); |
| 70 | MODULE_LICENSE("GPL v2"); |
| 71 | |