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 | |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/mtd/physmap.h> |
| 22 | #include <asm/mach/arch.h> |
| 23 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/common.h> |
| 25 | #include <mach/hardware.h> |
| 26 | #include <mach/iomux-mx1-mx2.h> |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 27 | #include <asm/mach/time.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/imx-uart.h> |
| 29 | #include <mach/board-pcm038.h> |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 30 | |
Sascha Hauer | 7e90534 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 31 | #include "devices.h" |
| 32 | |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 33 | /* |
| 34 | * Phytec's phyCORE-i.MX27 comes with 32MiB flash, |
| 35 | * 16 bit width |
| 36 | */ |
| 37 | static struct physmap_flash_data pcm038_flash_data = { |
| 38 | .width = 2, |
| 39 | }; |
| 40 | |
| 41 | static struct resource pcm038_flash_resource = { |
| 42 | .start = 0xc0000000, |
| 43 | .end = 0xc1ffffff, |
| 44 | .flags = IORESOURCE_MEM, |
| 45 | }; |
| 46 | |
| 47 | static struct platform_device pcm038_nor_mtd_device = { |
| 48 | .name = "physmap-flash", |
| 49 | .id = 0, |
| 50 | .dev = { |
| 51 | .platform_data = &pcm038_flash_data, |
| 52 | }, |
| 53 | .num_resources = 1, |
| 54 | .resource = &pcm038_flash_resource, |
| 55 | }; |
| 56 | |
| 57 | static int mxc_uart0_pins[] = { |
| 58 | PE12_PF_UART1_TXD, |
| 59 | PE13_PF_UART1_RXD, |
| 60 | PE14_PF_UART1_CTS, |
| 61 | PE15_PF_UART1_RTS |
| 62 | }; |
| 63 | |
| 64 | static int uart_mxc_port0_init(struct platform_device *pdev) |
| 65 | { |
| 66 | return mxc_gpio_setup_multiple_pins(mxc_uart0_pins, |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 67 | ARRAY_SIZE(mxc_uart0_pins), "UART0"); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static int uart_mxc_port0_exit(struct platform_device *pdev) |
| 71 | { |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 72 | mxc_gpio_release_multiple_pins(mxc_uart0_pins, |
| 73 | ARRAY_SIZE(mxc_uart0_pins)); |
| 74 | return 0; |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | static int mxc_uart1_pins[] = { |
| 78 | PE3_PF_UART2_CTS, |
| 79 | PE4_PF_UART2_RTS, |
| 80 | PE6_PF_UART2_TXD, |
| 81 | PE7_PF_UART2_RXD |
| 82 | }; |
| 83 | |
| 84 | static int uart_mxc_port1_init(struct platform_device *pdev) |
| 85 | { |
| 86 | return mxc_gpio_setup_multiple_pins(mxc_uart1_pins, |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 87 | ARRAY_SIZE(mxc_uart1_pins), "UART1"); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | static int uart_mxc_port1_exit(struct platform_device *pdev) |
| 91 | { |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 92 | mxc_gpio_release_multiple_pins(mxc_uart1_pins, |
| 93 | ARRAY_SIZE(mxc_uart1_pins)); |
| 94 | return 0; |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static int mxc_uart2_pins[] = { PE10_PF_UART3_CTS, |
| 98 | PE9_PF_UART3_RXD, |
| 99 | PE10_PF_UART3_CTS, |
| 100 | PE9_PF_UART3_RXD }; |
| 101 | |
| 102 | static int uart_mxc_port2_init(struct platform_device *pdev) |
| 103 | { |
| 104 | return mxc_gpio_setup_multiple_pins(mxc_uart2_pins, |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 105 | ARRAY_SIZE(mxc_uart2_pins), "UART2"); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static int uart_mxc_port2_exit(struct platform_device *pdev) |
| 109 | { |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 110 | mxc_gpio_release_multiple_pins(mxc_uart2_pins, |
| 111 | ARRAY_SIZE(mxc_uart2_pins)); |
| 112 | return 0; |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static struct imxuart_platform_data uart_pdata[] = { |
| 116 | { |
| 117 | .init = uart_mxc_port0_init, |
| 118 | .exit = uart_mxc_port0_exit, |
| 119 | .flags = IMXUART_HAVE_RTSCTS, |
| 120 | }, { |
| 121 | .init = uart_mxc_port1_init, |
| 122 | .exit = uart_mxc_port1_exit, |
| 123 | .flags = IMXUART_HAVE_RTSCTS, |
| 124 | }, { |
| 125 | .init = uart_mxc_port2_init, |
| 126 | .exit = uart_mxc_port2_exit, |
| 127 | .flags = IMXUART_HAVE_RTSCTS, |
| 128 | }, |
| 129 | }; |
| 130 | |
| 131 | static int mxc_fec_pins[] = { |
| 132 | PD0_AIN_FEC_TXD0, |
| 133 | PD1_AIN_FEC_TXD1, |
| 134 | PD2_AIN_FEC_TXD2, |
| 135 | PD3_AIN_FEC_TXD3, |
| 136 | PD4_AOUT_FEC_RX_ER, |
| 137 | PD5_AOUT_FEC_RXD1, |
| 138 | PD6_AOUT_FEC_RXD2, |
| 139 | PD7_AOUT_FEC_RXD3, |
| 140 | PD8_AF_FEC_MDIO, |
| 141 | PD9_AIN_FEC_MDC, |
| 142 | PD10_AOUT_FEC_CRS, |
| 143 | PD11_AOUT_FEC_TX_CLK, |
| 144 | PD12_AOUT_FEC_RXD0, |
| 145 | PD13_AOUT_FEC_RX_DV, |
| 146 | PD14_AOUT_FEC_CLR, |
| 147 | PD15_AOUT_FEC_COL, |
| 148 | PD16_AIN_FEC_TX_ER, |
| 149 | PF23_AIN_FEC_TX_EN |
| 150 | }; |
| 151 | |
| 152 | static void gpio_fec_active(void) |
| 153 | { |
| 154 | mxc_gpio_setup_multiple_pins(mxc_fec_pins, |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 155 | ARRAY_SIZE(mxc_fec_pins), "FEC"); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static void gpio_fec_inactive(void) |
| 159 | { |
Sascha Hauer | 7bd1822 | 2008-11-04 16:48:46 +0100 | [diff] [blame] | 160 | mxc_gpio_release_multiple_pins(mxc_fec_pins, |
| 161 | ARRAY_SIZE(mxc_fec_pins)); |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | static struct platform_device *platform_devices[] __initdata = { |
| 165 | &pcm038_nor_mtd_device, |
Sascha Hauer | d40a099 | 2008-12-01 14:15:40 -0800 | [diff] [blame] | 166 | &mxc_w1_master_device, |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | static void __init pcm038_init(void) |
| 170 | { |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 171 | gpio_fec_active(); |
| 172 | |
Sascha Hauer | 7e90534 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 173 | mxc_register_device(&mxc_uart_device0, &uart_pdata[0]); |
| 174 | mxc_register_device(&mxc_uart_device1, &uart_pdata[1]); |
| 175 | mxc_register_device(&mxc_uart_device2, &uart_pdata[2]); |
Sascha Hauer | d40a099 | 2008-12-01 14:15:40 -0800 | [diff] [blame] | 176 | mxc_gpio_mode(PE16_AF_RTCK); /* OWIRE */ |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 177 | |
| 178 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
Juergen Beisert | ff6552e | 2008-07-05 10:03:01 +0200 | [diff] [blame] | 179 | |
| 180 | #ifdef CONFIG_MACH_PCM970_BASEBOARD |
| 181 | pcm970_baseboard_init(); |
| 182 | #endif |
Juergen Beisert | 7e5e9f5 | 2008-07-05 10:03:00 +0200 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | static void __init pcm038_timer_init(void) |
| 186 | { |
| 187 | mxc_clocks_init(26000000); |
| 188 | mxc_timer_init("gpt_clk.0"); |
| 189 | } |
| 190 | |
| 191 | struct sys_timer pcm038_timer = { |
| 192 | .init = pcm038_timer_init, |
| 193 | }; |
| 194 | |
| 195 | MACHINE_START(PCM038, "phyCORE-i.MX27") |
| 196 | .phys_io = AIPI_BASE_ADDR, |
| 197 | .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
| 198 | .boot_params = PHYS_OFFSET + 0x100, |
| 199 | .map_io = mxc_map_io, |
| 200 | .init_irq = mxc_init_irq, |
| 201 | .init_machine = pcm038_init, |
| 202 | .timer = &pcm038_timer, |
| 203 | MACHINE_END |