David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/plat-omap/debug-devices.c |
| 3 | * |
| 4 | * Copyright (C) 2005 Nokia Corporation |
| 5 | * Modified from mach-omap2/board-h4.c |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 11 | #include <linux/gpio.h> |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 15 | #include <linux/io.h> |
Ladislav Michl | 3bc4801 | 2009-12-11 16:16:33 -0800 | [diff] [blame] | 16 | #include <linux/smc91x.h> |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 17 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 18 | #include <mach/hardware.h> |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 19 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 20 | #include <plat/board.h> |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 21 | |
| 22 | |
| 23 | /* Many OMAP development platforms reuse the same "debug board"; these |
| 24 | * platforms include H2, H3, H4, and Perseus2. |
| 25 | */ |
| 26 | |
Ladislav Michl | 3bc4801 | 2009-12-11 16:16:33 -0800 | [diff] [blame] | 27 | static struct smc91x_platdata smc91x_info = { |
| 28 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, |
| 29 | .leda = RPC_LED_100_10, |
| 30 | .ledb = RPC_LED_TX_RX, |
| 31 | }; |
| 32 | |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 33 | static struct resource smc91x_resources[] = { |
| 34 | [0] = { |
| 35 | .flags = IORESOURCE_MEM, |
| 36 | }, |
| 37 | [1] = { |
Russell King | e7b3dc7 | 2008-01-14 22:30:10 +0000 | [diff] [blame] | 38 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 39 | }, |
| 40 | }; |
| 41 | |
| 42 | static struct platform_device smc91x_device = { |
| 43 | .name = "smc91x", |
| 44 | .id = -1, |
Ladislav Michl | 3bc4801 | 2009-12-11 16:16:33 -0800 | [diff] [blame] | 45 | .dev = { |
| 46 | .platform_data = &smc91x_info, |
| 47 | }, |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 48 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 49 | .resource = smc91x_resources, |
| 50 | }; |
| 51 | |
| 52 | static struct resource led_resources[] = { |
| 53 | [0] = { |
| 54 | .flags = IORESOURCE_MEM, |
| 55 | }, |
| 56 | }; |
| 57 | |
| 58 | static struct platform_device led_device = { |
| 59 | .name = "omap_dbg_led", |
| 60 | .id = -1, |
| 61 | .num_resources = ARRAY_SIZE(led_resources), |
| 62 | .resource = led_resources, |
| 63 | }; |
| 64 | |
| 65 | static struct platform_device *debug_devices[] __initdata = { |
| 66 | &smc91x_device, |
| 67 | &led_device, |
| 68 | /* ps2 kbd + mouse ports */ |
| 69 | /* 4 extra uarts */ |
| 70 | /* 6 input dip switches */ |
| 71 | /* 8 output pins */ |
| 72 | }; |
| 73 | |
| 74 | int __init debug_card_init(u32 addr, unsigned gpio) |
| 75 | { |
| 76 | int status; |
| 77 | |
| 78 | smc91x_resources[0].start = addr + 0x300; |
| 79 | smc91x_resources[0].end = addr + 0x30f; |
| 80 | |
David Brownell | 15f74b0 | 2008-12-10 17:35:26 -0800 | [diff] [blame] | 81 | smc91x_resources[1].start = gpio_to_irq(gpio); |
| 82 | smc91x_resources[1].end = gpio_to_irq(gpio); |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 83 | |
Jarkko Nikula | f2d18fe | 2008-12-10 17:35:30 -0800 | [diff] [blame] | 84 | status = gpio_request(gpio, "SMC91x irq"); |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 85 | if (status < 0) { |
| 86 | printk(KERN_ERR "GPIO%d unavailable for smc91x IRQ\n", gpio); |
| 87 | return status; |
| 88 | } |
David Brownell | 40e3925 | 2008-12-10 17:35:26 -0800 | [diff] [blame] | 89 | gpio_direction_input(gpio); |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 90 | |
| 91 | led_resources[0].start = addr; |
| 92 | led_resources[0].end = addr + SZ_4K - 1; |
| 93 | |
| 94 | return platform_add_devices(debug_devices, ARRAY_SIZE(debug_devices)); |
| 95 | } |