Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * LP855x Backlight Driver |
| 3 | * |
| 4 | * Copyright (C) 2011 Texas Instruments |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef _LP855X_H |
| 13 | #define _LP855X_H |
| 14 | |
| 15 | #define BL_CTL_SHFT (0) |
| 16 | #define BRT_MODE_SHFT (1) |
| 17 | #define BRT_MODE_MASK (0x06) |
| 18 | |
| 19 | /* Enable backlight. Only valid when BRT_MODE=10(I2C only) */ |
| 20 | #define ENABLE_BL (1) |
| 21 | #define DISABLE_BL (0) |
| 22 | |
| 23 | #define I2C_CONFIG(id) id ## _I2C_CONFIG |
| 24 | #define PWM_CONFIG(id) id ## _PWM_CONFIG |
| 25 | |
| 26 | /* DEVICE CONTROL register - LP8550 */ |
| 27 | #define LP8550_PWM_CONFIG (LP8550_PWM_ONLY << BRT_MODE_SHFT) |
| 28 | #define LP8550_I2C_CONFIG ((ENABLE_BL << BL_CTL_SHFT) | \ |
| 29 | (LP8550_I2C_ONLY << BRT_MODE_SHFT)) |
| 30 | |
| 31 | /* DEVICE CONTROL register - LP8551 */ |
| 32 | #define LP8551_PWM_CONFIG LP8550_PWM_CONFIG |
| 33 | #define LP8551_I2C_CONFIG LP8550_I2C_CONFIG |
| 34 | |
| 35 | /* DEVICE CONTROL register - LP8552 */ |
| 36 | #define LP8552_PWM_CONFIG LP8550_PWM_CONFIG |
| 37 | #define LP8552_I2C_CONFIG LP8550_I2C_CONFIG |
| 38 | |
| 39 | /* DEVICE CONTROL register - LP8553 */ |
| 40 | #define LP8553_PWM_CONFIG LP8550_PWM_CONFIG |
| 41 | #define LP8553_I2C_CONFIG LP8550_I2C_CONFIG |
| 42 | |
Milo Kim | 5812c13 | 2013-11-12 15:08:57 -0800 | [diff] [blame] | 43 | /* CONFIG register - LP8555 */ |
| 44 | #define LP8555_PWM_STANDBY BIT(7) |
| 45 | #define LP8555_PWM_FILTER BIT(6) |
| 46 | #define LP8555_RELOAD_EPROM BIT(3) /* use it if EPROMs should be reset |
| 47 | when the backlight turns on */ |
| 48 | #define LP8555_OFF_OPENLEDS BIT(2) |
| 49 | #define LP8555_PWM_CONFIG LP8555_PWM_ONLY |
| 50 | #define LP8555_I2C_CONFIG LP8555_I2C_ONLY |
| 51 | #define LP8555_COMB1_CONFIG LP8555_COMBINED1 |
| 52 | #define LP8555_COMB2_CONFIG LP8555_COMBINED2 |
| 53 | |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 54 | /* DEVICE CONTROL register - LP8556 */ |
| 55 | #define LP8556_PWM_CONFIG (LP8556_PWM_ONLY << BRT_MODE_SHFT) |
| 56 | #define LP8556_COMB1_CONFIG (LP8556_COMBINED1 << BRT_MODE_SHFT) |
| 57 | #define LP8556_I2C_CONFIG ((ENABLE_BL << BL_CTL_SHFT) | \ |
| 58 | (LP8556_I2C_ONLY << BRT_MODE_SHFT)) |
| 59 | #define LP8556_COMB2_CONFIG (LP8556_COMBINED2 << BRT_MODE_SHFT) |
Kim, Milo | 6275ce9 | 2012-10-04 17:12:50 -0700 | [diff] [blame] | 60 | #define LP8556_FAST_CONFIG BIT(7) /* use it if EPROMs should be maintained |
| 61 | when exiting the low power mode */ |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 62 | |
Kim, Milo | 26e8ccc | 2013-02-21 16:44:06 -0800 | [diff] [blame] | 63 | /* CONFIG register - LP8557 */ |
| 64 | #define LP8557_PWM_STANDBY BIT(7) |
| 65 | #define LP8557_PWM_FILTER BIT(6) |
| 66 | #define LP8557_RELOAD_EPROM BIT(3) /* use it if EPROMs should be reset |
| 67 | when the backlight turns on */ |
| 68 | #define LP8557_OFF_OPENLEDS BIT(2) |
| 69 | #define LP8557_PWM_CONFIG LP8557_PWM_ONLY |
| 70 | #define LP8557_I2C_CONFIG LP8557_I2C_ONLY |
| 71 | #define LP8557_COMB1_CONFIG LP8557_COMBINED1 |
| 72 | #define LP8557_COMB2_CONFIG LP8557_COMBINED2 |
| 73 | |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 74 | enum lp855x_chip_id { |
| 75 | LP8550, |
| 76 | LP8551, |
| 77 | LP8552, |
| 78 | LP8553, |
Milo Kim | 5812c13 | 2013-11-12 15:08:57 -0800 | [diff] [blame] | 79 | LP8555, |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 80 | LP8556, |
Kim, Milo | 26e8ccc | 2013-02-21 16:44:06 -0800 | [diff] [blame] | 81 | LP8557, |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 84 | enum lp8550_brighntess_source { |
| 85 | LP8550_PWM_ONLY, |
| 86 | LP8550_I2C_ONLY = 2, |
| 87 | }; |
| 88 | |
| 89 | enum lp8551_brighntess_source { |
| 90 | LP8551_PWM_ONLY = LP8550_PWM_ONLY, |
| 91 | LP8551_I2C_ONLY = LP8550_I2C_ONLY, |
| 92 | }; |
| 93 | |
| 94 | enum lp8552_brighntess_source { |
| 95 | LP8552_PWM_ONLY = LP8550_PWM_ONLY, |
| 96 | LP8552_I2C_ONLY = LP8550_I2C_ONLY, |
| 97 | }; |
| 98 | |
| 99 | enum lp8553_brighntess_source { |
| 100 | LP8553_PWM_ONLY = LP8550_PWM_ONLY, |
| 101 | LP8553_I2C_ONLY = LP8550_I2C_ONLY, |
| 102 | }; |
| 103 | |
Milo Kim | 5812c13 | 2013-11-12 15:08:57 -0800 | [diff] [blame] | 104 | enum lp8555_brightness_source { |
| 105 | LP8555_PWM_ONLY, |
| 106 | LP8555_I2C_ONLY, |
| 107 | LP8555_COMBINED1, /* Brightness register with shaped PWM */ |
| 108 | LP8555_COMBINED2, /* PWM with shaped brightness register */ |
| 109 | }; |
| 110 | |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 111 | enum lp8556_brightness_source { |
| 112 | LP8556_PWM_ONLY, |
| 113 | LP8556_COMBINED1, /* pwm + i2c before the shaper block */ |
| 114 | LP8556_I2C_ONLY, |
| 115 | LP8556_COMBINED2, /* pwm + i2c after the shaper block */ |
| 116 | }; |
| 117 | |
Kim, Milo | 26e8ccc | 2013-02-21 16:44:06 -0800 | [diff] [blame] | 118 | enum lp8557_brightness_source { |
| 119 | LP8557_PWM_ONLY, |
| 120 | LP8557_I2C_ONLY, |
| 121 | LP8557_COMBINED1, /* pwm + i2c after the shaper block */ |
| 122 | LP8557_COMBINED2, /* pwm + i2c before the shaper block */ |
| 123 | }; |
| 124 | |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 125 | struct lp855x_rom_data { |
| 126 | u8 addr; |
| 127 | u8 val; |
| 128 | }; |
| 129 | |
| 130 | /** |
| 131 | * struct lp855x_platform_data |
| 132 | * @name : Backlight driver name. If it is not defined, default name is set. |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 133 | * @device_control : value of DEVICE CONTROL register |
| 134 | * @initial_brightness : initial value of backlight brightness |
Kim, Milo | 8cc9764 | 2012-12-17 16:00:43 -0800 | [diff] [blame] | 135 | * @period_ns : platform specific pwm period value. unit is nano. |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 136 | Only valid when mode is PWM_BASED. |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 137 | * @size_program : total size of lp855x_rom_data |
| 138 | * @rom_data : list of new eeprom/eprom registers |
Sean Paul | 829b030 | 2014-12-02 17:39:12 -0800 | [diff] [blame] | 139 | * @supply : regulator that supplies 3V input |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 140 | */ |
| 141 | struct lp855x_platform_data { |
Kim, Milo | 600ffd3 | 2013-04-29 16:18:02 -0700 | [diff] [blame] | 142 | const char *name; |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 143 | u8 device_control; |
Kim, Milo | 98e35be | 2013-04-29 16:18:04 -0700 | [diff] [blame] | 144 | u8 initial_brightness; |
Kim, Milo | 8cc9764 | 2012-12-17 16:00:43 -0800 | [diff] [blame] | 145 | unsigned int period_ns; |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 146 | int size_program; |
| 147 | struct lp855x_rom_data *rom_data; |
Sean Paul | 829b030 | 2014-12-02 17:39:12 -0800 | [diff] [blame] | 148 | struct regulator *supply; |
Kim, Milo | 7be865a | 2012-03-23 15:02:01 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | #endif |