blob: ce2dbdf4ba1a7f5ec794a547fa5e402817cefd12 [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[] = {
Russell Kinga1810992012-01-12 10:25:29 +000042 [0] = DEFINE_RES_MEM(BADGE4_SA1111_BASE, 0x2000),
43 [1] = DEFINE_RES_IRQ(BADGE4_IRQ_GPIO_SA1111),
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
Eric Miao19851c52009-12-26 16:23:02 +080046static struct sa1111_platform_data sa1111_info = {
47 .irq_base = IRQ_BOARD_END,
48};
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050static u64 sa1111_dmamask = 0xffffffffUL;
51
52static struct platform_device sa1111_device = {
53 .name = "sa1111",
54 .id = 0,
55 .dev = {
56 .dma_mask = &sa1111_dmamask,
57 .coherent_dma_mask = 0xffffffff,
Eric Miao19851c52009-12-26 16:23:02 +080058 .platform_data = &sa1111_info,
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 },
60 .num_resources = ARRAY_SIZE(sa1111_resources),
61 .resource = sa1111_resources,
62};
63
64static struct platform_device *devices[] __initdata = {
65 &sa1111_device,
66};
67
68static int __init badge4_sa1111_init(void)
69{
70 /*
71 * Ensure that the memory bus request/grant signals are setup,
72 * and the grant is held in its inactive state
73 */
74 sa1110_mb_disable();
75
76 /*
77 * Probe for SA1111.
78 */
79 return platform_add_devices(devices, ARRAY_SIZE(devices));
80}
81
82
83/*
84 * 1 x Intel 28F320C3 Advanced+ Boot Block Flash (32 Mi bit)
85 * Eight 4 KiW Parameter Bottom Blocks (64 KiB)
86 * Sixty-three 32 KiW Main Blocks (4032 Ki b)
87 *
88 * <or>
89 *
90 * 1 x Intel 28F640C3 Advanced+ Boot Block Flash (64 Mi bit)
91 * Eight 4 KiW Parameter Bottom Blocks (64 KiB)
92 * One-hundred-twenty-seven 32 KiW Main Blocks (8128 Ki b)
93 */
94static struct mtd_partition badge4_partitions[] = {
Kristoffer Ericsonbda03082008-09-29 17:09:10 +010095 {
96 .name = "BLOB boot loader",
97 .offset = 0,
98 .size = 0x0000A000
99 }, {
100 .name = "params",
101 .offset = MTDPART_OFS_APPEND,
102 .size = 0x00006000
103 }, {
104 .name = "root",
105 .offset = MTDPART_OFS_APPEND,
106 .size = MTDPART_SIZ_FULL
107 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108};
109
110static struct flash_platform_data badge4_flash_data = {
111 .map_name = "cfi_probe",
112 .parts = badge4_partitions,
113 .nr_parts = ARRAY_SIZE(badge4_partitions),
114};
115
Russell Kinga1810992012-01-12 10:25:29 +0000116static struct resource badge4_flash_resource =
117 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_64M);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119static int five_v_on __initdata = 0;
120
121static int __init five_v_on_setup(char *ignore)
122{
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100123 five_v_on = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 return 1;
125}
126__setup("five_v_on", five_v_on_setup);
127
128
129static int __init badge4_init(void)
130{
131 int ret;
132
133 if (!machine_is_badge4())
134 return -ENODEV;
135
136 /* LCD */
137 GPCR = (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
138 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
139 BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
140 BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
141 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
142 BADGE4_GPIO_GPC_VID);
143 GPDR &= ~BADGE4_GPIO_INT_VID;
144 GPDR |= (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
145 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
146 BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
147 BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
148 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
149 BADGE4_GPIO_GPC_VID);
150
151 /* SDRAM SPD i2c */
152 GPCR = (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
153 GPDR |= (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
154
155 /* uart */
156 GPCR = (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
157 GPDR |= (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
158
159 /* CPLD muxsel0 input for mux/adc chip select */
160 GPCR = BADGE4_GPIO_MUXSEL0;
161 GPDR |= BADGE4_GPIO_MUXSEL0;
162
163 /* test points: J5, J6 as inputs, J7 outputs */
164 GPDR &= ~(BADGE4_GPIO_TESTPT_J5 | BADGE4_GPIO_TESTPT_J6);
165 GPCR = BADGE4_GPIO_TESTPT_J7;
166 GPDR |= BADGE4_GPIO_TESTPT_J7;
167
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100168 /* 5V supply rail. */
169 GPCR = BADGE4_GPIO_PCMEN5V; /* initially off */
170 GPDR |= BADGE4_GPIO_PCMEN5V;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172 /* CPLD sdram type inputs; set up by blob */
173 //GPDR |= (BADGE4_GPIO_SDTYP1 | BADGE4_GPIO_SDTYP0);
174 printk(KERN_DEBUG __FILE__ ": SDRAM CPLD typ1=%d typ0=%d\n",
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100175 !!(GPLR & BADGE4_GPIO_SDTYP1),
176 !!(GPLR & BADGE4_GPIO_SDTYP0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178 /* SA1111 reset pin; set up by blob */
179 //GPSR = BADGE4_GPIO_SA1111_NRST;
180 //GPDR |= BADGE4_GPIO_SA1111_NRST;
181
182
183 /* power management cruft */
184 PGSR = 0;
185 PWER = 0;
186 PCFR = 0;
187 PSDR = 0;
188
189 PWER |= PWER_GPIO26; /* wake up on an edge from TESTPT_J5 */
190 PWER |= PWER_RTC; /* wake up if rtc fires */
191
192 /* drive sa1111_nrst during sleep */
193 PGSR |= BADGE4_GPIO_SA1111_NRST;
194 /* drive CPLD as is during sleep */
195 PGSR |= (GPLR & (BADGE4_GPIO_SDTYP0|BADGE4_GPIO_SDTYP1));
196
197
198 /* Now bring up the SA-1111. */
199 ret = badge4_sa1111_init();
200 if (ret < 0)
201 printk(KERN_ERR
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100202 "%s: SA-1111 initialization failed (%d)\n",
203 __func__, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205
206 /* maybe turn on 5v0 from the start */
207 badge4_set_5V(BADGE4_5V_INITIALLY, five_v_on);
208
Russell King7a5b4e12009-10-06 14:55:53 +0100209 sa11x0_register_mtd(&badge4_flash_data, &badge4_flash_resource, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
211 return 0;
212}
213
214arch_initcall(badge4_init);
215
216
217static unsigned badge4_5V_bitmap = 0;
218
219void badge4_set_5V(unsigned subsystem, int on)
220{
221 unsigned long flags;
222 unsigned old_5V_bitmap;
223
224 local_irq_save(flags);
225
226 old_5V_bitmap = badge4_5V_bitmap;
227
228 if (on) {
229 badge4_5V_bitmap |= subsystem;
230 } else {
231 badge4_5V_bitmap &= ~subsystem;
232 }
233
234 /* detect on->off and off->on transitions */
235 if ((!old_5V_bitmap) && (badge4_5V_bitmap)) {
236 /* was off, now on */
Harvey Harrison8e86f422008-03-04 15:08:02 -0800237 printk(KERN_INFO "%s: enabling 5V supply rail\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 GPSR = BADGE4_GPIO_PCMEN5V;
239 } else if ((old_5V_bitmap) && (!badge4_5V_bitmap)) {
240 /* was on, now off */
Harvey Harrison8e86f422008-03-04 15:08:02 -0800241 printk(KERN_INFO "%s: disabling 5V supply rail\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 GPCR = BADGE4_GPIO_PCMEN5V;
243 }
244
245 local_irq_restore(flags);
246}
247EXPORT_SYMBOL(badge4_set_5V);
248
249
250static struct map_desc badge4_io_desc[] __initdata = {
Kristoffer Ericsonbda03082008-09-29 17:09:10 +0100251 { /* SRAM bank 1 */
Deepak Saxena92519d82005-10-28 15:19:04 +0100252 .virtual = 0xf1000000,
253 .pfn = __phys_to_pfn(0x08000000),
254 .length = 0x00100000,
255 .type = MT_DEVICE
256 }, { /* SRAM bank 2 */
257 .virtual = 0xf2000000,
258 .pfn = __phys_to_pfn(0x10000000),
259 .length = 0x00100000,
260 .type = MT_DEVICE
261 }, { /* SA-1111 */
262 .virtual = 0xf4000000,
263 .pfn = __phys_to_pfn(0x48000000),
264 .length = 0x00100000,
265 .type = MT_DEVICE
266 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267};
268
269static void
270badge4_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
271{
272 if (!state) {
273 Ser1SDCR0 |= SDCR0_UART;
274 }
275}
276
277static struct sa1100_port_fns badge4_port_fns __initdata = {
278 //.get_mctrl = badge4_get_mctrl,
279 //.set_mctrl = badge4_set_mctrl,
280 .pm = badge4_uart_pm,
281};
282
283static void __init badge4_map_io(void)
284{
285 sa1100_map_io();
286 iotable_init(badge4_io_desc, ARRAY_SIZE(badge4_io_desc));
287
288 sa1100_register_uart_fns(&badge4_port_fns);
289 sa1100_register_uart(0, 3);
290 sa1100_register_uart(1, 1);
291}
292
293MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
Nicolas Pitre17f44252011-07-05 22:38:17 -0400294 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100295 .map_io = badge4_map_io,
296 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 .timer = &sa1100_timer,
Nicolas Pitree9107ab2011-07-05 22:28:09 -0400298#ifdef CONFIG_SA1111
299 .dma_zone_size = SZ_1M,
300#endif
Russell Kingd9ca5832011-11-05 10:28:50 +0000301 .restart = sa11x0_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302MACHINE_END