]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - arch/arm/mach-ep93xx/simone.c
Merge remote-tracking branches 'spi/topic/rockchip', 'spi/topic/rspi', 'spi/topic...
[mirror_ubuntu-hirsute-kernel.git] / arch / arm / mach-ep93xx / simone.c
CommitLineData
a3662f6b
RM
1/*
2 * arch/arm/mach-ep93xx/simone.c
3 * Simplemachines Sim.One support.
4 *
1c5454ee 5 * Copyright (C) 2010 Ryan Mallon
a3662f6b
RM
6 *
7 * Based on the 2.6.24.7 support:
8 * Copyright (C) 2009 Simplemachines
9 * MMC support by Peter Ivanov <ivanovp@gmail.com>, 2007
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 */
17
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
a3662f6b
RM
21#include <linux/i2c.h>
22#include <linux/i2c-gpio.h>
d50bfa47
MW
23#include <linux/mmc/host.h>
24#include <linux/spi/spi.h>
25#include <linux/spi/mmc_spi.h>
26#include <linux/platform_data/video-ep93xx.h>
27#include <linux/platform_data/spi-ep93xx.h>
28#include <linux/gpio.h>
a3662f6b
RM
29
30#include <mach/hardware.h>
bd5f12a2 31#include <mach/gpio-ep93xx.h>
a3662f6b
RM
32
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35
258249ec
RM
36#include "soc.h"
37
b370e082 38static struct ep93xx_eth_data __initdata simone_eth_data = {
a3662f6b
RM
39 .phy_id = 1,
40};
41
b370e082 42static struct ep93xxfb_mach_info __initdata simone_fb_info = {
a3662f6b
RM
43 .flags = EP93XXFB_USE_SDCSN0 | EP93XXFB_PCLK_FALLING,
44};
45
d50bfa47
MW
46/*
47 * GPIO lines used for MMC card detection.
48 */
49#define MMC_CARD_DETECT_GPIO EP93XX_GPIO_LINE_EGPIO0
50
d50bfa47
MW
51/*
52 * MMC card detection GPIO setup.
53 */
54
55static int simone_mmc_spi_init(struct device *dev,
56 irqreturn_t (*irq_handler)(int, void *), void *mmc)
57{
58 unsigned int gpio = MMC_CARD_DETECT_GPIO;
59 int irq, err;
60
61 err = gpio_request(gpio, dev_name(dev));
62 if (err)
63 return err;
64
65 err = gpio_direction_input(gpio);
66 if (err)
67 goto fail;
68
69 irq = gpio_to_irq(gpio);
70 if (irq < 0)
71 goto fail;
72
73 err = request_irq(irq, irq_handler, IRQF_TRIGGER_FALLING,
74 "MMC card detect", mmc);
75 if (err)
76 goto fail;
77
78 printk(KERN_INFO "%s: using irq %d for MMC card detection\n",
79 dev_name(dev), irq);
80
81 return 0;
82fail:
83 gpio_free(gpio);
84 return err;
85}
86
87static void simone_mmc_spi_exit(struct device *dev, void *mmc)
88{
89 unsigned int gpio = MMC_CARD_DETECT_GPIO;
90
91 free_irq(gpio_to_irq(gpio), mmc);
92 gpio_free(gpio);
93}
94
95static struct mmc_spi_platform_data simone_mmc_spi_data = {
96 .init = simone_mmc_spi_init,
97 .exit = simone_mmc_spi_exit,
98 .detect_delay = 500,
99 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
100};
101
102static struct spi_board_info simone_spi_devices[] __initdata = {
103 {
104 .modalias = "mmc_spi",
d50bfa47
MW
105 .platform_data = &simone_mmc_spi_data,
106 /*
107 * We use 10 MHz even though the maximum is 3.7 MHz. The driver
108 * will limit it automatically to max. frequency.
109 */
110 .max_speed_hz = 10 * 1000 * 1000,
111 .bus_num = 0,
112 .chip_select = 0,
113 .mode = SPI_MODE_3,
114 },
115};
116
55f0cd3f
HS
117/*
118 * Up to v1.3, the Sim.One used SFRMOUT as SD card chip select, but this goes
119 * low between multi-message command blocks. From v1.4, it uses a GPIO instead.
120 * v1.3 parts will still work, since the signal on SFRMOUT is automatic.
121 */
122static int simone_spi_chipselects[] __initdata = {
123 EP93XX_GPIO_LINE_EGPIO1,
124};
125
d50bfa47 126static struct ep93xx_spi_info simone_spi_info __initdata = {
55f0cd3f
HS
127 .chipselect = simone_spi_chipselects,
128 .num_chipselect = ARRAY_SIZE(simone_spi_chipselects),
109965a3 129 .use_dma = 1,
d50bfa47
MW
130};
131
b370e082 132static struct i2c_gpio_platform_data __initdata simone_i2c_gpio_data = {
a3662f6b
RM
133 .sda_pin = EP93XX_GPIO_LINE_EEDAT,
134 .sda_is_open_drain = 0,
135 .scl_pin = EP93XX_GPIO_LINE_EECLK,
136 .scl_is_open_drain = 0,
137 .udelay = 0,
138 .timeout = 0,
139};
140
141static struct i2c_board_info __initdata simone_i2c_board_info[] = {
142 {
143 I2C_BOARD_INFO("ds1337", 0x68),
144 },
145};
146
e5063fe8
MW
147static struct platform_device simone_audio_device = {
148 .name = "simone-audio",
149 .id = -1,
150};
151
152static void __init simone_register_audio(void)
153{
154 ep93xx_register_ac97();
155 platform_device_register(&simone_audio_device);
156}
157
a3662f6b
RM
158static void __init simone_init_machine(void)
159{
160 ep93xx_init_devices();
16bcf78f 161 ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_8M);
a3662f6b
RM
162 ep93xx_register_eth(&simone_eth_data, 1);
163 ep93xx_register_fb(&simone_fb_info);
164 ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info,
165 ARRAY_SIZE(simone_i2c_board_info));
d50bfa47
MW
166 ep93xx_register_spi(&simone_spi_info, simone_spi_devices,
167 ARRAY_SIZE(simone_spi_devices));
e5063fe8 168 simone_register_audio();
a3662f6b
RM
169}
170
171MACHINE_START(SIM_ONE, "Simplemachines Sim.One Board")
e562cf17
NP
172 /* Maintainer: Ryan Mallon */
173 .atag_offset = 0x100,
a3662f6b
RM
174 .map_io = ep93xx_map_io,
175 .init_irq = ep93xx_init_irq,
6bb27d73 176 .init_time = ep93xx_timer_init,
a3662f6b 177 .init_machine = simone_init_machine,
c914283f 178 .init_late = ep93xx_init_late,
3275166e 179 .restart = ep93xx_restart,
a3662f6b 180MACHINE_END