]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/arm/mach-imx/mach-mx1ads.c
ARM: imx: dynamically register imx-i2c devices (imx1)
[net-next-2.6.git] / arch / arm / mach-imx / mach-mx1ads.c
1 /*
2  * arch/arm/mach-imx/mach-mx1ads.c
3  *
4  * Initially based on:
5  *      linux-2.6.7-imx/arch/arm/mach-imx/scb9328.c
6  *      Copyright (c) 2004 Sascha Hauer <sascha@saschahauer.de>
7  *
8  * 2004 (c) MontaVista Software, Inc.
9  *
10  * This file is licensed under the terms of the GNU General Public
11  * License version 2. This program is licensed "as is" without any
12  * warranty of any kind, whether express or implied.
13  */
14
15 #include <linux/i2c.h>
16 #include <linux/i2c/pcf857x.h>
17 #include <linux/init.h>
18 #include <linux/kernel.h>
19 #include <linux/platform_device.h>
20 #include <linux/mtd/physmap.h>
21
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/time.h>
25
26 #include <mach/common.h>
27 #include <mach/hardware.h>
28 #include <mach/i2c.h>
29 #include <mach/imx-uart.h>
30 #include <mach/iomux-mx1.h>
31 #include <mach/irqs.h>
32
33 #include "devices-imx1.h"
34 #include "devices.h"
35
36 static int mx1ads_pins[] = {
37         /* UART1 */
38         PC9_PF_UART1_CTS,
39         PC10_PF_UART1_RTS,
40         PC11_PF_UART1_TXD,
41         PC12_PF_UART1_RXD,
42         /* UART2 */
43         PB28_PF_UART2_CTS,
44         PB29_PF_UART2_RTS,
45         PB30_PF_UART2_TXD,
46         PB31_PF_UART2_RXD,
47         /* I2C */
48         PA15_PF_I2C_SDA,
49         PA16_PF_I2C_SCL,
50         /* SPI */
51         PC13_PF_SPI1_SPI_RDY,
52         PC14_PF_SPI1_SCLK,
53         PC15_PF_SPI1_SS,
54         PC16_PF_SPI1_MISO,
55         PC17_PF_SPI1_MOSI,
56 };
57
58 /*
59  * UARTs platform data
60  */
61
62 static struct imxuart_platform_data uart_pdata[] = {
63         {
64                 .flags = IMXUART_HAVE_RTSCTS,
65         }, {
66                 .flags = IMXUART_HAVE_RTSCTS,
67         },
68 };
69
70 /*
71  * Physmap flash
72  */
73
74 static struct physmap_flash_data mx1ads_flash_data = {
75         .width          = 4,            /* bankwidth in bytes */
76 };
77
78 static struct resource flash_resource = {
79         .start  = MX1_CS0_PHYS,
80         .end    = MX1_CS0_PHYS + SZ_32M - 1,
81         .flags  = IORESOURCE_MEM,
82 };
83
84 static struct platform_device flash_device = {
85         .name   = "physmap-flash",
86         .id     = 0,
87         .resource = &flash_resource,
88         .num_resources = 1,
89 };
90
91 /*
92  * I2C
93  */
94 static struct pcf857x_platform_data pcf857x_data[] = {
95         {
96                 .gpio_base = 4 * 32,
97         }, {
98                 .gpio_base = 4 * 32 + 16,
99         }
100 };
101
102 static const struct imxi2c_platform_data mx1ads_i2c_data __initconst = {
103         .bitrate = 100000,
104 };
105
106 static struct i2c_board_info mx1ads_i2c_devices[] = {
107         {
108                 I2C_BOARD_INFO("pcf8575", 0x22),
109                 .platform_data = &pcf857x_data[0],
110         }, {
111                 I2C_BOARD_INFO("pcf8575", 0x24),
112                 .platform_data = &pcf857x_data[1],
113         },
114 };
115
116 /*
117  * Board init
118  */
119 static void __init mx1ads_init(void)
120 {
121         mxc_gpio_setup_multiple_pins(mx1ads_pins,
122                 ARRAY_SIZE(mx1ads_pins), "mx1ads");
123
124         /* UART */
125         mxc_register_device(&imx1_uart_device0, &uart_pdata[0]);
126         mxc_register_device(&imx1_uart_device1, &uart_pdata[1]);
127
128         /* Physmap flash */
129         mxc_register_device(&flash_device, &mx1ads_flash_data);
130
131         /* I2C */
132         i2c_register_board_info(0, mx1ads_i2c_devices,
133                                 ARRAY_SIZE(mx1ads_i2c_devices));
134
135         imx1_add_i2c_imx(&mx1ads_i2c_data);
136 }
137
138 static void __init mx1ads_timer_init(void)
139 {
140         mx1_clocks_init(32000);
141 }
142
143 struct sys_timer mx1ads_timer = {
144         .init   = mx1ads_timer_init,
145 };
146
147 MACHINE_START(MX1ADS, "Freescale MX1ADS")
148         /* Maintainer: Sascha Hauer, Pengutronix */
149         .phys_io        = MX1_IO_BASE_ADDR,
150         .io_pg_offst    = (MX1_IO_BASE_ADDR_VIRT >> 18) & 0xfffc,
151         .boot_params    = MX1_PHYS_OFFSET + 0x100,
152         .map_io         = mx1_map_io,
153         .init_irq       = mx1_init_irq,
154         .timer          = &mx1ads_timer,
155         .init_machine   = mx1ads_init,
156 MACHINE_END
157
158 MACHINE_START(MXLADS, "Freescale MXLADS")
159         .phys_io        = MX1_IO_BASE_ADDR,
160         .io_pg_offst    = (MX1_IO_BASE_ADDR_VIRT >> 18) & 0xfffc,
161         .boot_params    = MX1_PHYS_OFFSET + 0x100,
162         .map_io         = mx1_map_io,
163         .init_irq       = mx1_init_irq,
164         .timer          = &mx1ads_timer,
165         .init_machine   = mx1ads_init,
166 MACHINE_END