[OpenWrt-Devel] [PATCH] dragino2 update GPIO definitions

Pau pau at dabax.net
Mon Aug 11 11:27:20 EDT 2014


The one I got is the meshpotato v2, so I don't know about other kind of 
dragino boards. However what you say makes sense, let's just ignore 
this patch.
And sure, it would be nice to have some specific targets or subtargets 
for the different "flavors" of this board.

Cheers.

El lun 11 ago 2014 16:36:44 CEST, Karl Palsson escribió:
>
> Please no.  This might match your combination of dragino2 mainboard plus your daughterboard, but
> it most certainly doesn't match everyone's.  Also it contains lots of gratuitous whitespace
> changes.  Possibly it might be time to make more than one "dragino2" config, and possibly it
> should just start using the names on the PCB, MS14, for instance.  (Ours are version 2.3)
>
> Really, most of the changes in the dragino github repo since they moved from svn have been a
> pile of custom blobs for various projects, and not at all the nice clean "machine" level changes
> that the bare board should have.
>
> Sincerely,
> Karl Palsson
>
>
> On Mon, Aug 11, 2014 at 04:04:08PM +0200, Pau wrote:
>> Update mach-dragino2.c from Dragino2 official repository.
>> The patch should directly apply in trunk.
>> --
>> ./p4u
>
>> From 31692b700b79499bf0510b5350253b4c619c49ba Mon Sep 17 00:00:00 2001
>> From: Pau Escrich <p4u at dabax.net>
>> Date: Mon, 11 Aug 2014 15:57:37 +0200
>> Subject: [PATCH] Update dragino2 GPIO definitions
>>
>> Signed-off-by: Pau Escrich <p4u at dabax.net>
>> ---
>>  .../ar71xx/files/arch/mips/ath79/mach-dragino2.c   | 105 +++++++++++++++++++--
>>  1 file changed, 99 insertions(+), 6 deletions(-)
>>
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c
>> index 156fbe5..f6e0fd7 100644
>> --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c
>> +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-dragino2.c
>> @@ -2,7 +2,7 @@
>>   *  DRAGINO V2 board support, based on Atheros AP121 board support
>>   *
>>   *  Copyright (C) 2011-2012 Gabor Juhos <juhosg at openwrt.org>
>> - *  Copyright (C) 2012 Elektra Wagenrad <elektra at villagetelco.org>
>> + *  Copyright (C) 2012-2013 Elektra Wagenrad <elektra at villagetelco.org>
>>   *
>>   *  This program is free software; you can redistribute it and/or modify it
>>   *  under the terms of the GNU General Public License version 2 as published
>> @@ -21,13 +21,29 @@
>>  #include "dev-usb.h"
>>  #include "dev-wmac.h"
>>  #include "machtypes.h"
>> +// Added for SPI bitbanging support
>> +#include <linux/spi/spi_gpio.h>
>> +#include <linux/irq.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/linkage.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/types.h>
>> +#include <linux/leds.h>
>> +#include <linux/spi/spi.h>
>> +#include <linux/spi/spidev.h>
>> +#include <linux/spi/spi_bitbang.h>
>> +#include <linux/gpio.h>
>> +
>> +
>>
>>  #define DRAGINO2_GPIO_LED_WLAN		0
>>  #define DRAGINO2_GPIO_LED_LAN		13
>>  #define DRAGINO2_GPIO_LED_WAN		17
>>
>> -/*
>> - * The following GPIO is actually named "Router" on the board.
>> +
>> +/* 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.
>>   */
>> @@ -44,6 +60,8 @@
>>  #define DRAGINO2_CALDATA_OFFSET		0x1000
>>  #define DRAGINO2_WMAC_MAC_OFFSET	0x1002
>>
>> +
>> +
>>  static struct gpio_led dragino2_leds_gpio[] __initdata = {
>>  	{
>>  		.name		= "dragino2:red:lan",
>> @@ -65,6 +83,8 @@ static struct gpio_led dragino2_leds_gpio[] __initdata = {
>>  		.gpio		= DRAGINO2_GPIO_LED_USB,
>>  		.active_low	= 0,
>>  	},
>> +
>> +
>>  };
>>
>>  static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
>> @@ -86,9 +106,61 @@ static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
>>  	}
>>  };
>>
>> +/* Support for a second SPI Master with ID-number 1
>> + * by bitbanging GPIOs
>> + *
>> + * GPIO resources used by for the Si3217x-based FXS SPI slave module:
>> + *
>> + * CS (Chip select) for FXS board, SPI slave device #0, selected by GPIO_24 @Router_header_PIN12
>> + * FXS_RESET = GPIO 23 @Router_header_PIN9
>> + * FXS_INT = GPIO27 = @JTAG_header_PIN2
>> + * SCLK = GPIO_15 = @JTAG_header_PIN9
>> + * MOSI = GPIO_16 = @JTAG_header_PIN10
>> + * MISO = GPIO_26 = @JTAG_header_PIN1
>> +*/
>> +
>> +
>> +static struct spi_gpio_platform_data dragino2_20_spi_gpio_data = {
>> +.sck = 15,
>> +.mosi = 16,
>> +.miso = 26,
>> +.num_chipselect = 1
>> +};
>> +
>> +static struct platform_device dragino2_spi_gpio_device = {
>> +    .name		= "spi_gpio",
>> +    .id			= 1,
>> +    .dev.platform_data = &dragino2_20_spi_gpio_data,
>> +};
>> +
>> +
>> +
>> +// WiP: Add SPI client support for the FXS module
>> +
>> +/*static struct si3217x_platform_data si3217x_info [] = {
>> +	{
>> +	 .reset = 23,
>> +	},
>> +};*/
>> +
>> +static struct spi_board_info si3217x_spi_info[] = {
>> +	{
>> +		.bus_num	= 1,
>> +		.max_speed_hz	= 10000000,
>> +		.modalias	= "si3217x",
>> +		.chip_select	= 0,
>> +		.controller_data        = (void *) 24,
>> +		.mode 		= 3,
>> +		.irq		= 27,
>> +	}
>> +};
>> +
>> +
>> +
>>  static void __init dragino2_common_setup(void)
>>  {
>>  	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
>> +	u32 val;
>>
>>  	ath79_register_m25p80(NULL);
>>  	ath79_register_wmac(art + DRAGINO2_CALDATA_OFFSET,
>> @@ -99,19 +171,35 @@ static void __init dragino2_common_setup(void)
>>
>>  	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);
>> +	//Enable GPIO15 and GPIO16
>> +	ath79_gpio_function_disable(
>> +				   AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
>> +				   AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN
>> +                                  );
>>
>>  	/* LAN ports */
>>  	ath79_register_eth(1);
>>
>>  	/* WAN port */
>>  	ath79_register_eth(0);
>> +
>> +
>> +	/* Enable GPIO26 and GPIO27 */
>> +	/* Read reset register */
>> +	val = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
>> +
>> +	val |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
>> +
>> +	/* Write reset register */
>> +	ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, val);
>>  }
>>
>> +
>> +
>>  static void __init dragino2_setup(void)
>>  {
>> +	printk(KERN_INFO "In dragino2_setup()\n");
>> +
>>  	dragino2_common_setup();
>>
>>  	ath79_register_leds_gpio(-1, ARRAY_SIZE(dragino2_leds_gpio),
>> @@ -120,8 +208,13 @@ static void __init dragino2_setup(void)
>>  					ARRAY_SIZE(dragino2_gpio_keys),
>>  					dragino2_gpio_keys);
>>  	ath79_register_usb();
>> +
>> +	spi_register_board_info(si3217x_spi_info,ARRAY_SIZE(si3217x_spi_info));
>> +
>> +	platform_device_register(&dragino2_spi_gpio_device);
>>  }
>>
>> +
>>  MIPS_MACHINE(ATH79_MACH_DRAGINO2, "DRAGINO2", "Dragino Dragino v2",
>>  	     dragino2_setup);
>>
>> --
>> 2.0.1
>>
>
>
>
>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel at lists.openwrt.org
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>

--
./p4u
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list