26
26
#include <linux/irq.h>
27
27
#include <linux/pinctrl/machine.h>
28
28
#include <linux/pinctrl/pinconf-generic.h>
29
+ #include <linux/platform_data/pwm-renesas-tpu.h>
29
30
#include <linux/platform_device.h>
30
31
#include <linux/delay.h>
31
32
#include <linux/io.h>
37
38
#include <linux/input/sh_keysc.h>
38
39
#include <linux/gpio_keys.h>
39
40
#include <linux/leds.h>
41
+ #include <linux/leds_pwm.h>
40
42
#include <linux/irqchip/arm-gic.h>
41
- #include <linux/platform_data/leds-renesas-tpu.h>
42
43
#include <linux/mmc/host.h>
43
44
#include <linux/mmc/sh_mmcif.h>
44
45
#include <linux/mfd/tmio.h>
@@ -186,116 +187,100 @@ static struct platform_device gpio_leds_device = {
186
187
};
187
188
188
189
/* TPU LED */
189
- static struct led_renesas_tpu_config led_renesas_tpu12_pdata = {
190
- .name = "V2513" ,
191
- .pin_gpio_fn = GPIO_FN_TPU1TO2 ,
192
- .pin_gpio = 153 ,
193
- .channel_offset = 0x90 ,
194
- .timer_bit = 2 ,
195
- .max_brightness = 1000 ,
196
- };
197
-
198
- static struct resource tpu12_resources [] = {
190
+ static struct resource tpu1_pwm_resources [] = {
199
191
[0 ] = {
200
- .name = "TPU12" ,
201
- .start = 0xe6610090 ,
202
- .end = 0xe66100b5 ,
192
+ .start = 0xe6610000 ,
193
+ .end = 0xe66100ff ,
203
194
.flags = IORESOURCE_MEM ,
204
195
},
205
196
};
206
197
207
- static struct platform_device leds_tpu12_device = {
208
- .name = "leds-renesas-tpu" ,
209
- .id = 12 ,
210
- .dev = {
211
- .platform_data = & led_renesas_tpu12_pdata ,
212
- },
213
- .num_resources = ARRAY_SIZE (tpu12_resources ),
214
- .resource = tpu12_resources ,
198
+ static struct platform_device tpu1_pwm_device = {
199
+ .name = "renesas-tpu-pwm" ,
200
+ .id = 1 ,
201
+ .num_resources = ARRAY_SIZE (tpu1_pwm_resources ),
202
+ .resource = tpu1_pwm_resources ,
215
203
};
216
204
217
- static struct led_renesas_tpu_config led_renesas_tpu41_pdata = {
218
- .name = "V2514" ,
219
- .pin_gpio_fn = GPIO_FN_TPU4TO1 ,
220
- .pin_gpio = 199 ,
221
- .channel_offset = 0x50 ,
222
- .timer_bit = 1 ,
223
- .max_brightness = 1000 ,
224
- };
225
-
226
- static struct resource tpu41_resources [] = {
205
+ static struct resource tpu2_pwm_resources [] = {
227
206
[0 ] = {
228
- .name = "TPU41" ,
229
- .start = 0xe6640050 ,
230
- .end = 0xe6640075 ,
207
+ .start = 0xe6620000 ,
208
+ .end = 0xe66200ff ,
231
209
.flags = IORESOURCE_MEM ,
232
210
},
233
211
};
234
212
235
- static struct platform_device leds_tpu41_device = {
236
- .name = "leds-renesas-tpu" ,
237
- .id = 41 ,
238
- .dev = {
239
- .platform_data = & led_renesas_tpu41_pdata ,
213
+ static struct platform_device tpu2_pwm_device = {
214
+ .name = "renesas-tpu-pwm" ,
215
+ .id = 2 ,
216
+ .num_resources = ARRAY_SIZE (tpu2_pwm_resources ),
217
+ .resource = tpu2_pwm_resources ,
218
+ };
219
+
220
+ static struct resource tpu3_pwm_resources [] = {
221
+ [0 ] = {
222
+ .start = 0xe6630000 ,
223
+ .end = 0xe66300ff ,
224
+ .flags = IORESOURCE_MEM ,
240
225
},
241
- .num_resources = ARRAY_SIZE (tpu41_resources ),
242
- .resource = tpu41_resources ,
243
226
};
244
227
245
- static struct led_renesas_tpu_config led_renesas_tpu21_pdata = {
246
- .name = "V2515" ,
247
- .pin_gpio_fn = GPIO_FN_TPU2TO1 ,
248
- .pin_gpio = 197 ,
249
- .channel_offset = 0x50 ,
250
- .timer_bit = 1 ,
251
- .max_brightness = 1000 ,
228
+ static struct platform_device tpu3_pwm_device = {
229
+ .name = "renesas-tpu-pwm" ,
230
+ .id = 3 ,
231
+ .num_resources = ARRAY_SIZE (tpu3_pwm_resources ),
232
+ .resource = tpu3_pwm_resources ,
252
233
};
253
234
254
- static struct resource tpu21_resources [] = {
235
+ static struct resource tpu4_pwm_resources [] = {
255
236
[0 ] = {
256
- .name = "TPU21" ,
257
- .start = 0xe6620050 ,
258
- .end = 0xe6620075 ,
237
+ .start = 0xe6640000 ,
238
+ .end = 0xe66400ff ,
259
239
.flags = IORESOURCE_MEM ,
260
240
},
261
241
};
262
242
263
- static struct platform_device leds_tpu21_device = {
264
- .name = "leds-renesas-tpu" ,
265
- .id = 21 ,
266
- .dev = {
267
- .platform_data = & led_renesas_tpu21_pdata ,
243
+ static struct platform_device tpu4_pwm_device = {
244
+ .name = "renesas-tpu-pwm" ,
245
+ .id = 4 ,
246
+ .num_resources = ARRAY_SIZE (tpu4_pwm_resources ),
247
+ .resource = tpu4_pwm_resources ,
248
+ };
249
+
250
+ static struct pwm_lookup pwm_lookup [] = {
251
+ PWM_LOOKUP ("renesas-tpu-pwm.1" , 2 , "leds-pwm.0" , "V2513" ),
252
+ PWM_LOOKUP ("renesas-tpu-pwm.2" , 1 , "leds-pwm.0" , "V2515" ),
253
+ PWM_LOOKUP ("renesas-tpu-pwm.3" , 0 , "leds-pwm.0" , "KEYLED" ),
254
+ PWM_LOOKUP ("renesas-tpu-pwm.4" , 1 , "leds-pwm.0" , "V2514" ),
255
+ };
256
+
257
+ static struct led_pwm tpu_pwm_leds [] = {
258
+ {
259
+ .name = "V2513" ,
260
+ .max_brightness = 1000 ,
261
+ }, {
262
+ .name = "V2515" ,
263
+ .max_brightness = 1000 ,
264
+ }, {
265
+ .name = "KEYLED" ,
266
+ .max_brightness = 1000 ,
267
+ }, {
268
+ .name = "V2514" ,
269
+ .max_brightness = 1000 ,
268
270
},
269
- .num_resources = ARRAY_SIZE (tpu21_resources ),
270
- .resource = tpu21_resources ,
271
271
};
272
272
273
- static struct led_renesas_tpu_config led_renesas_tpu30_pdata = {
274
- .name = "KEYLED" ,
275
- .pin_gpio_fn = GPIO_FN_TPU3TO0 ,
276
- .pin_gpio = 163 ,
277
- .channel_offset = 0x10 ,
278
- .timer_bit = 0 ,
279
- .max_brightness = 1000 ,
273
+ static struct led_pwm_platform_data leds_pwm_pdata = {
274
+ .num_leds = ARRAY_SIZE (tpu_pwm_leds ),
275
+ .leds = tpu_pwm_leds ,
280
276
};
281
277
282
- static struct resource tpu30_resources [] = {
283
- [0 ] = {
284
- .name = "TPU30" ,
285
- .start = 0xe6630010 ,
286
- .end = 0xe6630035 ,
287
- .flags = IORESOURCE_MEM ,
288
- },
289
- };
290
-
291
- static struct platform_device leds_tpu30_device = {
292
- .name = "leds-renesas-tpu" ,
293
- .id = 30 ,
278
+ static struct platform_device leds_pwm_device = {
279
+ .name = "leds-pwm" ,
280
+ .id = 0 ,
294
281
.dev = {
295
- .platform_data = & led_renesas_tpu30_pdata ,
282
+ .platform_data = & leds_pwm_pdata ,
296
283
},
297
- .num_resources = ARRAY_SIZE (tpu30_resources ),
298
- .resource = tpu30_resources ,
299
284
};
300
285
301
286
/* Fixed 1.8V regulator to be used by MMCIF */
@@ -426,10 +411,11 @@ static struct platform_device *kota2_devices[] __initdata = {
426
411
& keysc_device ,
427
412
& gpio_keys_device ,
428
413
& gpio_leds_device ,
429
- & leds_tpu12_device ,
430
- & leds_tpu41_device ,
431
- & leds_tpu21_device ,
432
- & leds_tpu30_device ,
414
+ & tpu1_pwm_device ,
415
+ & tpu2_pwm_device ,
416
+ & tpu3_pwm_device ,
417
+ & tpu4_pwm_device ,
418
+ & leds_pwm_device ,
433
419
& mmcif_device ,
434
420
& sdhi0_device ,
435
421
& sdhi1_device ,
@@ -512,6 +498,15 @@ static const struct pinctrl_map kota2_pinctrl_map[] = {
512
498
"bsc_cs5_a" , "bsc" ),
513
499
PIN_MAP_MUX_GROUP_DEFAULT ("smsc911x.0" , "pfc-sh73a0" ,
514
500
"bsc_we0" , "bsc" ),
501
+ /* TPU */
502
+ PIN_MAP_MUX_GROUP_DEFAULT ("renesas-tpu-pwm.1" , "pfc-sh73a0" ,
503
+ "tpu1_to2" , "tpu1" ),
504
+ PIN_MAP_MUX_GROUP_DEFAULT ("renesas-tpu-pwm.2" , "pfc-sh73a0" ,
505
+ "tpu2_to1" , "tpu2" ),
506
+ PIN_MAP_MUX_GROUP_DEFAULT ("renesas-tpu-pwm.3" , "pfc-sh73a0" ,
507
+ "tpu3_to0" , "tpu3" ),
508
+ PIN_MAP_MUX_GROUP_DEFAULT ("renesas-tpu-pwm.4" , "pfc-sh73a0" ,
509
+ "tpu4_to1" , "tpu4" ),
515
510
};
516
511
517
512
static void __init kota2_init (void )
@@ -524,6 +519,8 @@ static void __init kota2_init(void)
524
519
525
520
pinctrl_register_mappings (kota2_pinctrl_map ,
526
521
ARRAY_SIZE (kota2_pinctrl_map ));
522
+ pwm_add_table (pwm_lookup , ARRAY_SIZE (pwm_lookup ));
523
+
527
524
sh73a0_pinmux_init ();
528
525
529
526
/* SMSC911X */
0 commit comments