]> err.no Git - linux-2.6/blob - arch/blackfin/mach-bf533/boards/cm_bf533.c
[Blackfin] arch: Functional power management support: Add CPU and platform voltage...
[linux-2.6] / 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/spi/spi.h>
35 #include <linux/spi/flash.h>
36 #include <linux/usb/isp1362.h>
37 #include <linux/ata_platform.h>
38 #include <linux/irq.h>
39 #include <asm/dma.h>
40 #include <asm/bfin5xx_spi.h>
41 #include <asm/portmux.h>
42 #include <asm/dpmc.h>
43
44 /*
45  * Name the Board for the /proc/cpuinfo
46  */
47 const char bfin_board_name[] = "Bluetechnix CM BF533";
48
49 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
50 /* all SPI peripherals info goes here */
51 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
52 static struct mtd_partition bfin_spi_flash_partitions[] = {
53         {
54                 .name = "bootloader",
55                 .size = 0x00020000,
56                 .offset = 0,
57                 .mask_flags = MTD_CAP_ROM
58         }, {
59                 .name = "kernel",
60                 .size = 0xe0000,
61                 .offset = 0x20000
62         }, {
63                 .name = "file system",
64                 .size = 0x700000,
65                 .offset = 0x00100000,
66         }
67 };
68
69 static struct flash_platform_data bfin_spi_flash_data = {
70         .name = "m25p80",
71         .parts = bfin_spi_flash_partitions,
72         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
73         .type = "m25p64",
74 };
75
76 /* SPI flash chip (m25p64) */
77 static struct bfin5xx_spi_chip spi_flash_chip_info = {
78         .enable_dma = 0,         /* use dma transfer with this chip*/
79         .bits_per_word = 8,
80 };
81 #endif
82
83 /* SPI ADC chip */
84 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
85 static struct bfin5xx_spi_chip spi_adc_chip_info = {
86         .enable_dma = 1,         /* use dma transfer with this chip*/
87         .bits_per_word = 16,
88 };
89 #endif
90
91 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
92 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
93         .enable_dma = 0,
94         .bits_per_word = 16,
95 };
96 #endif
97
98 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
99 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
100         .enable_dma = 1,
101         .bits_per_word = 8,
102 };
103 #endif
104
105 static struct spi_board_info bfin_spi_board_info[] __initdata = {
106 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
107         {
108                 /* the modalias must be the same as spi device driver name */
109                 .modalias = "m25p80",       /* Name of spi_driver for this device */
110                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
111                 .bus_num = 0,               /* Framework bus number */
112                 .chip_select = 1,           /* Framework chip select. On STAMP537 it is SPISSEL1*/
113                 .platform_data = &bfin_spi_flash_data,
114                 .controller_data = &spi_flash_chip_info,
115                 .mode = SPI_MODE_3,
116         },
117 #endif
118
119 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
120         {
121                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
122                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
123                 .bus_num = 0,               /* Framework bus number */
124                 .chip_select = 2,           /* Framework chip select. */
125                 .platform_data = NULL,      /* No spi_driver specific config */
126                 .controller_data = &spi_adc_chip_info,
127         },
128 #endif
129
130 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
131         {
132                 .modalias = "ad1836-spi",
133                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
134                 .bus_num = 0,
135                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
136                 .controller_data = &ad1836_spi_chip_info,
137         },
138 #endif
139
140 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
141         {
142                 .modalias = "spi_mmc_dummy",
143                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
144                 .bus_num = 0,
145                 .chip_select = 0,
146                 .platform_data = NULL,
147                 .controller_data = &spi_mmc_chip_info,
148                 .mode = SPI_MODE_3,
149         },
150         {
151                 .modalias = "spi_mmc",
152                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
153                 .bus_num = 0,
154                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
155                 .platform_data = NULL,
156                 .controller_data = &spi_mmc_chip_info,
157                 .mode = SPI_MODE_3,
158         },
159 #endif
160 };
161
162 /* SPI (0) */
163 static struct resource bfin_spi0_resource[] = {
164         [0] = {
165                 .start = SPI0_REGBASE,
166                 .end   = SPI0_REGBASE + 0xFF,
167                 .flags = IORESOURCE_MEM,
168         },
169         [1] = {
170                 .start = CH_SPI,
171                 .end   = CH_SPI,
172                 .flags = IORESOURCE_IRQ,
173         }
174 };
175
176 /* SPI controller data */
177 static struct bfin5xx_spi_master bfin_spi0_info = {
178         .num_chipselect = 8,
179         .enable_dma = 1,  /* master has the ability to do dma transfer */
180         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
181 };
182
183 static struct platform_device bfin_spi0_device = {
184         .name = "bfin-spi",
185         .id = 0, /* Bus number */
186         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
187         .resource = bfin_spi0_resource,
188         .dev = {
189                 .platform_data = &bfin_spi0_info, /* Passed to driver */
190         },
191 };
192 #endif  /* spi master and devices */
193
194 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
195 static struct platform_device rtc_device = {
196         .name = "rtc-bfin",
197         .id   = -1,
198 };
199 #endif
200
201 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
202 static struct resource smc91x_resources[] = {
203         {
204                 .start = 0x20200300,
205                 .end = 0x20200300 + 16,
206                 .flags = IORESOURCE_MEM,
207         }, {
208                 .start = IRQ_PF0,
209                 .end = IRQ_PF0,
210                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
211         },
212 };
213 static struct platform_device smc91x_device = {
214         .name = "smc91x",
215         .id = 0,
216         .num_resources = ARRAY_SIZE(smc91x_resources),
217         .resource = smc91x_resources,
218 };
219 #endif
220
221 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
222 static struct resource bfin_uart_resources[] = {
223         {
224                 .start = 0xFFC00400,
225                 .end = 0xFFC004FF,
226                 .flags = IORESOURCE_MEM,
227         },
228 };
229
230 static struct platform_device bfin_uart_device = {
231         .name = "bfin-uart",
232         .id = 1,
233         .num_resources = ARRAY_SIZE(bfin_uart_resources),
234         .resource = bfin_uart_resources,
235 };
236 #endif
237
238 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
239 static struct resource bfin_sir_resources[] = {
240 #ifdef CONFIG_BFIN_SIR0
241         {
242                 .start = 0xFFC00400,
243                 .end = 0xFFC004FF,
244                 .flags = IORESOURCE_MEM,
245         },
246 #endif
247 };
248
249 static struct platform_device bfin_sir_device = {
250         .name = "bfin_sir",
251         .id = 0,
252         .num_resources = ARRAY_SIZE(bfin_sir_resources),
253         .resource = bfin_sir_resources,
254 };
255 #endif
256
257 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
258 static struct platform_device bfin_sport0_uart_device = {
259         .name = "bfin-sport-uart",
260         .id = 0,
261 };
262
263 static struct platform_device bfin_sport1_uart_device = {
264         .name = "bfin-sport-uart",
265         .id = 1,
266 };
267 #endif
268
269 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
270 static struct resource isp1362_hcd_resources[] = {
271         {
272                 .start = 0x20308000,
273                 .end = 0x20308000,
274                 .flags = IORESOURCE_MEM,
275         }, {
276                 .start = 0x20308004,
277                 .end = 0x20308004,
278                 .flags = IORESOURCE_MEM,
279         }, {
280                 .start = IRQ_PF4,
281                 .end = IRQ_PF4,
282                 .flags = IORESOURCE_IRQ,
283         },
284 };
285
286 static struct isp1362_platform_data isp1362_priv = {
287         .sel15Kres = 1,
288         .clknotstop = 0,
289         .oc_enable = 0,
290         .int_act_high = 0,
291         .int_edge_triggered = 0,
292         .remote_wakeup_connected = 0,
293         .no_power_switching = 1,
294         .power_switching_mode = 0,
295 };
296
297 static struct platform_device isp1362_hcd_device = {
298         .name = "isp1362-hcd",
299         .id = 0,
300         .dev = {
301                 .platform_data = &isp1362_priv,
302         },
303         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
304         .resource = isp1362_hcd_resources,
305 };
306 #endif
307
308 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
309 #define PATA_INT        38
310
311 static struct pata_platform_info bfin_pata_platform_data = {
312         .ioport_shift = 2,
313         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
314 };
315
316 static struct resource bfin_pata_resources[] = {
317         {
318                 .start = 0x2030C000,
319                 .end = 0x2030C01F,
320                 .flags = IORESOURCE_MEM,
321         },
322         {
323                 .start = 0x2030D018,
324                 .end = 0x2030D01B,
325                 .flags = IORESOURCE_MEM,
326         },
327         {
328                 .start = PATA_INT,
329                 .end = PATA_INT,
330                 .flags = IORESOURCE_IRQ,
331         },
332 };
333
334 static struct platform_device bfin_pata_device = {
335         .name = "pata_platform",
336         .id = -1,
337         .num_resources = ARRAY_SIZE(bfin_pata_resources),
338         .resource = bfin_pata_resources,
339         .dev = {
340                 .platform_data = &bfin_pata_platform_data,
341         }
342 };
343 #endif
344
345 static const unsigned int cclk_vlev_datasheet[] =
346 {
347         VRPAIR(VLEV_085, 250000000),
348         VRPAIR(VLEV_090, 376000000),
349         VRPAIR(VLEV_095, 426000000),
350         VRPAIR(VLEV_100, 426000000),
351         VRPAIR(VLEV_105, 476000000),
352         VRPAIR(VLEV_110, 476000000),
353         VRPAIR(VLEV_115, 476000000),
354         VRPAIR(VLEV_120, 600000000),
355         VRPAIR(VLEV_125, 600000000),
356         VRPAIR(VLEV_130, 600000000),
357 };
358
359 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
360         .tuple_tab = cclk_vlev_datasheet,
361         .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
362         .vr_settling_time = 25 /* us */,
363 };
364
365 static struct platform_device bfin_dpmc = {
366         .name = "bfin dpmc",
367         .dev = {
368                 .platform_data = &bfin_dmpc_vreg_data,
369         },
370 };
371
372 static struct platform_device *cm_bf533_devices[] __initdata = {
373
374         &bfin_dpmc,
375
376 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
377         &bfin_uart_device,
378 #endif
379
380 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
381         &bfin_sir_device,
382 #endif
383
384 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
385         &bfin_sport0_uart_device,
386         &bfin_sport1_uart_device,
387 #endif
388
389 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
390         &rtc_device,
391 #endif
392
393 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
394         &isp1362_hcd_device,
395 #endif
396
397 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
398         &smc91x_device,
399 #endif
400
401 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
402         &bfin_spi0_device,
403 #endif
404
405 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
406         &bfin_pata_device,
407 #endif
408 };
409
410 static int __init cm_bf533_init(void)
411 {
412         printk(KERN_INFO "%s(): registering device resources\n", __func__);
413         platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
414 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
415         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
416 #endif
417
418 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
419         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
420 #endif
421         return 0;
422 }
423
424 arch_initcall(cm_bf533_init);