ar71xx: bring back Atheros AP83 support
authorZoltan HERPAI <[email protected]>
Tue, 5 May 2020 15:09:35 +0000 (17:09 +0200)
committerZoltan HERPAI <[email protected]>
Thu, 2 Jul 2020 08:53:38 +0000 (10:53 +0200)
I still have a (working!) AP83-040 board, so let's bring back
support for it. Changes since it was dropped:

 - WLAN LED isn't working, "fixme"
 - hardcoded flash layout was added back into the mach file
 - sysupgrade is "fixme"
 - the flash mechanism and the custom SPI driver was not
   modernized, but they compile and work.

Other than these notes, the board is working as expected.

Signed-off-by: Zoltan HERPAI <[email protected]>
13 files changed:
target/linux/ar71xx/base-files/etc/board.d/01_leds
target/linux/ar71xx/base-files/etc/board.d/02_network
target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/config-4.14
target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
target/linux/ar71xx/files/arch/mips/ath79/Makefile
target/linux/ar71xx/files/arch/mips/ath79/mach-ap83.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
target/linux/ar71xx/generic/config-default
target/linux/ar71xx/image/generic-legacy-devices.mk
target/linux/ar71xx/image/legacy.mk

index 54727a6e52451e810f859cbadead807ca5ac1978..2c6cbc74f5dc35a5063c2e19ebee17f3c7041dbd 100755 (executable)
@@ -18,6 +18,9 @@ a60)
        ucidef_set_led_default "status-red" "Status (red)" "a60:red:status" "0"
        ucidef_set_led_default "status-blue" "Status (blue)" "a60:blue:status" "0"
        ;;
+ap83)
+       ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt"
+       ;;
 airgateway|\
 airgatewaypro)
        ucidef_set_led_wlan "wlan" "WLAN" "ubnt:blue:wlan" "phy0tpt"
index 1487ff58de24a02107f618a7f97cc1b70cd737f8..8c0f5b4e9b4f3378381f7ff7cf74852b13a298d7 100755 (executable)
@@ -161,6 +161,7 @@ ar71xx_setup_interfaces()
        a60|\
        alfa-ap96|\
        alfa-nx|\
+       ap83|\
        dr344|\
        gl-ar150|\
        gl-ar300m|\
index 1a92ad927dc69c687b64c0d242227649ec8986a4..35216e3f1eadfb7c7052417f25d60a91bc9d5f73 100644 (file)
@@ -64,6 +64,7 @@ get_status_led() {
        ap135-020)
                status_led="ap135:green:status"
                ;;
+       ap83|\
        archer-c25-v1|\
        archer-c58-v1|\
        archer-c59-v1|\
index 044ef4eae5e1cd2f04bacc5b0c18a151f2fe1253..5e33ba6ba2e0060ec30a16a53b18bfa4e5eab80f 100755 (executable)
@@ -682,6 +682,9 @@ ar71xx_board_detect() {
        *"Atheros AP96")
                name="ap96"
                ;;
+       *"Atheros AP83")
+               name="ap83"
+               ;;
        *"AW-NR580")
                name="aw-nr580"
                ;;
index eb812865db8882cb4bfaf06fb11f5ab5ed473986..d7aa40a118877d9a343eef041c8d45f9e005d9ec 100755 (executable)
@@ -344,6 +344,7 @@ platform_check_image() {
        ap136-020|\
        ap147-010|\
        ap152|\
+       ap83|\
        ap91-5g|\
        ap96|\
        arduino-yun|\
index 9a524fae4316caa10431bd6b3b4dadbe8660f14c..4f3703cfc2a2697acfc55fa7e0fab9334d606c21 100644 (file)
@@ -46,6 +46,7 @@ CONFIG_ATH79=y
 # CONFIG_ATH79_MACH_AP152 is not set
 # CONFIG_ATH79_MACH_AP531B0 is not set
 # CONFIG_ATH79_MACH_AP81 is not set
+# CONFIG_ATH79_MACH_AP83 is not set
 # CONFIG_ATH79_MACH_AP90Q is not set
 # CONFIG_ATH79_MACH_AP91_5G is not set
 # CONFIG_ATH79_MACH_AP96 is not set
@@ -463,6 +464,7 @@ CONFIG_SERIAL_8250_RUNTIME_UARTS=1
 # CONFIG_SOC_QCA955X is not set
 # CONFIG_SOC_QCA956X is not set
 CONFIG_SPI=y
+CONFIG_SPI_AP83=y
 CONFIG_SPI_ATH79=y
 CONFIG_SPI_BITBANG=y
 CONFIG_SPI_GPIO=y
index 6fd78c46a09c40d82822c62b521486a22c5f27a6..de59b001ce45110c1c6448fe50c0699bfba24e18 100644 (file)
@@ -216,6 +216,14 @@ config ATH79_MACH_AP531B0
        select ATH79_DEV_USB
        select ATH79_DEV_WMAC
 
+config ATH79_MACH_AP83
+       bool "Atheros AP83 board support"
+       select SOC_AR913X
+       select ATH79_DEV_GPIO_BUTTONS
+       select ATH79_DEV_LEDS_GPIO
+       select ATH79_DEV_USB
+       select ATH79_DEV_WMAC
+
 config ATH79_MACH_AP90Q
        bool "YunCore AP80Q/AP90Q support"
        select SOC_QCA953X
index 0265b3d818135b3917f221173c59a85cc8d6cdb7..1ff6a5f893cf3edbd52778c212a4506e8e032a24 100644 (file)
@@ -56,6 +56,7 @@ obj-$(CONFIG_ATH79_MACH_AP143)                        += mach-ap143.o
 obj-$(CONFIG_ATH79_MACH_AP147)                 += mach-ap147.o
 obj-$(CONFIG_ATH79_MACH_AP152)                 += mach-ap152.o
 obj-$(CONFIG_ATH79_MACH_AP531B0)               += mach-ap531b0.o
+obj-$(CONFIG_ATH79_MACH_AP83)                  += mach-ap83.o
 obj-$(CONFIG_ATH79_MACH_AP90Q)                 += mach-ap90q.o
 obj-$(CONFIG_ATH79_MACH_AP91_5G)               += mach-ap91-5g.o
 obj-$(CONFIG_ATH79_MACH_AP96)                  += mach-ap96.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-ap83.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-ap83.c
new file mode 100644 (file)
index 0000000..053d17d
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ *  Atheros AP83 board support
+ *
+ *  Copyright (C) 2008-2012 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  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/delay.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_gpio.h>
+#include <linux/spi/vsc7385.h>
+
+#include <asm/mach-ath79/ar71xx_regs.h>
+#include <asm/mach-ath79/ath79.h>
+
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define AP83_GPIO_LED_WLAN     6
+#define AP83_GPIO_LED_POWER    14
+#define AP83_GPIO_LED_JUMPSTART        15
+#define AP83_GPIO_BTN_JUMPSTART        12
+#define AP83_GPIO_BTN_RESET    21
+
+#define AP83_050_GPIO_VSC7385_CS       1
+#define AP83_050_GPIO_VSC7385_MISO     3
+#define AP83_050_GPIO_VSC7385_MOSI     16
+#define AP83_050_GPIO_VSC7385_SCK      17
+
+#define AP83_KEYS_POLL_INTERVAL                20      /* msecs */
+#define AP83_KEYS_DEBOUNCE_INTERVAL    (3 * AP83_KEYS_POLL_INTERVAL)
+
+static struct mtd_partition ap83_flash_partitions[] = {
+       {
+               .name           = "u-boot",
+               .offset         = 0,
+               .size           = 0x040000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "u-boot-env",
+               .offset         = 0x040000,
+               .size           = 0x020000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "rootfs",
+               .offset         = 0x060000,
+               .size           = 0x400000,
+       }, {
+               .name           = "kernel",
+               .offset         = 0x460000,
+               .size           = 0x390000,
+       }, {
+               .name           = "art",
+               .offset         = 0x7f0000,
+               .size           = 0x010000,
+               .mask_flags     = MTD_WRITEABLE,
+       }, {
+               .name           = "firmware",
+               .offset         = 0x060000,
+               .size           = 0x790000,
+       }
+};
+
+static struct physmap_flash_data ap83_flash_data = {
+       .width          = 2,
+       .parts          = ap83_flash_partitions,
+       .nr_parts       = ARRAY_SIZE(ap83_flash_partitions),
+};
+
+static struct resource ap83_flash_resources[] = {
+       [0] = {
+               .start  = AR71XX_SPI_BASE,
+               .end    = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device ap83_flash_device = {
+       .name           = "physmap-flash",
+       .id             = -1,
+       .resource       = ap83_flash_resources,
+       .num_resources  = ARRAY_SIZE(ap83_flash_resources),
+       .dev            = {
+               .platform_data = &ap83_flash_data,
+       }
+};
+
+static struct gpio_led ap83_leds_gpio[] __initdata = {
+       {
+               .name           = "ap83:green:jumpstart",
+               .gpio           = AP83_GPIO_LED_JUMPSTART,
+               .active_low     = 0,
+       }, {
+               .name           = "ap83:green:power",
+               .gpio           = AP83_GPIO_LED_POWER,
+               .active_low     = 0,
+       }, {
+               .name           = "ap83:green:wlan",
+               .gpio           = AP83_GPIO_LED_WLAN,
+               .active_low     = 0,
+       },
+};
+
+static struct gpio_keys_button ap83_gpio_keys[] __initdata = {
+       {
+               .desc           = "soft_reset",
+               .type           = EV_KEY,
+               .code           = KEY_RESTART,
+               .debounce_interval = AP83_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = AP83_GPIO_BTN_RESET,
+               .active_low     = 1,
+       }, {
+               .desc           = "jumpstart",
+               .type           = EV_KEY,
+               .code           = KEY_WPS_BUTTON,
+               .debounce_interval = AP83_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = AP83_GPIO_BTN_JUMPSTART,
+               .active_low     = 1,
+       }
+};
+
+static struct resource ap83_040_spi_resources[] = {
+       [0] = {
+               .start  = AR71XX_SPI_BASE,
+               .end    = AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device ap83_040_spi_device = {
+       .name           = "ap83-spi",
+       .id             = 0,
+       .resource       = ap83_040_spi_resources,
+       .num_resources  = ARRAY_SIZE(ap83_040_spi_resources),
+};
+
+static struct spi_gpio_platform_data ap83_050_spi_data = {
+       .miso   = AP83_050_GPIO_VSC7385_MISO,
+       .mosi   = AP83_050_GPIO_VSC7385_MOSI,
+       .sck    = AP83_050_GPIO_VSC7385_SCK,
+       .num_chipselect = 1,
+};
+
+static struct platform_device ap83_050_spi_device = {
+       .name           = "spi_gpio",
+       .id             = 0,
+       .dev            = {
+               .platform_data = &ap83_050_spi_data,
+       }
+};
+
+static void ap83_vsc7385_reset(void)
+{
+       ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
+       udelay(10);
+       ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
+       mdelay(50);
+}
+
+static struct vsc7385_platform_data ap83_vsc7385_data = {
+       .reset          = ap83_vsc7385_reset,
+       .ucode_name     = "vsc7385_ucode_ap83.bin",
+       .mac_cfg = {
+               .tx_ipg         = 6,
+               .bit2           = 0,
+               .clk_sel        = 3,
+       },
+};
+
+static struct spi_board_info ap83_spi_info[] = {
+       {
+               .bus_num        = 0,
+               .chip_select    = 0,
+               .max_speed_hz   = 25000000,
+               .modalias       = "spi-vsc7385",
+               .platform_data  = &ap83_vsc7385_data,
+               .controller_data = (void *) AP83_050_GPIO_VSC7385_CS,
+       }
+};
+
+static void __init ap83_generic_setup(void)
+{
+       u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
+
+       ath79_register_mdio(0, 0xfffffffe);
+
+       ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
+       ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+       ath79_eth0_data.phy_mask = 0x1;
+
+       ath79_register_eth(0);
+
+       ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
+       ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+       ath79_eth1_data.speed = SPEED_1000;
+       ath79_eth1_data.duplex = DUPLEX_FULL;
+
+       ath79_eth1_pll_data.pll_1000 = 0x1f000000;
+
+       ath79_register_eth(1);
+
+       ath79_register_leds_gpio(-1, ARRAY_SIZE(ap83_leds_gpio),
+                                       ap83_leds_gpio);
+
+       ath79_register_gpio_keys_polled(-1, AP83_KEYS_POLL_INTERVAL,
+                                        ARRAY_SIZE(ap83_gpio_keys),
+                                        ap83_gpio_keys);
+
+       ath79_register_usb();
+
+       ath79_register_wmac(eeprom, NULL);
+
+       platform_device_register(&ap83_flash_device);
+
+       spi_register_board_info(ap83_spi_info, ARRAY_SIZE(ap83_spi_info));
+}
+
+static void ap83_040_flash_lock(struct platform_device *pdev)
+{
+       ath79_flash_acquire();
+}
+
+static void ap83_040_flash_unlock(struct platform_device *pdev)
+{
+       ath79_flash_release();
+}
+
+static void __init ap83_040_setup(void)
+{
+       ap83_flash_data.lock = ap83_040_flash_lock;
+       ap83_flash_data.unlock = ap83_040_flash_unlock;
+       ap83_generic_setup();
+       platform_device_register(&ap83_040_spi_device);
+}
+
+static void __init ap83_050_setup(void)
+{
+       ap83_generic_setup();
+       platform_device_register(&ap83_050_spi_device);
+}
+
+static void __init ap83_setup(void)
+{
+       u8 *board_id = (u8 *) KSEG1ADDR(0x1fff1244);
+       unsigned int board_version;
+
+       board_version = (unsigned int)(board_id[0] - '0');
+       board_version += ((unsigned int)(board_id[1] - '0')) * 10;
+
+       printk(KERN_WARNING "Board is AP83-%03u\n", board_version);
+
+       switch (board_version) {
+       case 40:
+               ap83_040_setup();
+               break;
+       case 50:
+               ap83_050_setup();
+               break;
+       default:
+               printk(KERN_WARNING "AP83-%03u board is not yet supported\n",
+                      board_version);
+       }
+}
+
+MIPS_MACHINE(ATH79_MACH_AP83, "AP83", "Atheros AP83", ap83_setup);
index 900b4ec87b1b8a3bf6def552974ce930df750acd..ee4afad19fe29abc0fcc6de9b4ccf48953ba1b35 100644 (file)
@@ -40,6 +40,7 @@ enum ath79_mach_type {
        ATH79_MACH_AP147_010,                   /* Atheros AP147-010 reference board */
        ATH79_MACH_AP152,                       /* Atheros AP152 reference board */
        ATH79_MACH_AP531B0,                     /* Rockeetech AP531B0 */
+       ATH79_MACH_AP83,                        /* Atheros AP83 */
        ATH79_MACH_AP90Q,                       /* YunCore AP80Q/AP90Q */
        ATH79_MACH_AP91_5G,                     /* ALFA Network AP91-5G */
        ATH79_MACH_AP96,                        /* Atheros AP96 */
index 25b58ae91e9919fce6f63f9b8fb2adef8239ef82..85b58db3ff1645d20a67c8296ae9f92517f30ec9 100644 (file)
@@ -24,6 +24,7 @@ CONFIG_ATH79_MACH_AP143=y
 CONFIG_ATH79_MACH_AP147=y
 CONFIG_ATH79_MACH_AP152=y
 CONFIG_ATH79_MACH_AP531B0=y
+CONFIG_ATH79_MACH_AP83=y
 CONFIG_ATH79_MACH_AP90Q=y
 CONFIG_ATH79_MACH_AP91_5G=y
 CONFIG_ATH79_MACH_AP96=y
index cbe039cd297a7800401454e0bc2a112bfd5cc8c3..7fdd30d248f490548845370b6f4d83d2f3aecd78 100644 (file)
@@ -21,6 +21,13 @@ define LegacyDevice/TUBE2H8M
 endef
 LEGACY_DEVICES += TUBE2H8M
 
+define LegacyDevice/AP83
+  DEVICE_TITLE := Atheros AP83 reference board
+  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 \
+         vsc7385-ucode-ap83 vsc7395-ucode-ap83
+endef
+LEGACY_DEVICES += AP83
+
 define LegacyDevice/AP96
   DEVICE_TITLE := Atheros AP96 reference board
   DEVICE_PACKAGES := kmod-usb2
index 926ce780b40a682c008388b3ab7d970d5462df9f..83ba0468404028feb04e81a09e473427112df582 100644 (file)
@@ -227,6 +227,7 @@ alfa_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs)
 alfa_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro
 all0258n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),6272k(firmware),1536k(failsafe),64k(art)ro
 all0315n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env),13568k(firmware),2048k(failsafe),256k(art)ro
+ap83_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,4096k(rootfs),3648k(kernel),64k(art)ro,7744k@0x60000(firmware)
 ap96_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1728k(kernel),64k(art)ro,7872k@0x40000(firmware)
 ap121_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1600k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
 ap121_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,10944k(rootfs),4992k(kernel),64k(nvram),64k(art)ro,15936k@0x50000(firmware)
@@ -882,6 +883,7 @@ $(eval $(call SingleProfile,AthLzma,64k,ALFAAP120C,alfa-ap120c,ALFA-AP120C,ttyS0
 $(eval $(call SingleProfile,AthLzma,64k,ALFAAP96,alfa-ap96,ALFA-AP96,ttyS0,115200,$$(alfa_ap96_mtdlayout),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,ALL0258N,all0258n,ALL0258N,ttyS0,115200,$$(all0258n_mtdlayout),KRuImage,65536))
 $(eval $(call SingleProfile,AthLzma,256k,ALL0315N,all0315n,ALL0315N,ttyS0,115200,$$(all0315n_mtdlayout),KRuImage,262144))
+$(eval $(call SingleProfile,AthGzip,64k,AP83,ap83,AP83,ttyS0,115200,$$(ap83_mtdlayout),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP121_8M,ap121-8M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_8M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP121_16M,ap121-16M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_16M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP132,ap132,AP132,ttyS0,115200,$$(ap132_mtdlayout),KRuImage))