Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[pandora-kernel.git] / arch / arm / mach-ep93xx / micro9.c
1 /*
2  *  linux/arch/arm/mach-ep93xx/micro9.c
3  *
4  * Copyright (C) 2006 Contec Steuerungstechnik & Automation GmbH
5  *                    Manfred Gruber <m.gruber@tirol.com>
6  * Copyright (C) 2009 Contec Steuerungstechnik & Automation GmbH
7  *                    Hubert Feurstein <hubert.feurstein@contec.at>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/mtd/physmap.h>
18
19 #include <mach/hardware.h>
20
21 #include <asm/mach-types.h>
22 #include <asm/mach/arch.h>
23
24
25 /*************************************************************************
26  * Micro9 NOR Flash
27  *
28  * Micro9-High has up to 64MB of 32-bit flash on CS1
29  * Micro9-Mid has up to 64MB of either 32-bit or 16-bit flash on CS1
30  * Micro9-Lite uses a seperate MTD map driver for flash support
31  * Micro9-Slim has up to 64MB of either 32-bit or 16-bit flash on CS1
32  *************************************************************************/
33 static struct physmap_flash_data micro9_flash_data;
34
35 static struct resource micro9_flash_resource = {
36         .start          = EP93XX_CS1_PHYS_BASE,
37         .end            = EP93XX_CS1_PHYS_BASE + SZ_64M - 1,
38         .flags          = IORESOURCE_MEM,
39 };
40
41 static struct platform_device micro9_flash = {
42         .name           = "physmap-flash",
43         .id             = 0,
44         .dev            = {
45                 .platform_data  = &micro9_flash_data,
46         },
47         .num_resources  = 1,
48         .resource       = &micro9_flash_resource,
49 };
50
51 static void __init __micro9_register_flash(unsigned int width)
52 {
53         micro9_flash_data.width = width;
54
55         platform_device_register(&micro9_flash);
56 }
57
58 static unsigned int __init micro9_detect_bootwidth(void)
59 {
60         u32 v;
61
62         /* Detect the bus width of the external flash memory */
63         v = __raw_readl(EP93XX_SYSCON_SYSCFG);
64         if (v & EP93XX_SYSCON_SYSCFG_LCSN7)
65                 return 4; /* 32-bit */
66         else
67                 return 2; /* 16-bit */
68 }
69
70 static void __init micro9_register_flash(void)
71 {
72         if (machine_is_micro9())
73                 __micro9_register_flash(4);
74         else if (machine_is_micro9m() || machine_is_micro9s())
75                 __micro9_register_flash(micro9_detect_bootwidth());
76 }
77
78
79 /*************************************************************************
80  * Micro9 Ethernet
81  *************************************************************************/
82 static struct ep93xx_eth_data micro9_eth_data = {
83         .phy_id         = 0x1f,
84 };
85
86
87 static void __init micro9_init_machine(void)
88 {
89         ep93xx_init_devices();
90         ep93xx_register_eth(&micro9_eth_data, 1);
91         micro9_register_flash();
92 }
93
94
95 #ifdef CONFIG_MACH_MICRO9H
96 MACHINE_START(MICRO9, "Contec Micro9-High")
97         /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
98         .phys_io        = EP93XX_APB_PHYS_BASE,
99         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
100         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
101         .map_io         = ep93xx_map_io,
102         .init_irq       = ep93xx_init_irq,
103         .timer          = &ep93xx_timer,
104         .init_machine   = micro9_init_machine,
105 MACHINE_END
106 #endif
107
108 #ifdef CONFIG_MACH_MICRO9M
109 MACHINE_START(MICRO9M, "Contec Micro9-Mid")
110         /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
111         .phys_io        = EP93XX_APB_PHYS_BASE,
112         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
113         .boot_params    = EP93XX_SDCE3_PHYS_BASE_ASYNC + 0x100,
114         .map_io         = ep93xx_map_io,
115         .init_irq       = ep93xx_init_irq,
116         .timer          = &ep93xx_timer,
117         .init_machine   = micro9_init_machine,
118 MACHINE_END
119 #endif
120
121 #ifdef CONFIG_MACH_MICRO9L
122 MACHINE_START(MICRO9L, "Contec Micro9-Lite")
123         /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
124         .phys_io        = EP93XX_APB_PHYS_BASE,
125         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
126         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
127         .map_io         = ep93xx_map_io,
128         .init_irq       = ep93xx_init_irq,
129         .timer          = &ep93xx_timer,
130         .init_machine   = micro9_init_machine,
131 MACHINE_END
132 #endif
133
134 #ifdef CONFIG_MACH_MICRO9S
135 MACHINE_START(MICRO9S, "Contec Micro9-Slim")
136         /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
137         .phys_io        = EP93XX_APB_PHYS_BASE,
138         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
139         .boot_params    = EP93XX_SDCE3_PHYS_BASE_ASYNC + 0x100,
140         .map_io         = ep93xx_map_io,
141         .init_irq       = ep93xx_init_irq,
142         .timer          = &ep93xx_timer,
143         .init_machine   = micro9_init_machine,
144 MACHINE_END
145 #endif