Backlight:
LED:
Function | File |
---|---|
driver | drivers/video/backlight/adp8870_bl.c |
include | include/linux/i2c/adp8870.h |
With the ADP8870 driver installed, you will find sysfs files in the
/sys/class/backlight/adp8870_bl/
directory. You will be able to query and set the current screen
brightness:
The ADP8870 features 5 individually programmable Ambient Light Sensing Zones:
LEDs not assigned to the Backlight are optionally exposed to the Linux LEDs Class.
The LED class allows control of LEDs from userspace.
LEDs appear in /sys/class/leds/. The brightness file will
set the brightness of the LED (taking a value 0-255).
The LEDS class also introduces the optional concept of an LED trigger. A trigger
is a kernel based source of led events, such as ide-disk or backlight control.
For more information read linux/Documentaion/leds-class.txt
For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.
For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.
platform_data: Platform data specific to the ADP8870 device.
Includes what LEDs are available, feature selections and default initialization.
#include
Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each I2C bus segment, and what address these devices are using. For this reason, the kernel code must instantiate I2C devices explicitly. There are different ways to achieve this, depending on the context and requirements. However the most common method is to declare the I2C devices by bus number.
This method is appropriate when the I2C bus is a system bus, as in many embedded systems, wherein each I2C bus has a number which is known in advance. It is thus possible to pre-declare the I2C devices that inhabit this bus. This is done with an array of struct i2c_board_info, which is registered by calling i2c_register_board_info().
So, to enable such a driver one need only edit the board support file by adding an appropriate entry to i2c_board_info.
For more information see: Documentation/i2c/instantiating-devices
static struct i2c_board_info __initdata bfin_i2c_board_info[] = { #if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE) { I2C_BOARD_INFO("adp8870", 0x2B), .platform_data = (void *)&adp8870_pdata, }, #endif }
Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)
The ADP8870 Backlight driver depends on I2C. It therefore requires selected I2C support to show up during kernel configuration.
Device Drivers ---> Graphics support ---> [*] Backlight & LCD device support ---> <*> Lowlevel Backlight controlsBacklight Driver for ADP8870 using WLED
There is no dedicated Blackfin STAMP evaluation board for the ADP8870. During test and driver development we used the ADP8870 Evaluation Mother/Daughter Board.
It can be easily wired to the Blackfin STAMP TWI/I2C header.
BF537-STAMP (P10) TWI/I2C header | ADP886x Adaptor Board (J30) | |
---|---|---|
PIN | Function | PIN/Function |
5 | SCL | SCL |
6 | SDA | SDA |
20 | GND | GND |
Leave J31 and J32 open (these jumpers connect the SCL and SDA to the cypress chip used as USB bridge). Then apply your own SCL, SDA, and GND to the big J30 connector on the left edge of the board.
The ADP8870 chip still needs Vin (to power the chip), Vddio (to pull nRST and nINT high), and Vboard (to power the ALS sensor on the daughter card). These are provided through the USB port and then get regulated down (Vin becomes 3.6V, Vddio is 2.7V, and Vboard is around 4 V). So even though you won't be using the USB to program the part, it would still be easiest to plug the board into a USB port just to power Vin, Vddio, and Vboard. Of course, if you want, you can power these supplies from a lab bench power supply. In that case, move LK1, 2, and 3 to the “EXT” position and apply the signals to J29.
ADP8870 driver is build as a module
root:/> modprobe adp8870_bl adp8870_bl 0-002b: Rev.0 Backlight Registered led device: adp8870-led7 root:/>
root:/> cd sys/class/backlight/adp8870_bl/ root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> ls -l -r--r--r-- 1 root root 4096 Jan 1 03:29 actual_brightness -r--r--r-- 1 root root 4096 Jan 1 03:29 ambient_light_level -rw-rw-r-- 1 root root 4096 Jan 1 03:29 ambient_light_zone -rw-r--r-- 1 root root 4096 Jan 1 03:31 bl_power -rw-r--r-- 1 root root 4096 Jan 1 04:55 brightness lrwxrwxrwx 1 root root 0 Jan 1 03:29 device -> ../../../0-002b -rw-rw-r-- 1 root root 4096 Jan 1 03:29 l1_daylight_dim -rw-rw-r-- 1 root root 4096 Jan 1 03:29 l1_daylight_max -rw-rw-r-- 1 root root 4096 Jan 1 03:30 l2_bright_dim -rw-rw-r-- 1 root root 4096 Jan 1 03:29 l2_bright_max -rw-rw-r-- 1 root root 4096 Jan 1 03:30 l3_office_dim -rw-rw-r-- 1 root root 4096 Jan 1 03:29 l3_office_max -rw-rw-r-- 1 root root 4096 Jan 1 03:31 l4_indoor_dim -rw-rw-r-- 1 root root 4096 Jan 1 03:29 l4_indoor_max -rw-rw-r-- 1 root root 4096 Jan 1 03:31 l5_dark_dim -rw-rw-r-- 1 root root 4096 Jan 1 03:29 l5_dark_max -r--r--r-- 1 root root 4096 Jan 1 03:29 max_brightness drwxr-xr-x 2 root root 0 Jan 1 03:29 power lrwxrwxrwx 1 root root 0 Jan 1 03:29 subsystem -> ../../../../../../../../class/backlight -rw-r--r-- 1 root root 4096 Jan 1 03:29 uevent root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl>
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> echo 42 > brightness
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat brightness 42
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> echo 127 > brightness
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat ambient_light_level 1276
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat ambient_light_zone 4
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> echo 22 > l4_indoor_max 22
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/backlight/adp8870_bl> cat l4_indoor_max 22
root:/> cd /sys/class/leds/adp8870-led7/ root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7> ls -l -rw-r--r-- 1 root root 4096 Jan 1 03:29 brightness lrwxrwxrwx 1 root root 0 Jan 1 03:29 device -> ../../../0-002b -r--r--r-- 1 root root 4096 Jan 1 03:29 max_brightness drwxr-xr-x 2 root root 0 Jan 1 03:29 power lrwxrwxrwx 1 root root 0 Jan 1 03:29 subsystem -> ../../../../../../../../class/leds
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7>echo 99 > brightness
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7> echo 0 > brightness
root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7> cat max_brightness 255 root:/sys/devices/platform/i2c-bfin-twi.0/i2c-adapter/i2c-0/0-002b/leds/adp8870-led7>
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !