blob: 0d8d91917d1030f2bafe7498c3c3c43eac8c058b [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
Russ Dill5b3689f2012-03-23 02:21:37 -070017#include <linux/regulator/fixed.h>
18#include <linux/regulator/machine.h>
19
Tony Lindgrence491cf2009-10-20 09:40:47 -070020#include <plat/gpmc.h>
Mike Rapoport21b42732011-04-16 22:29:30 +000021#include <plat/gpmc-smsc911x.h>
Vikram Pandita577145f2009-05-28 14:04:04 -070022
Manjunath Kondaiah G04aeae72010-10-08 09:58:35 -070023#include <mach/board-zoom.h>
24
Tony Lindgrendbc04162012-08-31 10:59:07 -070025#include "soc.h"
26#include "common.h"
27
vikram pandita62d0b3362009-11-22 10:11:31 -080028#define ZOOM_SMSC911X_CS 7
29#define ZOOM_SMSC911X_GPIO 158
30#define ZOOM_QUADUART_CS 3
31#define ZOOM_QUADUART_GPIO 102
Charulatha V4e964252011-07-04 04:08:46 -070032#define ZOOM_QUADUART_RST_GPIO 152
Vikram Pandita577145f2009-05-28 14:04:04 -070033#define QUART_CLK 1843200
34#define DEBUG_BASE 0x08000000
vikram pandita62d0b3362009-11-22 10:11:31 -080035#define ZOOM_ETHR_START DEBUG_BASE
Vikram Pandita577145f2009-05-28 14:04:04 -070036
Mike Rapoport21b42732011-04-16 22:29:30 +000037static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
38 .cs = ZOOM_SMSC911X_CS,
39 .gpio_irq = ZOOM_SMSC911X_GPIO,
40 .gpio_reset = -EINVAL,
Vikram Pandita577145f2009-05-28 14:04:04 -070041 .flags = SMSC911X_USE_32BIT,
Vikram Pandita577145f2009-05-28 14:04:04 -070042};
43
vikram pandita62d0b3362009-11-22 10:11:31 -080044static inline void __init zoom_init_smsc911x(void)
Vikram Pandita577145f2009-05-28 14:04:04 -070045{
Mike Rapoport21b42732011-04-16 22:29:30 +000046 gpmc_smsc911x_init(&zoom_smsc911x_cfg);
Vikram Pandita577145f2009-05-28 14:04:04 -070047}
48
49static struct plat_serial8250_port serial_platform_data[] = {
50 {
Tony Lindgrena4f57b82010-04-30 12:57:14 -070051 .mapbase = ZOOM_UART_BASE,
Vikram Pandita577145f2009-05-28 14:04:04 -070052 .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
Vikram Panditac426df82009-08-28 11:24:08 -070053 .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING,
Vikram Pandita577145f2009-05-28 14:04:04 -070054 .iotype = UPIO_MEM,
55 .regshift = 1,
56 .uartclk = QUART_CLK,
57 }, {
58 .flags = 0
59 }
60};
61
vikram pandita62d0b3362009-11-22 10:11:31 -080062static struct platform_device zoom_debugboard_serial_device = {
Vikram Pandita577145f2009-05-28 14:04:04 -070063 .name = "serial8250",
Sergio Aguirrefcbcea92010-03-01 12:17:15 -060064 .id = PLAT8250_DEV_PLATFORM,
Vikram Pandita577145f2009-05-28 14:04:04 -070065 .dev = {
66 .platform_data = serial_platform_data,
67 },
68};
69
vikram pandita62d0b3362009-11-22 10:11:31 -080070static inline void __init zoom_init_quaduart(void)
Vikram Pandita577145f2009-05-28 14:04:04 -070071{
72 int quart_cs;
73 unsigned long cs_mem_base;
74 int quart_gpio = 0;
75
Charulatha V4e964252011-07-04 04:08:46 -070076 if (gpio_request_one(ZOOM_QUADUART_RST_GPIO,
77 GPIOF_OUT_INIT_LOW,
78 "TL16CP754C GPIO") < 0) {
79 pr_err("Failed to request GPIO%d for TL16CP754C\n",
80 ZOOM_QUADUART_RST_GPIO);
81 return;
82 }
83
vikram pandita62d0b3362009-11-22 10:11:31 -080084 quart_cs = ZOOM_QUADUART_CS;
Vikram Pandita577145f2009-05-28 14:04:04 -070085
86 if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
Paul Walmsley7852ec02012-07-26 00:54:26 -060087 pr_err("Failed to request GPMC mem for Quad UART(TL16CP754C)\n");
Vikram Pandita577145f2009-05-28 14:04:04 -070088 return;
89 }
90
vikram pandita62d0b3362009-11-22 10:11:31 -080091 quart_gpio = ZOOM_QUADUART_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -070092
Igor Grinbergbc593f52011-05-03 18:22:09 +030093 if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
Vikram Pandita577145f2009-05-28 14:04:04 -070094 printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
95 quart_gpio);
Tarun Kanti DebBarma46a0a542012-03-29 08:41:01 -070096
97 serial_platform_data[0].irq = gpio_to_irq(102);
Vikram Pandita577145f2009-05-28 14:04:04 -070098}
99
vikram pandita62d0b3362009-11-22 10:11:31 -0800100static inline int omap_zoom_debugboard_detect(void)
Vikram Pandita577145f2009-05-28 14:04:04 -0700101{
102 int debug_board_detect = 0;
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500103 int ret = 1;
Vikram Pandita577145f2009-05-28 14:04:04 -0700104
vikram pandita62d0b3362009-11-22 10:11:31 -0800105 debug_board_detect = ZOOM_SMSC911X_GPIO;
Vikram Pandita577145f2009-05-28 14:04:04 -0700106
Igor Grinbergbc593f52011-05-03 18:22:09 +0300107 if (gpio_request_one(debug_board_detect, GPIOF_IN,
108 "Zoom debug board detect") < 0) {
Paul Walmsley7852ec02012-07-26 00:54:26 -0600109 pr_err("Failed to request GPIO%d for Zoom debug board detect\n",
110 debug_board_detect);
Vikram Pandita577145f2009-05-28 14:04:04 -0700111 return 0;
112 }
Vikram Pandita577145f2009-05-28 14:04:04 -0700113
114 if (!gpio_get_value(debug_board_detect)) {
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500115 ret = 0;
Vikram Pandita577145f2009-05-28 14:04:04 -0700116 }
Vikram Pandita2fcc81a2009-08-21 13:11:20 -0500117 gpio_free(debug_board_detect);
118 return ret;
Vikram Pandita577145f2009-05-28 14:04:04 -0700119}
120
vikram pandita62d0b3362009-11-22 10:11:31 -0800121static struct platform_device *zoom_devices[] __initdata = {
vikram pandita62d0b3362009-11-22 10:11:31 -0800122 &zoom_debugboard_serial_device,
Vikram Pandita577145f2009-05-28 14:04:04 -0700123};
124
Russ Dill5b3689f2012-03-23 02:21:37 -0700125static struct regulator_consumer_supply dummy_supplies[] = {
126 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
127 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
128};
129
vikram pandita62d0b3362009-11-22 10:11:31 -0800130int __init zoom_debugboard_init(void)
Vikram Pandita577145f2009-05-28 14:04:04 -0700131{
vikram pandita62d0b3362009-11-22 10:11:31 -0800132 if (!omap_zoom_debugboard_detect())
Vikram Pandita577145f2009-05-28 14:04:04 -0700133 return 0;
134
Russ Dill5b3689f2012-03-23 02:21:37 -0700135 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
vikram pandita62d0b3362009-11-22 10:11:31 -0800136 zoom_init_smsc911x();
137 zoom_init_quaduart();
138 return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
Vikram Pandita577145f2009-05-28 14:04:04 -0700139}