2 * Copyright (C) 2009 Texas Instruments Inc.
3 * Mikkel Christensen <mlc@ti.com>
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.
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>
16 #include <mach/gpmc.h>
18 #define ZOOM2_SMSC911X_CS 7
19 #define ZOOM2_SMSC911X_GPIO 158
20 #define ZOOM2_QUADUART_CS 3
21 #define ZOOM2_QUADUART_GPIO 102
22 #define QUART_CLK 1843200
23 #define DEBUG_BASE 0x08000000
24 #define ZOOM2_ETHR_START DEBUG_BASE
26 static struct resource zoom2_smsc911x_resources[] = {
28 .start = ZOOM2_ETHR_START,
29 .end = ZOOM2_ETHR_START + SZ_4K,
30 .flags = IORESOURCE_MEM,
33 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
37 static struct smsc911x_platform_config zoom2_smsc911x_config = {
38 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
39 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
40 .flags = SMSC911X_USE_32BIT,
41 .phy_interface = PHY_INTERFACE_MODE_MII,
44 static struct platform_device zoom2_smsc911x_device = {
47 .num_resources = ARRAY_SIZE(zoom2_smsc911x_resources),
48 .resource = zoom2_smsc911x_resources,
50 .platform_data = &zoom2_smsc911x_config,
54 static inline void __init zoom2_init_smsc911x(void)
57 unsigned long cs_mem_base;
60 eth_cs = ZOOM2_SMSC911X_CS;
62 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
63 printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
67 zoom2_smsc911x_resources[0].start = cs_mem_base + 0x0;
68 zoom2_smsc911x_resources[0].end = cs_mem_base + 0xff;
70 eth_gpio = ZOOM2_SMSC911X_GPIO;
72 zoom2_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
74 if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
75 printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
79 gpio_direction_input(eth_gpio);
82 static struct plat_serial8250_port serial_platform_data[] = {
84 .mapbase = 0x10000000,
85 .irq = OMAP_GPIO_IRQ(102),
86 .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
95 static struct platform_device zoom2_debugboard_serial_device = {
97 .id = PLAT8250_DEV_PLATFORM1,
99 .platform_data = serial_platform_data,
103 static inline void __init zoom2_init_quaduart(void)
106 unsigned long cs_mem_base;
109 quart_cs = ZOOM2_QUADUART_CS;
111 if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
112 printk(KERN_ERR "Failed to request GPMC mem"
113 "for Quad UART(TL16CP754C)\n");
117 quart_gpio = ZOOM2_QUADUART_GPIO;
119 if (gpio_request(quart_gpio, "TL16CP754C GPIO") < 0) {
120 printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
124 gpio_direction_input(quart_gpio);
127 static inline int omap_zoom2_debugboard_detect(void)
129 int debug_board_detect = 0;
131 debug_board_detect = ZOOM2_SMSC911X_GPIO;
133 if (gpio_request(debug_board_detect, "Zoom2 debug board detect") < 0) {
134 printk(KERN_ERR "Failed to request GPIO%d for Zoom2 debug"
135 "board detect\n", debug_board_detect);
138 gpio_direction_input(debug_board_detect);
140 if (!gpio_get_value(debug_board_detect)) {
141 gpio_free(debug_board_detect);
147 static struct platform_device *zoom2_devices[] __initdata = {
148 &zoom2_smsc911x_device,
149 &zoom2_debugboard_serial_device,
152 int __init omap_zoom2_debugboard_init(void)
154 if (!omap_zoom2_debugboard_detect())
157 zoom2_init_smsc911x();
158 zoom2_init_quaduart();
159 return platform_add_devices(zoom2_devices, ARRAY_SIZE(zoom2_devices));