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 lp5562
^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) * TI LP5562 LED Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) Author: Milo(Woogyom) Kim <milo.kim@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)   LP5562 can drive up to 4 channels. R/G/B and White.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)   LEDs can be controlled directly via the led class control interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)   All four channels can be also controlled using the engine micro programs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)   LP5562 has the internal program memory for running various LED patterns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)   For the details, please refer to 'firmware' section in leds-lp55xx.txt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) Device attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) ================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) engine_mux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)   3 Engines are allocated in LP5562, but the number of channel is 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)   Therefore each channel should be mapped to the engine number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)   Value: RGB or W
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)   This attribute is used for programming LED data with the firmware interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)   Unlike the LP5521/LP5523/55231, LP5562 has unique feature for the engine mux,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)   so additional sysfs is required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)   LED Map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)   ===== === ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)   Red   ... Engine 1 (fixed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)   Green ... Engine 2 (fixed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)   Blue  ... Engine 3 (fixed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)   White ... Engine 1 or 2 or 3 (selective)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)   ===== === ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) How to load the program data using engine_mux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) =============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)   Before loading the LP5562 program data, engine_mux should be written between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)   the engine selection and loading the firmware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)   Engine mux has two different mode, RGB and W.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)   RGB is used for loading RGB program data, W is used for W program data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)   For example, run blinking green channel pattern::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)     echo 2 > /sys/bus/i2c/devices/xxxx/select_engine     # 2 is for green channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)     echo "RGB" > /sys/bus/i2c/devices/xxxx/engine_mux    # engine mux for RGB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)     echo 1 > /sys/class/firmware/lp5562/loading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)     echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)     echo 0 > /sys/class/firmware/lp5562/loading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)     echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)   To run a blinking white pattern::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)     echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)     echo "W" > /sys/bus/i2c/devices/xxxx/engine_mux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)     echo 1 > /sys/class/firmware/lp5562/loading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)     echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)     echo 0 > /sys/class/firmware/lp5562/loading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)     echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) How to load the predefined patterns
^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)   Please refer to 'leds-lp55xx.txt"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) Setting Current of Each Channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)   Like LP5521 and LP5523/55231, LP5562 provides LED current settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)   The 'led_current' and 'max_current' are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) Example of Platform data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	static struct lp55xx_led_config lp5562_led_config[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			.name 		= "R",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			.chan_nr	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			.led_current	= 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			.max_current	= 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			.name 		= "G",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			.chan_nr	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			.led_current	= 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			.max_current	= 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			.name 		= "B",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			.chan_nr	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			.led_current	= 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			.max_current	= 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			.name 		= "W",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			.chan_nr	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			.led_current	= 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			.max_current	= 40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	static int lp5562_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		/* setup HW resources */
^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) 	static void lp5562_release(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		/* Release HW resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	static void lp5562_enable(bool state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		/* Control of chip enable signal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	static struct lp55xx_platform_data lp5562_platform_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		.led_config     = lp5562_led_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		.num_channels   = ARRAY_SIZE(lp5562_led_config),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		.setup_resources   = lp5562_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		.release_resources = lp5562_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.enable            = lp5562_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) To configure the platform specific data, lp55xx_platform_data structure is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) If the current is set to 0 in the platform data, that channel is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) disabled and it is not visible in the sysfs.