Skip to content

Commit b885966

Browse files
Laurent Pincharthorms
authored andcommitted
ARM: shmobile: kota2: Use leds-pwm + pwm-rmob
Instead of using the LED-specific TPU PWM driver, switch to the generic TPU PWM driver with leds-pwm. Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Simon Horman <[email protected]>
1 parent d58226a commit b885966

File tree

2 files changed

+90
-91
lines changed

2 files changed

+90
-91
lines changed

arch/arm/mach-shmobile/board-kota2.c

Lines changed: 83 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/irq.h>
2727
#include <linux/pinctrl/machine.h>
2828
#include <linux/pinctrl/pinconf-generic.h>
29+
#include <linux/platform_data/pwm-renesas-tpu.h>
2930
#include <linux/platform_device.h>
3031
#include <linux/delay.h>
3132
#include <linux/io.h>
@@ -37,8 +38,8 @@
3738
#include <linux/input/sh_keysc.h>
3839
#include <linux/gpio_keys.h>
3940
#include <linux/leds.h>
41+
#include <linux/leds_pwm.h>
4042
#include <linux/irqchip/arm-gic.h>
41-
#include <linux/platform_data/leds-renesas-tpu.h>
4243
#include <linux/mmc/host.h>
4344
#include <linux/mmc/sh_mmcif.h>
4445
#include <linux/mfd/tmio.h>
@@ -186,116 +187,100 @@ static struct platform_device gpio_leds_device = {
186187
};
187188

188189
/* 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[] = {
199191
[0] = {
200-
.name = "TPU12",
201-
.start = 0xe6610090,
202-
.end = 0xe66100b5,
192+
.start = 0xe6610000,
193+
.end = 0xe66100ff,
203194
.flags = IORESOURCE_MEM,
204195
},
205196
};
206197

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,
215203
};
216204

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[] = {
227206
[0] = {
228-
.name = "TPU41",
229-
.start = 0xe6640050,
230-
.end = 0xe6640075,
207+
.start = 0xe6620000,
208+
.end = 0xe66200ff,
231209
.flags = IORESOURCE_MEM,
232210
},
233211
};
234212

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,
240225
},
241-
.num_resources = ARRAY_SIZE(tpu41_resources),
242-
.resource = tpu41_resources,
243226
};
244227

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,
252233
};
253234

254-
static struct resource tpu21_resources[] = {
235+
static struct resource tpu4_pwm_resources[] = {
255236
[0] = {
256-
.name = "TPU21",
257-
.start = 0xe6620050,
258-
.end = 0xe6620075,
237+
.start = 0xe6640000,
238+
.end = 0xe66400ff,
259239
.flags = IORESOURCE_MEM,
260240
},
261241
};
262242

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,
268270
},
269-
.num_resources = ARRAY_SIZE(tpu21_resources),
270-
.resource = tpu21_resources,
271271
};
272272

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,
280276
};
281277

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,
294281
.dev = {
295-
.platform_data = &led_renesas_tpu30_pdata,
282+
.platform_data = &leds_pwm_pdata,
296283
},
297-
.num_resources = ARRAY_SIZE(tpu30_resources),
298-
.resource = tpu30_resources,
299284
};
300285

301286
/* Fixed 1.8V regulator to be used by MMCIF */
@@ -426,10 +411,11 @@ static struct platform_device *kota2_devices[] __initdata = {
426411
&keysc_device,
427412
&gpio_keys_device,
428413
&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,
433419
&mmcif_device,
434420
&sdhi0_device,
435421
&sdhi1_device,
@@ -512,6 +498,15 @@ static const struct pinctrl_map kota2_pinctrl_map[] = {
512498
"bsc_cs5_a", "bsc"),
513499
PIN_MAP_MUX_GROUP_DEFAULT("smsc911x.0", "pfc-sh73a0",
514500
"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"),
515510
};
516511

517512
static void __init kota2_init(void)
@@ -524,6 +519,8 @@ static void __init kota2_init(void)
524519

525520
pinctrl_register_mappings(kota2_pinctrl_map,
526521
ARRAY_SIZE(kota2_pinctrl_map));
522+
pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
523+
527524
sh73a0_pinmux_init();
528525

529526
/* SMSC911X */

arch/arm/mach-shmobile/clock-sh73a0.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ enum { MSTP001,
555555
MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
556556
MSTP331, MSTP329, MSTP328, MSTP325, MSTP323, MSTP322,
557557
MSTP314, MSTP313, MSTP312, MSTP311,
558-
MSTP303, MSTP302, MSTP301, MSTP300,
558+
MSTP304, MSTP303, MSTP302, MSTP301, MSTP300,
559559
MSTP411, MSTP410, MSTP403,
560560
MSTP_NR };
561561

@@ -593,6 +593,7 @@ static struct clk mstp_clks[MSTP_NR] = {
593593
[MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */
594594
[MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */
595595
[MSTP311] = MSTP(&div6_clks[DIV6_SDHI2], SMSTPCR3, 11, 0), /* SDHI2 */
596+
[MSTP304] = MSTP(&main_div2_clk, SMSTPCR3, 4, 0), /* TPU0 */
596597
[MSTP303] = MSTP(&main_div2_clk, SMSTPCR3, 3, 0), /* TPU1 */
597598
[MSTP302] = MSTP(&main_div2_clk, SMSTPCR3, 2, 0), /* TPU2 */
598599
[MSTP301] = MSTP(&main_div2_clk, SMSTPCR3, 1, 0), /* TPU3 */
@@ -669,10 +670,11 @@ static struct clk_lookup lookups[] = {
669670
CLKDEV_DEV_ID("e6bd0000.mmcif", &mstp_clks[MSTP312]), /* MMCIF0 */
670671
CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP311]), /* SDHI2 */
671672
CLKDEV_DEV_ID("ee140000.sdhi", &mstp_clks[MSTP311]), /* SDHI2 */
672-
CLKDEV_DEV_ID("leds-renesas-tpu.12", &mstp_clks[MSTP303]), /* TPU1 */
673-
CLKDEV_DEV_ID("leds-renesas-tpu.21", &mstp_clks[MSTP302]), /* TPU2 */
674-
CLKDEV_DEV_ID("leds-renesas-tpu.30", &mstp_clks[MSTP301]), /* TPU3 */
675-
CLKDEV_DEV_ID("leds-renesas-tpu.41", &mstp_clks[MSTP300]), /* TPU4 */
673+
CLKDEV_DEV_ID("renesas-tpu-pwm.0", &mstp_clks[MSTP304]), /* TPU0 */
674+
CLKDEV_DEV_ID("renesas-tpu-pwm.1", &mstp_clks[MSTP303]), /* TPU1 */
675+
CLKDEV_DEV_ID("renesas-tpu-pwm.2", &mstp_clks[MSTP302]), /* TPU2 */
676+
CLKDEV_DEV_ID("renesas-tpu-pwm.3", &mstp_clks[MSTP301]), /* TPU3 */
677+
CLKDEV_DEV_ID("renesas-tpu-pwm.4", &mstp_clks[MSTP300]), /* TPU4 */
676678
CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* I2C3 */
677679
CLKDEV_DEV_ID("e6826000.i2c", &mstp_clks[MSTP411]), /* I2C3 */
678680
CLKDEV_DEV_ID("i2c-sh_mobile.4", &mstp_clks[MSTP410]), /* I2C4 */

0 commit comments

Comments
 (0)