static int wm8770_probe(struct snd_soc_codec *codec) { struct wm8770_priv *wm8770; int ret; int i; wm8770 = snd_soc_codec_get_drvdata(codec); wm8770->codec = codec; ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8770->control_type); if (ret < 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) wm8770->supplies[i].supply = wm8770_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); return ret; } wm8770->disable_nb[0].notifier_call = wm8770_regulator_event_0; wm8770->disable_nb[1].notifier_call = wm8770_regulator_event_1; wm8770->disable_nb[2].notifier_call = wm8770_regulator_event_2; /* This should really be moved into the regulator core */ for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) { ret = regulator_register_notifier(wm8770->supplies[i].consumer, &wm8770->disable_nb[i]); if (ret) { dev_err(codec->dev, "Failed to register regulator notifier: %d\n", ret); } } ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_reg_get; } ret = wm8770_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; } wm8770_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* latch the volume update bits */ snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT1RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT2RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT3RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT4RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC1RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC2RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC3RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC4RVOL, 0x100, 0x100); /* mute all DACs */ snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); snd_soc_add_codec_controls(codec, wm8770_snd_controls, ARRAY_SIZE(wm8770_snd_controls)); snd_soc_dapm_new_controls(&codec->dapm, wm8770_dapm_widgets, ARRAY_SIZE(wm8770_dapm_widgets)); snd_soc_dapm_add_routes(&codec->dapm, wm8770_intercon, ARRAY_SIZE(wm8770_intercon)); return 0; err_reg_enable: regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); err_reg_get: regulator_bulk_free(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); return ret; }
static void msm_camera_vreg_disable(void) { regulator_bulk_disable(reg_count, regs); regulator_bulk_free(reg_count, regs); reg_count = 0; }
int __devinit arizona_dev_init(struct arizona *arizona) { struct device *dev = arizona->dev; const char *type_name; unsigned int reg, val; int ret, i; dev_set_drvdata(arizona->dev, arizona); mutex_init(&arizona->clk_lock); if (dev_get_platdata(arizona->dev)) memcpy(&arizona->pdata, dev_get_platdata(arizona->dev), sizeof(arizona->pdata)); regcache_cache_only(arizona->regmap, true); switch (arizona->type) { case WM5102: case WM5110: for (i = 0; i < ARRAY_SIZE(wm5102_core_supplies); i++) arizona->core_supplies[i].supply = wm5102_core_supplies[i]; arizona->num_core_supplies = ARRAY_SIZE(wm5102_core_supplies); break; default: dev_err(arizona->dev, "Unknown device type %d\n", arizona->type); return -EINVAL; } ret = mfd_add_devices(arizona->dev, -1, early_devs, ARRAY_SIZE(early_devs), NULL, 0); if (ret != 0) { dev_err(dev, "Failed to add early children: %d\n", ret); return ret; } ret = regulator_bulk_get(dev, arizona->num_core_supplies, arizona->core_supplies); if (ret != 0) { dev_err(dev, "Failed to request core supplies: %d\n", ret); goto err_early; } ret = regulator_bulk_enable(arizona->num_core_supplies, arizona->core_supplies); if (ret != 0) { dev_err(dev, "Failed to enable core supplies: %d\n", ret); goto err_bulk_get; } if (arizona->pdata.reset) { /* Start out with /RESET low to put the chip into reset */ ret = gpio_request_one(arizona->pdata.reset, GPIOF_DIR_OUT | GPIOF_INIT_LOW, "arizona /RESET"); if (ret != 0) { dev_err(dev, "Failed to request /RESET: %d\n", ret); goto err_enable; } gpio_set_value_cansleep(arizona->pdata.reset, 1); } if (arizona->pdata.ldoena) { ret = gpio_request_one(arizona->pdata.ldoena, GPIOF_DIR_OUT | GPIOF_INIT_HIGH, "arizona LDOENA"); if (ret != 0) { dev_err(dev, "Failed to request LDOENA: %d\n", ret); goto err_reset; } } regcache_cache_only(arizona->regmap, false); ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, ®); if (ret != 0) { dev_err(dev, "Failed to read ID register: %d\n", ret); goto err_ldoena; } ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION, &arizona->rev); if (ret != 0) { dev_err(dev, "Failed to read revision register: %d\n", ret); goto err_ldoena; } arizona->rev &= ARIZONA_DEVICE_REVISION_MASK; switch (reg) { #ifdef CONFIG_MFD_WM5102 case 0x5102: type_name = "WM5102"; if (arizona->type != WM5102) { dev_err(arizona->dev, "WM5102 registered as %d\n", arizona->type); arizona->type = WM5102; } ret = wm5102_patch(arizona); break; #endif #ifdef CONFIG_MFD_WM5110 case 0x5110: type_name = "WM5110"; if (arizona->type != WM5110) { dev_err(arizona->dev, "WM5110 registered as %d\n", arizona->type); arizona->type = WM5110; } ret = wm5110_patch(arizona); break; #endif default: dev_err(arizona->dev, "Unknown device ID %x\n", reg); goto err_ldoena; } dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A'); if (ret != 0) dev_err(arizona->dev, "Failed to apply patch: %d\n", ret); /* If we have a /RESET GPIO we'll already be reset */ if (!arizona->pdata.reset) { ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0); if (ret != 0) { dev_err(dev, "Failed to reset device: %d\n", ret); goto err_ldoena; } } ret = arizona_wait_for_boot(arizona); if (ret != 0) { dev_err(arizona->dev, "Device failed initial boot: %d\n", ret); goto err_reset; } for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) { if (!arizona->pdata.gpio_defaults[i]) continue; regmap_write(arizona->regmap, ARIZONA_GPIO1_CTRL + i, arizona->pdata.gpio_defaults[i]); } pm_runtime_set_autosuspend_delay(arizona->dev, 100); pm_runtime_use_autosuspend(arizona->dev); pm_runtime_enable(arizona->dev); /* Chip default */ if (!arizona->pdata.clk32k_src) arizona->pdata.clk32k_src = ARIZONA_32KZ_MCLK2; switch (arizona->pdata.clk32k_src) { case ARIZONA_32KZ_MCLK1: case ARIZONA_32KZ_MCLK2: regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, ARIZONA_CLK_32K_SRC_MASK, arizona->pdata.clk32k_src - 1); break; case ARIZONA_32KZ_NONE: regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, ARIZONA_CLK_32K_SRC_MASK, 2); break; default: dev_err(arizona->dev, "Invalid 32kHz clock source: %d\n", arizona->pdata.clk32k_src); ret = -EINVAL; goto err_ldoena; } for (i = 0; i < ARIZONA_MAX_INPUT; i++) { /* Default for both is 0 so noop with defaults */ val = arizona->pdata.dmic_ref[i] << ARIZONA_IN1_DMIC_SUP_SHIFT; val |= arizona->pdata.inmode[i] << ARIZONA_IN1_MODE_SHIFT; regmap_update_bits(arizona->regmap, ARIZONA_IN1L_CONTROL + (i * 8), ARIZONA_IN1_DMIC_SUP_MASK | ARIZONA_IN1_MODE_MASK, val); } for (i = 0; i < ARIZONA_MAX_OUTPUT; i++) { /* Default is 0 so noop with defaults */ if (arizona->pdata.out_mono[i]) val = ARIZONA_OUT1_MONO; else val = 0; regmap_update_bits(arizona->regmap, ARIZONA_OUTPUT_PATH_CONFIG_1L + (i * 8), ARIZONA_OUT1_MONO, val); } for (i = 0; i < ARIZONA_MAX_PDM_SPK; i++) { if (arizona->pdata.spk_mute[i]) regmap_update_bits(arizona->regmap, ARIZONA_PDM_SPK1_CTRL_1 + (i * 2), ARIZONA_SPK1_MUTE_ENDIAN_MASK | ARIZONA_SPK1_MUTE_SEQ1_MASK, arizona->pdata.spk_mute[i]); if (arizona->pdata.spk_fmt[i]) regmap_update_bits(arizona->regmap, ARIZONA_PDM_SPK1_CTRL_2 + (i * 2), ARIZONA_SPK1_FMT_MASK, arizona->pdata.spk_fmt[i]); } /* Set up for interrupts */ ret = arizona_irq_init(arizona); if (ret != 0) goto err_ldoena; arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error", arizona_clkgen_err, arizona); arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked", arizona_overclocked, arizona); arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked", arizona_underclocked, arizona); switch (arizona->type) { case WM5102: ret = mfd_add_devices(arizona->dev, -1, wm5102_devs, ARRAY_SIZE(wm5102_devs), NULL, 0); break; case WM5110: ret = mfd_add_devices(arizona->dev, -1, wm5110_devs, ARRAY_SIZE(wm5110_devs), NULL, 0); break; } if (ret != 0) { dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret); goto err_irq; } return 0; err_irq: arizona_irq_exit(arizona); err_ldoena: if (arizona->pdata.ldoena) { gpio_set_value_cansleep(arizona->pdata.ldoena, 0); gpio_free(arizona->pdata.ldoena); } err_reset: if (arizona->pdata.reset) { gpio_set_value_cansleep(arizona->pdata.reset, 1); gpio_free(arizona->pdata.reset); } err_enable: regulator_bulk_disable(ARRAY_SIZE(arizona->core_supplies), arizona->core_supplies); err_bulk_get: regulator_bulk_free(ARRAY_SIZE(arizona->core_supplies), arizona->core_supplies); err_early: mfd_remove_devices(dev); return ret; }
static int mipi_dsi_panel_msm_power(int on) { int rc = 0; uint32_t lcdc_reset_cfg; /* I2C-controlled GPIO Expander -init of the GPIOs very late */ if (unlikely(!dsi_gpio_initialized)) { pmapp_disp_backlight_init(); rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr"); if (rc < 0) { pr_err("failed to request gpio_disp_pwr\n"); return rc; } if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1); if (rc < 0) { pr_err("failed to enable display pwr\n"); goto fail_gpio1; } rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en"); if (rc < 0) { pr_err("failed to request gpio_bkl_en\n"); goto fail_gpio1; } rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1); if (rc < 0) { pr_err("failed to enable backlight\n"); goto fail_gpio2; } } rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio2; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } if (pmapp_disp_backlight_set_brightness(100)) pr_err("backlight set brightness failed\n"); dsi_gpio_initialized = 1; } if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() || machine_is_msm8625_ffa()) { if (on) { /* This line drives an active low pin on FFA */ rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on); if (rc < 0) pr_err("failed to set direction for " "display pwr\n"); } else { gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on); rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN); if (rc < 0) pr_err("failed to set direction for " "display pwr\n"); } } if (on) { gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr); rmb(); lcdc_reset_cfg &= ~1; writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); msleep(20); wmb(); lcdc_reset_cfg |= 1; writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); } else { gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); msleep(20); gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); } } else { gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1); } rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) : regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) pr_err("%s: could not %sable regulators: %d\n", __func__, on ? "en" : "dis", rc); return rc; fail_vreg: regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi); fail_gpio2: gpio_free(GPIO_BACKLIGHT_EN); fail_gpio1: gpio_free(GPIO_DISPLAY_PWR_EN); dsi_gpio_initialized = 0; return rc; }
/** * cs4270_probe - ASoC probe function * @pdev: platform device * * This function is called when ASoC has all the pieces it needs to * instantiate a sound driver. */ static int cs4270_probe(struct snd_soc_codec *codec) { struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); int i, ret; /* Tell ASoC what kind of I/O to use to read the registers. ASoC will * then do the I2C transactions itself. */ ret = snd_soc_codec_set_cache_io(codec, 8, 8, cs4270->control_type); if (ret < 0) { dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret); return ret; } /* Disable auto-mute. This feature appears to be buggy. In some * situations, auto-mute will not deactivate when it should, so we want * this feature disabled by default. An application (e.g. alsactl) can * re-enabled it by using the controls. */ ret = snd_soc_update_bits(codec, CS4270_MUTE, CS4270_MUTE_AUTO, 0); if (ret < 0) { dev_err(codec->dev, "i2c write failed\n"); return ret; } /* Disable automatic volume control. The hardware enables, and it * causes volume change commands to be delayed, sometimes until after * playback has started. An application (e.g. alsactl) can * re-enabled it by using the controls. */ ret = snd_soc_update_bits(codec, CS4270_TRANS, CS4270_TRANS_SOFT | CS4270_TRANS_ZERO, 0); if (ret < 0) { dev_err(codec->dev, "i2c write failed\n"); return ret; } /* Add the non-DAPM controls */ ret = snd_soc_add_codec_controls(codec, cs4270_snd_controls, ARRAY_SIZE(cs4270_snd_controls)); if (ret < 0) { dev_err(codec->dev, "failed to add controls\n"); return ret; } /* get the power supply regulators */ for (i = 0; i < ARRAY_SIZE(supply_names); i++) cs4270->supplies[i].supply = supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(cs4270->supplies), cs4270->supplies); if (ret < 0) return ret; ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), cs4270->supplies); if (ret < 0) goto error_free_regulators; return 0; error_free_regulators: regulator_bulk_free(ARRAY_SIZE(cs4270->supplies), cs4270->supplies); return ret; }
static int lis3lv02d_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; struct lis3lv02d_platform_data *pdata = client->dev.platform_data; #ifdef CONFIG_OF if (of_match_device(lis3lv02d_i2c_dt_ids, &client->dev)) { lis3_dev.of_node = client->dev.of_node; ret = lis3lv02d_init_dt(&lis3_dev); if (ret) return ret; pdata = lis3_dev.pdata; } #endif if (pdata) { if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))) lis3_dev.blkread = lis3_i2c_blockread; if (pdata->axis_x) lis3lv02d_axis_map.x = pdata->axis_x; if (pdata->axis_y) lis3lv02d_axis_map.y = pdata->axis_y; if (pdata->axis_z) lis3lv02d_axis_map.z = pdata->axis_z; if (pdata->setup_resources) ret = pdata->setup_resources(); if (ret) goto fail; } lis3_dev.regulators[0].supply = reg_vdd; lis3_dev.regulators[1].supply = reg_vdd_io; ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(lis3_dev.regulators), lis3_dev.regulators); if (ret < 0) goto fail; lis3_dev.pdata = pdata; lis3_dev.bus_priv = client; lis3_dev.init = lis3_i2c_init; lis3_dev.read = lis3_i2c_read; lis3_dev.write = lis3_i2c_write; lis3_dev.irq = client->irq; lis3_dev.ac = lis3lv02d_axis_map; lis3_dev.pm_dev = &client->dev; i2c_set_clientdata(client, &lis3_dev); /* Provide power over the init call */ lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); ret = lis3lv02d_init_device(&lis3_dev); lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); if (ret) goto fail2; return 0; fail2: regulator_bulk_free(ARRAY_SIZE(lis3_dev.regulators), lis3_dev.regulators); fail: if (pdata && pdata->release_resources) pdata->release_resources(); return ret; }
static int wm8523_probe(struct snd_soc_codec *codec) { struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); int ret, i; codec->hw_write = (hw_write_t)i2c_master_send; wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; wm8523->rate_constraint.count = ARRAY_SIZE(wm8523->rate_constraint_list); ret = snd_soc_codec_set_cache_io(codec, 8, 16, wm8523->control_type); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++) wm8523->supplies[i].supply = wm8523_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = snd_soc_read(codec, WM8523_DEVICE_ID); if (ret < 0) { dev_err(codec->dev, "Failed to read ID register\n"); goto err_enable; } if (ret != wm8523_reg[WM8523_DEVICE_ID]) { dev_err(codec->dev, "Device is not a WM8523, ID is %x\n", ret); ret = -EINVAL; goto err_enable; } ret = snd_soc_read(codec, WM8523_REVISION); if (ret < 0) { dev_err(codec->dev, "Failed to read revision register\n"); goto err_enable; } dev_info(codec->dev, "revision %c\n", (ret & WM8523_CHIP_REV_MASK) + 'A'); ret = wm8523_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset\n"); goto err_enable; } /* Change some default settings - latch VU and enable ZC */ snd_soc_update_bits(codec, WM8523_DAC_GAINR, WM8523_DACR_VU, WM8523_DACR_VU); snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC); wm8523_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); snd_soc_add_controls(codec, wm8523_snd_controls, ARRAY_SIZE(wm8523_snd_controls)); wm8523_add_widgets(codec); return 0; err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); err_get: regulator_bulk_free(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); return ret; }
static int mipi_dsi_panel_power(int on) { int rc = 0; #if 1 // #suwg. if(!odmm_dsi_gpio_initialized){ rc = gpio_request(ODMM_LCD_BACKLIGHT, "odmm_gpio_bkl_en"); if (rc < 0) return rc; rc = gpio_tlmm_config(GPIO_CFG(ODMM_LCD_BACKLIGHT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc < 0) { pr_err("failed odmm GPIO_BACKLIGHT_EN tlmm config\n"); return rc; } rc = gpio_direction_output(ODMM_LCD_BACKLIGHT, 1); if (rc < 0) { pr_err("failed to enable backlight\n"); gpio_free(ODMM_LCD_BACKLIGHT); return rc; } rc = regulator_bulk_get(NULL, ARRAY_SIZE(odmm_regs_dsi), odmm_regs_dsi); if (rc) { pr_err("%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio2; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(odmm_regs_dsi), odmm_regs_dsi); if (rc) { pr_err("%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } rc = regulator_bulk_enable(ARRAY_SIZE(odmm_regs_dsi), odmm_regs_dsi); // regulator_bulk_disable(ARRAY_SIZE(odmm_regs_dsi), odmm_regs_dsi); if (rc) pr_err("%s: could not %sable regulators: %d\n", __func__, on ? "en" : "dis", rc); odmm_dsi_gpio_initialized = 1; } return rc; fail_vreg: regulator_bulk_free(ARRAY_SIZE(odmm_regs_dsi), odmm_regs_dsi); fail_gpio2: gpio_free(ODMM_LCD_BACKLIGHT); return rc; #endif if (machine_is_msm7627a_qrd1()) rc = mipi_dsi_panel_qrd1_power(on); else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() || machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a()) rc = mipi_dsi_panel_qrd3_power(on); else if (machine_is_msm8625q_skud()) rc = mipi_dsi_panel_skud_power(on); else if (machine_is_msm8625q_evbd()) rc = mipi_dsi_panel_evbd_power(on); else if (machine_is_msm8625q_skue()) rc = mipi_dsi_panel_skue_power(on); else rc = mipi_dsi_panel_msm_power(on); return rc; }
int main_camera_power_on (struct platform_device *pdev) { int count1, count2, rc; struct device *dev = &pdev->dev; printk(KERN_ERR "%s: main_camera_power_on \n",__func__); gpio_set_value(CAM_MAIN_GPIO_RESET_N, 0); // Turn On Main Camera Power Part1 count1 = ARRAY_SIZE(regs_main1); rc = regulator_bulk_get(dev, count1, regs_main1); if (rc) { dev_err(dev, "%s: regs_main1 could not get regulators: %d\n", __func__, rc); return 0; } rc = regulator_bulk_set_voltage(count1, regs_main1); if (rc) { dev_err(dev, "%s: regs_main1 could not set voltages: %d\n", __func__, rc); goto reg_free1; } rc = regulator_bulk_enable(count1, regs_main1); if (rc) { dev_err(dev, "%s: regs_main1 could not enable regulators: %d\n", __func__, rc); goto reg_free1; } reg_count_main1 = count1; mdelay(20); // Supply Clock and Make high on reset msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK); mdelay(10); gpio_set_value(CAM_MAIN_GPIO_RESET_N, 1); mdelay(10); // Turn On Main Camera Power Part2 count2 = ARRAY_SIZE(regs_main2); rc = regulator_bulk_get(dev, count2, regs_main2); if (rc) { dev_err(dev, "%s: regs_main2 could not get regulators: %d\n", __func__, rc); goto reg_free1;; } rc = regulator_bulk_set_voltage(count2, regs_main2); if (rc) { dev_err(dev, "%s: regs_main2 could not set voltages: %d\n", __func__, rc); goto reg_free2; } rc = regulator_bulk_enable(count2, regs_main2); if (rc) { dev_err(dev, "%s: regs_main2 could not enable regulators: %d\n", __func__, rc); goto reg_free2; } reg_count_main2 = count2; mdelay(3); return 0; reg_free2: regulator_bulk_free(count2, regs_main2); reg_count_main2 = 0; regulator_bulk_disable(reg_count_main1, regs_main1); reg_free1: regulator_bulk_free(count1, regs_main1); reg_count_main1 = 0; return 0; }
/* * Instantiate the generic non-control parts of the device. */ static int wm8994_device_init(struct wm8994 *wm8994, int irq) { struct wm8994_pdata *pdata = wm8994->dev->platform_data; const char *devname; int ret, i; int pulls = 0; mutex_init(&wm8994->io_lock); dev_set_drvdata(wm8994->dev, wm8994); /* Add the on-chip regulators first for bootstrapping */ ret = mfd_add_devices(wm8994->dev, -1, wm8994_regulator_devs, ARRAY_SIZE(wm8994_regulator_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err; } switch (wm8994->type) { case WM1811: wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); break; case WM8994: wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); break; case WM8958: wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); break; default: BUG(); goto err; } wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) * wm8994->num_supplies, GFP_KERNEL); if (!wm8994->supplies) { ret = -ENOMEM; goto err; } switch (wm8994->type) { case WM1811: for (i = 0; i < ARRAY_SIZE(wm1811_main_supplies); i++) wm8994->supplies[i].supply = wm1811_main_supplies[i]; break; case WM8994: for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++) wm8994->supplies[i].supply = wm8994_main_supplies[i]; break; case WM8958: for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++) wm8994->supplies[i].supply = wm8958_main_supplies[i]; break; default: BUG(); goto err; } ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); goto err_supplies; } ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); if (ret < 0) { dev_err(wm8994->dev, "Failed to read ID register\n"); goto err_enable; } else dev_info(wm8994->dev, "Succeeded to read ID register\n"); switch (ret) { case 0x1811: devname = "WM1811"; if (wm8994->type != WM1811) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM1811; /* Samsung-specific customization of MICBIAS levels */ wm8994_reg_write(wm8994, 0x102, 0x3); wm8994_reg_write(wm8994, 0xcb, 0x5151); wm8994_reg_write(wm8994, 0xd3, 0x3f3f); wm8994_reg_write(wm8994, 0xd4, 0x3f3f); wm8994_reg_write(wm8994, 0xd5, 0x3f3f); wm8994_reg_write(wm8994, 0xd6, 0x3226); wm8994_reg_write(wm8994, 0x102, 0x0); wm8994_reg_write(wm8994, 0xd1, 0x87); wm8994_reg_write(wm8994, 0x3b, 0x9); wm8994_reg_write(wm8994, 0x3c, 0x2); break; case 0x8994: devname = "WM8994"; if (wm8994->type != WM8994) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8994; break; case 0x8958: devname = "WM8958"; if (wm8994->type != WM8958) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8958; break; default: dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", ret); ret = -EINVAL; goto err_enable; } ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); if (ret < 0) { dev_err(wm8994->dev, "Failed to read revision register: %d\n", ret); goto err_enable; } switch (wm8994->type) { case WM8994: switch (ret) { case 0: case 1: dev_warn(wm8994->dev, "revision %c not fully supported\n", 'A' + ret); break; default: break; } break; default: break; } dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret); if (pdata) { wm8994->irq_base = pdata->irq_base; wm8994->gpio_base = pdata->gpio_base; /* GPIO configuration is only applied if it's non-zero */ for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { if (pdata->gpio_defaults[i]) { wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, 0xffff, pdata->gpio_defaults[i]); } } wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; if (pdata->spkmode_pu) pulls |= WM8994_SPKMODE_PU; } /* Disable unneeded pulls */ wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD | WM8994_SPKMODE_PU | WM8994_CSNADDR_PD, pulls); /* In some system designs where the regulators are not in use, * we can achieve a small reduction in leakage currents by * floating LDO outputs. This bit makes no difference if the * LDOs are enabled, it only affects cases where the LDOs were * in operation and are then disabled. */ for (i = 0; i < WM8994_NUM_LDO_REGS; i++) { if (wm8994_ldo_in_use(pdata, i)) wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, WM8994_LDO1_DISCH); else wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, 0); } wm8994_irq_init(wm8994); ret = mfd_add_devices(wm8994->dev, -1, wm8994_devs, ARRAY_SIZE(wm8994_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err_irq; } #if 0 /* To do */ pm_runtime_enable(wm8994->dev); pm_runtime_resume(wm8994->dev); #endif return 0; err_irq: wm8994_irq_exit(wm8994); err_enable: regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); err_get: regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); err_supplies: kfree(wm8994->supplies); err: mfd_remove_devices(wm8994->dev); kfree(wm8994); return ret; }
void aic31xx_device_exit(struct aic31xx_priv *aic31xx) { if (aic31xx->pdata.gpio_reset) gpio_free(aic31xx->pdata.gpio_reset); regulator_bulk_free(ARRAY_SIZE(aic31xx->supplies), aic31xx->supplies); }
static int wm8741_register(struct wm8741_priv *wm8741, enum snd_soc_control_type control) { int ret; struct snd_soc_codec *codec = &wm8741->codec; int i; if (wm8741_codec) { dev_err(codec->dev, "Another WM8741 is registered\n"); return -EINVAL; } mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); snd_soc_codec_set_drvdata(codec, wm8741); codec->name = "WM8741"; codec->owner = THIS_MODULE; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = NULL; codec->dai = &wm8741_dai; codec->num_dai = 1; codec->reg_cache_size = WM8741_REGISTER_COUNT; codec->reg_cache = &wm8741->reg_cache; wm8741->rate_constraint.list = &wm8741->rate_constraint_list[0]; wm8741->rate_constraint.count = ARRAY_SIZE(wm8741->rate_constraint_list); memcpy(codec->reg_cache, wm8741_reg_defaults, sizeof(wm8741->reg_cache)); ret = snd_soc_codec_set_cache_io(codec, 7, 9, control); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); goto err; } for (i = 0; i < ARRAY_SIZE(wm8741->supplies); i++) wm8741->supplies[i].supply = wm8741_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8741->supplies), wm8741->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); goto err; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = wm8741_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset\n"); goto err_enable; } wm8741_dai.dev = codec->dev; /* Change some default settings - latch VU */ wm8741->reg_cache[WM8741_DACLLSB_ATTENUATION] |= WM8741_UPDATELL; wm8741->reg_cache[WM8741_DACLMSB_ATTENUATION] |= WM8741_UPDATELM; wm8741->reg_cache[WM8741_DACRLSB_ATTENUATION] |= WM8741_UPDATERL; wm8741->reg_cache[WM8741_DACRLSB_ATTENUATION] |= WM8741_UPDATERM; wm8741_codec = codec; ret = snd_soc_register_codec(codec); if (ret != 0) { dev_err(codec->dev, "Failed to register codec: %d\n", ret); return ret; } ret = snd_soc_register_dai(&wm8741_dai); if (ret != 0) { dev_err(codec->dev, "Failed to register DAI: %d\n", ret); snd_soc_unregister_codec(codec); return ret; } dev_dbg(codec->dev, "Successful registration\n"); return 0; err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); err_get: regulator_bulk_free(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); err: kfree(wm8741); return ret; }
static int mipi_dsi_panel_msm_power(int on) { /*++ Huize - 20120927 Modify for identifying what the code is used by customization ++*/ #ifdef DISPLAY_CUSTOMIZATION int rc = 0; if (unlikely(!dsi_gpio_initialized)) { pr_emerg("%s\n", __func__); #ifndef CONFIG_LEDS_CHIP_LM3533 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bl_en"); if (rc < 0) { pr_err("failed to request gpio_bl_en\n"); return rc; } rc = gpio_tlmm_config( GPIO_CFG(GPIO_BACKLIGHT_EN,0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #endif if (rc) { pr_err("Failed to enable gpio_bl_en\n"); goto fail_gpio1; } rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio2; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } dsi_gpio_initialized = 1; } #else int rc = 0; uint32_t lcdc_reset_cfg; /* I2C-controlled GPIO Expander -init of the GPIOs very late */ if (unlikely(!dsi_gpio_initialized)) { pmapp_disp_backlight_init(); rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr"); if (rc < 0) { pr_err("failed to request gpio_disp_pwr\n"); return rc; } if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1); if (rc < 0) { pr_err("failed to enable display pwr\n"); goto fail_gpio1; } rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en"); if (rc < 0) { pr_err("failed to request gpio_bkl_en\n"); goto fail_gpio1; } rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1); if (rc < 0) { pr_err("failed to enable backlight\n"); goto fail_gpio2; } } rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio2; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } if (pmapp_disp_backlight_set_brightness(100)) pr_err("backlight set brightness failed\n"); dsi_gpio_initialized = 1; } if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() || machine_is_msm8625_ffa()) { if (on) { /* This line drives an active low pin on FFA */ rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on); if (rc < 0) pr_err("failed to set direction for " "display pwr\n"); } else { gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on); rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN); if (rc < 0) pr_err("failed to set direction for " "display pwr\n"); } } if (on) { gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr); rmb(); lcdc_reset_cfg &= ~1; writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); msleep(20); wmb(); lcdc_reset_cfg |= 1; writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); } else { gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); msleep(20); gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); } } else { gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1); } #endif /*-- Huize - 20120927 Modify for identifying what the code is used by customization --*/ rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) : regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) pr_err("%s: could not %sable regulators: %d\n", __func__, on ? "en" : "dis", rc); return rc; fail_vreg: regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi); fail_gpio2: gpio_free(GPIO_BACKLIGHT_EN); fail_gpio1: //Jordan-20111230 , remove // gpio_free(GPIO_DISPLAY_PWR_EN); dsi_gpio_initialized = 0; return rc; }
static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq) { struct wm8994_pdata *pdata = wm8994->dev->platform_data; struct regmap_config *regmap_config; const struct reg_default *regmap_patch = NULL; const char *devname; int ret, i, patch_regs; int pulls = 0; dev_set_drvdata(wm8994->dev, wm8994); ret = mfd_add_devices(wm8994->dev, -1, wm8994_regulator_devs, ARRAY_SIZE(wm8994_regulator_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err; } switch (wm8994->type) { case WM1811: wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); break; case WM8994: wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); break; case WM8958: wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); break; default: BUG(); goto err; } wm8994->supplies = devm_kzalloc(wm8994->dev, sizeof(struct regulator_bulk_data) * wm8994->num_supplies, GFP_KERNEL); if (!wm8994->supplies) { ret = -ENOMEM; goto err; } switch (wm8994->type) { case WM1811: for (i = 0; i < ARRAY_SIZE(wm1811_main_supplies); i++) wm8994->supplies[i].supply = wm1811_main_supplies[i]; break; case WM8994: for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++) wm8994->supplies[i].supply = wm8994_main_supplies[i]; break; case WM8958: for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++) wm8994->supplies[i].supply = wm8958_main_supplies[i]; break; default: BUG(); goto err; } ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); goto err; } ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); if (ret < 0) { dev_err(wm8994->dev, "Failed to read ID register\n"); goto err_enable; } switch (ret) { case 0x1811: devname = "WM1811"; if (wm8994->type != WM1811) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM1811; break; case 0x8994: devname = "WM8994"; if (wm8994->type != WM8994) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8994; break; case 0x8958: devname = "WM8958"; if (wm8994->type != WM8958) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8958; break; default: dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", ret); ret = -EINVAL; goto err_enable; } ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); if (ret < 0) { dev_err(wm8994->dev, "Failed to read revision register: %d\n", ret); goto err_enable; } wm8994->revision = ret; switch (wm8994->type) { case WM8994: switch (wm8994->revision) { case 0: case 1: dev_warn(wm8994->dev, "revision %c not fully supported\n", 'A' + wm8994->revision); break; case 2: case 3: regmap_patch = wm8994_revc_patch; patch_regs = ARRAY_SIZE(wm8994_revc_patch); break; default: break; } break; case WM8958: switch (wm8994->revision) { case 0: regmap_patch = wm8958_reva_patch; patch_regs = ARRAY_SIZE(wm8958_reva_patch); break; default: break; } break; case WM1811: if (wm8994->revision > 1) wm8994->revision++; switch (wm8994->revision) { case 0: case 1: case 2: case 3: case 4: regmap_patch = wm1811_reva_patch; patch_regs = ARRAY_SIZE(wm1811_reva_patch); break; default: break; } break; default: break; } dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + wm8994->revision); switch (wm8994->type) { case WM1811: regmap_config = &wm1811_regmap_config; break; case WM8994: regmap_config = &wm8994_regmap_config; break; case WM8958: regmap_config = &wm8958_regmap_config; break; default: dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); return -EINVAL; } ret = regmap_reinit_cache(wm8994->regmap, regmap_config); if (ret != 0) { dev_err(wm8994->dev, "Failed to reinit register cache: %d\n", ret); return ret; } if (regmap_patch) { ret = regmap_register_patch(wm8994->regmap, regmap_patch, patch_regs); if (ret != 0) { dev_err(wm8994->dev, "Failed to register patch: %d\n", ret); goto err; } } if (pdata) { wm8994->irq_base = pdata->irq_base; wm8994->gpio_base = pdata->gpio_base; for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { if (pdata->gpio_defaults[i]) { wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, 0xffff, pdata->gpio_defaults[i]); } } wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; if (pdata->spkmode_pu) pulls |= WM8994_SPKMODE_PU; } wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD | WM8994_SPKMODE_PU | WM8994_CSNADDR_PD, pulls); for (i = 0; i < WM8994_NUM_LDO_REGS; i++) { if (wm8994_ldo_in_use(pdata, i)) wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, WM8994_LDO1_DISCH); else wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, 0); } wm8994_irq_init(wm8994); ret = mfd_add_devices(wm8994->dev, -1, wm8994_devs, ARRAY_SIZE(wm8994_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err_irq; } pm_runtime_enable(wm8994->dev); pm_runtime_idle(wm8994->dev); return 0; err_irq: wm8994_irq_exit(wm8994); err_enable: regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); err_get: regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); err: mfd_remove_devices(wm8994->dev); return ret; }
static int m5mols_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct m5mols_platform_data *pdata = client->dev.platform_data; struct m5mols_info *info; struct v4l2_subdev *sd; int ret = 0; if (pdata == NULL) { dev_err(&client->dev, "No platform data\n"); return -EINVAL; } if (!gpio_is_valid(pdata->gpio_rst)) { dev_err(&client->dev, "No valid nRST gpio pin.\n"); return -EINVAL; } if (!pdata->irq) { dev_err(&client->dev, "Interrupt not assigned.\n"); return -EINVAL; } info = kzalloc(sizeof(struct m5mols_info), GFP_KERNEL); if (info == NULL) { dev_err(&client->dev, "Failed to allocate info\n"); return -ENOMEM; } info->pdata = pdata; if (info->pdata->set_power) /* for additional power if needed. */ info->set_power = pdata->set_power; if (info->pdata->irq) { INIT_WORK(&info->work, m5mols_irq_work); ret = request_irq(info->pdata->irq, m5mols_irq_handler, IRQF_TRIGGER_RISING, MOD_NAME, &info->sd); if (ret) { dev_err(&client->dev, "Failed to request irq: %d\n", ret); return ret; } } ret = gpio_request(info->pdata->gpio_rst, "M5MOLS nRST"); if (ret) { dev_err(&client->dev, "Failed to set gpio, %d\n", ret); goto out_gpio; } gpio_direction_output(info->pdata->gpio_rst, !info->pdata->enable_rst); ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); if (ret) { dev_err(&client->dev, "Failed to get regulators, %d\n", ret); goto out_reg; } sd = &info->sd; init_waitqueue_head(&info->cap_wait); v4l2_i2c_subdev_init(sd, client, &m5mols_ops); info->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, 1, &info->pad, 0); if (ret < 0) goto out_reg; m5mols_init_formats(sd, NULL); strlcpy(sd->name, MOD_NAME, sizeof(sd->name)); sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE; sd->internal_ops = &m5mols_v4l2_internal_ops; sd->entity.ops = &m5mols_media_ops; info->res_type = M5MOLS_RESTYPE_MONITOR; v4l2_info(sd, "%s : m5mols driver probed success\n", __func__); return 0; out_reg: regulator_bulk_free(ARRAY_SIZE(supplies), supplies); out_gpio: gpio_free(info->pdata->gpio_rst); kfree(info); return ret; }
int vga_camera_power_on (struct platform_device *pdev) { int count1, count2, rc; struct device *dev = &pdev->dev; printk(KERN_ERR "vga_camera_power_on\n"); gpio_set_value(CAM_VGA_GPIO_RESET_N, 0); mdelay(1); gpio_set_value(CAM_VGA_GPIO_PWDN, 0); mdelay(1); // Turn On Main Camera Power Part1 count1 = ARRAY_SIZE(regs_vga1); rc = regulator_bulk_get(dev, count1, regs_vga1); if (rc) { dev_err(dev, "%s: regs_vga1 could not get regulators: %d\n", __func__, rc); return 0; } rc = regulator_bulk_set_voltage(count1, regs_vga1); if (rc) { dev_err(dev, "%s: regs_vga1 could not set voltages: %d\n", __func__, rc); goto reg_free1; } rc = regulator_bulk_enable(count1, regs_vga1); if (rc) { dev_err(dev, "%s: regs_vga1 could not enable regulators: %d\n", __func__, rc); goto reg_free1; } reg_count_vga1 = count1; // Turn On Main Camera Power Part2 count2 = ARRAY_SIZE(regs_vga2); rc = regulator_bulk_get(dev, count2, regs_vga2); if (rc) { dev_err(dev, "%s: regs_vga2 could not get regulators: %d\n", __func__, rc); goto reg_free1;; } rc = regulator_bulk_set_voltage(count2, regs_vga2); if (rc) { dev_err(dev, "%s: regs_vga2 could not set voltages: %d\n", __func__, rc); goto reg_free2; } rc = regulator_bulk_enable(count2, regs_vga2); if (rc) { dev_err(dev, "%s: regs_vga2 could not enable regulators: %d\n", __func__, rc); goto reg_free2; } reg_count_vga2 = count2; gpio_set_value(CAM_VGA_GPIO_PWDN, 1); mdelay(1); msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK); mdelay(1); gpio_set_value(CAM_VGA_GPIO_PWDN, 0); mdelay(1); gpio_set_value(CAM_VGA_GPIO_RESET_N, 1); mdelay(10); return 0; reg_free2: regulator_bulk_free(count2, regs_vga2); reg_count_vga2 = 0; regulator_bulk_disable(reg_count_vga1, regs_vga1); reg_free1: regulator_bulk_free(count1, regs_vga1); reg_count_vga1 = 0; return 0; }
static int wm8993_probe(struct snd_soc_codec *codec) { struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct snd_soc_dapm_context *dapm = &codec->dapm; int ret, i, val; wm8993->hubs_data.hp_startup_mode = 1; wm8993->hubs_data.dcs_codes_l = -2; wm8993->hubs_data.dcs_codes_r = -2; wm8993->hubs_data.series_startup = 1; ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } for (i = 0; i < ARRAY_SIZE(wm8993->supplies); i++) wm8993->supplies[i].supply = wm8993_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8993->supplies), wm8993->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } val = snd_soc_read(codec, WM8993_SOFTWARE_RESET); if (val != wm8993_reg_defaults[WM8993_SOFTWARE_RESET]) { dev_err(codec->dev, "Invalid ID register value %x\n", val); ret = -EINVAL; goto err_enable; } ret = snd_soc_write(codec, WM8993_SOFTWARE_RESET, 0xffff); if (ret != 0) goto err_enable; codec->cache_only = 1; /* By default we're using the output mixers */ wm8993->class_w_users = 2; /* Latch volume update bits and default ZC on */ snd_soc_update_bits(codec, WM8993_RIGHT_DAC_DIGITAL_VOLUME, WM8993_DAC_VU, WM8993_DAC_VU); snd_soc_update_bits(codec, WM8993_RIGHT_ADC_DIGITAL_VOLUME, WM8993_ADC_VU, WM8993_ADC_VU); /* Manualy manage the HPOUT sequencing for independent stereo * control. */ snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, WM8993_HPOUT1_AUTO_PU, 0); /* Use automatic clock configuration */ snd_soc_update_bits(codec, WM8993_CLOCKING_4, WM8993_SR_MODE, 0); wm_hubs_handle_analogue_pdata(codec, wm8993->pdata.lineout1_diff, wm8993->pdata.lineout2_diff, wm8993->pdata.lineout1fb, wm8993->pdata.lineout2fb, wm8993->pdata.jd_scthr, wm8993->pdata.jd_thr, wm8993->pdata.micbias1_lvl, wm8993->pdata.micbias2_lvl); ret = wm8993_set_bias_level(codec, SND_SOC_BIAS_STANDBY); if (ret != 0) goto err_enable; snd_soc_add_controls(codec, wm8993_snd_controls, ARRAY_SIZE(wm8993_snd_controls)); if (wm8993->pdata.num_retune_configs != 0) { dev_dbg(codec->dev, "Using ReTune Mobile\n"); } else { dev_dbg(codec->dev, "No ReTune Mobile, using normal EQ\n"); snd_soc_add_controls(codec, wm8993_eq_controls, ARRAY_SIZE(wm8993_eq_controls)); } snd_soc_dapm_new_controls(dapm, wm8993_dapm_widgets, ARRAY_SIZE(wm8993_dapm_widgets)); wm_hubs_add_analogue_controls(codec); snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes)); wm_hubs_add_analogue_routes(codec, wm8993->pdata.lineout1_diff, wm8993->pdata.lineout2_diff); return 0; err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); err_get: regulator_bulk_free(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); return ret; }
static __devinit int wm8350_codec_probe(struct platform_device *pdev) { struct wm8350 *wm8350 = platform_get_drvdata(pdev); struct wm8350_data *priv; struct snd_soc_codec *codec; int ret, i; if (wm8350->codec.platform_data == NULL) { dev_err(&pdev->dev, "No audio platform data supplied\n"); return -EINVAL; } priv = kzalloc(sizeof(struct wm8350_data), GFP_KERNEL); if (priv == NULL) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(supply_names); i++) priv->supplies[i].supply = supply_names[i]; ret = regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies), priv->supplies); if (ret != 0) goto err_priv; codec = &priv->codec; wm8350->codec.codec = codec; wm8350_dai.dev = &pdev->dev; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->dev = &pdev->dev; codec->name = "WM8350"; codec->owner = THIS_MODULE; codec->read = wm8350_codec_read; codec->write = wm8350_codec_write; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm8350_set_bias_level; codec->dai = &wm8350_dai; codec->num_dai = 1; codec->reg_cache_size = WM8350_MAX_REGISTER; codec->private_data = priv; codec->control_data = wm8350; /* Put the codec into reset if it wasn't already */ wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); INIT_DELAYED_WORK(&codec->delayed_work, wm8350_pga_work); ret = snd_soc_register_codec(codec); if (ret != 0) goto err_supply; wm8350_codec = codec; ret = snd_soc_register_dai(&wm8350_dai); if (ret != 0) goto err_codec; return 0; err_codec: snd_soc_unregister_codec(codec); err_supply: regulator_bulk_free(ARRAY_SIZE(priv->supplies), priv->supplies); err_priv: kfree(priv); wm8350_codec = NULL; return ret; }
static int __devinit twl6040_vibra_probe(struct platform_device *pdev) { struct twl4030_vibra_data *pdata = pdev->dev.platform_data; struct vibra_info *info; int ret; if (!pdata) { dev_err(&pdev->dev, "platform_data not available\n"); return -EINVAL; } info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "couldn't allocate memory\n"); return -ENOMEM; } info->dev = &pdev->dev; info->twl6040 = dev_get_drvdata(pdev->dev.parent); info->vibldrv_res = pdata->vibldrv_res; info->vibrdrv_res = pdata->vibrdrv_res; info->viblmotor_res = pdata->viblmotor_res; info->vibrmotor_res = pdata->vibrmotor_res; if ((!info->vibldrv_res && !info->viblmotor_res) || (!info->vibrdrv_res && !info->vibrmotor_res)) { dev_err(info->dev, "invalid vibra driver/motor resistance\n"); ret = -EINVAL; goto err_kzalloc; } info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) { dev_err(info->dev, "invalid irq\n"); ret = -EINVAL; goto err_kzalloc; } mutex_init(&info->mutex); info->input_dev = input_allocate_device(); if (info->input_dev == NULL) { dev_err(info->dev, "couldn't allocate input device\n"); ret = -ENOMEM; goto err_kzalloc; } input_set_drvdata(info->input_dev, info); info->input_dev->name = "twl6040:vibrator"; info->input_dev->id.version = 1; info->input_dev->dev.parent = pdev->dev.parent; info->input_dev->close = twl6040_vibra_close; __set_bit(FF_RUMBLE, info->input_dev->ffbit); ret = input_ff_create_memless(info->input_dev, NULL, vibra_play); if (ret < 0) { dev_err(info->dev, "couldn't register vibrator to FF\n"); goto err_ialloc; } ret = input_register_device(info->input_dev); if (ret < 0) { dev_err(info->dev, "couldn't register input device\n"); goto err_iff; } platform_set_drvdata(pdev, info); ret = request_threaded_irq(info->irq, NULL, twl6040_vib_irq_handler, 0, "twl6040_irq_vib", info); if (ret) { dev_err(info->dev, "VIB IRQ request failed: %d\n", ret); goto err_irq; } info->supplies[0].supply = "vddvibl"; info->supplies[1].supply = "vddvibr"; ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies), info->supplies); if (ret) { dev_err(info->dev, "couldn't get regulators %d\n", ret); goto err_regulator; } if (pdata->vddvibl_uV) { ret = regulator_set_voltage(info->supplies[0].consumer, pdata->vddvibl_uV, pdata->vddvibl_uV); if (ret) { dev_err(info->dev, "failed to set VDDVIBL volt %d\n", ret); goto err_voltage; } } if (pdata->vddvibr_uV) { ret = regulator_set_voltage(info->supplies[1].consumer, pdata->vddvibr_uV, pdata->vddvibr_uV); if (ret) { dev_err(info->dev, "failed to set VDDVIBR volt %d\n", ret); goto err_voltage; } } info->workqueue = alloc_workqueue("twl6040-vibra", 0, 0); if (info->workqueue == NULL) { dev_err(info->dev, "couldn't create workqueue\n"); ret = -ENOMEM; goto err_voltage; } INIT_WORK(&info->play_work, vibra_play_work); return 0; err_voltage: regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies); err_regulator: free_irq(info->irq, info); err_irq: input_unregister_device(info->input_dev); info->input_dev = NULL; err_iff: if (info->input_dev) input_ff_destroy(info->input_dev); err_ialloc: input_free_device(info->input_dev); err_kzalloc: kfree(info); return ret; }
/* * Instantiate the generic non-control parts of the device. */ static int wm8994_device_init(struct wm8994 *wm8994, int irq) { struct wm8994_pdata *pdata = wm8994->dev->platform_data; const char *devname; int ret, i; mutex_init(&wm8994->io_lock); dev_set_drvdata(wm8994->dev, wm8994); /* Add the on-chip regulators first for bootstrapping */ ret = mfd_add_devices(wm8994->dev, -1, wm8994_regulator_devs, ARRAY_SIZE(wm8994_regulator_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err; } switch (wm8994->type) { case WM8994: wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); break; case WM8958: wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); break; default: BUG(); return -EINVAL; } wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) * wm8994->num_supplies, GFP_KERNEL); if (!wm8994->supplies) { ret = -ENOMEM; goto err; } switch (wm8994->type) { case WM8994: for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++) wm8994->supplies[i].supply = wm8994_main_supplies[i]; break; case WM8958: for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++) wm8994->supplies[i].supply = wm8958_main_supplies[i]; break; default: BUG(); return -EINVAL; } ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); goto err_supplies; } ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); if (ret < 0) { dev_err(wm8994->dev, "Failed to read ID register\n"); goto err_enable; } switch (ret) { case 0x8994: devname = "WM8994"; if (wm8994->type != WM8994) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8994; break; case 0x8958: devname = "WM8958"; if (wm8994->type != WM8958) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8958; break; default: dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", ret); ret = -EINVAL; goto err_enable; } ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); if (ret < 0) { dev_err(wm8994->dev, "Failed to read revision register: %d\n", ret); goto err_enable; } switch (ret) { case 0: case 1: if (wm8994->type == WM8994) dev_warn(wm8994->dev, "revision %c not fully supported\n", 'A' + ret); break; default: break; } dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret); if (pdata) { wm8994->irq_base = pdata->irq_base; wm8994->gpio_base = pdata->gpio_base; /* GPIO configuration is only applied if it's non-zero */ for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { if (pdata->gpio_defaults[i]) { wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, 0xffff, pdata->gpio_defaults[i]); } } } /* In some system designs where the regulators are not in use, * we can achieve a small reduction in leakage currents by * floating LDO outputs. This bit makes no difference if the * LDOs are enabled, it only affects cases where the LDOs were * in operation and are then disabled. */ for (i = 0; i < WM8994_NUM_LDO_REGS; i++) { if (wm8994_ldo_in_use(pdata, i)) wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, WM8994_LDO1_DISCH); else wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, 0); } wm8994_irq_init(wm8994); ret = mfd_add_devices(wm8994->dev, -1, wm8994_devs, ARRAY_SIZE(wm8994_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err_irq; } pm_runtime_enable(wm8994->dev); pm_runtime_resume(wm8994->dev); return 0; err_irq: wm8994_irq_exit(wm8994); err_enable: regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); err_get: regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); err_supplies: kfree(wm8994->supplies); err: mfd_remove_devices(wm8994->dev); kfree(wm8994); return ret; }
static int bh1770_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct bh1770_chip *chip; int err; chip = kzalloc(sizeof *chip, GFP_KERNEL); if (!chip) return -ENOMEM; i2c_set_clientdata(client, chip); chip->client = client; mutex_init(&chip->mutex); init_waitqueue_head(&chip->wait); INIT_DELAYED_WORK(&chip->prox_work, bh1770_prox_work); if (client->dev.platform_data == NULL) { dev_err(&client->dev, "platform data is mandatory\n"); err = -EINVAL; goto fail1; } chip->pdata = client->dev.platform_data; chip->lux_calib = BH1770_LUX_NEUTRAL_CALIB_VALUE; chip->lux_rate_index = BH1770_LUX_DEFAULT_RATE; chip->lux_threshold_lo = BH1770_LUX_DEF_THRES; chip->lux_threshold_hi = BH1770_LUX_DEF_THRES; if (chip->pdata->glass_attenuation == 0) chip->lux_ga = BH1770_NEUTRAL_GA; else chip->lux_ga = chip->pdata->glass_attenuation; chip->prox_threshold = BH1770_PROX_DEF_THRES; chip->prox_led = chip->pdata->led_def_curr; chip->prox_abs_thres = BH1770_PROX_DEF_ABS_THRES; chip->prox_persistence = BH1770_DEFAULT_PERSISTENCE; chip->prox_rate_threshold = BH1770_PROX_DEF_RATE_THRESH; chip->prox_rate = BH1770_PROX_DEFAULT_RATE; chip->prox_data = 0; chip->regs[0].supply = reg_vcc; chip->regs[1].supply = reg_vleds; err = regulator_bulk_get(&client->dev, ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot get regulators\n"); goto fail1; } err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot enable regulators\n"); goto fail2; } usleep_range(BH1770_STARTUP_DELAY, BH1770_STARTUP_DELAY * 2); err = bh1770_detect(chip); if (err < 0) goto fail3; /* Start chip */ bh1770_chip_on(chip); pm_runtime_set_active(&client->dev); pm_runtime_enable(&client->dev); chip->lux_corr = bh1770_get_corr_value(chip); if (chip->lux_corr == 0) { dev_err(&client->dev, "Improper correction values\n"); err = -EINVAL; goto fail3; } if (chip->pdata->setup_resources) { err = chip->pdata->setup_resources(); if (err) { err = -EINVAL; goto fail3; } } err = sysfs_create_group(&chip->client->dev.kobj, &bh1770_attribute_group); if (err < 0) { dev_err(&chip->client->dev, "Sysfs registration failed\n"); goto fail4; } /* * Chip needs level triggered interrupt to work. However, * level triggering doesn't work always correctly with power * management. Select both */ err = request_threaded_irq(client->irq, NULL, bh1770_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_TRIGGER_LOW, "bh1770", chip); if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); goto fail5; } regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); return err; fail5: sysfs_remove_group(&chip->client->dev.kobj, &bh1770_attribute_group); fail4: if (chip->pdata->release_resources) chip->pdata->release_resources(); fail3: regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); fail2: regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); fail1: kfree(chip); return err; }
static int __devinit m5mols_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct m5mols_platform_data *pdata = client->dev.platform_data; struct m5mols_info *info; struct v4l2_subdev *sd; int ret; if (pdata == NULL) { dev_err(&client->dev, "No platform data\n"); return -EINVAL; } if (!gpio_is_valid(pdata->gpio_reset)) { dev_err(&client->dev, "No valid RESET GPIO specified\n"); return -EINVAL; } if (!pdata->irq) { dev_err(&client->dev, "Interrupt not assigned\n"); return -EINVAL; } info = kzalloc(sizeof(struct m5mols_info), GFP_KERNEL); if (!info) return -ENOMEM; info->pdata = pdata; info->set_power = pdata->set_power; ret = gpio_request(pdata->gpio_reset, "M5MOLS_NRST"); if (ret) { dev_err(&client->dev, "Failed to request gpio: %d\n", ret); goto out_free; } gpio_direction_output(pdata->gpio_reset, pdata->reset_polarity); ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies); if (ret) { dev_err(&client->dev, "Failed to get regulators: %d\n", ret); goto out_gpio; } sd = &info->sd; strlcpy(sd->name, MODULE_NAME, sizeof(sd->name)); v4l2_i2c_subdev_init(sd, client, &m5mols_ops); info->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, 1, &info->pad, 0); if (ret < 0) goto out_reg; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; init_waitqueue_head(&info->irq_waitq); INIT_WORK(&info->work_irq, m5mols_irq_work); ret = request_irq(pdata->irq, m5mols_irq_handler, IRQF_TRIGGER_RISING, MODULE_NAME, sd); if (ret) { dev_err(&client->dev, "Interrupt request failed: %d\n", ret); goto out_me; } info->res_type = M5MOLS_RESTYPE_MONITOR; return 0; out_me: media_entity_cleanup(&sd->entity); out_reg: regulator_bulk_free(ARRAY_SIZE(supplies), supplies); out_gpio: gpio_free(pdata->gpio_reset); out_free: kfree(info); return ret; }
static void lcdc_toshiba_gpio_init(void) { int rc = 0; if (!lcdc_gpio_initialized) { if (gpio_request(GPIO_SPI_CLK, "spi_clk")) { pr_err("failed to request gpio spi_clk\n"); return; } if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) { pr_err("failed to request gpio spi_cs0_N\n"); goto fail_gpio6; } if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) { pr_err("failed to request gpio spi_mosi\n"); goto fail_gpio5; } if (gpio_request(GPIO_SPI_MISO, "spi_miso")) { pr_err("failed to request gpio spi_miso\n"); goto fail_gpio4; } if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) { pr_err("failed to request gpio_disp_pwr\n"); goto fail_gpio3; } if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) { pr_err("failed to request gpio_bkl_en\n"); goto fail_gpio2; } pmapp_disp_backlight_init(); rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc), regs_lcdc); if (rc) { pr_err("%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio1; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc), regs_lcdc); if (rc) { pr_err("%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } lcdc_gpio_initialized = 1; } return; fail_vreg: regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc); fail_gpio1: gpio_free(GPIO_BACKLIGHT_EN); fail_gpio2: gpio_free(GPIO_DISPLAY_PWR_EN); fail_gpio3: gpio_free(GPIO_SPI_MISO); fail_gpio4: gpio_free(GPIO_SPI_MOSI); fail_gpio5: gpio_free(GPIO_SPI_CS0_N); fail_gpio6: gpio_free(GPIO_SPI_CLK); lcdc_gpio_initialized = 0; }
static int wm8523_register(struct wm8523_priv *wm8523, enum snd_soc_control_type control) { int ret; struct snd_soc_codec *codec = &wm8523->codec; int i; if (wm8523_codec) { dev_err(codec->dev, "Another WM8523 is registered\n"); ret = -EINVAL; goto err; } mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); snd_soc_codec_set_drvdata(codec, wm8523); codec->name = "WM8523"; codec->owner = THIS_MODULE; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm8523_set_bias_level; codec->dai = &wm8523_dai; codec->num_dai = 1; codec->reg_cache_size = WM8523_REGISTER_COUNT; codec->reg_cache = &wm8523->reg_cache; codec->volatile_register = wm8523_volatile_register; wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; wm8523->rate_constraint.count = ARRAY_SIZE(wm8523->rate_constraint_list); memcpy(codec->reg_cache, wm8523_reg, sizeof(wm8523_reg)); ret = snd_soc_codec_set_cache_io(codec, 8, 16, control); if (ret != 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); goto err; } for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++) wm8523->supplies[i].supply = wm8523_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); goto err; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = snd_soc_read(codec, WM8523_DEVICE_ID); if (ret < 0) { dev_err(codec->dev, "Failed to read ID register\n"); goto err_enable; } if (ret != wm8523_reg[WM8523_DEVICE_ID]) { dev_err(codec->dev, "Device is not a WM8523, ID is %x\n", ret); ret = -EINVAL; goto err_enable; } ret = snd_soc_read(codec, WM8523_REVISION); if (ret < 0) { dev_err(codec->dev, "Failed to read revision register\n"); goto err_enable; } dev_info(codec->dev, "revision %c\n", (ret & WM8523_CHIP_REV_MASK) + 'A'); ret = wm8523_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset\n"); goto err_enable; } wm8523_dai.dev = codec->dev; /* Change some default settings - latch VU and enable ZC */ wm8523->reg_cache[WM8523_DAC_GAINR] |= WM8523_DACR_VU; wm8523->reg_cache[WM8523_DAC_CTRL3] |= WM8523_ZC; wm8523_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); wm8523_codec = codec; ret = snd_soc_register_codec(codec); if (ret != 0) { dev_err(codec->dev, "Failed to register codec: %d\n", ret); goto err_enable; } ret = snd_soc_register_dai(&wm8523_dai); if (ret != 0) { dev_err(codec->dev, "Failed to register DAI: %d\n", ret); goto err_codec; } return 0; err_codec: snd_soc_unregister_codec(codec); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); err_get: regulator_bulk_free(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); err: kfree(wm8523); return ret; }
/* * Instantiate the generic non-control parts of the device. */ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq) { struct wm8994_pdata *pdata = wm8994->dev->platform_data; struct regmap_config *regmap_config; const struct reg_default *regmap_patch = NULL; const char *devname; int ret, i, patch_regs = 0; int pulls = 0; dev_set_drvdata(wm8994->dev, wm8994); /* Add the on-chip regulators first for bootstrapping */ ret = mfd_add_devices(wm8994->dev, -1, wm8994_regulator_devs, ARRAY_SIZE(wm8994_regulator_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err; } switch (wm8994->type) { case WM1811: wm8994->num_supplies = ARRAY_SIZE(wm1811_main_supplies); break; case WM8994: wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies); break; case WM8958: wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies); break; default: BUG(); goto err; } wm8994->supplies = devm_kzalloc(wm8994->dev, sizeof(struct regulator_bulk_data) * wm8994->num_supplies, GFP_KERNEL); if (!wm8994->supplies) { ret = -ENOMEM; goto err; } switch (wm8994->type) { case WM1811: for (i = 0; i < ARRAY_SIZE(wm1811_main_supplies); i++) wm8994->supplies[i].supply = wm1811_main_supplies[i]; break; case WM8994: for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++) wm8994->supplies[i].supply = wm8994_main_supplies[i]; break; case WM8958: for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++) wm8994->supplies[i].supply = wm8958_main_supplies[i]; break; default: BUG(); goto err; } ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); goto err; } ret = regulator_bulk_enable(wm8994->num_supplies, wm8994->supplies); if (ret != 0) { dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET); if (ret < 0) { dev_err(wm8994->dev, "Failed to read ID register\n"); goto err_enable; } switch (ret) { case 0x1811: devname = "WM1811"; if (wm8994->type != WM1811) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM1811; break; case 0x8994: devname = "WM8994"; if (wm8994->type != WM8994) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8994; break; case 0x8958: devname = "WM8958"; if (wm8994->type != WM8958) dev_warn(wm8994->dev, "Device registered as type %d\n", wm8994->type); wm8994->type = WM8958; break; default: dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n", ret); ret = -EINVAL; goto err_enable; } ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION); if (ret < 0) { dev_err(wm8994->dev, "Failed to read revision register: %d\n", ret); goto err_enable; } wm8994->revision = ret & WM8994_CHIP_REV_MASK; wm8994->cust_id = (ret & WM8994_CUST_ID_MASK) >> WM8994_CUST_ID_SHIFT; switch (wm8994->type) { case WM8994: switch (wm8994->revision) { case 0: case 1: dev_warn(wm8994->dev, "revision %c not fully supported\n", 'A' + wm8994->revision); break; case 2: case 3: regmap_patch = wm8994_revc_patch; patch_regs = ARRAY_SIZE(wm8994_revc_patch); break; default: break; } break; case WM8958: switch (wm8994->revision) { case 0: regmap_patch = wm8958_reva_patch; patch_regs = ARRAY_SIZE(wm8958_reva_patch); break; default: break; } break; case WM1811: /* Revision C did not change the relevant layer */ if (wm8994->revision > 1) wm8994->revision++; switch (wm8994->revision) { case 0: case 1: case 2: case 3: case 4: regmap_patch = wm1811_reva_patch; patch_regs = ARRAY_SIZE(wm1811_reva_patch); break; default: break; } break; default: break; } dev_info(wm8994->dev, "%s revision %c CUST_ID %02x\n", devname, 'A' + wm8994->revision, wm8994->cust_id); switch (wm8994->type) { case WM1811: regmap_config = &wm1811_regmap_config; break; case WM8994: regmap_config = &wm8994_regmap_config; break; case WM8958: regmap_config = &wm8958_regmap_config; break; default: dev_err(wm8994->dev, "Unknown device type %d\n", wm8994->type); return -EINVAL; } ret = regmap_reinit_cache(wm8994->regmap, regmap_config); if (ret != 0) { dev_err(wm8994->dev, "Failed to reinit register cache: %d\n", ret); return ret; } if (regmap_patch) { ret = regmap_register_patch(wm8994->regmap, regmap_patch, patch_regs); if (ret != 0) { dev_err(wm8994->dev, "Failed to register patch: %d\n", ret); goto err; } } if (pdata) { wm8994->irq_base = pdata->irq_base; wm8994->gpio_base = pdata->gpio_base; /* GPIO configuration is only applied if it's non-zero */ for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { if (pdata->gpio_defaults[i]) { wm8994_set_bits(wm8994, WM8994_GPIO_1 + i, 0xffff, pdata->gpio_defaults[i]); } } wm8994->ldo_ena_always_driven = pdata->ldo_ena_always_driven; if (pdata->spkmode_pu) pulls |= WM8994_SPKMODE_PU; } /* Disable unneeded pulls */ wm8994_set_bits(wm8994, WM8994_PULL_CONTROL_2, WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD | WM8994_SPKMODE_PU | WM8994_CSNADDR_PD, pulls); /* In some system designs where the regulators are not in use, * we can achieve a small reduction in leakage currents by * floating LDO outputs. This bit makes no difference if the * LDOs are enabled, it only affects cases where the LDOs were * in operation and are then disabled. */ for (i = 0; i < WM8994_NUM_LDO_REGS; i++) { if (wm8994_ldo_in_use(pdata, i)) wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, WM8994_LDO1_DISCH); else wm8994_set_bits(wm8994, WM8994_LDO_1 + i, WM8994_LDO1_DISCH, 0); } wm8994_irq_init(wm8994); ret = mfd_add_devices(wm8994->dev, -1, wm8994_devs, ARRAY_SIZE(wm8994_devs), NULL, 0); if (ret != 0) { dev_err(wm8994->dev, "Failed to add children: %d\n", ret); goto err_irq; } pm_runtime_enable(wm8994->dev); pm_runtime_idle(wm8994->dev); return 0; err_irq: wm8994_irq_exit(wm8994); err_enable: regulator_bulk_disable(wm8994->num_supplies, wm8994->supplies); err_get: regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); err: mfd_remove_devices(wm8994->dev); return ret; }
static int __devinit apds990x_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct apds990x_chip *chip; int err; chip = kzalloc(sizeof *chip, GFP_KERNEL); if (!chip) return -ENOMEM; i2c_set_clientdata(client, chip); chip->client = client; init_waitqueue_head(&chip->wait); mutex_init(&chip->mutex); chip->pdata = client->dev.platform_data; if (chip->pdata == NULL) { dev_err(&client->dev, "platform data is mandatory\n"); err = -EINVAL; goto fail1; } if (chip->pdata->cf.ga == 0) { /* set uncovered sensor default parameters */ chip->cf.ga = 1966; /* 0.48 * APDS_PARAM_SCALE */ chip->cf.cf1 = 4096; /* 1.00 * APDS_PARAM_SCALE */ chip->cf.irf1 = 9134; /* 2.23 * APDS_PARAM_SCALE */ chip->cf.cf2 = 2867; /* 0.70 * APDS_PARAM_SCALE */ chip->cf.irf2 = 5816; /* 1.42 * APDS_PARAM_SCALE */ chip->cf.df = 52; } else { chip->cf = chip->pdata->cf; } /* precalculate inverse chip factors for threshold control */ chip->rcf.afactor = (chip->cf.irf1 - chip->cf.irf2) * APDS_PARAM_SCALE / (chip->cf.cf1 - chip->cf.cf2); chip->rcf.cf1 = APDS_PARAM_SCALE * APDS_PARAM_SCALE / chip->cf.cf1; chip->rcf.irf1 = chip->cf.irf1 * APDS_PARAM_SCALE / chip->cf.cf1; chip->rcf.cf2 = APDS_PARAM_SCALE * APDS_PARAM_SCALE / chip->cf.cf2; chip->rcf.irf2 = chip->cf.irf2 * APDS_PARAM_SCALE / chip->cf.cf2; /* Set something to start with */ chip->lux_thres_hi = APDS_LUX_DEF_THRES_HI; chip->lux_thres_lo = APDS_LUX_DEF_THRES_LO; chip->lux_calib = APDS_LUX_NEUTRAL_CALIB_VALUE; chip->prox_thres = APDS_PROX_DEF_THRES; chip->pdrive = chip->pdata->pdrive; chip->pdiode = APDS_PDIODE_IR; chip->pgain = APDS_PGAIN_1X; chip->prox_calib = APDS_PROX_NEUTRAL_CALIB_VALUE; chip->prox_persistence = APDS_DEFAULT_PROX_PERS; chip->prox_continuous_mode = false; chip->regs[0].supply = reg_vcc; chip->regs[1].supply = reg_vled; err = regulator_bulk_get(&client->dev, ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot get regulators\n"); goto fail1; } err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot enable regulators\n"); goto fail2; } usleep_range(APDS_STARTUP_DELAY, 2 * APDS_STARTUP_DELAY); err = apds990x_detect(chip); if (err < 0) { dev_err(&client->dev, "APDS990X not found\n"); goto fail3; } pm_runtime_set_active(&client->dev); apds990x_configure(chip); apds990x_set_arate(chip, APDS_LUX_DEFAULT_RATE); apds990x_mode_on(chip); pm_runtime_enable(&client->dev); if (chip->pdata->setup_resources) { err = chip->pdata->setup_resources(); if (err) { err = -EINVAL; goto fail3; } } err = sysfs_create_group(&chip->client->dev.kobj, apds990x_attribute_group); if (err < 0) { dev_err(&chip->client->dev, "Sysfs registration failed\n"); goto fail4; } err = request_threaded_irq(client->irq, NULL, apds990x_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_LOW | IRQF_ONESHOT, "apds990x", chip); if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); goto fail5; } return err; fail5: sysfs_remove_group(&chip->client->dev.kobj, &apds990x_attribute_group[0]); fail4: if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources(); fail3: regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); fail2: regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); fail1: kfree(chip); return err; }
static int mipi_dsi_panel_msm_power(int on) { int rc = 0; /* Power off, Reset Pin pull LOW must before power source off */ //if ((!on) || (!dsi_gpio_initialized)){ if (!on){ rc = msm_fb_dsi_client_msm_reset(1); if (rc < 0) { pr_err("[DISPLAY] %s: Failed to pull low lcm reset\n", __func__); goto fail_gpio2; } } /* I2C-controlled GPIO Expander -init of the GPIOs very late */ if (unlikely(!dsi_gpio_initialized)) { rc = regulator_bulk_get(NULL, ARRAY_SIZE(fih_regs_dsi), fih_regs_dsi); if (rc) { pr_err("[DISPLAY]%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio2; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(fih_regs_dsi), fih_regs_dsi); if (rc) { pr_err("[DISPLAY]%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } msm_fb_dsi_client_msm_reset(1); dsi_gpio_initialized = 1; } rc = on ? regulator_bulk_enable(ARRAY_SIZE(fih_regs_dsi), fih_regs_dsi) : regulator_bulk_disable(ARRAY_SIZE(fih_regs_dsi), fih_regs_dsi); if (rc) pr_err("[DISPLAY]%s: could not %sable regulators: %d\n", __func__, on ? "en" : "dis", rc); printk(KERN_INFO "[DISPLAY]%s: X\n", __func__); return rc; fail_vreg: regulator_bulk_free(ARRAY_SIZE(fih_regs_dsi), fih_regs_dsi); fail_gpio2: //gpio_free(GPIO_BACKLIGHT_EN); //fail_gpio1: //gpio_free(GPIO_DISPLAY_PWR_EN); dsi_gpio_initialized = 0; printk(KERN_ERR "[DISPLAY]%s: X, failed\n", __func__); return rc; }
static int sta32x_probe(struct snd_soc_codec *codec) { struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); int i, ret = 0; sta32x->codec = codec; /* regulators */ for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) sta32x->supplies[i].supply = sta32x_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); goto err; } ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } /* Tell ASoC what kind of I/O to use to read the registers. ASoC will * then do the I2C transactions itself. */ ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); if (ret < 0) { dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret); return ret; } /* Chip documentation explicitly requires that the reset values * of reserved register bits are left untouched. * Write the register default value to cache for reserved registers, * so the write to the these registers are suppressed by the cache * restore code when it skips writes of default registers. */ snd_soc_cache_write(codec, STA32X_CONFC, 0xc2); snd_soc_cache_write(codec, STA32X_CONFE, 0xc2); snd_soc_cache_write(codec, STA32X_CONFF, 0x5c); snd_soc_cache_write(codec, STA32X_MMUTE, 0x10); snd_soc_cache_write(codec, STA32X_AUTO1, 0x60); snd_soc_cache_write(codec, STA32X_AUTO3, 0x00); snd_soc_cache_write(codec, STA32X_C3CFG, 0x40); /* FIXME enable thermal warning adjustment and recovery */ snd_soc_update_bits(codec, STA32X_CONFA, STA32X_CONFA_TWAB | STA32X_CONFA_TWRB, 0); /* FIXME select 2.1 mode */ snd_soc_update_bits(codec, STA32X_CONFF, STA32X_CONFF_OCFG_MASK, 1 << STA32X_CONFF_OCFG_SHIFT); /* FIXME channel to output mapping */ snd_soc_update_bits(codec, STA32X_C1CFG, STA32X_CxCFG_OM_MASK, 0 << STA32X_CxCFG_OM_SHIFT); snd_soc_update_bits(codec, STA32X_C2CFG, STA32X_CxCFG_OM_MASK, 1 << STA32X_CxCFG_OM_SHIFT); snd_soc_update_bits(codec, STA32X_C3CFG, STA32X_CxCFG_OM_MASK, 2 << STA32X_CxCFG_OM_SHIFT); /* initialize coefficient shadow RAM with reset values */ for (i = 4; i <= 49; i += 5) sta32x->coef_shadow[i] = 0x400000; for (i = 50; i <= 54; i++) sta32x->coef_shadow[i] = 0x7fffff; sta32x->coef_shadow[55] = 0x5a9df7; sta32x->coef_shadow[56] = 0x7fffff; sta32x->coef_shadow[59] = 0x7fffff; sta32x->coef_shadow[60] = 0x400000; sta32x->coef_shadow[61] = 0x400000; sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); return 0; err_get: regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); err: return ret; }