static int gbcodec_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_gbcodec, gbcodec_dai, ARRAY_SIZE(gbcodec_dai)); }
static int adau1701_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adau1701 *adau1701; struct device *dev = &client->dev; int gpio_nreset = -EINVAL; int gpio_pll_mode[2] = { -EINVAL, -EINVAL }; int ret, i; adau1701 = devm_kzalloc(dev, sizeof(*adau1701), GFP_KERNEL); if (!adau1701) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(supply_names); i++) adau1701->supplies[i].supply = supply_names[i]; ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(adau1701->supplies), adau1701->supplies); if (ret < 0) { dev_err(dev, "Failed to get regulators: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); if (ret < 0) { dev_err(dev, "Failed to enable regulators: %d\n", ret); return ret; } adau1701->client = client; adau1701->regmap = devm_regmap_init(dev, NULL, client, &adau1701_regmap); if (IS_ERR(adau1701->regmap)) { ret = PTR_ERR(adau1701->regmap); goto exit_regulators_disable; } if (dev->of_node) { gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0); if (gpio_nreset < 0 && gpio_nreset != -ENOENT) { ret = gpio_nreset; goto exit_regulators_disable; } gpio_pll_mode[0] = of_get_named_gpio(dev->of_node, "adi,pll-mode-gpios", 0); if (gpio_pll_mode[0] < 0 && gpio_pll_mode[0] != -ENOENT) { ret = gpio_pll_mode[0]; goto exit_regulators_disable; } gpio_pll_mode[1] = of_get_named_gpio(dev->of_node, "adi,pll-mode-gpios", 1); if (gpio_pll_mode[1] < 0 && gpio_pll_mode[1] != -ENOENT) { ret = gpio_pll_mode[1]; goto exit_regulators_disable; } of_property_read_u32(dev->of_node, "adi,pll-clkdiv", &adau1701->pll_clkdiv); of_property_read_u8_array(dev->of_node, "adi,pin-config", adau1701->pin_config, ARRAY_SIZE(adau1701->pin_config)); } if (gpio_is_valid(gpio_nreset)) { ret = devm_gpio_request_one(dev, gpio_nreset, GPIOF_OUT_INIT_LOW, "ADAU1701 Reset"); if (ret < 0) goto exit_regulators_disable; } if (gpio_is_valid(gpio_pll_mode[0]) && gpio_is_valid(gpio_pll_mode[1])) { ret = devm_gpio_request_one(dev, gpio_pll_mode[0], GPIOF_OUT_INIT_LOW, "ADAU1701 PLL mode 0"); if (ret < 0) goto exit_regulators_disable; ret = devm_gpio_request_one(dev, gpio_pll_mode[1], GPIOF_OUT_INIT_LOW, "ADAU1701 PLL mode 1"); if (ret < 0) goto exit_regulators_disable; } adau1701->gpio_nreset = gpio_nreset; adau1701->gpio_pll_mode[0] = gpio_pll_mode[0]; adau1701->gpio_pll_mode[1] = gpio_pll_mode[1]; i2c_set_clientdata(client, adau1701); adau1701->sigmadsp = devm_sigmadsp_init_i2c(client, &adau1701_sigmadsp_ops, ADAU1701_FIRMWARE); if (IS_ERR(adau1701->sigmadsp)) { ret = PTR_ERR(adau1701->sigmadsp); goto exit_regulators_disable; } ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv, &adau1701_dai, 1); exit_regulators_disable: regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); return ret; }
static int wm2000_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct wm2000_priv *wm2000; struct wm2000_platform_data *pdata; const char *filename; const struct firmware *fw = NULL; int ret, i; int reg; u16 id; wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), GFP_KERNEL); if (!wm2000) return -ENOMEM; mutex_init(&wm2000->lock); dev_set_drvdata(&i2c->dev, wm2000); wm2000->regmap = devm_regmap_init_i2c(i2c, &wm2000_regmap); if (IS_ERR(wm2000->regmap)) { ret = PTR_ERR(wm2000->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto out; } for (i = 0; i < WM2000_NUM_SUPPLIES; i++) wm2000->supplies[i].supply = wm2000_supplies[i]; ret = devm_regulator_bulk_get(&i2c->dev, WM2000_NUM_SUPPLIES, wm2000->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret); return ret; } ret = regulator_bulk_enable(WM2000_NUM_SUPPLIES, wm2000->supplies); if (ret != 0) { dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); return ret; } /* Verify that this is a WM2000 */ reg = wm2000_read(i2c, WM2000_REG_ID1); id = reg << 8; reg = wm2000_read(i2c, WM2000_REG_ID2); id |= reg & 0xff; if (id != 0x2000) { dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id); ret = -ENODEV; goto err_supplies; } reg = wm2000_read(i2c, WM2000_REG_REVISON); dev_info(&i2c->dev, "revision %c\n", reg + 'A'); wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK"); if (IS_ERR(wm2000->mclk)) { ret = PTR_ERR(wm2000->mclk); dev_err(&i2c->dev, "Failed to get MCLK: %d\n", ret); goto err_supplies; } filename = "wm2000_anc.bin"; pdata = dev_get_platdata(&i2c->dev); if (pdata) { wm2000->speech_clarity = !pdata->speech_enh_disable; if (pdata->download_file) filename = pdata->download_file; } ret = request_firmware(&fw, filename, &i2c->dev); if (ret != 0) { dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret); goto err_supplies; } /* Pre-cook the concatenation of the register address onto the image */ wm2000->anc_download_size = fw->size + 2; wm2000->anc_download = devm_kzalloc(&i2c->dev, wm2000->anc_download_size, GFP_KERNEL); if (wm2000->anc_download == NULL) { dev_err(&i2c->dev, "Out of memory\n"); ret = -ENOMEM; goto err_supplies; } wm2000->anc_download[0] = 0x80; wm2000->anc_download[1] = 0x00; memcpy(wm2000->anc_download + 2, fw->data, fw->size); wm2000->anc_eng_ena = 1; wm2000->anc_active = 1; wm2000->spk_ena = 1; wm2000->i2c = i2c; wm2000_reset(wm2000); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); err_supplies: regulator_bulk_disable(WM2000_NUM_SUPPLIES, wm2000->supplies); out: release_firmware(fw); return ret; }
static int ac97_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_ac97, &ac97_dai, 1); }
static int wm8961_register(struct wm8961_priv *wm8961) { struct snd_soc_codec *codec = &wm8961->codec; int ret; u16 reg; if (wm8961_codec) { dev_err(codec->dev, "Another WM8961 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, wm8961); codec->name = "WM8961"; codec->owner = THIS_MODULE; codec->dai = &wm8961_dai; codec->num_dai = 1; codec->reg_cache_size = ARRAY_SIZE(wm8961->reg_cache); codec->reg_cache = &wm8961->reg_cache; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm8961_set_bias_level; codec->volatile_register = wm8961_volatile_register; memcpy(codec->reg_cache, wm8961_reg_defaults, sizeof(wm8961_reg_defaults)); 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); goto err; } reg = snd_soc_read(codec, WM8961_SOFTWARE_RESET); if (reg != 0x1801) { dev_err(codec->dev, "Device is not a WM8961: ID=0x%x\n", reg); ret = -EINVAL; goto err; } /* This isn't volatile - readback doesn't correspond to write */ reg = codec->hw_read(codec, WM8961_RIGHT_INPUT_VOLUME); dev_info(codec->dev, "WM8961 family %d revision %c\n", (reg & WM8961_DEVICE_ID_MASK) >> WM8961_DEVICE_ID_SHIFT, ((reg & WM8961_CHIP_REV_MASK) >> WM8961_CHIP_REV_SHIFT) + 'A'); ret = wm8961_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset\n"); return ret; } /* Enable class W */ reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B); reg |= WM8961_CP_DYN_PWR_MASK; snd_soc_write(codec, WM8961_CHARGE_PUMP_B, reg); /* Latch volume update bits (right channel only, we always * write both out) and default ZC on. */ reg = snd_soc_read(codec, WM8961_ROUT1_VOLUME); snd_soc_write(codec, WM8961_ROUT1_VOLUME, reg | WM8961_LO1ZC | WM8961_OUT1VU); snd_soc_write(codec, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC); reg = snd_soc_read(codec, WM8961_ROUT2_VOLUME); snd_soc_write(codec, WM8961_ROUT2_VOLUME, reg | WM8961_SPKRZC | WM8961_SPKVU); snd_soc_write(codec, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC); reg = snd_soc_read(codec, WM8961_RIGHT_ADC_VOLUME); snd_soc_write(codec, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU); reg = snd_soc_read(codec, WM8961_RIGHT_INPUT_VOLUME); snd_soc_write(codec, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU); /* Use soft mute by default */ reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); reg |= WM8961_DACSMM; snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); /* Use automatic clocking mode by default; for now this is all * we support. */ reg = snd_soc_read(codec, WM8961_CLOCKING_3); reg &= ~WM8961_MANUAL_MODE; snd_soc_write(codec, WM8961_CLOCKING_3, reg); wm8961_set_bias_level(codec, SND_SOC_BIAS_STANDBY); wm8961_dai.dev = codec->dev; wm8961_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(&wm8961_dai); if (ret != 0) { dev_err(codec->dev, "Failed to register DAI: %d\n", ret); snd_soc_unregister_codec(codec); return ret; } return 0; err: kfree(wm8961); return ret; }
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"); return -EINVAL; } 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); return ret; } ret = snd_soc_register_dai(&wm8523_dai); if (ret != 0) { dev_err(codec->dev, "Failed to register DAI: %d\n", ret); snd_soc_unregister_codec(codec); return ret; } return 0; 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; }
static int __devinit cg29xx_codec_driver_probe(struct platform_device *pdev) { int ret; struct cg29xx_codec_dai_data *dai_data; pr_debug("%s: Enter.\n", __func__); pr_info("%s: Init codec private data..\n", __func__); dai_data = kzalloc(CG29XX_NBR_OF_DAI * sizeof(struct cg29xx_codec_dai_data), GFP_KERNEL); if (dai_data == NULL) return -ENOMEM; dai_data[0].tx_active = 0; dai_data[0].rx_active = 0; dai_data[0].input_select = 0; dai_data[0].output_select = 0; dai_data[0].config.port = PORT_0_I2S; dai_data[0].config.conf.i2s.mode = DAI_MODE_SLAVE; dai_data[0].config.conf.i2s.half_period = HALF_PER_DUR_16; dai_data[0].config.conf.i2s.channel_sel = CHANNEL_SELECTION_BOTH; dai_data[0].config.conf.i2s.sample_rate = SAMPLE_RATE_48; dai_data[0].config.conf.i2s.word_width = WORD_WIDTH_32; dai_data[1].tx_active = 0; dai_data[1].rx_active = 0; dai_data[1].input_select = 0; dai_data[1].output_select = 0; dai_data[1].config.port = PORT_1_I2S_PCM; dai_data[1].config.conf.i2s_pcm.mode = DAI_MODE_SLAVE; dai_data[1].config.conf.i2s_pcm.slot_0_dir = DAI_DIR_B_RX_A_TX; dai_data[1].config.conf.i2s_pcm.slot_1_dir = DAI_DIR_B_TX_A_RX; dai_data[1].config.conf.i2s_pcm.slot_2_dir = DAI_DIR_B_RX_A_TX; dai_data[1].config.conf.i2s_pcm.slot_3_dir = DAI_DIR_B_RX_A_TX; dai_data[1].config.conf.i2s_pcm.slot_0_used = true; dai_data[1].config.conf.i2s_pcm.slot_1_used = false; dai_data[1].config.conf.i2s_pcm.slot_2_used = false; dai_data[1].config.conf.i2s_pcm.slot_3_used = false; dai_data[1].config.conf.i2s_pcm.slot_0_start = 0; dai_data[1].config.conf.i2s_pcm.slot_1_start = 16; dai_data[1].config.conf.i2s_pcm.slot_2_start = 32; dai_data[1].config.conf.i2s_pcm.slot_3_start = 48; dai_data[1].config.conf.i2s_pcm.protocol = PORT_PROTOCOL_PCM; dai_data[1].config.conf.i2s_pcm.ratio = STREAM_RATIO_FM48_VOICE16; dai_data[1].config.conf.i2s_pcm.duration = SYNC_DURATION_32; dai_data[1].config.conf.i2s_pcm.clk = BIT_CLK_512; dai_data[1].config.conf.i2s_pcm.sample_rate = SAMPLE_RATE_16; platform_set_drvdata(pdev, dai_data); pr_info("%s: Register codec.\n", __func__); ret = snd_soc_register_codec(&pdev->dev, &cg29xx_codec_driver, &cg29xx_dai_driver[0], 2); if (ret < 0) { pr_debug("%s: Error: Failed to register codec (ret = %d).\n", __func__, ret); snd_soc_unregister_codec(&pdev->dev); kfree(platform_get_drvdata(pdev)); return ret; } return 0; }
static int cq93vc_platform_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cq93vc, &cq93vc_dai, 1); }
static int __devinit uda134x_codec_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_uda134x, &uda134x_dai, 1); }
static int s5m8751_codec_probe(struct platform_device *pdev) { struct s5m8751_priv *priv; struct s5m8751 *s5m8751 = dev_get_drvdata(pdev->dev.parent); struct s5m8751_pdata *s5m8751_pdata = s5m8751->dev->platform_data; struct s5m8751_audio_pdata *pdata = s5m8751_pdata->audio; struct snd_soc_codec *codec; uint8_t reg_val; int ret = 0; priv = kzalloc(sizeof(struct s5m8751_priv), GFP_KERNEL); if (priv == NULL) goto err; priv->s5m8751 = s5m8751; codec = &priv->codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); snd_soc_codec_set_drvdata(codec, priv); codec->name = "S5M8751"; codec->owner = THIS_MODULE; codec->read = s5m8751_codec_read; codec->write = s5m8751_codec_write; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = s5m8751_set_bias_level; codec->dai = &s5m8751_dai; codec->num_dai = 1; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); s5m8751_codec = codec; reg_val = s5m8751_codec_read(codec, S5M8751_AMP_CTRL); s5m8751_codec_write(codec, S5M8751_AMP_CTRL, reg_val | S5M8751_HP_AMP_MUTE_CONTROL_ON); s5m8751_codec_write(codec, S5M8751_DA_PDB1, S5M8751_DA_PDB1_SPK | S5M8751_VMID_50K); s5m8751_codec_write(codec, S5M8751_DA_AMIX1, S5M8751_DA_AMIX1_SPK); reg_val = s5m8751_codec_read(codec, S5M8751_IN1_CTRL1); reg_val &= ~S5M8751_LOGIC_PDN; s5m8751_codec_write(codec, S5M8751_IN1_CTRL1, reg_val); reg_val |= S5M8751_LOGIC_PDN; s5m8751_codec_write(codec, S5M8751_IN1_CTRL1, reg_val); s5m8751_codec_write(codec, S5M8751_DA_VOLL, pdata->dac_vol); s5m8751_codec_write(codec, S5M8751_DA_VOLR, pdata->dac_vol); s5m8751_codec_write(codec, S5M8751_HP_VOL1, pdata->hp_vol); s5m8751_codec_write(codec, S5M8751_HP_VOL2, pdata->hp_vol); s5m8751_codec_write(codec, S5M8751_AMP_EN, S5M8751_SPK_AMP_EN); codec->dev = &pdev->dev; s5m8751_dai.dev = codec->dev; s5m8751_set_bias_level(codec, SND_SOC_BIAS_STANDBY); s5m8751_codec = codec; ret = snd_soc_register_codec(codec); if (ret != 0) { dev_err(codec->dev, "Failed to register codec: %d\n", ret); goto err_codec; } ret = snd_soc_register_dais(&s5m8751_dai, 1); 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: kfree(priv); return ret; }
static int __devinit dfbmcs320_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_dfbmcs320, &dfbmcs320_dai, 1); }
static int wm9090_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm9090_priv *wm9090; struct snd_soc_codec *codec; int ret; wm9090 = kzalloc(sizeof(*wm9090), GFP_KERNEL); if (wm9090 == NULL) { dev_err(&i2c->dev, "Can not allocate memory\n"); return -ENOMEM; } codec = &wm9090->codec; if (i2c->dev.platform_data) memcpy(&wm9090->pdata, i2c->dev.platform_data, sizeof(wm9090->pdata)); wm9090_codec = codec; i2c_set_clientdata(i2c, wm9090); mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->control_data = i2c; snd_soc_codec_set_drvdata(codec, wm9090); codec->dev = &i2c->dev; codec->name = "WM9090"; codec->owner = THIS_MODULE; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm9090_set_bias_level, codec->reg_cache_size = WM9090_MAX_REGISTER + 1; codec->reg_cache = &wm9090->reg_cache; codec->volatile_register = wm9090_volatile; 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); goto err; } memcpy(&wm9090->reg_cache, wm9090_reg_defaults, sizeof(wm9090->reg_cache)); ret = snd_soc_read(codec, WM9090_SOFTWARE_RESET); if (ret < 0) goto err; if (ret != wm9090_reg_defaults[WM9090_SOFTWARE_RESET]) { dev_err(&i2c->dev, "Device is not a WM9090, ID=%x\n", ret); ret = -EINVAL; goto err; } ret = snd_soc_write(codec, WM9090_SOFTWARE_RESET, 0); if (ret < 0) goto err; /* Configure some defaults; they will be written out when we * bring the bias up. */ wm9090->reg_cache[WM9090_IN1_LINE_INPUT_A_VOLUME] |= WM9090_IN1_VU | WM9090_IN1A_ZC; wm9090->reg_cache[WM9090_IN1_LINE_INPUT_B_VOLUME] |= WM9090_IN1_VU | WM9090_IN1B_ZC; wm9090->reg_cache[WM9090_IN2_LINE_INPUT_A_VOLUME] |= WM9090_IN2_VU | WM9090_IN2A_ZC; wm9090->reg_cache[WM9090_IN2_LINE_INPUT_B_VOLUME] |= WM9090_IN2_VU | WM9090_IN2B_ZC; wm9090->reg_cache[WM9090_SPEAKER_VOLUME_LEFT] |= WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC; wm9090->reg_cache[WM9090_LEFT_OUTPUT_VOLUME] |= WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC; wm9090->reg_cache[WM9090_RIGHT_OUTPUT_VOLUME] |= WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC; wm9090->reg_cache[WM9090_CLOCKING_1] |= WM9090_TOCLK_ENA; wm9090_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ret = snd_soc_register_codec(codec); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); goto err_bias; } return 0; err_bias: wm9090_set_bias_level(codec, SND_SOC_BIAS_OFF); err: kfree(wm9090); i2c_set_clientdata(i2c, NULL); wm9090_codec = NULL; return ret; }
static __devinit int wm8903_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8903_priv *wm8903; struct snd_soc_codec *codec; int ret; u16 val; wm8903 = kzalloc(sizeof(struct wm8903_priv), GFP_KERNEL); if (wm8903 == NULL) return -ENOMEM; codec = &wm8903->codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->dev = &i2c->dev; codec->name = "WM8903"; codec->owner = THIS_MODULE; codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm8903_set_bias_level; codec->dai = &wm8903_dai; codec->num_dai = 1; codec->reg_cache_size = ARRAY_SIZE(wm8903->reg_cache); codec->reg_cache = &wm8903->reg_cache[0]; codec->private_data = wm8903; codec->volatile_register = wm8903_volatile_register; i2c_set_clientdata(i2c, codec); codec->control_data = i2c; ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); if (ret != 0) { dev_err(&i2c->dev, "Failed to set cache I/O: %d\n", ret); goto err; } val = snd_soc_read(codec, WM8903_SW_RESET_AND_ID); if (val != wm8903_reg_defaults[WM8903_SW_RESET_AND_ID]) { dev_err(&i2c->dev, "Device with ID register %x is not a WM8903\n", val); return -ENODEV; } val = snd_soc_read(codec, WM8903_REVISION_NUMBER); dev_info(&i2c->dev, "WM8903 revision %d\n", val & WM8903_CHIP_REV_MASK); wm8903_reset(codec); /* power on device */ wm8903_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Latch volume update bits */ val = snd_soc_read(codec, WM8903_ADC_DIGITAL_VOLUME_LEFT); val |= WM8903_ADCVU; snd_soc_write(codec, WM8903_ADC_DIGITAL_VOLUME_LEFT, val); snd_soc_write(codec, WM8903_ADC_DIGITAL_VOLUME_RIGHT, val); val = snd_soc_read(codec, WM8903_DAC_DIGITAL_VOLUME_LEFT); val |= WM8903_DACVU; snd_soc_write(codec, WM8903_DAC_DIGITAL_VOLUME_LEFT, val); snd_soc_write(codec, WM8903_DAC_DIGITAL_VOLUME_RIGHT, val); val = snd_soc_read(codec, WM8903_ANALOGUE_OUT1_LEFT); val |= WM8903_HPOUTVU; snd_soc_write(codec, WM8903_ANALOGUE_OUT1_LEFT, val); snd_soc_write(codec, WM8903_ANALOGUE_OUT1_RIGHT, val); val = snd_soc_read(codec, WM8903_ANALOGUE_OUT2_LEFT); val |= WM8903_LINEOUTVU; snd_soc_write(codec, WM8903_ANALOGUE_OUT2_LEFT, val); snd_soc_write(codec, WM8903_ANALOGUE_OUT2_RIGHT, val); val = snd_soc_read(codec, WM8903_ANALOGUE_OUT3_LEFT); val |= WM8903_SPKVU; snd_soc_write(codec, WM8903_ANALOGUE_OUT3_LEFT, val); snd_soc_write(codec, WM8903_ANALOGUE_OUT3_RIGHT, val); /* Enable DAC soft mute by default */ val = snd_soc_read(codec, WM8903_DAC_DIGITAL_1); val |= WM8903_DAC_MUTEMODE; snd_soc_write(codec, WM8903_DAC_DIGITAL_1, val); wm8903_dai.dev = &i2c->dev; wm8903_codec = codec; ret = snd_soc_register_codec(codec); if (ret != 0) { dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); goto err; } ret = snd_soc_register_dai(&wm8903_dai); if (ret != 0) { dev_err(&i2c->dev, "Failed to register DAI: %d\n", ret); goto err_codec; } return ret; err_codec: snd_soc_unregister_codec(codec); err: wm8903_codec = NULL; kfree(wm8903); return ret; }
static int tfa_dummy_platform_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_tfa_dummy, &tfa_dummy_dai, 1); }
static int spdif_dit_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit, &dit_stub_dai, 1); }
static int cs42l73_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs42l73_private *cs42l73; struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev); int ret; unsigned int devid = 0; unsigned int reg; u32 val32; cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), GFP_KERNEL); if (!cs42l73) return -ENOMEM; cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); if (IS_ERR(cs42l73->regmap)) { ret = PTR_ERR(cs42l73->regmap); dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); return ret; } if (pdata) { cs42l73->pdata = *pdata; } else { pdata = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_platform_data), GFP_KERNEL); if (!pdata) { dev_err(&i2c_client->dev, "could not allocate pdata\n"); return -ENOMEM; } if (i2c_client->dev.of_node) { if (of_property_read_u32(i2c_client->dev.of_node, "chgfreq", &val32) >= 0) pdata->chgfreq = val32; } pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, "reset-gpio", 0); cs42l73->pdata = *pdata; } i2c_set_clientdata(i2c_client, cs42l73); if (cs42l73->pdata.reset_gpio) { ret = devm_gpio_request_one(&i2c_client->dev, cs42l73->pdata.reset_gpio, GPIOF_OUT_INIT_HIGH, "CS42L73 /RST"); if (ret < 0) { dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", cs42l73->pdata.reset_gpio, ret); return ret; } gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0); gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1); } regcache_cache_bypass(cs42l73->regmap, true); /* initialize codec */ ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, ®); devid = (reg & 0xFF) << 12; ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_CD, ®); devid |= (reg & 0xFF) << 4; ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, ®); devid |= (reg & 0xF0) >> 4; if (devid != CS42L73_DEVID) { ret = -ENODEV; dev_err(&i2c_client->dev, "CS42L73 Device ID (%X). Expected %X\n", devid, CS42L73_DEVID); return ret; } ret = regmap_read(cs42l73->regmap, CS42L73_REVID, ®); if (ret < 0) { dev_err(&i2c_client->dev, "Get Revision ID failed\n"); return ret;; } dev_info(&i2c_client->dev, "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF); regcache_cache_bypass(cs42l73->regmap, false); ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_cs42l73, cs42l73_dai, ARRAY_SIZE(cs42l73_dai)); if (ret < 0) return ret; return 0; }
static int __devinit sndspdif_codec_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_sndspdif, &sndspdif_dai, 1); }
static __devinit int alc5632_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct alc5632_priv *alc5632; int ret, ret1, ret2; unsigned int vid1, vid2; alc5632 = devm_kzalloc(&client->dev, sizeof(struct alc5632_priv), GFP_KERNEL); if (alc5632 == NULL) return -ENOMEM; i2c_set_clientdata(client, alc5632); alc5632->regmap = regmap_init_i2c(client, &alc5632_regmap); if (IS_ERR(alc5632->regmap)) { ret = PTR_ERR(alc5632->regmap); dev_err(&client->dev, "regmap_init() failed: %d\n", ret); return ret; } ret1 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID1, &vid1); ret2 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID2, &vid2); if (ret1 != 0 || ret2 != 0) { dev_err(&client->dev, "Failed to read chip ID: ret1=%d, ret2=%d\n", ret1, ret2); regmap_exit(alc5632->regmap); return -EIO; } vid2 >>= 8; if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) { dev_err(&client->dev, "Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2); regmap_exit(alc5632->regmap); return -EINVAL; } ret = alc5632_reset(alc5632->regmap); if (ret < 0) { dev_err(&client->dev, "Failed to issue reset\n"); regmap_exit(alc5632->regmap); return ret; } alc5632->id = vid2; switch (alc5632->id) { case 0x5c: alc5632_dai.name = "alc5632-hifi"; break; default: return -EINVAL; } ret = snd_soc_register_codec(&client->dev, &soc_codec_device_alc5632, &alc5632_dai, 1); if (ret < 0) { dev_err(&client->dev, "Failed to register codec: %d\n", ret); regmap_exit(alc5632->regmap); return ret; } return ret; }
static int wm8993_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8993_priv *wm8993; struct snd_soc_codec *codec; unsigned int val; int ret; int i; if (wm8993_codec) { dev_err(&i2c->dev, "A WM8993 is already registered\n"); return -EINVAL; } wm8993 = kzalloc(sizeof(struct wm8993_priv), GFP_KERNEL); if (wm8993 == NULL) return -ENOMEM; codec = &wm8993->codec; if (i2c->dev.platform_data) memcpy(&wm8993->pdata, i2c->dev.platform_data, sizeof(wm8993->pdata)); mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); codec->name = "WM8993"; codec->volatile_register = wm8993_volatile; codec->reg_cache = wm8993->reg_cache; codec->reg_cache_size = ARRAY_SIZE(wm8993->reg_cache); codec->bias_level = SND_SOC_BIAS_OFF; codec->set_bias_level = wm8993_set_bias_level; codec->dai = &wm8993_dai; codec->num_dai = 1; codec->private_data = wm8993; wm8993->hubs_data.hp_startup_mode = 1; wm8993->hubs_data.dcs_codes = -2; memcpy(wm8993->reg_cache, wm8993_reg_defaults, sizeof(wm8993->reg_cache)); 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); goto err; } i2c_set_clientdata(i2c, wm8993); codec->control_data = i2c; wm8993_codec = codec; codec->dev = &i2c->dev; 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); goto err; } 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; wm8993_dai.dev = codec->dev; ret = snd_soc_register_dai(&wm8993_dai); if (ret != 0) goto err_bias; ret = snd_soc_register_codec(codec); return 0; err_bias: wm8993_set_bias_level(codec, SND_SOC_BIAS_OFF); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); err_get: regulator_bulk_free(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); err: wm8993_codec = NULL; kfree(wm8993); return ret; }
static int __devinit twl6040_codec_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl6040, twl6040_dai, ARRAY_SIZE(twl6040_dai)); }
static int tas5086_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct tas5086_private *priv; struct device *dev = &i2c->dev; int gpio_nreset = -EINVAL; int i, ret; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(supply_names); i++) priv->supplies[i].supply = supply_names[i]; ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(priv->supplies), priv->supplies); if (ret < 0) { dev_err(dev, "Failed to get regulators: %d\n", ret); return ret; } priv->regmap = devm_regmap_init(dev, NULL, i2c, &tas5086_regmap); if (IS_ERR(priv->regmap)) { ret = PTR_ERR(priv->regmap); dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret); return ret; } i2c_set_clientdata(i2c, priv); if (of_match_device(of_match_ptr(tas5086_dt_ids), dev)) { struct device_node *of_node = dev->of_node; gpio_nreset = of_get_named_gpio(of_node, "reset-gpio", 0); } if (gpio_is_valid(gpio_nreset)) if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset")) gpio_nreset = -EINVAL; priv->gpio_nreset = gpio_nreset; ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret < 0) { dev_err(dev, "Failed to enable regulators: %d\n", ret); return ret; } tas5086_reset(priv); /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */ ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i); if (ret == 0 && i != 0x3) { dev_err(dev, "Failed to identify TAS5086 codec (got %02x)\n", i); ret = -ENODEV; } /* * The chip has been identified, so we can turn off the power * again until the dai link is set up. */ regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret == 0) ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tas5086, &tas5086_dai, 1); return ret; }
static int cs42l52_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs42l52_private *cs42l52; struct cs42l52_platform_data *pdata = dev_get_platdata(&i2c_client->dev); int ret; unsigned int devid = 0; unsigned int reg; u32 val32; cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private), GFP_KERNEL); if (cs42l52 == NULL) return -ENOMEM; cs42l52->dev = &i2c_client->dev; cs42l52->regmap = devm_regmap_init_i2c(i2c_client, &cs42l52_regmap); if (IS_ERR(cs42l52->regmap)) { ret = PTR_ERR(cs42l52->regmap); dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); return ret; } if (pdata) { cs42l52->pdata = *pdata; } else { pdata = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_platform_data), GFP_KERNEL); if (!pdata) { dev_err(&i2c_client->dev, "could not allocate pdata\n"); return -ENOMEM; } if (i2c_client->dev.of_node) { if (of_property_read_bool(i2c_client->dev.of_node, "cirrus,mica-differential-cfg")) pdata->mica_diff_cfg = true; if (of_property_read_bool(i2c_client->dev.of_node, "cirrus,micb-differential-cfg")) pdata->micb_diff_cfg = true; if (of_property_read_u32(i2c_client->dev.of_node, "cirrus,micbias-lvl", &val32) >= 0) pdata->micbias_lvl = val32; if (of_property_read_u32(i2c_client->dev.of_node, "cirrus,chgfreq-divisor", &val32) >= 0) pdata->chgfreq = val32; pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, "cirrus,reset-gpio", 0); } cs42l52->pdata = *pdata; } if (cs42l52->pdata.reset_gpio) { ret = devm_gpio_request_one(&i2c_client->dev, cs42l52->pdata.reset_gpio, GPIOF_OUT_INIT_HIGH, "CS42L52 /RST"); if (ret < 0) { dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", cs42l52->pdata.reset_gpio, ret); return ret; } gpio_set_value_cansleep(cs42l52->pdata.reset_gpio, 0); gpio_set_value_cansleep(cs42l52->pdata.reset_gpio, 1); } i2c_set_clientdata(i2c_client, cs42l52); ret = regmap_register_patch(cs42l52->regmap, cs42l52_threshold_patch, ARRAY_SIZE(cs42l52_threshold_patch)); if (ret != 0) dev_warn(cs42l52->dev, "Failed to apply regmap patch: %d\n", ret); ret = regmap_read(cs42l52->regmap, CS42L52_CHIP, ®); devid = reg & CS42L52_CHIP_ID_MASK; if (devid != CS42L52_CHIP_ID) { ret = -ENODEV; dev_err(&i2c_client->dev, "CS42L52 Device ID (%X). Expected %X\n", devid, CS42L52_CHIP_ID); return ret; } dev_info(&i2c_client->dev, "Cirrus Logic CS42L52, Revision: %02X\n", reg & CS42L52_CHIP_REV_MASK); /* Set Platform Data */ if (cs42l52->pdata.mica_diff_cfg) regmap_update_bits(cs42l52->regmap, CS42L52_MICA_CTL, CS42L52_MIC_CTL_TYPE_MASK, cs42l52->pdata.mica_diff_cfg << CS42L52_MIC_CTL_TYPE_SHIFT); if (cs42l52->pdata.micb_diff_cfg) regmap_update_bits(cs42l52->regmap, CS42L52_MICB_CTL, CS42L52_MIC_CTL_TYPE_MASK, cs42l52->pdata.micb_diff_cfg << CS42L52_MIC_CTL_TYPE_SHIFT); if (cs42l52->pdata.chgfreq) regmap_update_bits(cs42l52->regmap, CS42L52_CHARGE_PUMP, CS42L52_CHARGE_PUMP_MASK, cs42l52->pdata.chgfreq << CS42L52_CHARGE_PUMP_SHIFT); if (cs42l52->pdata.micbias_lvl) regmap_update_bits(cs42l52->regmap, CS42L52_IFACE_CTL2, CS42L52_IFACE_CTL2_BIAS_LVL, cs42l52->pdata.micbias_lvl); ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_cs42l52, &cs42l52_dai, 1); if (ret < 0) return ret; return 0; }
static int __devinit dmic_dev_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_dmic, &dmic_dai, 1); }
static int cs35l32_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct cs35l32_private *cs35l32; struct device_node *np = i2c_client->dev.of_node; u32 val32; int ret; unsigned int devid = 0; unsigned int reg; cs35l32 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs35l32_private), GFP_KERNEL); if (!cs35l32) { dev_err(&i2c_client->dev, "could not allocate codec\n"); return -ENOMEM; } i2c_set_clientdata(i2c_client, cs35l32); cs35l32->regmap = devm_regmap_init_i2c(i2c_client, &cs35l32_regmap); if (IS_ERR(cs35l32->regmap)) { ret = PTR_ERR(cs35l32->regmap); dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); return ret; } if (of_property_read_u32(np, "cs35l32,boost-mng", &val32) >= 0) cs35l32->pdata.boost_mng = val32; if (of_property_read_u32(np, "cs35l32,sdout-datacfg", &val32) >= 0) cs35l32->pdata.sdout_datacfg = val32; if (of_property_read_u32(np, "cs35l32,sdout-share", &val32) >= 0) cs35l32->pdata.sdout_share = val32; cs35l32->pdata.gpio_nreset = of_get_named_gpio_flags(np, "cs35l32,gpio-nreset", 0, NULL); ret = gpio_request(cs35l32->pdata.gpio_nreset, "cs35l32 reset"); if (ret < 0) { dev_err(&i2c_client->dev, "failed to request the gpio %d\n", cs35l32->pdata.gpio_nreset); return ret; } /*bring the chip out of reset*/ gpio_direction_output(cs35l32->pdata.gpio_nreset, 0); msleep(20); gpio_set_value_cansleep(cs35l32->pdata.gpio_nreset, 1); msleep(20); ret = regmap_register_patch(cs35l32->regmap, cs35l32_monitor_patch, ARRAY_SIZE(cs35l32_monitor_patch)); if (ret < 0) { dev_err(&i2c_client->dev, "failed to register regmap(try again : 0x40)\n"); i2c_client->addr = 0x40; ret = regmap_register_patch(cs35l32->regmap, cs35l32_monitor_patch, ARRAY_SIZE(cs35l32_monitor_patch)); if (ret < 0) dev_err(&i2c_client->dev, "failed to register regmap retry again\n"); } /* initialize codec */ ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, ®); devid = (reg & 0xFF) << 12; ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_CD, ®); devid |= (reg & 0xFF) << 4; ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_E, ®); devid |= (reg & 0xF0) >> 4; if ((devid != CS35L32_CHIP_ID) && (devid != CS35L32_CHIP_ID_VZW)) { ret = -ENODEV; dev_err(&i2c_client->dev, "CS35L32 Device ID (%X). Expected %X\n", devid, CS35L32_CHIP_ID); return ret; } ret = regmap_read(cs35l32->regmap, CS35L32_REV_ID, ®); if (ret < 0) { dev_err(&i2c_client->dev, "Get Revision ID failed\n"); return ret;; } dev_info(&i2c_client->dev, "Cirrus Logic CS35L32, Revision: %02X\n", reg & 0xFF); regcache_cache_only(cs35l32->regmap, false); ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_cs35l32, cs35l32_dai, ARRAY_SIZE(cs35l32_dai)); if (ret < 0) return ret; return 0; }
static int pcm5102a_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm5102a, &pcm5102a_dai, 1); }
static __devinit int asoc_msm_codec_probe(struct platform_device *pdev) { dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm, msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais)); }
static int max98506_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct max98506_priv *max98506; struct max98506_pdata *pdata; struct max98506_volume_step_info *vstep; int ret; int pinfo_status = 0; msg_maxim("enter, device '%s'", id->name); max98506 = devm_kzalloc(&i2c->dev, sizeof(struct max98506_priv), GFP_KERNEL); if (!max98506) { ret = -ENOMEM; goto err_allocate_priv; } max98506->pdata = devm_kzalloc(&i2c->dev, sizeof(struct max98506_pdata), GFP_KERNEL); if (!max98506->pdata) { ret = -ENOMEM; goto err_allocate_pdata; } i2c_set_clientdata(i2c, max98506); pdata = max98506->pdata; vstep = &max98506->vstep; if (i2c->dev.of_node) { /* Read system clock */ ret = of_property_read_u32(i2c->dev.of_node, "maxim,sysclk", &pdata->sysclk); if (ret) { dev_err(&i2c->dev, "There is no sysclk property."); pdata->sysclk = 12288000; } /* Read speaker volume */ ret = of_property_read_u32(i2c->dev.of_node, "maxim,spk-gain", &pdata->spk_gain); if (ret) { dev_err(&i2c->dev, "There is no spk_gain property."); pdata->spk_gain = 0x14; } /* Read VMON slot info.*/ ret = of_property_read_u32(i2c->dev.of_node, "maxim,vmon_slot", &pdata->vmon_slot); if (ret) { dev_err(&i2c->dev, "There is no vmon_slot property."); pdata->vmon_slot = 0; } /* Regulator status */ pdata->i2c_pull_up = of_property_read_bool( i2c->dev.of_node, "maxim,i2c-pull-up"); if (pdata->i2c_pull_up) max98506_regulator_config(&i2c->dev); #ifdef USE_MAX98506_IRQ pdata->irq = of_get_named_gpio_flags( i2c->dev.of_node, "maxim,irq-gpio", 0, NULL); #endif /* USE_MAX98506_IRQ */ /* Read information related to DSM */ ret = of_property_read_u32_array(i2c->dev.of_node, "maxim,platform_info", (u32 *) &pdata->pinfo, sizeof(pdata->pinfo)/sizeof(uint32_t)); if (ret) dev_err(&i2c->dev, "There is no platform info. property.\n"); else pinfo_status = 1; ret = of_property_read_u32_array(i2c->dev.of_node, "maxim,boost_step", (uint32_t *) &vstep->boost_step, sizeof(vstep->boost_step)/sizeof(uint32_t)); if (ret) { dev_err(&i2c->dev, "There is no boost_step property.\n"); for (ret = 0; ret < MAX98506_VSTEP_14; ret++) vstep->boost_step[ret] = 0x0F; vstep->boost_step[MAX98506_VSTEP_14] = 0x02; vstep->boost_step[MAX98506_VSTEP_15] = 0x00; } ret = of_property_read_u32(i2c->dev.of_node, "maxim,adc_threshold", &vstep->adc_thres); if (ret) { dev_err(&i2c->dev, "There is no adc_threshold property."); vstep->adc_thres = MAX98506_VSTEP_7; } pdata->reg_arr = of_get_property(i2c->dev.of_node, "maxim,registers-of-amp", &pdata->reg_arr_len); if (pdata->reg_arr == NULL) dev_err(&i2c->dev, "There is no registers-diff property."); #ifdef USE_DSM_LOG ret = of_property_read_string(i2c->dev.of_node, "maxim,log_class", &class_name_log); if (ret) { dev_err(&i2c->dev, "There is no log_class property.\n"); class_name_log = DEFAULT_LOG_CLASS_NAME; } #endif /* USE_DSM_LOG */ } else { pdata->sysclk = 12288000; pdata->spk_gain = 0x14; pdata->vmon_slot = 0; } #ifdef USE_MAX98506_IRQ if (pdata != NULL && gpio_is_valid(pdata->irq)) { ret = gpio_request(pdata->irq, "max98506_irq_gpio"); if (ret) { dev_err(&i2c->dev, "unable to request gpio [%d]", pdata->irq); goto err_irq_gpio_req; } ret = gpio_direction_input(pdata->irq); if (ret) { dev_err(&i2c->dev, "unable to set direction for gpio [%d]", pdata->irq); goto err_irq_gpio_req; } i2c->irq = gpio_to_irq(pdata->irq); ret = request_threaded_irq(i2c->irq, NULL, max98506_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "max98506_interrupt", max98506); if (ret) dev_err(&i2c->dev, "Failed to register interrupt"); } else { dev_err(&i2c->dev, "irq gpio not provided\n"); } dev_dbg(&i2c->dev, "requested irq for max98506"); goto go_ahead_next_step; err_irq_gpio_req: if (gpio_is_valid(pdata->irq)) gpio_free(pdata->irq); go_ahead_next_step: #endif /* USE_MAX98506_IRQ */ #ifdef CONFIG_SND_SOC_MAXIM_DSM maxdsm_init(); if (pinfo_status) #ifdef CONFIG_MACH_KACTIVELTE_KOR maxdsm_update_info(pdata->pinfo); #else dev_info(&i2c->dev, "pinfo will be ignored.\n"); #endif /* CONFIG_MACH_KACTIVELTE_KOR */ #endif /* CONFIG_SND_SOC_MAXIM_DSM */ ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98506, max98506_dai, ARRAY_SIZE(max98506_dai)); if (ret) { dev_err(&i2c->dev, "Failed to register codec"); goto err_register_codec; } max98506->regmap = regmap_init_i2c(i2c, &max98506_regmap); if (IS_ERR(max98506->regmap)) { ret = PTR_ERR(max98506->regmap); dev_err(&i2c->dev, "Failed to initialize regmap: %d", ret); goto err_regmap; } msg_maxim("exit, device '%s'", id->name); return 0; err_regmap: snd_soc_unregister_codec(&i2c->dev); if (max98506->regmap) regmap_exit(max98506->regmap); err_register_codec: #ifdef CONFIG_SND_SOC_MAXIM_DSM maxdsm_deinit(); #endif /* CONFIG_SND_SOC_MAXIM_DSM */ devm_kfree(&i2c->dev, max98506->pdata); err_allocate_pdata: devm_kfree(&i2c->dev, max98506); err_allocate_priv: msg_maxim("exit with errors. ret=%d", ret); return ret; }
static __devinit int ad1980_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_ad1980, &ad1980_dai, 1); }
static int gtm601_platform_probe(struct platform_device *pdev) { return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_gtm601, >m601_dai, 1); }
static int __devinit wm2000_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct wm2000_priv *wm2000; struct wm2000_platform_data *pdata; const char *filename; const struct firmware *fw; int reg, ret; u16 id; wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), GFP_KERNEL); if (wm2000 == NULL) { dev_err(&i2c->dev, "Unable to allocate private data\n"); return -ENOMEM; } dev_set_drvdata(&i2c->dev, wm2000); wm2000->regmap = regmap_init_i2c(i2c, &wm2000_regmap); if (IS_ERR(wm2000->regmap)) { ret = PTR_ERR(wm2000->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); goto err; } /* Verify that this is a WM2000 */ reg = wm2000_read(i2c, WM2000_REG_ID1); id = reg << 8; reg = wm2000_read(i2c, WM2000_REG_ID2); id |= reg & 0xff; if (id != 0x2000) { dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id); ret = -ENODEV; goto err_regmap; } reg = wm2000_read(i2c, WM2000_REG_REVISON); dev_info(&i2c->dev, "revision %c\n", reg + 'A'); filename = "wm2000_anc.bin"; pdata = dev_get_platdata(&i2c->dev); if (pdata) { wm2000->mclk_div = pdata->mclkdiv2; wm2000->speech_clarity = !pdata->speech_enh_disable; if (pdata->download_file) filename = pdata->download_file; } ret = request_firmware(&fw, filename, &i2c->dev); if (ret != 0) { dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret); goto err_regmap; } /* Pre-cook the concatenation of the register address onto the image */ wm2000->anc_download_size = fw->size + 2; wm2000->anc_download = devm_kzalloc(&i2c->dev, wm2000->anc_download_size, GFP_KERNEL); if (wm2000->anc_download == NULL) { dev_err(&i2c->dev, "Out of memory\n"); ret = -ENOMEM; goto err_fw; } wm2000->anc_download[0] = 0x80; wm2000->anc_download[1] = 0x00; memcpy(wm2000->anc_download + 2, fw->data, fw->size); release_firmware(fw); wm2000->anc_eng_ena = 1; wm2000->anc_active = 1; wm2000->spk_ena = 1; wm2000->i2c = i2c; wm2000_reset(wm2000); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); if (ret != 0) goto err_fw; return 0; err_fw: release_firmware(fw); err_regmap: regmap_exit(wm2000->regmap); err: return ret; }