3 * Copyright (C) 2009 Yoichi Yuasa <yuasa@linux-mips.org>
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.
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.
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.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <linux/gpio.h>
26 #include <linux/init.h>
27 #include <linux/platform_device.h>
28 #include <linux/serial_8250.h>
29 #include <linux/smsc911x.h>
30 #include <linux/types.h>
33 #include <asm/mach-types.h>
34 #include <asm/setup.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/irq.h>
37 #include <asm/mach/map.h>
38 #include <asm/mach/time.h>
40 #include <mach/board-kzmarm11.h>
41 #include <mach/clock.h>
42 #include <mach/common.h>
43 #include <mach/imx-uart.h>
44 #include <mach/iomux-mx3.h>
45 #include <mach/memory.h>
49 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
51 * KZM-ARM11-01 has an external UART on FPGA
53 static struct plat_serial8250_port serial_platform_data
[] = {
55 .membase
= IO_ADDRESS(KZM_ARM11_16550
),
56 .mapbase
= KZM_ARM11_16550
,
57 .irq
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_1
),
58 .irqflags
= IRQ_TYPE_EDGE_RISING
,
62 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
|
68 static struct resource serial8250_resources
[] = {
70 .start
= KZM_ARM11_16550
,
71 .end
= KZM_ARM11_16550
+ 0x10,
72 .flags
= IORESOURCE_MEM
,
75 .start
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_1
),
76 .end
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_1
),
77 .flags
= IORESOURCE_IRQ
,
81 static struct platform_device serial_device
= {
83 .id
= PLAT8250_DEV_PLATFORM
,
85 .platform_data
= serial_platform_data
,
87 .num_resources
= ARRAY_SIZE(serial8250_resources
),
88 .resource
= serial8250_resources
,
91 static int __init
kzm_init_ext_uart(void)
96 * GPIO 1-1: external UART interrupt line
98 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1
, IOMUX_CONFIG_GPIO
));
99 gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1
), "ext-uart-int");
100 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1
));
103 * Unmask UART interrupt
105 tmp
= __raw_readb(IO_ADDRESS(KZM_ARM11_CTL1
));
107 __raw_writeb(tmp
, IO_ADDRESS(KZM_ARM11_CTL1
));
109 return platform_device_register(&serial_device
);
112 static inline int kzm_init_ext_uart(void)
121 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
122 static struct smsc911x_platform_config kzm_smsc9118_config
= {
123 .phy_interface
= PHY_INTERFACE_MODE_MII
,
124 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
125 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
126 .flags
= SMSC911X_USE_32BIT
| SMSC911X_SAVE_MAC_ADDRESS
,
129 static struct resource kzm_smsc9118_resources
[] = {
131 .start
= MX31_CS5_BASE_ADDR
,
132 .end
= MX31_CS5_BASE_ADDR
+ SZ_128K
- 1,
133 .flags
= IORESOURCE_MEM
,
136 .start
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_2
),
137 .end
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_2
),
138 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
142 static struct platform_device kzm_smsc9118_device
= {
145 .num_resources
= ARRAY_SIZE(kzm_smsc9118_resources
),
146 .resource
= kzm_smsc9118_resources
,
148 .platform_data
= &kzm_smsc9118_config
,
152 static int __init
kzm_init_smsc9118(void)
155 * GPIO 1-2: SMSC9118 interrupt line
157 mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2
, IOMUX_CONFIG_GPIO
));
158 gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2
), "smsc9118-int");
159 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2
));
161 return platform_device_register(&kzm_smsc9118_device
);
164 static inline int kzm_init_smsc9118(void)
170 #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
171 static struct imxuart_platform_data uart_pdata
= {
172 .flags
= IMXUART_HAVE_RTSCTS
,
175 static void __init
kzm_init_imx_uart(void)
177 mxc_register_device(&mxc_uart_device0
, &uart_pdata
);
179 mxc_register_device(&mxc_uart_device1
, &uart_pdata
);
182 static inline void kzm_init_imx_uart(void)
187 static int kzm_pins
[] __initdata
= {
192 MX31_PIN_DCD_DCE1__DCD_DCE1
,
193 MX31_PIN_RI_DCE1__RI_DCE1
,
194 MX31_PIN_DSR_DCE1__DSR_DCE1
,
195 MX31_PIN_DTR_DCE1__DTR_DCE1
,
200 MX31_PIN_DCD_DTE1__DCD_DTE2
,
201 MX31_PIN_RI_DTE1__RI_DTE2
,
202 MX31_PIN_DSR_DTE1__DSR_DTE2
,
203 MX31_PIN_DTR_DTE1__DTR_DTE2
,
207 * Board specific initialization.
209 static void __init
kzm_board_init(void)
211 mxc_iomux_setup_multiple_pins(kzm_pins
,
212 ARRAY_SIZE(kzm_pins
), "kzm");
217 pr_info("Clock input source is 26MHz\n");
221 * This structure defines static mappings for the kzm-arm11-01 board.
223 static struct map_desc kzm_io_desc
[] __initdata
= {
225 .virtual = MX31_CS4_BASE_ADDR_VIRT
,
226 .pfn
= __phys_to_pfn(MX31_CS4_BASE_ADDR
),
227 .length
= MX31_CS4_SIZE
,
231 .virtual = MX31_CS5_BASE_ADDR_VIRT
,
232 .pfn
= __phys_to_pfn(MX31_CS5_BASE_ADDR
),
233 .length
= MX31_CS5_SIZE
,
239 * Set up static virtual mappings.
241 static void __init
kzm_map_io(void)
244 iotable_init(kzm_io_desc
, ARRAY_SIZE(kzm_io_desc
));
247 static void __init
kzm_timer_init(void)
249 mx31_clocks_init(26000000);
252 static struct sys_timer kzm_timer
= {
253 .init
= kzm_timer_init
,
257 * The following uses standard kernel macros define in arch.h in order to
258 * initialize __mach_desc_KZM_ARM11_01 data structure.
260 MACHINE_START(KZM_ARM11_01
, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01")
261 .phys_io
= MX31_AIPS1_BASE_ADDR
,
262 .io_pg_offst
= ((MX31_AIPS1_BASE_ADDR_VIRT
) >> 18) & 0xfffc,
263 .boot_params
= PHYS_OFFSET
+ 0x100,
264 .map_io
= kzm_map_io
,
265 .init_irq
= mx31_init_irq
,
266 .init_machine
= kzm_board_init
,