aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Haslam <ahaslam@baylibre.com>2016-11-24 10:04:54 -0500
committerSekhar Nori <nsekhar@ti.com>2016-11-28 03:31:17 -0500
commitb5e1438cf98a1c588726b0f861178f9aa5a96caf (patch)
tree6fe31504f312478b8212288ea5f931e97690d169
parentbdf0e8364fd3a0c510a4f5d54b6e567903143cdb (diff)
ARM: davinci: da830-evm: use gpio descriptor for mmc pins
Currently the mmc driver is polling the gpio to know if the card was removed. By using a gpio descriptor instead of the platform callbacks, the driver will be able to register the gpio using the mmc core APIs designed for this purpose. This has the advantage that an irq will be registered, and polling is no longer needed. Also, a dependency on platform callbacks is removed for this board. Signed-off-by: Axel Haslam <ahaslam@baylibre.com> [nsekhar@ti.com: minor commit message edit] Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r--arch/arm/mach-davinci/board-da830-evm.c41
1 files changed, 11 insertions, 30 deletions
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 5db09014f55a..58075627c6df 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -14,6 +14,7 @@
14#include <linux/console.h> 14#include <linux/console.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/gpio/machine.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/i2c.h> 19#include <linux/i2c.h>
19#include <linux/i2c/pcf857x.h> 20#include <linux/i2c/pcf857x.h>
@@ -204,22 +205,16 @@ static const short da830_evm_mmc_sd_pins[] = {
204 -1 205 -1
205}; 206};
206 207
207#define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1) 208static struct gpiod_lookup_table mmc_gpios_table = {
208#define DA830_MMCSD_CD_PIN GPIO_TO_PIN(2, 2) 209 .dev_id = "da830-mmc.0",
209 210 .table = {
210static int da830_evm_mmc_get_ro(int index) 211 /* gpio chip 1 contains gpio range 32-63 */
211{ 212 GPIO_LOOKUP("davinci_gpio.1", 2, "cd", GPIO_ACTIVE_LOW),
212 return gpio_get_value(DA830_MMCSD_WP_PIN); 213 GPIO_LOOKUP("davinci_gpio.1", 1, "wp", GPIO_ACTIVE_LOW),
213} 214 },
214 215};
215static int da830_evm_mmc_get_cd(int index)
216{
217 return !gpio_get_value(DA830_MMCSD_CD_PIN);
218}
219 216
220static struct davinci_mmc_config da830_evm_mmc_config = { 217static struct davinci_mmc_config da830_evm_mmc_config = {
221 .get_ro = da830_evm_mmc_get_ro,
222 .get_cd = da830_evm_mmc_get_cd,
223 .wires = 8, 218 .wires = 8,
224 .max_freq = 50000000, 219 .max_freq = 50000000,
225 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, 220 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
@@ -235,26 +230,12 @@ static inline void da830_evm_init_mmc(void)
235 return; 230 return;
236 } 231 }
237 232
238 ret = gpio_request(DA830_MMCSD_WP_PIN, "MMC WP"); 233 gpiod_add_lookup_table(&mmc_gpios_table);
239 if (ret) {
240 pr_warn("%s: can not open GPIO %d\n",
241 __func__, DA830_MMCSD_WP_PIN);
242 return;
243 }
244 gpio_direction_input(DA830_MMCSD_WP_PIN);
245
246 ret = gpio_request(DA830_MMCSD_CD_PIN, "MMC CD\n");
247 if (ret) {
248 pr_warn("%s: can not open GPIO %d\n",
249 __func__, DA830_MMCSD_CD_PIN);
250 return;
251 }
252 gpio_direction_input(DA830_MMCSD_CD_PIN);
253 234
254 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config); 235 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config);
255 if (ret) { 236 if (ret) {
256 pr_warn("%s: mmc/sd registration failed: %d\n", __func__, ret); 237 pr_warn("%s: mmc/sd registration failed: %d\n", __func__, ret);
257 gpio_free(DA830_MMCSD_WP_PIN); 238 gpiod_remove_lookup_table(&mmc_gpios_table);
258 } 239 }
259} 240}
260 241