aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Haslam <ahaslam@baylibre.com>2016-11-24 10:04:52 -0500
committerSekhar Nori <nsekhar@ti.com>2016-11-28 03:30:55 -0500
commitc69f43fb4f26ddb45c285dfdfc7d7e9c5993d11c (patch)
tree1f941bedf832b1500f61ff1772aa4cdc868256a8
parent8439a1d77d07514fadc616a2691b5d130ce0b678 (diff)
ARM: davinci: hawk: 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> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r--arch/arm/mach-davinci/board-omapl138-hawk.c42
1 files changed, 11 insertions, 31 deletions
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
index a4e87264ebd7..41d5500996b2 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/console.h> 14#include <linux/console.h>
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16#include <linux/gpio/machine.h>
16#include <linux/platform_data/gpio-davinci.h> 17#include <linux/platform_data/gpio-davinci.h>
17#include <linux/regulator/machine.h> 18#include <linux/regulator/machine.h>
18 19
@@ -25,8 +26,6 @@
25#include <mach/mux.h> 26#include <mach/mux.h>
26 27
27#define HAWKBOARD_PHY_ID "davinci_mdio-0:07" 28#define HAWKBOARD_PHY_ID "davinci_mdio-0:07"
28#define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12)
29#define DA850_HAWK_MMCSD_WP_PIN GPIO_TO_PIN(3, 13)
30 29
31#define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4) 30#define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4)
32#define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13) 31#define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13)
@@ -123,19 +122,16 @@ static const short hawk_mmcsd0_pins[] = {
123 -1 122 -1
124}; 123};
125 124
126static int da850_hawk_mmc_get_ro(int index) 125static struct gpiod_lookup_table mmc_gpios_table = {
127{ 126 .dev_id = "da830-mmc.0",
128 return gpio_get_value(DA850_HAWK_MMCSD_WP_PIN); 127 .table = {
129} 128 /* CD: gpio3_12: gpio60: chip 1 contains gpio range 32-63*/
130 129 GPIO_LOOKUP("davinci_gpio.1", 28, "cd", GPIO_ACTIVE_LOW),
131static int da850_hawk_mmc_get_cd(int index) 130 GPIO_LOOKUP("davinci_gpio.1", 29, "wp", GPIO_ACTIVE_LOW),
132{ 131 },
133 return !gpio_get_value(DA850_HAWK_MMCSD_CD_PIN); 132};
134}
135 133
136static struct davinci_mmc_config da850_mmc_config = { 134static struct davinci_mmc_config da850_mmc_config = {
137 .get_ro = da850_hawk_mmc_get_ro,
138 .get_cd = da850_hawk_mmc_get_cd,
139 .wires = 4, 135 .wires = 4,
140 .max_freq = 50000000, 136 .max_freq = 50000000,
141 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, 137 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
@@ -151,21 +147,7 @@ static __init void omapl138_hawk_mmc_init(void)
151 return; 147 return;
152 } 148 }
153 149
154 ret = gpio_request_one(DA850_HAWK_MMCSD_CD_PIN, 150 gpiod_add_lookup_table(&mmc_gpios_table);
155 GPIOF_DIR_IN, "MMC CD");
156 if (ret < 0) {
157 pr_warn("%s: can not open GPIO %d\n",
158 __func__, DA850_HAWK_MMCSD_CD_PIN);
159 return;
160 }
161
162 ret = gpio_request_one(DA850_HAWK_MMCSD_WP_PIN,
163 GPIOF_DIR_IN, "MMC WP");
164 if (ret < 0) {
165 pr_warn("%s: can not open GPIO %d\n",
166 __func__, DA850_HAWK_MMCSD_WP_PIN);
167 goto mmc_setup_wp_fail;
168 }
169 151
170 ret = da8xx_register_mmcsd0(&da850_mmc_config); 152 ret = da8xx_register_mmcsd0(&da850_mmc_config);
171 if (ret) { 153 if (ret) {
@@ -176,9 +158,7 @@ static __init void omapl138_hawk_mmc_init(void)
176 return; 158 return;
177 159
178mmc_setup_mmcsd_fail: 160mmc_setup_mmcsd_fail:
179 gpio_free(DA850_HAWK_MMCSD_WP_PIN); 161 gpiod_remove_lookup_table(&mmc_gpios_table);
180mmc_setup_wp_fail:
181 gpio_free(DA850_HAWK_MMCSD_CD_PIN);
182} 162}
183 163
184static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id); 164static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);