Merge branch 'davinci-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / arch / blackfin / mach-bf533 / boards / cm_bf533.c
1 /*
2  * File:         arch/blackfin/mach-bf533/boards/cm_bf533.c
3  * Based on:     arch/blackfin/mach-bf533/boards/ezkit.c
4  * Author:       Aidan Williams <aidan@nicta.com.au> Copyright 2005
5  *
6  * Created:      2005
7  * Description:  Board description file
8  *
9  * Modified:
10  *               Copyright 2004-2006 Analog Devices Inc.
11  *
12  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, see the file COPYING, or write
26  * to the Free Software Foundation, Inc.,
27  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
29
30 #include <linux/device.h>
31 #include <linux/platform_device.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/partitions.h>
34 #include <linux/mtd/physmap.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/flash.h>
37 #include <linux/spi/mmc_spi.h>
38 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
39 #include <linux/usb/isp1362.h>
40 #endif
41 #include <linux/irq.h>
42 #include <asm/dma.h>
43 #include <asm/bfin5xx_spi.h>
44 #include <asm/portmux.h>
45 #include <asm/dpmc.h>
46
47 /*
48  * Name the Board for the /proc/cpuinfo
49  */
50 const char bfin_board_name[] = "Bluetechnix CM BF533";
51
52 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
53 /* all SPI peripherals info goes here */
54 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
55 static struct mtd_partition bfin_spi_flash_partitions[] = {
56         {
57                 .name = "bootloader(spi)",
58                 .size = 0x00020000,
59                 .offset = 0,
60                 .mask_flags = MTD_CAP_ROM
61         }, {
62                 .name = "linux kernel(spi)",
63                 .size = 0xe0000,
64                 .offset = 0x20000
65         }, {
66                 .name = "file system(spi)",
67                 .size = 0x700000,
68                 .offset = 0x00100000,
69         }
70 };
71
72 static struct flash_platform_data bfin_spi_flash_data = {
73         .name = "m25p80",
74         .parts = bfin_spi_flash_partitions,
75         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
76         .type = "m25p64",
77 };
78
79 /* SPI flash chip (m25p64) */
80 static struct bfin5xx_spi_chip spi_flash_chip_info = {
81         .enable_dma = 0,         /* use dma transfer with this chip*/
82         .bits_per_word = 8,
83 };
84 #endif
85
86 /* SPI ADC chip */
87 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
88 static struct bfin5xx_spi_chip spi_adc_chip_info = {
89         .enable_dma = 1,         /* use dma transfer with this chip*/
90         .bits_per_word = 16,
91 };
92 #endif
93
94 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
95 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
96         .enable_dma = 0,
97         .bits_per_word = 16,
98 };
99 #endif
100
101 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
102 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
103         .enable_dma = 0,
104         .bits_per_word = 8,
105 };
106 #endif
107
108 static struct spi_board_info bfin_spi_board_info[] __initdata = {
109 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
110         {
111                 /* the modalias must be the same as spi device driver name */
112                 .modalias = "m25p80",       /* Name of spi_driver for this device */
113                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
114                 .bus_num = 0,               /* Framework bus number */
115                 .chip_select = 1,           /* Framework chip select. On STAMP537 it is SPISSEL1*/
116                 .platform_data = &bfin_spi_flash_data,
117                 .controller_data = &spi_flash_chip_info,
118                 .mode = SPI_MODE_3,
119         },
120 #endif
121
122 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
123         {
124                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
125                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
126                 .bus_num = 0,               /* Framework bus number */
127                 .chip_select = 2,           /* Framework chip select. */
128                 .platform_data = NULL,      /* No spi_driver specific config */
129                 .controller_data = &spi_adc_chip_info,
130         },
131 #endif
132
133 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
134         {
135                 .modalias = "ad1836",
136                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
137                 .bus_num = 0,
138                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
139                 .controller_data = &ad1836_spi_chip_info,
140         },
141 #endif
142
143 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
144         {
145                 .modalias = "mmc_spi",
146                 .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
147                 .bus_num = 0,
148                 .chip_select = 1,
149                 .controller_data = &mmc_spi_chip_info,
150                 .mode = SPI_MODE_3,
151         },
152 #endif
153 };
154
155 /* SPI (0) */
156 static struct resource bfin_spi0_resource[] = {
157         [0] = {
158                 .start = SPI0_REGBASE,
159                 .end   = SPI0_REGBASE + 0xFF,
160                 .flags = IORESOURCE_MEM,
161         },
162         [1] = {
163                 .start = CH_SPI,
164                 .end   = CH_SPI,
165                 .flags = IORESOURCE_DMA,
166         },
167         [2] = {
168                 .start = IRQ_SPI,
169                 .end   = IRQ_SPI,
170                 .flags = IORESOURCE_IRQ,
171         }
172 };
173
174 /* SPI controller data */
175 static struct bfin5xx_spi_master bfin_spi0_info = {
176         .num_chipselect = 8,
177         .enable_dma = 1,  /* master has the ability to do dma transfer */
178         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
179 };
180
181 static struct platform_device bfin_spi0_device = {
182         .name = "bfin-spi",
183         .id = 0, /* Bus number */
184         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
185         .resource = bfin_spi0_resource,
186         .dev = {
187                 .platform_data = &bfin_spi0_info, /* Passed to driver */
188         },
189 };
190 #endif  /* spi master and devices */
191
192 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
193 static struct platform_device rtc_device = {
194         .name = "rtc-bfin",
195         .id   = -1,
196 };
197 #endif
198
199 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
200 #include <linux/smc91x.h>
201
202 static struct smc91x_platdata smc91x_info = {
203         .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
204         .leda = RPC_LED_100_10,
205         .ledb = RPC_LED_TX_RX,
206 };
207
208 static struct resource smc91x_resources[] = {
209         {
210                 .start = 0x20200300,
211                 .end = 0x20200300 + 16,
212                 .flags = IORESOURCE_MEM,
213         }, {
214                 .start = IRQ_PF0,
215                 .end = IRQ_PF0,
216                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
217         },
218 };
219 static struct platform_device smc91x_device = {
220         .name = "smc91x",
221         .id = 0,
222         .num_resources = ARRAY_SIZE(smc91x_resources),
223         .resource = smc91x_resources,
224         .dev    = {
225                 .platform_data  = &smc91x_info,
226         },
227 };
228 #endif
229
230 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
231 #include <linux/smsc911x.h>
232
233 static struct resource smsc911x_resources[] = {
234         {
235                 .name = "smsc911x-memory",
236                 .start = 0x20308000,
237                 .end = 0x20308000 + 0xFF,
238                 .flags = IORESOURCE_MEM,
239         }, {
240                 .start = IRQ_PF8,
241                 .end = IRQ_PF8,
242                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
243         },
244 };
245
246 static struct smsc911x_platform_config smsc911x_config = {
247         .flags = SMSC911X_USE_16BIT,
248         .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
249         .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
250         .phy_interface = PHY_INTERFACE_MODE_MII,
251 };
252
253 static struct platform_device smsc911x_device = {
254         .name = "smsc911x",
255         .id = 0,
256         .num_resources = ARRAY_SIZE(smsc911x_resources),
257         .resource = smsc911x_resources,
258         .dev = {
259                 .platform_data = &smsc911x_config,
260         },
261 };
262 #endif
263
264 static struct resource bfin_gpios_resources = {
265         .start = 0,
266         .end   = MAX_BLACKFIN_GPIOS - 1,
267         .flags = IORESOURCE_IRQ,
268 };
269
270 static struct platform_device bfin_gpios_device = {
271         .name = "simple-gpio",
272         .id = -1,
273         .num_resources = 1,
274         .resource = &bfin_gpios_resources,
275 };
276
277 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
278 static struct resource bfin_uart_resources[] = {
279         {
280                 .start = 0xFFC00400,
281                 .end = 0xFFC004FF,
282                 .flags = IORESOURCE_MEM,
283         },
284 };
285
286 static struct platform_device bfin_uart_device = {
287         .name = "bfin-uart",
288         .id = 1,
289         .num_resources = ARRAY_SIZE(bfin_uart_resources),
290         .resource = bfin_uart_resources,
291 };
292 #endif
293
294 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
295 #ifdef CONFIG_BFIN_SIR0
296 static struct resource bfin_sir0_resources[] = {
297         {
298                 .start = 0xFFC00400,
299                 .end = 0xFFC004FF,
300                 .flags = IORESOURCE_MEM,
301         },
302         {
303                 .start = IRQ_UART0_RX,
304                 .end = IRQ_UART0_RX+1,
305                 .flags = IORESOURCE_IRQ,
306         },
307         {
308                 .start = CH_UART0_RX,
309                 .end = CH_UART0_RX+1,
310                 .flags = IORESOURCE_DMA,
311         },
312 };
313
314 static struct platform_device bfin_sir0_device = {
315         .name = "bfin_sir",
316         .id = 0,
317         .num_resources = ARRAY_SIZE(bfin_sir0_resources),
318         .resource = bfin_sir0_resources,
319 };
320 #endif
321 #endif
322
323 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
324 static struct platform_device bfin_sport0_uart_device = {
325         .name = "bfin-sport-uart",
326         .id = 0,
327 };
328
329 static struct platform_device bfin_sport1_uart_device = {
330         .name = "bfin-sport-uart",
331         .id = 1,
332 };
333 #endif
334
335 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
336 static struct resource isp1362_hcd_resources[] = {
337         {
338                 .start = 0x20308000,
339                 .end = 0x20308000,
340                 .flags = IORESOURCE_MEM,
341         }, {
342                 .start = 0x20308004,
343                 .end = 0x20308004,
344                 .flags = IORESOURCE_MEM,
345         }, {
346                 .start = IRQ_PF4,
347                 .end = IRQ_PF4,
348                 .flags = IORESOURCE_IRQ,
349         },
350 };
351
352 static struct isp1362_platform_data isp1362_priv = {
353         .sel15Kres = 1,
354         .clknotstop = 0,
355         .oc_enable = 0,
356         .int_act_high = 0,
357         .int_edge_triggered = 0,
358         .remote_wakeup_connected = 0,
359         .no_power_switching = 1,
360         .power_switching_mode = 0,
361 };
362
363 static struct platform_device isp1362_hcd_device = {
364         .name = "isp1362-hcd",
365         .id = 0,
366         .dev = {
367                 .platform_data = &isp1362_priv,
368         },
369         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
370         .resource = isp1362_hcd_resources,
371 };
372 #endif
373
374
375 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
376 static struct resource net2272_bfin_resources[] = {
377         {
378                 .start = 0x20300000,
379                 .end = 0x20300000 + 0x100,
380                 .flags = IORESOURCE_MEM,
381         }, {
382                 .start = IRQ_PF6,
383                 .end = IRQ_PF6,
384                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
385         },
386 };
387
388 static struct platform_device net2272_bfin_device = {
389         .name = "net2272",
390         .id = -1,
391         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
392         .resource = net2272_bfin_resources,
393 };
394 #endif
395
396
397
398 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
399 static struct mtd_partition para_partitions[] = {
400         {
401                 .name       = "bootloader(nor)",
402                 .size       = 0x40000,
403                 .offset     = 0,
404         }, {
405                 .name       = "linux+rootfs(nor)",
406                 .size       = MTDPART_SIZ_FULL,
407                 .offset     = MTDPART_OFS_APPEND,
408         },
409 };
410
411 static struct physmap_flash_data para_flash_data = {
412         .width      = 2,
413         .parts      = para_partitions,
414         .nr_parts   = ARRAY_SIZE(para_partitions),
415 };
416
417 static struct resource para_flash_resource = {
418         .start = 0x20000000,
419         .end   = 0x201fffff,
420         .flags = IORESOURCE_MEM,
421 };
422
423 static struct platform_device para_flash_device = {
424         .name          = "physmap-flash",
425         .id            = 0,
426         .dev = {
427                 .platform_data = &para_flash_data,
428         },
429         .num_resources = 1,
430         .resource      = &para_flash_resource,
431 };
432 #endif
433
434
435
436 static const unsigned int cclk_vlev_datasheet[] =
437 {
438         VRPAIR(VLEV_085, 250000000),
439         VRPAIR(VLEV_090, 376000000),
440         VRPAIR(VLEV_095, 426000000),
441         VRPAIR(VLEV_100, 426000000),
442         VRPAIR(VLEV_105, 476000000),
443         VRPAIR(VLEV_110, 476000000),
444         VRPAIR(VLEV_115, 476000000),
445         VRPAIR(VLEV_120, 600000000),
446         VRPAIR(VLEV_125, 600000000),
447         VRPAIR(VLEV_130, 600000000),
448 };
449
450 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
451         .tuple_tab = cclk_vlev_datasheet,
452         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
453         .vr_settling_time = 25 /* us */,
454 };
455
456 static struct platform_device bfin_dpmc = {
457         .name = "bfin dpmc",
458         .dev = {
459                 .platform_data = &bfin_dmpc_vreg_data,
460         },
461 };
462
463 static struct platform_device *cm_bf533_devices[] __initdata = {
464
465         &bfin_dpmc,
466
467 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
468         &bfin_uart_device,
469 #endif
470
471 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
472 #ifdef CONFIG_BFIN_SIR0
473         &bfin_sir0_device,
474 #endif
475 #endif
476
477 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
478         &bfin_sport0_uart_device,
479         &bfin_sport1_uart_device,
480 #endif
481
482 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
483         &rtc_device,
484 #endif
485
486 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
487         &isp1362_hcd_device,
488 #endif
489
490 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
491         &smc91x_device,
492 #endif
493
494 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
495         &smsc911x_device,
496 #endif
497
498 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
499         &net2272_bfin_device,
500 #endif
501
502 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
503         &bfin_spi0_device,
504 #endif
505
506 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
507         &para_flash_device,
508 #endif
509
510         &bfin_gpios_device,
511 };
512
513 static int __init cm_bf533_init(void)
514 {
515         printk(KERN_INFO "%s(): registering device resources\n", __func__);
516         platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
517 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
518         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
519 #endif
520         return 0;
521 }
522
523 arch_initcall(cm_bf533_init);