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