diff options
author | Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> | 2013-08-14 17:23:50 -0400 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-08-26 20:22:14 -0400 |
commit | 56a1740c21e4396164265c3ec80e29990ddcdc36 (patch) | |
tree | 5b8de09166080cb6479811c7436e57b8788434cd | |
parent | a7d0e9884fd7594d4de5066add5135ac6bb55bd4 (diff) |
leds-pca9633: Rename to leds-pca963x
The driver now supports the chips pca9633 and pca9634, therefore we
rename the files to more generic and meaningul names
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r-- | Documentation/devicetree/bindings/leds/pca963x.txt (renamed from Documentation/devicetree/bindings/leds/pca9633.txt) | 0 | ||||
-rw-r--r-- | drivers/leds/Kconfig | 2 | ||||
-rw-r--r-- | drivers/leds/Makefile | 2 | ||||
-rw-r--r-- | drivers/leds/leds-pca963x.c (renamed from drivers/leds/leds-pca9633.c) | 288 | ||||
-rw-r--r-- | include/linux/platform_data/leds-pca963x.h (renamed from include/linux/platform_data/leds-pca9633.h) | 27 |
5 files changed, 160 insertions, 159 deletions
diff --git a/Documentation/devicetree/bindings/leds/pca9633.txt b/Documentation/devicetree/bindings/leds/pca963x.txt index aece3eac1b63..aece3eac1b63 100644 --- a/Documentation/devicetree/bindings/leds/pca9633.txt +++ b/Documentation/devicetree/bindings/leds/pca963x.txt | |||
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index e7977aa3ee59..a1a52bec03d4 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -291,7 +291,7 @@ config LEDS_PCA955X | |||
291 | LED driver chips accessed via the I2C bus. Supported | 291 | LED driver chips accessed via the I2C bus. Supported |
292 | devices include PCA9550, PCA9551, PCA9552, and PCA9553. | 292 | devices include PCA9550, PCA9551, PCA9552, and PCA9553. |
293 | 293 | ||
294 | config LEDS_PCA9633 | 294 | config LEDS_PCA963X |
295 | tristate "LED support for PCA963x I2C chip" | 295 | tristate "LED support for PCA963x I2C chip" |
296 | depends on LEDS_CLASS | 296 | depends on LEDS_CLASS |
297 | depends on I2C | 297 | depends on I2C |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 3013113e74d2..c7e35423fed9 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -35,7 +35,7 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o | |||
35 | obj-$(CONFIG_LEDS_OT200) += leds-ot200.o | 35 | obj-$(CONFIG_LEDS_OT200) += leds-ot200.o |
36 | obj-$(CONFIG_LEDS_FSG) += leds-fsg.o | 36 | obj-$(CONFIG_LEDS_FSG) += leds-fsg.o |
37 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o | 37 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o |
38 | obj-$(CONFIG_LEDS_PCA9633) += leds-pca9633.o | 38 | obj-$(CONFIG_LEDS_PCA963X) += leds-pca963x.o |
39 | obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o | 39 | obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o |
40 | obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o | 40 | obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o |
41 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o | 41 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o |
diff --git a/drivers/leds/leds-pca9633.c b/drivers/leds/leds-pca963x.c index aaa1c4a0dbc5..35d56a62f92f 100644 --- a/drivers/leds/leds-pca9633.c +++ b/drivers/leds/leds-pca963x.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * in identical fashion. The delay_on/delay_off values of the last LED | 21 | * in identical fashion. The delay_on/delay_off values of the last LED |
22 | * that is set to blink will be used for all of the blinking LEDs. | 22 | * that is set to blink will be used for all of the blinking LEDs. |
23 | * Hardware blinking is disabled by default but can be enabled by setting | 23 | * Hardware blinking is disabled by default but can be enabled by setting |
24 | * the 'blink_type' member in the platform_data struct to 'PCA9633_HW_BLINK' | 24 | * the 'blink_type' member in the platform_data struct to 'PCA963X_HW_BLINK' |
25 | * or by adding the 'nxp,hw-blink' property to the DTS. | 25 | * or by adding the 'nxp,hw-blink' property to the DTS. |
26 | */ | 26 | */ |
27 | 27 | ||
@@ -35,33 +35,33 @@ | |||
35 | #include <linux/workqueue.h> | 35 | #include <linux/workqueue.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/of.h> | 37 | #include <linux/of.h> |
38 | #include <linux/platform_data/leds-pca9633.h> | 38 | #include <linux/platform_data/leds-pca963x.h> |
39 | 39 | ||
40 | /* LED select registers determine the source that drives LED outputs */ | 40 | /* LED select registers determine the source that drives LED outputs */ |
41 | #define PCA9633_LED_OFF 0x0 /* LED driver off */ | 41 | #define PCA963X_LED_OFF 0x0 /* LED driver off */ |
42 | #define PCA9633_LED_ON 0x1 /* LED driver on */ | 42 | #define PCA963X_LED_ON 0x1 /* LED driver on */ |
43 | #define PCA9633_LED_PWM 0x2 /* Controlled through PWM */ | 43 | #define PCA963X_LED_PWM 0x2 /* Controlled through PWM */ |
44 | #define PCA9633_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */ | 44 | #define PCA963X_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */ |
45 | 45 | ||
46 | #define PCA9633_MODE2_DMBLNK 0x20 /* Enable blinking */ | 46 | #define PCA963X_MODE2_DMBLNK 0x20 /* Enable blinking */ |
47 | 47 | ||
48 | #define PCA9633_MODE1 0x00 | 48 | #define PCA963X_MODE1 0x00 |
49 | #define PCA9633_MODE2 0x01 | 49 | #define PCA963X_MODE2 0x01 |
50 | #define PCA9633_PWM_BASE 0x02 | 50 | #define PCA963X_PWM_BASE 0x02 |
51 | 51 | ||
52 | enum pca9633_type { | 52 | enum pca963x_type { |
53 | pca9633, | 53 | pca9633, |
54 | pca9634, | 54 | pca9634, |
55 | }; | 55 | }; |
56 | 56 | ||
57 | struct pca9633_chipdef { | 57 | struct pca963x_chipdef { |
58 | u8 grppwm; | 58 | u8 grppwm; |
59 | u8 grpfreq; | 59 | u8 grpfreq; |
60 | u8 ledout_base; | 60 | u8 ledout_base; |
61 | int n_leds; | 61 | int n_leds; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | static struct pca9633_chipdef pca9633_chipdefs[] = { | 64 | static struct pca963x_chipdef pca963x_chipdefs[] = { |
65 | [pca9633] = { | 65 | [pca9633] = { |
66 | .grppwm = 0x6, | 66 | .grppwm = 0x6, |
67 | .grpfreq = 0x7, | 67 | .grpfreq = 0x7, |
@@ -77,141 +77,141 @@ static struct pca9633_chipdef pca9633_chipdefs[] = { | |||
77 | }; | 77 | }; |
78 | 78 | ||
79 | /* Total blink period in milliseconds */ | 79 | /* Total blink period in milliseconds */ |
80 | #define PCA9632_BLINK_PERIOD_MIN 42 | 80 | #define PCA963X_BLINK_PERIOD_MIN 42 |
81 | #define PCA9632_BLINK_PERIOD_MAX 10667 | 81 | #define PCA963X_BLINK_PERIOD_MAX 10667 |
82 | 82 | ||
83 | static const struct i2c_device_id pca9633_id[] = { | 83 | static const struct i2c_device_id pca963x_id[] = { |
84 | { "pca9632", pca9633 }, | 84 | { "pca9632", pca9633 }, |
85 | { "pca9633", pca9633 }, | 85 | { "pca9633", pca9633 }, |
86 | { "pca9634", pca9634 }, | 86 | { "pca9634", pca9634 }, |
87 | { } | 87 | { } |
88 | }; | 88 | }; |
89 | MODULE_DEVICE_TABLE(i2c, pca9633_id); | 89 | MODULE_DEVICE_TABLE(i2c, pca963x_id); |
90 | 90 | ||
91 | enum pca9633_cmd { | 91 | enum pca963x_cmd { |
92 | BRIGHTNESS_SET, | 92 | BRIGHTNESS_SET, |
93 | BLINK_SET, | 93 | BLINK_SET, |
94 | }; | 94 | }; |
95 | 95 | ||
96 | struct pca9633_led; | 96 | struct pca963x_led; |
97 | 97 | ||
98 | struct pca9633 { | 98 | struct pca963x { |
99 | struct pca9633_chipdef *chipdef; | 99 | struct pca963x_chipdef *chipdef; |
100 | struct mutex mutex; | 100 | struct mutex mutex; |
101 | struct i2c_client *client; | 101 | struct i2c_client *client; |
102 | struct pca9633_led *leds; | 102 | struct pca963x_led *leds; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | struct pca9633_led { | 105 | struct pca963x_led { |
106 | struct pca9633 *chip; | 106 | struct pca963x *chip; |
107 | struct work_struct work; | 107 | struct work_struct work; |
108 | enum led_brightness brightness; | 108 | enum led_brightness brightness; |
109 | struct led_classdev led_cdev; | 109 | struct led_classdev led_cdev; |
110 | int led_num; /* 0 .. 7 potentially */ | 110 | int led_num; /* 0 .. 7 potentially */ |
111 | enum pca9633_cmd cmd; | 111 | enum pca963x_cmd cmd; |
112 | char name[32]; | 112 | char name[32]; |
113 | u8 gdc; | 113 | u8 gdc; |
114 | u8 gfrq; | 114 | u8 gfrq; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | static void pca9633_brightness_work(struct pca9633_led *pca9633) | 117 | static void pca963x_brightness_work(struct pca963x_led *pca963x) |
118 | { | 118 | { |
119 | u8 ledout_addr = pca9633->chip->chipdef->ledout_base | 119 | u8 ledout_addr = pca963x->chip->chipdef->ledout_base |
120 | + (pca9633->led_num / 4); | 120 | + (pca963x->led_num / 4); |
121 | u8 ledout; | 121 | u8 ledout; |
122 | int shift = 2 * (pca9633->led_num % 4); | 122 | int shift = 2 * (pca963x->led_num % 4); |
123 | u8 mask = 0x3 << shift; | 123 | u8 mask = 0x3 << shift; |
124 | 124 | ||
125 | mutex_lock(&pca9633->chip->mutex); | 125 | mutex_lock(&pca963x->chip->mutex); |
126 | ledout = i2c_smbus_read_byte_data(pca9633->chip->client, ledout_addr); | 126 | ledout = i2c_smbus_read_byte_data(pca963x->chip->client, ledout_addr); |
127 | switch (pca9633->brightness) { | 127 | switch (pca963x->brightness) { |
128 | case LED_FULL: | 128 | case LED_FULL: |
129 | i2c_smbus_write_byte_data(pca9633->chip->client, ledout_addr, | 129 | i2c_smbus_write_byte_data(pca963x->chip->client, ledout_addr, |
130 | (ledout & ~mask) | (PCA9633_LED_ON << shift)); | 130 | (ledout & ~mask) | (PCA963X_LED_ON << shift)); |
131 | break; | 131 | break; |
132 | case LED_OFF: | 132 | case LED_OFF: |
133 | i2c_smbus_write_byte_data(pca9633->chip->client, ledout_addr, | 133 | i2c_smbus_write_byte_data(pca963x->chip->client, ledout_addr, |
134 | ledout & ~mask); | 134 | ledout & ~mask); |
135 | break; | 135 | break; |
136 | default: | 136 | default: |
137 | i2c_smbus_write_byte_data(pca9633->chip->client, | 137 | i2c_smbus_write_byte_data(pca963x->chip->client, |
138 | PCA9633_PWM_BASE + pca9633->led_num, | 138 | PCA963X_PWM_BASE + pca963x->led_num, |
139 | pca9633->brightness); | 139 | pca963x->brightness); |
140 | i2c_smbus_write_byte_data(pca9633->chip->client, ledout_addr, | 140 | i2c_smbus_write_byte_data(pca963x->chip->client, ledout_addr, |
141 | (ledout & ~mask) | (PCA9633_LED_PWM << shift)); | 141 | (ledout & ~mask) | (PCA963X_LED_PWM << shift)); |
142 | break; | 142 | break; |
143 | } | 143 | } |
144 | mutex_unlock(&pca9633->chip->mutex); | 144 | mutex_unlock(&pca963x->chip->mutex); |
145 | } | 145 | } |
146 | 146 | ||
147 | static void pca9633_blink_work(struct pca9633_led *pca9633) | 147 | static void pca963x_blink_work(struct pca963x_led *pca963x) |
148 | { | 148 | { |
149 | u8 ledout_addr = pca9633->chip->chipdef->ledout_base + | 149 | u8 ledout_addr = pca963x->chip->chipdef->ledout_base + |
150 | (pca9633->led_num / 4); | 150 | (pca963x->led_num / 4); |
151 | u8 ledout; | 151 | u8 ledout; |
152 | u8 mode2 = i2c_smbus_read_byte_data(pca9633->chip->client, | 152 | u8 mode2 = i2c_smbus_read_byte_data(pca963x->chip->client, |
153 | PCA9633_MODE2); | 153 | PCA963X_MODE2); |
154 | int shift = 2 * (pca9633->led_num % 4); | 154 | int shift = 2 * (pca963x->led_num % 4); |
155 | u8 mask = 0x3 << shift; | 155 | u8 mask = 0x3 << shift; |
156 | 156 | ||
157 | i2c_smbus_write_byte_data(pca9633->chip->client, | 157 | i2c_smbus_write_byte_data(pca963x->chip->client, |
158 | pca9633->chip->chipdef->grppwm, pca9633->gdc); | 158 | pca963x->chip->chipdef->grppwm, pca963x->gdc); |
159 | 159 | ||
160 | i2c_smbus_write_byte_data(pca9633->chip->client, | 160 | i2c_smbus_write_byte_data(pca963x->chip->client, |
161 | pca9633->chip->chipdef->grpfreq, pca9633->gfrq); | 161 | pca963x->chip->chipdef->grpfreq, pca963x->gfrq); |
162 | 162 | ||
163 | if (!(mode2 & PCA9633_MODE2_DMBLNK)) | 163 | if (!(mode2 & PCA963X_MODE2_DMBLNK)) |
164 | i2c_smbus_write_byte_data(pca9633->chip->client, PCA9633_MODE2, | 164 | i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2, |
165 | mode2 | PCA9633_MODE2_DMBLNK); | 165 | mode2 | PCA963X_MODE2_DMBLNK); |
166 | 166 | ||
167 | mutex_lock(&pca9633->chip->mutex); | 167 | mutex_lock(&pca963x->chip->mutex); |
168 | ledout = i2c_smbus_read_byte_data(pca9633->chip->client, ledout_addr); | 168 | ledout = i2c_smbus_read_byte_data(pca963x->chip->client, ledout_addr); |
169 | if ((ledout & mask) != (PCA9633_LED_GRP_PWM << shift)) | 169 | if ((ledout & mask) != (PCA963X_LED_GRP_PWM << shift)) |
170 | i2c_smbus_write_byte_data(pca9633->chip->client, ledout_addr, | 170 | i2c_smbus_write_byte_data(pca963x->chip->client, ledout_addr, |
171 | (ledout & ~mask) | (PCA9633_LED_GRP_PWM << shift)); | 171 | (ledout & ~mask) | (PCA963X_LED_GRP_PWM << shift)); |
172 | mutex_unlock(&pca9633->chip->mutex); | 172 | mutex_unlock(&pca963x->chip->mutex); |
173 | } | 173 | } |
174 | 174 | ||
175 | static void pca9633_work(struct work_struct *work) | 175 | static void pca963x_work(struct work_struct *work) |
176 | { | 176 | { |
177 | struct pca9633_led *pca9633 = container_of(work, | 177 | struct pca963x_led *pca963x = container_of(work, |
178 | struct pca9633_led, work); | 178 | struct pca963x_led, work); |
179 | 179 | ||
180 | switch (pca9633->cmd) { | 180 | switch (pca963x->cmd) { |
181 | case BRIGHTNESS_SET: | 181 | case BRIGHTNESS_SET: |
182 | pca9633_brightness_work(pca9633); | 182 | pca963x_brightness_work(pca963x); |
183 | break; | 183 | break; |
184 | case BLINK_SET: | 184 | case BLINK_SET: |
185 | pca9633_blink_work(pca9633); | 185 | pca963x_blink_work(pca963x); |
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | static void pca9633_led_set(struct led_classdev *led_cdev, | 190 | static void pca963x_led_set(struct led_classdev *led_cdev, |
191 | enum led_brightness value) | 191 | enum led_brightness value) |
192 | { | 192 | { |
193 | struct pca9633_led *pca9633; | 193 | struct pca963x_led *pca963x; |
194 | 194 | ||
195 | pca9633 = container_of(led_cdev, struct pca9633_led, led_cdev); | 195 | pca963x = container_of(led_cdev, struct pca963x_led, led_cdev); |
196 | 196 | ||
197 | pca9633->cmd = BRIGHTNESS_SET; | 197 | pca963x->cmd = BRIGHTNESS_SET; |
198 | pca9633->brightness = value; | 198 | pca963x->brightness = value; |
199 | 199 | ||
200 | /* | 200 | /* |
201 | * Must use workqueue for the actual I/O since I2C operations | 201 | * Must use workqueue for the actual I/O since I2C operations |
202 | * can sleep. | 202 | * can sleep. |
203 | */ | 203 | */ |
204 | schedule_work(&pca9633->work); | 204 | schedule_work(&pca963x->work); |
205 | } | 205 | } |
206 | 206 | ||
207 | static int pca9633_blink_set(struct led_classdev *led_cdev, | 207 | static int pca963x_blink_set(struct led_classdev *led_cdev, |
208 | unsigned long *delay_on, unsigned long *delay_off) | 208 | unsigned long *delay_on, unsigned long *delay_off) |
209 | { | 209 | { |
210 | struct pca9633_led *pca9633; | 210 | struct pca963x_led *pca963x; |
211 | unsigned long time_on, time_off, period; | 211 | unsigned long time_on, time_off, period; |
212 | u8 gdc, gfrq; | 212 | u8 gdc, gfrq; |
213 | 213 | ||
214 | pca9633 = container_of(led_cdev, struct pca9633_led, led_cdev); | 214 | pca963x = container_of(led_cdev, struct pca963x_led, led_cdev); |
215 | 215 | ||
216 | time_on = *delay_on; | 216 | time_on = *delay_on; |
217 | time_off = *delay_off; | 217 | time_off = *delay_off; |
@@ -225,8 +225,8 @@ static int pca9633_blink_set(struct led_classdev *led_cdev, | |||
225 | period = time_on + time_off; | 225 | period = time_on + time_off; |
226 | 226 | ||
227 | /* If period not supported by hardware, default to someting sane. */ | 227 | /* If period not supported by hardware, default to someting sane. */ |
228 | if ((period < PCA9632_BLINK_PERIOD_MIN) || | 228 | if ((period < PCA963X_BLINK_PERIOD_MIN) || |
229 | (period > PCA9632_BLINK_PERIOD_MAX)) { | 229 | (period > PCA963X_BLINK_PERIOD_MAX)) { |
230 | time_on = 500; | 230 | time_on = 500; |
231 | time_off = 500; | 231 | time_off = 500; |
232 | period = time_on + time_off; | 232 | period = time_on + time_off; |
@@ -246,15 +246,15 @@ static int pca9633_blink_set(struct led_classdev *led_cdev, | |||
246 | */ | 246 | */ |
247 | gfrq = (period * 24 / 1000) - 1; | 247 | gfrq = (period * 24 / 1000) - 1; |
248 | 248 | ||
249 | pca9633->cmd = BLINK_SET; | 249 | pca963x->cmd = BLINK_SET; |
250 | pca9633->gdc = gdc; | 250 | pca963x->gdc = gdc; |
251 | pca9633->gfrq = gfrq; | 251 | pca963x->gfrq = gfrq; |
252 | 252 | ||
253 | /* | 253 | /* |
254 | * Must use workqueue for the actual I/O since I2C operations | 254 | * Must use workqueue for the actual I/O since I2C operations |
255 | * can sleep. | 255 | * can sleep. |
256 | */ | 256 | */ |
257 | schedule_work(&pca9633->work); | 257 | schedule_work(&pca963x->work); |
258 | 258 | ||
259 | *delay_on = time_on; | 259 | *delay_on = time_on; |
260 | *delay_off = time_off; | 260 | *delay_off = time_off; |
@@ -263,21 +263,21 @@ static int pca9633_blink_set(struct led_classdev *led_cdev, | |||
263 | } | 263 | } |
264 | 264 | ||
265 | #if IS_ENABLED(CONFIG_OF) | 265 | #if IS_ENABLED(CONFIG_OF) |
266 | static struct pca9633_platform_data * | 266 | static struct pca963x_platform_data * |
267 | pca9633_dt_init(struct i2c_client *client, struct pca9633_chipdef *chip) | 267 | pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) |
268 | { | 268 | { |
269 | struct device_node *np = client->dev.of_node, *child; | 269 | struct device_node *np = client->dev.of_node, *child; |
270 | struct pca9633_platform_data *pdata; | 270 | struct pca963x_platform_data *pdata; |
271 | struct led_info *pca9633_leds; | 271 | struct led_info *pca963x_leds; |
272 | int count; | 272 | int count; |
273 | 273 | ||
274 | count = of_get_child_count(np); | 274 | count = of_get_child_count(np); |
275 | if (!count || count > chip->n_leds) | 275 | if (!count || count > chip->n_leds) |
276 | return ERR_PTR(-ENODEV); | 276 | return ERR_PTR(-ENODEV); |
277 | 277 | ||
278 | pca9633_leds = devm_kzalloc(&client->dev, | 278 | pca963x_leds = devm_kzalloc(&client->dev, |
279 | sizeof(struct led_info) * chip->n_leds, GFP_KERNEL); | 279 | sizeof(struct led_info) * chip->n_leds, GFP_KERNEL); |
280 | if (!pca9633_leds) | 280 | if (!pca963x_leds) |
281 | return ERR_PTR(-ENOMEM); | 281 | return ERR_PTR(-ENOMEM); |
282 | 282 | ||
283 | for_each_child_of_node(np, child) { | 283 | for_each_child_of_node(np, child) { |
@@ -292,59 +292,59 @@ pca9633_dt_init(struct i2c_client *client, struct pca9633_chipdef *chip) | |||
292 | res = of_property_read_u32(child, "reg", ®); | 292 | res = of_property_read_u32(child, "reg", ®); |
293 | if (res != 0) | 293 | if (res != 0) |
294 | continue; | 294 | continue; |
295 | pca9633_leds[reg] = led; | 295 | pca963x_leds[reg] = led; |
296 | } | 296 | } |
297 | pdata = devm_kzalloc(&client->dev, | 297 | pdata = devm_kzalloc(&client->dev, |
298 | sizeof(struct pca9633_platform_data), GFP_KERNEL); | 298 | sizeof(struct pca963x_platform_data), GFP_KERNEL); |
299 | if (!pdata) | 299 | if (!pdata) |
300 | return ERR_PTR(-ENOMEM); | 300 | return ERR_PTR(-ENOMEM); |
301 | 301 | ||
302 | pdata->leds.leds = pca9633_leds; | 302 | pdata->leds.leds = pca963x_leds; |
303 | pdata->leds.num_leds = count; | 303 | pdata->leds.num_leds = count; |
304 | 304 | ||
305 | /* default to open-drain unless totem pole (push-pull) is specified */ | 305 | /* default to open-drain unless totem pole (push-pull) is specified */ |
306 | if (of_property_read_bool(np, "nxp,totem-pole")) | 306 | if (of_property_read_bool(np, "nxp,totem-pole")) |
307 | pdata->outdrv = PCA9633_TOTEM_POLE; | 307 | pdata->outdrv = PCA963X_TOTEM_POLE; |
308 | else | 308 | else |
309 | pdata->outdrv = PCA9633_OPEN_DRAIN; | 309 | pdata->outdrv = PCA963X_OPEN_DRAIN; |
310 | 310 | ||
311 | /* default to software blinking unless hardware blinking is specified */ | 311 | /* default to software blinking unless hardware blinking is specified */ |
312 | if (of_property_read_bool(np, "nxp,hw-blink")) | 312 | if (of_property_read_bool(np, "nxp,hw-blink")) |
313 | pdata->blink_type = PCA9633_HW_BLINK; | 313 | pdata->blink_type = PCA963X_HW_BLINK; |
314 | else | 314 | else |
315 | pdata->blink_type = PCA9633_SW_BLINK; | 315 | pdata->blink_type = PCA963X_SW_BLINK; |
316 | 316 | ||
317 | return pdata; | 317 | return pdata; |
318 | } | 318 | } |
319 | 319 | ||
320 | static const struct of_device_id of_pca9633_match[] = { | 320 | static const struct of_device_id of_pca963x_match[] = { |
321 | { .compatible = "nxp,pca9632", }, | 321 | { .compatible = "nxp,pca9632", }, |
322 | { .compatible = "nxp,pca9633", }, | 322 | { .compatible = "nxp,pca9633", }, |
323 | { .compatible = "nxp,pca9634", }, | 323 | { .compatible = "nxp,pca9634", }, |
324 | {}, | 324 | {}, |
325 | }; | 325 | }; |
326 | #else | 326 | #else |
327 | static struct pca9633_platform_data * | 327 | static struct pca963x_platform_data * |
328 | pca9633_dt_init(struct i2c_client *client, struct pca9633_chipdef *chip) | 328 | pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) |
329 | { | 329 | { |
330 | return ERR_PTR(-ENODEV); | 330 | return ERR_PTR(-ENODEV); |
331 | } | 331 | } |
332 | #endif | 332 | #endif |
333 | 333 | ||
334 | static int pca9633_probe(struct i2c_client *client, | 334 | static int pca963x_probe(struct i2c_client *client, |
335 | const struct i2c_device_id *id) | 335 | const struct i2c_device_id *id) |
336 | { | 336 | { |
337 | struct pca9633 *pca9633_chip; | 337 | struct pca963x *pca963x_chip; |
338 | struct pca9633_led *pca9633; | 338 | struct pca963x_led *pca963x; |
339 | struct pca9633_platform_data *pdata; | 339 | struct pca963x_platform_data *pdata; |
340 | struct pca9633_chipdef *chip; | 340 | struct pca963x_chipdef *chip; |
341 | int i, err; | 341 | int i, err; |
342 | 342 | ||
343 | chip = &pca9633_chipdefs[id->driver_data]; | 343 | chip = &pca963x_chipdefs[id->driver_data]; |
344 | pdata = dev_get_platdata(&client->dev); | 344 | pdata = dev_get_platdata(&client->dev); |
345 | 345 | ||
346 | if (!pdata) { | 346 | if (!pdata) { |
347 | pdata = pca9633_dt_init(client, chip); | 347 | pdata = pca963x_dt_init(client, chip); |
348 | if (IS_ERR(pdata)) { | 348 | if (IS_ERR(pdata)) { |
349 | dev_warn(&client->dev, "could not parse configuration\n"); | 349 | dev_warn(&client->dev, "could not parse configuration\n"); |
350 | pdata = NULL; | 350 | pdata = NULL; |
@@ -358,21 +358,21 @@ static int pca9633_probe(struct i2c_client *client, | |||
358 | return -EINVAL; | 358 | return -EINVAL; |
359 | } | 359 | } |
360 | 360 | ||
361 | pca9633_chip = devm_kzalloc(&client->dev, sizeof(*pca9633_chip), | 361 | pca963x_chip = devm_kzalloc(&client->dev, sizeof(*pca963x_chip), |
362 | GFP_KERNEL); | 362 | GFP_KERNEL); |
363 | if (!pca9633_chip) | 363 | if (!pca963x_chip) |
364 | return -ENOMEM; | 364 | return -ENOMEM; |
365 | pca9633 = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca9633), | 365 | pca963x = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca963x), |
366 | GFP_KERNEL); | 366 | GFP_KERNEL); |
367 | if (!pca9633) | 367 | if (!pca963x) |
368 | return -ENOMEM; | 368 | return -ENOMEM; |
369 | 369 | ||
370 | i2c_set_clientdata(client, pca9633_chip); | 370 | i2c_set_clientdata(client, pca963x_chip); |
371 | 371 | ||
372 | mutex_init(&pca9633_chip->mutex); | 372 | mutex_init(&pca963x_chip->mutex); |
373 | pca9633_chip->chipdef = chip; | 373 | pca963x_chip->chipdef = chip; |
374 | pca9633_chip->client = client; | 374 | pca963x_chip->client = client; |
375 | pca9633_chip->leds = pca9633; | 375 | pca963x_chip->leds = pca963x; |
376 | 376 | ||
377 | /* Turn off LEDs by default*/ | 377 | /* Turn off LEDs by default*/ |
378 | i2c_smbus_write_byte_data(client, chip->ledout_base, 0x00); | 378 | i2c_smbus_write_byte_data(client, chip->ledout_base, 0x00); |
@@ -380,82 +380,82 @@ static int pca9633_probe(struct i2c_client *client, | |||
380 | i2c_smbus_write_byte_data(client, chip->ledout_base + 1, 0x00); | 380 | i2c_smbus_write_byte_data(client, chip->ledout_base + 1, 0x00); |
381 | 381 | ||
382 | for (i = 0; i < chip->n_leds; i++) { | 382 | for (i = 0; i < chip->n_leds; i++) { |
383 | pca9633[i].led_num = i; | 383 | pca963x[i].led_num = i; |
384 | pca9633[i].chip = pca9633_chip; | 384 | pca963x[i].chip = pca963x_chip; |
385 | 385 | ||
386 | /* Platform data can specify LED names and default triggers */ | 386 | /* Platform data can specify LED names and default triggers */ |
387 | if (pdata && i < pdata->leds.num_leds) { | 387 | if (pdata && i < pdata->leds.num_leds) { |
388 | if (pdata->leds.leds[i].name) | 388 | if (pdata->leds.leds[i].name) |
389 | snprintf(pca9633[i].name, | 389 | snprintf(pca963x[i].name, |
390 | sizeof(pca9633[i].name), "pca9633:%s", | 390 | sizeof(pca963x[i].name), "pca963x:%s", |
391 | pdata->leds.leds[i].name); | 391 | pdata->leds.leds[i].name); |
392 | if (pdata->leds.leds[i].default_trigger) | 392 | if (pdata->leds.leds[i].default_trigger) |
393 | pca9633[i].led_cdev.default_trigger = | 393 | pca963x[i].led_cdev.default_trigger = |
394 | pdata->leds.leds[i].default_trigger; | 394 | pdata->leds.leds[i].default_trigger; |
395 | } | 395 | } |
396 | if (!pdata || i >= pdata->leds.num_leds || | 396 | if (!pdata || i >= pdata->leds.num_leds || |
397 | !pdata->leds.leds[i].name) | 397 | !pdata->leds.leds[i].name) |
398 | snprintf(pca9633[i].name, sizeof(pca9633[i].name), | 398 | snprintf(pca963x[i].name, sizeof(pca963x[i].name), |
399 | "pca9633:%d:%.2x:%d", client->adapter->nr, | 399 | "pca963x:%d:%.2x:%d", client->adapter->nr, |
400 | client->addr, i); | 400 | client->addr, i); |
401 | 401 | ||
402 | pca9633[i].led_cdev.name = pca9633[i].name; | 402 | pca963x[i].led_cdev.name = pca963x[i].name; |
403 | pca9633[i].led_cdev.brightness_set = pca9633_led_set; | 403 | pca963x[i].led_cdev.brightness_set = pca963x_led_set; |
404 | 404 | ||
405 | if (pdata && pdata->blink_type == PCA9633_HW_BLINK) | 405 | if (pdata && pdata->blink_type == PCA963X_HW_BLINK) |
406 | pca9633[i].led_cdev.blink_set = pca9633_blink_set; | 406 | pca963x[i].led_cdev.blink_set = pca963x_blink_set; |
407 | 407 | ||
408 | INIT_WORK(&pca9633[i].work, pca9633_work); | 408 | INIT_WORK(&pca963x[i].work, pca963x_work); |
409 | 409 | ||
410 | err = led_classdev_register(&client->dev, &pca9633[i].led_cdev); | 410 | err = led_classdev_register(&client->dev, &pca963x[i].led_cdev); |
411 | if (err < 0) | 411 | if (err < 0) |
412 | goto exit; | 412 | goto exit; |
413 | } | 413 | } |
414 | 414 | ||
415 | /* Disable LED all-call address and set normal mode */ | 415 | /* Disable LED all-call address and set normal mode */ |
416 | i2c_smbus_write_byte_data(client, PCA9633_MODE1, 0x00); | 416 | i2c_smbus_write_byte_data(client, PCA963X_MODE1, 0x00); |
417 | 417 | ||
418 | /* Configure output: open-drain or totem pole (push-pull) */ | 418 | /* Configure output: open-drain or totem pole (push-pull) */ |
419 | if (pdata && pdata->outdrv == PCA9633_OPEN_DRAIN) | 419 | if (pdata && pdata->outdrv == PCA963X_OPEN_DRAIN) |
420 | i2c_smbus_write_byte_data(client, PCA9633_MODE2, 0x01); | 420 | i2c_smbus_write_byte_data(client, PCA963X_MODE2, 0x01); |
421 | 421 | ||
422 | return 0; | 422 | return 0; |
423 | 423 | ||
424 | exit: | 424 | exit: |
425 | while (i--) { | 425 | while (i--) { |
426 | led_classdev_unregister(&pca9633[i].led_cdev); | 426 | led_classdev_unregister(&pca963x[i].led_cdev); |
427 | cancel_work_sync(&pca9633[i].work); | 427 | cancel_work_sync(&pca963x[i].work); |
428 | } | 428 | } |
429 | 429 | ||
430 | return err; | 430 | return err; |
431 | } | 431 | } |
432 | 432 | ||
433 | static int pca9633_remove(struct i2c_client *client) | 433 | static int pca963x_remove(struct i2c_client *client) |
434 | { | 434 | { |
435 | struct pca9633 *pca9633 = i2c_get_clientdata(client); | 435 | struct pca963x *pca963x = i2c_get_clientdata(client); |
436 | int i; | 436 | int i; |
437 | 437 | ||
438 | for (i = 0; i < pca9633->chipdef->n_leds; i++) { | 438 | for (i = 0; i < pca963x->chipdef->n_leds; i++) { |
439 | led_classdev_unregister(&pca9633->leds[i].led_cdev); | 439 | led_classdev_unregister(&pca963x->leds[i].led_cdev); |
440 | cancel_work_sync(&pca9633->leds[i].work); | 440 | cancel_work_sync(&pca963x->leds[i].work); |
441 | } | 441 | } |
442 | 442 | ||
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | 445 | ||
446 | static struct i2c_driver pca9633_driver = { | 446 | static struct i2c_driver pca963x_driver = { |
447 | .driver = { | 447 | .driver = { |
448 | .name = "leds-pca9633", | 448 | .name = "leds-pca963x", |
449 | .owner = THIS_MODULE, | 449 | .owner = THIS_MODULE, |
450 | .of_match_table = of_match_ptr(of_pca9633_match), | 450 | .of_match_table = of_match_ptr(of_pca963x_match), |
451 | }, | 451 | }, |
452 | .probe = pca9633_probe, | 452 | .probe = pca963x_probe, |
453 | .remove = pca9633_remove, | 453 | .remove = pca963x_remove, |
454 | .id_table = pca9633_id, | 454 | .id_table = pca963x_id, |
455 | }; | 455 | }; |
456 | 456 | ||
457 | module_i2c_driver(pca9633_driver); | 457 | module_i2c_driver(pca963x_driver); |
458 | 458 | ||
459 | MODULE_AUTHOR("Peter Meerwald <p.meerwald@bct-electronic.com>"); | 459 | MODULE_AUTHOR("Peter Meerwald <p.meerwald@bct-electronic.com>"); |
460 | MODULE_DESCRIPTION("PCA9633 LED driver"); | 460 | MODULE_DESCRIPTION("PCA963X LED driver"); |
461 | MODULE_LICENSE("GPL v2"); | 461 | MODULE_LICENSE("GPL v2"); |
diff --git a/include/linux/platform_data/leds-pca9633.h b/include/linux/platform_data/leds-pca963x.h index 3c1037a81d34..e731f0036329 100644 --- a/include/linux/platform_data/leds-pca9633.h +++ b/include/linux/platform_data/leds-pca963x.h | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * PCA9633 LED chip driver. | 2 | * PCA963X LED chip driver. |
3 | * | 3 | * |
4 | * Copyright 2012 bct electronic GmbH | 4 | * Copyright 2012 bct electronic GmbH |
5 | * Copyright 2013 Qtechnology A/S | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
@@ -18,24 +19,24 @@ | |||
18 | * 02110-1301 USA | 19 | * 02110-1301 USA |
19 | */ | 20 | */ |
20 | 21 | ||
21 | #ifndef __LINUX_PCA9633_H | 22 | #ifndef __LINUX_PCA963X_H |
22 | #define __LINUX_PCA9633_H | 23 | #define __LINUX_PCA963X_H |
23 | #include <linux/leds.h> | 24 | #include <linux/leds.h> |
24 | 25 | ||
25 | enum pca9633_outdrv { | 26 | enum pca963x_outdrv { |
26 | PCA9633_OPEN_DRAIN, | 27 | PCA963X_OPEN_DRAIN, |
27 | PCA9633_TOTEM_POLE, /* aka push-pull */ | 28 | PCA963X_TOTEM_POLE, /* aka push-pull */ |
28 | }; | 29 | }; |
29 | 30 | ||
30 | enum pca9633_blink_type { | 31 | enum pca963x_blink_type { |
31 | PCA9633_SW_BLINK, | 32 | PCA963X_SW_BLINK, |
32 | PCA9633_HW_BLINK, | 33 | PCA963X_HW_BLINK, |
33 | }; | 34 | }; |
34 | 35 | ||
35 | struct pca9633_platform_data { | 36 | struct pca963x_platform_data { |
36 | struct led_platform_data leds; | 37 | struct led_platform_data leds; |
37 | enum pca9633_outdrv outdrv; | 38 | enum pca963x_outdrv outdrv; |
38 | enum pca9633_blink_type blink_type; | 39 | enum pca963x_blink_type blink_type; |
39 | }; | 40 | }; |
40 | 41 | ||
41 | #endif /* __LINUX_PCA9633_H*/ | 42 | #endif /* __LINUX_PCA963X_H*/ |