• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1========================
2Kernel driver for lp5521
3========================
4
5* National Semiconductor LP5521 led driver chip
6* Datasheet: http://www.national.com/pf/LP/LP5521.html
7
8Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
9
10Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
11
12Description
13-----------
14
15LP5521 can drive up to 3 channels. Leds can be controlled directly via
16the led class control interface. Channels have generic names:
17lp5521:channelx, where x is 0 .. 2
18
19All three channels can be also controlled using the engine micro programs.
20More details of the instructions can be found from the public data sheet.
21
22LP5521 has the internal program memory for running various LED patterns.
23There are two ways to run LED patterns.
24
251) Legacy interface - enginex_mode and enginex_load
26   Control interface for the engines:
27
28   x is 1 .. 3
29
30   enginex_mode:
31	disabled, load, run
32   enginex_load:
33	store program (visible only in engine load mode)
34
35  Example (start to blink the channel 2 led)::
36
37	cd   /sys/class/leds/lp5521:channel2/device
38	echo "load" > engine3_mode
39	echo "037f4d0003ff6000" > engine3_load
40	echo "run" > engine3_mode
41
42  To stop the engine::
43
44	echo "disabled" > engine3_mode
45
462) Firmware interface - LP55xx common interface
47
48For the details, please refer to 'firmware' section in leds-lp55xx.txt
49
50sysfs contains a selftest entry.
51
52The test communicates with the chip and checks that
53the clock mode is automatically set to the requested one.
54
55Each channel has its own led current settings.
56
57- /sys/class/leds/lp5521:channel0/led_current - RW
58- /sys/class/leds/lp5521:channel0/max_current - RO
59
60Format: 10x mA i.e 10 means 1.0 mA
61
62example platform data::
63
64  static struct lp55xx_led_config lp5521_led_config[] = {
65	  {
66		.name = "red",
67		  .chan_nr        = 0,
68		  .led_current    = 50,
69		.max_current    = 130,
70	  }, {
71		.name = "green",
72		  .chan_nr        = 1,
73		  .led_current    = 0,
74		.max_current    = 130,
75	  }, {
76		.name = "blue",
77		  .chan_nr        = 2,
78		  .led_current    = 0,
79		.max_current    = 130,
80	  }
81  };
82
83  static int lp5521_setup(void)
84  {
85	/* setup HW resources */
86  }
87
88  static void lp5521_release(void)
89  {
90	/* Release HW resources */
91  }
92
93  static void lp5521_enable(bool state)
94  {
95	/* Control of chip enable signal */
96  }
97
98  static struct lp55xx_platform_data lp5521_platform_data = {
99	  .led_config     = lp5521_led_config,
100	  .num_channels   = ARRAY_SIZE(lp5521_led_config),
101	  .clock_mode     = LP55XX_CLOCK_EXT,
102	  .setup_resources   = lp5521_setup,
103	  .release_resources = lp5521_release,
104	  .enable            = lp5521_enable,
105  };
106
107Note:
108  chan_nr can have values between 0 and 2.
109  The name of each channel can be configurable.
110  If the name field is not defined, the default name will be set to 'xxxx:channelN'
111  (XXXX : pdata->label or i2c client name, N : channel number)
112
113
114If the current is set to 0 in the platform data, that channel is
115disabled and it is not visible in the sysfs.
116