aee68cb9f8544484b2fd6639c9e7220fe762ab48
[openwrt-10.03/.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wndr3700.c
1 /*
2  *  Netgear WNDR3700 board support
3  *
4  *  Copyright (C) 2009 Marco Porsch
5  *  Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
6  *
7  *  This program is free software; you can redistribute it and/or modify it
8  *  under the terms of the GNU General Public License version 2 as published
9  *  by the Free Software Foundation.
10  */
11
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17
18 #include <asm/mips_machine.h>
19 #include <asm/mach-ar71xx/ar71xx.h>
20 #include <asm/mach-ar71xx/pci.h>
21
22 #include "devices.h"
23
24 #ifdef CONFIG_MTD_PARTITIONS
25 static struct mtd_partition wndr3700_partitions[] = {
26         {
27                 .name           = "uboot",
28                 .offset         = 0,
29                 .size           = 0x050000,
30                 .mask_flags     = MTD_WRITEABLE,
31         } , {
32                 .name           = "env",
33                 .offset         = 0x050000,
34                 .size           = 0x020000,
35                 .mask_flags     = MTD_WRITEABLE,
36         } , {
37                 .name           = "rootfs",
38                 .offset         = 0x070000,
39                 .size           = 0x720000,
40         } , {
41                 .name           = "config",
42                 .offset         = 0x790000,
43                 .size           = 0x010000,
44                 .mask_flags     = MTD_WRITEABLE,
45         } , {
46                 .name           = "config_bak",
47                 .offset         = 0x7a0000,
48                 .size           = 0x010000,
49                 .mask_flags     = MTD_WRITEABLE,
50         } , {
51                 .name           = "pot",
52                 .offset         = 0x7b0000,
53                 .size           = 0x010000,
54                 .mask_flags     = MTD_WRITEABLE,
55         } , {
56                 .name           = "traffic_meter",
57                 .offset         = 0x7c0000,
58                 .size           = 0x010000,
59                 .mask_flags     = MTD_WRITEABLE,
60         } , {
61                 .name           = "language",
62                 .offset         = 0x7d0000,
63                 .size           = 0x020000,
64                 .mask_flags     = MTD_WRITEABLE,
65         } , {
66                 .name           = "caldata",
67                 .offset         = 0x7f0000,
68                 .size           = 0x010000,
69                 .mask_flags     = MTD_WRITEABLE,
70         }
71 };
72 #endif /* CONFIG_MTD_PARTITIONS */
73
74 static struct flash_platform_data wndr3700_flash_data = {
75 #ifdef CONFIG_MTD_PARTITIONS
76         .parts          = wndr3700_partitions,
77         .nr_parts       = ARRAY_SIZE(wndr3700_partitions),
78 #endif
79 };
80
81 static struct ar71xx_pci_irq wndr3700_pci_irqs[] __initdata = {
82         {
83                 .slot   = 0,
84                 .pin    = 1,
85                 .irq    = AR71XX_PCI_IRQ_DEV0,
86         }, {
87                 .slot   = 1,
88                 .pin    = 1,
89                 .irq    = AR71XX_PCI_IRQ_DEV1,
90         }
91 };
92
93 static struct spi_board_info wndr3700_spi_info[] = {
94         {
95                 .bus_num        = 0,
96                 .chip_select    = 0,
97                 .max_speed_hz   = 25000000,
98                 .modalias       = "m25p80",
99                 .platform_data  = &wndr3700_flash_data,
100         }
101 };
102
103 static void __init wndr3700_setup(void)
104 {
105         u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
106
107         ar71xx_set_mac_base(mac);
108         ar71xx_add_device_mdio(0x0);
109
110         ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
111         ar71xx_eth0_data.phy_mask = 0xf;
112         ar71xx_eth0_data.speed = SPEED_1000;
113         ar71xx_eth0_data.duplex = DUPLEX_FULL;
114
115         ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
116         ar71xx_eth1_data.phy_mask = 0x10;
117
118         ar71xx_add_device_eth(0);
119         ar71xx_add_device_eth(1);
120
121         ar71xx_add_device_usb();
122
123         ar71xx_pci_init(ARRAY_SIZE(wndr3700_pci_irqs), wndr3700_pci_irqs);
124
125         ar71xx_add_device_spi(NULL, wndr3700_spi_info,
126                               ARRAY_SIZE(wndr3700_spi_info));
127
128         /* TODO: LEDs, buttons support */
129 }
130
131 MIPS_MACHINE(AR71XX_MACH_WNDR3700, "NETGEAR WNDR3700", wndr3700_setup);