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