Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 1 | /* |
| 2 | * KZM-ARM11-01 support |
| 3 | * Copyright (C) 2009 Yoichi Yuasa <yuasa@linux-mips.org> |
| 4 | * |
| 5 | * based on code for MX31ADS, |
| 6 | * Copyright (C) 2000 Deep Blue Solutions Ltd |
| 7 | * Copyright (C) 2002 Shane Nay (shane@minirl.com) |
| 8 | * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <linux/gpio.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/serial_8250.h> |
| 25 | #include <linux/smsc911x.h> |
| 26 | #include <linux/types.h> |
Fabio Estevam | ccdf327 | 2012-04-02 10:39:46 -0300 | [diff] [blame] | 27 | #include <linux/regulator/machine.h> |
| 28 | #include <linux/regulator/fixed.h> |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 29 | |
| 30 | #include <asm/irq.h> |
| 31 | #include <asm/mach-types.h> |
Russell King | f4117ac | 2011-01-04 18:07:14 +0000 | [diff] [blame] | 32 | #include <asm/memory.h> |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 33 | #include <asm/setup.h> |
| 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/irq.h> |
| 36 | #include <asm/mach/map.h> |
| 37 | #include <asm/mach/time.h> |
| 38 | |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 39 | #include "common.h" |
Uwe Kleine-König | 16cf5c4 | 2010-06-23 11:46:16 +0200 | [diff] [blame] | 40 | #include "devices-imx31.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 41 | #include "hardware.h" |
Shawn Guo | 267dd34 | 2012-09-13 13:26:00 +0800 | [diff] [blame] | 42 | #include "iomux-mx3.h" |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 43 | |
Uwe Kleine-König | f5d7a13 | 2010-10-25 11:40:30 +0200 | [diff] [blame] | 44 | #define KZM_ARM11_IO_ADDRESS(x) (IOMEM( \ |
| 45 | IMX_IO_P2V_MODULE(x, MX31_CS4) ?: \ |
| 46 | IMX_IO_P2V_MODULE(x, MX31_CS5)) ?: \ |
Uwe Kleine-König | 59e2608 | 2009-12-16 19:08:09 +0100 | [diff] [blame] | 47 | MX31_IO_ADDRESS(x)) |
| 48 | |
Uwe Kleine-König | 7b562d0 | 2010-03-08 11:58:53 +0100 | [diff] [blame] | 49 | /* |
| 50 | * KZM-ARM11-01 Board Control Registers on FPGA |
| 51 | */ |
| 52 | #define KZM_ARM11_CTL1 (MX31_CS4_BASE_ADDR + 0x1000) |
| 53 | #define KZM_ARM11_CTL2 (MX31_CS4_BASE_ADDR + 0x1001) |
| 54 | #define KZM_ARM11_RSW1 (MX31_CS4_BASE_ADDR + 0x1002) |
| 55 | #define KZM_ARM11_BACK_LIGHT (MX31_CS4_BASE_ADDR + 0x1004) |
| 56 | #define KZM_ARM11_FPGA_REV (MX31_CS4_BASE_ADDR + 0x1008) |
| 57 | #define KZM_ARM11_7SEG_LED (MX31_CS4_BASE_ADDR + 0x1010) |
| 58 | #define KZM_ARM11_LEDS (MX31_CS4_BASE_ADDR + 0x1020) |
| 59 | #define KZM_ARM11_DIPSW2 (MX31_CS4_BASE_ADDR + 0x1003) |
| 60 | |
| 61 | /* |
| 62 | * External UART for touch panel on FPGA |
| 63 | */ |
| 64 | #define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050) |
| 65 | |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 66 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) |
| 67 | /* |
| 68 | * KZM-ARM11-01 has an external UART on FPGA |
| 69 | */ |
| 70 | static struct plat_serial8250_port serial_platform_data[] = { |
| 71 | { |
Uwe Kleine-König | 59e2608 | 2009-12-16 19:08:09 +0100 | [diff] [blame] | 72 | .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550), |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 73 | .mapbase = KZM_ARM11_16550, |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 74 | /* irq number is run-time assigned */ |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 75 | .irqflags = IRQ_TYPE_EDGE_RISING, |
| 76 | .uartclk = 14745600, |
| 77 | .regshift = 0, |
| 78 | .iotype = UPIO_MEM, |
| 79 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | |
| 80 | UPF_BUGGY_UART, |
| 81 | }, |
| 82 | {}, |
| 83 | }; |
| 84 | |
| 85 | static struct resource serial8250_resources[] = { |
| 86 | { |
| 87 | .start = KZM_ARM11_16550, |
| 88 | .end = KZM_ARM11_16550 + 0x10, |
| 89 | .flags = IORESOURCE_MEM, |
| 90 | }, |
| 91 | { |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 92 | /* irq number is run-time assigned */ |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 93 | .flags = IORESOURCE_IRQ, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct platform_device serial_device = { |
| 98 | .name = "serial8250", |
| 99 | .id = PLAT8250_DEV_PLATFORM, |
| 100 | .dev = { |
| 101 | .platform_data = serial_platform_data, |
| 102 | }, |
| 103 | .num_resources = ARRAY_SIZE(serial8250_resources), |
| 104 | .resource = serial8250_resources, |
| 105 | }; |
| 106 | |
| 107 | static int __init kzm_init_ext_uart(void) |
| 108 | { |
| 109 | u8 tmp; |
| 110 | |
| 111 | /* |
| 112 | * GPIO 1-1: external UART interrupt line |
| 113 | */ |
| 114 | mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO)); |
| 115 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int"); |
| 116 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); |
| 117 | |
| 118 | /* |
| 119 | * Unmask UART interrupt |
| 120 | */ |
Uwe Kleine-König | 59e2608 | 2009-12-16 19:08:09 +0100 | [diff] [blame] | 121 | tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 122 | tmp |= 0x2; |
Uwe Kleine-König | 59e2608 | 2009-12-16 19:08:09 +0100 | [diff] [blame] | 123 | __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 124 | |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 125 | serial_platform_data[0].irq = |
| 126 | gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); |
| 127 | serial8250_resources[1].start = |
| 128 | gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); |
| 129 | serial8250_resources[1].end = |
| 130 | gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); |
| 131 | |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 132 | return platform_device_register(&serial_device); |
| 133 | } |
| 134 | #else |
| 135 | static inline int kzm_init_ext_uart(void) |
| 136 | { |
| 137 | return 0; |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | /* |
| 142 | * SMSC LAN9118 |
| 143 | */ |
| 144 | #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) |
| 145 | static struct smsc911x_platform_config kzm_smsc9118_config = { |
| 146 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 147 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, |
| 148 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 149 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 150 | }; |
| 151 | |
| 152 | static struct resource kzm_smsc9118_resources[] = { |
| 153 | { |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 154 | .start = MX31_CS5_BASE_ADDR, |
| 155 | .end = MX31_CS5_BASE_ADDR + SZ_128K - 1, |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 156 | .flags = IORESOURCE_MEM, |
| 157 | }, |
| 158 | { |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 159 | /* irq number is run-time assigned */ |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 160 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | static struct platform_device kzm_smsc9118_device = { |
| 165 | .name = "smsc911x", |
| 166 | .id = -1, |
| 167 | .num_resources = ARRAY_SIZE(kzm_smsc9118_resources), |
| 168 | .resource = kzm_smsc9118_resources, |
| 169 | .dev = { |
| 170 | .platform_data = &kzm_smsc9118_config, |
| 171 | }, |
| 172 | }; |
| 173 | |
Fabio Estevam | ccdf327 | 2012-04-02 10:39:46 -0300 | [diff] [blame] | 174 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 175 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 176 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 177 | }; |
| 178 | |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 179 | static int __init kzm_init_smsc9118(void) |
| 180 | { |
| 181 | /* |
| 182 | * GPIO 1-2: SMSC9118 interrupt line |
| 183 | */ |
| 184 | mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO)); |
| 185 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int"); |
| 186 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); |
| 187 | |
Fabio Estevam | ccdf327 | 2012-04-02 10:39:46 -0300 | [diff] [blame] | 188 | regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); |
| 189 | |
Shawn Guo | ed17534 | 2011-12-02 20:00:33 +0800 | [diff] [blame] | 190 | kzm_smsc9118_resources[1].start = |
| 191 | gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); |
| 192 | kzm_smsc9118_resources[1].end = |
| 193 | gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); |
| 194 | |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 195 | return platform_device_register(&kzm_smsc9118_device); |
| 196 | } |
| 197 | #else |
| 198 | static inline int kzm_init_smsc9118(void) |
| 199 | { |
| 200 | return 0; |
| 201 | } |
| 202 | #endif |
| 203 | |
| 204 | #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) |
Uwe Kleine-König | 16cf5c4 | 2010-06-23 11:46:16 +0200 | [diff] [blame] | 205 | static const struct imxuart_platform_data uart_pdata __initconst = { |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 206 | .flags = IMXUART_HAVE_RTSCTS, |
| 207 | }; |
| 208 | |
| 209 | static void __init kzm_init_imx_uart(void) |
| 210 | { |
Uwe Kleine-König | 16cf5c4 | 2010-06-23 11:46:16 +0200 | [diff] [blame] | 211 | imx31_add_imx_uart0(&uart_pdata); |
| 212 | imx31_add_imx_uart1(&uart_pdata); |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 213 | } |
| 214 | #else |
| 215 | static inline void kzm_init_imx_uart(void) |
| 216 | { |
| 217 | } |
| 218 | #endif |
| 219 | |
| 220 | static int kzm_pins[] __initdata = { |
| 221 | MX31_PIN_CTS1__CTS1, |
| 222 | MX31_PIN_RTS1__RTS1, |
| 223 | MX31_PIN_TXD1__TXD1, |
| 224 | MX31_PIN_RXD1__RXD1, |
| 225 | MX31_PIN_DCD_DCE1__DCD_DCE1, |
| 226 | MX31_PIN_RI_DCE1__RI_DCE1, |
| 227 | MX31_PIN_DSR_DCE1__DSR_DCE1, |
| 228 | MX31_PIN_DTR_DCE1__DTR_DCE1, |
| 229 | MX31_PIN_CTS2__CTS2, |
| 230 | MX31_PIN_RTS2__RTS2, |
| 231 | MX31_PIN_TXD2__TXD2, |
| 232 | MX31_PIN_RXD2__RXD2, |
| 233 | MX31_PIN_DCD_DTE1__DCD_DTE2, |
| 234 | MX31_PIN_RI_DTE1__RI_DTE2, |
| 235 | MX31_PIN_DSR_DTE1__DSR_DTE2, |
| 236 | MX31_PIN_DTR_DTE1__DTR_DTE2, |
| 237 | }; |
| 238 | |
| 239 | /* |
| 240 | * Board specific initialization. |
| 241 | */ |
| 242 | static void __init kzm_board_init(void) |
| 243 | { |
Shawn Guo | b78d8e5 | 2011-06-06 00:07:55 +0800 | [diff] [blame] | 244 | imx31_soc_init(); |
| 245 | |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 246 | mxc_iomux_setup_multiple_pins(kzm_pins, |
| 247 | ARRAY_SIZE(kzm_pins), "kzm"); |
| 248 | kzm_init_ext_uart(); |
| 249 | kzm_init_smsc9118(); |
| 250 | kzm_init_imx_uart(); |
| 251 | |
| 252 | pr_info("Clock input source is 26MHz\n"); |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * This structure defines static mappings for the kzm-arm11-01 board. |
| 257 | */ |
| 258 | static struct map_desc kzm_io_desc[] __initdata = { |
| 259 | { |
Arnd Bergmann | f25d696 | 2012-09-14 20:14:01 +0000 | [diff] [blame] | 260 | .virtual = (unsigned long)MX31_CS4_BASE_ADDR_VIRT, |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 261 | .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR), |
| 262 | .length = MX31_CS4_SIZE, |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 263 | .type = MT_DEVICE |
| 264 | }, |
| 265 | { |
Arnd Bergmann | f25d696 | 2012-09-14 20:14:01 +0000 | [diff] [blame] | 266 | .virtual = (unsigned long)MX31_CS5_BASE_ADDR_VIRT, |
Uwe Kleine-König | f568dd7 | 2009-12-09 11:57:21 +0100 | [diff] [blame] | 267 | .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), |
| 268 | .length = MX31_CS5_SIZE, |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 269 | .type = MT_DEVICE |
| 270 | }, |
| 271 | }; |
| 272 | |
| 273 | /* |
| 274 | * Set up static virtual mappings. |
| 275 | */ |
| 276 | static void __init kzm_map_io(void) |
| 277 | { |
| 278 | mx31_map_io(); |
| 279 | iotable_init(kzm_io_desc, ARRAY_SIZE(kzm_io_desc)); |
| 280 | } |
| 281 | |
| 282 | static void __init kzm_timer_init(void) |
| 283 | { |
| 284 | mx31_clocks_init(26000000); |
| 285 | } |
| 286 | |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 287 | MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01") |
Nicolas Pitre | dc8f190 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 288 | .atag_offset = 0x100, |
Uwe Kleine-König | 97976e2 | 2011-02-07 16:35:20 +0100 | [diff] [blame] | 289 | .map_io = kzm_map_io, |
| 290 | .init_early = imx31_init_early, |
| 291 | .init_irq = mx31_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 292 | .init_time = kzm_timer_init, |
Uwe Kleine-König | 97976e2 | 2011-02-07 16:35:20 +0100 | [diff] [blame] | 293 | .init_machine = kzm_board_init, |
Russell King | 65ea788 | 2011-11-06 17:12:08 +0000 | [diff] [blame] | 294 | .restart = mxc_restart, |
Yoichi Yuasa | 415c7d2 | 2009-11-02 11:37:36 +0900 | [diff] [blame] | 295 | MACHINE_END |