Paulius Zaleckas | cfca8b5 | 2008-11-14 11:01:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-imx/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/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/mtd/physmap.h> |
Sascha Hauer | b8b19b0 | 2009-01-28 14:06:20 +0100 | [diff] [blame^] | 19 | #include <linux/i2c.h> |
| 20 | #include <linux/i2c/pcf857x.h> |
Paulius Zaleckas | cfca8b5 | 2008-11-14 11:01:38 +0100 | [diff] [blame] | 21 | |
| 22 | #include <asm/mach-types.h> |
| 23 | #include <asm/mach/arch.h> |
| 24 | #include <asm/mach/time.h> |
| 25 | |
| 26 | #include <mach/hardware.h> |
| 27 | #include <mach/common.h> |
| 28 | #include <mach/imx-uart.h> |
Sascha Hauer | b8b19b0 | 2009-01-28 14:06:20 +0100 | [diff] [blame^] | 29 | #include <mach/irqs.h> |
| 30 | #ifdef CONFIG_I2C_IMX |
| 31 | #include <mach/i2c.h> |
| 32 | #endif |
Holger Schurig | ccfe30a | 2009-01-29 10:07:50 +0100 | [diff] [blame] | 33 | #include <mach/iomux.h> |
Paulius Zaleckas | cfca8b5 | 2008-11-14 11:01:38 +0100 | [diff] [blame] | 34 | #include "devices.h" |
| 35 | |
| 36 | /* |
| 37 | * UARTs platform data |
| 38 | */ |
| 39 | static int mxc_uart1_pins[] = { |
| 40 | PC9_PF_UART1_CTS, |
| 41 | PC10_PF_UART1_RTS, |
| 42 | PC11_PF_UART1_TXD, |
| 43 | PC12_PF_UART1_RXD, |
| 44 | }; |
| 45 | |
| 46 | static int uart1_mxc_init(struct platform_device *pdev) |
| 47 | { |
| 48 | return mxc_gpio_setup_multiple_pins(mxc_uart1_pins, |
| 49 | ARRAY_SIZE(mxc_uart1_pins), "UART1"); |
| 50 | } |
| 51 | |
| 52 | static int uart1_mxc_exit(struct platform_device *pdev) |
| 53 | { |
| 54 | mxc_gpio_release_multiple_pins(mxc_uart1_pins, |
| 55 | ARRAY_SIZE(mxc_uart1_pins)); |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static int mxc_uart2_pins[] = { |
| 60 | PB28_PF_UART2_CTS, |
| 61 | PB29_PF_UART2_RTS, |
| 62 | PB30_PF_UART2_TXD, |
| 63 | PB31_PF_UART2_RXD, |
| 64 | }; |
| 65 | |
| 66 | static int uart2_mxc_init(struct platform_device *pdev) |
| 67 | { |
| 68 | return mxc_gpio_setup_multiple_pins(mxc_uart2_pins, |
| 69 | ARRAY_SIZE(mxc_uart2_pins), "UART2"); |
| 70 | } |
| 71 | |
| 72 | static int uart2_mxc_exit(struct platform_device *pdev) |
| 73 | { |
| 74 | mxc_gpio_release_multiple_pins(mxc_uart2_pins, |
| 75 | ARRAY_SIZE(mxc_uart2_pins)); |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static struct imxuart_platform_data uart_pdata[] = { |
| 80 | { |
| 81 | .init = uart1_mxc_init, |
| 82 | .exit = uart1_mxc_exit, |
| 83 | .flags = IMXUART_HAVE_RTSCTS, |
| 84 | }, { |
| 85 | .init = uart2_mxc_init, |
| 86 | .exit = uart2_mxc_exit, |
| 87 | .flags = IMXUART_HAVE_RTSCTS, |
| 88 | }, |
| 89 | }; |
| 90 | |
| 91 | /* |
| 92 | * Physmap flash |
| 93 | */ |
| 94 | |
| 95 | static struct physmap_flash_data mx1ads_flash_data = { |
| 96 | .width = 4, /* bankwidth in bytes */ |
| 97 | }; |
| 98 | |
| 99 | static struct resource flash_resource = { |
| 100 | .start = IMX_CS0_PHYS, |
| 101 | .end = IMX_CS0_PHYS + SZ_32M - 1, |
| 102 | .flags = IORESOURCE_MEM, |
| 103 | }; |
| 104 | |
| 105 | static struct platform_device flash_device = { |
| 106 | .name = "physmap-flash", |
| 107 | .id = 0, |
| 108 | .resource = &flash_resource, |
| 109 | .num_resources = 1, |
| 110 | }; |
| 111 | |
| 112 | /* |
Sascha Hauer | b8b19b0 | 2009-01-28 14:06:20 +0100 | [diff] [blame^] | 113 | * I2C |
| 114 | */ |
| 115 | |
| 116 | #ifdef CONFIG_I2C_IMX |
| 117 | static int i2c_pins[] = { |
| 118 | PA15_PF_I2C_SDA, |
| 119 | PA16_PF_I2C_SCL, |
| 120 | }; |
| 121 | |
| 122 | static int i2c_init(struct device *dev) |
| 123 | { |
| 124 | return mxc_gpio_setup_multiple_pins(i2c_pins, |
| 125 | ARRAY_SIZE(i2c_pins), "I2C"); |
| 126 | } |
| 127 | |
| 128 | static void i2c_exit(struct device *dev) |
| 129 | { |
| 130 | mxc_gpio_release_multiple_pins(i2c_pins, |
| 131 | ARRAY_SIZE(i2c_pins)); |
| 132 | } |
| 133 | |
| 134 | static struct pcf857x_platform_data pcf857x_data[] = { |
| 135 | { |
| 136 | .gpio_base = 4 * 32, |
| 137 | }, { |
| 138 | .gpio_base = 4 * 32 + 16, |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | static struct imxi2c_platform_data mx1ads_i2c_data = { |
| 143 | .bitrate = 100000, |
| 144 | .init = i2c_init, |
| 145 | .exit = i2c_exit, |
| 146 | }; |
| 147 | |
| 148 | static struct i2c_board_info mx1ads_i2c_devices[] = { |
| 149 | { |
| 150 | I2C_BOARD_INFO("pcf857x", 0x22), |
| 151 | .type = "pcf8575", |
| 152 | .platform_data = &pcf857x_data[0], |
| 153 | }, { |
| 154 | I2C_BOARD_INFO("pcf857x", 0x24), |
| 155 | .type = "pcf8575", |
| 156 | .platform_data = &pcf857x_data[1], |
| 157 | }, |
| 158 | }; |
| 159 | #endif |
| 160 | |
| 161 | /* |
Paulius Zaleckas | cfca8b5 | 2008-11-14 11:01:38 +0100 | [diff] [blame] | 162 | * Board init |
| 163 | */ |
| 164 | static void __init mx1ads_init(void) |
| 165 | { |
| 166 | /* UART */ |
| 167 | mxc_register_device(&imx_uart1_device, &uart_pdata[0]); |
| 168 | mxc_register_device(&imx_uart2_device, &uart_pdata[1]); |
| 169 | |
| 170 | /* Physmap flash */ |
| 171 | mxc_register_device(&flash_device, &mx1ads_flash_data); |
Sascha Hauer | b8b19b0 | 2009-01-28 14:06:20 +0100 | [diff] [blame^] | 172 | |
| 173 | /* I2C */ |
| 174 | #ifdef CONFIG_I2C_IMX |
| 175 | i2c_register_board_info(0, mx1ads_i2c_devices, |
| 176 | ARRAY_SIZE(mx1ads_i2c_devices)); |
| 177 | |
| 178 | mxc_register_device(&imx_i2c_device, &mx1ads_i2c_data); |
| 179 | #endif |
Paulius Zaleckas | cfca8b5 | 2008-11-14 11:01:38 +0100 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | static void __init mx1ads_timer_init(void) |
| 183 | { |
Sascha Hauer | 30c730f | 2009-02-16 14:36:49 +0100 | [diff] [blame] | 184 | mx1_clocks_init(32000); |
Paulius Zaleckas | cfca8b5 | 2008-11-14 11:01:38 +0100 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | struct sys_timer mx1ads_timer = { |
| 188 | .init = mx1ads_timer_init, |
| 189 | }; |
| 190 | |
| 191 | MACHINE_START(MX1ADS, "Freescale MX1ADS") |
| 192 | /* Maintainer: Sascha Hauer, Pengutronix */ |
| 193 | .phys_io = IMX_IO_PHYS, |
| 194 | .io_pg_offst = (IMX_IO_BASE >> 18) & 0xfffc, |
| 195 | .boot_params = PHYS_OFFSET + 0x100, |
| 196 | .map_io = mxc_map_io, |
| 197 | .init_irq = mxc_init_irq, |
| 198 | .timer = &mx1ads_timer, |
| 199 | .init_machine = mx1ads_init, |
| 200 | MACHINE_END |
| 201 | |
| 202 | MACHINE_START(MXLADS, "Freescale MXLADS") |
| 203 | .phys_io = IMX_IO_PHYS, |
| 204 | .io_pg_offst = (IMX_IO_BASE >> 18) & 0xfffc, |
| 205 | .boot_params = PHYS_OFFSET + 0x100, |
| 206 | .map_io = mxc_map_io, |
| 207 | .init_irq = mxc_init_irq, |
| 208 | .timer = &mx1ads_timer, |
| 209 | .init_machine = mx1ads_init, |
| 210 | MACHINE_END |