[Blackfin] arch: Functional power management support: Add CPU and platform voltage...
[linux-2.6] / arch / blackfin / mach-bf537 / boards / cm_bf537.c
1 /*
2  * File:         arch/blackfin/mach-bf537/boards/cm_bf537.c
3  * Based on:     arch/blackfin/mach-bf533/boards/ezkit.c
4  * Author:       Aidan Williams <aidan@nicta.com.au>
5  *
6  * Created:      2005
7  * Description:  Board description file
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/etherdevice.h>
33 #include <linux/platform_device.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/partitions.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #include <linux/usb/isp1362.h>
39 #include <linux/ata_platform.h>
40 #include <linux/irq.h>
41 #include <asm/dma.h>
42 #include <asm/bfin5xx_spi.h>
43 #include <asm/portmux.h>
44 #include <asm/dpmc.h>
45
46 /*
47  * Name the Board for the /proc/cpuinfo
48  */
49 const char bfin_board_name[] = "Bluetechnix CM BF537";
50
51 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
52 /* all SPI peripherals info goes here */
53
54 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
55 static struct mtd_partition bfin_spi_flash_partitions[] = {
56         {
57                 .name = "bootloader",
58                 .size = 0x00020000,
59                 .offset = 0,
60                 .mask_flags = MTD_CAP_ROM
61         }, {
62                 .name = "kernel",
63                 .size = 0xe0000,
64                 .offset = 0x20000
65         }, {
66                 .name = "file system",
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 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
87 /* SPI ADC chip */
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_AD9960) || defined(CONFIG_AD9960_MODULE)
102 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
103         .enable_dma = 0,
104         .bits_per_word = 16,
105 };
106 #endif
107
108 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
109 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
110         .enable_dma = 1,
111         .bits_per_word = 8,
112 };
113 #endif
114
115 static struct spi_board_info bfin_spi_board_info[] __initdata = {
116 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
117         {
118                 /* the modalias must be the same as spi device driver name */
119                 .modalias = "m25p80", /* Name of spi_driver for this device */
120                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
121                 .bus_num = 0, /* Framework bus number */
122                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
123                 .platform_data = &bfin_spi_flash_data,
124                 .controller_data = &spi_flash_chip_info,
125                 .mode = SPI_MODE_3,
126         },
127 #endif
128
129 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
130         {
131                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
132                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
133                 .bus_num = 0, /* Framework bus number */
134                 .chip_select = 1, /* Framework chip select. */
135                 .platform_data = NULL, /* No spi_driver specific config */
136                 .controller_data = &spi_adc_chip_info,
137         },
138 #endif
139
140 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
141         {
142                 .modalias = "ad1836-spi",
143                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
144                 .bus_num = 0,
145                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
146                 .controller_data = &ad1836_spi_chip_info,
147         },
148 #endif
149
150 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
151         {
152                 .modalias = "ad9960-spi",
153                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
154                 .bus_num = 0,
155                 .chip_select = 1,
156                 .controller_data = &ad9960_spi_chip_info,
157         },
158 #endif
159
160 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
161         {
162                 .modalias = "spi_mmc_dummy",
163                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
164                 .bus_num = 0,
165                 .chip_select = 7,
166                 .platform_data = NULL,
167                 .controller_data = &spi_mmc_chip_info,
168                 .mode = SPI_MODE_3,
169         },
170         {
171                 .modalias = "spi_mmc",
172                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
173                 .bus_num = 0,
174                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
175                 .platform_data = NULL,
176                 .controller_data = &spi_mmc_chip_info,
177                 .mode = SPI_MODE_3,
178         },
179 #endif
180 };
181
182 /* SPI (0) */
183 static struct resource bfin_spi0_resource[] = {
184         [0] = {
185                 .start = SPI0_REGBASE,
186                 .end   = SPI0_REGBASE + 0xFF,
187                 .flags = IORESOURCE_MEM,
188                 },
189         [1] = {
190                 .start = CH_SPI,
191                 .end   = CH_SPI,
192                 .flags = IORESOURCE_IRQ,
193         }
194 };
195
196 /* SPI controller data */
197 static struct bfin5xx_spi_master bfin_spi0_info = {
198         .num_chipselect = 8,
199         .enable_dma = 1,  /* master has the ability to do dma transfer */
200         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
201 };
202
203 static struct platform_device bfin_spi0_device = {
204         .name = "bfin-spi",
205         .id = 0, /* Bus number */
206         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
207         .resource = bfin_spi0_resource,
208         .dev = {
209                 .platform_data = &bfin_spi0_info, /* Passed to driver */
210         },
211 };
212 #endif  /* spi master and devices */
213
214 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
215 static struct platform_device rtc_device = {
216         .name = "rtc-bfin",
217         .id   = -1,
218 };
219 #endif
220
221 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
222 static struct platform_device hitachi_fb_device = {
223         .name = "hitachi-tx09",
224 };
225 #endif
226
227 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
228 static struct resource smc91x_resources[] = {
229         {
230                 .start = 0x20200300,
231                 .end = 0x20200300 + 16,
232                 .flags = IORESOURCE_MEM,
233         }, {
234                 .start = IRQ_PF14,
235                 .end = IRQ_PF14,
236                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
237                 },
238 };
239
240 static struct platform_device smc91x_device = {
241         .name = "smc91x",
242         .id = 0,
243         .num_resources = ARRAY_SIZE(smc91x_resources),
244         .resource = smc91x_resources,
245 };
246 #endif
247
248 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
249 static struct resource isp1362_hcd_resources[] = {
250         {
251                 .start = 0x20308000,
252                 .end = 0x20308000,
253                 .flags = IORESOURCE_MEM,
254         }, {
255                 .start = 0x20308004,
256                 .end = 0x20308004,
257                 .flags = IORESOURCE_MEM,
258         }, {
259                 .start = IRQ_PG15,
260                 .end = IRQ_PG15,
261                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
262         },
263 };
264
265 static struct isp1362_platform_data isp1362_priv = {
266         .sel15Kres = 1,
267         .clknotstop = 0,
268         .oc_enable = 0,
269         .int_act_high = 0,
270         .int_edge_triggered = 0,
271         .remote_wakeup_connected = 0,
272         .no_power_switching = 1,
273         .power_switching_mode = 0,
274 };
275
276 static struct platform_device isp1362_hcd_device = {
277         .name = "isp1362-hcd",
278         .id = 0,
279         .dev = {
280                 .platform_data = &isp1362_priv,
281         },
282         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
283         .resource = isp1362_hcd_resources,
284 };
285 #endif
286
287 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
288 static struct resource net2272_bfin_resources[] = {
289         {
290                 .start = 0x20200000,
291                 .end = 0x20200000 + 0x100,
292                 .flags = IORESOURCE_MEM,
293         }, {
294                 .start = IRQ_PH14,
295                 .end = IRQ_PH14,
296                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
297         },
298 };
299
300 static struct platform_device net2272_bfin_device = {
301         .name = "net2272",
302         .id = -1,
303         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
304         .resource = net2272_bfin_resources,
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                 .start = 0xFFC02000,
316                 .end = 0xFFC020FF,
317                 .flags = IORESOURCE_MEM,
318         },
319 };
320
321 static struct platform_device bfin_uart_device = {
322         .name = "bfin-uart",
323         .id = 1,
324         .num_resources = ARRAY_SIZE(bfin_uart_resources),
325         .resource = bfin_uart_resources,
326 };
327 #endif
328
329 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
330 static struct resource bfin_sir_resources[] = {
331 #ifdef CONFIG_BFIN_SIR0
332         {
333                 .start = 0xFFC00400,
334                 .end = 0xFFC004FF,
335                 .flags = IORESOURCE_MEM,
336         },
337 #endif
338 #ifdef CONFIG_BFIN_SIR1
339         {
340                 .start = 0xFFC02000,
341                 .end = 0xFFC020FF,
342                 .flags = IORESOURCE_MEM,
343         },
344 #endif
345 };
346
347 static struct platform_device bfin_sir_device = {
348         .name = "bfin_sir",
349         .id = 0,
350         .num_resources = ARRAY_SIZE(bfin_sir_resources),
351         .resource = bfin_sir_resources,
352 };
353 #endif
354
355 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
356 static struct resource bfin_twi0_resource[] = {
357         [0] = {
358                 .start = TWI0_REGBASE,
359                 .end   = TWI0_REGBASE,
360                 .flags = IORESOURCE_MEM,
361         },
362         [1] = {
363                 .start = IRQ_TWI,
364                 .end   = IRQ_TWI,
365                 .flags = IORESOURCE_IRQ,
366         },
367 };
368
369 static struct platform_device i2c_bfin_twi_device = {
370         .name = "i2c-bfin-twi",
371         .id = 0,
372         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
373         .resource = bfin_twi0_resource,
374 };
375 #endif
376
377 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
378 static struct platform_device bfin_sport0_uart_device = {
379         .name = "bfin-sport-uart",
380         .id = 0,
381 };
382
383 static struct platform_device bfin_sport1_uart_device = {
384         .name = "bfin-sport-uart",
385         .id = 1,
386 };
387 #endif
388
389 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
390 static struct platform_device bfin_mac_device = {
391         .name = "bfin_mac",
392 };
393 #endif
394
395 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
396 #define PATA_INT        64
397
398 static struct pata_platform_info bfin_pata_platform_data = {
399         .ioport_shift = 2,
400         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
401 };
402
403 static struct resource bfin_pata_resources[] = {
404         {
405                 .start = 0x2030C000,
406                 .end = 0x2030C01F,
407                 .flags = IORESOURCE_MEM,
408         },
409         {
410                 .start = 0x2030D018,
411                 .end = 0x2030D01B,
412                 .flags = IORESOURCE_MEM,
413         },
414         {
415                 .start = PATA_INT,
416                 .end = PATA_INT,
417                 .flags = IORESOURCE_IRQ,
418         },
419 };
420
421 static struct platform_device bfin_pata_device = {
422         .name = "pata_platform",
423         .id = -1,
424         .num_resources = ARRAY_SIZE(bfin_pata_resources),
425         .resource = bfin_pata_resources,
426         .dev = {
427                 .platform_data = &bfin_pata_platform_data,
428         }
429 };
430 #endif
431
432 static const unsigned int cclk_vlev_datasheet[] =
433 {
434         VRPAIR(VLEV_085, 250000000),
435         VRPAIR(VLEV_090, 376000000),
436         VRPAIR(VLEV_095, 426000000),
437         VRPAIR(VLEV_100, 426000000),
438         VRPAIR(VLEV_105, 476000000),
439         VRPAIR(VLEV_110, 476000000),
440         VRPAIR(VLEV_115, 476000000),
441         VRPAIR(VLEV_120, 500000000),
442         VRPAIR(VLEV_125, 533000000),
443         VRPAIR(VLEV_130, 600000000),
444 };
445
446 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
447         .tuple_tab = cclk_vlev_datasheet,
448         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
449         .vr_settling_time = 25 /* us */,
450 };
451
452 static struct platform_device bfin_dpmc = {
453         .name = "bfin dpmc",
454         .dev = {
455                 .platform_data = &bfin_dmpc_vreg_data,
456         },
457 };
458
459 static struct platform_device *cm_bf537_devices[] __initdata = {
460
461         &bfin_dpmc,
462
463 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
464         &hitachi_fb_device,
465 #endif
466
467 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
468         &rtc_device,
469 #endif
470
471 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
472         &bfin_uart_device,
473 #endif
474
475 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
476         &bfin_sir_device,
477 #endif
478
479 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
480         &i2c_bfin_twi_device,
481 #endif
482
483 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
484         &bfin_sport0_uart_device,
485         &bfin_sport1_uart_device,
486 #endif
487
488 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
489         &isp1362_hcd_device,
490 #endif
491
492 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
493         &smc91x_device,
494 #endif
495
496 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
497         &bfin_mac_device,
498 #endif
499
500 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
501         &net2272_bfin_device,
502 #endif
503
504 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
505         &bfin_spi0_device,
506 #endif
507
508 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
509         &bfin_pata_device,
510 #endif
511 };
512
513 static int __init cm_bf537_init(void)
514 {
515         printk(KERN_INFO "%s(): registering device resources\n", __func__);
516         platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_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
521 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
522         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
523 #endif
524         return 0;
525 }
526
527 arch_initcall(cm_bf537_init);
528
529 void bfin_get_ether_addr(char *addr)
530 {
531         random_ether_addr(addr);
532         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
533 }
534 EXPORT_SYMBOL(bfin_get_ether_addr);