Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[sfrench/cifs-2.6.git] / arch / blackfin / mach-bf533 / boards / stamp.c
1 /*
2  * File:         arch/blackfin/mach-bf533/stamp.c
3  * Based on:     arch/blackfin/mach-bf533/ezkit.c
4  * Author:       Aidan Williams <aidan@nicta.com.au>
5  *
6  * Created:      2005
7  * Description:  Board Info File for the BF533-STAMP
8  *
9  * Modified:
10  *               Copyright 2005 National ICT Australia (NICTA)
11  *               Copyright 2004-2006 Analog Devices Inc.
12  *
13  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, see the file COPYING, or write
27  * to the Free Software Foundation, Inc.,
28  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include <linux/device.h>
32 #include <linux/platform_device.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/flash.h>
37 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38 #include <linux/usb_isp1362.h>
39 #endif
40 #include <linux/pata_platform.h>
41 #include <linux/irq.h>
42 #include <asm/dma.h>
43 #include <asm/bfin5xx_spi.h>
44 #include <asm/reboot.h>
45
46 /*
47  * Name the Board for the /proc/cpuinfo
48  */
49 char *bfin_board_name = "ADDS-BF533-STAMP";
50
51 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
52 static struct platform_device rtc_device = {
53         .name = "rtc-bfin",
54         .id   = -1,
55 };
56 #endif
57
58 /*
59  *  Driver needs to know address, irq and flag pin.
60  */
61 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
62 static struct resource smc91x_resources[] = {
63         {
64                 .name = "smc91x-regs",
65                 .start = 0x20300300,
66                 .end = 0x20300300 + 16,
67                 .flags = IORESOURCE_MEM,
68         }, {
69                 .start = IRQ_PF7,
70                 .end = IRQ_PF7,
71                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
72         },
73 };
74
75 static struct platform_device smc91x_device = {
76         .name = "smc91x",
77         .id = 0,
78         .num_resources = ARRAY_SIZE(smc91x_resources),
79         .resource = smc91x_resources,
80 };
81 #endif
82
83 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
84 static struct platform_device bfin_fb_adv7393_device = {
85         .name = "bfin-adv7393",
86 };
87 #endif
88
89 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
90 static struct resource net2272_bfin_resources[] = {
91         {
92                 .start = 0x20300000,
93                 .end = 0x20300000 + 0x100,
94                 .flags = IORESOURCE_MEM,
95         }, {
96                 .start = IRQ_PF10,
97                 .end = IRQ_PF10,
98                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
99         },
100 };
101
102 static struct platform_device net2272_bfin_device = {
103         .name = "net2272",
104         .id = -1,
105         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
106         .resource = net2272_bfin_resources,
107 };
108 #endif
109
110 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
111 /* all SPI peripherals info goes here */
112
113 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
114 static struct mtd_partition bfin_spi_flash_partitions[] = {
115         {
116                 .name = "bootloader",
117                 .size = 0x00020000,
118                 .offset = 0,
119                 .mask_flags = MTD_CAP_ROM
120         }, {
121                 .name = "kernel",
122                 .size = 0xe0000,
123                 .offset = 0x20000
124         }, {
125                 .name = "file system",
126                 .size = 0x700000,
127                 .offset = 0x00100000,
128         }
129 };
130
131 static struct flash_platform_data bfin_spi_flash_data = {
132         .name = "m25p80",
133         .parts = bfin_spi_flash_partitions,
134         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
135         .type = "m25p64",
136 };
137
138 /* SPI flash chip (m25p64) */
139 static struct bfin5xx_spi_chip spi_flash_chip_info = {
140         .enable_dma = 0,         /* use dma transfer with this chip*/
141         .bits_per_word = 8,
142 };
143 #endif
144
145 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
146 /* SPI ADC chip */
147 static struct bfin5xx_spi_chip spi_adc_chip_info = {
148         .enable_dma = 1,         /* use dma transfer with this chip*/
149         .bits_per_word = 16,
150 };
151 #endif
152
153 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
154 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
155         .enable_dma = 0,
156         .bits_per_word = 16,
157 };
158 #endif
159
160 #if defined(CONFIG_PBX)
161 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
162         .ctl_reg        = 0x4, /* send zero */
163         .enable_dma     = 0,
164         .bits_per_word  = 8,
165         .cs_change_per_word = 1,
166 };
167 #endif
168
169 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
170 static struct bfin5xx_spi_chip ad5304_chip_info = {
171         .enable_dma = 0,
172         .bits_per_word = 16,
173 };
174 #endif
175
176 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
177 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
178         .enable_dma = 1,
179         .bits_per_word = 8,
180 };
181 #endif
182
183 static struct spi_board_info bfin_spi_board_info[] __initdata = {
184 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
185         {
186                 /* the modalias must be the same as spi device driver name */
187                 .modalias = "m25p80", /* Name of spi_driver for this device */
188                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
189                 .bus_num = 0, /* Framework bus number */
190                 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
191                 .platform_data = &bfin_spi_flash_data,
192                 .controller_data = &spi_flash_chip_info,
193                 .mode = SPI_MODE_3,
194         },
195 #endif
196
197 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
198         {
199                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
200                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
201                 .bus_num = 0, /* Framework bus number */
202                 .chip_select = 1, /* Framework chip select. */
203                 .platform_data = NULL, /* No spi_driver specific config */
204                 .controller_data = &spi_adc_chip_info,
205         },
206 #endif
207
208 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
209         {
210                 .modalias = "ad1836-spi",
211                 .max_speed_hz = 31250000,     /* max spi clock (SCK) speed in HZ */
212                 .bus_num = 0,
213                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
214                 .controller_data = &ad1836_spi_chip_info,
215         },
216 #endif
217
218 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
219         {
220                 .modalias = "spi_mmc_dummy",
221                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
222                 .bus_num = 0,
223                 .chip_select = 0,
224                 .platform_data = NULL,
225                 .controller_data = &spi_mmc_chip_info,
226                 .mode = SPI_MODE_3,
227         },
228         {
229                 .modalias = "spi_mmc",
230                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
231                 .bus_num = 0,
232                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
233                 .platform_data = NULL,
234                 .controller_data = &spi_mmc_chip_info,
235                 .mode = SPI_MODE_3,
236         },
237 #endif
238
239 #if defined(CONFIG_PBX)
240         {
241                 .modalias = "fxs-spi",
242                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
243                 .bus_num = 0,
244                 .chip_select = 8 - CONFIG_J11_JUMPER,
245                 .controller_data = &spi_si3xxx_chip_info,
246                 .mode = SPI_MODE_3,
247         },
248         {
249                 .modalias = "fxo-spi",
250                 .max_speed_hz = 12500000,     /* max spi clock (SCK) speed in HZ */
251                 .bus_num = 0,
252                 .chip_select = 8 - CONFIG_J19_JUMPER,
253                 .controller_data = &spi_si3xxx_chip_info,
254                 .mode = SPI_MODE_3,
255         },
256 #endif
257
258 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
259         {
260                 .modalias = "ad5304_spi",
261                 .max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */
262                 .bus_num = 0,
263                 .chip_select = 2,
264                 .platform_data = NULL,
265                 .controller_data = &ad5304_chip_info,
266                 .mode = SPI_MODE_2,
267         },
268 #endif
269 };
270
271 /* SPI (0) */
272 static struct resource bfin_spi0_resource[] = {
273         [0] = {
274                 .start = SPI0_REGBASE,
275                 .end   = SPI0_REGBASE + 0xFF,
276                 .flags = IORESOURCE_MEM,
277         },
278         [1] = {
279                 .start = CH_SPI,
280                 .end   = CH_SPI,
281                 .flags = IORESOURCE_IRQ,
282         }
283 };
284
285 /* SPI controller data */
286 static struct bfin5xx_spi_master bfin_spi0_info = {
287         .num_chipselect = 8,
288         .enable_dma = 1,  /* master has the ability to do dma transfer */
289 };
290
291 static struct platform_device bfin_spi0_device = {
292         .name = "bfin-spi",
293         .id = 0, /* Bus number */
294         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
295         .resource = bfin_spi0_resource,
296         .dev = {
297                 .platform_data = &bfin_spi0_info, /* Passed to driver */
298         },
299 };
300 #endif  /* spi master and devices */
301
302 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
303 static struct platform_device bfin_fb_device = {
304         .name = "bf537-fb",
305 };
306 #endif
307
308 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
309 static struct resource bfin_uart_resources[] = {
310         {
311                 .start = 0xFFC00400,
312                 .end = 0xFFC004FF,
313                 .flags = IORESOURCE_MEM,
314         },
315 };
316
317 static struct platform_device bfin_uart_device = {
318         .name = "bfin-uart",
319         .id = 1,
320         .num_resources = ARRAY_SIZE(bfin_uart_resources),
321         .resource = bfin_uart_resources,
322 };
323 #endif
324
325 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
326 static struct platform_device bfin_sport0_uart_device = {
327         .name = "bfin-sport-uart",
328         .id = 0,
329 };
330
331 static struct platform_device bfin_sport1_uart_device = {
332         .name = "bfin-sport-uart",
333         .id = 1,
334 };
335 #endif
336
337 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
338 #define PATA_INT        55
339
340 static struct pata_platform_info bfin_pata_platform_data = {
341         .ioport_shift = 1,
342         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
343 };
344
345 static struct resource bfin_pata_resources[] = {
346         {
347                 .start = 0x20314020,
348                 .end = 0x2031403F,
349                 .flags = IORESOURCE_MEM,
350         },
351         {
352                 .start = 0x2031401C,
353                 .end = 0x2031401F,
354                 .flags = IORESOURCE_MEM,
355         },
356         {
357                 .start = PATA_INT,
358                 .end = PATA_INT,
359                 .flags = IORESOURCE_IRQ,
360         },
361 };
362
363 static struct platform_device bfin_pata_device = {
364         .name = "pata_platform",
365         .id = -1,
366         .num_resources = ARRAY_SIZE(bfin_pata_resources),
367         .resource = bfin_pata_resources,
368         .dev = {
369                 .platform_data = &bfin_pata_platform_data,
370         }
371 };
372 #endif
373
374 static struct platform_device *stamp_devices[] __initdata = {
375 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
376         &rtc_device,
377 #endif
378
379 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
380         &smc91x_device,
381 #endif
382
383 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
384         &bfin_fb_adv7393_device,
385 #endif
386
387 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
388         &net2272_bfin_device,
389 #endif
390
391 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
392         &bfin_spi0_device,
393 #endif
394
395 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
396         &bfin_uart_device,
397 #endif
398
399 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
400         &bfin_sport0_uart_device,
401         &bfin_sport1_uart_device,
402 #endif
403
404 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
405         &bfin_pata_device,
406 #endif
407 };
408
409 static int __init stamp_init(void)
410 {
411         int ret;
412
413         printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
414         ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
415         if (ret < 0)
416                 return ret;
417
418 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
419 # if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
420         /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
421         bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (1 << CONFIG_ENET_FLASH_PIN));
422         bfin_write_FIO_FLAG_S(1 << CONFIG_ENET_FLASH_PIN);
423         SSYNC();
424 # endif
425 #endif
426
427 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
428         spi_register_board_info(bfin_spi_board_info,
429                                 ARRAY_SIZE(bfin_spi_board_info));
430 #endif
431 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
432         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
433 #endif
434         return 0;
435 }
436
437 arch_initcall(stamp_init);
438
439 void native_machine_restart(char *cmd)
440 {
441 #if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
442 # define BIT_TO_SET (1 << CONFIG_ENET_FLASH_PIN)
443         bfin_write_FIO_INEN(~BIT_TO_SET);
444         bfin_write_FIO_DIR(BIT_TO_SET);
445         bfin_write_FIO_FLAG_C(BIT_TO_SET);
446 #endif
447 }