]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-at91/board-sam9261ek.c
[ARM] 4379/1: AT91: LCD support on SAM9261-EK and SAM9263-EK boards
[linux-2.6-omap-h63xx.git] / arch / arm / mach-at91 / board-sam9261ek.c
1 /*
2  * linux/arch/arm/mach-at91/board-sam9261ek.c
3  *
4  *  Copyright (C) 2005 SAN People
5  *  Copyright (C) 2006 Atmel
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <linux/types.h>
23 #include <linux/init.h>
24 #include <linux/mm.h>
25 #include <linux/module.h>
26 #include <linux/platform_device.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
29 #include <linux/dm9000.h>
30 #include <linux/fb.h>
31
32 #include <video/atmel_lcdc.h>
33
34 #include <asm/hardware.h>
35 #include <asm/setup.h>
36 #include <asm/mach-types.h>
37 #include <asm/irq.h>
38
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/irq.h>
42
43 #include <asm/arch/board.h>
44 #include <asm/arch/gpio.h>
45 #include <asm/arch/at91sam926x_mc.h>
46
47 #include "generic.h"
48
49
50 /*
51  * Serial port configuration.
52  *    0 .. 2 = USART0 .. USART2
53  *    3      = DBGU
54  */
55 static struct at91_uart_config __initdata ek_uart_config = {
56         .console_tty    = 0,                            /* ttyS0 */
57         .nr_tty         = 1,
58         .tty_map        = { 3, -1, -1, -1 }             /* ttyS0, ..., ttyS3 */
59 };
60
61 static void __init ek_map_io(void)
62 {
63         /* Initialize processor: 18.432 MHz crystal */
64         at91sam9261_initialize(18432000);
65
66         /* Setup the LEDs */
67         at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
68
69         /* Setup the serial ports and console */
70         at91_init_serial(&ek_uart_config);
71 }
72
73 static void __init ek_init_irq(void)
74 {
75         at91sam9261_init_interrupts(NULL);
76 }
77
78
79 /*
80  * DM9000 ethernet device
81  */
82 #if defined(CONFIG_DM9000)
83 static struct resource at91sam9261_dm9000_resource[] = {
84         [0] = {
85                 .start  = AT91_CHIPSELECT_2,
86                 .end    = AT91_CHIPSELECT_2 + 3,
87                 .flags  = IORESOURCE_MEM
88         },
89         [1] = {
90                 .start  = AT91_CHIPSELECT_2 + 0x44,
91                 .end    = AT91_CHIPSELECT_2 + 0xFF,
92                 .flags  = IORESOURCE_MEM
93         },
94         [2] = {
95                 .start  = AT91_PIN_PC11,
96                 .end    = AT91_PIN_PC11,
97                 .flags  = IORESOURCE_IRQ
98         }
99 };
100
101 static struct dm9000_plat_data dm9000_platdata = {
102         .flags          = DM9000_PLATF_16BITONLY,
103 };
104
105 static struct platform_device at91sam9261_dm9000_device = {
106         .name           = "dm9000",
107         .id             = 0,
108         .num_resources  = ARRAY_SIZE(at91sam9261_dm9000_resource),
109         .resource       = at91sam9261_dm9000_resource,
110         .dev            = {
111                 .platform_data  = &dm9000_platdata,
112         }
113 };
114
115 static void __init ek_add_device_dm9000(void)
116 {
117         /*
118          * Configure Chip-Select 2 on SMC for the DM9000.
119          * Note: These timings were calculated for MASTER_CLOCK = 100000000
120          *  according to the DM9000 timings.
121          */
122         at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
123         at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
124         at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
125         at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
126
127         /* Configure Reset signal as output */
128         at91_set_gpio_output(AT91_PIN_PC10, 0);
129
130         /* Configure Interrupt pin as input, no pull-up */
131         at91_set_gpio_input(AT91_PIN_PC11, 0);
132
133         platform_device_register(&at91sam9261_dm9000_device);
134 }
135 #else
136 static void __init ek_add_device_dm9000(void) {}
137 #endif /* CONFIG_DM9000 */
138
139
140 /*
141  * USB Host Port
142  */
143 static struct at91_usbh_data __initdata ek_usbh_data = {
144         .ports          = 2,
145 };
146
147
148 /*
149  * USB Device Port
150  */
151 static struct at91_udc_data __initdata ek_udc_data = {
152         .vbus_pin       = AT91_PIN_PB29,
153         .pullup_pin     = 0,            /* pull-up driven by UDC */
154 };
155
156
157 /*
158  * MCI (SD/MMC)
159  */
160 static struct at91_mmc_data __initdata ek_mmc_data = {
161         .wire4          = 1,
162 //      .det_pin        = ... not connected
163 //      .wp_pin         = ... not connected
164 //      .vcc_pin        = ... not connected
165 };
166
167
168 /*
169  * NAND flash
170  */
171 static struct mtd_partition __initdata ek_nand_partition[] = {
172         {
173                 .name   = "Partition 1",
174                 .offset = 0,
175                 .size   = 256 * 1024,
176         },
177         {
178                 .name   = "Partition 2",
179                 .offset = 256 * 1024 ,
180                 .size   = MTDPART_SIZ_FULL,
181         },
182 };
183
184 static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
185 {
186         *num_partitions = ARRAY_SIZE(ek_nand_partition);
187         return ek_nand_partition;
188 }
189
190 static struct at91_nand_data __initdata ek_nand_data = {
191         .ale            = 22,
192         .cle            = 21,
193 //      .det_pin        = ... not connected
194         .rdy_pin        = AT91_PIN_PC15,
195         .enable_pin     = AT91_PIN_PC14,
196         .partition_info = nand_partitions,
197 #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
198         .bus_width_16   = 1,
199 #else
200         .bus_width_16   = 0,
201 #endif
202 };
203
204 /*
205  * ADS7846 Touchscreen
206  */
207 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
208
209 static int ads7843_pendown_state(void)
210 {
211         return !at91_get_gpio_value(AT91_PIN_PC2);      /* Touchscreen PENIRQ */
212 }
213
214 static struct ads7846_platform_data ads_info = {
215         .model                  = 7843,
216         .x_min                  = 150,
217         .x_max                  = 3830,
218         .y_min                  = 190,
219         .y_max                  = 3830,
220         .vref_delay_usecs       = 100,
221         .x_plate_ohms           = 450,
222         .y_plate_ohms           = 250,
223         .pressure_max           = 15000,
224         .debounce_max           = 1,
225         .debounce_rep           = 0,
226         .debounce_tol           = (~0),
227         .get_pendown_state      = ads7843_pendown_state,
228 };
229
230 static void __init ek_add_device_ts(void)
231 {
232         at91_set_B_periph(AT91_PIN_PC2, 1);     /* External IRQ0, with pullup */
233         at91_set_gpio_input(AT91_PIN_PA11, 1);  /* Touchscreen BUSY signal */
234 }
235 #else
236 static void __init ek_add_device_ts(void) {}
237 #endif
238
239 /*
240  * SPI devices
241  */
242 static struct spi_board_info ek_spi_devices[] = {
243         {       /* DataFlash chip */
244                 .modalias       = "mtd_dataflash",
245                 .chip_select    = 0,
246                 .max_speed_hz   = 15 * 1000 * 1000,
247                 .bus_num        = 0,
248         },
249 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
250         {
251                 .modalias       = "ads7846",
252                 .chip_select    = 2,
253                 .max_speed_hz   = 125000 * 26,  /* (max sample rate @ 3V) * (cmd + data + overhead) */
254                 .bus_num        = 0,
255                 .platform_data  = &ads_info,
256                 .irq            = AT91SAM9261_ID_IRQ0,
257         },
258 #endif
259 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
260         {       /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
261                 .modalias       = "mtd_dataflash",
262                 .chip_select    = 3,
263                 .max_speed_hz   = 15 * 1000 * 1000,
264                 .bus_num        = 0,
265         },
266 #elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
267         {       /* AT73C213 DAC */
268                 .modalias       = "at73c213",
269                 .chip_select    = 3,
270                 .max_speed_hz   = 10 * 1000 * 1000,
271                 .bus_num        = 0,
272         },
273 #endif
274 };
275
276
277 /*
278  * LCD Controller
279  */
280 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
281 static struct fb_videomode at91_tft_vga_modes[] = {
282         {
283                 .name           = "TX09D50VM1CCA @ 60",
284                 .refresh        = 60,
285                 .xres           = 240,          .yres           = 320,
286                 .pixclock       = KHZ2PICOS(4965),
287
288                 .left_margin    = 1,            .right_margin   = 33,
289                 .upper_margin   = 1,            .lower_margin   = 0,
290                 .hsync_len      = 5,            .vsync_len      = 1,
291
292                 .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
293                 .vmode          = FB_VMODE_NONINTERLACED,
294         },
295 };
296
297 static struct fb_monspecs at91fb_default_monspecs = {
298         .manufacturer   = "HIT",
299         .monitor        = "TX09D50VM1CCA",
300
301         .modedb         = at91_tft_vga_modes,
302         .modedb_len     = ARRAY_SIZE(at91_tft_vga_modes),
303         .hfmin          = 15000,
304         .hfmax          = 64000,
305         .vfmin          = 50,
306         .vfmax          = 150,
307 };
308
309 #define AT91SAM9261_DEFAULT_LCDCON2     (ATMEL_LCDC_MEMOR_LITTLE \
310                                         | ATMEL_LCDC_DISTYPE_TFT    \
311                                         | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
312
313 static void at91_lcdc_power_control(int on)
314 {
315         if (on)
316                 at91_set_gpio_value(AT91_PIN_PA12, 0);  /* power up */
317         else
318                 at91_set_gpio_value(AT91_PIN_PA12, 1);  /* power down */
319 }
320
321 /* Driver datas */
322 static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
323         .default_bpp                    = 16,
324         .default_dmacon                 = ATMEL_LCDC_DMAEN,
325         .default_lcdcon2                = AT91SAM9261_DEFAULT_LCDCON2,
326         .default_monspecs               = &at91fb_default_monspecs,
327         .atmel_lcdfb_power_control      = at91_lcdc_power_control,
328         .guard_time                     = 1,
329 };
330
331 #else
332 static struct atmel_lcdfb_info __initdata ek_lcdc_data;
333 #endif
334
335
336 static void __init ek_board_init(void)
337 {
338         /* Serial */
339         at91_add_device_serial();
340         /* USB Host */
341         at91_add_device_usbh(&ek_usbh_data);
342         /* USB Device */
343         at91_add_device_udc(&ek_udc_data);
344         /* I2C */
345         at91_add_device_i2c();
346         /* NAND */
347         at91_add_device_nand(&ek_nand_data);
348         /* DM9000 ethernet */
349         ek_add_device_dm9000();
350
351         /* spi0 and mmc/sd share the same PIO pins */
352 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
353         /* SPI */
354         at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
355         /* Touchscreen */
356         ek_add_device_ts();
357 #else
358         /* MMC */
359         at91_add_device_mmc(0, &ek_mmc_data);
360 #endif
361         /* LCD Controller */
362         at91_add_device_lcdc(&ek_lcdc_data);
363 }
364
365 MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
366         /* Maintainer: Atmel */
367         .phys_io        = AT91_BASE_SYS,
368         .io_pg_offst    = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
369         .boot_params    = AT91_SDRAM_BASE + 0x100,
370         .timer          = &at91sam926x_timer,
371         .map_io         = ek_map_io,
372         .init_irq       = ek_init_irq,
373         .init_machine   = ek_board_init,
374 MACHINE_END