From 7e715c2d9c27c23f3187454157c58cf292ed103e Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Wed, 17 May 2017 21:55:07 +0100 Subject: backlight: Report error on failure It is possible to update the backlight power and the brightness using the sysfs and on writing it either returns the count or if the callback function does not exist then returns the error code 'ENXIO'. We have a situation where the userspace client is writing to the sysfs to update the power and since the callback function exists the client receives the return value as count and considers the operation to be successful. That is correct as the write to the sysfs was successful. But there is no way to know if the actual operation was done or not. backlight_update_status() returns the error code if it fails. Pass that to the userspace client who is trying to update the power so that the client knows that the operation failed. Signed-off-by: Sudip Mukherjee Acked-by: Daniel Thompson Signed-off-by: Lee Jones --- drivers/video/backlight/backlight.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 288318ad21dd..8049e7656daa 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -134,7 +134,7 @@ static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr, { int rc; struct backlight_device *bd = to_backlight_device(dev); - unsigned long power; + unsigned long power, old_power; rc = kstrtoul(buf, 0, &power); if (rc) @@ -145,10 +145,16 @@ static ssize_t bl_power_store(struct device *dev, struct device_attribute *attr, if (bd->ops) { pr_debug("set power to %lu\n", power); if (bd->props.power != power) { + old_power = bd->props.power; bd->props.power = power; - backlight_update_status(bd); + rc = backlight_update_status(bd); + if (rc) + bd->props.power = old_power; + else + rc = count; + } else { + rc = count; } - rc = count; } mutex_unlock(&bd->ops_lock); @@ -176,8 +182,7 @@ int backlight_device_set_brightness(struct backlight_device *bd, else { pr_debug("set brightness to %lu\n", brightness); bd->props.brightness = brightness; - backlight_update_status(bd); - rc = 0; + rc = backlight_update_status(bd); } } mutex_unlock(&bd->ops_lock); -- cgit From 8476d6cde2cd11a2cb87bd7392fc318eec25c8a0 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 22 May 2017 00:09:52 +0200 Subject: backlight: adp8860: Move header file out of I2C realm include/linux/i2c is not for client devices. Move the header file to a more appropriate location. Signed-off-by: Wolfram Sang Acked-by: Daniel Thompson Acked-by: Michael Hennerich Signed-off-by: Lee Jones --- arch/blackfin/mach-bf537/boards/stamp.c | 2 +- drivers/video/backlight/adp8860_bl.c | 2 +- include/linux/i2c/adp8860.h | 154 -------------------------------- include/linux/platform_data/adp8860.h | 154 ++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 156 deletions(-) delete mode 100644 include/linux/i2c/adp8860.h create mode 100644 include/linux/platform_data/adp8860.h diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index eaec7b4832a2..76983dfba324 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -2047,7 +2047,7 @@ static struct adp8870_backlight_platform_data adp8870_pdata = { #endif #if IS_ENABLED(CONFIG_BACKLIGHT_ADP8860) -#include +#include static struct led_info adp8860_leds[] = { { .name = "adp8860-led7", diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 510e559c060e..e7315bf14d60 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -18,7 +18,7 @@ #include #include -#include +#include #define ADP8860_EXT_FEATURES #define ADP8860_USE_LEDS diff --git a/include/linux/i2c/adp8860.h b/include/linux/i2c/adp8860.h deleted file mode 100644 index 0b4d39855c91..000000000000 --- a/include/linux/i2c/adp8860.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Definitions and platform data for Analog Devices - * Backlight drivers ADP8860 - * - * Copyright 2009-2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#ifndef __LINUX_I2C_ADP8860_H -#define __LINUX_I2C_ADP8860_H - -#include -#include - -#define ID_ADP8860 8860 - -#define ADP8860_MAX_BRIGHTNESS 0x7F -#define FLAG_OFFT_SHIFT 8 - -/* - * LEDs subdevice platform data - */ - -#define ADP8860_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT) -#define ADP8860_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT) -#define ADP8860_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT) -#define ADP8860_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT) - -#define ADP8860_LED_ONT_200ms 0 -#define ADP8860_LED_ONT_600ms 1 -#define ADP8860_LED_ONT_800ms 2 -#define ADP8860_LED_ONT_1200ms 3 - -#define ADP8860_LED_D7 (7) -#define ADP8860_LED_D6 (6) -#define ADP8860_LED_D5 (5) -#define ADP8860_LED_D4 (4) -#define ADP8860_LED_D3 (3) -#define ADP8860_LED_D2 (2) -#define ADP8860_LED_D1 (1) - -/* - * Backlight subdevice platform data - */ - -#define ADP8860_BL_D7 (1 << 6) -#define ADP8860_BL_D6 (1 << 5) -#define ADP8860_BL_D5 (1 << 4) -#define ADP8860_BL_D4 (1 << 3) -#define ADP8860_BL_D3 (1 << 2) -#define ADP8860_BL_D2 (1 << 1) -#define ADP8860_BL_D1 (1 << 0) - -#define ADP8860_FADE_T_DIS 0 /* Fade Timer Disabled */ -#define ADP8860_FADE_T_300ms 1 /* 0.3 Sec */ -#define ADP8860_FADE_T_600ms 2 -#define ADP8860_FADE_T_900ms 3 -#define ADP8860_FADE_T_1200ms 4 -#define ADP8860_FADE_T_1500ms 5 -#define ADP8860_FADE_T_1800ms 6 -#define ADP8860_FADE_T_2100ms 7 -#define ADP8860_FADE_T_2400ms 8 -#define ADP8860_FADE_T_2700ms 9 -#define ADP8860_FADE_T_3000ms 10 -#define ADP8860_FADE_T_3500ms 11 -#define ADP8860_FADE_T_4000ms 12 -#define ADP8860_FADE_T_4500ms 13 -#define ADP8860_FADE_T_5000ms 14 -#define ADP8860_FADE_T_5500ms 15 /* 5.5 Sec */ - -#define ADP8860_FADE_LAW_LINEAR 0 -#define ADP8860_FADE_LAW_SQUARE 1 -#define ADP8860_FADE_LAW_CUBIC1 2 -#define ADP8860_FADE_LAW_CUBIC2 3 - -#define ADP8860_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */ -#define ADP8860_BL_AMBL_FILT_160ms 1 -#define ADP8860_BL_AMBL_FILT_320ms 2 -#define ADP8860_BL_AMBL_FILT_640ms 3 -#define ADP8860_BL_AMBL_FILT_1280ms 4 -#define ADP8860_BL_AMBL_FILT_2560ms 5 -#define ADP8860_BL_AMBL_FILT_5120ms 6 -#define ADP8860_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */ - -/* - * Blacklight current 0..30mA - */ -#define ADP8860_BL_CUR_mA(I) ((I * 127) / 30) - -/* - * L2 comparator current 0..1106uA - */ -#define ADP8860_L2_COMP_CURR_uA(I) ((I * 255) / 1106) - -/* - * L3 comparator current 0..138uA - */ -#define ADP8860_L3_COMP_CURR_uA(I) ((I * 255) / 138) - -struct adp8860_backlight_platform_data { - u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */ - - u8 bl_fade_in; /* Backlight Fade-In Timer */ - u8 bl_fade_out; /* Backlight Fade-Out Timer */ - u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */ - - u8 en_ambl_sens; /* 1 = enable ambient light sensor */ - u8 abml_filt; /* Light sensor filter time */ - - u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l2_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l2_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l3_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l3_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - - u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ - u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ - u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ - u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ - - /** - * Independent Current Sinks / LEDS - * Sinks not assigned to the Backlight can be exposed to - * user space using the LEDS CLASS interface - */ - - int num_leds; - struct led_info *leds; - u8 led_fade_in; /* LED Fade-In Timer */ - u8 led_fade_out; /* LED Fade-Out Timer */ - u8 led_fade_law; /* fade-on/fade-off transfer characteristic */ - u8 led_on_time; - - /** - * Gain down disable. Setting this option does not allow the - * charge pump to switch to lower gains. NOT AVAILABLE on ADP8860 - * 1 = the charge pump doesn't switch down in gain until all LEDs are 0. - * The charge pump switches up in gain as needed. This feature is - * useful if the ADP8863 charge pump is used to drive an external load. - * This feature must be used when utilizing small fly capacitors - * (0402 or smaller). - * 0 = the charge pump automatically switches up and down in gain. - * This provides optimal efficiency, but is not suitable for driving - * loads that are not connected through the ADP8863 diode drivers. - * Additionally, the charge pump fly capacitors should be low ESR - * and sized 0603 or greater. - */ - - u8 gdwn_dis; -}; - -#endif /* __LINUX_I2C_ADP8860_H */ diff --git a/include/linux/platform_data/adp8860.h b/include/linux/platform_data/adp8860.h new file mode 100644 index 000000000000..0b4d39855c91 --- /dev/null +++ b/include/linux/platform_data/adp8860.h @@ -0,0 +1,154 @@ +/* + * Definitions and platform data for Analog Devices + * Backlight drivers ADP8860 + * + * Copyright 2009-2010 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef __LINUX_I2C_ADP8860_H +#define __LINUX_I2C_ADP8860_H + +#include +#include + +#define ID_ADP8860 8860 + +#define ADP8860_MAX_BRIGHTNESS 0x7F +#define FLAG_OFFT_SHIFT 8 + +/* + * LEDs subdevice platform data + */ + +#define ADP8860_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT) +#define ADP8860_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT) +#define ADP8860_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT) +#define ADP8860_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT) + +#define ADP8860_LED_ONT_200ms 0 +#define ADP8860_LED_ONT_600ms 1 +#define ADP8860_LED_ONT_800ms 2 +#define ADP8860_LED_ONT_1200ms 3 + +#define ADP8860_LED_D7 (7) +#define ADP8860_LED_D6 (6) +#define ADP8860_LED_D5 (5) +#define ADP8860_LED_D4 (4) +#define ADP8860_LED_D3 (3) +#define ADP8860_LED_D2 (2) +#define ADP8860_LED_D1 (1) + +/* + * Backlight subdevice platform data + */ + +#define ADP8860_BL_D7 (1 << 6) +#define ADP8860_BL_D6 (1 << 5) +#define ADP8860_BL_D5 (1 << 4) +#define ADP8860_BL_D4 (1 << 3) +#define ADP8860_BL_D3 (1 << 2) +#define ADP8860_BL_D2 (1 << 1) +#define ADP8860_BL_D1 (1 << 0) + +#define ADP8860_FADE_T_DIS 0 /* Fade Timer Disabled */ +#define ADP8860_FADE_T_300ms 1 /* 0.3 Sec */ +#define ADP8860_FADE_T_600ms 2 +#define ADP8860_FADE_T_900ms 3 +#define ADP8860_FADE_T_1200ms 4 +#define ADP8860_FADE_T_1500ms 5 +#define ADP8860_FADE_T_1800ms 6 +#define ADP8860_FADE_T_2100ms 7 +#define ADP8860_FADE_T_2400ms 8 +#define ADP8860_FADE_T_2700ms 9 +#define ADP8860_FADE_T_3000ms 10 +#define ADP8860_FADE_T_3500ms 11 +#define ADP8860_FADE_T_4000ms 12 +#define ADP8860_FADE_T_4500ms 13 +#define ADP8860_FADE_T_5000ms 14 +#define ADP8860_FADE_T_5500ms 15 /* 5.5 Sec */ + +#define ADP8860_FADE_LAW_LINEAR 0 +#define ADP8860_FADE_LAW_SQUARE 1 +#define ADP8860_FADE_LAW_CUBIC1 2 +#define ADP8860_FADE_LAW_CUBIC2 3 + +#define ADP8860_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */ +#define ADP8860_BL_AMBL_FILT_160ms 1 +#define ADP8860_BL_AMBL_FILT_320ms 2 +#define ADP8860_BL_AMBL_FILT_640ms 3 +#define ADP8860_BL_AMBL_FILT_1280ms 4 +#define ADP8860_BL_AMBL_FILT_2560ms 5 +#define ADP8860_BL_AMBL_FILT_5120ms 6 +#define ADP8860_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */ + +/* + * Blacklight current 0..30mA + */ +#define ADP8860_BL_CUR_mA(I) ((I * 127) / 30) + +/* + * L2 comparator current 0..1106uA + */ +#define ADP8860_L2_COMP_CURR_uA(I) ((I * 255) / 1106) + +/* + * L3 comparator current 0..138uA + */ +#define ADP8860_L3_COMP_CURR_uA(I) ((I * 255) / 138) + +struct adp8860_backlight_platform_data { + u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */ + + u8 bl_fade_in; /* Backlight Fade-In Timer */ + u8 bl_fade_out; /* Backlight Fade-Out Timer */ + u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */ + + u8 en_ambl_sens; /* 1 = enable ambient light sensor */ + u8 abml_filt; /* Light sensor filter time */ + + u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l2_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l2_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l3_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l3_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + + u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ + u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ + u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ + u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ + + /** + * Independent Current Sinks / LEDS + * Sinks not assigned to the Backlight can be exposed to + * user space using the LEDS CLASS interface + */ + + int num_leds; + struct led_info *leds; + u8 led_fade_in; /* LED Fade-In Timer */ + u8 led_fade_out; /* LED Fade-Out Timer */ + u8 led_fade_law; /* fade-on/fade-off transfer characteristic */ + u8 led_on_time; + + /** + * Gain down disable. Setting this option does not allow the + * charge pump to switch to lower gains. NOT AVAILABLE on ADP8860 + * 1 = the charge pump doesn't switch down in gain until all LEDs are 0. + * The charge pump switches up in gain as needed. This feature is + * useful if the ADP8863 charge pump is used to drive an external load. + * This feature must be used when utilizing small fly capacitors + * (0402 or smaller). + * 0 = the charge pump automatically switches up and down in gain. + * This provides optimal efficiency, but is not suitable for driving + * loads that are not connected through the ADP8863 diode drivers. + * Additionally, the charge pump fly capacitors should be low ESR + * and sized 0603 or greater. + */ + + u8 gdwn_dis; +}; + +#endif /* __LINUX_I2C_ADP8860_H */ -- cgit From 056d6ff470a8e782648fd020940c04d0d4a0d761 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 22 May 2017 00:09:53 +0200 Subject: video: adp8870: move header file out of I2C realm include/linux/i2c is not for client devices. Move the header file to a more appropriate location. Signed-off-by: Wolfram Sang Acked-by: Daniel Thompson Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Lee Jones --- arch/blackfin/mach-bf537/boards/stamp.c | 2 +- drivers/video/backlight/adp8870_bl.c | 2 +- include/linux/i2c/adp8870.h | 153 -------------------------------- include/linux/platform_data/adp8870.h | 153 ++++++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+), 155 deletions(-) delete mode 100644 include/linux/i2c/adp8870.h create mode 100644 include/linux/platform_data/adp8870.h diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 76983dfba324..388b91e21b74 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -1995,7 +1995,7 @@ static struct adp5588_gpio_platform_data adp5588_gpio_data = { #endif #if IS_ENABLED(CONFIG_BACKLIGHT_ADP8870) -#include +#include static struct led_info adp8870_leds[] = { { .name = "adp8870-led7", diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 21acac90fd77..058d1def2d1f 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -18,7 +18,7 @@ #include #include -#include +#include #define ADP8870_EXT_FEATURES #define ADP8870_USE_LEDS diff --git a/include/linux/i2c/adp8870.h b/include/linux/i2c/adp8870.h deleted file mode 100644 index 624dceccbd5b..000000000000 --- a/include/linux/i2c/adp8870.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Definitions and platform data for Analog Devices - * Backlight drivers ADP8870 - * - * Copyright 2009-2010 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#ifndef __LINUX_I2C_ADP8870_H -#define __LINUX_I2C_ADP8870_H - -#define ID_ADP8870 8870 - -#define ADP8870_MAX_BRIGHTNESS 0x7F -#define FLAG_OFFT_SHIFT 8 - -/* - * LEDs subdevice platform data - */ - -#define ADP8870_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT) -#define ADP8870_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT) -#define ADP8870_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT) -#define ADP8870_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT) - -#define ADP8870_LED_ONT_200ms 0 -#define ADP8870_LED_ONT_600ms 1 -#define ADP8870_LED_ONT_800ms 2 -#define ADP8870_LED_ONT_1200ms 3 - -#define ADP8870_LED_D7 (7) -#define ADP8870_LED_D6 (6) -#define ADP8870_LED_D5 (5) -#define ADP8870_LED_D4 (4) -#define ADP8870_LED_D3 (3) -#define ADP8870_LED_D2 (2) -#define ADP8870_LED_D1 (1) - -/* - * Backlight subdevice platform data - */ - -#define ADP8870_BL_D7 (1 << 6) -#define ADP8870_BL_D6 (1 << 5) -#define ADP8870_BL_D5 (1 << 4) -#define ADP8870_BL_D4 (1 << 3) -#define ADP8870_BL_D3 (1 << 2) -#define ADP8870_BL_D2 (1 << 1) -#define ADP8870_BL_D1 (1 << 0) - -#define ADP8870_FADE_T_DIS 0 /* Fade Timer Disabled */ -#define ADP8870_FADE_T_300ms 1 /* 0.3 Sec */ -#define ADP8870_FADE_T_600ms 2 -#define ADP8870_FADE_T_900ms 3 -#define ADP8870_FADE_T_1200ms 4 -#define ADP8870_FADE_T_1500ms 5 -#define ADP8870_FADE_T_1800ms 6 -#define ADP8870_FADE_T_2100ms 7 -#define ADP8870_FADE_T_2400ms 8 -#define ADP8870_FADE_T_2700ms 9 -#define ADP8870_FADE_T_3000ms 10 -#define ADP8870_FADE_T_3500ms 11 -#define ADP8870_FADE_T_4000ms 12 -#define ADP8870_FADE_T_4500ms 13 -#define ADP8870_FADE_T_5000ms 14 -#define ADP8870_FADE_T_5500ms 15 /* 5.5 Sec */ - -#define ADP8870_FADE_LAW_LINEAR 0 -#define ADP8870_FADE_LAW_SQUARE 1 -#define ADP8870_FADE_LAW_CUBIC1 2 -#define ADP8870_FADE_LAW_CUBIC2 3 - -#define ADP8870_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */ -#define ADP8870_BL_AMBL_FILT_160ms 1 -#define ADP8870_BL_AMBL_FILT_320ms 2 -#define ADP8870_BL_AMBL_FILT_640ms 3 -#define ADP8870_BL_AMBL_FILT_1280ms 4 -#define ADP8870_BL_AMBL_FILT_2560ms 5 -#define ADP8870_BL_AMBL_FILT_5120ms 6 -#define ADP8870_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */ - -/* - * Blacklight current 0..30mA - */ -#define ADP8870_BL_CUR_mA(I) ((I * 127) / 30) - -/* - * L2 comparator current 0..1106uA - */ -#define ADP8870_L2_COMP_CURR_uA(I) ((I * 255) / 1106) - -/* - * L3 comparator current 0..551uA - */ -#define ADP8870_L3_COMP_CURR_uA(I) ((I * 255) / 551) - -/* - * L4 comparator current 0..275uA - */ -#define ADP8870_L4_COMP_CURR_uA(I) ((I * 255) / 275) - -/* - * L5 comparator current 0..138uA - */ -#define ADP8870_L5_COMP_CURR_uA(I) ((I * 255) / 138) - -struct adp8870_backlight_platform_data { - u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */ - u8 pwm_assign; /* 1 = Enables PWM mode */ - - u8 bl_fade_in; /* Backlight Fade-In Timer */ - u8 bl_fade_out; /* Backlight Fade-Out Timer */ - u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */ - - u8 en_ambl_sens; /* 1 = enable ambient light sensor */ - u8 abml_filt; /* Light sensor filter time */ - - u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l2_bright_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l2_bright_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l3_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l3_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l4_indoor_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l4_indor_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l5_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ - u8 l5_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ - - u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ - u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ - u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ - u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ - u8 l4_trip; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */ - u8 l4_hyst; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */ - u8 l5_trip; /* use L5_COMP_CURR_uA(I) 0 <= I <= 138 uA */ - u8 l5_hyst; /* use L6_COMP_CURR_uA(I) 0 <= I <= 138 uA */ - - /** - * Independent Current Sinks / LEDS - * Sinks not assigned to the Backlight can be exposed to - * user space using the LEDS CLASS interface - */ - - int num_leds; - struct led_info *leds; - u8 led_fade_in; /* LED Fade-In Timer */ - u8 led_fade_out; /* LED Fade-Out Timer */ - u8 led_fade_law; /* fade-on/fade-off transfer characteristic */ - u8 led_on_time; -}; - -#endif /* __LINUX_I2C_ADP8870_H */ diff --git a/include/linux/platform_data/adp8870.h b/include/linux/platform_data/adp8870.h new file mode 100644 index 000000000000..624dceccbd5b --- /dev/null +++ b/include/linux/platform_data/adp8870.h @@ -0,0 +1,153 @@ +/* + * Definitions and platform data for Analog Devices + * Backlight drivers ADP8870 + * + * Copyright 2009-2010 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef __LINUX_I2C_ADP8870_H +#define __LINUX_I2C_ADP8870_H + +#define ID_ADP8870 8870 + +#define ADP8870_MAX_BRIGHTNESS 0x7F +#define FLAG_OFFT_SHIFT 8 + +/* + * LEDs subdevice platform data + */ + +#define ADP8870_LED_DIS_BLINK (0 << FLAG_OFFT_SHIFT) +#define ADP8870_LED_OFFT_600ms (1 << FLAG_OFFT_SHIFT) +#define ADP8870_LED_OFFT_1200ms (2 << FLAG_OFFT_SHIFT) +#define ADP8870_LED_OFFT_1800ms (3 << FLAG_OFFT_SHIFT) + +#define ADP8870_LED_ONT_200ms 0 +#define ADP8870_LED_ONT_600ms 1 +#define ADP8870_LED_ONT_800ms 2 +#define ADP8870_LED_ONT_1200ms 3 + +#define ADP8870_LED_D7 (7) +#define ADP8870_LED_D6 (6) +#define ADP8870_LED_D5 (5) +#define ADP8870_LED_D4 (4) +#define ADP8870_LED_D3 (3) +#define ADP8870_LED_D2 (2) +#define ADP8870_LED_D1 (1) + +/* + * Backlight subdevice platform data + */ + +#define ADP8870_BL_D7 (1 << 6) +#define ADP8870_BL_D6 (1 << 5) +#define ADP8870_BL_D5 (1 << 4) +#define ADP8870_BL_D4 (1 << 3) +#define ADP8870_BL_D3 (1 << 2) +#define ADP8870_BL_D2 (1 << 1) +#define ADP8870_BL_D1 (1 << 0) + +#define ADP8870_FADE_T_DIS 0 /* Fade Timer Disabled */ +#define ADP8870_FADE_T_300ms 1 /* 0.3 Sec */ +#define ADP8870_FADE_T_600ms 2 +#define ADP8870_FADE_T_900ms 3 +#define ADP8870_FADE_T_1200ms 4 +#define ADP8870_FADE_T_1500ms 5 +#define ADP8870_FADE_T_1800ms 6 +#define ADP8870_FADE_T_2100ms 7 +#define ADP8870_FADE_T_2400ms 8 +#define ADP8870_FADE_T_2700ms 9 +#define ADP8870_FADE_T_3000ms 10 +#define ADP8870_FADE_T_3500ms 11 +#define ADP8870_FADE_T_4000ms 12 +#define ADP8870_FADE_T_4500ms 13 +#define ADP8870_FADE_T_5000ms 14 +#define ADP8870_FADE_T_5500ms 15 /* 5.5 Sec */ + +#define ADP8870_FADE_LAW_LINEAR 0 +#define ADP8870_FADE_LAW_SQUARE 1 +#define ADP8870_FADE_LAW_CUBIC1 2 +#define ADP8870_FADE_LAW_CUBIC2 3 + +#define ADP8870_BL_AMBL_FILT_80ms 0 /* Light sensor filter time */ +#define ADP8870_BL_AMBL_FILT_160ms 1 +#define ADP8870_BL_AMBL_FILT_320ms 2 +#define ADP8870_BL_AMBL_FILT_640ms 3 +#define ADP8870_BL_AMBL_FILT_1280ms 4 +#define ADP8870_BL_AMBL_FILT_2560ms 5 +#define ADP8870_BL_AMBL_FILT_5120ms 6 +#define ADP8870_BL_AMBL_FILT_10240ms 7 /* 10.24 sec */ + +/* + * Blacklight current 0..30mA + */ +#define ADP8870_BL_CUR_mA(I) ((I * 127) / 30) + +/* + * L2 comparator current 0..1106uA + */ +#define ADP8870_L2_COMP_CURR_uA(I) ((I * 255) / 1106) + +/* + * L3 comparator current 0..551uA + */ +#define ADP8870_L3_COMP_CURR_uA(I) ((I * 255) / 551) + +/* + * L4 comparator current 0..275uA + */ +#define ADP8870_L4_COMP_CURR_uA(I) ((I * 255) / 275) + +/* + * L5 comparator current 0..138uA + */ +#define ADP8870_L5_COMP_CURR_uA(I) ((I * 255) / 138) + +struct adp8870_backlight_platform_data { + u8 bl_led_assign; /* 1 = Backlight 0 = Individual LED */ + u8 pwm_assign; /* 1 = Enables PWM mode */ + + u8 bl_fade_in; /* Backlight Fade-In Timer */ + u8 bl_fade_out; /* Backlight Fade-Out Timer */ + u8 bl_fade_law; /* fade-on/fade-off transfer characteristic */ + + u8 en_ambl_sens; /* 1 = enable ambient light sensor */ + u8 abml_filt; /* Light sensor filter time */ + + u8 l1_daylight_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l1_daylight_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l2_bright_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l2_bright_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l3_office_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l3_office_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l4_indoor_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l4_indor_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l5_dark_max; /* use BL_CUR_mA(I) 0 <= I <= 30 mA */ + u8 l5_dark_dim; /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */ + + u8 l2_trip; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ + u8 l2_hyst; /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */ + u8 l3_trip; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ + u8 l3_hyst; /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */ + u8 l4_trip; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */ + u8 l4_hyst; /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */ + u8 l5_trip; /* use L5_COMP_CURR_uA(I) 0 <= I <= 138 uA */ + u8 l5_hyst; /* use L6_COMP_CURR_uA(I) 0 <= I <= 138 uA */ + + /** + * Independent Current Sinks / LEDS + * Sinks not assigned to the Backlight can be exposed to + * user space using the LEDS CLASS interface + */ + + int num_leds; + struct led_info *leds; + u8 led_fade_in; /* LED Fade-In Timer */ + u8 led_fade_out; /* LED Fade-Out Timer */ + u8 led_fade_law; /* fade-on/fade-off transfer characteristic */ + u8 led_on_time; +}; + +#endif /* __LINUX_I2C_ADP8870_H */ -- cgit