Blame view

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