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 lm3556
^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) * Texas Instrument:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)   1.5 A Synchronous Boost LED Flash Driver w/ High-Side Current Source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) * Datasheet: http://www.national.com/ds/LM/LM3556.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)       - Daniel Jeong
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	Contact:Daniel Jeong(daniel.jeong-at-ti.com, gshark.jeong-at-gmail.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) There are 3 functions in LM3556, Flash, Torch and Indicator.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) Flash Mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) ^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) In Flash Mode, the LED current source(LED) provides 16 target current levels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) from 93.75 mA to 1500 mA.The Flash currents are adjusted via the CURRENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) or by pulling the STROBE pin HIGH.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) LM3556 Flash can be controlled through sys/class/leds/flash/brightness file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) * if STROBE pin is enabled, below example control brightness only, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)   ON / OFF will be controlled by STROBE pin.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) Flash Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) OFF::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	#echo 0 > sys/class/leds/flash/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 93.75 mA::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	#echo 1 > sys/class/leds/flash/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 1500  mA::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	#echo 16 > sys/class/leds/flash/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) Torch Mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) ^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) In Torch Mode, the current source(LED) is programmed via the CURRENT CONTROL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) hardware TORCH input.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) LM3556 torch can be controlled through sys/class/leds/torch/brightness file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) * if TORCH pin is enabled, below example control brightness only,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) and ON / OFF will be controlled by TORCH pin.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) Torch Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) OFF::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	#echo 0 > sys/class/leds/torch/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 46.88 mA::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	#echo 1 > sys/class/leds/torch/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 375 mA::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	#echo 8 > sys/class/leds/torch/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) Indicator Mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) ^^^^^^^^^^^^^^
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) Indicator pattern can be set through sys/class/leds/indicator/pattern file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) and 4 patterns are pre-defined in indicator_pattern array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) According to N-lank, Pulse time and N Period values, different pattern wiill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) be generated.If you want new patterns for your own device, change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) indicator_pattern array with your own values and INDIC_PATTERN_SIZE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) Please refer datasheet for more detail about N-Blank, Pulse time and N Period.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) Indicator pattern example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) pattern 0::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	#echo 0 > sys/class/leds/indicator/pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) pattern 3::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	#echo 3 > sys/class/leds/indicator/pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) Indicator brightness can be controlled through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) sys/class/leds/indicator/brightness file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) OFF::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	#echo 0 > sys/class/leds/indicator/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 5.86 mA::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	#echo 1 > sys/class/leds/indicator/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 46.875mA::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	#echo 8 > sys/class/leds/indicator/brightness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) Notes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) -----
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) Driver expects it is registered using the i2c_board_info mechanism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) To register the chip at address 0x63 on specific adapter, set the platform data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) according to include/linux/platform_data/leds-lm3556.h, set the i2c board info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) Example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	static struct i2c_board_info board_i2c_ch4[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			 I2C_BOARD_INFO(LM3556_NAME, 0x63),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			 .platform_data = &lm3556_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		 },
^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) and register it in the platform init function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) Example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	board_register_i2c_bus(4, 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 				board_i2c_ch4, ARRAY_SIZE(board_i2c_ch4));