]>
Commit | Line | Data |
---|---|---|
577145f4 VP |
1 | /* |
2 | * Copyright (C) 2009 Texas Instruments Inc. | |
3 | * Mikkel Christensen <mlc@ti.com> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | */ | |
9 | ||
10 | #include <linux/kernel.h> | |
11 | #include <linux/init.h> | |
12 | #include <linux/gpio.h> | |
13 | #include <linux/serial_8250.h> | |
14 | #include <linux/smsc911x.h> | |
c426df87 | 15 | #include <linux/interrupt.h> |
577145f4 | 16 | |
ce491cf8 | 17 | #include <plat/gpmc.h> |
577145f4 | 18 | |
62d0b336 | 19 | #define ZOOM_SMSC911X_CS 7 |
20 | #define ZOOM_SMSC911X_GPIO 158 | |
21 | #define ZOOM_QUADUART_CS 3 | |
22 | #define ZOOM_QUADUART_GPIO 102 | |
577145f4 VP |
23 | #define QUART_CLK 1843200 |
24 | #define DEBUG_BASE 0x08000000 | |
62d0b336 | 25 | #define ZOOM_ETHR_START DEBUG_BASE |
577145f4 | 26 | |
62d0b336 | 27 | static struct resource zoom_smsc911x_resources[] = { |
577145f4 | 28 | [0] = { |
62d0b336 | 29 | .start = ZOOM_ETHR_START, |
30 | .end = ZOOM_ETHR_START + SZ_4K, | |
577145f4 VP |
31 | .flags = IORESOURCE_MEM, |
32 | }, | |
33 | [1] = { | |
34 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
35 | }, | |
36 | }; | |
37 | ||
62d0b336 | 38 | static struct smsc911x_platform_config zoom_smsc911x_config = { |
577145f4 VP |
39 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
40 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, | |
41 | .flags = SMSC911X_USE_32BIT, | |
42 | .phy_interface = PHY_INTERFACE_MODE_MII, | |
43 | }; | |
44 | ||
62d0b336 | 45 | static struct platform_device zoom_smsc911x_device = { |
577145f4 VP |
46 | .name = "smsc911x", |
47 | .id = -1, | |
62d0b336 | 48 | .num_resources = ARRAY_SIZE(zoom_smsc911x_resources), |
49 | .resource = zoom_smsc911x_resources, | |
577145f4 | 50 | .dev = { |
62d0b336 | 51 | .platform_data = &zoom_smsc911x_config, |
577145f4 VP |
52 | }, |
53 | }; | |
54 | ||
62d0b336 | 55 | static inline void __init zoom_init_smsc911x(void) |
577145f4 VP |
56 | { |
57 | int eth_cs; | |
58 | unsigned long cs_mem_base; | |
59 | int eth_gpio = 0; | |
60 | ||
62d0b336 | 61 | eth_cs = ZOOM_SMSC911X_CS; |
577145f4 VP |
62 | |
63 | if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { | |
64 | printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n"); | |
65 | return; | |
66 | } | |
67 | ||
62d0b336 | 68 | zoom_smsc911x_resources[0].start = cs_mem_base + 0x0; |
69 | zoom_smsc911x_resources[0].end = cs_mem_base + 0xff; | |
577145f4 | 70 | |
62d0b336 | 71 | eth_gpio = ZOOM_SMSC911X_GPIO; |
577145f4 | 72 | |
62d0b336 | 73 | zoom_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio); |
577145f4 VP |
74 | |
75 | if (gpio_request(eth_gpio, "smsc911x irq") < 0) { | |
76 | printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n", | |
77 | eth_gpio); | |
78 | return; | |
79 | } | |
80 | gpio_direction_input(eth_gpio); | |
81 | } | |
82 | ||
83 | static struct plat_serial8250_port serial_platform_data[] = { | |
84 | { | |
85 | .mapbase = 0x10000000, | |
86 | .irq = OMAP_GPIO_IRQ(102), | |
87 | .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ, | |
c426df87 | 88 | .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING, |
577145f4 VP |
89 | .iotype = UPIO_MEM, |
90 | .regshift = 1, | |
91 | .uartclk = QUART_CLK, | |
92 | }, { | |
93 | .flags = 0 | |
94 | } | |
95 | }; | |
96 | ||
62d0b336 | 97 | static struct platform_device zoom_debugboard_serial_device = { |
577145f4 | 98 | .name = "serial8250", |
fcbcea93 | 99 | .id = PLAT8250_DEV_PLATFORM, |
577145f4 VP |
100 | .dev = { |
101 | .platform_data = serial_platform_data, | |
102 | }, | |
103 | }; | |
104 | ||
62d0b336 | 105 | static inline void __init zoom_init_quaduart(void) |
577145f4 VP |
106 | { |
107 | int quart_cs; | |
108 | unsigned long cs_mem_base; | |
109 | int quart_gpio = 0; | |
110 | ||
62d0b336 | 111 | quart_cs = ZOOM_QUADUART_CS; |
577145f4 VP |
112 | |
113 | if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) { | |
114 | printk(KERN_ERR "Failed to request GPMC mem" | |
115 | "for Quad UART(TL16CP754C)\n"); | |
116 | return; | |
117 | } | |
118 | ||
62d0b336 | 119 | quart_gpio = ZOOM_QUADUART_GPIO; |
577145f4 VP |
120 | |
121 | if (gpio_request(quart_gpio, "TL16CP754C GPIO") < 0) { | |
122 | printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n", | |
123 | quart_gpio); | |
124 | return; | |
125 | } | |
126 | gpio_direction_input(quart_gpio); | |
127 | } | |
128 | ||
62d0b336 | 129 | static inline int omap_zoom_debugboard_detect(void) |
577145f4 VP |
130 | { |
131 | int debug_board_detect = 0; | |
2fcc81a3 | 132 | int ret = 1; |
577145f4 | 133 | |
62d0b336 | 134 | debug_board_detect = ZOOM_SMSC911X_GPIO; |
577145f4 | 135 | |
62d0b336 | 136 | if (gpio_request(debug_board_detect, "Zoom debug board detect") < 0) { |
137 | printk(KERN_ERR "Failed to request GPIO%d for Zoom debug" | |
577145f4 VP |
138 | "board detect\n", debug_board_detect); |
139 | return 0; | |
140 | } | |
141 | gpio_direction_input(debug_board_detect); | |
142 | ||
143 | if (!gpio_get_value(debug_board_detect)) { | |
2fcc81a3 | 144 | ret = 0; |
577145f4 | 145 | } |
2fcc81a3 VP |
146 | gpio_free(debug_board_detect); |
147 | return ret; | |
577145f4 VP |
148 | } |
149 | ||
62d0b336 | 150 | static struct platform_device *zoom_devices[] __initdata = { |
151 | &zoom_smsc911x_device, | |
152 | &zoom_debugboard_serial_device, | |
577145f4 VP |
153 | }; |
154 | ||
62d0b336 | 155 | int __init zoom_debugboard_init(void) |
577145f4 | 156 | { |
62d0b336 | 157 | if (!omap_zoom_debugboard_detect()) |
577145f4 VP |
158 | return 0; |
159 | ||
62d0b336 | 160 | zoom_init_smsc911x(); |
161 | zoom_init_quaduart(); | |
162 | return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices)); | |
577145f4 | 163 | } |