Dragino2 ar9331 uses the LED pins as ordinary Gpio

Source: Internet
Author: User

1, the gpio13 and Gpio17 also as ordinary gpio use, modify

target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c files are as follows

/** Dragino V2 Board support, based on Atheros AP121 Board Support * * Copyright (C) 2011-2012 Gabor juhos <[email protected]> * Copyright (C) Elektra Wagenrad <[email protected]> * * This program was free software;  You can redistribute it and/or modify it * under the terms of the GNU general public License version 2 as published * by The Free software Foundation. */#include<linux/gpio.h>#include<asm/mach-ath79/ath79.h>#include<asm/mach-ath79/ar71xx_regs.h>#include"Common.h"#include"dev-eth.h"#include"Dev-gpio-buttons.h"#include"dev-leds-gpio.h"#include"dev-m25p80.h"#include"dev-spi-gpio.h"    //Add by Merlin#include"dev-spi.h"#include"Dev-usb.h"#include"dev-wmac.h"#include"Machtypes.h"#defineDragino2_gpio_led_wlan 0//#define Dragino2_gpio_led_lan//#define Dragino2_gpio_led_wan/** The following GPIO is actually named ' Router ' on the board. * However, since the ' Router ' feature is not supported As of yet * we use it to display USB activity. */#defineDragino2_gpio_led_usb 28#defineDragino2_gpio_btn_jumpstart 11#defineDragino2_gpio_btn_reset 12#defineDragino2_keys_poll_interval/* msecs */#defineDragino2_keys_debounce_interval (3 * dragino2_keys_poll_interval)#defineDragino2_mac0_offset 0x0000#defineDragino2_mac1_offset 0x0006#defineDragino2_caldata_offset 0x1000#defineDragino2_wmac_mac_offset 0x1002Static structgpio_led dragino2_leds_gpio[] __initdata = {//    {//. Name = "Dragino2:red:lan",//. Gpio = Dragino2_gpio_led_lan,//. Active_low = 0,//    },{. Name="Dragino2:red:wlan",. Gpio=Dragino2_gpio_led_wlan,. Active_low=0,    },//        {//. Name = "Dragino2:red:wan",//. Gpio = Dragino2_gpio_led_wan,//. Active_low = 0,//    },{. Name="Dragino2:red:usb",. Gpio=Dragino2_gpio_led_usb,. Active_low=0,    },};Static structGpio_keys_button dragino2_gpio_keys[] __initdata ={. desc="Jumpstart Button",. Type=Ev_key,. Code=Key_wps_button,. Debounce_interval=dragino2_keys_debounce_interval,. Gpio=Dragino2_gpio_btn_jumpstart,. Active_low=1,}, {. desc="reset Button",. Type=Ev_key,. Code=Key_restart,. Debounce_interval=dragino2_keys_debounce_interval,. Gpio=Dragino2_gpio_btn_reset,. Active_low=1,    }};Static void__init Dragino2_common_setup (void) {U8*art = (U8 *) kseg1addr (0x1fff0000);    ATH79_REGISTER_M25P80 (NULL); Ath79_register_wmac (Art+Dragino2_caldata_offset, Art+dragino2_wmac_mac_offset); Ath79_init_mac (ath79_eth0_data.mac_addr, Art+ Dragino2_mac0_offset,0); Ath79_init_mac (ath79_eth1_data.mac_addr, Art+ Dragino2_mac1_offset,0); Ath79_register_mdio (0,0x0); /*Enable GPIO15 and GPIO16 and possibly GPIO26 and GPIO27*/    //ath79_gpio_function_disable (ar933x_gpio_func_eth_switch_led2_en | //ar933x_gpio_func_eth_switch_led3_en);Ath79_gpio_function_disable (Ar933x_gpio_func_eth_switch_led0_en |ar933x_gpio_func_eth_switch_led1_en|ar933x_gpio_func_eth_switch_led2_en|ar933x_gpio_func_eth_switch_led3_en|ar933x_gpio_func_eth_switch_led4_en); /*LAN Ports*/Ath79_register_eth (1); /*WAN Port*/Ath79_register_eth (0); //Add by Merlin 2014-07-18Ath79_register_spi_gpio ();}Static void__init Dragino2_setup (void) {dragino2_common_setup (); Ath79_register_leds_gpio (-1, Array_size (Dragino2_leds_gpio), Dragino2_leds_gpio); Ath79_register_gpio_keys_polled (-1, Dragino2_keys_poll_interval, Array_size (Dragino2_gpio_keys), Dragino2_gpio_key    s); Ath79_register_usb ();} Mips_machine (Ath79_mach_dragino2,"DRAGINO2","Dragino Dragino v2", dragino2_setup);

Note Two, 1, comment out the Dragino2_gpio_led_lan and Dragino2_gpio_led_wan related definitions, 2, use the pin as a normal GPIO, to Ath79_gpio_function_ Add the relevant content to the Disable function by default.

2. Testing

such as Test LED3 (gpio_14) and LED6 (GPIO_17)

 [email protected]:/sys/class/gpio# echo  14  > export [email protected] - m-base:/sys/class/gpio# echo  out > Gpio14/-m-base:/sys/class/gpio# echo  1  > Gpio14/value [email protected] -m-base:/sys/class/gpio# Span style= "color: #0000ff;" >echo  17  > export [email  Protected] -m-base:/sys/class/gpio# echo  out > Gpio17/direction [email protected] -m-base:/sys/class/gpio# echo  1  > Gpio17/value 

Reference:

Http://www.cnblogs.com/tfanalysis/p/4206513.html

Dragino2 ar9331 uses the LED pins as ordinary Gpio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.