2 * Zyxel NBG 460N/550N/550NH board support
4 * Copyright (C) 2010 Michael Kurz <michi.kurz@googlemail.com>
6 * based on mach-tl-wr1043nd.c
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/delay.h>
17 #include <linux/rtl8366s.h>
19 #include <linux/i2c.h>
20 #include <linux/i2c-algo-bit.h>
21 #include <linux/i2c-gpio.h>
23 #include <asm/mach-ar71xx/ar71xx.h>
27 #include "dev-m25p80.h"
28 #include "dev-ar913x-wmac.h"
29 #include "dev-gpio-buttons.h"
30 #include "dev-leds-gpio.h"
33 #define NBG460N_GPIO_LED_WPS 3
34 #define NBG460N_GPIO_LED_WAN 6
35 #define NBG460N_GPIO_LED_POWER 14
36 #define NBG460N_GPIO_LED_WLAN 15
39 #define NBG460N_GPIO_BTN_WPS 12
40 #define NBG460N_GPIO_BTN_RESET 21
41 #define NBG460N_BUTTONS_POLL_INTERVAL 20
43 /* RTC chip PCF8563 I2C interface */
44 #define NBG460N_GPIO_PCF8563_SDA 8
45 #define NBG460N_GPIO_PCF8563_SCK 7
47 /* Switch configuration I2C interface */
48 #define NBG460N_GPIO_RTL8366_SDA 16
49 #define NBG460N_GPIO_RTL8366_SCK 18
51 #ifdef CONFIG_MTD_PARTITIONS
52 static struct mtd_partition nbg460n_partitions
[] = {
58 .name
= "U-Boot Config",
61 .mask_flags
= MTD_WRITEABLE
,
66 .mask_flags
= MTD_WRITEABLE
,
71 .mask_flags
= MTD_WRITEABLE
,
78 #endif /* CONFIG_MTD_PARTITIONS */
80 static struct flash_platform_data nbg460n_flash_data
= {
81 #ifdef CONFIG_MTD_PARTITIONS
82 .parts
= nbg460n_partitions
,
83 .nr_parts
= ARRAY_SIZE(nbg460n_partitions
),
87 static struct gpio_led nbg460n_leds_gpio
[] __initdata
= {
89 .name
= "nbg460n:green:power",
90 .gpio
= NBG460N_GPIO_LED_POWER
,
92 .default_trigger
= "default-on",
94 .name
= "nbg460n:green:wps",
95 .gpio
= NBG460N_GPIO_LED_WPS
,
98 .name
= "nbg460n:green:wlan",
99 .gpio
= NBG460N_GPIO_LED_WLAN
,
102 /* Not really for controlling the LED,
103 when set low the LED blinks uncontrollable */
104 .name
= "nbg460n:green:wan",
105 .gpio
= NBG460N_GPIO_LED_WAN
,
110 static struct gpio_button nbg460n_gpio_buttons
[] __initdata
= {
116 .gpio
= NBG460N_GPIO_BTN_RESET
,
121 .code
= KEY_WPS_BUTTON
,
123 .gpio
= NBG460N_GPIO_BTN_WPS
,
128 static struct i2c_gpio_platform_data nbg460n_i2c_device_platdata
= {
129 .sda_pin
= NBG460N_GPIO_PCF8563_SDA
,
130 .scl_pin
= NBG460N_GPIO_PCF8563_SCK
,
134 static struct platform_device nbg460n_i2c_device
= {
140 .platform_data
= &nbg460n_i2c_device_platdata
,
144 static struct i2c_board_info nbg460n_i2c_devs
[] __initdata
= {
146 I2C_BOARD_INFO("pcf8563", 0x51),
150 static void __devinit
nbg460n_i2c_init(void)
152 /* The gpio interface */
153 platform_device_register(&nbg460n_i2c_device
);
155 i2c_register_board_info(0, nbg460n_i2c_devs
,
156 ARRAY_SIZE(nbg460n_i2c_devs
));
160 static struct rtl8366s_platform_data nbg460n_rtl8366s_data
= {
161 .gpio_sda
= NBG460N_GPIO_RTL8366_SDA
,
162 .gpio_sck
= NBG460N_GPIO_RTL8366_SCK
,
165 static struct platform_device nbg460n_rtl8366s_device
= {
166 .name
= RTL8366S_DRIVER_NAME
,
169 .platform_data
= &nbg460n_rtl8366s_data
,
173 static void __init
nbg460n_setup(void)
175 /* end of bootloader sector contains mac address*/
176 u8
*mac
= (u8
*) KSEG1ADDR(0x1fc0fff8);
177 /* last sector contains wlan calib data */
178 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1fff1000);
180 ar71xx_set_mac_base(mac
);
183 ar71xx_eth0_data
.mii_bus_dev
= &nbg460n_rtl8366s_device
.dev
;
184 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
185 ar71xx_eth0_data
.speed
= SPEED_1000
;
186 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
189 ar71xx_eth1_data
.mii_bus_dev
= &nbg460n_rtl8366s_device
.dev
;
190 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
191 ar71xx_eth1_data
.phy_mask
= 0x10;
193 ar71xx_add_device_eth(0);
194 ar71xx_add_device_eth(1);
196 /* register the switch phy */
197 platform_device_register(&nbg460n_rtl8366s_device
);
200 ar71xx_add_device_m25p80(&nbg460n_flash_data
);
202 ar913x_add_device_wmac(eeprom
, mac
);
204 /* register RTC chip */
207 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(nbg460n_leds_gpio
),
210 ar71xx_add_device_gpio_buttons(-1, NBG460N_BUTTONS_POLL_INTERVAL
,
211 ARRAY_SIZE(nbg460n_gpio_buttons
),
212 nbg460n_gpio_buttons
);
215 MIPS_MACHINE(AR71XX_MACH_NBG460N
, "NBG460N", "Zyxel NBG460N/550N/550NH", nbg460n_setup
);