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