1      Hardware Overview

gpio interface,pin map:

AM335X_I2C0_W_C----------------------MCASP0_AXR1

/*4g-power*/

AM335X_MMC2_DAT0------------------GPMC_A1

/*4g-reset*/

AM335X_MMC2_DAT2------------------GPMC_A3

/*wifi-led*/

AM335X_WIFI------------------------------GPMC_A2

/*system-led*/

AM335X_XDMA_EVENT_INTR1------XDMA_EVENT_INTR1

/*key2 button*/

AM335X_SPI0_CS1-----------------------SPI0_CS1

2   GPIO DRIVER Overview

The gpio-leds driver provide userspace access gpio interface, for example: /sys/class/leds/4g-reset dir,  under the dir have brightness、trigger, led trigger mode current triggers are:

"backlight" - LED will act as a back-light, controlled by the framebuffer system

"default-on" - LED will turn on (but for leds-gpio see "default-state"

property in Documentation/devicetree/bindings/gpio/led.txt)

"heartbeat" - LED "double" flashes at a load average based rate

"disk-activity" - LED indicates disk activity

"ide-disk" - LED indicates IDE disk activity (deprecated),in new implementations use "disk-activity"

"timer" - LED flashes at a fixed, configurable rate

am335x system upgrade kernel gpio(九)-LMLPHP

The gpio driver can be used to pullup/pulldown led(io) from the User interface as shown by the below diagram..

am335x system upgrade kernel gpio(九)-LMLPHP

3  Kernel GPIO porting

PIN MUX

user_leds_s0: user_leds_s0 {
pinctrl-single,pins = <
AM33XX_IOPAD(0x9a8, PIN_OUTPUT_PULLUP | MUX_MODE7) /* mcasp0_axr1.gpio3_20 ----> eeprom_write_control*/
AM33XX_IOPAD(0x844, PIN_OUTPUT_PULLUP | MUX_MODE7) /* gpmc_a1.gpio1_17 ----> 4g-power*/
AM33XX_IOPAD(0x84c, PIN_OUTPUT_PULLUP | MUX_MODE7) /* gpmc_a3.gpio1_19 ---->4g-reset*/
AM33XX_IOPAD(0x848, PIN_OUTPUT_PULLUP | MUX_MODE7) /* gpmc_a2.gpio1_18 ---->wifi-led*/
AM33XX_IOPAD(0x9b4, PIN_OUTPUT_PULLUP | MUX_MODE7) /* xdma_event_intr1.gpio0_20 ---->system-led*/
AM33XX_IOPAD(0x960, PIN_INPUT_PULLUP | MUX_MODE7) /* spi0_cs1.gpio0_6 ----> button */
>;
};

GPIO DTS NODE

leds {
pinctrl-names = "default";
pinctrl-0 = <&user_leds_s0>;

compatible = "gpio-leds";

led1 {
label = "heartbeat";
gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
};

led2 {
label = "eeprom-write-control";
gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
default-state = "off";
};

led3 {
label = "4g-power";
gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>;
default-state = "on";
};

led4 {
label = "4g-reset";
gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>;
default-state = "off";
};

led5 {
label = "wif-led";
gpios = <&gpio1 18 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "heartbeat";
default-state = "off";
};
};

4    User Space Interface

root@am335x-evm:/sys/class/leds/4g-reset# ls

brightness      device          max_brightness  power           subsystem       trigger         uevent

05-27 15:43