[ARM] 3069/1: Add spitz irda platform support
[firewire-audio.git] / arch / arm / mach-pxa / spitz.c
blobb838842b6a2050438cc351698cbf63a54ae68778
1 /*
2 * Support for Sharp SL-Cxx00 Series of PDAs
3 * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
5 * Copyright (c) 2005 Richard Purdie
7 * Based on Sharp's 2.4 kernel patches/lubbock.c
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/device.h>
18 #include <linux/delay.h>
19 #include <linux/major.h>
20 #include <linux/fs.h>
21 #include <linux/interrupt.h>
22 #include <linux/mmc/host.h>
24 #include <asm/setup.h>
25 #include <asm/memory.h>
26 #include <asm/mach-types.h>
27 #include <asm/hardware.h>
28 #include <asm/irq.h>
29 #include <asm/io.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/irq.h>
35 #include <asm/arch/pxa-regs.h>
36 #include <asm/arch/irq.h>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/mmc.h>
39 #include <asm/arch/udc.h>
40 #include <asm/arch/pxafb.h>
41 #include <asm/arch/akita.h>
42 #include <asm/arch/spitz.h>
43 #include <asm/arch/sharpsl.h>
45 #include <asm/mach/sharpsl_param.h>
46 #include <asm/hardware/scoop.h>
48 #include "generic.h"
49 #include "sharpsl.h"
52 * Spitz SCOOP Device #1
54 static struct resource spitz_scoop_resources[] = {
55 [0] = {
56 .start = 0x10800000,
57 .end = 0x10800fff,
58 .flags = IORESOURCE_MEM,
62 static struct scoop_config spitz_scoop_setup = {
63 .io_dir = SPITZ_SCP_IO_DIR,
64 .io_out = SPITZ_SCP_IO_OUT,
65 .suspend_clr = SPITZ_SCP_SUS_CLR,
66 .suspend_set = SPITZ_SCP_SUS_SET,
69 struct platform_device spitzscoop_device = {
70 .name = "sharp-scoop",
71 .id = 0,
72 .dev = {
73 .platform_data = &spitz_scoop_setup,
75 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
76 .resource = spitz_scoop_resources,
80 * Spitz SCOOP Device #2
82 static struct resource spitz_scoop2_resources[] = {
83 [0] = {
84 .start = 0x08800040,
85 .end = 0x08800fff,
86 .flags = IORESOURCE_MEM,
90 static struct scoop_config spitz_scoop2_setup = {
91 .io_dir = SPITZ_SCP2_IO_DIR,
92 .io_out = SPITZ_SCP2_IO_OUT,
93 .suspend_clr = SPITZ_SCP2_SUS_CLR,
94 .suspend_set = SPITZ_SCP2_SUS_SET,
97 struct platform_device spitzscoop2_device = {
98 .name = "sharp-scoop",
99 .id = 1,
100 .dev = {
101 .platform_data = &spitz_scoop2_setup,
103 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
104 .resource = spitz_scoop2_resources,
107 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
109 .dev = &spitzscoop_device.dev,
110 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
111 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
112 .cd_irq_str = "PCMCIA0 CD",
114 .dev = &spitzscoop2_device.dev,
115 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
116 .cd_irq = -1,
122 * Spitz SSP Device
124 * Set the parent as the scoop device because a lot of SSP devices
125 * also use scoop functions and this makes the power up/down order
126 * work correctly.
128 struct platform_device spitzssp_device = {
129 .name = "corgi-ssp",
130 .dev = {
131 .parent = &spitzscoop_device.dev,
133 .id = -1,
136 struct corgissp_machinfo spitz_ssp_machinfo = {
137 .port = 2,
138 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
139 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
140 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
141 .clk_lcdcon = 520,
142 .clk_ads7846 = 14,
143 .clk_max1111 = 56,
148 * Spitz Backlight Device
150 static struct corgibl_machinfo spitz_bl_machinfo = {
151 .max_intensity = 0x2f,
154 static struct platform_device spitzbl_device = {
155 .name = "corgi-bl",
156 .dev = {
157 .platform_data = &spitz_bl_machinfo,
159 .id = -1,
164 * Spitz Keyboard Device
166 static struct platform_device spitzkbd_device = {
167 .name = "spitz-keyboard",
168 .id = -1,
173 * Spitz Touch Screen Device
175 static struct resource spitzts_resources[] = {
176 [0] = {
177 .start = SPITZ_IRQ_GPIO_TP_INT,
178 .end = SPITZ_IRQ_GPIO_TP_INT,
179 .flags = IORESOURCE_IRQ,
183 static struct corgits_machinfo spitz_ts_machinfo = {
184 .get_hsync_len = spitz_get_hsync_len,
185 .put_hsync = spitz_put_hsync,
186 .wait_hsync = spitz_wait_hsync,
189 static struct platform_device spitzts_device = {
190 .name = "corgi-ts",
191 .dev = {
192 .parent = &spitzssp_device.dev,
193 .platform_data = &spitz_ts_machinfo,
195 .id = -1,
196 .num_resources = ARRAY_SIZE(spitzts_resources),
197 .resource = spitzts_resources,
202 * MMC/SD Device
204 * The card detect interrupt isn't debounced so we delay it by 250ms
205 * to give the card a chance to fully insert/eject.
208 static struct pxamci_platform_data spitz_mci_platform_data;
210 static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
212 int err;
214 /* setup GPIO for PXA27x MMC controller */
215 pxa_gpio_mode(GPIO32_MMCCLK_MD);
216 pxa_gpio_mode(GPIO112_MMCCMD_MD);
217 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
218 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
219 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
220 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
221 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN);
222 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN);
224 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
226 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, SA_INTERRUPT,
227 "MMC card detect", data);
228 if (err) {
229 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
230 return -1;
233 set_irq_type(SPITZ_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
235 return 0;
238 /* Power control is shared with one of the CF slots so we have a mess */
239 static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
241 struct pxamci_platform_data* p_d = dev->platform_data;
243 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
245 if (( 1 << vdd) & p_d->ocr_mask) {
246 /* printk(KERN_DEBUG "%s: on\n", __FUNCTION__); */
247 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
248 mdelay(2);
249 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | 0x04);
250 } else {
251 /* printk(KERN_DEBUG "%s: off\n", __FUNCTION__); */
252 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr & ~0x04);
254 if (!(cpr | 0x02)) {
255 mdelay(1);
256 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
261 static int spitz_mci_get_ro(struct device *dev)
263 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
266 static void spitz_mci_exit(struct device *dev, void *data)
268 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
271 static struct pxamci_platform_data spitz_mci_platform_data = {
272 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
273 .init = spitz_mci_init,
274 .get_ro = spitz_mci_get_ro,
275 .setpower = spitz_mci_setpower,
276 .exit = spitz_mci_exit,
281 * Irda
283 static void spitz_irda_transceiver_mode(struct device *dev, int mode)
285 if (mode & IR_OFF)
286 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
287 else
288 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
291 static struct pxaficp_platform_data spitz_ficp_platform_data = {
292 .transceiver_cap = IR_SIRMODE | IR_OFF,
293 .transceiver_mode = spitz_irda_transceiver_mode,
298 * Spitz PXA Framebuffer
300 static struct pxafb_mach_info spitz_pxafb_info __initdata = {
301 .pixclock = 19231,
302 .xres = 480,
303 .yres = 640,
304 .bpp = 16,
305 .hsync_len = 40,
306 .left_margin = 46,
307 .right_margin = 125,
308 .vsync_len = 3,
309 .upper_margin = 1,
310 .lower_margin = 0,
311 .sync = 0,
312 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
313 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
314 .pxafb_lcd_power = spitz_lcd_power,
318 static struct platform_device *devices[] __initdata = {
319 &spitzscoop_device,
320 &spitzssp_device,
321 &spitzkbd_device,
322 &spitzts_device,
323 &spitzbl_device,
326 static void __init common_init(void)
328 PMCR = 0x00;
330 /* setup sleep mode values */
331 PWER = 0x00000002;
332 PFER = 0x00000000;
333 PRER = 0x00000002;
334 PGSR0 = 0x0158C000;
335 PGSR1 = 0x00FF0080;
336 PGSR2 = 0x0001C004;
338 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
339 PCFR |= PCFR_OPDE;
341 corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
343 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
345 platform_add_devices(devices, ARRAY_SIZE(devices));
346 pxa_set_mci_info(&spitz_mci_platform_data);
347 pxa_set_ficp_info(&spitz_ficp_platform_data);
348 set_pxa_fb_parent(&spitzssp_device.dev);
349 set_pxa_fb_info(&spitz_pxafb_info);
352 static void __init spitz_init(void)
354 scoop_num = 2;
355 scoop_devs = &spitz_pcmcia_scoop[0];
356 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
358 common_init();
360 platform_device_register(&spitzscoop2_device);
363 static void __init fixup_spitz(struct machine_desc *desc,
364 struct tag *tags, char **cmdline, struct meminfo *mi)
366 sharpsl_save_param();
367 mi->nr_banks = 1;
368 mi->bank[0].start = 0xa0000000;
369 mi->bank[0].node = 0;
370 mi->bank[0].size = (64*1024*1024);
373 #ifdef CONFIG_MACH_SPITZ
374 MACHINE_START(SPITZ, "SHARP Spitz")
375 .phys_ram = 0xa0000000,
376 .phys_io = 0x40000000,
377 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
378 .fixup = fixup_spitz,
379 .map_io = pxa_map_io,
380 .init_irq = pxa_init_irq,
381 .init_machine = spitz_init,
382 .timer = &pxa_timer,
383 MACHINE_END
384 #endif
386 #ifdef CONFIG_MACH_BORZOI
387 MACHINE_START(BORZOI, "SHARP Borzoi")
388 .phys_ram = 0xa0000000,
389 .phys_io = 0x40000000,
390 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
391 .fixup = fixup_spitz,
392 .map_io = pxa_map_io,
393 .init_irq = pxa_init_irq,
394 .init_machine = spitz_init,
395 .timer = &pxa_timer,
396 MACHINE_END
397 #endif