blob: 007ebdc6c993eec5a8d73243a18a6be382557501 [file] [log] [blame]
Vikram Pandita577145f2009-05-28 14:04:04 -07001/*
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>
Vikram Panditac426df82009-08-28 11:24:08 -070015#include <linux/interrupt.h>
Vikram Pandita577145f2009-05-28 14:04:04 -070016
Tony Lindgrence491cf2009-10-20 09:40:47 -070017#include <plat/gpmc.h>
Vikram Pandita577145f2009-05-28 14:04:04 -070018
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070019#include <mach/board-zoom.h>
20
vikram pandita62d0b3362009-11-22 10:11:31 -080021#define ZOOM_SMSC911X_CS 7
22#define ZOOM_SMSC911X_GPIO 158
23#define ZOOM_QUADUART_CS 3
24#define ZOOM_QUADUART_GPIO 102
Vikram Pandita577145f2009-05-28 14:04:04 -070025#define QUART_CLK 1843200
26#define DEBUG_BASE 0x08000000
vikram pandita62d0b3362009-11-22 10:11:31 -080027#define ZOOM_ETHR_START DEBUG_BASE
Vikram Pandita577145f2009-05-28 14:04:04 -070028
vikram pandita62d0b3362009-11-22 10:11:31 -080029static struct resource zoom_smsc911x_resources[] = {
Vikram Pandita577145f2009-05-28 14:04:04 -070030 [0] = {
vikram pandita62d0b3362009-11-22 10:11:31 -080031 .start = ZOOM_ETHR_START,
32 .end = ZOOM_ETHR_START + SZ_4K,
Vikram Pandita577145f2009-05-28 14:04:04 -070033 .flags = IORESOURCE_MEM,
34 },
35 [1] = {
36 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
37 },
38};
39
vikram pandita62d0b3362009-11-22 10:11:31 -080040static struct smsc911x_platform_config zoom_smsc911x_config = {
Vikram Pandita577145f2009-05-28 14:04:04 -070041 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
42 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
43 .flags = SMSC911X_USE_32BIT,
44 .phy_interface = PHY_INTERFACE_MODE_MII,
45};
46
vikram pandita62d0b3362009-11-22 10:11:31 -080047static struct platform_device zoom_smsc911x_device = {
Vikram Pandita577145f2009-05-28 14:04:04 -070048 .name = "smsc911x",
49 .id = -1,
vikram pandita62d0b3362009-11-22 10:11:31 -080050 .num_resources = ARRAY_SIZE(zoom_smsc911x_resources),
51 .resource = zoom_smsc911x_resources,
Vikram Pandita577145f2009-05-28 14:04:04 -070052 .dev = {
vikram pandita62d0b3362009-11-22 10:11:31 -080053 .platform_data = &zoom_smsc911x_config,
Vikram Pandita577145f2009-05-28 14:04:04 -070054 },
55};
56
vikram pandita62d0b3362009-11-22 10:11:31 -080057static inline void __init zoom_init_smsc911x(void)
Vikram Pandita577145f2009-05-28 14:04:04 -070058{
59 int eth_cs;
60 unsigned long cs_mem_base;
61 int eth_gpio = 0;
62
vikram pandita62d0b3362009-11-22 10:11:31 -080063 eth_cs = ZOOM_SMSC911X_CS;
Vikram Pandita577145f2009-05-28 14:04:04 -070064
65 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
66 printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
67 return;
68 }
69
vikram pandita62d0b3362009-11-22 10:11:31 -080070 zoom_smsc911x_resources[0].start = cs_mem_base + 0x0;
71 zoom_smsc911x_resources[0].end = cs_mem_base + 0xff;
Vikram Pandita577145f2009-05-28 14:04:04 -070072
vikram pandita62d0b3362009-11-22 10:11:31 -080073 eth_gpio = ZOOM_SMSC911X_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -070074
vikram pandita62d0b3362009-11-22 10:11:31 -080075 zoom_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
Vikram Pandita577145f2009-05-28 14:04:04 -070076
77 if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
78 printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
79 eth_gpio);
80 return;
81 }
82 gpio_direction_input(eth_gpio);
83}
84
85static struct plat_serial8250_port serial_platform_data[] = {
86 {
Tony Lindgrena4f57b82010-04-30 12:57:14 -070087 .mapbase = ZOOM_UART_BASE,
Vikram Pandita577145f2009-05-28 14:04:04 -070088 .irq = OMAP_GPIO_IRQ(102),
89 .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
Vikram Panditac426df82009-08-28 11:24:08 -070090 .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING,
Vikram Pandita577145f2009-05-28 14:04:04 -070091 .iotype = UPIO_MEM,
92 .regshift = 1,
93 .uartclk = QUART_CLK,
94 }, {
95 .flags = 0
96 }
97};
98
vikram pandita62d0b3362009-11-22 10:11:31 -080099static struct platform_device zoom_debugboard_serial_device = {
Vikram Pandita577145f2009-05-28 14:04:04 -0700100 .name = "serial8250",
Sergio Aguirrefcbcea92010-03-01 12:17:15 -0600101 .id = PLAT8250_DEV_PLATFORM,
Vikram Pandita577145f2009-05-28 14:04:04 -0700102 .dev = {
103 .platform_data = serial_platform_data,
104 },
105};
106
vikram pandita62d0b3362009-11-22 10:11:31 -0800107static inline void __init zoom_init_quaduart(void)
Vikram Pandita577145f2009-05-28 14:04:04 -0700108{
109 int quart_cs;
110 unsigned long cs_mem_base;
111 int quart_gpio = 0;
112
vikram pandita62d0b3362009-11-22 10:11:31 -0800113 quart_cs = ZOOM_QUADUART_CS;
Vikram Pandita577145f2009-05-28 14:04:04 -0700114
115 if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
116 printk(KERN_ERR "Failed to request GPMC mem"
117 "for Quad UART(TL16CP754C)\n");
118 return;
119 }
120
vikram pandita62d0b3362009-11-22 10:11:31 -0800121 quart_gpio = ZOOM_QUADUART_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -0700122
123 if (gpio_request(quart_gpio, "TL16CP754C GPIO") < 0) {
124 printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
125 quart_gpio);
126 return;
127 }
128 gpio_direction_input(quart_gpio);
129}
130
vikram pandita62d0b3362009-11-22 10:11:31 -0800131static inline int omap_zoom_debugboard_detect(void)
Vikram Pandita577145f2009-05-28 14:04:04 -0700132{
133 int debug_board_detect = 0;
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500134 int ret = 1;
Vikram Pandita577145f2009-05-28 14:04:04 -0700135
vikram pandita62d0b3362009-11-22 10:11:31 -0800136 debug_board_detect = ZOOM_SMSC911X_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -0700137
vikram pandita62d0b3362009-11-22 10:11:31 -0800138 if (gpio_request(debug_board_detect, "Zoom debug board detect") < 0) {
139 printk(KERN_ERR "Failed to request GPIO%d for Zoom debug"
Vikram Pandita577145f2009-05-28 14:04:04 -0700140 "board detect\n", debug_board_detect);
141 return 0;
142 }
143 gpio_direction_input(debug_board_detect);
144
145 if (!gpio_get_value(debug_board_detect)) {
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500146 ret = 0;
Vikram Pandita577145f2009-05-28 14:04:04 -0700147 }
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500148 gpio_free(debug_board_detect);
149 return ret;
Vikram Pandita577145f2009-05-28 14:04:04 -0700150}
151
vikram pandita62d0b3362009-11-22 10:11:31 -0800152static struct platform_device *zoom_devices[] __initdata = {
153 &zoom_smsc911x_device,
154 &zoom_debugboard_serial_device,
Vikram Pandita577145f2009-05-28 14:04:04 -0700155};
156
vikram pandita62d0b3362009-11-22 10:11:31 -0800157int __init zoom_debugboard_init(void)
Vikram Pandita577145f2009-05-28 14:04:04 -0700158{
vikram pandita62d0b3362009-11-22 10:11:31 -0800159 if (!omap_zoom_debugboard_detect())
Vikram Pandita577145f2009-05-28 14:04:04 -0700160 return 0;
161
vikram pandita62d0b3362009-11-22 10:11:31 -0800162 zoom_init_smsc911x();
163 zoom_init_quaduart();
164 return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
Vikram Pandita577145f2009-05-28 14:04:04 -0700165}