blob: 5a4678edd65a9a8eb31a766fd566ee86a968e8f9 [file] [log] [blame]
David Brownellf6049312006-12-06 17:14:03 -08001/*
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 King2f8163b2011-07-26 10:53:52 +010011#include <linux/gpio.h>
David Brownellf6049312006-12-06 17:14:03 -080012#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010015#include <linux/io.h>
Ladislav Michl3bc48012009-12-11 16:16:33 -080016#include <linux/smc91x.h>
David Brownellf6049312006-12-06 17:14:03 -080017
Russell Kinga09e64f2008-08-05 16:14:15 +010018#include <mach/hardware.h>
Paul Walmsley3fca4eb2012-10-16 11:19:17 -070019#include "../mach-omap2/debug-devices.h"
David Brownellf6049312006-12-06 17:14:03 -080020
David Brownellf6049312006-12-06 17:14:03 -080021/* Many OMAP development platforms reuse the same "debug board"; these
22 * platforms include H2, H3, H4, and Perseus2.
23 */
24
Ladislav Michl3bc48012009-12-11 16:16:33 -080025static struct smc91x_platdata smc91x_info = {
26 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
27 .leda = RPC_LED_100_10,
28 .ledb = RPC_LED_TX_RX,
29};
30
David Brownellf6049312006-12-06 17:14:03 -080031static struct resource smc91x_resources[] = {
32 [0] = {
33 .flags = IORESOURCE_MEM,
34 },
35 [1] = {
Russell Kinge7b3dc72008-01-14 22:30:10 +000036 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
David Brownellf6049312006-12-06 17:14:03 -080037 },
38};
39
40static struct platform_device smc91x_device = {
41 .name = "smc91x",
42 .id = -1,
Ladislav Michl3bc48012009-12-11 16:16:33 -080043 .dev = {
44 .platform_data = &smc91x_info,
45 },
David Brownellf6049312006-12-06 17:14:03 -080046 .num_resources = ARRAY_SIZE(smc91x_resources),
47 .resource = smc91x_resources,
48};
49
50static struct resource led_resources[] = {
51 [0] = {
52 .flags = IORESOURCE_MEM,
53 },
54};
55
56static struct platform_device led_device = {
57 .name = "omap_dbg_led",
58 .id = -1,
59 .num_resources = ARRAY_SIZE(led_resources),
60 .resource = led_resources,
61};
62
63static struct platform_device *debug_devices[] __initdata = {
64 &smc91x_device,
65 &led_device,
66 /* ps2 kbd + mouse ports */
67 /* 4 extra uarts */
68 /* 6 input dip switches */
69 /* 8 output pins */
70};
71
72int __init debug_card_init(u32 addr, unsigned gpio)
73{
74 int status;
75
76 smc91x_resources[0].start = addr + 0x300;
77 smc91x_resources[0].end = addr + 0x30f;
78
David Brownell15f74b02008-12-10 17:35:26 -080079 smc91x_resources[1].start = gpio_to_irq(gpio);
80 smc91x_resources[1].end = gpio_to_irq(gpio);
David Brownellf6049312006-12-06 17:14:03 -080081
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -080082 status = gpio_request(gpio, "SMC91x irq");
David Brownellf6049312006-12-06 17:14:03 -080083 if (status < 0) {
84 printk(KERN_ERR "GPIO%d unavailable for smc91x IRQ\n", gpio);
85 return status;
86 }
David Brownell40e39252008-12-10 17:35:26 -080087 gpio_direction_input(gpio);
David Brownellf6049312006-12-06 17:14:03 -080088
89 led_resources[0].start = addr;
90 led_resources[0].end = addr + SZ_4K - 1;
91
92 return platform_add_devices(debug_devices, ARRAY_SIZE(debug_devices));
93}