blob: f84be4eabfd1985af425717cfeb353c48ecd60a6 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
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
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080040#include <linux/pata_platform.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080041#include <linux/irq.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080042#include <asm/dma.h>
Bryan Wu1394f032007-05-06 14:50:22 -070043#include <asm/bfin5xx_spi.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080044#include <asm/reboot.h>
Bryan Wu1394f032007-05-06 14:50:22 -070045
46/*
47 * Name the Board for the /proc/cpuinfo
48 */
Mike Frysinger066954a2007-10-21 22:36:06 +080049const char bfin_board_name[] = "ADDS-BF533-STAMP";
Bryan Wu1394f032007-05-06 14:50:22 -070050
51#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
52static 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)
62static struct resource smc91x_resources[] = {
63 {
64 .name = "smc91x-regs",
65 .start = 0x20300300,
66 .end = 0x20300300 + 16,
67 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080068 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070069 .start = IRQ_PF7,
70 .end = IRQ_PF7,
71 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
72 },
73};
74
75static 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
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080083#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
84static struct platform_device bfin_fb_adv7393_device = {
85 .name = "bfin-adv7393",
86};
87#endif
88
Bryan Wu1394f032007-05-06 14:50:22 -070089#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
90static struct resource net2272_bfin_resources[] = {
91 {
92 .start = 0x20300000,
93 .end = 0x20300000 + 0x100,
94 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080095 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070096 .start = IRQ_PF10,
97 .end = IRQ_PF10,
98 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
99 },
100};
101
102static 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)
114static struct mtd_partition bfin_spi_flash_partitions[] = {
115 {
116 .name = "bootloader",
117 .size = 0x00020000,
118 .offset = 0,
119 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800120 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700121 .name = "kernel",
122 .size = 0xe0000,
123 .offset = 0x20000
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800124 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700125 .name = "file system",
126 .size = 0x700000,
127 .offset = 0x00100000,
128 }
129};
130
131static 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) */
139static 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 */
147static 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)
154static 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)
161static 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)
170static struct bfin5xx_spi_chip ad5304_chip_info = {
171 .enable_dma = 0,
172 .bits_per_word = 16,
173};
174#endif
175
Bryan Wued2fbf52007-05-21 18:09:10 +0800176#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
177static struct bfin5xx_spi_chip spi_mmc_chip_info = {
178 .enable_dma = 1,
179 .bits_per_word = 8,
180};
181#endif
182
Bryan Wu1394f032007-05-06 14:50:22 -0700183static 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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800189 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700190 .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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800201 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700202 .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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800212 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700213 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
214 .controller_data = &ad1836_spi_chip_info,
215 },
216#endif
217
Bryan Wued2fbf52007-05-21 18:09:10 +0800218#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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800222 .bus_num = 0,
Bryan Wued2fbf52007-05-21 18:09:10 +0800223 .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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800231 .bus_num = 0,
Bryan Wued2fbf52007-05-21 18:09:10 +0800232 .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
Bryan Wu1394f032007-05-06 14:50:22 -0700239#if defined(CONFIG_PBX)
240 {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800241 .modalias = "fxs-spi",
242 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800243 .bus_num = 0,
244 .chip_select = 8 - CONFIG_J11_JUMPER,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800245 .controller_data = &spi_si3xxx_chip_info,
Bryan Wu1394f032007-05-06 14:50:22 -0700246 .mode = SPI_MODE_3,
247 },
248 {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800249 .modalias = "fxo-spi",
250 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800251 .bus_num = 0,
252 .chip_select = 8 - CONFIG_J19_JUMPER,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800253 .controller_data = &spi_si3xxx_chip_info,
Bryan Wu1394f032007-05-06 14:50:22 -0700254 .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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800262 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700263 .chip_select = 2,
264 .platform_data = NULL,
265 .controller_data = &ad5304_chip_info,
266 .mode = SPI_MODE_2,
267 },
268#endif
269};
270
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800271/* SPI (0) */
272static 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
Bryan Wu1394f032007-05-06 14:50:22 -0700285/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800286static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700287 .num_chipselect = 8,
288 .enable_dma = 1, /* master has the ability to do dma transfer */
289};
290
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800291static 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,
Bryan Wu1394f032007-05-06 14:50:22 -0700296 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800297 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700298 },
299};
300#endif /* spi master and devices */
301
302#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
303static 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)
309static struct resource bfin_uart_resources[] = {
310 {
311 .start = 0xFFC00400,
312 .end = 0xFFC004FF,
313 .flags = IORESOURCE_MEM,
314 },
315};
316
317static 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)
326static struct platform_device bfin_sport0_uart_device = {
327 .name = "bfin-sport-uart",
328 .id = 0,
329};
330
331static struct platform_device bfin_sport1_uart_device = {
332 .name = "bfin-sport-uart",
333 .id = 1,
334};
335#endif
336
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800337#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
338#define PATA_INT 55
339
340static struct pata_platform_info bfin_pata_platform_data = {
341 .ioport_shift = 1,
342 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
343};
344
345static 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
363static 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
Bryan Wu1394f032007-05-06 14:50:22 -0700374static 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
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800383#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
384 &bfin_fb_adv7393_device,
385#endif
386
Bryan Wu1394f032007-05-06 14:50:22 -0700387#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)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800392 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700393#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
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800403
404#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
405 &bfin_pata_device,
406#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700407};
408
409static int __init stamp_init(void)
410{
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800411 int ret;
412
Bryan Wu1394f032007-05-06 14:50:22 -0700413 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800414 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
Bryan Wu1394f032007-05-06 14:50:22 -0700425#endif
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800426
427#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800428 spi_register_board_info(bfin_spi_board_info,
429 ARRAY_SIZE(bfin_spi_board_info));
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800430#endif
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800431#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
432 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
433#endif
434 return 0;
Bryan Wu1394f032007-05-06 14:50:22 -0700435}
436
437arch_initcall(stamp_init);
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800438
439void 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}