brcm47xx: deactivate CONFIG_NO_HZ as it seams not to be needed.
[openwrt.git] / target / linux / ep93xx / patches-3.2 / 004-simone_add_mmc_spi.patch
1 This enables the mmc-over-spi driver for the Sim.One board, based on Mika's
2 patch, which used a GPIO for chip select in stead of the default SFRMOUT pin.
3 I've modified it to use the usual SFRMOUT; if you've modified your Sim.One
4 board to use a GPIO instead, uncomment and modify
5 // #define MMC_CHIP_SELECT_GPIO EP93XX_GPIO_LINE_EGPIO15
6 in the source file.
7 -martinwguy, 14 May 2010
8
9 From: Mika Westerberg <mika.westerberg@iki.fi>
10 Date: Wed, 28 Apr 2010 08:42:46 +0300
11 Subject: [PATCH] ep93xx: simone: added board specific SPI support for MMC/SD cards
12
13 This includes setting up EGPIOs 0 and 9 for card detection and chip select
14 respectively.
15
16 --- a/arch/arm/mach-ep93xx/simone.c
17 +++ b/arch/arm/mach-ep93xx/simone.c
18 @@ -18,12 +18,17 @@
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 +#include <linux/gpio.h>
23 #include <linux/i2c.h>
24 #include <linux/i2c-gpio.h>
25 +#include <linux/mmc/host.h>
26 +#include <linux/spi/spi.h>
27 +#include <linux/spi/mmc_spi.h>
28
29 #include <mach/hardware.h>
30 #include <mach/fb.h>
31 #include <mach/gpio-ep93xx.h>
32 +#include <mach/ep93xx_spi.h>
33
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 @@ -38,6 +43,135 @@ static struct ep93xxfb_mach_info __initd
37 .flags = EP93XXFB_USE_SDCSN0 | EP93XXFB_PCLK_FALLING,
38 };
39
40 +/*
41 + * GPIO lines used for MMC card detection.
42 + */
43 +#define MMC_CARD_DETECT_GPIO EP93XX_GPIO_LINE_EGPIO0
44 +
45 +/*
46 + * If you have hacked your Sim.One to use a GPIO as SD card chip select
47 + * (SD pin 1), uncomment the following line.
48 + * The example, EGPIO15, is on TP17 near the CPU.
49 + */
50 +// #define MMC_CHIP_SELECT_GPIO EP93XX_GPIO_LINE_EGPIO15
51 +
52 +/*
53 + * MMC SPI chip select GPIO handling. If you are using SFRMOUT (SFRM1) signal,
54 + * you can leave these empty and pass NULL as .controller_data.
55 + */
56 +
57 +#ifdef MMC_CHIP_SELECT_GPIO
58 +static int simone_mmc_spi_setup(struct spi_device *spi)
59 +{
60 + unsigned int gpio = MMC_CHIP_SELECT_GPIO;
61 + int err;
62 +
63 + err = gpio_request(gpio, spi->modalias);
64 + if (err)
65 + return err;
66 +
67 + err = gpio_direction_output(gpio, 1);
68 + if (err) {
69 + gpio_free(gpio);
70 + return err;
71 + }
72 +
73 + return 0;
74 +}
75 +
76 +static void simone_mmc_spi_cleanup(struct spi_device *spi)
77 +{
78 + unsigned int gpio = MMC_CHIP_SELECT_GPIO;
79 +
80 + gpio_set_value(gpio, 1);
81 + gpio_direction_input(gpio);
82 + gpio_free(gpio);
83 +}
84 +
85 +static void simone_mmc_spi_cs_control(struct spi_device *spi, int value)
86 +{
87 + gpio_set_value(MMC_CHIP_SELECT_GPIO, value);
88 +}
89 +
90 +static struct ep93xx_spi_chip_ops simone_mmc_spi_ops = {
91 + .setup = simone_mmc_spi_setup,
92 + .cleanup = simone_mmc_spi_cleanup,
93 + .cs_control = simone_mmc_spi_cs_control,
94 +};
95 +#endif
96 +
97 +/*
98 + * MMC card detection GPIO setup.
99 + */
100 +static int simone_mmc_spi_init(struct device *dev,
101 + irqreturn_t (*irq_handler)(int, void *), void *mmc)
102 +{
103 + unsigned int gpio = MMC_CARD_DETECT_GPIO;
104 + int irq, err;
105 +
106 + err = gpio_request(gpio, dev_name(dev));
107 + if (err)
108 + return err;
109 +
110 + err = gpio_direction_input(gpio);
111 + if (err)
112 + goto fail;
113 +
114 + irq = gpio_to_irq(gpio);
115 + if (irq < 0)
116 + goto fail;
117 +
118 + err = request_irq(irq, irq_handler, IRQF_TRIGGER_FALLING,
119 + "MMC card detect", mmc);
120 + if (err)
121 + goto fail;
122 +
123 + printk(KERN_INFO "%s: using irq %d for MMC card detection\n",
124 + dev_name(dev), irq);
125 +
126 + return 0;
127 +fail:
128 + gpio_free(gpio);
129 + return err;
130 +}
131 +
132 +static void simone_mmc_spi_exit(struct device *dev, void *mmc)
133 +{
134 + unsigned int gpio = MMC_CARD_DETECT_GPIO;
135 +
136 + free_irq(gpio_to_irq(gpio), mmc);
137 + gpio_free(gpio);
138 +}
139 +
140 +static struct mmc_spi_platform_data simone_mmc_spi_data = {
141 + .init = simone_mmc_spi_init,
142 + .exit = simone_mmc_spi_exit,
143 + .detect_delay = 500,
144 + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
145 +};
146 +
147 +static struct spi_board_info simone_spi_devices[] __initdata = {
148 + {
149 + .modalias = "mmc_spi",
150 +#ifdef MMC_CHIP_SELECT_GPIO
151 + .controller_data = &simone_mmc_spi_ops,
152 +#endif
153 + .platform_data = &simone_mmc_spi_data,
154 + /*
155 + * We use 10 MHz even though the maximum is 3.7 MHz. The driver
156 + * will limit it automatically to max. frequency.
157 + */
158 + .max_speed_hz = 10 * 1000 * 1000,
159 + .bus_num = 0,
160 + .chip_select = 0,
161 + .mode = SPI_MODE_3,
162 + },
163 +};
164 +
165 +static struct ep93xx_spi_info simone_spi_info __initdata = {
166 + .num_chipselect = ARRAY_SIZE(simone_spi_devices),
167 +};
168 +
169 static struct i2c_gpio_platform_data __initdata simone_i2c_gpio_data = {
170 .sda_pin = EP93XX_GPIO_LINE_EEDAT,
171 .sda_is_open_drain = 0,
172 @@ -72,6 +206,8 @@ static void __init simone_init_machine(v
173 ep93xx_register_fb(&simone_fb_info);
174 ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info,
175 ARRAY_SIZE(simone_i2c_board_info));
176 + ep93xx_register_spi(&simone_spi_info, simone_spi_devices,
177 + ARRAY_SIZE(simone_spi_devices));
178 simone_register_audio();
179 }
180
This page took 0.051448 seconds and 5 git commands to generate.