Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) Kernel driver for lp5523
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) * National Semiconductor LP5523 led driver chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) * Datasheet: http://www.national.com/pf/LP/LP5523.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) LP5523 can drive up to 9 channels. Leds can be controlled directly via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) the led class control interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) The name of each channel is configurable in the platform data - name and label.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) There are three options to make the channel name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) a) Define the 'name' in the platform data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) To make specific channel name, then use 'name' platform data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) - /sys/class/leds/R1               (name: 'R1')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) - /sys/class/leds/B1               (name: 'B1')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) b) Use the 'label' with no 'name' field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) For one device name with channel number, then use 'label'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) - /sys/class/leds/RGB:channelN     (label: 'RGB', N: 0 ~ 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) c) Default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) If both fields are NULL, 'lp5523' is used by default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) - /sys/class/leds/lp5523:channelN  (N: 0 ~ 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) LP5523 has the internal program memory for running various LED patterns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) There are two ways to run LED patterns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 1) Legacy interface - enginex_mode, enginex_load and enginex_leds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)   Control interface for the engines:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)   x is 1 .. 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)   enginex_mode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	disabled, load, run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)   enginex_load:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	microcode load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)   enginex_leds:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	led mux control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)   ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	cd /sys/class/leds/lp5523:channel2/device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	echo "load" > engine3_mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	echo "9d80400004ff05ff437f0000" > engine3_load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	echo "111111111" > engine3_leds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	echo "run" > engine3_mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)   To stop the engine::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	echo "disabled" > engine3_mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 2) Firmware interface - LP55xx common interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) For the details, please refer to 'firmware' section in leds-lp55xx.txt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) LP5523 has three master faders. If a channel is mapped to one of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) the master faders, its output is dimmed based on the value of the master
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) fader.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) For example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)   echo "123000123" > master_fader_leds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) creates the following channel-fader mappings::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)   channel 0,6 to master_fader1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)   channel 1,7 to master_fader2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)   channel 2,8 to master_fader3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) Then, to have 25% of the original output on channel 0,6::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)   echo 64 > master_fader1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) To have 0% of the original output (i.e. no output) channel 1,7::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)   echo 0 > master_fader2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) To have 100% of the original output (i.e. no dimming) on channel 2,8::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)   echo 255 > master_fader3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) To clear all master fader controls::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)   echo "000000000" > master_fader_leds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) Selftest uses always the current from the platform data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) Each channel contains led current settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) - /sys/class/leds/lp5523:channel2/led_current - RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) - /sys/class/leds/lp5523:channel2/max_current - RO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) Format: 10x mA i.e 10 means 1.0 mA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) Example platform data::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	static struct lp55xx_led_config lp5523_led_config[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			.name		= "D1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			.chan_nr        = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			.led_current    = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			.max_current    = 130,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			.chan_nr        = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			.led_current    = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			.max_current    = 130,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	static int lp5523_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		/* Setup HW resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	static void lp5523_release(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		/* Release HW resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	static void lp5523_enable(bool state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		/* Control chip enable signal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	static struct lp55xx_platform_data lp5523_platform_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.led_config     = lp5523_led_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		.num_channels   = ARRAY_SIZE(lp5523_led_config),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		.clock_mode     = LP55XX_CLOCK_EXT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		.setup_resources   = lp5523_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		.release_resources = lp5523_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		.enable            = lp5523_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) Note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)   chan_nr can have values between 0 and 8.