1f0c2fd492b97eb5339ff2faa9631b8336def1e4
[librecmc/librecmc.git] / target / linux / at91 / files / arch / arm / mach-at91 / board-tqma9263.c
1 /*
2  *  Copyright (C) 2008 I2SE GmbH
3  *  Copyright (C) 2010 IEQualize GmbH
4  *  Copyright (C) 2010-2011 Michael Heimpold
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <linux/types.h>
22 #include <linux/init.h>
23 #include <linux/mm.h>
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
26 #include <linux/fb.h>
27
28 #include <mach/hardware.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
31 #include <asm/irq.h>
32
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/irq.h>
36
37 #include <mach/board.h>
38 #include <mach/gpio.h>
39 #include <mach/at91sam9_smc.h>
40
41 #include <video/atmel_lcdc.h>
42
43 #include "sam9_smc.h"
44 #include "generic.h"
45
46 #include <linux/atmel_serial.h>
47
48
49 static void __init tqma9263_map_io(void)
50 {
51         unsigned pins;
52
53         /* Initialize processor: 18.432 MHz crystal */
54         at91sam9263_initialize(18432000);
55
56         /* DGBU on ttyS0. (Rx & Tx only) */
57         at91_register_uart(0, 0, 0);
58
59         /* USART0 on ttyS1 */
60         pins = ATMEL_UART_CTS | ATMEL_UART_RTS |
61                ATMEL_UART_DSR | ATMEL_UART_DTR |
62                ATMEL_UART_DCD | ATMEL_UART_RI;
63         at91_register_uart(AT91SAM9263_ID_US0, 1, pins);
64
65         /* USART1 on ttyS2 */
66         pins = ATMEL_UART_RTS;
67         at91_register_uart(AT91SAM9263_ID_US1, 2, pins);
68
69         /* USART2 on ttyS3 */
70         pins = ATMEL_UART_RTS;
71         at91_register_uart(AT91SAM9263_ID_US2, 3, pins);
72
73         /* set serial console to ttyS0 (ie, DBGU) */
74         at91_set_serial_console(0);
75 }
76
77
78 static void __init tqma9263_init_irq(void)
79 {
80         at91sam9263_init_interrupts(NULL);
81 }
82
83
84 /*
85  * USB Host port
86  */
87 static struct at91_usbh_data __initdata tqma9263_usbh_data = {
88         .ports                  = 2,
89         .vbus_pin               = { AT91_PIN_PA24, AT91_PIN_PA21 },
90         .vbus_active_high       = 1,
91 };
92
93
94 /*
95  * USB Device port
96  */
97 static struct at91_udc_data __initdata tqma9263_udc_data = {
98         .vbus_pin       = AT91_PIN_PA25,
99         .pullup_pin     = 0,                    /* pull-up driven by UDC */
100 };
101
102
103 /*
104  * MCI (SD/MMC)
105  */
106 static struct at91_mmc_data __initdata tqma9263_mmc_data = {
107         .wire4          = 1,
108         .det_pin        = AT91_PIN_PE18,
109         .wp_pin         = AT91_PIN_PB28,
110 };
111
112
113 /*
114  * MACB Ethernet device
115  */
116 static struct at91_eth_data __initdata tqma9263_macb_data = {
117         .phy_irq_pin    = AT91_PIN_PE31,
118         .is_rmii        = 1,
119 };
120
121
122 /*
123  * I2C devices
124  */
125 static struct i2c_board_info __initdata tqma9263_i2c_devices[] = {
126         {
127                 I2C_BOARD_INFO("pcf8563", 0x51),
128         },
129         {
130                 I2C_BOARD_INFO("24c04", 0x52),
131         },
132 };
133
134
135 /*
136  * NAND flash
137  */
138 static struct mtd_partition __initdata tqma9263_nand_partition[] = {
139         {
140                 .name   = "uboot",
141                 .offset = 0,
142                 .size   = 3 * SZ_128K,
143         },
144         {
145                 .name   = "uboot-env",
146                 .offset = MTDPART_OFS_NXTBLK,
147                 .size   = SZ_128K,
148         },
149         {
150                 .name   = "linux",
151                 .offset = MTDPART_OFS_NXTBLK,
152                 .size   = SZ_2M,
153         },
154         {
155                 .name   = "rootfs",
156                 .offset = MTDPART_OFS_NXTBLK,
157                 .size   = MTDPART_SIZ_FULL,
158         },
159 };
160
161 static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
162 {
163         *num_partitions = ARRAY_SIZE(tqma9263_nand_partition);
164         return tqma9263_nand_partition;
165 }
166
167 static struct atmel_nand_data __initdata tqma9263_nand_data = {
168         .ale                    = 21,
169         .cle                    = 22,
170         .rdy_pin                = AT91_PIN_PD14,
171         .enable_pin             = AT91_PIN_PD15,
172         .partition_info         = nand_partitions,
173 };
174
175 static struct sam9_smc_config __initdata tqma9263_nand_smc_config = {
176         .ncs_read_setup         = 0,
177         .nrd_setup              = 1,
178         .ncs_write_setup        = 0,
179         .nwe_setup              = 1,
180
181         .ncs_read_pulse         = 3,
182         .nrd_pulse              = 3,
183         .ncs_write_pulse        = 3,
184         .nwe_pulse              = 3,
185
186         .read_cycle             = 5,
187         .write_cycle            = 5,
188
189         .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
190         .tdf_cycles             = 2,
191 };
192
193 static void __init tqma9263_add_device_nand(void)
194 {
195         /* configure chip-select 3 (NAND) */
196         sam9_smc_configure(3, &tqma9263_nand_smc_config);
197
198         at91_add_device_nand(&tqma9263_nand_data);
199 }
200
201
202 static void __init tqma9263_board_init(void)
203 {
204         /* Serial */
205         at91_add_device_serial();
206         /* USB Host */
207         at91_add_device_usbh(&tqma9263_usbh_data);
208         /* USB Device */
209         at91_add_device_udc(&tqma9263_udc_data);
210         /* MMC */
211         at91_add_device_mmc(1, &tqma9263_mmc_data);
212         /* I2C */
213         at91_add_device_i2c(tqma9263_i2c_devices, ARRAY_SIZE(tqma9263_i2c_devices));
214         /* Ethernet */
215         at91_add_device_eth(&tqma9263_macb_data);
216         /* NAND flash */
217         tqma9263_add_device_nand();
218 }
219
220 MACHINE_START(TQMA9263, "TQ Components TQMa9263")
221         /* Maintainer: Michael Heimpold */
222         .phys_io        = AT91_BASE_SYS,
223         .io_pg_offst    = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
224         .boot_params    = AT91_SDRAM_BASE + 0x100,
225         .timer          = &at91sam926x_timer,
226         .map_io         = tqma9263_map_io,
227         .init_irq       = tqma9263_init_irq,
228         .init_machine   = tqma9263_board_init,
229 MACHINE_END