Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix |
| 3 | * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) |
| 4 | * |
| 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. |
| 13 | * |
| 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, |
| 17 | * MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 20 | #include <linux/i2c.h> |
| 21 | #include <linux/i2c/at24.h> |
Sascha Hauer | bff0b53 | 2009-04-29 09:17:03 +0200 | [diff] [blame] | 22 | #include <linux/io.h> |
| 23 | #include <linux/mtd/plat-ram.h> |
| 24 | #include <linux/mtd/physmap.h> |
| 25 | #include <linux/platform_device.h> |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 26 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 27 | #include <asm/mach-types.h> |
Sascha Hauer | bff0b53 | 2009-04-29 09:17:03 +0200 | [diff] [blame] | 28 | #include <asm/mach/arch.h> |
| 29 | #include <asm/mach/time.h> |
| 30 | |
| 31 | #include <mach/board-pcm038.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 32 | #include <mach/common.h> |
| 33 | #include <mach/hardware.h> |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 34 | #include <mach/i2c.h> |
Sascha Hauer | bff0b53 | 2009-04-29 09:17:03 +0200 | [diff] [blame] | 35 | #include <mach/iomux.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 36 | #include <mach/imx-uart.h> |
Sascha Hauer | 01f71a3 | 2008-09-09 11:30:58 +0200 | [diff] [blame] | 37 | #include <mach/mxc_nand.h> |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 38 | |
Sascha Hauer | 7e90534 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 39 | #include "devices.h" |
| 40 | |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 41 | static int pcm038_pins[] = { |
| 42 | /* UART1 */ |
| 43 | PE12_PF_UART1_TXD, |
| 44 | PE13_PF_UART1_RXD, |
| 45 | PE14_PF_UART1_CTS, |
| 46 | PE15_PF_UART1_RTS, |
| 47 | /* UART2 */ |
| 48 | PE3_PF_UART2_CTS, |
| 49 | PE4_PF_UART2_RTS, |
| 50 | PE6_PF_UART2_TXD, |
| 51 | PE7_PF_UART2_RXD, |
| 52 | /* UART3 */ |
| 53 | PE8_PF_UART3_TXD, |
| 54 | PE9_PF_UART3_RXD, |
| 55 | PE10_PF_UART3_CTS, |
| 56 | PE11_PF_UART3_RTS, |
| 57 | /* FEC */ |
| 58 | PD0_AIN_FEC_TXD0, |
| 59 | PD1_AIN_FEC_TXD1, |
| 60 | PD2_AIN_FEC_TXD2, |
| 61 | PD3_AIN_FEC_TXD3, |
| 62 | PD4_AOUT_FEC_RX_ER, |
| 63 | PD5_AOUT_FEC_RXD1, |
| 64 | PD6_AOUT_FEC_RXD2, |
| 65 | PD7_AOUT_FEC_RXD3, |
| 66 | PD8_AF_FEC_MDIO, |
| 67 | PD9_AIN_FEC_MDC, |
| 68 | PD10_AOUT_FEC_CRS, |
| 69 | PD11_AOUT_FEC_TX_CLK, |
| 70 | PD12_AOUT_FEC_RXD0, |
| 71 | PD13_AOUT_FEC_RX_DV, |
| 72 | PD14_AOUT_FEC_RX_CLK, |
| 73 | PD15_AOUT_FEC_COL, |
| 74 | PD16_AIN_FEC_TX_ER, |
| 75 | PF23_AIN_FEC_TX_EN, |
| 76 | /* I2C2 */ |
| 77 | PC5_PF_I2C2_SDA, |
| 78 | PC6_PF_I2C2_SCL, |
| 79 | /* SPI1 */ |
| 80 | PD25_PF_CSPI1_RDY, |
| 81 | PD27_PF_CSPI1_SS1, |
| 82 | PD28_PF_CSPI1_SS0, |
| 83 | PD29_PF_CSPI1_SCLK, |
| 84 | PD30_PF_CSPI1_MISO, |
| 85 | PD31_PF_CSPI1_MOSI, |
| 86 | /* SSI1 */ |
| 87 | PC20_PF_SSI1_FS, |
| 88 | PC21_PF_SSI1_RXD, |
| 89 | PC22_PF_SSI1_TXD, |
| 90 | PC23_PF_SSI1_CLK, |
| 91 | /* SSI4 */ |
| 92 | PC16_PF_SSI4_FS, |
| 93 | PC17_PF_SSI4_RXD, |
| 94 | PC18_PF_SSI4_TXD, |
| 95 | PC19_PF_SSI4_CLK, |
| 96 | }; |
| 97 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 98 | /* |
Sascha Hauer | 3620c0d | 2008-11-23 17:31:46 +0100 | [diff] [blame] | 99 | * Phytec's PCM038 comes with 2MiB battery buffered SRAM, |
| 100 | * 16 bit width |
| 101 | */ |
| 102 | |
| 103 | static struct platdata_mtd_ram pcm038_sram_data = { |
| 104 | .bankwidth = 2, |
| 105 | }; |
| 106 | |
| 107 | static struct resource pcm038_sram_resource = { |
| 108 | .start = CS1_BASE_ADDR, |
| 109 | .end = CS1_BASE_ADDR + 512 * 1024 - 1, |
| 110 | .flags = IORESOURCE_MEM, |
| 111 | }; |
| 112 | |
| 113 | static struct platform_device pcm038_sram_mtd_device = { |
| 114 | .name = "mtd-ram", |
| 115 | .id = 0, |
| 116 | .dev = { |
| 117 | .platform_data = &pcm038_sram_data, |
| 118 | }, |
| 119 | .num_resources = 1, |
| 120 | .resource = &pcm038_sram_resource, |
| 121 | }; |
| 122 | |
| 123 | /* |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 124 | * Phytec's phyCORE-i.MX27 comes with 32MiB flash, |
| 125 | * 16 bit width |
| 126 | */ |
| 127 | static struct physmap_flash_data pcm038_flash_data = { |
| 128 | .width = 2, |
| 129 | }; |
| 130 | |
| 131 | static struct resource pcm038_flash_resource = { |
| 132 | .start = 0xc0000000, |
| 133 | .end = 0xc1ffffff, |
| 134 | .flags = IORESOURCE_MEM, |
| 135 | }; |
| 136 | |
| 137 | static struct platform_device pcm038_nor_mtd_device = { |
| 138 | .name = "physmap-flash", |
| 139 | .id = 0, |
| 140 | .dev = { |
| 141 | .platform_data = &pcm038_flash_data, |
| 142 | }, |
| 143 | .num_resources = 1, |
| 144 | .resource = &pcm038_flash_resource, |
| 145 | }; |
| 146 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 147 | static struct imxuart_platform_data uart_pdata[] = { |
| 148 | { |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 149 | .flags = IMXUART_HAVE_RTSCTS, |
| 150 | }, { |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 151 | .flags = IMXUART_HAVE_RTSCTS, |
| 152 | }, { |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 153 | .flags = IMXUART_HAVE_RTSCTS, |
| 154 | }, |
| 155 | }; |
| 156 | |
Sascha Hauer | 01f71a3 | 2008-09-09 11:30:58 +0200 | [diff] [blame] | 157 | static struct mxc_nand_platform_data pcm038_nand_board_info = { |
| 158 | .width = 1, |
| 159 | .hw_ecc = 1, |
| 160 | }; |
| 161 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 162 | static struct platform_device *platform_devices[] __initdata = { |
| 163 | &pcm038_nor_mtd_device, |
Sascha Hauer | d40a099 | 2008-12-01 14:15:40 -0800 | [diff] [blame] | 164 | &mxc_w1_master_device, |
Sascha Hauer | 879fea1 | 2009-01-26 17:26:02 +0100 | [diff] [blame] | 165 | &mxc_fec_device, |
Sascha Hauer | 3620c0d | 2008-11-23 17:31:46 +0100 | [diff] [blame] | 166 | &pcm038_sram_mtd_device, |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 167 | }; |
| 168 | |
Sascha Hauer | 3620c0d | 2008-11-23 17:31:46 +0100 | [diff] [blame] | 169 | /* On pcm038 there's a sram attached to CS1, we enable the chipselect here and |
| 170 | * setup other stuffs to access the sram. */ |
| 171 | static void __init pcm038_init_sram(void) |
| 172 | { |
| 173 | __raw_writel(0x0000d843, CSCR_U(1)); |
| 174 | __raw_writel(0x22252521, CSCR_L(1)); |
| 175 | __raw_writel(0x22220a00, CSCR_A(1)); |
| 176 | } |
| 177 | |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 178 | static struct imxi2c_platform_data pcm038_i2c_1_data = { |
| 179 | .bitrate = 100000, |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | static struct at24_platform_data board_eeprom = { |
| 183 | .byte_len = 4096, |
| 184 | .page_size = 32, |
| 185 | .flags = AT24_FLAG_ADDR16, |
| 186 | }; |
| 187 | |
| 188 | static struct i2c_board_info pcm038_i2c_devices[] = { |
Sascha Hauer | cf87a6e | 2009-07-20 08:18:47 +0200 | [diff] [blame] | 189 | { |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 190 | I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ |
| 191 | .platform_data = &board_eeprom, |
Sascha Hauer | cf87a6e | 2009-07-20 08:18:47 +0200 | [diff] [blame] | 192 | }, { |
| 193 | I2C_BOARD_INFO("pcf8563", 0x51), |
| 194 | }, { |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 195 | I2C_BOARD_INFO("lm75", 0x4a), |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 196 | } |
| 197 | }; |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 198 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 199 | static void __init pcm038_init(void) |
| 200 | { |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 201 | mxc_gpio_setup_multiple_pins(pcm038_pins, ARRAY_SIZE(pcm038_pins), |
| 202 | "PCM038"); |
| 203 | |
Sascha Hauer | 3620c0d | 2008-11-23 17:31:46 +0100 | [diff] [blame] | 204 | pcm038_init_sram(); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 205 | |
Sascha Hauer | 7e90534 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 206 | mxc_register_device(&mxc_uart_device0, &uart_pdata[0]); |
| 207 | mxc_register_device(&mxc_uart_device1, &uart_pdata[1]); |
| 208 | mxc_register_device(&mxc_uart_device2, &uart_pdata[2]); |
Sascha Hauer | 01f71a3 | 2008-09-09 11:30:58 +0200 | [diff] [blame] | 209 | |
Holger Schurig | ccfe30a | 2009-01-29 10:07:50 +0100 | [diff] [blame] | 210 | mxc_gpio_mode(PE16_AF_OWIRE); |
Sascha Hauer | 01f71a3 | 2008-09-09 11:30:58 +0200 | [diff] [blame] | 211 | mxc_register_device(&mxc_nand_device, &pcm038_nand_board_info); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 212 | |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 213 | /* only the i2c master 1 is used on this CPU card */ |
| 214 | i2c_register_board_info(1, pcm038_i2c_devices, |
| 215 | ARRAY_SIZE(pcm038_i2c_devices)); |
| 216 | |
| 217 | mxc_register_device(&mxc_i2c_device1, &pcm038_i2c_1_data); |
Sascha Hauer | a4e9a65 | 2009-01-28 13:07:11 +0100 | [diff] [blame] | 218 | |
Luotao Fu | 0160651 | 2009-06-18 12:21:51 +0200 | [diff] [blame] | 219 | /* PE18 for user-LED D40 */ |
| 220 | mxc_gpio_mode(GPIO_PORTE | 18 | GPIO_GPIO | GPIO_OUT); |
| 221 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 222 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
Juergen Beisert | ff6552e | 2008-07-05 10:03:01 +0200 | [diff] [blame] | 223 | |
| 224 | #ifdef CONFIG_MACH_PCM970_BASEBOARD |
| 225 | pcm970_baseboard_init(); |
| 226 | #endif |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static void __init pcm038_timer_init(void) |
| 230 | { |
Sascha Hauer | 30c730f | 2009-02-16 14:36:49 +0100 | [diff] [blame] | 231 | mx27_clocks_init(26000000); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 232 | } |
| 233 | |
Holger Schurig | 058b7a6 | 2009-01-26 16:34:51 +0100 | [diff] [blame] | 234 | static struct sys_timer pcm038_timer = { |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 235 | .init = pcm038_timer_init, |
| 236 | }; |
| 237 | |
| 238 | MACHINE_START(PCM038, "phyCORE-i.MX27") |
| 239 | .phys_io = AIPI_BASE_ADDR, |
| 240 | .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
| 241 | .boot_params = PHYS_OFFSET + 0x100, |
Sascha Hauer | cd4a05f | 2009-04-02 22:32:10 +0200 | [diff] [blame] | 242 | .map_io = mx27_map_io, |
Sascha Hauer | c5aa0ad | 2009-05-25 17:36:19 +0200 | [diff] [blame] | 243 | .init_irq = mx27_init_irq, |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 244 | .init_machine = pcm038_init, |
| 245 | .timer = &pcm038_timer, |
| 246 | MACHINE_END |