blob: 8fb80f02c2a922cdbc7728cb1efee3215640e6bb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-sa1100/badge4.c
3 *
4 * BadgePAD 4 specific initialization
5 *
6 * Tim Connors <connors@hpl.hp.com>
7 * Christopher Hoover <ch@hpl.hp.com>
8 *
9 * Copyright (C) 2002 Hewlett-Packard Company
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 */
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/kernel.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010019#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/delay.h>
21#include <linux/tty.h>
22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h>
24#include <linux/errno.h>
25
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <asm/mach-types.h>
28#include <asm/setup.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/irqs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#include <asm/mach/arch.h>
32#include <asm/mach/flash.h>
33#include <asm/mach/map.h>
34#include <asm/hardware/sa1111.h>
35#include <asm/mach/serial_sa1100.h>
36
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/badge4.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#include "generic.h"
40
41static struct resource sa1111_resources[] = {
42 [0] = {
43 .start = BADGE4_SA1111_BASE,
44 .end = BADGE4_SA1111_BASE + 0x00001fff,
45 .flags = IORESOURCE_MEM,
46 },
47 [1] = {
48 .start = BADGE4_IRQ_GPIO_SA1111,
49 .end = BADGE4_IRQ_GPIO_SA1111,
50 .flags = IORESOURCE_IRQ,
51 },
52};
53
Russell King32597012012-01-26 13:28:35 +000054static int badge4_sa1111_enable(void *data, unsigned devid)
55{
56 if (devid == SA1111_DEVID_USB)
57 badge4_set_5V(BADGE4_5V_USB, 1);
58 return 0;
59}
60
61static void badge4_sa1111_disable(void *data, unsigned devid)
62{
63 if (devid == SA1111_DEVID_USB)
64 badge4_set_5V(BADGE4_5V_USB, 0);
65}
66
Eric Miao19851c52009-12-26 16:23:02 +080067static struct sa1111_platform_data sa1111_info = {
68 .irq_base = IRQ_BOARD_END,
Russell King07be45f2012-01-26 13:34:21 +000069 .disable_devs = SA1111_DEVID_PS2_MSE,
Russell King32597012012-01-26 13:28:35 +000070 .enable = badge4_sa1111_enable,
71 .disable = badge4_sa1111_disable,
Eric Miao19851c52009-12-26 16:23:02 +080072};
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static u64 sa1111_dmamask = 0xffffffffUL;
75
76static struct platform_device sa1111_device = {
77 .name = "sa1111",
78 .id = 0,
79 .dev = {
80 .dma_mask = &sa1111_dmamask,
81 .coherent_dma_mask = 0xffffffff,
Eric Miao19851c52009-12-26 16:23:02 +080082 .platform_data = &sa1111_info,
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 },
84 .num_resources = ARRAY_SIZE(sa1111_resources),
85 .resource = sa1111_resources,
86};
87
88static struct platform_device *devices[] __initdata = {
89 &sa1111_device,
90};
91
92static int __init badge4_sa1111_init(void)
93{
94 /*
95 * Ensure that the memory bus request/grant signals are setup,
96 * and the grant is held in its inactive state
97 */
98 sa1110_mb_disable();
99
100 /*
101 * Probe for SA1111.
102 */
103 return platform_add_devices(devices, ARRAY_SIZE(devices));
104}
105
106
107/*
108 * 1 x Intel 28F320C3 Advanced+ Boot Block Flash (32 Mi bit)
109 * Eight 4 KiW Parameter Bottom Blocks (64 KiB)
110 * Sixty-three 32 KiW Main Blocks (4032 Ki b)
111 *
112 * <or>
113 *
114 * 1 x Intel 28F640C3 Advanced+ Boot Block Flash (64 Mi bit)
115 * Eight 4 KiW Parameter Bottom Blocks (64 KiB)
116 * One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b)
117 */
118static struct mtd_partition badge4_partitions[] = {
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100119 {
120 .name = "BLOB boot loader",
121 .offset = 0,
122 .size = 0x0000A000
123 }, {
124 .name = "params",
125 .offset = MTDPART_OFS_APPEND,
126 .size = 0x00006000
127 }, {
128 .name = "root",
129 .offset = MTDPART_OFS_APPEND,
130 .size = MTDPART_SIZ_FULL
131 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132};
133
134static struct flash_platform_data badge4_flash_data = {
135 .map_name = "cfi_probe",
136 .parts = badge4_partitions,
137 .nr_parts = ARRAY_SIZE(badge4_partitions),
138};
139
140static struct resource badge4_flash_resource = {
141 .start = SA1100_CS0_PHYS,
142 .end = SA1100_CS0_PHYS + SZ_64M - 1,
143 .flags = IORESOURCE_MEM,
144};
145
146static int five_v_on __initdata = 0;
147
148static int __init five_v_on_setup(char *ignore)
149{
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100150 five_v_on = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 return 1;
152}
153__setup("five_v_on", five_v_on_setup);
154
155
156static int __init badge4_init(void)
157{
158 int ret;
159
160 if (!machine_is_badge4())
161 return -ENODEV;
162
163 /* LCD */
164 GPCR = (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
165 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
166 BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
167 BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
168 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
169 BADGE4_GPIO_GPC_VID);
170 GPDR &= ~BADGE4_GPIO_INT_VID;
171 GPDR |= (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
172 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
173 BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
174 BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
175 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
176 BADGE4_GPIO_GPC_VID);
177
178 /* SDRAM SPD i2c */
179 GPCR = (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
180 GPDR |= (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
181
182 /* uart */
183 GPCR = (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
184 GPDR |= (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
185
186 /* CPLD muxsel0 input for mux/adc chip select */
187 GPCR = BADGE4_GPIO_MUXSEL0;
188 GPDR |= BADGE4_GPIO_MUXSEL0;
189
190 /* test points: J5, J6 as inputs, J7 outputs */
191 GPDR &= ~(BADGE4_GPIO_TESTPT_J5 | BADGE4_GPIO_TESTPT_J6);
192 GPCR = BADGE4_GPIO_TESTPT_J7;
193 GPDR |= BADGE4_GPIO_TESTPT_J7;
194
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100195 /* 5V supply rail. */
196 GPCR = BADGE4_GPIO_PCMEN5V; /* initially off */
197 GPDR |= BADGE4_GPIO_PCMEN5V;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 /* CPLD sdram type inputs; set up by blob */
200 //GPDR |= (BADGE4_GPIO_SDTYP1 | BADGE4_GPIO_SDTYP0);
201 printk(KERN_DEBUG __FILE__ ": SDRAM CPLD typ1=%d typ0=%d\n",
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100202 !!(GPLR & BADGE4_GPIO_SDTYP1),
203 !!(GPLR & BADGE4_GPIO_SDTYP0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205 /* SA1111 reset pin; set up by blob */
206 //GPSR = BADGE4_GPIO_SA1111_NRST;
207 //GPDR |= BADGE4_GPIO_SA1111_NRST;
208
209
210 /* power management cruft */
211 PGSR = 0;
212 PWER = 0;
213 PCFR = 0;
214 PSDR = 0;
215
216 PWER |= PWER_GPIO26; /* wake up on an edge from TESTPT_J5 */
217 PWER |= PWER_RTC; /* wake up if rtc fires */
218
219 /* drive sa1111_nrst during sleep */
220 PGSR |= BADGE4_GPIO_SA1111_NRST;
221 /* drive CPLD as is during sleep */
222 PGSR |= (GPLR & (BADGE4_GPIO_SDTYP0|BADGE4_GPIO_SDTYP1));
223
224
225 /* Now bring up the SA-1111. */
226 ret = badge4_sa1111_init();
227 if (ret < 0)
228 printk(KERN_ERR
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100229 "%s: SA-1111 initialization failed (%d)\n",
230 __func__, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232
233 /* maybe turn on 5v0 from the start */
234 badge4_set_5V(BADGE4_5V_INITIALLY, five_v_on);
235
Russell King7a5b4e12009-10-06 14:55:53 +0100236 sa11x0_register_mtd(&badge4_flash_data, &badge4_flash_resource, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 return 0;
239}
240
241arch_initcall(badge4_init);
242
243
244static unsigned badge4_5V_bitmap = 0;
245
246void badge4_set_5V(unsigned subsystem, int on)
247{
248 unsigned long flags;
249 unsigned old_5V_bitmap;
250
251 local_irq_save(flags);
252
253 old_5V_bitmap = badge4_5V_bitmap;
254
255 if (on) {
256 badge4_5V_bitmap |= subsystem;
257 } else {
258 badge4_5V_bitmap &= ~subsystem;
259 }
260
261 /* detect on->off and off->on transitions */
262 if ((!old_5V_bitmap) && (badge4_5V_bitmap)) {
263 /* was off, now on */
Harvey Harrison8e86f422008-03-04 15:08:02 -0800264 printk(KERN_INFO "%s: enabling 5V supply rail\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 GPSR = BADGE4_GPIO_PCMEN5V;
266 } else if ((old_5V_bitmap) && (!badge4_5V_bitmap)) {
267 /* was on, now off */
Harvey Harrison8e86f422008-03-04 15:08:02 -0800268 printk(KERN_INFO "%s: disabling 5V supply rail\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 GPCR = BADGE4_GPIO_PCMEN5V;
270 }
271
272 local_irq_restore(flags);
273}
274EXPORT_SYMBOL(badge4_set_5V);
275
276
277static struct map_desc badge4_io_desc[] __initdata = {
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100278 { /* SRAM bank 1 */
Deepak Saxena92519d82005-10-28 15:19:04 +0100279 .virtual = 0xf1000000,
280 .pfn = __phys_to_pfn(0x08000000),
281 .length = 0x00100000,
282 .type = MT_DEVICE
283 }, { /* SRAM bank 2 */
284 .virtual = 0xf2000000,
285 .pfn = __phys_to_pfn(0x10000000),
286 .length = 0x00100000,
287 .type = MT_DEVICE
288 }, { /* SA-1111 */
289 .virtual = 0xf4000000,
290 .pfn = __phys_to_pfn(0x48000000),
291 .length = 0x00100000,
292 .type = MT_DEVICE
293 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294};
295
296static void
297badge4_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
298{
299 if (!state) {
300 Ser1SDCR0 |= SDCR0_UART;
301 }
302}
303
304static struct sa1100_port_fns badge4_port_fns __initdata = {
305 //.get_mctrl = badge4_get_mctrl,
306 //.set_mctrl = badge4_set_mctrl,
307 .pm = badge4_uart_pm,
308};
309
310static void __init badge4_map_io(void)
311{
312 sa1100_map_io();
313 iotable_init(badge4_io_desc, ARRAY_SIZE(badge4_io_desc));
314
315 sa1100_register_uart_fns(&badge4_port_fns);
316 sa1100_register_uart(0, 3);
317 sa1100_register_uart(1, 1);
318}
319
320MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
Nicolas Pitre17f44252011-07-05 22:38:17 -0400321 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100322 .map_io = badge4_map_io,
323 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 .timer = &sa1100_timer,
Nicolas Pitree9107ab2011-07-05 22:28:09 -0400325#ifdef CONFIG_SA1111
326 .dma_zone_size = SZ_1M,
327#endif
Russell Kingd9ca5832011-11-05 10:28:50 +0000328 .restart = sa11x0_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329MACHINE_END