Merge branch 'i2c-embedded/for-next' of git://git.pengutronix.de/git/wsa/linux
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-omap2 / board-zoom-debugboard.c
CommitLineData
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
5b3689f4
RD
17#include <linux/regulator/fixed.h>
18#include <linux/regulator/machine.h>
19
3ef5d007 20#include "gpmc.h"
ac839b3c 21#include "gpmc-smsc911x.h"
577145f4 22
8599e7c5 23#include "board-zoom.h"
04aeae77 24
dbc04161
TL
25#include "soc.h"
26#include "common.h"
27
62d0b336 28#define ZOOM_SMSC911X_CS 7
29#define ZOOM_SMSC911X_GPIO 158
30#define ZOOM_QUADUART_CS 3
31#define ZOOM_QUADUART_GPIO 102
4e964252 32#define ZOOM_QUADUART_RST_GPIO 152
577145f4
VP
33#define QUART_CLK 1843200
34#define DEBUG_BASE 0x08000000
62d0b336 35#define ZOOM_ETHR_START DEBUG_BASE
577145f4 36
21b42731
MR
37static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
38 .cs = ZOOM_SMSC911X_CS,
39 .gpio_irq = ZOOM_SMSC911X_GPIO,
40 .gpio_reset = -EINVAL,
577145f4 41 .flags = SMSC911X_USE_32BIT,
577145f4
VP
42};
43
62d0b336 44static inline void __init zoom_init_smsc911x(void)
577145f4 45{
21b42731 46 gpmc_smsc911x_init(&zoom_smsc911x_cfg);
577145f4
VP
47}
48
49static struct plat_serial8250_port serial_platform_data[] = {
50 {
a4f57b81 51 .mapbase = ZOOM_UART_BASE,
577145f4 52 .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
c426df87 53 .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING,
577145f4
VP
54 .iotype = UPIO_MEM,
55 .regshift = 1,
56 .uartclk = QUART_CLK,
57 }, {
58 .flags = 0
59 }
60};
61
62d0b336 62static struct platform_device zoom_debugboard_serial_device = {
577145f4 63 .name = "serial8250",
fcbcea93 64 .id = PLAT8250_DEV_PLATFORM,
577145f4
VP
65 .dev = {
66 .platform_data = serial_platform_data,
67 },
68};
69
62d0b336 70static inline void __init zoom_init_quaduart(void)
577145f4
VP
71{
72 int quart_cs;
73 unsigned long cs_mem_base;
74 int quart_gpio = 0;
75
4e964252
C
76 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
62d0b336 84 quart_cs = ZOOM_QUADUART_CS;
577145f4
VP
85
86 if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
7852ec05 87 pr_err("Failed to request GPMC mem for Quad UART(TL16CP754C)\n");
577145f4
VP
88 return;
89 }
90
62d0b336 91 quart_gpio = ZOOM_QUADUART_GPIO;
577145f4 92
bc593f5d 93 if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
577145f4
VP
94 printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
95 quart_gpio);
46a0a540
TKD
96
97 serial_platform_data[0].irq = gpio_to_irq(102);
577145f4
VP
98}
99
62d0b336 100static inline int omap_zoom_debugboard_detect(void)
577145f4
VP
101{
102 int debug_board_detect = 0;
2fcc81a3 103 int ret = 1;
577145f4 104
62d0b336 105 debug_board_detect = ZOOM_SMSC911X_GPIO;
577145f4 106
bc593f5d
IG
107 if (gpio_request_one(debug_board_detect, GPIOF_IN,
108 "Zoom debug board detect") < 0) {
7852ec05
PW
109 pr_err("Failed to request GPIO%d for Zoom debug board detect\n",
110 debug_board_detect);
577145f4
VP
111 return 0;
112 }
577145f4
VP
113
114 if (!gpio_get_value(debug_board_detect)) {
2fcc81a3 115 ret = 0;
577145f4 116 }
2fcc81a3
VP
117 gpio_free(debug_board_detect);
118 return ret;
577145f4
VP
119}
120
62d0b336 121static struct platform_device *zoom_devices[] __initdata = {
62d0b336 122 &zoom_debugboard_serial_device,
577145f4
VP
123};
124
5b3689f4
RD
125static struct regulator_consumer_supply dummy_supplies[] = {
126 REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
127 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
128};
129
62d0b336 130int __init zoom_debugboard_init(void)
577145f4 131{
62d0b336 132 if (!omap_zoom_debugboard_detect())
577145f4
VP
133 return 0;
134
5b3689f4 135 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
62d0b336 136 zoom_init_smsc911x();
137 zoom_init_quaduart();
138 return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
577145f4 139}