Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[deliverable/linux.git] / arch / blackfin / mach-bf561 / boards / cm_bf561.c
CommitLineData
1394f032 1/*
96f1050d
RG
2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2008-2009 Bluetechnix
4 * 2005 National ICT Australia (NICTA)
5 * Aidan Williams <aidan@nicta.com.au>
1394f032 6 *
96f1050d 7 * Licensed under the GPL-2 or later.
1394f032
BW
8 */
9
10#include <linux/device.h>
11#include <linux/platform_device.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/spi/spi.h>
15#include <linux/spi/flash.h>
c4a2c58d 16#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
f02bcec5 17#include <linux/usb/isp1362.h>
b964c592 18#endif
0a87e3e9 19#include <linux/ata_platform.h>
1f83b8f1 20#include <linux/irq.h>
4ba7b5f0 21#include <linux/gpio.h>
c6c4d7bb 22#include <asm/dma.h>
1394f032 23#include <asm/bfin5xx_spi.h>
5d448dd5 24#include <asm/portmux.h>
14b03204 25#include <asm/dpmc.h>
9c21453e 26#include <linux/mtd/physmap.h>
1394f032
BW
27
28/*
29 * Name the Board for the /proc/cpuinfo
30 */
066954a3 31const char bfin_board_name[] = "Bluetechnix CM BF561";
1394f032 32
c4a2c58d 33#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
d2d50aa9 34/* all SPI peripherals info goes here */
1394f032 35
c4a2c58d 36#if IS_ENABLED(CONFIG_MTD_M25P80)
1394f032
BW
37static struct mtd_partition bfin_spi_flash_partitions[] = {
38 {
aa582977 39 .name = "bootloader(spi)",
1394f032
BW
40 .size = 0x00020000,
41 .offset = 0,
42 .mask_flags = MTD_CAP_ROM
1f83b8f1 43 }, {
aa582977 44 .name = "linux kernel(spi)",
1394f032
BW
45 .size = 0xe0000,
46 .offset = 0x20000
1f83b8f1 47 }, {
aa582977 48 .name = "file system(spi)",
1394f032
BW
49 .size = 0x700000,
50 .offset = 0x00100000,
51 }
52};
53
54static struct flash_platform_data bfin_spi_flash_data = {
55 .name = "m25p80",
56 .parts = bfin_spi_flash_partitions,
57 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
58 .type = "m25p64",
59};
60
61/* SPI flash chip (m25p64) */
62static struct bfin5xx_spi_chip spi_flash_chip_info = {
63 .enable_dma = 0, /* use dma transfer with this chip*/
1394f032
BW
64};
65#endif
66
67static struct spi_board_info bfin_spi_board_info[] __initdata = {
c4a2c58d 68#if IS_ENABLED(CONFIG_MTD_M25P80)
1394f032
BW
69 {
70 /* the modalias must be the same as spi device driver name */
71 .modalias = "m25p80", /* Name of spi_driver for this device */
72 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 73 .bus_num = 0, /* Framework bus number */
1394f032
BW
74 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
75 .platform_data = &bfin_spi_flash_data,
76 .controller_data = &spi_flash_chip_info,
77 .mode = SPI_MODE_3,
78 },
79#endif
80
c4a2c58d 81#if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
1394f032 82 {
7ba80063 83 .modalias = "ad183x",
1394f032 84 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 85 .bus_num = 0,
7ba80063 86 .chip_select = 4,
1394f032
BW
87 },
88#endif
c4a2c58d 89#if IS_ENABLED(CONFIG_MMC_SPI)
1394f032 90 {
f3f704d3 91 .modalias = "mmc_spi",
9c21453e 92 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 93 .bus_num = 0,
9c21453e 94 .chip_select = 1,
1394f032
BW
95 .mode = SPI_MODE_3,
96 },
97#endif
98};
99
c6c4d7bb
BW
100/* SPI (0) */
101static struct resource bfin_spi0_resource[] = {
102 [0] = {
103 .start = SPI0_REGBASE,
104 .end = SPI0_REGBASE + 0xFF,
105 .flags = IORESOURCE_MEM,
106 },
107 [1] = {
108 .start = CH_SPI,
109 .end = CH_SPI,
53122693
YL
110 .flags = IORESOURCE_DMA,
111 },
112 [2] = {
113 .start = IRQ_SPI,
114 .end = IRQ_SPI,
c6c4d7bb 115 .flags = IORESOURCE_IRQ,
53122693 116 },
c6c4d7bb
BW
117};
118
1394f032 119/* SPI controller data */
c6c4d7bb 120static struct bfin5xx_spi_master bfin_spi0_info = {
1394f032
BW
121 .num_chipselect = 8,
122 .enable_dma = 1, /* master has the ability to do dma transfer */
5d448dd5 123 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1394f032
BW
124};
125
c6c4d7bb
BW
126static struct platform_device bfin_spi0_device = {
127 .name = "bfin-spi",
128 .id = 0, /* Bus number */
129 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
130 .resource = bfin_spi0_resource,
1394f032 131 .dev = {
c6c4d7bb 132 .platform_data = &bfin_spi0_info, /* Passed to driver */
1394f032
BW
133 },
134};
135#endif /* spi master and devices */
136
137
c4a2c58d 138#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
0d4a89bb
MH
139static struct platform_device hitachi_fb_device = {
140 .name = "hitachi-tx09",
141};
142#endif
143
144
c4a2c58d 145#if IS_ENABLED(CONFIG_SMC91X)
61f09b5a
MH
146#include <linux/smc91x.h>
147
148static struct smc91x_platdata smc91x_info = {
2fb04fdf
RK
149 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
150 SMC91X_NOWAIT,
61f09b5a
MH
151 .leda = RPC_LED_100_10,
152 .ledb = RPC_LED_TX_RX,
153};
1394f032
BW
154
155static struct resource smc91x_resources[] = {
156 {
157 .name = "smc91x-regs",
158 .start = 0x28000300,
159 .end = 0x28000300 + 16,
160 .flags = IORESOURCE_MEM,
1f83b8f1 161 }, {
1394f032
BW
162 .start = IRQ_PF0,
163 .end = IRQ_PF0,
164 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
165 },
166};
167static struct platform_device smc91x_device = {
168 .name = "smc91x",
169 .id = 0,
170 .num_resources = ARRAY_SIZE(smc91x_resources),
171 .resource = smc91x_resources,
61f09b5a
MH
172 .dev = {
173 .platform_data = &smc91x_info,
174 },
1394f032
BW
175};
176#endif
177
c4a2c58d 178#if IS_ENABLED(CONFIG_SMSC911X)
9c21453e
HK
179#include <linux/smsc911x.h>
180
181static struct resource smsc911x_resources[] = {
182 {
183 .name = "smsc911x-memory",
184 .start = 0x24008000,
185 .end = 0x24008000 + 0xFF,
186 .flags = IORESOURCE_MEM,
187 },
188 {
189 .start = IRQ_PF43,
190 .end = IRQ_PF43,
191 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
192 },
193};
194
195static struct smsc911x_platform_config smsc911x_config = {
196 .flags = SMSC911X_USE_16BIT,
197 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
198 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
199 .phy_interface = PHY_INTERFACE_MODE_MII,
200};
201
202static struct platform_device smsc911x_device = {
203 .name = "smsc911x",
204 .id = 0,
205 .num_resources = ARRAY_SIZE(smsc911x_resources),
206 .resource = smsc911x_resources,
207 .dev = {
208 .platform_data = &smsc911x_config,
209 },
210};
211#endif
212
c4a2c58d 213#if IS_ENABLED(CONFIG_USB_NET2272)
9c21453e
HK
214static struct resource net2272_bfin_resources[] = {
215 {
216 .start = 0x24000000,
217 .end = 0x24000000 + 0x100,
218 .flags = IORESOURCE_MEM,
219 }, {
220 .start = IRQ_PF45,
221 .end = IRQ_PF45,
222 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
223 },
224};
225
226static struct platform_device net2272_bfin_device = {
227 .name = "net2272",
228 .id = -1,
229 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
230 .resource = net2272_bfin_resources,
231};
232#endif
233
c4a2c58d 234#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
1394f032
BW
235static struct resource isp1362_hcd_resources[] = {
236 {
237 .start = 0x24008000,
238 .end = 0x24008000,
239 .flags = IORESOURCE_MEM,
1f83b8f1 240 }, {
1394f032
BW
241 .start = 0x24008004,
242 .end = 0x24008004,
243 .flags = IORESOURCE_MEM,
1f83b8f1 244 }, {
1394f032
BW
245 .start = IRQ_PF47,
246 .end = IRQ_PF47,
9e75894c 247 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
1394f032
BW
248 },
249};
250
251static struct isp1362_platform_data isp1362_priv = {
252 .sel15Kres = 1,
253 .clknotstop = 0,
254 .oc_enable = 0,
255 .int_act_high = 0,
256 .int_edge_triggered = 0,
257 .remote_wakeup_connected = 0,
258 .no_power_switching = 1,
259 .power_switching_mode = 0,
260};
261
262static struct platform_device isp1362_hcd_device = {
263 .name = "isp1362-hcd",
264 .id = 0,
265 .dev = {
266 .platform_data = &isp1362_priv,
267 },
268 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
269 .resource = isp1362_hcd_resources,
270};
271#endif
272
c4a2c58d 273#if IS_ENABLED(CONFIG_SERIAL_BFIN)
6bd1fbea
SZ
274#ifdef CONFIG_SERIAL_BFIN_UART0
275static struct resource bfin_uart0_resources[] = {
1f83b8f1 276 {
6bd1fbea
SZ
277 .start = BFIN_UART_THR,
278 .end = BFIN_UART_GCTL+2,
1f83b8f1
MF
279 .flags = IORESOURCE_MEM,
280 },
edb0a640
SZ
281 {
282 .start = IRQ_UART_TX,
283 .end = IRQ_UART_TX,
284 .flags = IORESOURCE_IRQ,
285 },
6bd1fbea
SZ
286 {
287 .start = IRQ_UART_RX,
edb0a640 288 .end = IRQ_UART_RX,
6bd1fbea
SZ
289 .flags = IORESOURCE_IRQ,
290 },
291 {
292 .start = IRQ_UART_ERROR,
293 .end = IRQ_UART_ERROR,
294 .flags = IORESOURCE_IRQ,
295 },
296 {
297 .start = CH_UART_TX,
298 .end = CH_UART_TX,
299 .flags = IORESOURCE_DMA,
300 },
301 {
302 .start = CH_UART_RX,
303 .end = CH_UART_RX,
304 .flags = IORESOURCE_DMA,
305 },
306};
307
a8b19886 308static unsigned short bfin_uart0_peripherals[] = {
6bd1fbea 309 P_UART0_TX, P_UART0_RX, 0
1394f032
BW
310};
311
6bd1fbea 312static struct platform_device bfin_uart0_device = {
1f83b8f1 313 .name = "bfin-uart",
6bd1fbea
SZ
314 .id = 0,
315 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
316 .resource = bfin_uart0_resources,
317 .dev = {
318 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
319 },
1394f032
BW
320};
321#endif
6bd1fbea 322#endif
1394f032 323
c4a2c58d 324#if IS_ENABLED(CONFIG_BFIN_SIR)
5be36d22 325#ifdef CONFIG_BFIN_SIR0
42bd8bcb 326static struct resource bfin_sir0_resources[] = {
5be36d22
GY
327 {
328 .start = 0xFFC00400,
329 .end = 0xFFC004FF,
330 .flags = IORESOURCE_MEM,
331 },
42bd8bcb
GY
332 {
333 .start = IRQ_UART0_RX,
334 .end = IRQ_UART0_RX+1,
335 .flags = IORESOURCE_IRQ,
336 },
337 {
338 .start = CH_UART0_RX,
339 .end = CH_UART0_RX+1,
340 .flags = IORESOURCE_DMA,
341 },
5be36d22
GY
342};
343
42bd8bcb 344static struct platform_device bfin_sir0_device = {
5be36d22
GY
345 .name = "bfin_sir",
346 .id = 0,
42bd8bcb
GY
347 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
348 .resource = bfin_sir0_resources,
5be36d22
GY
349};
350#endif
42bd8bcb 351#endif
5be36d22 352
c4a2c58d 353#if IS_ENABLED(CONFIG_PATA_PLATFORM)
fe5aeb93 354#define PATA_INT IRQ_PF46
c6c4d7bb
BW
355
356static struct pata_platform_info bfin_pata_platform_data = {
357 .ioport_shift = 2,
c6c4d7bb
BW
358};
359
360static struct resource bfin_pata_resources[] = {
361 {
362 .start = 0x2400C000,
363 .end = 0x2400C001F,
364 .flags = IORESOURCE_MEM,
365 },
366 {
367 .start = 0x2400D018,
368 .end = 0x2400D01B,
369 .flags = IORESOURCE_MEM,
370 },
371 {
372 .start = PATA_INT,
373 .end = PATA_INT,
53f3cc46 374 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
c6c4d7bb
BW
375 },
376};
377
378static struct platform_device bfin_pata_device = {
379 .name = "pata_platform",
380 .id = -1,
381 .num_resources = ARRAY_SIZE(bfin_pata_resources),
382 .resource = bfin_pata_resources,
383 .dev = {
384 .platform_data = &bfin_pata_platform_data,
385 }
386};
387#endif
388
c4a2c58d 389#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
9c21453e
HK
390static struct mtd_partition para_partitions[] = {
391 {
392 .name = "bootloader(nor)",
393 .size = 0x40000,
394 .offset = 0,
395 }, {
396 .name = "linux kernel(nor)",
397 .size = 0x100000,
398 .offset = MTDPART_OFS_APPEND,
399 }, {
400 .name = "file system(nor)",
401 .size = MTDPART_SIZ_FULL,
402 .offset = MTDPART_OFS_APPEND,
403 }
404};
405
406static struct physmap_flash_data para_flash_data = {
407 .width = 2,
408 .parts = para_partitions,
409 .nr_parts = ARRAY_SIZE(para_partitions),
410};
411
412static struct resource para_flash_resource = {
413 .start = 0x20000000,
414 .end = 0x207fffff,
415 .flags = IORESOURCE_MEM,
416};
417
418static struct platform_device para_flash_device = {
419 .name = "physmap-flash",
420 .id = 0,
421 .dev = {
422 .platform_data = &para_flash_data,
423 },
424 .num_resources = 1,
425 .resource = &para_flash_resource,
426};
427#endif
428
14b03204
MH
429static const unsigned int cclk_vlev_datasheet[] =
430{
431 VRPAIR(VLEV_085, 250000000),
432 VRPAIR(VLEV_090, 300000000),
433 VRPAIR(VLEV_095, 313000000),
434 VRPAIR(VLEV_100, 350000000),
435 VRPAIR(VLEV_105, 400000000),
436 VRPAIR(VLEV_110, 444000000),
437 VRPAIR(VLEV_115, 450000000),
438 VRPAIR(VLEV_120, 475000000),
439 VRPAIR(VLEV_125, 500000000),
440 VRPAIR(VLEV_130, 600000000),
441};
442
443static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
444 .tuple_tab = cclk_vlev_datasheet,
445 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
446 .vr_settling_time = 25 /* us */,
447};
448
449static struct platform_device bfin_dpmc = {
450 .name = "bfin dpmc",
451 .dev = {
452 .platform_data = &bfin_dmpc_vreg_data,
453 },
454};
455
1394f032
BW
456static struct platform_device *cm_bf561_devices[] __initdata = {
457
14b03204
MH
458 &bfin_dpmc,
459
c4a2c58d 460#if IS_ENABLED(CONFIG_FB_HITACHI_TX09)
0d4a89bb
MH
461 &hitachi_fb_device,
462#endif
463
c4a2c58d 464#if IS_ENABLED(CONFIG_SERIAL_BFIN)
6bd1fbea
SZ
465#ifdef CONFIG_SERIAL_BFIN_UART0
466 &bfin_uart0_device,
467#endif
1394f032
BW
468#endif
469
c4a2c58d 470#if IS_ENABLED(CONFIG_BFIN_SIR)
42bd8bcb
GY
471#ifdef CONFIG_BFIN_SIR0
472 &bfin_sir0_device,
473#endif
5be36d22
GY
474#endif
475
c4a2c58d 476#if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
1394f032
BW
477 &isp1362_hcd_device,
478#endif
479
c4a2c58d 480#if IS_ENABLED(CONFIG_SMC91X)
1394f032
BW
481 &smc91x_device,
482#endif
483
c4a2c58d 484#if IS_ENABLED(CONFIG_SMSC911X)
9c21453e
HK
485 &smsc911x_device,
486#endif
487
c4a2c58d 488#if IS_ENABLED(CONFIG_USB_NET2272)
9c21453e
HK
489 &net2272_bfin_device,
490#endif
491
c4a2c58d 492#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
c6c4d7bb 493 &bfin_spi0_device,
1394f032
BW
494#endif
495
c4a2c58d 496#if IS_ENABLED(CONFIG_PATA_PLATFORM)
c6c4d7bb
BW
497 &bfin_pata_device,
498#endif
c97618d3 499
c4a2c58d 500#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
9c21453e
HK
501 &para_flash_device,
502#endif
1394f032
BW
503};
504
9be8631b
MF
505static int __init net2272_init(void)
506{
c4a2c58d 507#if IS_ENABLED(CONFIG_USB_NET2272)
9be8631b
MF
508 int ret;
509
510 ret = gpio_request(GPIO_PF46, "net2272");
511 if (ret)
512 return ret;
513
514 /* Reset USB Chip, PF46 */
515 gpio_direction_output(GPIO_PF46, 0);
516 mdelay(2);
517 gpio_set_value(GPIO_PF46, 1);
518#endif
519
520 return 0;
521}
522
1394f032
BW
523static int __init cm_bf561_init(void)
524{
b85d858b 525 printk(KERN_INFO "%s(): registering device resources\n", __func__);
1394f032 526 platform_add_devices(cm_bf561_devices, ARRAY_SIZE(cm_bf561_devices));
c4a2c58d 527#if IS_ENABLED(CONFIG_SPI_BFIN5XX)
1394f032
BW
528 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
529#endif
c6c4d7bb 530
c4a2c58d 531#if IS_ENABLED(CONFIG_PATA_PLATFORM)
bc2f6bd8 532 irq_set_status_flags(PATA_INT, IRQ_NOAUTOEN);
c6c4d7bb 533#endif
9be8631b
MF
534
535 if (net2272_init())
536 pr_warning("unable to configure net2272; it probably won't work\n");
537
1394f032
BW
538 return 0;
539}
540
541arch_initcall(cm_bf561_init);
c13ce9fd
SZ
542
543static struct platform_device *cm_bf561_early_devices[] __initdata = {
544#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
545#ifdef CONFIG_SERIAL_BFIN_UART0
546 &bfin_uart0_device,
547#endif
548#endif
549};
550
551void __init native_machine_early_platform_add_devices(void)
552{
553 printk(KERN_INFO "register early platform devices\n");
554 early_platform_add_devices(cm_bf561_early_devices,
555 ARRAY_SIZE(cm_bf561_early_devices));
556}
This page took 0.793378 seconds and 5 git commands to generate.