int __devexit arizona_dev_exit(struct arizona *arizona) { mfd_remove_devices(arizona->dev); arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona); arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona); arizona_free_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, arizona); pm_runtime_disable(arizona->dev); arizona_irq_exit(arizona); return 0; }
int arizona_dev_exit(struct arizona *arizona) { mfd_remove_devices(arizona->dev); arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona); arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona); arizona_free_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, arizona); pm_runtime_disable(arizona->dev); arizona_irq_exit(arizona); if (arizona->pdata.reset) gpio_set_value_cansleep(arizona->pdata.reset, 0); regulator_disable(arizona->dcvdd); regulator_bulk_disable(ARRAY_SIZE(arizona->core_supplies), arizona->core_supplies); return 0; }
static int __devexit arizona_extcon_remove(struct platform_device *pdev) { struct arizona_extcon_info *info = platform_get_drvdata(pdev); struct arizona *arizona = info->arizona; pm_runtime_disable(&pdev->dev); arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_RISE, 0); arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_FALL, 0); arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info); arizona_free_irq(arizona, ARIZONA_IRQ_JD_RISE, info); arizona_free_irq(arizona, ARIZONA_IRQ_JD_FALL, info); regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, ARIZONA_JD1_ENA, 0); arizona_clk32k_disable(arizona); extcon_dev_unregister(&info->edev); return 0; }
static int __devinit arizona_extcon_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); struct arizona_pdata *pdata; struct arizona_extcon_info *info; int ret, mode; pdata = dev_get_platdata(arizona->dev); info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "failed to allocate memory\n"); ret = -ENOMEM; goto err; } info->micvdd = devm_regulator_get(arizona->dev, "MICVDD"); if (IS_ERR(info->micvdd)) { ret = PTR_ERR(info->micvdd); dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret); goto err; } mutex_init(&info->lock); info->arizona = arizona; info->dev = &pdev->dev; info->detecting = true; platform_set_drvdata(pdev, info); switch (arizona->type) { case WM5102: switch (arizona->rev) { case 0: info->micd_reva = true; break; default: break; } break; default: break; } info->edev.name = "Headset Jack"; info->edev.supported_cable = arizona_cable; ret = extcon_dev_register(&info->edev, arizona->dev); if (ret < 0) { dev_err(arizona->dev, "extcon_dev_regster() failed: %d\n", ret); goto err; } if (pdata->num_micd_configs) { info->micd_modes = pdata->micd_configs; info->micd_num_modes = pdata->num_micd_configs; } else { info->micd_modes = micd_default_modes; info->micd_num_modes = ARRAY_SIZE(micd_default_modes); } if (arizona->pdata.micd_pol_gpio > 0) { if (info->micd_modes[0].gpio) mode = GPIOF_OUT_INIT_HIGH; else mode = GPIOF_OUT_INIT_LOW; ret = devm_gpio_request_one(&pdev->dev, arizona->pdata.micd_pol_gpio, mode, "MICD polarity"); if (ret != 0) { dev_err(arizona->dev, "Failed to request GPIO%d: %d\n", arizona->pdata.micd_pol_gpio, ret); goto err_register; } } arizona_extcon_set_mode(info, 0); pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev); pm_runtime_get_sync(&pdev->dev); ret = arizona_request_irq(arizona, ARIZONA_IRQ_JD_RISE, "JACKDET rise", arizona_jackdet, info); if (ret != 0) { dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n", ret); goto err_register; } ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_RISE, 1); if (ret != 0) { dev_err(&pdev->dev, "Failed to set JD rise IRQ wake: %d\n", ret); goto err_rise; } ret = arizona_request_irq(arizona, ARIZONA_IRQ_JD_FALL, "JACKDET fall", arizona_jackdet, info); if (ret != 0) { dev_err(&pdev->dev, "Failed to get JD fall IRQ: %d\n", ret); goto err_rise_wake; } ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_FALL, 1); if (ret != 0) { dev_err(&pdev->dev, "Failed to set JD fall IRQ wake: %d\n", ret); goto err_fall; } ret = arizona_request_irq(arizona, ARIZONA_IRQ_MICDET, "MICDET", arizona_micdet, info); if (ret != 0) { dev_err(&pdev->dev, "Failed to get MICDET IRQ: %d\n", ret); goto err_fall_wake; } regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1, ARIZONA_MICD_BIAS_STARTTIME_MASK | ARIZONA_MICD_RATE_MASK, 7 << ARIZONA_MICD_BIAS_STARTTIME_SHIFT | 8 << ARIZONA_MICD_RATE_SHIFT); arizona_clk32k_enable(arizona); regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_DEBOUNCE, ARIZONA_JD1_DB, ARIZONA_JD1_DB); regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, ARIZONA_JD1_ENA, ARIZONA_JD1_ENA); pm_runtime_put(&pdev->dev); return 0; err_fall_wake: arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_FALL, 0); err_fall: arizona_free_irq(arizona, ARIZONA_IRQ_JD_FALL, info); err_rise_wake: arizona_set_irq_wake(arizona, ARIZONA_IRQ_JD_RISE, 0); err_rise: arizona_free_irq(arizona, ARIZONA_IRQ_JD_RISE, info); err_register: pm_runtime_disable(&pdev->dev); extcon_dev_unregister(&info->edev); err: return ret; }