Path: blob/master/arch/arm/mach-orion5x/wrt350n-v2-setup.c
10817 views
/*1* arch/arm/mach-orion5x/wrt350n-v2-setup.c2*3* This file is licensed under the terms of the GNU General Public4* License version 2. This program is licensed "as is" without any5* warranty of any kind, whether express or implied.6*/78#include <linux/kernel.h>9#include <linux/init.h>10#include <linux/platform_device.h>11#include <linux/pci.h>12#include <linux/irq.h>13#include <linux/delay.h>14#include <linux/mtd/physmap.h>15#include <linux/mv643xx_eth.h>16#include <linux/ethtool.h>17#include <linux/leds.h>18#include <linux/gpio_keys.h>19#include <linux/input.h>20#include <net/dsa.h>21#include <asm/mach-types.h>22#include <asm/gpio.h>23#include <asm/mach/arch.h>24#include <asm/mach/pci.h>25#include <mach/orion5x.h>26#include "common.h"27#include "mpp.h"2829/*30* LEDs attached to GPIO31*/32static struct gpio_led wrt350n_v2_led_pins[] = {33{34.name = "wrt350nv2:green:power",35.gpio = 0,36.active_low = 1,37}, {38.name = "wrt350nv2:green:security",39.gpio = 1,40.active_low = 1,41}, {42.name = "wrt350nv2:orange:power",43.gpio = 5,44.active_low = 1,45}, {46.name = "wrt350nv2:green:usb",47.gpio = 6,48.active_low = 1,49}, {50.name = "wrt350nv2:green:wireless",51.gpio = 7,52.active_low = 1,53},54};5556static struct gpio_led_platform_data wrt350n_v2_led_data = {57.leds = wrt350n_v2_led_pins,58.num_leds = ARRAY_SIZE(wrt350n_v2_led_pins),59};6061static struct platform_device wrt350n_v2_leds = {62.name = "leds-gpio",63.id = -1,64.dev = {65.platform_data = &wrt350n_v2_led_data,66},67};6869/*70* Buttons attached to GPIO71*/72static struct gpio_keys_button wrt350n_v2_buttons[] = {73{74.code = KEY_RESTART,75.gpio = 3,76.desc = "Reset Button",77.active_low = 1,78}, {79.code = KEY_WPS_BUTTON,80.gpio = 2,81.desc = "WPS Button",82.active_low = 1,83},84};8586static struct gpio_keys_platform_data wrt350n_v2_button_data = {87.buttons = wrt350n_v2_buttons,88.nbuttons = ARRAY_SIZE(wrt350n_v2_buttons),89};9091static struct platform_device wrt350n_v2_button_device = {92.name = "gpio-keys",93.id = -1,94.num_resources = 0,95.dev = {96.platform_data = &wrt350n_v2_button_data,97},98};99100/*101* General setup102*/103static unsigned int wrt350n_v2_mpp_modes[] __initdata = {104MPP0_GPIO, /* Power LED green (0=on) */105MPP1_GPIO, /* Security LED (0=on) */106MPP2_GPIO, /* Internal Button (0=on) */107MPP3_GPIO, /* Reset Button (0=on) */108MPP4_GPIO, /* PCI int */109MPP5_GPIO, /* Power LED orange (0=on) */110MPP6_GPIO, /* USB LED (0=on) */111MPP7_GPIO, /* Wireless LED (0=on) */112MPP8_UNUSED, /* ??? */113MPP9_GIGE, /* GE_RXERR */114MPP10_UNUSED, /* ??? */115MPP11_UNUSED, /* ??? */116MPP12_GIGE, /* GE_TXD[4] */117MPP13_GIGE, /* GE_TXD[5] */118MPP14_GIGE, /* GE_TXD[6] */119MPP15_GIGE, /* GE_TXD[7] */120MPP16_GIGE, /* GE_RXD[4] */121MPP17_GIGE, /* GE_RXD[5] */122MPP18_GIGE, /* GE_RXD[6] */123MPP19_GIGE, /* GE_RXD[7] */1240,125};126127/*128* 8M NOR flash Device bus boot chip select129*/130#define WRT350N_V2_NOR_BOOT_BASE 0xf4000000131#define WRT350N_V2_NOR_BOOT_SIZE SZ_8M132133static struct mtd_partition wrt350n_v2_nor_flash_partitions[] = {134{135.name = "kernel",136.offset = 0x00000000,137.size = 0x00760000,138}, {139.name = "rootfs",140.offset = 0x001a0000,141.size = 0x005c0000,142}, {143.name = "lang",144.offset = 0x00760000,145.size = 0x00040000,146}, {147.name = "nvram",148.offset = 0x007a0000,149.size = 0x00020000,150}, {151.name = "u-boot",152.offset = 0x007c0000,153.size = 0x00040000,154},155};156157static struct physmap_flash_data wrt350n_v2_nor_flash_data = {158.width = 1,159.parts = wrt350n_v2_nor_flash_partitions,160.nr_parts = ARRAY_SIZE(wrt350n_v2_nor_flash_partitions),161};162163static struct resource wrt350n_v2_nor_flash_resource = {164.flags = IORESOURCE_MEM,165.start = WRT350N_V2_NOR_BOOT_BASE,166.end = WRT350N_V2_NOR_BOOT_BASE + WRT350N_V2_NOR_BOOT_SIZE - 1,167};168169static struct platform_device wrt350n_v2_nor_flash = {170.name = "physmap-flash",171.id = 0,172.dev = {173.platform_data = &wrt350n_v2_nor_flash_data,174},175.num_resources = 1,176.resource = &wrt350n_v2_nor_flash_resource,177};178179static struct mv643xx_eth_platform_data wrt350n_v2_eth_data = {180.phy_addr = MV643XX_ETH_PHY_NONE,181.speed = SPEED_1000,182.duplex = DUPLEX_FULL,183};184185static struct dsa_chip_data wrt350n_v2_switch_chip_data = {186.port_names[0] = "lan2",187.port_names[1] = "lan1",188.port_names[2] = "wan",189.port_names[3] = "cpu",190.port_names[5] = "lan3",191.port_names[7] = "lan4",192};193194static struct dsa_platform_data wrt350n_v2_switch_plat_data = {195.nr_chips = 1,196.chip = &wrt350n_v2_switch_chip_data,197};198199static void __init wrt350n_v2_init(void)200{201/*202* Setup basic Orion functions. Need to be called early.203*/204orion5x_init();205206orion5x_mpp_conf(wrt350n_v2_mpp_modes);207208/*209* Configure peripherals.210*/211orion5x_ehci0_init();212orion5x_eth_init(&wrt350n_v2_eth_data);213orion5x_eth_switch_init(&wrt350n_v2_switch_plat_data, NO_IRQ);214orion5x_uart0_init();215216orion5x_setup_dev_boot_win(WRT350N_V2_NOR_BOOT_BASE,217WRT350N_V2_NOR_BOOT_SIZE);218platform_device_register(&wrt350n_v2_nor_flash);219platform_device_register(&wrt350n_v2_leds);220platform_device_register(&wrt350n_v2_button_device);221}222223static int __init wrt350n_v2_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)224{225int irq;226227/*228* Check for devices with hard-wired IRQs.229*/230irq = orion5x_pci_map_irq(dev, slot, pin);231if (irq != -1)232return irq;233234/*235* Mini-PCI slot.236*/237if (slot == 7)238return gpio_to_irq(4);239240return -1;241}242243static struct hw_pci wrt350n_v2_pci __initdata = {244.nr_controllers = 2,245.swizzle = pci_std_swizzle,246.setup = orion5x_pci_sys_setup,247.scan = orion5x_pci_sys_scan_bus,248.map_irq = wrt350n_v2_pci_map_irq,249};250251static int __init wrt350n_v2_pci_init(void)252{253if (machine_is_wrt350n_v2())254pci_common_init(&wrt350n_v2_pci);255256return 0;257}258subsys_initcall(wrt350n_v2_pci_init);259260MACHINE_START(WRT350N_V2, "Linksys WRT350N v2")261/* Maintainer: Lennert Buytenhek <[email protected]> */262.boot_params = 0x00000100,263.init_machine = wrt350n_v2_init,264.map_io = orion5x_map_io,265.init_early = orion5x_init_early,266.init_irq = orion5x_init_irq,267.timer = &orion5x_timer,268.fixup = tag_fixup_mem32,269MACHINE_END270271272