Merge branches 'release', 'asus', 'sony-laptop' and 'thinkpad' into release
[pandora-kernel.git] / arch / arm / mach-orion / kurobox_pro-setup.c
1 /*
2  * arch/arm/mach-orion/kurobox_pro-setup.c
3  *
4  * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
5  *
6  * This file is licensed under  the terms of the GNU General Public
7  * License version 2. This program is licensed "as is" without any
8  * warranty of any kind, whether express or implied.
9  */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/pci.h>
15 #include <linux/irq.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/mtd/nand.h>
18 #include <linux/mv643xx_eth.h>
19 #include <linux/i2c.h>
20 #include <asm/mach-types.h>
21 #include <asm/gpio.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/pci.h>
24 #include <asm/arch/orion.h>
25 #include <asm/arch/platform.h>
26 #include "common.h"
27
28 /*****************************************************************************
29  * KUROBOX-PRO Info
30  ****************************************************************************/
31
32 /*
33  * 256K NOR flash Device bus boot chip select
34  */
35
36 #define KUROBOX_PRO_NOR_BOOT_BASE       0xf4000000
37 #define KUROBOX_PRO_NOR_BOOT_SIZE       SZ_256K
38
39 /*
40  * 256M NAND flash on Device bus chip select 1
41  */
42
43 #define KUROBOX_PRO_NAND_BASE           0xfc000000
44 #define KUROBOX_PRO_NAND_SIZE           SZ_2M
45
46 /*****************************************************************************
47  * 256MB NAND Flash on Device bus CS0
48  ****************************************************************************/
49
50 static struct mtd_partition kurobox_pro_nand_parts[] = {
51         {
52                 .name   = "uImage",
53                 .offset = 0,
54                 .size   = SZ_4M,
55         },
56         {
57                 .name   = "rootfs",
58                 .offset = SZ_4M,
59                 .size   = SZ_64M,
60         },
61         {
62                 .name   = "extra",
63                 .offset = SZ_4M + SZ_64M,
64                 .size   = SZ_256M - (SZ_4M + SZ_64M),
65         },
66 };
67
68 static struct resource kurobox_pro_nand_resource = {
69         .flags          = IORESOURCE_MEM,
70         .start          = KUROBOX_PRO_NAND_BASE,
71         .end            = KUROBOX_PRO_NAND_BASE + KUROBOX_PRO_NAND_SIZE - 1,
72 };
73
74 static struct orion_nand_data kurobox_pro_nand_data = {
75         .parts          = kurobox_pro_nand_parts,
76         .nr_parts       = ARRAY_SIZE(kurobox_pro_nand_parts),
77         .cle            = 0,
78         .ale            = 1,
79         .width          = 8,
80 };
81
82 static struct platform_device kurobox_pro_nand_flash = {
83         .name           = "orion_nand",
84         .id             = -1,
85         .dev            = {
86                 .platform_data  = &kurobox_pro_nand_data,
87         },
88         .resource       = &kurobox_pro_nand_resource,
89         .num_resources  = 1,
90 };
91
92 /*****************************************************************************
93  * 256KB NOR Flash on BOOT Device
94  ****************************************************************************/
95
96 static struct physmap_flash_data kurobox_pro_nor_flash_data = {
97         .width          = 1,
98 };
99
100 static struct resource kurobox_pro_nor_flash_resource = {
101         .flags                  = IORESOURCE_MEM,
102         .start                  = KUROBOX_PRO_NOR_BOOT_BASE,
103         .end                    = KUROBOX_PRO_NOR_BOOT_BASE + KUROBOX_PRO_NOR_BOOT_SIZE - 1,
104 };
105
106 static struct platform_device kurobox_pro_nor_flash = {
107         .name                   = "physmap-flash",
108         .id                     = 0,
109         .dev            = {
110                 .platform_data  = &kurobox_pro_nor_flash_data,
111         },
112         .num_resources          = 1,
113         .resource               = &kurobox_pro_nor_flash_resource,
114 };
115
116 /*****************************************************************************
117  * PCI
118  ****************************************************************************/
119
120 static int __init kurobox_pro_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
121 {
122         /*
123          * PCI isn't used on the Kuro
124          */
125         if (dev->bus->number == orion_pcie_local_bus_nr())
126                 return IRQ_ORION_PCIE0_INT;
127         else
128                 printk(KERN_ERR "kurobox_pro_pci_map_irq failed, unknown bus\n");
129
130         return -1;
131 }
132
133 static struct hw_pci kurobox_pro_pci __initdata = {
134         .nr_controllers = 1,
135         .swizzle        = pci_std_swizzle,
136         .setup          = orion_pci_sys_setup,
137         .scan           = orion_pci_sys_scan_bus,
138         .map_irq        = kurobox_pro_pci_map_irq,
139 };
140
141 static int __init kurobox_pro_pci_init(void)
142 {
143         if (machine_is_kurobox_pro())
144                 pci_common_init(&kurobox_pro_pci);
145
146         return 0;
147 }
148
149 subsys_initcall(kurobox_pro_pci_init);
150
151 /*****************************************************************************
152  * Ethernet
153  ****************************************************************************/
154
155 static struct mv643xx_eth_platform_data kurobox_pro_eth_data = {
156         .phy_addr       = 8,
157         .force_phy_addr = 1,
158 };
159
160 /*****************************************************************************
161  * RTC 5C372a on I2C bus
162  ****************************************************************************/
163 static struct i2c_board_info __initdata kurobox_pro_i2c_rtc = {
164        .driver_name    = "rtc-rs5c372",
165        .type           = "rs5c372a",
166        .addr           = 0x32,
167 };
168
169 /*****************************************************************************
170  * General Setup
171  ****************************************************************************/
172
173 static struct platform_device *kurobox_pro_devices[] __initdata = {
174         &kurobox_pro_nor_flash,
175         &kurobox_pro_nand_flash,
176 };
177
178 static void __init kurobox_pro_init(void)
179 {
180         /*
181          * Setup basic Orion functions. Need to be called early.
182          */
183         orion_init();
184
185         /*
186          * Setup the CPU address decode windows for our devices
187          */
188         orion_setup_cpu_win(ORION_DEV_BOOT, KUROBOX_PRO_NOR_BOOT_BASE,
189                                 KUROBOX_PRO_NOR_BOOT_SIZE, -1);
190         orion_setup_cpu_win(ORION_DEV0, KUROBOX_PRO_NAND_BASE,
191                                 KUROBOX_PRO_NAND_SIZE, -1);
192         /*
193          * Open a special address decode windows for the PCIE WA.
194          */
195         orion_write(ORION_REGS_BASE | 0x20074, ORION_PCIE_WA_BASE);
196         orion_write(ORION_REGS_BASE | 0x20070, (0x7941 |
197                 (((ORION_PCIE_WA_SIZE >> 16) - 1)) << 16));
198
199         /*
200          * Setup Multiplexing Pins --
201          * MPP[0-1] Not used
202          * MPP[2] GPIO Micon
203          * MPP[3] GPIO RTC
204          * MPP[4-5] Not used
205          * MPP[6] Nand Flash REn
206          * MPP[7] Nand Flash WEn
207          * MPP[8-11] Not used
208          * MPP[12] SATA 0 presence Indication
209          * MPP[13] SATA 1 presence Indication
210          * MPP[14] SATA 0 active Indication
211          * MPP[15] SATA 1 active indication
212          * MPP[16-19] Not used
213          */
214         orion_write(MPP_0_7_CTRL, 0x44220003);
215         orion_write(MPP_8_15_CTRL, 0x55550000);
216         orion_write(MPP_16_19_CTRL, 0x0);
217
218         orion_gpio_set_valid_pins(0x0000000c);
219
220         platform_add_devices(kurobox_pro_devices, ARRAY_SIZE(kurobox_pro_devices));
221         i2c_register_board_info(0, &kurobox_pro_i2c_rtc, 1);
222         orion_eth_init(&kurobox_pro_eth_data);
223 }
224
225 MACHINE_START(KUROBOX_PRO, "Buffalo/Revogear Kurobox Pro")
226         /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
227         .phys_io        = ORION_REGS_BASE,
228         .io_pg_offst    = ((ORION_REGS_BASE) >> 18) & 0xFFFC,
229         .boot_params    = 0x00000100,
230         .init_machine   = kurobox_pro_init,
231         .map_io         = orion_map_io,
232         .init_irq       = orion_init_irq,
233         .timer          = &orion_timer,
234 MACHINE_END