board-zoom-debugboard.c 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * Copyright (C) 2009 Texas Instruments Inc.
 * Mikkel Christensen <mlc@ti.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/serial_8250.h>
#include <linux/smsc911x.h>
15
#include <linux/interrupt.h>
16

17 18 19
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>

20
#include <plat/gpmc.h>
21
#include <plat/gpmc-smsc911x.h>
22
#include <plat/serial.h>
23

24 25
#include <mach/board-zoom.h>

26 27 28 29
#define ZOOM_SMSC911X_CS	7
#define ZOOM_SMSC911X_GPIO	158
#define ZOOM_QUADUART_CS	3
#define ZOOM_QUADUART_GPIO	102
30
#define ZOOM_QUADUART_RST_GPIO	152
31 32
#define QUART_CLK		1843200
#define DEBUG_BASE		0x08000000
33
#define ZOOM_ETHR_START	DEBUG_BASE
34

35 36 37 38
static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
	.cs             = ZOOM_SMSC911X_CS,
	.gpio_irq       = ZOOM_SMSC911X_GPIO,
	.gpio_reset     = -EINVAL,
39 40 41
	.flags		= SMSC911X_USE_32BIT,
};

42
static inline void __init zoom_init_smsc911x(void)
43
{
44
	gpmc_smsc911x_init(&zoom_smsc911x_cfg);
45 46 47 48
}

static struct plat_serial8250_port serial_platform_data[] = {
	{
49
		.mapbase	= ZOOM_UART_BASE,
50
		.flags		= UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
51
		.irqflags	= IRQF_SHARED | IRQF_TRIGGER_RISING,
52 53 54 55 56 57 58 59
		.iotype		= UPIO_MEM,
		.regshift	= 1,
		.uartclk	= QUART_CLK,
	}, {
		.flags		= 0
	}
};

60
static struct platform_device zoom_debugboard_serial_device = {
61
	.name			= "serial8250",
62
	.id			= PLAT8250_DEV_PLATFORM,
63 64 65 66 67
	.dev			= {
		.platform_data	= serial_platform_data,
	},
};

68
static inline void __init zoom_init_quaduart(void)
69 70 71 72 73
{
	int quart_cs;
	unsigned long cs_mem_base;
	int quart_gpio = 0;

74 75 76 77 78 79 80 81
	if (gpio_request_one(ZOOM_QUADUART_RST_GPIO,
				GPIOF_OUT_INIT_LOW,
				"TL16CP754C GPIO") < 0) {
		pr_err("Failed to request GPIO%d for TL16CP754C\n",
			ZOOM_QUADUART_RST_GPIO);
		return;
	}

82
	quart_cs = ZOOM_QUADUART_CS;
83 84 85 86 87 88 89

	if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
		printk(KERN_ERR "Failed to request GPMC mem"
				"for Quad UART(TL16CP754C)\n");
		return;
	}

90
	quart_gpio = ZOOM_QUADUART_GPIO;
91

I
Igor Grinberg 已提交
92
	if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
93 94
		printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
								quart_gpio);
95 96

	serial_platform_data[0].irq = gpio_to_irq(102);
97 98
}

99
static inline int omap_zoom_debugboard_detect(void)
100 101
{
	int debug_board_detect = 0;
102
	int ret = 1;
103

104
	debug_board_detect = ZOOM_SMSC911X_GPIO;
105

I
Igor Grinberg 已提交
106 107
	if (gpio_request_one(debug_board_detect, GPIOF_IN,
			     "Zoom debug board detect") < 0) {
108
		printk(KERN_ERR "Failed to request GPIO%d for Zoom debug"
109 110 111 112 113
		"board detect\n", debug_board_detect);
		return 0;
	}

	if (!gpio_get_value(debug_board_detect)) {
114
		ret = 0;
115
	}
116 117
	gpio_free(debug_board_detect);
	return ret;
118 119
}

120 121
static struct platform_device *zoom_devices[] __initdata = {
	&zoom_debugboard_serial_device,
122 123
};

124 125 126 127 128
static struct regulator_consumer_supply dummy_supplies[] = {
	REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
	REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
};

129
int __init zoom_debugboard_init(void)
130
{
131
	if (!omap_zoom_debugboard_detect())
132 133
		return 0;

134
	regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
135 136 137
	zoom_init_smsc911x();
	zoom_init_quaduart();
	return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
138
}