Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: OMAP2: HSMMC: explicit fields to declare cover/card detect pin

board-rx51 has no card detect pin in the mmc slot, but can detect that
the (cell-phone) cover has been removed and the card is accessible.
The semantics between cover/card detect differ, the gpio on the slot
informs you after the card has been removed, cover removal does not
necessarily mean that the card has been removed.
This means different code paths are necessary. To complete this we
also want different fields in the platform data for cover and card
detect. This separation is not pushed all the way down into struct
omap2_hsmmc_info which is used to initialize the platform data.
If we did that we had to go over all board files and set the new
gpio_cod pin to -EINVAL. If we forget one board or some out-of-tree
archicture forgets that the default '0' is used which is a valid pin
number.

Signed-off-by: Andreas Fenkart <afenkart@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Andreas Fenkart and committed by
Ulf Hansson
b7a5646f 40433267

+33 -17
+25 -8
arch/arm/mach-omap2/hsmmc.c
··· 150 150 static inline void omap_hsmmc_mux(struct omap_hsmmc_platform_data 151 151 *mmc_controller, int controller_nr) 152 152 { 153 - if (gpio_is_valid(mmc_controller->switch_pin) && 154 - (mmc_controller->switch_pin < OMAP_MAX_GPIO_LINES)) 155 - omap_mux_init_gpio(mmc_controller->switch_pin, 153 + if (gpio_is_valid(mmc_controller->gpio_cd) && 154 + (mmc_controller->gpio_cd < OMAP_MAX_GPIO_LINES)) 155 + omap_mux_init_gpio(mmc_controller->gpio_cd, 156 + OMAP_PIN_INPUT_PULLUP); 157 + if (gpio_is_valid(mmc_controller->gpio_cod) && 158 + (mmc_controller->gpio_cod < OMAP_MAX_GPIO_LINES)) 159 + omap_mux_init_gpio(mmc_controller->gpio_cod, 156 160 OMAP_PIN_INPUT_PULLUP); 157 161 if (gpio_is_valid(mmc_controller->gpio_wp) && 158 162 (mmc_controller->gpio_wp < OMAP_MAX_GPIO_LINES)) ··· 254 250 mmc->internal_clock = !c->ext_clock; 255 251 mmc->reg_offset = 0; 256 252 257 - mmc->switch_pin = c->gpio_cd; 253 + if (c->cover_only) { 254 + /* detect if mobile phone cover removed */ 255 + mmc->gpio_cd = -EINVAL; 256 + mmc->gpio_cod = c->gpio_cd; 257 + } else { 258 + /* card detect pin on the mmc socket itself */ 259 + mmc->gpio_cd = c->gpio_cd; 260 + mmc->gpio_cod = -EINVAL; 261 + } 258 262 mmc->gpio_wp = c->gpio_wp; 259 263 260 264 mmc->remux = c->remux; 261 265 mmc->init_card = c->init_card; 262 - 263 - if (c->cover_only) 264 - mmc->cover = 1; 265 266 266 267 if (c->nonremovable) 267 268 mmc->nonremovable = 1; ··· 367 358 if (!mmc_pdata) 368 359 continue; 369 360 370 - mmc_pdata->switch_pin = c->gpio_cd; 361 + if (c->cover_only) { 362 + /* detect if mobile phone cover removed */ 363 + mmc_pdata->gpio_cd = -EINVAL; 364 + mmc_pdata->gpio_cod = c->gpio_cd; 365 + } else { 366 + /* card detect pin on the mmc socket itself */ 367 + mmc_pdata->gpio_cd = c->gpio_cd; 368 + mmc_pdata->gpio_cod = -EINVAL; 369 + } 371 370 mmc_pdata->gpio_wp = c->gpio_wp; 372 371 373 372 res = omap_device_register(pdev);
+6 -5
drivers/mmc/host/omap_hsmmc.c
··· 427 427 { 428 428 int ret; 429 429 430 - if (pdata->cover && gpio_is_valid(pdata->switch_pin)) { 431 - ret = mmc_gpio_request_cd(mmc, pdata->switch_pin, 0); 430 + if (gpio_is_valid(pdata->gpio_cod)) { 431 + ret = mmc_gpio_request_cd(mmc, pdata->gpio_cod, 0); 432 432 if (ret) 433 433 return ret; 434 434 435 435 host->get_cover_state = omap_hsmmc_get_cover_state; 436 436 mmc_gpio_set_cd_isr(mmc, omap_hsmmc_cover_irq); 437 - } else if (!pdata->cover && gpio_is_valid(pdata->switch_pin)) { 438 - ret = mmc_gpio_request_cd(mmc, pdata->switch_pin, 0); 437 + } else if (gpio_is_valid(pdata->gpio_cd)) { 438 + ret = mmc_gpio_request_cd(mmc, pdata->gpio_cd, 0); 439 439 if (ret) 440 440 return ret; 441 441 ··· 1920 1920 if (of_find_property(np, "ti,dual-volt", NULL)) 1921 1921 pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT; 1922 1922 1923 - pdata->switch_pin = -EINVAL; 1923 + pdata->gpio_cd = -EINVAL; 1924 + pdata->gpio_cod = -EINVAL; 1924 1925 pdata->gpio_wp = -EINVAL; 1925 1926 1926 1927 if (of_find_property(np, "ti,non-removable", NULL)) {
+2 -4
include/linux/platform_data/hsmmc-omap.h
··· 55 55 u32 caps; /* Used for the MMC driver on 2430 and later */ 56 56 u32 pm_caps; /* PM capabilities of the mmc */ 57 57 58 - /* switch pin can be for card detect (default) or card cover */ 59 - unsigned cover:1; 60 - 61 58 /* use the internal clock */ 62 59 unsigned internal_clock:1; 63 60 ··· 70 73 #define HSMMC_HAS_HSPE_SUPPORT (1 << 2) 71 74 unsigned features; 72 75 73 - int switch_pin; /* gpio (card detect) */ 76 + int gpio_cd; /* gpio (card detect) */ 77 + int gpio_cod; /* gpio (cover detect) */ 74 78 int gpio_wp; /* gpio (write protect) */ 75 79 76 80 int (*set_power)(struct device *dev, int power_on, int vdd);