static int qrd_gpios_request_enable(const struct msm_gpio *table, int size) { int i; const struct msm_gpio *g; struct gpiomux_setting setting; int rc = msm_gpios_request(table, size); if (!rc){ for (i = 0; i < size; i++) { g = table + i; /* use msm_gpiomux_write which can save old configuration */ setting.func = GPIO_FUNC(g->gpio_cfg); setting.dir = GPIO_DIR(g->gpio_cfg); setting.pull = GPIO_PULL(g->gpio_cfg); setting.drv = GPIO_DRVSTR(g->gpio_cfg); msm_gpiomux_write(GPIO_PIN(g->gpio_cfg), GPIOMUX_ACTIVE, &setting, NULL); pr_debug("I2C pin %d func %d dir %d pull %d drvstr %d\n", GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), GPIO_DRVSTR(g->gpio_cfg)); } } return rc; }
static void __init msm_device_i2c_init(void) { if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw))) pr_err("failed to request I2C gpios\n"); msm_device_i2c.dev.platform_data = &msm_i2c_pdata; }
int msm_gpios_request_enable(const struct msm_gpio *table, int size) { int rc = msm_gpios_request(table, size); if (rc) return rc; rc = msm_gpios_enable(table, size); if (rc) msm_gpios_free(table, size); return rc; }
static void __init qup_device_i2c_init(void) { if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw))) pr_err("failed to request I2C gpios\n"); qup_device_i2c.dev.platform_data = &qup_i2c_pdata; /*This needs to be enabled only for OEMS*/ #ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA qup_vreg = vreg_get(NULL, "lvsw0"); if (IS_ERR(qup_vreg)) { printk(KERN_ERR "%s: vreg get failed (%ld)\n", __func__, PTR_ERR(qup_vreg)); } #endif }
static int msm7200a_wl1251_probe(struct platform_device *pdev) { int rc; struct vreg* vreg; struct msm7200a_wl1251_pdata *pdata = pdev->dev.platform_data; if (!pdata) { pr_err("%s: no platform data\n", __func__); return -EINVAL; } if (pdata->slot_number < 1 || pdata->slot_number > 4) { pr_err("%s: invalid slot number %d\n", __func__, pdata->slot_number); return -EINVAL; } memset(&wl1251_priv, 0, sizeof(wl1251_priv)); if (pdata->gpio_irq >= 0) { rc = gpio_request(pdata->gpio_irq, "WiFi IRQ"); if (rc) { goto err_gpio_irq; } #if MSM7200A_WL1251_HACK wl1251_pdata.irq = gpio_to_irq(pdata->gpio_irq); set_irq_flags(wl1251_pdata.irq, IRQF_VALID | IRQF_NOAUTOEN); #endif } if (pdata->gpio_32k_osc >= 0) { rc = gpio_request(pdata->gpio_32k_osc, "WiFi IRQ"); if (rc) { goto err_gpio_32k_osc; } } if (pdata->gpio_enable >= 0) { rc = gpio_request(pdata->gpio_enable, "WiFi Power"); if (rc) { goto err_gpio_enable; } } if (pdata->gpio_reset >= 0) { rc = gpio_request(pdata->gpio_reset, "WiFi Reset"); if (rc) { goto err_gpio_reset; } } if (pdata->vreg_id >= 0) { vreg = vreg_get_by_id(&pdev->dev, pdata->vreg_id); if (IS_ERR(vreg)) { rc = PTR_ERR(vreg); goto err_vreg; } wl1251_priv.vreg = vreg; } msm7200a_setup_gpios(pdata->slot_number, &wl1251_priv.gpios); rc = msm_gpios_request(wl1251_priv.gpios.on, wl1251_priv.gpios.on_length); if (rc) { goto err_sdcc_gpios; } wl1251_priv.pdata = pdata; rc = msm_add_sdcc(pdata->slot_number, &msm7200a_wl1251_data, 0, 0); if (rc) { goto err_sdcc_dev; } #if MSM7200A_WL1251_HACK rc = platform_device_register(&wl1251_device); if (rc) { goto err_pdev; } #endif return 0; #if MSM7200A_WL1251_HACK err_pdev: msm_delete_sdcc(pdata->slot_number); #endif err_sdcc_dev: wl1251_priv.pdata = NULL; err_sdcc_gpios: if (wl1251_priv.vreg) { vreg_put(wl1251_priv.vreg); wl1251_priv.vreg = NULL; } err_vreg: if (pdata->gpio_reset >= 0) { gpio_free(pdata->gpio_reset); } err_gpio_reset: if (pdata->gpio_enable >= 0) { gpio_free(pdata->gpio_enable); } err_gpio_enable: if (pdata->gpio_32k_osc >= 0) { gpio_free(pdata->gpio_32k_osc); } err_gpio_32k_osc: if (pdata->gpio_irq >= 0) { gpio_free(pdata->gpio_irq); } err_gpio_irq: return rc; }
static int msm7200a_mmc_probe(struct platform_device *pdev) { int rc; struct vreg* vreg; struct msm7200a_mmc_pdata *pdata = pdev->dev.platform_data; if (!pdata) { pr_err("%s: no platform data\n", __func__); return -EINVAL; } if (pdata->slot_number < 1 || pdata->slot_number > 4) { pr_err("%s: invalid slot number %d\n", __func__, pdata->slot_number); return -EINVAL; } memset(&sdslot_priv, 0, sizeof(sdslot_priv)); if (pdata->gpio_detection >= 0) { rc = gpio_request(pdata->gpio_detection, "SD Status"); if (rc) { goto err_gpio; } } if (pdata->vreg_id >= 0) { vreg = vreg_get_by_id(&pdev->dev, pdata->vreg_id); if (IS_ERR(vreg)) { rc = PTR_ERR(vreg); goto err_vreg; } sdslot_priv.vreg = vreg; } msm7200a_setup_gpios(pdata->slot_number, &sdslot_priv.gpios); rc = msm_gpios_request(sdslot_priv.gpios.on, sdslot_priv.gpios.on_length); if (rc) { goto err_sdcc_gpios; } sdslot_priv.pdata = pdata; if (pdata->gpio_detection >= 0) { set_irq_wake(gpio_to_irq(pdata->gpio_detection), 1); rc = msm_add_sdcc(pdata->slot_number, &msm7200a_sdslot_data, gpio_to_irq(pdata->gpio_detection), IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING); } else { rc = msm_add_sdcc(pdata->slot_number, &msm7200a_sdslot_data, 0, 0); } if (rc) { goto err_sdcc_dev; } return 0; err_sdcc_dev: sdslot_priv.pdata = NULL; if (pdata->gpio_detection >= 0) { set_irq_wake(gpio_to_irq(pdata->gpio_detection), 0); } err_sdcc_gpios: if (sdslot_priv.vreg) { vreg_put(sdslot_priv.vreg); sdslot_priv.vreg = NULL; } err_vreg: if (pdata->gpio_detection >= 0) { gpio_free(pdata->gpio_detection); } err_gpio: return rc; }