Blame view

arch/arm/mach-sa1100/collie.c 9.08 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
   * linux/arch/arm/mach-sa1100/collie.c
   *
   * May be copied or modified under the terms of the GNU General Public
   * License.  See linux/COPYING for more information.
   *
   * This file contains all Collie-specific tweaks.
   *
   * 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.
   *
   * ChangeLog:
a2531293d   Pavel Machek   update email address
14
   *  2006 Pavel Machek <pavel@ucw.cz>
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
15
   *  03-06-2004 John Lenz <lenz@cs.wisc.edu>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
18
   *  06-04-2002 Chris Larson <kergoth@digitalnemesis.net>
   *  04-16-2001 Lineo Japan,Inc. ...
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
22
  #include <linux/init.h>
  #include <linux/kernel.h>
  #include <linux/tty.h>
  #include <linux/delay.h>
d052d1bef   Russell King   Create platform_d...
23
  #include <linux/platform_device.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
26
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
  #include <linux/timer.h>
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
27
  #include <linux/gpio.h>
9823b2d0f   Thomas Kunze   collie: support p...
28
  #include <linux/pda_power.h>
5dd7bf59e   Jochen Friedrich   ARM: sa11x0: Impl...
29
  #include <linux/mfd/ucb1x00.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

a09e64fbc   Russell King   [ARM] Move includ...
31
  #include <mach/hardware.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
33
  #include <asm/mach-types.h>
  #include <asm/irq.h>
9e54d33fb   Paul Gortmaker   arm: fix implicit...
34
  #include <asm/page.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
  #include <asm/setup.h>
a09e64fbc   Russell King   [ARM] Move includ...
36
  #include <mach/collie.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
41
42
43
44
45
  
  #include <asm/mach/arch.h>
  #include <asm/mach/flash.h>
  #include <asm/mach/map.h>
  #include <asm/mach/serial_sa1100.h>
  
  #include <asm/hardware/scoop.h>
  #include <asm/mach/sharpsl_param.h>
  #include <asm/hardware/locomo.h>
a09e64fbc   Russell King   [ARM] Move includ...
46
  #include <mach/mcp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  
  #include "generic.h"
  
  static struct resource collie_scoop_resources[] = {
  	[0] = {
  		.start		= 0x40800000,
  		.end		= 0x40800fff,
  		.flags		= IORESOURCE_MEM,
  	},
  };
  
  static struct scoop_config collie_scoop_setup = {
  	.io_dir 	= COLLIE_SCOOP_IO_DIR,
  	.io_out		= COLLIE_SCOOP_IO_OUT,
f151ccf76   Thomas Kunze   collie: fix scoop...
61
  	.gpio_base	= COLLIE_SCOOP_GPIO_BASE,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
64
65
66
67
68
69
70
71
72
  };
  
  struct platform_device colliescoop_device = {
  	.name		= "sharp-scoop",
  	.id		= -1,
  	.dev		= {
   		.platform_data	= &collie_scoop_setup,
  	},
  	.num_resources	= ARRAY_SIZE(collie_scoop_resources),
  	.resource	= collie_scoop_resources,
  };
44575b2f0   Pavel Machek   [PATCH] collie: f...
73
  static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
74
75
76
77
78
79
  	{
  	.dev		= &colliescoop_device.dev,
  	.irq		= COLLIE_IRQ_GPIO_CF_IRQ,
  	.cd_irq		= COLLIE_IRQ_GPIO_CF_CD,
  	.cd_irq_str	= "PCMCIA0 CD",
  	},
44575b2f0   Pavel Machek   [PATCH] collie: f...
80
81
82
  };
  
  static struct scoop_pcmcia_config collie_pcmcia_config = {
93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
83
84
  	.devs		= &collie_pcmcia_scoop[0],
  	.num_devs	= 1,
44575b2f0   Pavel Machek   [PATCH] collie: f...
85
  };
5dd7bf59e   Jochen Friedrich   ARM: sa11x0: Impl...
86
87
88
  static struct ucb1x00_plat_data collie_ucb1x00_data = {
  	.gpio_base	= COLLIE_TC35143_GPIO_BASE,
  };
44575b2f0   Pavel Machek   [PATCH] collie: f...
89
  static struct mcp_plat_data collie_mcp_data = {
93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
90
91
  	.mccr0		= MCCR0_ADM | MCCR0_ExtClk,
  	.sclk_rate	= 9216000,
5dd7bf59e   Jochen Friedrich   ARM: sa11x0: Impl...
92
93
  	.codec		= "ucb1x00",
  	.codec_pdata	= &collie_ucb1x00_data,
44575b2f0   Pavel Machek   [PATCH] collie: f...
94
  };
9823b2d0f   Thomas Kunze   collie: support p...
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
  /*
   * Collie AC IN
   */
  static int collie_power_init(struct device *dev)
  {
  	int ret = gpio_request(COLLIE_GPIO_AC_IN, "ac in");
  	if (ret)
  		goto err_gpio_req;
  
  	ret = gpio_direction_input(COLLIE_GPIO_AC_IN);
  	if (ret)
  		goto err_gpio_in;
  
  	return 0;
  
  err_gpio_in:
  	gpio_free(COLLIE_GPIO_AC_IN);
  err_gpio_req:
  	return ret;
  }
  
  static void collie_power_exit(struct device *dev)
  {
  	gpio_free(COLLIE_GPIO_AC_IN);
  }
  
  static int collie_power_ac_online(void)
  {
  	return gpio_get_value(COLLIE_GPIO_AC_IN) == 2;
  }
  
  static char *collie_ac_supplied_to[] = {
  	"main-battery",
  	"backup-battery",
  };
  
  static struct pda_power_pdata collie_power_data = {
  	.init			= collie_power_init,
  	.is_ac_online		= collie_power_ac_online,
  	.exit			= collie_power_exit,
  	.supplied_to		= collie_ac_supplied_to,
  	.num_supplicants	= ARRAY_SIZE(collie_ac_supplied_to),
  };
  
  static struct resource collie_power_resource[] = {
  	{
  		.name		= "ac",
  		.start		= gpio_to_irq(COLLIE_GPIO_AC_IN),
  		.end		= gpio_to_irq(COLLIE_GPIO_AC_IN),
  		.flags		= IORESOURCE_IRQ |
  				  IORESOURCE_IRQ_HIGHEDGE |
  				  IORESOURCE_IRQ_LOWEDGE,
  	},
  };
  
  static struct platform_device collie_power_device = {
  	.name			= "pda-power",
  	.id			= -1,
  	.dev.platform_data	= &collie_power_data,
  	.resource		= collie_power_resource,
  	.num_resources		= ARRAY_SIZE(collie_power_resource),
44575b2f0   Pavel Machek   [PATCH] collie: f...
156
  };
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
157
158
159
160
  #ifdef CONFIG_SHARP_LOCOMO
  /*
   * low-level UART features.
   */
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
161
  struct platform_device collie_locomo_device;
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
162
163
164
  
  static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
  {
93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
165
  	if (mctrl & TIOCM_RTS)
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
166
  		locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 0);
93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
167
  	else
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
168
  		locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_RTS, 1);
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
169

93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
170
  	if (mctrl & TIOCM_DTR)
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
171
  		locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 0);
93982535a   Kristoffer Ericson   [ARM] 5336/1: For...
172
  	else
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
173
  		locomo_gpio_write(&collie_locomo_device.dev, LOCOMO_GPIO_DTR, 1);
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
174
175
176
177
178
179
  }
  
  static u_int collie_uart_get_mctrl(struct uart_port *port)
  {
  	int ret = TIOCM_CD;
  	unsigned int r;
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
180

8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
181
182
183
  	r = locomo_gpio_read_output(&collie_locomo_device.dev, LOCOMO_GPIO_CTS & LOCOMO_GPIO_DSR);
  	if (r == -ENODEV)
  		return ret;
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
184
185
186
187
188
189
190
  	if (r & LOCOMO_GPIO_CTS)
  		ret |= TIOCM_CTS;
  	if (r & LOCOMO_GPIO_DSR)
  		ret |= TIOCM_DSR;
  
  	return ret;
  }
44575b2f0   Pavel Machek   [PATCH] collie: f...
191
192
193
194
195
  
  static struct sa1100_port_fns collie_port_fns __initdata = {
  	.set_mctrl	= collie_uart_set_mctrl,
  	.get_mctrl	= collie_uart_get_mctrl,
  };
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
196
197
  static int collie_uart_probe(struct locomo_dev *dev)
  {
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
198
199
200
201
202
  	return 0;
  }
  
  static int collie_uart_remove(struct locomo_dev *dev)
  {
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
203
204
205
206
207
208
209
210
211
212
213
  	return 0;
  }
  
  static struct locomo_driver collie_uart_driver = {
  	.drv = {
  		.name = "collie_uart",
  	},
  	.devid	= LOCOMO_DEVID_UART,
  	.probe	= collie_uart_probe,
  	.remove	= collie_uart_remove,
  };
e63cedb65   Russell King   [ARM] collie: fix...
214
215
  static int __init collie_uart_init(void)
  {
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
216
217
218
219
220
  	return locomo_driver_register(&collie_uart_driver);
  }
  device_initcall(collie_uart_init);
  
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
221
222
223
224
225
226
227
228
229
230
231
232
233
  
  static struct resource locomo_resources[] = {
  	[0] = {
  		.start		= 0x40000000,
  		.end		= 0x40001fff,
  		.flags		= IORESOURCE_MEM,
  	},
  	[1] = {
  		.start		= IRQ_GPIO25,
  		.end		= IRQ_GPIO25,
  		.flags		= IORESOURCE_IRQ,
  	},
  };
ac609d266   Eric Miao   [ARM] locomo: all...
234
235
236
  static struct locomo_platform_data locomo_info = {
  	.irq_base	= IRQ_BOARD_START,
  };
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
237
  struct platform_device collie_locomo_device = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
238
239
  	.name		= "locomo",
  	.id		= 0,
34cd2d38d   Dmitry Eremin-Solenikov   ARM: 6658/1: coll...
240
241
242
  	.dev		= {
  		.platform_data	= &locomo_info,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243
244
245
246
247
  	.num_resources	= ARRAY_SIZE(locomo_resources),
  	.resource	= locomo_resources,
  };
  
  static struct platform_device *devices[] __initdata = {
8d48427ec   Richard Purdie   [ARM] 3847/2: Co...
248
  	&collie_locomo_device,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
249
  	&colliescoop_device,
9823b2d0f   Thomas Kunze   collie: support p...
250
  	&collie_power_device,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
  };
  
  static struct mtd_partition collie_partitions[] = {
  	{
  		.name		= "bootloader",
  		.offset 	= 0,
  		.size		= 0x000C0000,
  		.mask_flags	= MTD_WRITEABLE
  	}, {
  		.name		= "kernel",
  		.offset 	= MTDPART_OFS_APPEND,
  		.size		= 0x00100000,
  	}, {
  		.name		= "rootfs",
  		.offset 	= MTDPART_OFS_APPEND,
  		.size		= 0x00e20000,
  	}
  };
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
269
270
  static int collie_flash_init(void)
  {
e63cedb65   Russell King   [ARM] collie: fix...
271
  	int rc = gpio_request(COLLIE_GPIO_VPEN, "flash Vpp enable");
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
272
273
274
275
276
277
278
279
280
  	if (rc)
  		return rc;
  
  	rc = gpio_direction_output(COLLIE_GPIO_VPEN, 1);
  	if (rc)
  		gpio_free(COLLIE_GPIO_VPEN);
  
  	return rc;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
281
282
  static void collie_set_vpp(int vpp)
  {
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
283
  	gpio_set_value(COLLIE_GPIO_VPEN, vpp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
284
  }
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
285
286
287
288
  static void collie_flash_exit(void)
  {
  	gpio_free(COLLIE_GPIO_VPEN);
  }
e63cedb65   Russell King   [ARM] collie: fix...
289

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
290
291
  static struct flash_platform_data collie_flash_data = {
  	.map_name	= "cfi_probe",
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
292
  	.init		= collie_flash_init,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
293
  	.set_vpp	= collie_set_vpp,
224be092d   Dmitry Eremin-Solenikov   [ARM] 5429/1: col...
294
  	.exit		= collie_flash_exit,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
  	.parts		= collie_partitions,
  	.nr_parts	= ARRAY_SIZE(collie_partitions),
  };
  
  static struct resource collie_flash_resources[] = {
  	{
  		.start	= SA1100_CS0_PHYS,
  		.end	= SA1100_CS0_PHYS + SZ_32M - 1,
  		.flags	= IORESOURCE_MEM,
  	}
  };
  
  static void __init collie_init(void)
  {
  	int ret = 0;
  
  	/* cpu initialize */
864d0ec9d   Thomas Kunze   [ARM] 5025/2: fix...
312
313
314
315
316
317
  	GAFR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SSP_CLK |
  		GPIO_MCP_CLK | GPIO_32_768kHz;
  
  	GPDR = GPIO_LDD8 | GPIO_LDD9 | GPIO_LDD10 | GPIO_LDD11 | GPIO_LDD12 |
  		GPIO_LDD13 | GPIO_LDD14 | GPIO_LDD15 | GPIO_SSP_TXD |
  		GPIO_SSP_SCLK | GPIO_SSP_SFRM | GPIO_SDLC_SCLK |
1d0ad843b   Thomas Kunze   collie: prepare f...
318
319
  		_COLLIE_GPIO_UCB1x00_RESET | _COLLIE_GPIO_nMIC_ON |
  		_COLLIE_GPIO_nREMOCON_ON | GPIO_32_768kHz;
864d0ec9d   Thomas Kunze   [ARM] 5025/2: fix...
320
321
322
323
  
  	PPDR = PPC_LDD0 | PPC_LDD1 | PPC_LDD2 | PPC_LDD3 | PPC_LDD4 | PPC_LDD5 |
  		PPC_LDD6 | PPC_LDD7 | PPC_L_PCLK | PPC_L_LCLK | PPC_L_FCLK | PPC_L_BIAS |
  		PPC_TXD1 | PPC_TXD2 | PPC_TXD3 | PPC_TXD4 | PPC_SCLK | PPC_SFRM;
1d0ad843b   Thomas Kunze   collie: prepare f...
324
325
  	PWER = _COLLIE_GPIO_AC_IN | _COLLIE_GPIO_CO | _COLLIE_GPIO_ON_KEY |
  		_COLLIE_GPIO_WAKEUP | _COLLIE_GPIO_nREMOCON_INT | PWER_RTC;
864d0ec9d   Thomas Kunze   [ARM] 5025/2: fix...
326

1d0ad843b   Thomas Kunze   collie: prepare f...
327
  	PGSR = _COLLIE_GPIO_nREMOCON_ON;
864d0ec9d   Thomas Kunze   [ARM] 5025/2: fix...
328
329
330
331
  
  	PSDR = PPC_RXD1 | PPC_RXD2 | PPC_RXD3 | PPC_RXD4;
  
  	PCFR = PCFR_OPDE;
1d0ad843b   Thomas Kunze   collie: prepare f...
332
  	GPSR |= _COLLIE_GPIO_UCB1x00_RESET;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
333

44575b2f0   Pavel Machek   [PATCH] collie: f...
334
  	platform_scoop_config = &collie_pcmcia_config;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
335
336
337
338
339
  	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  	if (ret) {
  		printk(KERN_WARNING "collie: Unable to register LoCoMo device
  ");
  	}
7a5b4e16c   Russell King   ARM: sa11x0: conv...
340
341
  	sa11x0_register_mtd(&collie_flash_data, collie_flash_resources,
  			    ARRAY_SIZE(collie_flash_resources));
af9081ae6   Jochen Friedrich   ARM: sa1100: Refa...
342
343
344
345
346
347
348
349
350
  
  	/*
  	 * Setup the PPC unit correctly.
  	 */
  	PPDR &= ~PPC_RXD4;
  	PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
  	PSDR |= PPC_RXD4;
  	PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
  	PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
7a5b4e16c   Russell King   ARM: sa11x0: conv...
351
  	sa11x0_register_mcp(&collie_mcp_data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
352
353
354
355
356
  
  	sharpsl_save_param();
  }
  
  static struct map_desc collie_io_desc[] __initdata = {
92519d828   Deepak Saxena   [ARM] 2992/1: Rep...
357
358
359
360
361
362
363
364
365
366
367
  	{	/* 32M main flash (cs0) */
  		.virtual	= 0xe8000000,
  		.pfn		= __phys_to_pfn(0x00000000),
  		.length		= 0x02000000,
  		.type		= MT_DEVICE
  	}, {	/* 32M boot flash (cs1) */
  		.virtual	= 0xea000000,
  		.pfn		= __phys_to_pfn(0x08000000),
  		.length		= 0x02000000,
  		.type		= MT_DEVICE
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
368
369
370
371
372
373
  };
  
  static void __init collie_map_io(void)
  {
  	sa1100_map_io();
  	iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
50c37e216   Pavel Machek   [ARM] 3436/1: 2.6...
374
375
376
377
378
379
  
  #ifdef CONFIG_SHARP_LOCOMO
  	sa1100_register_uart_fns(&collie_port_fns);
  #endif
  	sa1100_register_uart(0, 3);
  	sa1100_register_uart(1, 1);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
380
381
382
  }
  
  MACHINE_START(COLLIE, "Sharp-Collie")
e9dea0c65   Russell King   [PATCH] ARM: Remo...
383
384
  	.map_io		= collie_map_io,
  	.init_irq	= sa1100_init_irq,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
386
  	.timer		= &sa1100_timer,
  	.init_machine	= collie_init,
d9ca5839f   Russell King   ARM: restart: sa1...
387
  	.restart	= sa11x0_restart,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
388
  MACHINE_END