leds: Renesas TPU LED driver
PATCH 1/1 leds: Renesas TPU LED driver
From: Magnus Damm <[email protected]>
This patch adds a LED driver for a single timer channel of the TPU hardware block commonly found in Renesas SoCs.
The driver has been written with optimal Power Management in mind, so to save power the LED is driven as a regular GPIO pin in case of maximum brightness and power off which allows the TPU hardware to be idle and which in turn allows the clocks to be stopped and the power domain to be turned off transparently.
Any other brightness level requires use of the TPU hardware in PWM mode. TPU hardware device clocks and power are managed through Runtime PM. System suspend and resume is known to be working - during suspend the LED is set to off by the generic LED code.
The TPU hardware timer is equipeed with a 16-bit counter together with an up-to-divide-by-64 prescaler which makes the hardware suitable for brightness control. Hardware blink is unsupported.
The LED PWM waveform has been verified with a Fluke 123 Scope meter on a sh7372 Mackerel board. Tested with experimental sh7372 A3SP power domain patches. Platform device bind/unbind tested ok.
---
drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 drivers/leds/leds-renesas-tpu.c | 343 ++++++++++++++++++++++++++++++++++++++ include/linux/leds-renesas-tpu.h | 14 + 4 files changed, 370 insertions(+)
drivers/leds/Kconfig +12 -0
@@ -399,6 +399,18 @@ config LEDS_ASIC3 cannot be used. This driver supports hardware blinking with an on+off period from 62ms to 125s. Say Y to enable LEDs on the HP iPAQ hx4700. +config LEDS_RENESAS_TPU + bool "LED support for Renesas TPU" + depends on LEDS_CLASS + help + This option enables build of the LED TPU platform driver, + suitable to drive any TPU channel on newer Renesas SoCs. + The driver controls the GPIO pin connected to the LED via + the GPIO framework and expects the LED to be connected to + a pin that can be driven in both GPIO mode and using TPU + pin function. The latter to support brightness control. + Brightness control is supported but hardware blinking is not. + config LEDS_TRIGGERS bool "LED Trigger support" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -43,6 +43,7 @@ obj-$(CONFIG_LEDS_MC13783) += leds-mc13 obj-$(CONFIG_LEDS_NS2) += leds-ns2.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o +obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
drivers/leds/leds-renesas-tpu.c new file +343 -0
343 lines not on this page · raw message
include/linux/leds-renesas-tpu.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __LEDS_RENESAS_TPU_H__ +#define __LEDS_RENESAS_TPU_H__ + +struct led_renesas_tpu_config { +char *name; +unsigned pin_gpio_fn; +unsigned pin_gpio; +unsigned int channel_offset; +unsigned int timer_bit; +unsigned int max_brightness; +unsigned int refresh_rate; +}; + +#endif /* __LEDS_RENESAS_TPU_H__ */