Skip to contentSkip to conversation

Video: Backlight: Add a MMIO backlight driver using DT.

PATCH New Martin Fuzzey 1 participant 1 message Nov 19, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Video: Backlight: Add a MMIO backlight driver using DT.

Some boards have very simple backlight controllers consisting of a latch on the bus with a bunch of resistors used as a "poor man's DAC".

Prior to the device tree such boards were supported using generic-bl with a callback in the board file to poke the hardware.

This driver allows such hardware to be supported
on device tree based platforms where callbacks
and board files cannot be used.

---
 .../bindings/video/backlight/mmio_bl.txt           |   50 ++++
 drivers/video/backlight/Kconfig                    |   12 +
 drivers/video/backlight/Makefile                   |    1 
 drivers/video/backlight/mmio_bl.c                  |  225 ++++++++++++++++++++
 4 files changed, 288 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/video/backlight/mmio_bl.txt
 create mode 100644 drivers/video/backlight/mmio_bl.c
Documentation/devicetree/bindings/video/backlight/mmio_bl.txt new file +50 -0
new file mode 100644
index 0000000..39a53d0
@@ -0,0 +1,50 @@
+Memory mapped IO backlight bindings
+===================================
+
+Required properties:
+ - compatible : mmio-bl
+ - reg : register address and size
+
+Optional properties:
+ - reg-width : Register size in bits (default = 8 * size of reg)
+ - reg-shift : Register shift in bits (default = 0)
+ - max-brightness : Maximum brightness (defaults to all bits 1)
+ - default-brightness : Default brightness (defaults to all bits 1)
+
+The size of reg must be 1,2 or 4 bytes and is used to determine the type
+of bus access.
+
+The brightness values are silently clamped to the maximum supported by
+reg-width.
+
+Examples:
+	backlight at 1,0 {
+		compatible = "mmio-bl";
+		reg = <1 0 2>;
+	};
+	Defines a 16 bit register with max and default brightness 0xFFFF
+
+
+	backlight at 1,0 {
+		compatible = "mmio-bl";
+		reg = <1 0 1>;
+		reg-width = <6>;
+		reg-shift = <1>;
+		max-brightness = <50>;
+		default-brightness = <40>;
+	};
+	Defines a 6 bit register on D1->D7 so that
+		brightness 0 => X000000X
+		brigtness 50 => X110010X
+
+
+	backlight at 1,0 {
+		compatible = "mmio-bl";
+		reg = <1 0 1>;
+		reg-width = <6>;
+		max-brightness = <100>;
+		default-brightness = <100>;
+	};
+	Defines a 6 bit register on D0->D5 with maximum and default
+	brighntesses of 63 (since not enough bits for 100)
+
drivers/video/backlight/Kconfig +12 -0
index 765a945..6482092 100644
@@ -185,6 +185,18 @@ config BACKLIGHT_GENERIC
 	  known as the Corgi backlight driver. If you have a Sharp Zaurus
 	  SL-C7xx, SL-Cxx00 or SL-6000x say y.
 
+config BACKLIGHT_MMIO
+	tristate "Memory Mapped IO Backlight Driver"
+	depends on OF
+	default n
+	help
+	  Say Y to enable backlight driver for simple memory mapped latches.
+
+	  Typically this type of backlight interface consists of a latch on
+	  the bus with a bunch of resistors behind it (a poor man's DAC).
+	  A device tree configuration is required, non DT systems can
+	  use BACKLIGHT_GENERIC instead with a board specific callback.
+
 config BACKLIGHT_LM3533
 	tristate "Backlight Driver for LM3533"
 	depends on BACKLIGHT_CLASS_DEVICE
drivers/video/backlight/Makefile +1 -0
index e7ce729..9de5aa2 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
 obj-$(CONFIG_BACKLIGHT_ATMEL_PWM)    += atmel-pwm-bl.o
 obj-$(CONFIG_BACKLIGHT_EP93XX)	+= ep93xx_bl.o
 obj-$(CONFIG_BACKLIGHT_GENERIC)	+= generic_bl.o
+obj-$(CONFIG_BACKLIGHT_MMIO)	+= mmio_bl.o
 obj-$(CONFIG_BACKLIGHT_HP700)	+= jornada720_bl.o
 obj-$(CONFIG_BACKLIGHT_HP680)	+= hp680_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3533)	+= lm3533_bl.o
drivers/video/backlight/mmio_bl.c new file +225 -0

225 lines not on this page · raw message