blob: 799f31f2c7ff2e9e797672affd221c7a38063e29 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/*
2 * linux/arch/arm/mach-pxa/lubbock.c
3 *
4 * Support for the Intel DBPXA250 Development Platform.
5 *
6 * Author: Nicolas Pitre
7 * Created: Jun 15, 2001
8 * Copyright: MontaVista Software Inc.
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 version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/gpio.h>
15#include <linux/gpio/machine.h>
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/syscore_ops.h>
21#include <linux/major.h>
22#include <linux/fb.h>
23#include <linux/interrupt.h>
24#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h>
26#include <linux/smc91x.h>
27
28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h>
30#include <linux/spi/pxa2xx_spi.h>
31
32#include <asm/setup.h>
33#include <asm/memory.h>
34#include <asm/mach-types.h>
35#include <mach/hardware.h>
36#include <asm/irq.h>
37#include <asm/sizes.h>
38
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41#include <asm/mach/irq.h>
42#include <asm/mach/flash.h>
43
44#include <asm/hardware/sa1111.h>
45
46#include <mach/pxa25x.h>
47#include <mach/audio.h>
48#include <mach/lubbock.h>
49#include <mach/udc.h>
50#include <mach/irda.h>
51#include <mach/pxafb.h>
52#include <mach/mmc.h>
53#include <mach/pm.h>
54#include <mach/smemc.h>
55
56#include "generic.h"
57#include "clock.h"
58#include "devices.h"
59
60static unsigned long lubbock_pin_config[] __initdata = {
61 GPIO15_nCS_1, /* CS1 - Flash */
62 GPIO78_nCS_2, /* CS2 - Baseboard FGPA */
63 GPIO79_nCS_3, /* CS3 - SMC ethernet */
64 GPIO80_nCS_4, /* CS4 - SA1111 */
65
66 /* SSP data pins */
67 GPIO23_SSP1_SCLK,
68 GPIO25_SSP1_TXD,
69 GPIO26_SSP1_RXD,
70
71 /* AC97 */
72 GPIO28_AC97_BITCLK,
73 GPIO29_AC97_SDATA_IN_0,
74 GPIO30_AC97_SDATA_OUT,
75 GPIO31_AC97_SYNC,
76
77 /* LCD - 16bpp DSTN */
78 GPIOxx_LCD_DSTN_16BPP,
79
80 /* BTUART */
81 GPIO42_BTUART_RXD,
82 GPIO43_BTUART_TXD,
83 GPIO44_BTUART_CTS,
84 GPIO45_BTUART_RTS,
85
86 /* PC Card */
87 GPIO48_nPOE,
88 GPIO49_nPWE,
89 GPIO50_nPIOR,
90 GPIO51_nPIOW,
91 GPIO52_nPCE_1,
92 GPIO53_nPCE_2,
93 GPIO54_nPSKTSEL,
94 GPIO55_nPREG,
95 GPIO56_nPWAIT,
96 GPIO57_nIOIS16,
97
98 /* MMC */
99 GPIO6_MMC_CLK,
100 GPIO8_MMC_CS0,
101
102 /* wakeup */
103 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
104};
105
106#define LUB_HEXLED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
107#define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
108
109void lubbock_set_hexled(uint32_t value)
110{
111 LUB_HEXLED = value;
112}
113
114void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
115{
116 unsigned long flags;
117
118 local_irq_save(flags);
119 LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
120 local_irq_restore(flags);
121}
122EXPORT_SYMBOL(lubbock_set_misc_wr);
123
124static int lubbock_udc_is_connected(void)
125{
126 return (LUB_MISC_RD & (1 << 9)) == 0;
127}
128
129static struct pxa2xx_udc_mach_info udc_info __initdata = {
130 .udc_is_connected = lubbock_udc_is_connected,
131 // no D+ pullup; lubbock can't connect/disconnect in software
132};
133
134static struct resource sa1111_resources[] = {
135 [0] = {
136 .start = 0x10000000,
137 .end = 0x10001fff,
138 .flags = IORESOURCE_MEM,
139 },
140 [1] = {
141 .start = LUBBOCK_SA1111_IRQ,
142 .end = LUBBOCK_SA1111_IRQ,
143 .flags = IORESOURCE_IRQ,
144 },
145};
146
147static struct sa1111_platform_data sa1111_info = {
148 .irq_base = LUBBOCK_SA1111_IRQ_BASE,
149 .disable_devs = SA1111_DEVID_SAC,
150};
151
152static struct platform_device sa1111_device = {
153 .name = "sa1111",
154 .id = -1,
155 .num_resources = ARRAY_SIZE(sa1111_resources),
156 .resource = sa1111_resources,
157 .dev = {
158 .platform_data = &sa1111_info,
159 },
160};
161
162/* ADS7846 is connected through SSP ... and if your board has J5 populated,
163 * you can select it to replace the ucb1400 by switching the touchscreen cable
164 * (to J5) and poking board registers (as done below). Else it's only useful
165 * for the temperature sensors.
166 */
167static struct pxa2xx_spi_master pxa_ssp_master_info = {
168 .num_chipselect = 1,
169};
170
171static int lubbock_ads7846_pendown_state(void)
172{
173 /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
174 return 0;
175}
176
177static struct ads7846_platform_data ads_info = {
178 .model = 7846,
179 .vref_delay_usecs = 100, /* internal, no cap */
180 .get_pendown_state = lubbock_ads7846_pendown_state,
181 // .x_plate_ohms = 500, /* GUESS! */
182 // .y_plate_ohms = 500, /* GUESS! */
183};
184
185static void ads7846_cs(u32 command)
186{
187 static const unsigned TS_nCS = 1 << 11;
188 lubbock_set_misc_wr(TS_nCS, (command == PXA2XX_CS_ASSERT) ? 0 : TS_nCS);
189}
190
191static struct pxa2xx_spi_chip ads_hw = {
192 .tx_threshold = 1,
193 .rx_threshold = 2,
194 .cs_control = ads7846_cs,
195};
196
197static struct spi_board_info spi_board_info[] __initdata = { {
198 .modalias = "ads7846",
199 .platform_data = &ads_info,
200 .controller_data = &ads_hw,
201 .irq = LUBBOCK_BB_IRQ,
202 .max_speed_hz = 120000 /* max sample rate at 3V */
203 * 26 /* command + data + overhead */,
204 .bus_num = 1,
205 .chip_select = 0,
206},
207};
208
209static struct resource smc91x_resources[] = {
210 [0] = {
211 .name = "smc91x-regs",
212 .start = 0x0c000c00,
213 .end = 0x0c0fffff,
214 .flags = IORESOURCE_MEM,
215 },
216 [1] = {
217 .start = LUBBOCK_ETH_IRQ,
218 .end = LUBBOCK_ETH_IRQ,
219 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
220 },
221 [2] = {
222 .name = "smc91x-attrib",
223 .start = 0x0e000000,
224 .end = 0x0e0fffff,
225 .flags = IORESOURCE_MEM,
226 },
227};
228
229static struct smc91x_platdata lubbock_smc91x_info = {
230 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
231};
232
233static struct platform_device smc91x_device = {
234 .name = "smc91x",
235 .id = -1,
236 .num_resources = ARRAY_SIZE(smc91x_resources),
237 .resource = smc91x_resources,
238 .dev = {
239 .platform_data = &lubbock_smc91x_info,
240 },
241};
242
243static struct resource flash_resources[] = {
244 [0] = {
245 .start = 0x00000000,
246 .end = SZ_64M - 1,
247 .flags = IORESOURCE_MEM,
248 },
249 [1] = {
250 .start = 0x04000000,
251 .end = 0x04000000 + SZ_64M - 1,
252 .flags = IORESOURCE_MEM,
253 },
254};
255
256static struct mtd_partition lubbock_partitions[] = {
257 {
258 .name = "Bootloader",
259 .size = 0x00040000,
260 .offset = 0,
261 .mask_flags = MTD_WRITEABLE /* force read-only */
262 },{
263 .name = "Kernel",
264 .size = 0x00100000,
265 .offset = 0x00040000,
266 },{
267 .name = "Filesystem",
268 .size = MTDPART_SIZ_FULL,
269 .offset = 0x00140000
270 }
271};
272
273static struct flash_platform_data lubbock_flash_data[2] = {
274 {
275 .map_name = "cfi_probe",
276 .parts = lubbock_partitions,
277 .nr_parts = ARRAY_SIZE(lubbock_partitions),
278 }, {
279 .map_name = "cfi_probe",
280 .parts = NULL,
281 .nr_parts = 0,
282 }
283};
284
285static struct platform_device lubbock_flash_device[2] = {
286 {
287 .name = "pxa2xx-flash",
288 .id = 0,
289 .dev = {
290 .platform_data = &lubbock_flash_data[0],
291 },
292 .resource = &flash_resources[0],
293 .num_resources = 1,
294 },
295 {
296 .name = "pxa2xx-flash",
297 .id = 1,
298 .dev = {
299 .platform_data = &lubbock_flash_data[1],
300 },
301 .resource = &flash_resources[1],
302 .num_resources = 1,
303 },
304};
305
306static struct resource lubbock_cplds_resources[] = {
307 [0] = {
308 .start = LUBBOCK_FPGA_PHYS + 0xc0,
309 .end = LUBBOCK_FPGA_PHYS + 0xe0 - 1,
310 .flags = IORESOURCE_MEM,
311 },
312 [1] = {
313 .start = PXA_GPIO_TO_IRQ(0),
314 .end = PXA_GPIO_TO_IRQ(0),
315 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
316 },
317 [2] = {
318 .start = LUBBOCK_IRQ(0),
319 .end = LUBBOCK_IRQ(6),
320 .flags = IORESOURCE_IRQ,
321 },
322};
323
324static struct platform_device lubbock_cplds_device = {
325 .name = "pxa_cplds_irqs",
326 .id = -1,
327 .resource = &lubbock_cplds_resources[0],
328 .num_resources = 3,
329};
330
331
332static struct platform_device *devices[] __initdata = {
333 &sa1111_device,
334 &smc91x_device,
335 &lubbock_flash_device[0],
336 &lubbock_flash_device[1],
337 &lubbock_cplds_device,
338};
339
340static struct pxafb_mode_info sharp_lm8v31_mode = {
341 .pixclock = 270000,
342 .xres = 640,
343 .yres = 480,
344 .bpp = 16,
345 .hsync_len = 1,
346 .left_margin = 3,
347 .right_margin = 3,
348 .vsync_len = 1,
349 .upper_margin = 0,
350 .lower_margin = 0,
351 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
352 .cmap_greyscale = 0,
353};
354
355static struct pxafb_mach_info sharp_lm8v31 = {
356 .modes = &sharp_lm8v31_mode,
357 .num_modes = 1,
358 .cmap_inverse = 0,
359 .cmap_static = 0,
360 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
361 LCD_AC_BIAS_FREQ(255),
362};
363
364#define MMC_POLL_RATE msecs_to_jiffies(1000)
365
366static void lubbock_mmc_poll(unsigned long);
367static irq_handler_t mmc_detect_int;
368
369static struct timer_list mmc_timer = {
370 .function = lubbock_mmc_poll,
371};
372
373static void lubbock_mmc_poll(unsigned long data)
374{
375 unsigned long flags;
376
377 /* clear any previous irq state, then ... */
378 local_irq_save(flags);
379 LUB_IRQ_SET_CLR &= ~(1 << 0);
380 local_irq_restore(flags);
381
382 /* poll until mmc/sd card is removed */
383 if (LUB_IRQ_SET_CLR & (1 << 0))
384 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
385 else {
386 (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
387 enable_irq(LUBBOCK_SD_IRQ);
388 }
389}
390
391static irqreturn_t lubbock_detect_int(int irq, void *data)
392{
393 /* IRQ is level triggered; disable, and poll for removal */
394 disable_irq(irq);
395 mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
396
397 return mmc_detect_int(irq, data);
398}
399
400static int lubbock_mci_init(struct device *dev,
401 irq_handler_t detect_int,
402 void *data)
403{
404 /* detect card insert/eject */
405 mmc_detect_int = detect_int;
406 init_timer(&mmc_timer);
407 mmc_timer.data = (unsigned long) data;
408 return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
409 IRQF_SAMPLE_RANDOM, "lubbock-sd-detect", data);
410}
411
412static int lubbock_mci_get_ro(struct device *dev)
413{
414 return (LUB_MISC_RD & (1 << 2)) != 0;
415}
416
417static void lubbock_mci_exit(struct device *dev, void *data)
418{
419 free_irq(LUBBOCK_SD_IRQ, data);
420 del_timer_sync(&mmc_timer);
421}
422
423static struct pxamci_platform_data lubbock_mci_platform_data = {
424 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
425 .detect_delay_ms = 10,
426 .init = lubbock_mci_init,
427 .get_ro = lubbock_mci_get_ro,
428 .exit = lubbock_mci_exit,
429 .gpio_card_detect = -1,
430 .gpio_card_ro = -1,
431 .gpio_power = -1,
432};
433
434static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
435{
436 unsigned long flags;
437
438 local_irq_save(flags);
439 if (mode & IR_SIRMODE) {
440 LUB_MISC_WR &= ~(1 << 4);
441 } else if (mode & IR_FIRMODE) {
442 LUB_MISC_WR |= 1 << 4;
443 }
444 pxa2xx_transceiver_mode(dev, mode);
445 local_irq_restore(flags);
446}
447
448static struct pxaficp_platform_data lubbock_ficp_platform_data = {
449 .gpio_pwdown = -1,
450 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
451 .transceiver_mode = lubbock_irda_transceiver_mode,
452};
453
454static void __init lubbock_init(void)
455{
456 int flashboot = (LUB_CONF_SWITCHES & 1);
457
458 pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
459
460 pxa_set_ffuart_info(NULL);
461 pxa_set_btuart_info(NULL);
462 pxa_set_stuart_info(NULL);
463
464 clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
465 pxa_set_udc_info(&udc_info);
466 pxa_set_fb_info(NULL, &sharp_lm8v31);
467 pxa_set_mci_info(&lubbock_mci_platform_data);
468 pxa_set_ficp_info(&lubbock_ficp_platform_data);
469 pxa_set_ac97_info(NULL);
470
471 lubbock_flash_data[0].width = lubbock_flash_data[1].width =
472 (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
473 /* Compensate for the nROMBT switch which swaps the flash banks */
474 printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
475 flashboot?"Flash":"ROM", flashboot);
476
477 lubbock_flash_data[flashboot^1].name = "application-flash";
478 lubbock_flash_data[flashboot].name = "boot-rom";
479 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
480
481 pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
482 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
483}
484
485static struct map_desc lubbock_io_desc[] __initdata = {
486 { /* CPLD */
487 .virtual = LUBBOCK_FPGA_VIRT,
488 .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
489 .length = 0x00100000,
490 .type = MT_DEVICE
491 }
492};
493
494static void __init lubbock_map_io(void)
495{
496 pxa25x_map_io();
497 iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
498
499 PCFR |= PCFR_OPDE;
500}
501
502MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
503 /* Maintainer: MontaVista Software Inc. */
504 .map_io = lubbock_map_io,
505 .nr_irqs = LUBBOCK_NR_IRQS,
506 .init_irq = pxa25x_init_irq,
507 .handle_irq = pxa25x_handle_irq,
508 .timer = &pxa_timer,
509 .init_machine = lubbock_init,
510 .restart = pxa_restart,
511MACHINE_END