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