blob: 7601c3be1b5c3a70256d8d7d3af091261a7a88d6 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
2 * File: arch/blackfin/mach-bf561/ezkit.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
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>
Mike Frysingerde8c43f2008-01-24 17:14:04 +080032#include <linux/mtd/mtd.h>
33#include <linux/mtd/partitions.h>
34#include <linux/mtd/physmap.h>
Bryan Wu1394f032007-05-06 14:50:22 -070035#include <linux/spi/spi.h>
Michael Hennerich140a9ae2007-05-21 18:09:13 +080036#include <linux/irq.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080037#include <linux/interrupt.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080038#include <linux/pata_platform.h>
39#include <asm/dma.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080040#include <asm/bfin5xx_spi.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080041#include <asm/portmux.h>
Bryan Wu1394f032007-05-06 14:50:22 -070042
43/*
44 * Name the Board for the /proc/cpuinfo
45 */
Mike Frysinger066954a2007-10-21 22:36:06 +080046const char bfin_board_name[] = "ADDS-BF561-EZKIT";
Bryan Wu1394f032007-05-06 14:50:22 -070047
Michael Hennerich140a9ae2007-05-21 18:09:13 +080048#define ISP1761_BASE 0x2C0F0000
49#define ISP1761_IRQ IRQ_PF10
50
51#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
52static struct resource bfin_isp1761_resources[] = {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080053 {
Michael Hennerich140a9ae2007-05-21 18:09:13 +080054 .name = "isp1761-regs",
55 .start = ISP1761_BASE + 0x00000000,
56 .end = ISP1761_BASE + 0x000fffff,
57 .flags = IORESOURCE_MEM,
58 },
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080059 {
Michael Hennerich140a9ae2007-05-21 18:09:13 +080060 .start = ISP1761_IRQ,
61 .end = ISP1761_IRQ,
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct platform_device bfin_isp1761_device = {
67 .name = "isp1761",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
70 .resource = bfin_isp1761_resources,
71};
72
73static struct platform_device *bfin_isp1761_devices[] = {
74 &bfin_isp1761_device,
75};
76
77int __init bfin_isp1761_init(void)
78{
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080079 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
Michael Hennerich140a9ae2007-05-21 18:09:13 +080080
81 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
82 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
83
84 return platform_add_devices(bfin_isp1761_devices, num_devices);
85}
86
87void __exit bfin_isp1761_exit(void)
88{
89 platform_device_unregister(&bfin_isp1761_device);
90}
91
92arch_initcall(bfin_isp1761_init);
93#endif
94
Bryan Wu1394f032007-05-06 14:50:22 -070095/*
96 * USB-LAN EzExtender board
97 * Driver needs to know address, irq and flag pin.
98 */
99#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
100static struct resource smc91x_resources[] = {
101 {
102 .name = "smc91x-regs",
103 .start = 0x2C010300,
104 .end = 0x2C010300 + 16,
105 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800106 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700107
108 .start = IRQ_PF9,
109 .end = IRQ_PF9,
110 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
111 },
112};
113
114static struct platform_device smc91x_device = {
115 .name = "smc91x",
116 .id = 0,
117 .num_resources = ARRAY_SIZE(smc91x_resources),
118 .resource = smc91x_resources,
119};
120#endif
121
Michael Hennerich561cc182007-11-17 23:56:08 +0800122#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
123static struct resource ax88180_resources[] = {
124 [0] = {
125 .start = 0x2c000000,
126 .end = 0x2c000000 + 0x8000,
127 .flags = IORESOURCE_MEM,
128 },
129 [1] = {
130 .start = IRQ_PF10,
131 .end = IRQ_PF10,
132 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
133 },
134};
135
136static struct platform_device ax88180_device = {
137 .name = "ax88180",
138 .id = -1,
139 .num_resources = ARRAY_SIZE(ax88180_resources),
140 .resource = ax88180_resources,
141};
142#endif
143
Bryan Wu1394f032007-05-06 14:50:22 -0700144#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
145static struct resource bfin_uart_resources[] = {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800146 {
147 .start = 0xFFC00400,
148 .end = 0xFFC004FF,
149 .flags = IORESOURCE_MEM,
150 },
Bryan Wu1394f032007-05-06 14:50:22 -0700151};
152
153static struct platform_device bfin_uart_device = {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800154 .name = "bfin-uart",
155 .id = 1,
156 .num_resources = ARRAY_SIZE(bfin_uart_resources),
157 .resource = bfin_uart_resources,
Bryan Wu1394f032007-05-06 14:50:22 -0700158};
159#endif
160
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800161static struct mtd_partition ezkit_partitions[] = {
162 {
163 .name = "Bootloader",
164 .size = 0x20000,
165 .offset = 0,
166 }, {
167 .name = "Kernel",
168 .size = 0xE0000,
169 .offset = MTDPART_OFS_APPEND,
170 }, {
171 .name = "RootFS",
172 .size = MTDPART_SIZ_FULL,
173 .offset = MTDPART_OFS_APPEND,
174 }
175};
176
177static struct physmap_flash_data ezkit_flash_data = {
178 .width = 2,
179 .parts = ezkit_partitions,
180 .nr_parts = ARRAY_SIZE(ezkit_partitions),
181};
182
183static struct resource ezkit_flash_resource = {
184 .start = 0x20000000,
185 .end = 0x207fffff,
186 .flags = IORESOURCE_MEM,
187};
188
189static struct platform_device ezkit_flash_device = {
190 .name = "physmap-flash",
191 .id = 0,
192 .dev = {
193 .platform_data = &ezkit_flash_data,
194 },
195 .num_resources = 1,
196 .resource = &ezkit_flash_resource,
197};
198
Bryan Wu1394f032007-05-06 14:50:22 -0700199#ifdef CONFIG_SPI_BFIN
200#if defined(CONFIG_SND_BLACKFIN_AD1836) \
201 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
202static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
203 .enable_dma = 0,
204 .bits_per_word = 16,
205};
206#endif
207#endif
208
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800209/* SPI (0) */
210static struct resource bfin_spi0_resource[] = {
211 [0] = {
212 .start = SPI0_REGBASE,
213 .end = SPI0_REGBASE + 0xFF,
214 .flags = IORESOURCE_MEM,
215 },
216 [1] = {
217 .start = CH_SPI,
218 .end = CH_SPI,
219 .flags = IORESOURCE_IRQ,
220 }
221};
222
Bryan Wu1394f032007-05-06 14:50:22 -0700223/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800224static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700225 .num_chipselect = 8,
226 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800227 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700228};
229
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800230static struct platform_device bfin_spi0_device = {
231 .name = "bfin-spi",
232 .id = 0, /* Bus number */
233 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
234 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700235 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800236 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700237 },
238};
239
240static struct spi_board_info bfin_spi_board_info[] __initdata = {
241#if defined(CONFIG_SND_BLACKFIN_AD1836) \
242 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
243 {
244 .modalias = "ad1836-spi",
245 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800246 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700247 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
248 .controller_data = &ad1836_spi_chip_info,
249 },
250#endif
251};
252
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800253#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
254#define PATA_INT 55
255
256static struct pata_platform_info bfin_pata_platform_data = {
257 .ioport_shift = 1,
258 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
259};
260
261static struct resource bfin_pata_resources[] = {
262 {
263 .start = 0x20314020,
264 .end = 0x2031403F,
265 .flags = IORESOURCE_MEM,
266 },
267 {
268 .start = 0x2031401C,
269 .end = 0x2031401F,
270 .flags = IORESOURCE_MEM,
271 },
272 {
273 .start = PATA_INT,
274 .end = PATA_INT,
275 .flags = IORESOURCE_IRQ,
276 },
277};
278
279static struct platform_device bfin_pata_device = {
280 .name = "pata_platform",
281 .id = -1,
282 .num_resources = ARRAY_SIZE(bfin_pata_resources),
283 .resource = bfin_pata_resources,
284 .dev = {
285 .platform_data = &bfin_pata_platform_data,
286 }
287};
288#endif
289
Michael Hennerich2463ef22008-01-27 16:49:48 +0800290#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
291#include <linux/input.h>
292#include <linux/gpio_keys.h>
293
294static struct gpio_keys_button bfin_gpio_keys_table[] = {
295 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
296 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
297 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
298 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
299};
300
301static struct gpio_keys_platform_data bfin_gpio_keys_data = {
302 .buttons = bfin_gpio_keys_table,
303 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
304};
305
306static struct platform_device bfin_device_gpiokeys = {
307 .name = "gpio-keys",
308 .dev = {
309 .platform_data = &bfin_gpio_keys_data,
310 },
311};
312#endif
313
Bryan Wue3163952008-01-24 16:19:15 +0800314#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
315#include <linux/i2c-gpio.h>
316
317static struct i2c_gpio_platform_data i2c_gpio_data = {
318 .sda_pin = 1,
319 .scl_pin = 0,
320 .sda_is_open_drain = 0,
321 .scl_is_open_drain = 0,
322 .udelay = 40,
323};
324
325static struct platform_device i2c_gpio_device = {
326 .name = "i2c-gpio",
327 .id = 0,
328 .dev = {
329 .platform_data = &i2c_gpio_data,
330 },
331};
332#endif
333
Bryan Wu1394f032007-05-06 14:50:22 -0700334static struct platform_device *ezkit_devices[] __initdata = {
335#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
336 &smc91x_device,
337#endif
Michael Hennerich561cc182007-11-17 23:56:08 +0800338
339#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
340 &ax88180_device,
341#endif
342
Bryan Wu1394f032007-05-06 14:50:22 -0700343#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800344 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700345#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800346
Bryan Wu1394f032007-05-06 14:50:22 -0700347#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800348 &bfin_uart_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700349#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800350
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800351#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
352 &bfin_pata_device,
353#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800354
355#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
356 &bfin_device_gpiokeys,
357#endif
Bryan Wue3163952008-01-24 16:19:15 +0800358
359#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
360 &i2c_gpio_device,
361#endif
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800362 &ezkit_flash_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700363};
364
365static int __init ezkit_init(void)
366{
367 int ret;
368
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800369 printk(KERN_INFO "%s(): registering device resources\n", __func__);
370
371 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
Bryan Wu1394f032007-05-06 14:50:22 -0700372 if (ret < 0)
373 return ret;
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800374
375#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
376 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
377 SSYNC();
378#endif
379
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800380#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
381 spi_register_board_info(bfin_spi_board_info,
382 ARRAY_SIZE(bfin_spi_board_info));
383#endif
384
385#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
386 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
387#endif
388 return 0;
Bryan Wu1394f032007-05-06 14:50:22 -0700389}
390
391arch_initcall(ezkit_init);