blob: 1e8540eabde98188ced71d321d7b531a685b463a [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>
Mike Rapoport21b42732011-04-16 22:29:30 +000018#include <plat/gpmc-smsc911x.h>
Vikram Pandita577145f2009-05-28 14:04:04 -070019
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070020#include <mach/board-zoom.h>
21
vikram pandita62d0b3362009-11-22 10:11:31 -080022#define ZOOM_SMSC911X_CS 7
23#define ZOOM_SMSC911X_GPIO 158
24#define ZOOM_QUADUART_CS 3
25#define ZOOM_QUADUART_GPIO 102
Charulatha V4e964252011-07-04 04:08:46 -070026#define ZOOM_QUADUART_RST_GPIO 152
Vikram Pandita577145f2009-05-28 14:04:04 -070027#define QUART_CLK 1843200
28#define DEBUG_BASE 0x08000000
vikram pandita62d0b3362009-11-22 10:11:31 -080029#define ZOOM_ETHR_START DEBUG_BASE
Vikram Pandita577145f2009-05-28 14:04:04 -070030
Mike Rapoport21b42732011-04-16 22:29:30 +000031static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
32 .cs = ZOOM_SMSC911X_CS,
33 .gpio_irq = ZOOM_SMSC911X_GPIO,
34 .gpio_reset = -EINVAL,
Vikram Pandita577145f2009-05-28 14:04:04 -070035 .flags = SMSC911X_USE_32BIT,
Vikram Pandita577145f2009-05-28 14:04:04 -070036};
37
vikram pandita62d0b3362009-11-22 10:11:31 -080038static inline void __init zoom_init_smsc911x(void)
Vikram Pandita577145f2009-05-28 14:04:04 -070039{
Mike Rapoport21b42732011-04-16 22:29:30 +000040 gpmc_smsc911x_init(&zoom_smsc911x_cfg);
Vikram Pandita577145f2009-05-28 14:04:04 -070041}
42
43static struct plat_serial8250_port serial_platform_data[] = {
44 {
Tony Lindgrena4f57b82010-04-30 12:57:14 -070045 .mapbase = ZOOM_UART_BASE,
Vikram Pandita577145f2009-05-28 14:04:04 -070046 .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
Vikram Panditac426df82009-08-28 11:24:08 -070047 .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING,
Vikram Pandita577145f2009-05-28 14:04:04 -070048 .iotype = UPIO_MEM,
49 .regshift = 1,
50 .uartclk = QUART_CLK,
51 }, {
52 .flags = 0
53 }
54};
55
vikram pandita62d0b3362009-11-22 10:11:31 -080056static struct platform_device zoom_debugboard_serial_device = {
Vikram Pandita577145f2009-05-28 14:04:04 -070057 .name = "serial8250",
Sergio Aguirrefcbcea92010-03-01 12:17:15 -060058 .id = PLAT8250_DEV_PLATFORM,
Vikram Pandita577145f2009-05-28 14:04:04 -070059 .dev = {
60 .platform_data = serial_platform_data,
61 },
62};
63
vikram pandita62d0b3362009-11-22 10:11:31 -080064static inline void __init zoom_init_quaduart(void)
Vikram Pandita577145f2009-05-28 14:04:04 -070065{
66 int quart_cs;
67 unsigned long cs_mem_base;
68 int quart_gpio = 0;
69
Charulatha V4e964252011-07-04 04:08:46 -070070 if (gpio_request_one(ZOOM_QUADUART_RST_GPIO,
71 GPIOF_OUT_INIT_LOW,
72 "TL16CP754C GPIO") < 0) {
73 pr_err("Failed to request GPIO%d for TL16CP754C\n",
74 ZOOM_QUADUART_RST_GPIO);
75 return;
76 }
77
vikram pandita62d0b3362009-11-22 10:11:31 -080078 quart_cs = ZOOM_QUADUART_CS;
Vikram Pandita577145f2009-05-28 14:04:04 -070079
80 if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
81 printk(KERN_ERR "Failed to request GPMC mem"
82 "for Quad UART(TL16CP754C)\n");
83 return;
84 }
85
vikram pandita62d0b3362009-11-22 10:11:31 -080086 quart_gpio = ZOOM_QUADUART_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -070087
Igor Grinbergbc593f52011-05-03 18:22:09 +030088 if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
Vikram Pandita577145f2009-05-28 14:04:04 -070089 printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
90 quart_gpio);
Tarun Kanti DebBarma46a0a542012-03-29 08:41:01 -070091
92 serial_platform_data[0].irq = gpio_to_irq(102);
Vikram Pandita577145f2009-05-28 14:04:04 -070093}
94
vikram pandita62d0b3362009-11-22 10:11:31 -080095static inline int omap_zoom_debugboard_detect(void)
Vikram Pandita577145f2009-05-28 14:04:04 -070096{
97 int debug_board_detect = 0;
Vikram Pandita2fcc81a2009-08-21 13:11:20 -050098 int ret = 1;
Vikram Pandita577145f2009-05-28 14:04:04 -070099
vikram pandita62d0b3362009-11-22 10:11:31 -0800100 debug_board_detect = ZOOM_SMSC911X_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -0700101
Igor Grinbergbc593f52011-05-03 18:22:09 +0300102 if (gpio_request_one(debug_board_detect, GPIOF_IN,
103 "Zoom debug board detect") < 0) {
vikram pandita62d0b3362009-11-22 10:11:31 -0800104 printk(KERN_ERR "Failed to request GPIO%d for Zoom debug"
Vikram Pandita577145f2009-05-28 14:04:04 -0700105 "board detect\n", debug_board_detect);
106 return 0;
107 }
Vikram Pandita577145f2009-05-28 14:04:04 -0700108
109 if (!gpio_get_value(debug_board_detect)) {
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500110 ret = 0;
Vikram Pandita577145f2009-05-28 14:04:04 -0700111 }
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500112 gpio_free(debug_board_detect);
113 return ret;
Vikram Pandita577145f2009-05-28 14:04:04 -0700114}
115
vikram pandita62d0b3362009-11-22 10:11:31 -0800116static struct platform_device *zoom_devices[] __initdata = {
vikram pandita62d0b3362009-11-22 10:11:31 -0800117 &zoom_debugboard_serial_device,
Vikram Pandita577145f2009-05-28 14:04:04 -0700118};
119
vikram pandita62d0b3362009-11-22 10:11:31 -0800120int __init zoom_debugboard_init(void)
Vikram Pandita577145f2009-05-28 14:04:04 -0700121{
vikram pandita62d0b3362009-11-22 10:11:31 -0800122 if (!omap_zoom_debugboard_detect())
Vikram Pandita577145f2009-05-28 14:04:04 -0700123 return 0;
124
vikram pandita62d0b3362009-11-22 10:11:31 -0800125 zoom_init_smsc911x();
126 zoom_init_quaduart();
127 return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
Vikram Pandita577145f2009-05-28 14:04:04 -0700128}