ARM: imx: move iomux drivers and headers into mach-imx
[linux-3.10.git] / arch / arm / mach-imx / mach-apf9328.c
1 /*
2  * linux/arch/arm/mach-imx/mach-apf9328.c
3  *
4  * Copyright (c) 2005-2011 ARMadeus systems <support@armadeus.com>
5  *
6  * This work is based on mach-scb9328.c which is:
7  * Copyright (c) 2004 Sascha Hauer <saschahauer@web.de>
8  * Copyright (c) 2006-2008 Juergen Beisert <jbeisert@netscape.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  */
15
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/platform_device.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/dm9000.h>
21 #include <linux/gpio.h>
22 #include <linux/i2c.h>
23
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/time.h>
27
28 #include <mach/common.h>
29 #include <mach/hardware.h>
30
31 #include "devices-imx1.h"
32 #include "iomux-mx1.h"
33
34 static const int apf9328_pins[] __initconst = {
35         /* UART1 */
36         PC9_PF_UART1_CTS,
37         PC10_PF_UART1_RTS,
38         PC11_PF_UART1_TXD,
39         PC12_PF_UART1_RXD,
40         /* UART2 */
41         PB28_PF_UART2_CTS,
42         PB29_PF_UART2_RTS,
43         PB30_PF_UART2_TXD,
44         PB31_PF_UART2_RXD,
45         /* I2C */
46         PA15_PF_I2C_SDA,
47         PA16_PF_I2C_SCL,
48 };
49
50 /*
51  * The APF9328 can have up to 32MB NOR Flash
52  */
53 static struct resource flash_resource = {
54         .start  = MX1_CS0_PHYS,
55         .end    = MX1_CS0_PHYS + SZ_32M - 1,
56         .flags  = IORESOURCE_MEM,
57 };
58
59 static struct physmap_flash_data apf9328_flash_data = {
60         .width  = 2,
61 };
62
63 static struct platform_device apf9328_flash_device = {
64         .name           = "physmap-flash",
65         .id             = 0,
66         .dev = {
67                 .platform_data = &apf9328_flash_data,
68         },
69         .resource = &flash_resource,
70         .num_resources = 1,
71 };
72
73 /*
74  * APF9328 has a DM9000 Ethernet controller
75  */
76 static struct dm9000_plat_data dm9000_setup = {
77         .flags          = DM9000_PLATF_16BITONLY
78 };
79
80 static struct resource dm9000_resources[] = {
81         {
82                 .start  = MX1_CS4_PHYS + 0x00C00000,
83                 .end    = MX1_CS4_PHYS + 0x00C00001,
84                 .flags  = IORESOURCE_MEM,
85         }, {
86                 .start  = MX1_CS4_PHYS + 0x00C00002,
87                 .end    = MX1_CS4_PHYS + 0x00C00003,
88                 .flags  = IORESOURCE_MEM,
89         }, {
90                 /* irq number is run-time assigned */
91                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
92         },
93 };
94
95 static struct platform_device dm9000x_device = {
96         .name           = "dm9000",
97         .id             = 0,
98         .num_resources  = ARRAY_SIZE(dm9000_resources),
99         .resource       = dm9000_resources,
100         .dev            = {
101                 .platform_data = &dm9000_setup,
102         }
103 };
104
105 static const struct imxuart_platform_data uart1_pdata __initconst = {
106         .flags = IMXUART_HAVE_RTSCTS,
107 };
108
109 static const struct imxi2c_platform_data apf9328_i2c_data __initconst = {
110         .bitrate = 100000,
111 };
112
113 static struct platform_device *devices[] __initdata = {
114         &apf9328_flash_device,
115         &dm9000x_device,
116 };
117
118 static void __init apf9328_init(void)
119 {
120         imx1_soc_init();
121
122         mxc_gpio_setup_multiple_pins(apf9328_pins,
123                         ARRAY_SIZE(apf9328_pins),
124                         "APF9328");
125
126         imx1_add_imx_uart0(NULL);
127         imx1_add_imx_uart1(&uart1_pdata);
128
129         imx1_add_imx_i2c(&apf9328_i2c_data);
130
131         dm9000_resources[2].start = gpio_to_irq(IMX_GPIO_NR(2, 14));
132         dm9000_resources[2].end = gpio_to_irq(IMX_GPIO_NR(2, 14));
133         platform_add_devices(devices, ARRAY_SIZE(devices));
134 }
135
136 static void __init apf9328_timer_init(void)
137 {
138         mx1_clocks_init(32768);
139 }
140
141 static struct sys_timer apf9328_timer = {
142         .init   = apf9328_timer_init,
143 };
144
145 MACHINE_START(APF9328, "Armadeus APF9328")
146         /* Maintainer: Gwenhael Goavec-Merou, ARMadeus Systems */
147         .map_io       = mx1_map_io,
148         .init_early   = imx1_init_early,
149         .init_irq     = mx1_init_irq,
150         .handle_irq   = imx1_handle_irq,
151         .timer        = &apf9328_timer,
152         .init_machine = apf9328_init,
153         .restart        = mxc_restart,
154 MACHINE_END