Lines Matching +full:gpio +full:- +full:out +full:- +full:pol
1 // SPDX-License-Identifier: GPL-2.0
3 // cs35l36.c -- CS35L36 ALSA SoC audio driver
19 #include <linux/gpio/consumer.h>
27 #include <sound/soc-dapm.h>
28 #include <linux/gpio.h>
448 TLV_DB_MINMAX_ITEM(-10200, 1200));
465 ucontrol->value.integer.value[0] = cs35l36->ldm_mode_sel; in cs35l36_ldm_sel_get()
477 int val = (ucontrol->value.integer.value[0]) ? CS35L36_NG_AMP_EN_MASK : in cs35l36_ldm_sel_put()
480 cs35l36->ldm_mode_sel = val; in cs35l36_ldm_sel_put()
482 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_ldm_sel_put()
494 SOC_SINGLE("Amp Gain Zero-Cross Switch", CS35L36_AMP_GAIN_CTRL,
508 snd_soc_dapm_to_component(w->dapm); in cs35l36_main_amp_event()
515 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL1, in cs35l36_main_amp_event()
521 regmap_read(cs35l36->regmap, CS35L36_INT4_RAW_STATUS, ®); in cs35l36_main_amp_event()
524 dev_crit(cs35l36->dev, "PLL Unlocked\n"); in cs35l36_main_amp_event()
526 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SEL, in cs35l36_main_amp_event()
529 regmap_update_bits(cs35l36->regmap, CS35L36_AMP_OUT_MUTE, in cs35l36_main_amp_event()
534 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SEL, in cs35l36_main_amp_event()
537 regmap_update_bits(cs35l36->regmap, CS35L36_AMP_OUT_MUTE, in cs35l36_main_amp_event()
542 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL1, in cs35l36_main_amp_event()
549 dev_dbg(component->dev, "Invalid event = 0x%x\n", event); in cs35l36_main_amp_event()
550 return -EINVAL; in cs35l36_main_amp_event()
560 snd_soc_dapm_to_component(w->dapm); in cs35l36_boost_event()
566 if (!cs35l36->pdata.extern_boost) in cs35l36_boost_event()
567 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL2, in cs35l36_boost_event()
573 if (!cs35l36->pdata.extern_boost) in cs35l36_boost_event()
574 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL2, in cs35l36_boost_event()
580 dev_dbg(component->dev, "Invalid event = 0x%x\n", event); in cs35l36_boost_event()
581 return -EINVAL; in cs35l36_boost_event()
759 snd_soc_component_get_drvdata(component_dai->component); in cs35l36_set_dai_fmt()
770 return -EINVAL; in cs35l36_set_dai_fmt()
773 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_set_dai_fmt()
776 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RATE_CTRL, in cs35l36_set_dai_fmt()
788 return -EINVAL; in cs35l36_set_dai_fmt()
791 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_set_dai_fmt()
794 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RATE_CTRL, in cs35l36_set_dai_fmt()
806 return -EINVAL; in cs35l36_set_dai_fmt()
827 return -EINVAL; in cs35l36_set_dai_fmt()
830 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RATE_CTRL, in cs35l36_set_dai_fmt()
833 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_set_dai_fmt()
836 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_FORMAT, in cs35l36_set_dai_fmt()
869 snd_soc_component_get_drvdata(dai->component); in cs35l36_pcm_hw_params()
875 regmap_update_bits(cs35l36->regmap, in cs35l36_pcm_hw_params()
893 return -EINVAL; in cs35l36_pcm_hw_params()
896 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l36_pcm_hw_params()
897 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_FRAME_CTRL, in cs35l36_pcm_hw_params()
901 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_FRAME_CTRL, in cs35l36_pcm_hw_params()
912 struct snd_soc_component *component = dai->component; in cs35l36_dai_set_sysclk()
925 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
927 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
930 regmap_update_bits(cs35l36->regmap, CS35L36_TST_FS_MON0, in cs35l36_dai_set_sysclk()
934 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
936 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
967 snd_pcm_hw_constraint_list(substream->runtime, 0, in cs35l36_pcm_startup()
982 .name = "cs35l36-pcm",
1013 prev_clksrc = cs35l36->clksrc; in cs35l36_component_set_sysclk()
1017 cs35l36->clksrc = CS35L36_PLLSRC_SCLK; in cs35l36_component_set_sysclk()
1020 cs35l36->clksrc = CS35L36_PLLSRC_LRCLK; in cs35l36_component_set_sysclk()
1023 cs35l36->clksrc = CS35L36_PLLSRC_PDMCLK; in cs35l36_component_set_sysclk()
1026 cs35l36->clksrc = CS35L36_PLLSRC_SELF; in cs35l36_component_set_sysclk()
1029 cs35l36->clksrc = CS35L36_PLLSRC_MCLK; in cs35l36_component_set_sysclk()
1032 return -EINVAL; in cs35l36_component_set_sysclk()
1037 dev_err(component->dev, "Invalid CLK Config Freq: %d\n", freq); in cs35l36_component_set_sysclk()
1038 return -EINVAL; in cs35l36_component_set_sysclk()
1041 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1044 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1046 clk_cfg->clk_cfg << CS35L36_REFCLK_FREQ_SHIFT); in cs35l36_component_set_sysclk()
1047 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1050 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1052 cs35l36->clksrc); in cs35l36_component_set_sysclk()
1053 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1056 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1060 if (cs35l36->rev_id == CS35L36_REV_A0) { in cs35l36_component_set_sysclk()
1061 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1063 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1066 regmap_write(cs35l36->regmap, CS35L36_DCO_CTRL, 0x00036DA8); in cs35l36_component_set_sysclk()
1067 regmap_write(cs35l36->regmap, CS35L36_MISC_CTRL, 0x0100EE0E); in cs35l36_component_set_sysclk()
1069 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_LOOP_PARAMS, in cs35l36_component_set_sysclk()
1073 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_LOOP_PARAMS, in cs35l36_component_set_sysclk()
1075 clk_cfg->fll_igain); in cs35l36_component_set_sysclk()
1077 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1079 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1083 if (cs35l36->clksrc == CS35L36_PLLSRC_PDMCLK) { in cs35l36_component_set_sysclk()
1084 pdm_switch = cs35l36->ldm_mode_sel && in cs35l36_component_set_sysclk()
1088 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1092 regmap_update_bits(cs35l36->regmap, CS35L36_DAC_MSM_CFG, in cs35l36_component_set_sysclk()
1097 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1101 pdm_switch = cs35l36->ldm_mode_sel && in cs35l36_component_set_sysclk()
1105 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1109 regmap_update_bits(cs35l36->regmap, CS35L36_DAC_MSM_CFG, in cs35l36_component_set_sysclk()
1114 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1124 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_COEFF, in cs35l36_boost_inductor()
1126 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_COEFF, in cs35l36_boost_inductor()
1129 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SW_FREQ, in cs35l36_boost_inductor()
1134 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1137 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1141 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1144 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1148 dev_err(cs35l36->dev, "%s Invalid Inductor Value %d uH\n", in cs35l36_boost_inductor()
1150 return -EINVAL; in cs35l36_boost_inductor()
1162 if ((cs35l36->rev_id == CS35L36_REV_A0) && cs35l36->pdata.dcm_mode) { in cs35l36_component_probe()
1163 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_DCM_CTRL, in cs35l36_component_probe()
1167 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1169 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1172 regmap_update_bits(cs35l36->regmap, CS35L36_BST_TST_MANUAL, in cs35l36_component_probe()
1175 regmap_update_bits(cs35l36->regmap, CS35L36_BST_TST_MANUAL, in cs35l36_component_probe()
1179 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1181 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1185 if (cs35l36->pdata.amp_pcm_inv) in cs35l36_component_probe()
1186 regmap_update_bits(cs35l36->regmap, CS35L36_AMP_DIG_VOL_CTRL, in cs35l36_component_probe()
1190 if (cs35l36->pdata.multi_amp_mode) in cs35l36_component_probe()
1191 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_component_probe()
1195 if (cs35l36->pdata.imon_pol_inv) in cs35l36_component_probe()
1196 regmap_update_bits(cs35l36->regmap, CS35L36_VI_SPKMON_FILT, in cs35l36_component_probe()
1199 if (cs35l36->pdata.vmon_pol_inv) in cs35l36_component_probe()
1200 regmap_update_bits(cs35l36->regmap, CS35L36_VI_SPKMON_FILT, in cs35l36_component_probe()
1203 if (cs35l36->pdata.bst_vctl) in cs35l36_component_probe()
1204 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL1, in cs35l36_component_probe()
1206 cs35l36->pdata.bst_vctl); in cs35l36_component_probe()
1208 if (cs35l36->pdata.bst_vctl_sel) in cs35l36_component_probe()
1209 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL2, in cs35l36_component_probe()
1211 cs35l36->pdata.bst_vctl_sel); in cs35l36_component_probe()
1213 if (cs35l36->pdata.bst_ipk) in cs35l36_component_probe()
1214 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_PEAK_CUR, in cs35l36_component_probe()
1216 cs35l36->pdata.bst_ipk); in cs35l36_component_probe()
1218 if (cs35l36->pdata.boost_ind) { in cs35l36_component_probe()
1219 ret = cs35l36_boost_inductor(cs35l36, cs35l36->pdata.boost_ind); in cs35l36_component_probe()
1221 dev_err(cs35l36->dev, in cs35l36_component_probe()
1227 if (cs35l36->pdata.temp_warn_thld) in cs35l36_component_probe()
1228 regmap_update_bits(cs35l36->regmap, CS35L36_DTEMP_WARN_THLD, in cs35l36_component_probe()
1230 cs35l36->pdata.temp_warn_thld); in cs35l36_component_probe()
1232 if (cs35l36->pdata.irq_drv_sel) in cs35l36_component_probe()
1233 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_component_probe()
1235 cs35l36->pdata.irq_drv_sel << in cs35l36_component_probe()
1238 if (cs35l36->pdata.irq_gpio_sel) in cs35l36_component_probe()
1239 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_component_probe()
1241 cs35l36->pdata.irq_gpio_sel << in cs35l36_component_probe()
1252 if (cs35l36->chip_version == CS35L36_10V_L36) { in cs35l36_component_probe()
1253 regmap_update_bits(cs35l36->regmap, in cs35l36_component_probe()
1258 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1260 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1263 regmap_update_bits(cs35l36->regmap, CS35L36_BST_ANA2_TEST, in cs35l36_component_probe()
1267 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL2, in cs35l36_component_probe()
1270 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL1, in cs35l36_component_probe()
1273 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1275 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1284 regmap_update_bits(cs35l36->regmap, CS35L36_CTRL_OVRRIDE, in cs35l36_component_probe()
1326 regmap_bulk_read(cs35l36->regmap, CS35L36_INT1_STATUS, status, in cs35l36_irq()
1329 regmap_bulk_read(cs35l36->regmap, CS35L36_INT1_MASK, masks, in cs35l36_irq()
1341 * speaker out of Safe-Mode. in cs35l36_irq()
1344 dev_crit(cs35l36->dev, "Amp short error\n"); in cs35l36_irq()
1345 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1347 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1350 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1352 regmap_update_bits(cs35l36->regmap, CS35L36_INT3_STATUS, in cs35l36_irq()
1359 dev_crit(cs35l36->dev, "Over temperature warning\n"); in cs35l36_irq()
1360 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1362 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1365 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1367 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1373 dev_crit(cs35l36->dev, "Over temperature error\n"); in cs35l36_irq()
1374 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1376 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1378 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1380 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1386 dev_crit(cs35l36->dev, "VBST Over Voltage error\n"); in cs35l36_irq()
1387 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1389 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1391 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1393 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1399 dev_crit(cs35l36->dev, "DCM VBST Under Voltage Error\n"); in cs35l36_irq()
1400 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1402 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1405 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1407 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1414 dev_crit(cs35l36->dev, "LBST SHORT error!\n"); in cs35l36_irq()
1415 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1417 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1420 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1422 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1434 struct device_node *np = i2c_client->dev.of_node; in cs35l36_handle_of_data()
1435 struct cs35l36_vpbr_cfg *vpbr_config = &pdata->vpbr_config; in cs35l36_handle_of_data()
1443 ret = of_property_read_u32(np, "cirrus,boost-ctl-millivolt", &val); in cs35l36_handle_of_data()
1446 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1448 return -EINVAL; in cs35l36_handle_of_data()
1450 pdata->bst_vctl = (((val - 2550) / 100) + 1) << 1; in cs35l36_handle_of_data()
1452 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1453 "Unable to find required parameter 'cirrus,boost-ctl-millivolt'"); in cs35l36_handle_of_data()
1454 return -EINVAL; in cs35l36_handle_of_data()
1457 ret = of_property_read_u32(np, "cirrus,boost-ctl-select", &val); in cs35l36_handle_of_data()
1459 pdata->bst_vctl_sel = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1461 ret = of_property_read_u32(np, "cirrus,boost-peak-milliamp", &val); in cs35l36_handle_of_data()
1464 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1466 return -EINVAL; in cs35l36_handle_of_data()
1469 pdata->bst_ipk = (val - 1600) / 50; in cs35l36_handle_of_data()
1471 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1472 "Unable to find required parameter 'cirrus,boost-peak-milliamp'"); in cs35l36_handle_of_data()
1473 return -EINVAL; in cs35l36_handle_of_data()
1476 pdata->multi_amp_mode = of_property_read_bool(np, in cs35l36_handle_of_data()
1477 "cirrus,multi-amp-mode"); in cs35l36_handle_of_data()
1479 pdata->dcm_mode = of_property_read_bool(np, in cs35l36_handle_of_data()
1480 "cirrus,dcm-mode-enable"); in cs35l36_handle_of_data()
1482 pdata->amp_pcm_inv = of_property_read_bool(np, in cs35l36_handle_of_data()
1483 "cirrus,amp-pcm-inv"); in cs35l36_handle_of_data()
1485 pdata->imon_pol_inv = of_property_read_bool(np, in cs35l36_handle_of_data()
1486 "cirrus,imon-pol-inv"); in cs35l36_handle_of_data()
1488 pdata->vmon_pol_inv = of_property_read_bool(np, in cs35l36_handle_of_data()
1489 "cirrus,vmon-pol-inv"); in cs35l36_handle_of_data()
1491 if (of_property_read_u32(np, "cirrus,temp-warn-threshold", &val) >= 0) in cs35l36_handle_of_data()
1492 pdata->temp_warn_thld = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1494 if (of_property_read_u32(np, "cirrus,boost-ind-nanohenry", &val) >= 0) { in cs35l36_handle_of_data()
1495 pdata->boost_ind = val; in cs35l36_handle_of_data()
1497 dev_err(&i2c_client->dev, "Inductor not specified.\n"); in cs35l36_handle_of_data()
1498 return -EINVAL; in cs35l36_handle_of_data()
1501 if (of_property_read_u32(np, "cirrus,irq-drive-select", &val) >= 0) in cs35l36_handle_of_data()
1502 pdata->irq_drv_sel = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1504 if (of_property_read_u32(np, "cirrus,irq-gpio-select", &val) >= 0) in cs35l36_handle_of_data()
1505 pdata->irq_gpio_sel = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1508 vpbr_node = of_get_child_by_name(np, "cirrus,vpbr-config"); in cs35l36_handle_of_data()
1509 vpbr_config->is_present = vpbr_node ? true : false; in cs35l36_handle_of_data()
1510 if (vpbr_config->is_present) { in cs35l36_handle_of_data()
1511 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-en", in cs35l36_handle_of_data()
1513 vpbr_config->vpbr_en = val; in cs35l36_handle_of_data()
1514 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-thld", in cs35l36_handle_of_data()
1516 vpbr_config->vpbr_thld = val; in cs35l36_handle_of_data()
1517 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-atk-rate", in cs35l36_handle_of_data()
1519 vpbr_config->vpbr_atk_rate = val; in cs35l36_handle_of_data()
1520 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-atk-vol", in cs35l36_handle_of_data()
1522 vpbr_config->vpbr_atk_vol = val; in cs35l36_handle_of_data()
1523 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-max-attn", in cs35l36_handle_of_data()
1525 vpbr_config->vpbr_max_attn = val; in cs35l36_handle_of_data()
1526 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-wait", in cs35l36_handle_of_data()
1528 vpbr_config->vpbr_wait = val; in cs35l36_handle_of_data()
1529 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-rel-rate", in cs35l36_handle_of_data()
1531 vpbr_config->vpbr_rel_rate = val; in cs35l36_handle_of_data()
1532 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-mute-en", in cs35l36_handle_of_data()
1534 vpbr_config->vpbr_mute_en = val; in cs35l36_handle_of_data()
1546 if (cs35l36->rev_id != CS35L36_REV_B0) in cs35l36_pac()
1552 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1554 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1559 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL1, in cs35l36_pac()
1561 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL3, in cs35l36_pac()
1563 regmap_write(cs35l36->regmap, CS35L36_PAC_PMEM_WORD0, in cs35l36_pac()
1566 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL3, in cs35l36_pac()
1568 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL1, in cs35l36_pac()
1573 ret = regmap_read(cs35l36->regmap, CS35L36_INT4_STATUS, &val); in cs35l36_pac()
1575 dev_err(cs35l36->dev, "Failed to read int4_status %d\n", ret); in cs35l36_pac()
1584 ret = regmap_read(cs35l36->regmap, CS35L36_INT4_STATUS, in cs35l36_pac()
1587 dev_err(cs35l36->dev, "Failed to read int4_status %d\n", in cs35l36_pac()
1593 return -EINVAL; in cs35l36_pac()
1596 regmap_write(cs35l36->regmap, CS35L36_INT4_STATUS, in cs35l36_pac()
1598 regmap_update_bits(cs35l36->regmap, CS35L36_PAC_CTL1, in cs35l36_pac()
1601 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1603 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1611 struct cs35l36_platform_data *pdata = &cs35l36->pdata; in cs35l36_apply_vpbr_config()
1612 struct cs35l36_vpbr_cfg *vpbr_config = &pdata->vpbr_config; in cs35l36_apply_vpbr_config()
1614 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL3, in cs35l36_apply_vpbr_config()
1616 vpbr_config->vpbr_en << in cs35l36_apply_vpbr_config()
1618 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1620 vpbr_config->vpbr_thld << in cs35l36_apply_vpbr_config()
1622 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1624 vpbr_config->vpbr_max_attn << in cs35l36_apply_vpbr_config()
1626 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1628 vpbr_config->vpbr_atk_vol << in cs35l36_apply_vpbr_config()
1630 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1632 vpbr_config->vpbr_atk_rate << in cs35l36_apply_vpbr_config()
1634 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1636 vpbr_config->vpbr_wait << in cs35l36_apply_vpbr_config()
1638 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1640 vpbr_config->vpbr_rel_rate << in cs35l36_apply_vpbr_config()
1642 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1644 vpbr_config->vpbr_mute_en << in cs35l36_apply_vpbr_config()
1706 struct device *dev = &i2c_client->dev; in cs35l36_i2c_probe()
1714 return -ENOMEM; in cs35l36_i2c_probe()
1716 cs35l36->dev = dev; in cs35l36_i2c_probe()
1719 cs35l36->regmap = devm_regmap_init_i2c(i2c_client, &cs35l36_regmap); in cs35l36_i2c_probe()
1720 if (IS_ERR(cs35l36->regmap)) { in cs35l36_i2c_probe()
1721 ret = PTR_ERR(cs35l36->regmap); in cs35l36_i2c_probe()
1726 cs35l36->num_supplies = ARRAY_SIZE(cs35l36_supplies); in cs35l36_i2c_probe()
1728 cs35l36->supplies[i].supply = cs35l36_supplies[i]; in cs35l36_i2c_probe()
1730 ret = devm_regulator_bulk_get(dev, cs35l36->num_supplies, in cs35l36_i2c_probe()
1731 cs35l36->supplies); in cs35l36_i2c_probe()
1738 cs35l36->pdata = *pdata; in cs35l36_i2c_probe()
1743 return -ENOMEM; in cs35l36_i2c_probe()
1745 if (i2c_client->dev.of_node) { in cs35l36_i2c_probe()
1752 cs35l36->pdata = *pdata; in cs35l36_i2c_probe()
1755 ret = regulator_bulk_enable(cs35l36->num_supplies, cs35l36->supplies); in cs35l36_i2c_probe()
1762 cs35l36->reset_gpio = devm_gpiod_get_optional(dev, "reset", in cs35l36_i2c_probe()
1764 if (IS_ERR(cs35l36->reset_gpio)) { in cs35l36_i2c_probe()
1765 ret = PTR_ERR(cs35l36->reset_gpio); in cs35l36_i2c_probe()
1766 cs35l36->reset_gpio = NULL; in cs35l36_i2c_probe()
1767 if (ret == -EBUSY) { in cs35l36_i2c_probe()
1770 dev_err(dev, "Failed to get reset GPIO: %d\n", ret); in cs35l36_i2c_probe()
1775 if (cs35l36->reset_gpio) in cs35l36_i2c_probe()
1776 gpiod_set_value_cansleep(cs35l36->reset_gpio, 1); in cs35l36_i2c_probe()
1781 ret = regmap_read(cs35l36->regmap, CS35L36_SW_RESET, ®_id); in cs35l36_i2c_probe()
1790 ret = -ENODEV; in cs35l36_i2c_probe()
1794 ret = regmap_read(cs35l36->regmap, CS35L36_REV_ID, ®_revid); in cs35l36_i2c_probe()
1796 dev_err(&i2c_client->dev, "Get Revision ID failed %d\n", ret); in cs35l36_i2c_probe()
1800 cs35l36->rev_id = reg_revid >> 8; in cs35l36_i2c_probe()
1802 ret = regmap_read(cs35l36->regmap, CS35L36_OTP_MEM30, &l37_id_reg); in cs35l36_i2c_probe()
1804 dev_err(&i2c_client->dev, "Failed to read otp_id Register %d\n", in cs35l36_i2c_probe()
1810 cs35l36->chip_version = CS35L36_12V_L37; in cs35l36_i2c_probe()
1812 cs35l36->chip_version = CS35L36_10V_L36; in cs35l36_i2c_probe()
1814 switch (cs35l36->rev_id) { in cs35l36_i2c_probe()
1816 ret = regmap_register_patch(cs35l36->regmap, in cs35l36_i2c_probe()
1832 ret = regmap_register_patch(cs35l36->regmap, in cs35l36_i2c_probe()
1843 if (pdata->vpbr_config.is_present) in cs35l36_i2c_probe()
1846 irq_d = irq_get_irq_data(i2c_client->irq); in cs35l36_i2c_probe()
1848 dev_err(&i2c_client->dev, "Invalid IRQ: %d\n", i2c_client->irq); in cs35l36_i2c_probe()
1849 ret = -ENODEV; in cs35l36_i2c_probe()
1865 dev_err(cs35l36->dev, "Invalid IRQ polarity: %d\n", irq_pol); in cs35l36_i2c_probe()
1866 ret = -EINVAL; in cs35l36_i2c_probe()
1870 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_i2c_probe()
1874 ret = devm_request_threaded_irq(dev, i2c_client->irq, NULL, cs35l36_irq, in cs35l36_i2c_probe()
1882 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_i2c_probe()
1886 regmap_write(cs35l36->regmap, CS35L36_INT1_MASK, in cs35l36_i2c_probe()
1888 regmap_write(cs35l36->regmap, CS35L36_INT3_MASK, in cs35l36_i2c_probe()
1891 dev_info(&i2c_client->dev, "Cirrus Logic CS35L%d, Revision: %02X\n", in cs35l36_i2c_probe()
1892 cs35l36->chip_version, reg_revid >> 8); in cs35l36_i2c_probe()
1906 gpiod_set_value_cansleep(cs35l36->reset_gpio, 0); in cs35l36_i2c_probe()
1909 regulator_bulk_disable(cs35l36->num_supplies, cs35l36->supplies); in cs35l36_i2c_probe()
1918 regmap_write(cs35l36->regmap, CS35L36_INT1_MASK, in cs35l36_i2c_remove()
1920 regmap_write(cs35l36->regmap, CS35L36_INT3_MASK, in cs35l36_i2c_remove()
1923 if (cs35l36->reset_gpio) in cs35l36_i2c_remove()
1924 gpiod_set_value_cansleep(cs35l36->reset_gpio, 0); in cs35l36_i2c_remove()
1926 regulator_bulk_disable(cs35l36->num_supplies, cs35l36->supplies); in cs35l36_i2c_remove()