[OpenWrt-Devel] [PATCH 1/1v2] ar71xx: add support for WNXT01/Springmole Boards
Massimiliano Galanti
massimiliano.galanti at winext.eu
Thu Oct 16 07:28:47 EDT 2014
WNXT01/Springmole is a family of OEM boards designed by Wi-Next. This
patch adds the core files needed by openwrt to support them. See:
http://www.winext.eu http://www.springmole.com
Signed-off-by: Massimiliano Galanti <massimiliano.galanti at winext.eu>
---
target/linux/ar71xx/base-files/lib/ar71xx.sh | 6 +
.../ar71xx/files/arch/mips/ath79/mach-wnxt01.c | 304 ++++++++++++++++++++
.../ar71xx/files/arch/mips/ath79/mach-wnxt01lc.c | 133 +++++++++
.../728-MIPS-ath79-add-springmole-support.patch | 36 +++
4 files changed, 479 insertions(+)
create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01.c
create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01lc.c
create mode 100644 target/linux/ar71xx/patches-3.10/728-MIPS-ath79-add-springmole-support.patch
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 378a619..6f08c94 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -737,6 +737,12 @@ ar71xx_board_detect() {
*ZCN-1523H-5)
name="zcn-1523h-5"
;;
+ *"Wi-Next 01 Board")
+ name="wnxt01"
+ ;;
+ *"Wi-Next 01 LC Board")
+ name="wnxt01lc"
+ ;;
*EmbWir-Dorin)
name="ew-dorin"
;;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01.c
new file mode 100644
index 0000000..61a643d
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01.c
@@ -0,0 +1,304 @@
+/*
+ * Wi-Next WNXT01 board support
+ *
+ * Copyright (C) 2014 Wi-Next <info at winext.eu>
+ *
+ * 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
+ * by the Free Software Foundation.
+ */
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include <linux/i2c-gpio.h>
+
+#include <linux/spi/mcp23s08.h>
+#include <linux/i2c/ads1015.h>
+//#include <linux/rtc/ds1307.h>
+
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/mmc_spi.h>
+#include <linux/mmc/host.h>
+#include <linux/platform_device.h>
+#include <linux/ar8216_platform.h>
+
+#include <asm/mach-ath79/ath79.h>
+
+#include <asm/gpio.h>
+
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-spi.h"
+#include "dev-usb.h"
+#include "machtypes.h"
+#include "pci.h"
+
+#define WNXT01_GPIO_I2C_SDA 12
+#define WNXT01_GPIO_I2C_SCL 14
+
+static struct i2c_gpio_platform_data i2c_device_platdata = {
+ .sda_pin = WNXT01_GPIO_I2C_SDA,
+ .scl_pin = WNXT01_GPIO_I2C_SCL,
+ .scl_is_output_only = 1,
+};
+
+static struct platform_device i2c_gpio_device = {
+ .name = "i2c-gpio",
+ .id = 0,
+ .dev = {
+ .platform_data = &i2c_device_platdata,
+ },
+};
+
+static struct mcp23s08_platform_data mcp23s08_platdata = {
+ .chip = {
+ {
+ .is_present = 1,
+ .pullups = (1 << 4 | 1 << 5),
+ },
+ },
+ .base = 20,
+};
+
+#define WNXT01_GPIO_EXP0 20
+#define WNXT01_GPIO_EXP1 21
+#define WNXT01_GPIO_EXP2 22
+#define WNXT01_GPIO_EXP3 23
+
+#define WNXT01_GPIO_BTN0 24
+#define WNXT01_GPIO_BTN1 25
+#define WNXT01_GPIO_SDEN 26
+#define WNXT01_GPIO_USEN 27
+
+static struct ads1015_platform_data ads1015_platdata = {
+ .channel_data = {
+ [4] = { .enabled = true, .pga = 1, .data_rate = 0 },
+ [5] = { .enabled = true, .pga = 1, .data_rate = 0 },
+ [6] = { .enabled = true, .pga = 1, .data_rate = 0 },
+ [7] = { .enabled = true, .pga = 1, .data_rate = 0 },
+ }
+};
+
+//static struct ds1307_platform_data ds1307_platform_data = {
+// .trickle_charger_setup = 0,
+//};
+
+static struct i2c_board_info i2c_devs[] __initdata = {
+ {
+ I2C_BOARD_INFO("mcp23008", 0x20),
+ .platform_data = &mcp23s08_platdata,
+ },
+ {
+ I2C_BOARD_INFO("ads1015", 0x48),
+ .platform_data = &ads1015_platdata,
+ },
+ {
+ I2C_BOARD_INFO("ds1339", 0x68),
+ //.platform_data = &ds1307_platform_data,
+ },
+};
+
+static struct ath79_spi_controller_data ath79_spi0_cdata =
+{
+ .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
+ .cs_line = 0,
+};
+
+static struct ath79_spi_controller_data ath79_spi1_cdata =
+{
+ .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
+ .cs_line = 1,
+};
+
+static struct flash_platform_data pb92_flash_data = {
+ .name = "ar7240-nor0",
+};
+
+#include <linux/delay.h>
+static int wnxt01_mmc_init(struct device *dev, irqreturn_t (*isr)(int, void *), void *data)
+{
+ gpio_request(WNXT01_GPIO_SDEN, "SD power");
+ //gpio_direction_output(WNXT01_GPIO_SDEN, 0);
+
+ //mdelay(500);
+ gpio_direction_output(WNXT01_GPIO_SDEN, 1);
+ mdelay(500);
+
+ return 0;
+}
+
+static struct mmc_spi_platform_data mmc_spi_data = {
+ .init = &wnxt01_mmc_init,
+// .powerup_msecs = 500,
+ .caps = MMC_CAP_NONREMOVABLE,
+ .ocr_mask = 0x00ffff80,//MMC_VDD_28_29 | MMC_VDD_29_30 | MMC_VDD_30_31 |MMC_VDD_31_32 |MMC_VDD_32_33,
+};
+
+static struct spi_board_info ath79_spi_info[] = {
+ {
+ .bus_num = 0,
+ .chip_select = 0,
+ .max_speed_hz = 25000000,
+ .modalias = "s25fl129p1",
+ .controller_data = &ath79_spi0_cdata,
+ .platform_data = &pb92_flash_data,
+ },
+ {
+ .bus_num = 0,
+ .chip_select = 1,
+ .max_speed_hz = 5000000,
+ .modalias = "mmc_spi",
+ .controller_data = &ath79_spi1_cdata,
+ .platform_data = &mmc_spi_data,
+ }
+};
+
+static struct ath79_spi_platform_data ath79_spi_data = {
+ .bus_num = 0,
+ .num_chipselect = 2,
+};
+
+#define WNXT01_GPIO_LED_R 15
+#define WNXT01_GPIO_LED_G 13
+#define WNXT01_GPIO_LED_B 16
+
+static struct gpio_led leds_gpio[] __initdata = {
+ {
+ .name = "wnxt01:red",
+ .gpio = WNXT01_GPIO_LED_R,
+ .active_low = 0,
+ }, {
+ .name = "wnxt01:green",
+ .gpio = WNXT01_GPIO_LED_G,
+ .active_low = 0,
+ },
+ {
+ .name = "wnxt01:blue",
+ .gpio = WNXT01_GPIO_LED_B,
+ .active_low = 0,
+ },
+};
+
+#define KEYS_POLL_INTERVAL 50 /* msecs */
+#define KEYS_DEBOUNCE_INTERVAL (3 * KEYS_POLL_INTERVAL)
+
+static struct gpio_keys_button gpio_buttons[] = {
+ {
+ .code = BTN_0,
+ .gpio = WNXT01_GPIO_BTN0,
+ .active_low = 1,
+ .desc = "reset",
+ .type = EV_KEY,
+ .wakeup = 0,
+ .debounce_interval = KEYS_DEBOUNCE_INTERVAL,
+ .can_disable = 0,
+ },
+ {
+ .code = BTN_1,
+ .gpio = WNXT01_GPIO_BTN1,
+ .active_low = 1,
+ .desc = "user",
+ .type = EV_KEY,
+ .wakeup = 0,
+ .debounce_interval = KEYS_DEBOUNCE_INTERVAL,
+ .can_disable = 0,
+ },
+};
+
+static struct ar8327_pad_cfg wnxt01_ar8327_pad0_cfg = {
+ .mode = AR8327_PAD_MAC_RGMII,
+ .txclk_delay_en = true,
+ .rxclk_delay_en = true,
+ .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
+ .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
+};
+
+/* Bit 24: enable the timing delay for the output
+ * path of AR8327/AR8328.
+ * Set 1 to add 2ns delay in 1000 mode.
+ * (Need to enable 0xc[24] to take effect) */
+static struct ar8327_pad_cfg wnxt01_ar8327_pad6_cfg = {
+ .mode = AR8327_PAD_MAC_RGMII,
+ .rxclk_delay_en = true,
+};
+
+// TBD
+static struct ar8327_led_cfg wnxt01_ar8327_led_cfg = {
+ .led_ctrl0 = 0xcf05cf05,
+ .led_ctrl1 = 0xc831c831,
+ .led_ctrl2 = 0xc935c935,
+ .led_ctrl3 = 0x03ffff03,
+ .open_drain = false,
+};
+
+static struct ar8327_platform_data wnxt01_ar8327_data = {
+ .pad0_cfg = &wnxt01_ar8327_pad0_cfg,
+ .pad6_cfg = &wnxt01_ar8327_pad6_cfg,
+ .port0_cfg = {
+ .force_link = 1,
+ .speed = AR8327_PORT_SPEED_1000,
+ .duplex = 1,
+ .txpause = 1,
+ .rxpause = 1,
+ },
+ .led_cfg = &wnxt01_ar8327_led_cfg,
+};
+
+static struct mdio_board_info wnxt01_mdio0_info[] = {
+ {
+ .bus_id = "ag71xx-mdio.0",
+ .phy_addr = 0,
+ .platform_data = &wnxt01_ar8327_data,
+ },
+};
+
+static void __init wnxt01_init(void)
+{
+ //u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
+
+ /* I2C Bus */
+ platform_device_register(&i2c_gpio_device);
+ /* I2C devices */
+ i2c_register_board_info(0, i2c_devs,
+ ARRAY_SIZE(i2c_devs));
+
+ /* GPIO Leds */
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(leds_gpio),
+ leds_gpio);
+
+ /* GPIO Buttons */
+ ath79_register_gpio_keys_polled(-1, KEYS_POLL_INTERVAL, ARRAY_SIZE(gpio_buttons),
+ gpio_buttons);
+
+ /* SPI Bus and devices */
+ ath79_register_spi(&ath79_spi_data, ath79_spi_info, ARRAY_SIZE(ath79_spi_info));
+
+ //ath79_register_mdio(1, 0x0);
+ //ath79_register_mdio(0, 0x0);
+
+ mdiobus_register_board_info(wnxt01_mdio0_info, ARRAY_SIZE(wnxt01_mdio0_info));
+
+ ath79_register_mdio(0, ~BIT(0));
+ ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
+ ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+ ath79_eth0_data.speed = SPEED_1000;
+ ath79_eth0_data.duplex = DUPLEX_FULL;
+ ath79_eth0_data.phy_mask = BIT(0);
+ ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
+ ath79_eth0_pll_data.pll_1000 = 0x06000000;
+
+ ath79_register_eth(0);
+
+ /* USB Port */
+ ath79_register_usb();
+
+ /* PCI */
+ ath79_register_pci();
+}
+
+MIPS_MACHINE(ATH79_MACH_WNXT01, "WNXT01", "Wi-Next 01 Board", wnxt01_init);
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01lc.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01lc.c
new file mode 100644
index 0000000..e4aa3af
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnxt01lc.c
@@ -0,0 +1,133 @@
+/*
+ * Wi-Next WNXT01 board support
+ *
+ * Copyright (C) 2014 Wi-Next <info at winext.eu>
+ *
+ * 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
+ * by the Free Software Foundation.
+ */
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-ath79/ath79.h>
+
+#include <asm/gpio.h>
+
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-spi.h"
+#include "dev-usb.h"
+#include "machtypes.h"
+#include "pci.h"
+
+#define WNXT01_GPIO_BTN0 12
+#define WNXT01_GPIO_BTN1 11
+#define WNXT01_GPIO_USEN 17
+
+static struct ath79_spi_controller_data ath79_spi0_cdata =
+{
+ .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
+ .cs_line = 0,
+};
+
+static struct flash_platform_data pb92_flash_data = {
+ .name = "ar7240-nor0",
+};
+
+static struct spi_board_info ath79_spi_info[] = {
+ {
+ .bus_num = 0,
+ .chip_select = 0,
+ .max_speed_hz = 25000000,
+ .modalias = "s25fl129p1",
+ .controller_data = &ath79_spi0_cdata,
+ .platform_data = &pb92_flash_data,
+ }
+};
+
+static struct ath79_spi_platform_data ath79_spi_data = {
+ .bus_num = 0,
+ .num_chipselect = 1,
+};
+
+#define WNXT01_GPIO_LED_R 15
+#define WNXT01_GPIO_LED_G 13
+#define WNXT01_GPIO_LED_B 16
+
+static struct gpio_led leds_gpio[] __initdata = {
+ {
+ .name = "wnxt01:red",
+ .gpio = WNXT01_GPIO_LED_R,
+ .active_low = 0,
+ }, {
+ .name = "wnxt01:green",
+ .gpio = WNXT01_GPIO_LED_G,
+ .active_low = 0,
+ },
+ {
+ .name = "wnxt01:blue",
+ .gpio = WNXT01_GPIO_LED_B,
+ .active_low = 0,
+ },
+};
+
+static struct gpio_keys_button gpio_buttons[] = {
+ {
+ .code = BTN_0,
+ .gpio = WNXT01_GPIO_BTN0,
+ .active_low = 1,
+ .desc = "Reset button",
+ .type = EV_KEY,
+ .wakeup = 0,
+ .debounce_interval = 100,
+ .can_disable = 0,
+ },
+ {
+ .code = BTN_1,
+ .gpio = WNXT01_GPIO_BTN1,
+ .active_low = 1,
+ .desc = "Service button",
+ .type = EV_KEY,
+ .wakeup = 0,
+ .debounce_interval = 100,
+ .can_disable = 0,
+ },
+};
+
+static void __init wnxt01_init(void)
+{
+ /* GPIO Leds */
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(leds_gpio),
+ leds_gpio);
+
+ /* GPIO Buttons */
+ ath79_register_gpio_keys_polled(-1, 500, ARRAY_SIZE(gpio_buttons),
+ gpio_buttons);
+
+ /* SPI Bus and devices */
+ ath79_register_spi(&ath79_spi_data, ath79_spi_info, ARRAY_SIZE(ath79_spi_info));
+
+ ath79_register_mdio(0, ~BIT(4));
+ ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
+ ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+ ath79_eth0_data.speed = SPEED_1000;
+ ath79_eth0_data.duplex = DUPLEX_FULL;
+ ath79_eth0_data.phy_mask = BIT(4);
+
+ ath79_register_eth(0);
+
+ /* USB Port */
+ ath79_register_usb();
+
+ /* PCI */
+ ath79_register_pci();
+}
+
+MIPS_MACHINE(ATH79_MACH_WNXT01LC, "WNXT01LC", "Wi-Next 01 LC Board", wnxt01_init);
diff --git a/target/linux/ar71xx/patches-3.10/728-MIPS-ath79-add-springmole-support.patch b/target/linux/ar71xx/patches-3.10/728-MIPS-ath79-add-springmole-support.patch
new file mode 100644
index 0000000..46f02e0
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.10/728-MIPS-ath79-add-springmole-support.patch
@@ -0,0 +1,36 @@
+--- a/arch/mips/ath79/Kconfig 2013-09-26 15:29:58.421003763 +0200
++++ b/arch/mips/ath79/Kconfig 2013-09-26 14:44:17.832873176 +0200
+@@ -1045,6 +1045,15 @@
+ select ATH79_DEV_USB
+ select ATH79_NVRAM
+
++config ATH79_MACH_WNXT01
++ bool "Wi-Next WNXT01/Springmole board support"
++ select SOC_AR724X
++ select ATH79_DEV_ETH
++ select ATH79_DEV_GPIO_BUTTONS
++ select ATH79_DEV_LEDS_GPIO
++ select ATH79_DEV_PB9X_PCI if PCI
++ select ATH79_DEV_USB
++
+ endmenu
+
+ config SOC_AR71XX
+--- a/arch/mips/ath79/machtypes.h 2013-09-26 15:29:58.433003766 +0200
++++ b/arch/mips/ath79/machtypes.h 2013-09-26 14:45:06.356875493 +0200
+@@ -185,6 +185,8 @@
+ ATH79_MACH_WZR_HP_G450H, /* Buffalo WZR-HP-G450H */
+ ATH79_MACH_ZCN_1523H_2, /* Zcomax ZCN-1523H-2-xx */
+ ATH79_MACH_ZCN_1523H_5, /* Zcomax ZCN-1523H-5-xx */
++ ATH79_MACH_WNXT01,
++ ATH79_MACH_WNXT01LC,
+ };
+
+ #endif /* _ATH79_MACHTYPE_H */
+--- a/arch/mips/ath79/Makefile 2014-10-16 10:22:32.553865053 +0200
++++ b/arch/mips/ath79/Makefile 2014-10-16 10:20:35.689859186 +0200
+@@ -143,3 +143,4 @@
+ obj-$(CONFIG_ATH79_MACH_ZCN_1523H) += mach-zcn-1523h.o
+ obj-$(CONFIG_ATH79_MACH_CARAMBOLA2) += mach-carambola2.o
+ obj-$(CONFIG_ATH79_MACH_NBG6716) += mach-nbg6716.o
++obj-$(CONFIG_ATH79_MACH_WNXT01) += mach-wnxt01.o mach-wnxt01lc.o
--
1.7.10.4
_______________________________________________
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