Wiki

no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


Previous revision
Next revision
software:driver:linux:adp5520 [29 Sep 2010 15:50] – remove include file and add link to kernel.org hennerich
Line 1: Line 1:
 +====== ADP5520/01 driver ======
 +
 +===== Supported Devices =====
 +
 +The driver for the [[:ADP5520]] also supports the [[:ADP5501]].
 +
 +===== Description =====
 +
 +The ADP5520/01 driver utilizes several Linux device-driver subsystems and provides 
 +various software interfaces. It is therefore implemented as a multifunction device (MFD).
 +In this particular case the ADP5520 backlight driver and I/O expander, concurrently
 +leverages the Linux backlight, LED, GPIO, and input subsystems for its keypad functionality.
 +
 +<graphviz dot 650x200>
 +digraph {
 + size="8,5"
 + ADP5520_MFD_CORE [shape=box]
 + ADP5520_BACKLIGHT [shape=box]
 + ADP5520_GPIO[shape=box]
 + ADP5520_LED [shape=box]
 + ADP5520_KEYPAD [shape=box]
 + ADP5520_MFD_CORE -> ADP5520_BACKLIGHT [dir=none];
 + ADP5520_MFD_CORE -> ADP5520_LED [dir=none];
 + ADP5520_MFD_CORE -> ADP5520_GPIO [dir=none];
 + ADP5520_MFD_CORE -> ADP5520_KEYPAD [dir=none];
 +}
 +</graphviz>
 +
 +===== Core =====
 +
 +The ADP5520/01 core driver in drivers/mfd provides common services for the
 +subsystem drivers. These services include register access, control and shared interrupt management.
 +
 +The core registers/enumerates platform devices for the various subsystems
 +via the platform device and driver system.
 +
 +When a platform driver for one of the subsystems is instantiated,
 +the core initializes the chip (which may be specified by the platform data).
 +
 +The ADP5520/01 platform drivers follow the standard driver model convention, where
 +discovery/enumeration is handled outside the drivers, and drivers
 +provide probe() and remove() methods.
 +
 +===== Resources =====
 +
 +Each peripheral (subsystem device) has a view of the device which is implicitly narrowed to
 +the specific set of resources that peripheral requires in order to
 +function correctly.
 +
 +===== Configuration =====
 +
 +The device driver uses a set of platform data to pass
 +configurations through to the core and the subsidiary drivers
 +so that there can be support for multiple ADP5520/01 devices 
 +built into a single kernel image.
 +
 +===== Software configurable features =====
 +
 +Backlight:
 +  * Ambient Light Sensor Support
 +  * Configurable Fade On/Off times
 +  * Configurable Brightness/Intensity in 127 steps
 +
 +LED:
 +  * Up to 3 LEDs configurable
 +  * Configurable Fade On/Off times
 +  * LED Blink On/Off times
 +  * Configurable Brightness/Intensity in 64 steps from [0..255]
 +
 + Keypad:
 +  * Configurable keypad size matrix (rows, columns) up to 16 keys
 +  * Enabling and disabling automatic key repeat feature.
 +
 +GPIO:
 +  * Configurable number of dedicated GPIOs, up to 8 GPIOs
 +  * Configurable Pull-Ups  
 +
 +
 +
 +====== Source Code ======
 +
 +===== Status =====
 +
 +^  Source  ^  Mainlined?  ^
 +|  [[bf>project/linux-kernel/scmsvn/trunk/drivers/mfd/adp5520.c|svn]]  [[bfin>git/?p=readonly-mirrors/linux-kernel.git;a=history;f=drivers/mfd/adp5520.c;hb=HEAD|git]]  |  [[http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/mfd/adp5520.c;hb=HEAD|Yes]]  |
 +
 +===== Files =====
 +
 +^ Function ^ File ^
 +| MFD-CORE  | [[git.linux.org>drivers/mfd/adp5520.c]] |
 +| include   | [[git.linux.org>include/linux/mfd/adp5520.h]] |
 +| BACKLIGHT | [[git.linux.org>drivers/video/backlight/adp5520_bl.c]] | 
 +| LED       | [[git.linux.org>drivers/led/leds-adp5520.c]] |
 +| GPIO      | [[git.linux.org>drivers/gpio/adp5520-gpio.c]]((ADP5520 only)) |
 +| KEYPAD    | [[git.linux.org>drivers/input/keyboard/adp5520-keys.c]]((ADP5520 only)) |
 +
 +====== Example platform device initialization ======
 +
 +<note important>
 +Since Keypad, GPIO and optional LEDs (2, 3) are multiplexed, you need to avoid double configurations. Please refer to the table below.
 +</note>
 +
 +^ ADP5520 PIN ^ R3 ^ R2 ^ R1 ^ R0 ^ C0 ^ C1 ^ C2 ^ C3 ^
 +| **GPIO** | GPIO_R3 | GPIO_R2 | GPIO_R1 | GPIO_R0 | GPIO_C0 | GPIO_C1 | GPIO_C2 | GPIO_C3 |
 +| **Keypad** | ROW_R3 | ROW_R2 | ROW_R1 | ROW_R0 | COL_C0 | COL_C1 | COL_C2 | COL_C3 |
 +| **LED** | LED3 |  |  |  |  |  |  | LED2 |  
 +
 +<note tip> 
 +Please refer to [[git.linux.org>include/linux/mfd/adp5520.h]] for detailed configuration defines.
 +</note>
 +
 +==== Backlight =====
 +
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_backlight_data{} c linux-kernel>
 +
 +==== LED =====
 +
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_leds[] c linux-kernel>
 +
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_leds_data{} c linux-kernel>
 +
 +==== GPIO =====
 +
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_gpio_data{} c linux-kernel>
 +
 +==== Keypad =====
 +
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_keymap[] c linux-kernel>
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_keys_data{} c linux-kernel>
 +
 +
 +==== ADP5520/ADP5501 MFD Core Support =====
 +
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:adp5520_pdev_data{} c linux-kernel>
 +<source trunk/arch/blackfin/mach-bf537/boards/stamp.c:/CONFIG_PMIC_ADP5520/2-/#if/ c linux-kernel>
 +
 +<note tip>
 +**ADP5520 IRQ Usage:**\\
 +If you aren’t planning to utilize the Keypad interface, you don’t need to specify an IRQ in bfin_i2c_board_info.
 +</note>
 +
 +====== Adding Linux driver support ======
 +
 +Fist of all you need to enable i2c support followed by the ADP5520 MFD Core Driver.
 +Then you may select individual components like LCD backlight, LEDs, GPIOs and Keypad under the corresponding menus.
 +
 +==== ADP5520 MFD Core Support =====
 +
 +<xterm>
 +Device Drivers  ---> 
 + <*> I2C support  --->
 + <*> Blackfin TWI I2C support
 + Or:
 + <*> GPIO-based bitbanging I2C
 +
 +
 +Device Drivers  ---> 
 + Multifunction device drivers  --->
 + [*] Analog Devices ADP5520/01 MFD PMIC Core Support
 +</xterm>
 +
 +
 +==== Backlight =====
 +
 +<xterm>
 +Device Drivers  ---> 
 + Graphics support  --->
 + [*] Backlight & LCD device support  --->
 + <*>   Lowlevel Backlight controls
 + <M>     Backlight Driver for ADP5520/ADP5501 using WLED
 +</xterm>
 +
 +==== LED =====
 +
 +<xterm>
 +Device Drivers  --->
 + [*] LED Support  --->
 + <*>   LED Class Support
 + <M>   LED Support for ADP5520/ADP5501 PMIC
 +</xterm>
 +
 +==== GPIO =====
 +
 +<xterm>
 +Device Drivers  --->
 + [*] GPIO Support  --->
 + [*]   /sys/class/gpio/... (sysfs interface)
 + <M>   GPIO Support for ADP5520 PMIC
 +</xterm>
 +
 +==== Keypad =====
 +
 +<xterm>
 +Device Drivers  --->
 + Input device support  --->
 + <*> Generic input layer (needed for keyboard, mouse, ...)
 + <*>   Event interface
 + [*]   Keyboards  --->
 + <M>   Keypad Support for ADP5520 PMIC
 +</xterm>
 +
 +====== Hardware configuration ======
 +
 +There is no dedicated Blackfin STAMP evaluation board for the ADP5520.
 +During test and driver development we used the ADP5520 Demo Mother/Daughter Board.
 +
 +It can be easily wired to the Blackfin STAMP TWI/I2C header.
 +
 +^ BF537-STAMP (P10) TWI/I2C header  ^^ ADP5520 Daughter Board ^
 +^ PIN ^ Function ^ PIN/Function ^
 +| 2 | (+3.3V) | VCC |
 +| 5 | SCL | SCL |
 +| 6 | SDA| SDA |
 +| 10 | GPIO_PG0 | nINT |
 +| 20 | GND | GND |
 +
 +
 +====== Driver testing ======
 +
 +
 +==== Backlight =====
 +
 +<xterm>
 +root:/> **modprobe adp5520_bl**
 +root:/>
 +
 +root:/> cd sys/class/backlight/adp5520-backlight/
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/backlight/adp5520-backlight> ls -l
 +-r--r--r--    1 root     root         4096 Nov 12 10:31 actual_brightness
 +-rw-r--r--    1 root     root         4096 Nov 12 10:31 bl_power
 +-rw-r--r--    1 root     root         4096 Nov 12 10:31 brightness
 +-rw-rw-r--    1 root     root         4096 Nov 12 10:31 dark_dim
 +-rw-rw-r--    1 root     root         4096 Nov 12 10:31 dark_max
 +-rw-rw-r--    1 root     root         4096 Nov 12 10:31 daylight_dim
 +-rw-rw-r--    1 root     root         4096 Nov 12 10:31 daylight_max
 +lrwxrwxrwx    1 root     root            0 Nov 12 10:31 device -> ../../../0-0032
 +-r--r--r--    1 root     root         4096 Nov 12 10:31 max_brightness
 +-rw-rw-r--    1 root     root         4096 Nov 12 10:31 office_dim
 +-rw-rw-r--    1 root     root         4096 Nov 12 10:31 office_max
 +drwxr-xr-x    2 root     root            0 Nov 12 10:31 power
 +lrwxrwxrwx    1 root     root            0 Nov 12 10:31 subsystem -> ../../../../../../../../class/backlight
 +
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/backlight/adp5520-backlight> **echo 127 > brightness**
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/backlight/adp5520-backlight> **echo 50 > brightness**
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/backlight/adp5520-backlight> **echo 0 > brightness**
 +</xterm>
 +
 +__**For more information on Backlight handling in Linux read:**__ [[git.linux.org>Documentation/ABI/stable/sysfs-class-backlight]] 
 +
 +==== LED =====
 +
 +<xterm>
 +root:/> **modprobe leds-adp5520**
 +Registered led device: adp5520-led1
 +Registered led device: adp5520-led2
 +Registered led device: adp5520-led3
 +
 +root:/> cd sys/class/leds/adp5520-led
 +sys/class/leds/adp5520-led1/  sys/class/leds/adp5520-led3/
 +sys/class/leds/adp5520-led2/
 +
 +root:/> cd sys/class/leds/adp5520-led1
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/leds/adp5520-led1> ls -l
 +-rw-r--r--    1 root     root         4096 Nov 12 10:34 brightness
 +lrwxrwxrwx    1 root     root            0 Nov 12 10:34 device -> ../../../0-0032
 +drwxr-xr-x    2 root     root            0 Nov 12 10:34 power
 +lrwxrwxrwx    1 root     root            0 Nov 12 10:34 subsystem -> ../../../../../../../../class/leds
 +-rw-r--r--    1 root     root         4096 Nov 12 10:34 trigger
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/leds/adp5520-led1> **echo 10 > brightness**
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/leds/adp5520-led1> **echo 255 > brightness**
 +root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/leds/adp5520-led1> **echo 0 > brightness**
 +
 +root:/> **modprobe -r leds-adp5520**
 +root:/>
 +</xterm>
 +
 +__**For more information on LEDs handling in Linux read:**__ [[git.linux.org>Documentation/leds-class.txt]] 
 +
 +==== GPIO =====
 +<xterm>
 +root:/> **modprobe adp5520-gpio**
 +root:/> cd sys/class/gpio/gpiochip50/
 +root:/sys/devices/virtual/gpio/gpiochip50> ls -l
 +-r--r--r--    1 root     root         4096 Nov 12 10:37 base
 +-r--r--r--    1 root     root         4096 Nov 12 10:37 label
 +-r--r--r--    1 root     root         4096 Nov 12 10:37 ngpio
 +drwxr-xr-x    2 root     root            0 Nov 12 10:37 power
 +lrwxrwxrwx    1 root     root            0 Nov 12 10:37 subsystem -> ../../../../class/gpio
 +-rw-r--r--    1 root     root         4096 Nov 12 10:37 uevent
 +root:/sys/devices/virtual/gpio/gpiochip50> cd
 +root:/>
 +</xterm>
 +Note that you will have to enable the event_test utility under "Blackfin test programs" in your user space configuration.
 +<xterm>
 +--- Blackfin test programs
 +                   [*] Input event device test
 +</xterm>
 +
 +__**For more information on GPIO handling in Linux read:**__ [[git.linux.org>Documentation/gpio.txt]] 
 +
 +
 +==== Keypad =====
 +
 +<xterm>
 +root:/> **modprobe adp5520-keys**
 +input: adp5520-keys as /devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-0032/adp5520-keys.5520/input/input0
 +
 +root:/> **event_test /dev/input/event0**
 +Input driver version is 1.0.0
 +Input device ID: bus 0x18 vendor 0x1 product 0x5520 version 0x1
 +Input device name: "adp5520-keys"
 +Supported events:
 +  Event type 0 (Reset)
 +    Event code 0 (Reset)
 +    Event code 1 (Key)
 +  Event type 1 (Key)
 +    Event code 2 (1)
 +    Event code 3 (2)
 +    Event code 4 (3)
 +    Event code 5 (4)
 +    Event code 6 (5)
 +    Event code 7 (6)
 +    Event code 8 (7)
 +    Event code 9 (8)
 +    Event code 10 (9)
 +    Event code 11 (0)
 +    Event code 12 (Minus)
 +    Event code 13 (Equal)
 +    Event code 28 (Enter)
 +    Event code 41 (Grave)
 +    Event code 43 (BackSlash)
 +Testing ... (interrupt to exit)
 +Event: time 1415788674.340000, type 1 (Key), code 41 (Grave), value 1
 +Event: time 1415788674.340000, type 0 (Reset), code 0 (Reset), value 0
 +Event: time 1415788674.516000, type 1 (Key), code 41 (Grave), value 0
 +Event: time 1415788674.516000, type 0 (Reset), code 0 (Reset), value 0
 +Event: time 1415788674.912000, type 1 (Key), code 2 (1), value 1
 +Event: time 1415788674.912000, type 0 (Reset), code 0 (Reset), value 0
 +Event: time 1415788675.140000, type 1 (Key), code 2 (1), value 0
 +Event: time 1415788675.140000, type 0 (Reset), code 0 (Reset), value 0
 +Event: time 1415788675.892000, type 1 (Key), code 6 (5), value 1
 +Event: time 1415788675.892000, type 0 (Reset), code 0 (Reset), value 0
 +Event: time 1415788676.092000, type 1 (Key), code 6 (5), value 0
 +Event: time 1415788676.092000, type 0 (Reset), code 0 (Reset), value 0
 +
 +root:/> **modprobe -r adp5520-keys**
 +root:/>
 +</xterm>
 +
 +__**For more information on Input handling in Linux read:**__ [[git.linux.org>Documentation/input/input.txt]] 
  
resources/tools-software/linux-drivers/multifunction-device/adp5520.txt · Last modified: 16 Feb 2015 11:50 by Lars-Peter Clausen