2 * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
3 * Copyright (C) 2009 Sascha Hauer (kernel@pengutronix.de)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 #include <linux/platform_device.h>
22 #include <linux/i2c.h>
23 #include <linux/i2c/at24.h>
24 #include <linux/dma-mapping.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/eeprom.h>
27 #include <linux/irq.h>
28 #include <linux/gpio.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach-types.h>
32 #include <mach/common.h>
33 #include <mach/hardware.h>
34 #include <mach/iomux.h>
36 #include <asm/mach/time.h>
37 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
40 #include <mach/imx-uart.h>
41 #include <mach/mxc_nand.h>
42 #include <mach/irqs.h>
47 static int pca100_pins[] = {
97 static struct imxuart_platform_data uart_pdata = {
98 .flags = IMXUART_HAVE_RTSCTS,
101 static struct mxc_nand_platform_data pca100_nand_board_info = {
106 static struct platform_device *platform_devices[] __initdata = {
107 &mxc_w1_master_device,
111 static struct imxi2c_platform_data pca100_i2c_1_data = {
115 static struct at24_platform_data board_eeprom = {
118 .flags = AT24_FLAG_ADDR16,
121 static struct i2c_board_info pca100_i2c_devices[] = {
123 I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
124 .platform_data = &board_eeprom,
126 I2C_BOARD_INFO("rtc-pcf8563", 0x51),
129 I2C_BOARD_INFO("lm75", 0x4a),
134 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
135 static struct spi_eeprom at25320 = {
142 static struct spi_board_info pca100_spi_board_info[] __initdata = {
145 .max_speed_hz = 30000,
148 .platform_data = &at25320,
152 static int pca100_spi_cs[] = {GPIO_PORTD + 28, GPIO_PORTD + 27};
154 static struct spi_imx_master pca100_spi_0_data = {
155 .chipselect = pca100_spi_cs,
156 .num_chipselect = ARRAY_SIZE(pca100_spi_cs),
160 static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
165 ret = request_irq(IRQ_GPIOC(29), detect_irq,
166 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
167 "imx-mmc-detect", data);
170 "pca100: Failed to reuest irq for sd/mmc detection\n");
175 static void pca100_sdhc2_exit(struct device *dev, void *data)
177 free_irq(IRQ_GPIOC(29), data);
180 static struct imxmmc_platform_data sdhc_pdata = {
181 .init = pca100_sdhc2_init,
182 .exit = pca100_sdhc2_exit,
185 static void __init pca100_init(void)
189 ret = mxc_gpio_setup_multiple_pins(pca100_pins,
190 ARRAY_SIZE(pca100_pins), "PCA100");
192 printk(KERN_ERR "pca100: Failed to setup pins (%d)\n", ret);
194 mxc_register_device(&mxc_uart_device0, &uart_pdata);
196 mxc_gpio_mode(GPIO_PORTC | 29 | GPIO_GPIO | GPIO_IN);
197 mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata);
199 mxc_register_device(&mxc_nand_device, &pca100_nand_board_info);
201 /* only the i2c master 1 is used on this CPU card */
202 i2c_register_board_info(1, pca100_i2c_devices,
203 ARRAY_SIZE(pca100_i2c_devices));
205 mxc_register_device(&mxc_i2c_device1, &pca100_i2c_1_data);
207 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
208 mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_OUT);
211 mxc_gpio_mode(GPIO_PORTC | 31 | GPIO_GPIO | GPIO_IN);
213 mxc_gpio_mode(GPIO_PORTC | 25 | GPIO_GPIO | GPIO_IN);
215 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_IN);
217 #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
218 spi_register_board_info(pca100_spi_board_info,
219 ARRAY_SIZE(pca100_spi_board_info));
220 mxc_register_device(&mxc_spi_device0, &pca100_spi_0_data);
223 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
226 static void __init pca100_timer_init(void)
228 mx27_clocks_init(26000000);
231 static struct sys_timer pca100_timer = {
232 .init = pca100_timer_init,
235 MACHINE_START(PCA100, "phyCARD-i.MX27")
236 .phys_io = AIPI_BASE_ADDR,
237 .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
238 .boot_params = PHYS_OFFSET + 0x100,
239 .map_io = mx27_map_io,
240 .init_irq = mx27_init_irq,
241 .init_machine = pca100_init,
242 .timer = &pca100_timer,