+/* common RB SSRs */
+#define RBSPI_SSR_GPIO_BASE 40
+#define RBSPI_SSR_GPIO(bit) (RBSPI_SSR_GPIO_BASE + (bit))
+
+/* RB 951Ui-2nD gpios */
+#define RB952_SSR_BIT_LED_LAN1 0
+#define RB952_SSR_BIT_LED_LAN2 1
+#define RB952_SSR_BIT_LED_LAN3 2
+#define RB952_SSR_BIT_LED_LAN4 3
+#define RB952_SSR_BIT_LED_LAN5 4
+#define RB952_SSR_BIT_USB_POWER 5
+#define RB952_SSR_BIT_LED_WLAN 6
+#define RB952_GPIO_SSR_CS 11
+#define RB952_GPIO_LED_USER 4
+#define RB952_GPIO_POE_POWER 14
+#define RB952_GPIO_POE_STATUS 12
+#define RB952_GPIO_BTN_RESET 16
+#define RB952_GPIO_USB_POWER RBSPI_SSR_GPIO(RB952_SSR_BIT_USB_POWER)
+#define RB952_GPIO_LED_LAN1 RBSPI_SSR_GPIO(RB952_SSR_BIT_LED_LAN1)
+#define RB952_GPIO_LED_LAN2 RBSPI_SSR_GPIO(RB952_SSR_BIT_LED_LAN2)
+#define RB952_GPIO_LED_LAN3 RBSPI_SSR_GPIO(RB952_SSR_BIT_LED_LAN3)
+#define RB952_GPIO_LED_LAN4 RBSPI_SSR_GPIO(RB952_SSR_BIT_LED_LAN4)
+#define RB952_GPIO_LED_LAN5 RBSPI_SSR_GPIO(RB952_SSR_BIT_LED_LAN5)
+#define RB952_GPIO_LED_WLAN RBSPI_SSR_GPIO(RB952_SSR_BIT_LED_WLAN)
+
+static struct gpio_led rb952_leds[] __initdata = {
+ {
+ .name = "rb:green:user",
+ .gpio = RB952_GPIO_LED_USER,
+ .active_low = 0,
+ }, {
+ .name = "rb:blue:wlan",
+ .gpio = RB952_GPIO_LED_WLAN,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:port1",
+ .gpio = RB952_GPIO_LED_LAN1,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:port2",
+ .gpio = RB952_GPIO_LED_LAN2,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:port3",
+ .gpio = RB952_GPIO_LED_LAN3,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:port4",
+ .gpio = RB952_GPIO_LED_LAN4,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:port5",
+ .gpio = RB952_GPIO_LED_LAN5,
+ .active_low = 1,
+ },
+};
+
+
+/* RB 962UiGS-5HacT2HnT gpios */
+#define RB962_GPIO_POE_STATUS 2
+#define RB962_GPIO_POE_POWER 3
+#define RB962_GPIO_LED_USER 12
+#define RB962_GPIO_USB_POWER 13
+#define RB962_GPIO_BTN_RESET 20
+
+static struct gpio_led rb962_leds_gpio[] __initdata = {
+ {
+ .name = "rb:green:user",
+ .gpio = RB962_GPIO_LED_USER,
+ .active_low = 1,
+ },
+};
+
+static const struct ar8327_led_info rb962_leds_ar8327[] = {
+ AR8327_LED_INFO(PHY0_0, HW, "rb:green:port1"),
+ AR8327_LED_INFO(PHY1_0, HW, "rb:green:port2"),
+ AR8327_LED_INFO(PHY2_0, HW, "rb:green:port3"),
+ AR8327_LED_INFO(PHY3_0, HW, "rb:green:port4"),
+ AR8327_LED_INFO(PHY4_0, HW, "rb:green:port5"),
+};
+
+static struct ar8327_pad_cfg rb962_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,
+ .mac06_exchange_dis = true,
+};
+
+static struct ar8327_pad_cfg rb962_ar8327_pad6_cfg = {
+ /* Use SGMII interface for GMAC6 of the AR8337 switch */
+ .mode = AR8327_PAD_MAC_SGMII,
+ .rxclk_delay_en = true,
+ .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
+};
+
+static struct ar8327_led_cfg rb962_ar8327_led_cfg = {
+ .led_ctrl0 = 0xc737c737,
+ .led_ctrl1 = 0x00000000,
+ .led_ctrl2 = 0x00000000,
+ .led_ctrl3 = 0x0030c300,
+ .open_drain = false,
+};
+
+static struct ar8327_platform_data rb962_ar8327_data = {
+ .pad0_cfg = &rb962_ar8327_pad0_cfg,
+ .pad6_cfg = &rb962_ar8327_pad6_cfg,
+ .port0_cfg = {
+ .force_link = 1,
+ .speed = AR8327_PORT_SPEED_1000,
+ .duplex = 1,
+ .txpause = 1,
+ .rxpause = 1,
+ },
+ .port6_cfg = {
+ .force_link = 1,
+ .speed = AR8327_PORT_SPEED_1000,
+ .duplex = 1,
+ .txpause = 1,
+ .rxpause = 1,
+ },
+ .led_cfg = &rb962_ar8327_led_cfg,
+ .num_leds = ARRAY_SIZE(rb962_leds_ar8327),
+ .leds = rb962_leds_ar8327,
+};
+
+static struct mdio_board_info rb962_mdio0_info[] = {
+ {
+ .bus_id = "ag71xx-mdio.0",
+ .phy_addr = 0,
+ .platform_data = &rb962_ar8327_data,
+ },
+};
+
+/* RB wAP-2nD gpios */
+#define RBWAP_GPIO_LED_USER 14
+#define RBWAP_GPIO_LED_WLAN 11
+#define RBWAP_GPIO_BTN_RESET 16
+
+static struct gpio_led rbwap_leds[] __initdata = {
+ {
+ .name = "rb:green:user",
+ .gpio = RBWAP_GPIO_LED_USER,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:wlan",
+ .gpio = RBWAP_GPIO_LED_WLAN,
+ .active_low = 1,
+ },
+};
+
+/* RB cAP-2nD gpios */
+#define RBCAP_GPIO_LED_1 14
+#define RBCAP_GPIO_LED_2 12
+#define RBCAP_GPIO_LED_3 11
+#define RBCAP_GPIO_LED_4 4
+#define RBCAP_GPIO_LED_ALL 13
+
+static struct gpio_led rbcap_leds[] __initdata = {
+ {
+ .name = "rb:green:rssi1",
+ .gpio = RBCAP_GPIO_LED_1,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi2",
+ .gpio = RBCAP_GPIO_LED_2,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi3",
+ .gpio = RBCAP_GPIO_LED_3,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi4",
+ .gpio = RBCAP_GPIO_LED_4,
+ .active_low = 1,
+ },
+};
+
+/* RB mAP-2nD gpios */
+#define RBMAP_SSR_BIT_LED_LAN1 0
+#define RBMAP_SSR_BIT_LED_LAN2 1
+#define RBMAP_SSR_BIT_LED_POEO 2
+#define RBMAP_SSR_BIT_LED_USER 3
+#define RBMAP_SSR_BIT_LED_WLAN 4
+#define RBMAP_SSR_BIT_USB_POWER 5
+#define RBMAP_SSR_BIT_LED_APCAP 6
+#define RBMAP_GPIO_BTN_RESET 16
+#define RBMAP_GPIO_SSR_CS 11
+#define RBMAP_GPIO_LED_POWER 4
+#define RBMAP_GPIO_POE_POWER 14
+#define RBMAP_GPIO_POE_STATUS 12
+#define RBMAP_GPIO_USB_POWER RBSPI_SSR_GPIO(RBMAP_SSR_BIT_USB_POWER)
+#define RBMAP_GPIO_LED_LAN1 RBSPI_SSR_GPIO(RBMAP_SSR_BIT_LED_LAN1)
+#define RBMAP_GPIO_LED_LAN2 RBSPI_SSR_GPIO(RBMAP_SSR_BIT_LED_LAN2)
+#define RBMAP_GPIO_LED_POEO RBSPI_SSR_GPIO(RBMAP_SSR_BIT_LED_POEO)
+#define RBMAP_GPIO_LED_USER RBSPI_SSR_GPIO(RBMAP_SSR_BIT_LED_USER)
+#define RBMAP_GPIO_LED_WLAN RBSPI_SSR_GPIO(RBMAP_SSR_BIT_LED_WLAN)
+#define RBMAP_GPIO_LED_APCAP RBSPI_SSR_GPIO(RBMAP_SSR_BIT_LED_APCAP)
+
+static struct gpio_led rbmap_leds[] __initdata = {
+ {
+ .name = "rb:green:power",
+ .gpio = RBMAP_GPIO_LED_POWER,
+ .active_low = 1,
+ .default_state = LEDS_GPIO_DEFSTATE_ON,
+ }, {
+ .name = "rb:green:eth1",
+ .gpio = RBMAP_GPIO_LED_LAN1,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:eth2",
+ .gpio = RBMAP_GPIO_LED_LAN2,
+ .active_low = 1,
+ }, {
+ .name = "rb:red:poe_out",
+ .gpio = RBMAP_GPIO_LED_POEO,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:user",
+ .gpio = RBMAP_GPIO_LED_USER,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:wlan",
+ .gpio = RBMAP_GPIO_LED_WLAN,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:ap_cap",
+ .gpio = RBMAP_GPIO_LED_APCAP,
+ .active_low = 1,
+ },
+};
+
+/* RB LHG 5nD gpios */
+#define RBLHG_GPIO_LED_0 13
+#define RBLHG_GPIO_LED_1 12
+#define RBLHG_GPIO_LED_2 4
+#define RBLHG_GPIO_LED_3 21
+#define RBLHG_GPIO_LED_4 18
+#define RBLHG_GPIO_LED_ETH 14
+#define RBLHG_GPIO_LED_POWER 11
+#define RBLHG_GPIO_LED_USER 20
+#define RBLHG_GPIO_BTN_RESET 15
+
+static struct gpio_led rblhg_leds[] __initdata = {
+ {
+ .name = "rb:green:rssi0",
+ .gpio = RBLHG_GPIO_LED_0,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi1",
+ .gpio = RBLHG_GPIO_LED_1,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi2",
+ .gpio = RBLHG_GPIO_LED_2,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi3",
+ .gpio = RBLHG_GPIO_LED_3,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:rssi4",
+ .gpio = RBLHG_GPIO_LED_4,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:eth",
+ .gpio = RBLHG_GPIO_LED_ETH,
+ .active_low = 1,
+ }, {
+ .name = "rb:green:user",
+ .gpio = RBLHG_GPIO_LED_USER,
+ .active_low = 1,
+ }, {
+ .name = "rb:blue:power",
+ .gpio = RBLHG_GPIO_LED_POWER,
+ .active_low = 0,
+ .default_state = LEDS_GPIO_DEFSTATE_ON,
+ },
+};
+
+/* RB w APG-5HacT2HnD (wAP AC) gpios*/
+#define RBWAPGSC_LED1 1
+#define RBWAPGSC_LED2 8
+#define RBWAPGSC_LED3 9
+#define RBWAPGSC_POWERLED 16
+#define RBWAPGSC_GPIO_BTN_RESET 1
+#define RBWAPGSC_GPIO_MDIO_MDC 12
+#define RBWAPGSC_GPIO_MDIO_DATA 11
+#define RBWAPGSC_MDIO_PHYADDR 0
+
+static struct gpio_led rbwapgsc_leds[] __initdata = {
+ {
+ .name = "rb:green:led1",
+ .gpio = RBWAPGSC_LED1,
+ .active_low = 1,
+ },{
+ .name = "rb:blue:power",
+ .gpio = RBWAPGSC_POWERLED,
+ .active_low = 1,
+ },
+};
+
+static struct mdio_gpio_platform_data rbwapgsc_mdio_data = {
+ .mdc = RBWAPGSC_GPIO_MDIO_MDC,
+ .mdio = RBWAPGSC_GPIO_MDIO_DATA,
+ .phy_mask = ~BIT(RBWAPGSC_MDIO_PHYADDR),
+};
+
+static struct platform_device rbwapgsc_phy_device = {
+ .name = "mdio-gpio",
+ .id = 1,
+ .dev = {
+ .platform_data = &rbwapgsc_mdio_data
+ },
+};
+
+static struct gen_74x164_chip_platform_data rbspi_ssr_data = {
+ .base = RBSPI_SSR_GPIO_BASE,
+ .num_registers = 1,
+};
+
+/* the spi-ath79 driver can only natively handle CS0. Other CS are bit-banged */
+static int rbspi_spi_cs_gpios[] = {
+ -ENOENT, /* CS0 is always -ENOENT: natively handled */
+ -ENOENT, /* CS1 can be updated by the code as necessary */
+};
+
+static struct ath79_spi_platform_data rbspi_ath79_spi_data = {
+ .bus_num = 0,
+ .cs_gpios = rbspi_spi_cs_gpios,
+};
+
+/*
+ * Global spi_board_info: devices that don't have an SSR only have the SPI NOR
+ * flash on bus0 CS0, while devices that have an SSR add it on the same bus CS1
+ */
+static struct spi_board_info rbspi_spi_info[] = {
+ {
+ .bus_num = 0,
+ .chip_select = 0,
+ .max_speed_hz = 25000000,
+ .modalias = "m25p80",
+ .platform_data = &rbspi_spi_flash_data,
+ }, {
+ .bus_num = 0,
+ .chip_select = 1,
+ .max_speed_hz = 25000000,
+ .modalias = "74x164",
+ .platform_data = &rbspi_ssr_data,
+ }
+};
+
+void __init rbspi_wlan_init(u16 id, int wmac_offset)