Commit | Line | Data |
---|---|---|
1394f032 BW |
1 | /* |
2 | * File: arch/blackfin/mach-bf533/ezkit.c | |
d2d50aa9 | 3 | * Based on: Original Work |
1394f032 BW |
4 | * Author: Aidan Williams <aidan@nicta.com.au> |
5 | * | |
6 | * Created: 2005 | |
7 | * Description: | |
8 | * | |
9 | * Modified: Robin Getz <rgetz@blackfin.uclinux.org> - Named the boards | |
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> | |
67f2d33e | 37 | #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) |
f02bcec5 | 38 | #include <linux/usb/isp1362.h> |
67f2d33e | 39 | #endif |
0a87e3e9 | 40 | #include <linux/ata_platform.h> |
1f83b8f1 | 41 | #include <linux/irq.h> |
c6c4d7bb | 42 | #include <asm/dma.h> |
1394f032 | 43 | #include <asm/bfin5xx_spi.h> |
5d448dd5 | 44 | #include <asm/portmux.h> |
14b03204 | 45 | #include <asm/dpmc.h> |
1394f032 BW |
46 | |
47 | /* | |
48 | * Name the Board for the /proc/cpuinfo | |
49 | */ | |
066954a3 | 50 | const char bfin_board_name[] = "ADDS-BF533-EZKIT"; |
1394f032 BW |
51 | |
52 | #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) | |
53 | static struct platform_device rtc_device = { | |
54 | .name = "rtc-bfin", | |
55 | .id = -1, | |
56 | }; | |
57 | #endif | |
58 | ||
c6c4d7bb BW |
59 | #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) |
60 | static struct platform_device bfin_fb_adv7393_device = { | |
61 | .name = "bfin-adv7393", | |
62 | }; | |
63 | #endif | |
64 | ||
1394f032 BW |
65 | /* |
66 | * USB-LAN EzExtender board | |
67 | * Driver needs to know address, irq and flag pin. | |
68 | */ | |
69 | #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) | |
70 | static struct resource smc91x_resources[] = { | |
71 | { | |
72 | .name = "smc91x-regs", | |
73 | .start = 0x20310300, | |
74 | .end = 0x20310300 + 16, | |
75 | .flags = IORESOURCE_MEM, | |
1f83b8f1 | 76 | }, { |
1394f032 BW |
77 | .start = IRQ_PF9, |
78 | .end = IRQ_PF9, | |
79 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, | |
80 | }, | |
81 | }; | |
82 | static struct platform_device smc91x_device = { | |
83 | .name = "smc91x", | |
84 | .id = 0, | |
85 | .num_resources = ARRAY_SIZE(smc91x_resources), | |
86 | .resource = smc91x_resources, | |
87 | }; | |
88 | #endif | |
89 | ||
1394f032 BW |
90 | #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) |
91 | static struct mtd_partition bfin_spi_flash_partitions[] = { | |
92 | { | |
aa582977 | 93 | .name = "bootloader(spi)", |
1394f032 BW |
94 | .size = 0x00020000, |
95 | .offset = 0, | |
96 | .mask_flags = MTD_CAP_ROM | |
1f83b8f1 | 97 | }, { |
aa582977 | 98 | .name = "linux kernel(spi)", |
1394f032 | 99 | .size = 0xe0000, |
edf05641 | 100 | .offset = MTDPART_OFS_APPEND, |
1f83b8f1 | 101 | }, { |
aa582977 | 102 | .name = "file system(spi)", |
edf05641 MF |
103 | .size = MTDPART_SIZ_FULL, |
104 | .offset = MTDPART_OFS_APPEND, | |
1394f032 BW |
105 | } |
106 | }; | |
107 | ||
108 | static struct flash_platform_data bfin_spi_flash_data = { | |
109 | .name = "m25p80", | |
110 | .parts = bfin_spi_flash_partitions, | |
111 | .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions), | |
112 | .type = "m25p64", | |
113 | }; | |
114 | ||
115 | /* SPI flash chip (m25p64) */ | |
116 | static struct bfin5xx_spi_chip spi_flash_chip_info = { | |
117 | .enable_dma = 0, /* use dma transfer with this chip*/ | |
118 | .bits_per_word = 8, | |
119 | }; | |
120 | #endif | |
121 | ||
122 | #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE) | |
123 | /* SPI ADC chip */ | |
124 | static struct bfin5xx_spi_chip spi_adc_chip_info = { | |
125 | .enable_dma = 1, /* use dma transfer with this chip*/ | |
126 | .bits_per_word = 16, | |
127 | }; | |
128 | #endif | |
129 | ||
130 | #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) | |
131 | static struct bfin5xx_spi_chip ad1836_spi_chip_info = { | |
132 | .enable_dma = 0, | |
133 | .bits_per_word = 16, | |
134 | }; | |
135 | #endif | |
136 | ||
6e668936 MH |
137 | #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) |
138 | static struct bfin5xx_spi_chip spidev_chip_info = { | |
139 | .enable_dma = 0, | |
140 | .bits_per_word = 8, | |
141 | }; | |
142 | #endif | |
143 | ||
1394f032 BW |
144 | static struct spi_board_info bfin_spi_board_info[] __initdata = { |
145 | #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE) | |
146 | { | |
147 | /* the modalias must be the same as spi device driver name */ | |
148 | .modalias = "m25p80", /* Name of spi_driver for this device */ | |
149 | .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */ | |
c6c4d7bb | 150 | .bus_num = 0, /* Framework bus number */ |
1394f032 BW |
151 | .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/ |
152 | .platform_data = &bfin_spi_flash_data, | |
153 | .controller_data = &spi_flash_chip_info, | |
154 | .mode = SPI_MODE_3, | |
155 | }, | |
156 | #endif | |
157 | ||
158 | #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE) | |
159 | { | |
160 | .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */ | |
161 | .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */ | |
c6c4d7bb | 162 | .bus_num = 0, /* Framework bus number */ |
1394f032 BW |
163 | .chip_select = 1, /* Framework chip select. */ |
164 | .platform_data = NULL, /* No spi_driver specific config */ | |
165 | .controller_data = &spi_adc_chip_info, | |
166 | }, | |
167 | #endif | |
168 | ||
169 | #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) | |
170 | { | |
171 | .modalias = "ad1836-spi", | |
172 | .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ | |
c6c4d7bb | 173 | .bus_num = 0, |
1394f032 BW |
174 | .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, |
175 | .controller_data = &ad1836_spi_chip_info, | |
176 | }, | |
177 | #endif | |
6e668936 MH |
178 | #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) |
179 | { | |
180 | .modalias = "spidev", | |
181 | .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ | |
182 | .bus_num = 0, | |
183 | .chip_select = 1, | |
184 | .controller_data = &spidev_chip_info, | |
185 | }, | |
186 | #endif | |
1394f032 BW |
187 | }; |
188 | ||
5bda2723 | 189 | #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) |
c6c4d7bb BW |
190 | /* SPI (0) */ |
191 | static struct resource bfin_spi0_resource[] = { | |
192 | [0] = { | |
193 | .start = SPI0_REGBASE, | |
194 | .end = SPI0_REGBASE + 0xFF, | |
195 | .flags = IORESOURCE_MEM, | |
196 | }, | |
197 | [1] = { | |
198 | .start = CH_SPI, | |
199 | .end = CH_SPI, | |
200 | .flags = IORESOURCE_IRQ, | |
201 | } | |
202 | }; | |
203 | ||
1394f032 | 204 | /* SPI controller data */ |
c6c4d7bb | 205 | static struct bfin5xx_spi_master bfin_spi0_info = { |
1394f032 BW |
206 | .num_chipselect = 8, |
207 | .enable_dma = 1, /* master has the ability to do dma transfer */ | |
5d448dd5 | 208 | .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, |
1394f032 BW |
209 | }; |
210 | ||
c6c4d7bb BW |
211 | static struct platform_device bfin_spi0_device = { |
212 | .name = "bfin-spi", | |
213 | .id = 0, /* Bus number */ | |
214 | .num_resources = ARRAY_SIZE(bfin_spi0_resource), | |
215 | .resource = bfin_spi0_resource, | |
1394f032 | 216 | .dev = { |
c6c4d7bb | 217 | .platform_data = &bfin_spi0_info, /* Passed to driver */ |
1394f032 BW |
218 | }, |
219 | }; | |
220 | #endif /* spi master and devices */ | |
221 | ||
222 | #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) | |
223 | static struct resource bfin_uart_resources[] = { | |
224 | { | |
225 | .start = 0xFFC00400, | |
226 | .end = 0xFFC004FF, | |
227 | .flags = IORESOURCE_MEM, | |
228 | }, | |
229 | }; | |
230 | ||
231 | static struct platform_device bfin_uart_device = { | |
232 | .name = "bfin-uart", | |
233 | .id = 1, | |
234 | .num_resources = ARRAY_SIZE(bfin_uart_resources), | |
235 | .resource = bfin_uart_resources, | |
236 | }; | |
237 | #endif | |
238 | ||
5be36d22 GY |
239 | #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) |
240 | static struct resource bfin_sir_resources[] = { | |
241 | #ifdef CONFIG_BFIN_SIR0 | |
242 | { | |
243 | .start = 0xFFC00400, | |
244 | .end = 0xFFC004FF, | |
245 | .flags = IORESOURCE_MEM, | |
246 | }, | |
247 | #endif | |
248 | }; | |
249 | ||
250 | static struct platform_device bfin_sir_device = { | |
251 | .name = "bfin_sir", | |
252 | .id = 0, | |
253 | .num_resources = ARRAY_SIZE(bfin_sir_resources), | |
254 | .resource = bfin_sir_resources, | |
255 | }; | |
256 | #endif | |
257 | ||
c6c4d7bb BW |
258 | #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) |
259 | #define PATA_INT 55 | |
260 | ||
261 | static struct pata_platform_info bfin_pata_platform_data = { | |
262 | .ioport_shift = 1, | |
263 | .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED, | |
264 | }; | |
265 | ||
266 | static struct resource bfin_pata_resources[] = { | |
267 | { | |
268 | .start = 0x20314020, | |
269 | .end = 0x2031403F, | |
270 | .flags = IORESOURCE_MEM, | |
271 | }, | |
272 | { | |
273 | .start = 0x2031401C, | |
274 | .end = 0x2031401F, | |
275 | .flags = IORESOURCE_MEM, | |
276 | }, | |
277 | { | |
278 | .start = PATA_INT, | |
279 | .end = PATA_INT, | |
280 | .flags = IORESOURCE_IRQ, | |
281 | }, | |
282 | }; | |
283 | ||
284 | static struct platform_device bfin_pata_device = { | |
285 | .name = "pata_platform", | |
286 | .id = -1, | |
287 | .num_resources = ARRAY_SIZE(bfin_pata_resources), | |
288 | .resource = bfin_pata_resources, | |
289 | .dev = { | |
290 | .platform_data = &bfin_pata_platform_data, | |
291 | } | |
292 | }; | |
293 | #endif | |
294 | ||
2463ef22 MH |
295 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
296 | #include <linux/input.h> | |
297 | #include <linux/gpio_keys.h> | |
298 | ||
299 | static struct gpio_keys_button bfin_gpio_keys_table[] = { | |
300 | {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"}, | |
301 | {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"}, | |
302 | {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"}, | |
303 | {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"}, | |
304 | }; | |
305 | ||
306 | static struct gpio_keys_platform_data bfin_gpio_keys_data = { | |
307 | .buttons = bfin_gpio_keys_table, | |
308 | .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table), | |
309 | }; | |
310 | ||
311 | static struct platform_device bfin_device_gpiokeys = { | |
312 | .name = "gpio-keys", | |
313 | .dev = { | |
314 | .platform_data = &bfin_gpio_keys_data, | |
315 | }, | |
316 | }; | |
317 | #endif | |
318 | ||
cad2ab65 MF |
319 | static struct resource bfin_gpios_resources = { |
320 | .start = 0, | |
321 | .end = MAX_BLACKFIN_GPIOS - 1, | |
322 | .flags = IORESOURCE_IRQ, | |
323 | }; | |
324 | ||
325 | static struct platform_device bfin_gpios_device = { | |
326 | .name = "simple-gpio", | |
327 | .id = -1, | |
328 | .num_resources = 1, | |
329 | .resource = &bfin_gpios_resources, | |
330 | }; | |
331 | ||
e3163954 BW |
332 | #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) |
333 | #include <linux/i2c-gpio.h> | |
334 | ||
335 | static struct i2c_gpio_platform_data i2c_gpio_data = { | |
336 | .sda_pin = 1, | |
337 | .scl_pin = 0, | |
338 | .sda_is_open_drain = 0, | |
339 | .scl_is_open_drain = 0, | |
340 | .udelay = 40, | |
341 | }; | |
342 | ||
343 | static struct platform_device i2c_gpio_device = { | |
344 | .name = "i2c-gpio", | |
345 | .id = 0, | |
346 | .dev = { | |
347 | .platform_data = &i2c_gpio_data, | |
348 | }, | |
349 | }; | |
350 | #endif | |
351 | ||
14b03204 MH |
352 | static const unsigned int cclk_vlev_datasheet[] = |
353 | { | |
354 | VRPAIR(VLEV_085, 250000000), | |
355 | VRPAIR(VLEV_090, 376000000), | |
356 | VRPAIR(VLEV_095, 426000000), | |
357 | VRPAIR(VLEV_100, 426000000), | |
358 | VRPAIR(VLEV_105, 476000000), | |
359 | VRPAIR(VLEV_110, 476000000), | |
360 | VRPAIR(VLEV_115, 476000000), | |
361 | VRPAIR(VLEV_120, 600000000), | |
362 | VRPAIR(VLEV_125, 600000000), | |
363 | VRPAIR(VLEV_130, 600000000), | |
364 | }; | |
365 | ||
366 | static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = { | |
367 | .tuple_tab = cclk_vlev_datasheet, | |
368 | .tabsize = ARRAY_SIZE(cclk_vlev_datasheet), | |
369 | .vr_settling_time = 25 /* us */, | |
370 | }; | |
371 | ||
372 | static struct platform_device bfin_dpmc = { | |
373 | .name = "bfin dpmc", | |
374 | .dev = { | |
375 | .platform_data = &bfin_dmpc_vreg_data, | |
376 | }, | |
377 | }; | |
378 | ||
1394f032 | 379 | static struct platform_device *ezkit_devices[] __initdata = { |
14b03204 MH |
380 | |
381 | &bfin_dpmc, | |
382 | ||
1394f032 BW |
383 | #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) |
384 | &smc91x_device, | |
385 | #endif | |
386 | ||
387 | #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) | |
c6c4d7bb BW |
388 | &bfin_spi0_device, |
389 | #endif | |
390 | ||
391 | #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE) | |
392 | &bfin_fb_adv7393_device, | |
1394f032 BW |
393 | #endif |
394 | ||
395 | #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) | |
396 | &rtc_device, | |
397 | #endif | |
398 | ||
399 | #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) | |
400 | &bfin_uart_device, | |
401 | #endif | |
c6c4d7bb | 402 | |
5be36d22 GY |
403 | #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) |
404 | &bfin_sir_device, | |
405 | #endif | |
406 | ||
c6c4d7bb BW |
407 | #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) |
408 | &bfin_pata_device, | |
409 | #endif | |
2463ef22 MH |
410 | |
411 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
412 | &bfin_device_gpiokeys, | |
413 | #endif | |
e3163954 BW |
414 | |
415 | #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) | |
416 | &i2c_gpio_device, | |
417 | #endif | |
cad2ab65 MF |
418 | |
419 | &bfin_gpios_device, | |
1394f032 BW |
420 | }; |
421 | ||
422 | static int __init ezkit_init(void) | |
423 | { | |
b85d858b | 424 | printk(KERN_INFO "%s(): registering device resources\n", __func__); |
1394f032 | 425 | platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices)); |
1394f032 | 426 | spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); |
c6c4d7bb BW |
427 | |
428 | #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) | |
429 | irq_desc[PATA_INT].status |= IRQ_NOAUTOEN; | |
430 | #endif | |
1394f032 BW |
431 | return 0; |
432 | } | |
433 | ||
434 | arch_initcall(ezkit_init); |