blob: 6d413f6701a77ebd8afdeba39ec4a09fd1118081 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-pxa/poodle.c
3 *
4 * Support for the SHARP Poodle Board.
5 *
6 * Based on:
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
8 *
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.
12 *
13 * Change Log
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/device.h>
20#include <linux/fb.h>
21
22#include <asm/hardware.h>
23#include <asm/mach-types.h>
24#include <asm/irq.h>
25#include <asm/setup.h>
26
27#include <asm/mach/arch.h>
28#include <asm/mach/map.h>
29#include <asm/mach/irq.h>
30
31#include <asm/arch/pxa-regs.h>
32#include <asm/arch/irq.h>
Richard Purdie13b9d472005-09-15 14:53:22 +010033#include <asm/arch/mmc.h>
34#include <asm/arch/udc.h>
Richard Purdie8e4b8712005-10-30 14:38:52 +000035#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <asm/arch/poodle.h>
37#include <asm/arch/pxafb.h>
38
39#include <asm/hardware/scoop.h>
40#include <asm/hardware/locomo.h>
41#include <asm/mach/sharpsl_param.h>
42
43#include "generic.h"
44
45static struct resource poodle_scoop_resources[] = {
46 [0] = {
47 .start = 0x10800000,
48 .end = 0x10800fff,
49 .flags = IORESOURCE_MEM,
50 },
51};
52
53static struct scoop_config poodle_scoop_setup = {
54 .io_dir = POODLE_SCOOP_IO_DIR,
55 .io_out = POODLE_SCOOP_IO_OUT,
56};
57
58struct platform_device poodle_scoop_device = {
59 .name = "sharp-scoop",
60 .id = -1,
61 .dev = {
62 .platform_data = &poodle_scoop_setup,
63 },
64 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
65 .resource = poodle_scoop_resources,
66};
67
Richard Purdie0ce76252005-09-05 20:49:54 +010068static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
69{
70 .dev = &poodle_scoop_device.dev,
71 .irq = POODLE_IRQ_GPIO_CF_IRQ,
72 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
73 .cd_irq_str = "PCMCIA0 CD",
74},
75};
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78/* LoCoMo device */
79static struct resource locomo_resources[] = {
80 [0] = {
81 .start = 0x10000000,
82 .end = 0x10001fff,
83 .flags = IORESOURCE_MEM,
84 },
85 [1] = {
86 .start = IRQ_GPIO(10),
87 .end = IRQ_GPIO(10),
88 .flags = IORESOURCE_IRQ,
89 },
90};
91
92static struct platform_device locomo_device = {
93 .name = "locomo",
94 .id = 0,
95 .num_resources = ARRAY_SIZE(locomo_resources),
96 .resource = locomo_resources,
97};
98
Richard Purdie13b9d472005-09-15 14:53:22 +010099
100/*
101 * MMC/SD Device
102 *
103 * The card detect interrupt isn't debounced so we delay it by 250ms
104 * to give the card a chance to fully insert/eject.
105 */
106static struct pxamci_platform_data poodle_mci_platform_data;
107
108static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
109{
110 int err;
111
112 /* setup GPIO for PXA25x MMC controller */
113 pxa_gpio_mode(GPIO6_MMCCLK_MD);
114 pxa_gpio_mode(GPIO8_MMCCS0_MD);
115 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
116 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
117
118 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
119
120 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, SA_INTERRUPT,
121 "MMC card detect", data);
122 if (err) {
123 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
124 return -1;
125 }
126
127 set_irq_type(POODLE_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
128
129 return 0;
130}
131
132static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
133{
134 struct pxamci_platform_data* p_d = dev->platform_data;
135
136 if (( 1 << vdd) & p_d->ocr_mask)
137 GPSR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
138 else
139 GPCR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
140}
141
142static void poodle_mci_exit(struct device *dev, void *data)
143{
144 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
145}
146
147static struct pxamci_platform_data poodle_mci_platform_data = {
148 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
149 .init = poodle_mci_init,
150 .setpower = poodle_mci_setpower,
151 .exit = poodle_mci_exit,
152};
153
154
155/*
Richard Purdie8e4b8712005-10-30 14:38:52 +0000156 * Irda
157 */
158static void poodle_irda_transceiver_mode(struct device *dev, int mode)
159{
160 if (mode & IR_OFF) {
161 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
162 } else {
163 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
164 }
165}
166
167static struct pxaficp_platform_data poodle_ficp_platform_data = {
168 .transceiver_cap = IR_SIRMODE | IR_OFF,
169 .transceiver_mode = poodle_irda_transceiver_mode,
170};
171
172
173/*
Richard Purdie13b9d472005-09-15 14:53:22 +0100174 * USB Device Controller
175 */
176static void poodle_udc_command(int cmd)
177{
178 switch(cmd) {
179 case PXA2XX_UDC_CMD_CONNECT:
180 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
181 break;
182 case PXA2XX_UDC_CMD_DISCONNECT:
183 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
184 break;
185 }
186}
187
188static struct pxa2xx_udc_mach_info udc_info __initdata = {
189 /* no connect GPIO; poodle can't tell connection status */
190 .udc_command = poodle_udc_command,
191};
192
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194/* PXAFB device */
195static struct pxafb_mach_info poodle_fb_info __initdata = {
196 .pixclock = 144700,
197
198 .xres = 320,
199 .yres = 240,
200 .bpp = 16,
201
202 .hsync_len = 7,
203 .left_margin = 11,
204 .right_margin = 30,
205
206 .vsync_len = 2,
207 .upper_margin = 2,
208 .lower_margin = 0,
209 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
210
211 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
212 .lccr3 = 0,
213
214 .pxafb_backlight_power = NULL,
215 .pxafb_lcd_power = NULL,
216};
217
218static struct platform_device *devices[] __initdata = {
219 &locomo_device,
220 &poodle_scoop_device,
221};
222
223static void __init poodle_init(void)
224{
225 int ret = 0;
226
Richard Purdief29d2452005-09-15 14:53:22 +0100227 /* setup sleep mode values */
228 PWER = 0x00000002;
229 PFER = 0x00000000;
230 PRER = 0x00000002;
231 PGSR0 = 0x00008000;
232 PGSR1 = 0x003F0202;
233 PGSR2 = 0x0001C000;
234 PCFR |= PCFR_OPDE;
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 /* cpu initialize */
237 /* Pgsr Register */
238 PGSR0 = 0x0146dd80;
239 PGSR1 = 0x03bf0890;
240 PGSR2 = 0x0001c000;
241
242 /* Alternate Register */
243 GAFR0_L = 0x01001000;
244 GAFR0_U = 0x591a8010;
245 GAFR1_L = 0x900a8451;
246 GAFR1_U = 0xaaa5aaaa;
247 GAFR2_L = 0x8aaaaaaa;
248 GAFR2_U = 0x00000002;
249
250 /* Direction Register */
251 GPDR0 = 0xd3f0904c;
252 GPDR1 = 0xfcffb7d3;
253 GPDR2 = 0x0001ffff;
254
255 /* Output Register */
256 GPCR0 = 0x00000000;
257 GPCR1 = 0x00000000;
258 GPCR2 = 0x00000000;
259
260 GPSR0 = 0x00400000;
261 GPSR1 = 0x00000000;
262 GPSR2 = 0x00000000;
263
264 set_pxa_fb_info(&poodle_fb_info);
Richard Purdie13b9d472005-09-15 14:53:22 +0100265 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000266 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100267 pxa_set_udc_info(&udc_info);
268 pxa_set_mci_info(&poodle_mci_platform_data);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000269 pxa_set_ficp_info(&poodle_ficp_platform_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Richard Purdie0ce76252005-09-05 20:49:54 +0100271 scoop_num = 1;
272 scoop_devs = &poodle_pcmcia_scoop[0];
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
275 if (ret) {
276 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
277 }
278}
279
280static void __init fixup_poodle(struct machine_desc *desc,
281 struct tag *tags, char **cmdline, struct meminfo *mi)
282{
283 sharpsl_save_param();
284}
285
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286MACHINE_START(POODLE, "SHARP Poodle")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100287 .phys_ram = 0xa0000000,
288 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100289 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100290 .fixup = fixup_poodle,
Richard Purdief29d2452005-09-15 14:53:22 +0100291 .map_io = pxa_map_io,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100292 .init_irq = pxa_init_irq,
293 .timer = &pxa_timer,
294 .init_machine = poodle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295MACHINE_END