Lines Matching +full:mux +full:- +full:reg +full:- +full:masks

1 // SPDX-License-Identifier: GPL-2.0
3 // cs35l36.c -- CS35L36 ALSA SoC audio driver
27 #include <sound/soc-dapm.h>
245 static bool cs35l36_readable_reg(struct device *dev, unsigned int reg) in cs35l36_readable_reg() argument
247 switch (reg) { in cs35l36_readable_reg()
387 if (reg >= CS35L36_PAC_PMEM_WORD0 && in cs35l36_readable_reg()
388 reg <= CS35L36_PAC_PMEM_WORD1023) in cs35l36_readable_reg()
395 static bool cs35l36_precious_reg(struct device *dev, unsigned int reg) in cs35l36_precious_reg() argument
397 switch (reg) { in cs35l36_precious_reg()
407 static bool cs35l36_volatile_reg(struct device *dev, unsigned int reg) in cs35l36_volatile_reg() argument
409 switch (reg) { in cs35l36_volatile_reg()
437 if (reg >= CS35L36_PAC_PMEM_WORD0 && in cs35l36_volatile_reg()
438 reg <= CS35L36_PAC_PMEM_WORD1023) in cs35l36_volatile_reg()
446 TLV_DB_MINMAX_ITEM(-10200, 1200));
463 ucontrol->value.integer.value[0] = cs35l36->ldm_mode_sel; in cs35l36_ldm_sel_get()
475 int val = (ucontrol->value.integer.value[0]) ? CS35L36_NG_AMP_EN_MASK : in cs35l36_ldm_sel_put()
478 cs35l36->ldm_mode_sel = val; in cs35l36_ldm_sel_put()
480 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_ldm_sel_put()
492 SOC_SINGLE("Amp Gain Zero-Cross Switch", CS35L36_AMP_GAIN_CTRL,
506 snd_soc_dapm_to_component(w->dapm); in cs35l36_main_amp_event()
509 u32 reg; in cs35l36_main_amp_event() local
513 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL1, in cs35l36_main_amp_event()
519 regmap_read(cs35l36->regmap, CS35L36_INT4_RAW_STATUS, &reg); in cs35l36_main_amp_event()
521 if (WARN_ON_ONCE(reg & CS35L36_PLL_UNLOCK_MASK)) in cs35l36_main_amp_event()
522 dev_crit(cs35l36->dev, "PLL Unlocked\n"); in cs35l36_main_amp_event()
524 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SEL, in cs35l36_main_amp_event()
527 regmap_update_bits(cs35l36->regmap, CS35L36_AMP_OUT_MUTE, in cs35l36_main_amp_event()
532 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RX1_SEL, in cs35l36_main_amp_event()
535 regmap_update_bits(cs35l36->regmap, CS35L36_AMP_OUT_MUTE, in cs35l36_main_amp_event()
540 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL1, in cs35l36_main_amp_event()
547 dev_dbg(component->dev, "Invalid event = 0x%x\n", event); in cs35l36_main_amp_event()
548 return -EINVAL; in cs35l36_main_amp_event()
558 snd_soc_dapm_to_component(w->dapm); in cs35l36_boost_event()
564 if (!cs35l36->pdata.extern_boost) in cs35l36_boost_event()
565 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL2, in cs35l36_boost_event()
571 if (!cs35l36->pdata.extern_boost) in cs35l36_boost_event()
572 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL2, in cs35l36_boost_event()
578 dev_dbg(component->dev, "Invalid event = 0x%x\n", event); in cs35l36_boost_event()
579 return -EINVAL; in cs35l36_boost_event()
594 SOC_DAPM_ENUM("Input Mux", chansel_enum);
654 SND_SOC_DAPM_MUX("Channel Mux", SND_SOC_NOPM, 0, 0, &cs35l36_chan_mux),
744 {"Channel Mux", "RX1", "SDIN"},
745 {"Channel Mux", "RX2", "SDIN"},
746 {"BOOST Enable", "Switch", "Channel Mux"},
748 {"Main AMP", NULL, "Channel Mux"},
757 snd_soc_component_get_drvdata(component_dai->component); in cs35l36_set_dai_fmt()
768 return -EINVAL; in cs35l36_set_dai_fmt()
771 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_set_dai_fmt()
774 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RATE_CTRL, in cs35l36_set_dai_fmt()
786 return -EINVAL; in cs35l36_set_dai_fmt()
789 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_set_dai_fmt()
792 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RATE_CTRL, in cs35l36_set_dai_fmt()
804 return -EINVAL; in cs35l36_set_dai_fmt()
825 return -EINVAL; in cs35l36_set_dai_fmt()
828 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_RATE_CTRL, in cs35l36_set_dai_fmt()
831 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_set_dai_fmt()
834 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_FORMAT, in cs35l36_set_dai_fmt()
867 snd_soc_component_get_drvdata(dai->component); in cs35l36_pcm_hw_params()
873 regmap_update_bits(cs35l36->regmap, in cs35l36_pcm_hw_params()
891 return -EINVAL; in cs35l36_pcm_hw_params()
894 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l36_pcm_hw_params()
895 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_FRAME_CTRL, in cs35l36_pcm_hw_params()
899 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_FRAME_CTRL, in cs35l36_pcm_hw_params()
910 struct snd_soc_component *component = dai->component; in cs35l36_dai_set_sysclk()
923 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
925 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
928 regmap_update_bits(cs35l36->regmap, CS35L36_TST_FS_MON0, in cs35l36_dai_set_sysclk()
932 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
934 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_dai_set_sysclk()
970 .name = "cs35l36-pcm",
1001 prev_clksrc = cs35l36->clksrc; in cs35l36_component_set_sysclk()
1005 cs35l36->clksrc = CS35L36_PLLSRC_SCLK; in cs35l36_component_set_sysclk()
1008 cs35l36->clksrc = CS35L36_PLLSRC_LRCLK; in cs35l36_component_set_sysclk()
1011 cs35l36->clksrc = CS35L36_PLLSRC_PDMCLK; in cs35l36_component_set_sysclk()
1014 cs35l36->clksrc = CS35L36_PLLSRC_SELF; in cs35l36_component_set_sysclk()
1017 cs35l36->clksrc = CS35L36_PLLSRC_MCLK; in cs35l36_component_set_sysclk()
1020 return -EINVAL; in cs35l36_component_set_sysclk()
1025 dev_err(component->dev, "Invalid CLK Config Freq: %d\n", freq); in cs35l36_component_set_sysclk()
1026 return -EINVAL; in cs35l36_component_set_sysclk()
1029 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1032 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1034 clk_cfg->clk_cfg << CS35L36_REFCLK_FREQ_SHIFT); in cs35l36_component_set_sysclk()
1035 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1038 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_CLK_CTRL, in cs35l36_component_set_sysclk()
1040 cs35l36->clksrc); 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()
1048 if (cs35l36->rev_id == CS35L36_REV_A0) { in cs35l36_component_set_sysclk()
1049 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1051 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1054 regmap_write(cs35l36->regmap, CS35L36_DCO_CTRL, 0x00036DA8); in cs35l36_component_set_sysclk()
1055 regmap_write(cs35l36->regmap, CS35L36_MISC_CTRL, 0x0100EE0E); in cs35l36_component_set_sysclk()
1057 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_LOOP_PARAMS, in cs35l36_component_set_sysclk()
1061 regmap_update_bits(cs35l36->regmap, CS35L36_PLL_LOOP_PARAMS, in cs35l36_component_set_sysclk()
1063 clk_cfg->fll_igain); in cs35l36_component_set_sysclk()
1065 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1067 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_set_sysclk()
1071 if (cs35l36->clksrc == CS35L36_PLLSRC_PDMCLK) { in cs35l36_component_set_sysclk()
1072 pdm_switch = cs35l36->ldm_mode_sel && in cs35l36_component_set_sysclk()
1076 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1080 regmap_update_bits(cs35l36->regmap, CS35L36_DAC_MSM_CFG, in cs35l36_component_set_sysclk()
1085 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1089 pdm_switch = cs35l36->ldm_mode_sel && in cs35l36_component_set_sysclk()
1093 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1097 regmap_update_bits(cs35l36->regmap, CS35L36_DAC_MSM_CFG, in cs35l36_component_set_sysclk()
1102 regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG, in cs35l36_component_set_sysclk()
1112 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_COEFF, in cs35l36_boost_inductor()
1114 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_COEFF, in cs35l36_boost_inductor()
1117 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SW_FREQ, in cs35l36_boost_inductor()
1122 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1125 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1129 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1132 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_SLOPE_LBST, in cs35l36_boost_inductor()
1136 dev_err(cs35l36->dev, "%s Invalid Inductor Value %d uH\n", in cs35l36_boost_inductor()
1138 return -EINVAL; in cs35l36_boost_inductor()
1150 if ((cs35l36->rev_id == CS35L36_REV_A0) && cs35l36->pdata.dcm_mode) { in cs35l36_component_probe()
1151 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_DCM_CTRL, in cs35l36_component_probe()
1155 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1157 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1160 regmap_update_bits(cs35l36->regmap, CS35L36_BST_TST_MANUAL, in cs35l36_component_probe()
1163 regmap_update_bits(cs35l36->regmap, CS35L36_BST_TST_MANUAL, 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()
1173 if (cs35l36->pdata.amp_pcm_inv) in cs35l36_component_probe()
1174 regmap_update_bits(cs35l36->regmap, CS35L36_AMP_DIG_VOL_CTRL, in cs35l36_component_probe()
1178 if (cs35l36->pdata.multi_amp_mode) in cs35l36_component_probe()
1179 regmap_update_bits(cs35l36->regmap, CS35L36_ASP_TX_PIN_CTRL, in cs35l36_component_probe()
1183 if (cs35l36->pdata.imon_pol_inv) in cs35l36_component_probe()
1184 regmap_update_bits(cs35l36->regmap, CS35L36_VI_SPKMON_FILT, in cs35l36_component_probe()
1187 if (cs35l36->pdata.vmon_pol_inv) in cs35l36_component_probe()
1188 regmap_update_bits(cs35l36->regmap, CS35L36_VI_SPKMON_FILT, in cs35l36_component_probe()
1191 if (cs35l36->pdata.bst_vctl) in cs35l36_component_probe()
1192 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL1, in cs35l36_component_probe()
1194 cs35l36->pdata.bst_vctl); in cs35l36_component_probe()
1196 if (cs35l36->pdata.bst_vctl_sel) in cs35l36_component_probe()
1197 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL2, in cs35l36_component_probe()
1199 cs35l36->pdata.bst_vctl_sel); in cs35l36_component_probe()
1201 if (cs35l36->pdata.bst_ipk) in cs35l36_component_probe()
1202 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_PEAK_CUR, in cs35l36_component_probe()
1204 cs35l36->pdata.bst_ipk); in cs35l36_component_probe()
1206 if (cs35l36->pdata.boost_ind) { in cs35l36_component_probe()
1207 ret = cs35l36_boost_inductor(cs35l36, cs35l36->pdata.boost_ind); in cs35l36_component_probe()
1209 dev_err(cs35l36->dev, in cs35l36_component_probe()
1215 if (cs35l36->pdata.temp_warn_thld) in cs35l36_component_probe()
1216 regmap_update_bits(cs35l36->regmap, CS35L36_DTEMP_WARN_THLD, in cs35l36_component_probe()
1218 cs35l36->pdata.temp_warn_thld); in cs35l36_component_probe()
1220 if (cs35l36->pdata.irq_drv_sel) in cs35l36_component_probe()
1221 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_component_probe()
1223 cs35l36->pdata.irq_drv_sel << in cs35l36_component_probe()
1226 if (cs35l36->pdata.irq_gpio_sel) in cs35l36_component_probe()
1227 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_component_probe()
1229 cs35l36->pdata.irq_gpio_sel << in cs35l36_component_probe()
1240 if (cs35l36->chip_version == CS35L36_10V_L36) { in cs35l36_component_probe()
1241 regmap_update_bits(cs35l36->regmap, in cs35l36_component_probe()
1246 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1248 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1251 regmap_update_bits(cs35l36->regmap, CS35L36_BST_ANA2_TEST, in cs35l36_component_probe()
1255 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL2, in cs35l36_component_probe()
1258 regmap_update_bits(cs35l36->regmap, CS35L36_BSTCVRT_VCTRL1, in cs35l36_component_probe()
1261 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1263 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_component_probe()
1272 regmap_update_bits(cs35l36->regmap, CS35L36_CTRL_OVRRIDE, in cs35l36_component_probe()
1310 unsigned int masks[4]; in cs35l36_irq() local
1314 regmap_bulk_read(cs35l36->regmap, CS35L36_INT1_STATUS, status, in cs35l36_irq()
1317 regmap_bulk_read(cs35l36->regmap, CS35L36_INT1_MASK, masks, in cs35l36_irq()
1318 ARRAY_SIZE(masks)); in cs35l36_irq()
1321 if (!(status[0] & ~masks[0]) && !(status[1] & ~masks[1]) && in cs35l36_irq()
1322 !(status[2] & ~masks[2]) && !(status[3] & ~masks[3])) { in cs35l36_irq()
1329 * speaker out of Safe-Mode. in cs35l36_irq()
1332 dev_crit(cs35l36->dev, "Amp short error\n"); in cs35l36_irq()
1333 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1335 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1338 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1340 regmap_update_bits(cs35l36->regmap, CS35L36_INT3_STATUS, in cs35l36_irq()
1347 dev_crit(cs35l36->dev, "Over temperature warning\n"); in cs35l36_irq()
1348 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()
1353 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1355 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1361 dev_crit(cs35l36->dev, "Over temperature error\n"); in cs35l36_irq()
1362 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1364 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1366 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1368 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1374 dev_crit(cs35l36->dev, "VBST Over Voltage error\n"); in cs35l36_irq()
1375 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1377 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1379 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1381 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1387 dev_crit(cs35l36->dev, "DCM VBST Under Voltage Error\n"); in cs35l36_irq()
1388 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1390 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1393 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1395 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1402 dev_crit(cs35l36->dev, "LBST SHORT error!\n"); in cs35l36_irq()
1403 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()
1408 regmap_update_bits(cs35l36->regmap, CS35L36_PROTECT_REL_ERR, in cs35l36_irq()
1410 regmap_update_bits(cs35l36->regmap, CS35L36_INT1_STATUS, in cs35l36_irq()
1422 struct device_node *np = i2c_client->dev.of_node; in cs35l36_handle_of_data()
1423 struct cs35l36_vpbr_cfg *vpbr_config = &pdata->vpbr_config; in cs35l36_handle_of_data()
1431 ret = of_property_read_u32(np, "cirrus,boost-ctl-millivolt", &val); in cs35l36_handle_of_data()
1434 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1436 return -EINVAL; in cs35l36_handle_of_data()
1438 pdata->bst_vctl = (((val - 2550) / 100) + 1) << 1; in cs35l36_handle_of_data()
1440 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1441 "Unable to find required parameter 'cirrus,boost-ctl-millivolt'"); in cs35l36_handle_of_data()
1442 return -EINVAL; in cs35l36_handle_of_data()
1445 ret = of_property_read_u32(np, "cirrus,boost-ctl-select", &val); in cs35l36_handle_of_data()
1447 pdata->bst_vctl_sel = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1449 ret = of_property_read_u32(np, "cirrus,boost-peak-milliamp", &val); in cs35l36_handle_of_data()
1452 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1454 return -EINVAL; in cs35l36_handle_of_data()
1457 pdata->bst_ipk = (val - 1600) / 50; in cs35l36_handle_of_data()
1459 dev_err(&i2c_client->dev, in cs35l36_handle_of_data()
1460 "Unable to find required parameter 'cirrus,boost-peak-milliamp'"); in cs35l36_handle_of_data()
1461 return -EINVAL; in cs35l36_handle_of_data()
1464 pdata->multi_amp_mode = of_property_read_bool(np, in cs35l36_handle_of_data()
1465 "cirrus,multi-amp-mode"); in cs35l36_handle_of_data()
1467 pdata->dcm_mode = of_property_read_bool(np, in cs35l36_handle_of_data()
1468 "cirrus,dcm-mode-enable"); in cs35l36_handle_of_data()
1470 pdata->amp_pcm_inv = of_property_read_bool(np, in cs35l36_handle_of_data()
1471 "cirrus,amp-pcm-inv"); in cs35l36_handle_of_data()
1473 pdata->imon_pol_inv = of_property_read_bool(np, in cs35l36_handle_of_data()
1474 "cirrus,imon-pol-inv"); in cs35l36_handle_of_data()
1476 pdata->vmon_pol_inv = of_property_read_bool(np, in cs35l36_handle_of_data()
1477 "cirrus,vmon-pol-inv"); in cs35l36_handle_of_data()
1479 if (of_property_read_u32(np, "cirrus,temp-warn-threshold", &val) >= 0) in cs35l36_handle_of_data()
1480 pdata->temp_warn_thld = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1482 if (of_property_read_u32(np, "cirrus,boost-ind-nanohenry", &val) >= 0) { in cs35l36_handle_of_data()
1483 pdata->boost_ind = val; in cs35l36_handle_of_data()
1485 dev_err(&i2c_client->dev, "Inductor not specified.\n"); in cs35l36_handle_of_data()
1486 return -EINVAL; in cs35l36_handle_of_data()
1489 if (of_property_read_u32(np, "cirrus,irq-drive-select", &val) >= 0) in cs35l36_handle_of_data()
1490 pdata->irq_drv_sel = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1492 if (of_property_read_u32(np, "cirrus,irq-gpio-select", &val) >= 0) in cs35l36_handle_of_data()
1493 pdata->irq_gpio_sel = val | CS35L36_VALID_PDATA; in cs35l36_handle_of_data()
1496 vpbr_node = of_get_child_by_name(np, "cirrus,vpbr-config"); in cs35l36_handle_of_data()
1497 vpbr_config->is_present = vpbr_node ? true : false; in cs35l36_handle_of_data()
1498 if (vpbr_config->is_present) { in cs35l36_handle_of_data()
1499 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-en", in cs35l36_handle_of_data()
1501 vpbr_config->vpbr_en = val; in cs35l36_handle_of_data()
1502 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-thld", in cs35l36_handle_of_data()
1504 vpbr_config->vpbr_thld = val; in cs35l36_handle_of_data()
1505 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-atk-rate", in cs35l36_handle_of_data()
1507 vpbr_config->vpbr_atk_rate = val; in cs35l36_handle_of_data()
1508 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-atk-vol", in cs35l36_handle_of_data()
1510 vpbr_config->vpbr_atk_vol = val; in cs35l36_handle_of_data()
1511 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-max-attn", in cs35l36_handle_of_data()
1513 vpbr_config->vpbr_max_attn = val; in cs35l36_handle_of_data()
1514 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-wait", in cs35l36_handle_of_data()
1516 vpbr_config->vpbr_wait = val; in cs35l36_handle_of_data()
1517 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-rel-rate", in cs35l36_handle_of_data()
1519 vpbr_config->vpbr_rel_rate = val; in cs35l36_handle_of_data()
1520 if (of_property_read_u32(vpbr_node, "cirrus,vpbr-mute-en", in cs35l36_handle_of_data()
1522 vpbr_config->vpbr_mute_en = val; in cs35l36_handle_of_data()
1534 if (cs35l36->rev_id != CS35L36_REV_B0) in cs35l36_pac()
1540 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1542 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1547 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL1, in cs35l36_pac()
1549 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL3, in cs35l36_pac()
1551 regmap_write(cs35l36->regmap, CS35L36_PAC_PMEM_WORD0, in cs35l36_pac()
1554 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL3, in cs35l36_pac()
1556 regmap_write(cs35l36->regmap, CS35L36_PAC_CTL1, in cs35l36_pac()
1561 ret = regmap_read(cs35l36->regmap, CS35L36_INT4_STATUS, &val); in cs35l36_pac()
1563 dev_err(cs35l36->dev, "Failed to read int4_status %d\n", ret); in cs35l36_pac()
1572 ret = regmap_read(cs35l36->regmap, CS35L36_INT4_STATUS, in cs35l36_pac()
1575 dev_err(cs35l36->dev, "Failed to read int4_status %d\n", in cs35l36_pac()
1581 return -EINVAL; in cs35l36_pac()
1584 regmap_write(cs35l36->regmap, CS35L36_INT4_STATUS, in cs35l36_pac()
1586 regmap_update_bits(cs35l36->regmap, CS35L36_PAC_CTL1, in cs35l36_pac()
1589 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1591 regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL, in cs35l36_pac()
1599 struct cs35l36_platform_data *pdata = &cs35l36->pdata; in cs35l36_apply_vpbr_config()
1600 struct cs35l36_vpbr_cfg *vpbr_config = &pdata->vpbr_config; in cs35l36_apply_vpbr_config()
1602 regmap_update_bits(cs35l36->regmap, CS35L36_PWR_CTRL3, in cs35l36_apply_vpbr_config()
1604 vpbr_config->vpbr_en << in cs35l36_apply_vpbr_config()
1606 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1608 vpbr_config->vpbr_thld << in cs35l36_apply_vpbr_config()
1610 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1612 vpbr_config->vpbr_max_attn << in cs35l36_apply_vpbr_config()
1614 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1616 vpbr_config->vpbr_atk_vol << in cs35l36_apply_vpbr_config()
1618 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1620 vpbr_config->vpbr_atk_rate << in cs35l36_apply_vpbr_config()
1622 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1624 vpbr_config->vpbr_wait << in cs35l36_apply_vpbr_config()
1626 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1628 vpbr_config->vpbr_rel_rate << in cs35l36_apply_vpbr_config()
1630 regmap_update_bits(cs35l36->regmap, CS35L36_VPBR_CFG, in cs35l36_apply_vpbr_config()
1632 vpbr_config->vpbr_mute_en << in cs35l36_apply_vpbr_config()
1694 struct device *dev = &i2c_client->dev; in cs35l36_i2c_probe()
1702 return -ENOMEM; in cs35l36_i2c_probe()
1704 cs35l36->dev = dev; in cs35l36_i2c_probe()
1707 cs35l36->regmap = devm_regmap_init_i2c(i2c_client, &cs35l36_regmap); in cs35l36_i2c_probe()
1708 if (IS_ERR(cs35l36->regmap)) { in cs35l36_i2c_probe()
1709 ret = PTR_ERR(cs35l36->regmap); in cs35l36_i2c_probe()
1714 cs35l36->num_supplies = ARRAY_SIZE(cs35l36_supplies); in cs35l36_i2c_probe()
1716 cs35l36->supplies[i].supply = cs35l36_supplies[i]; in cs35l36_i2c_probe()
1718 ret = devm_regulator_bulk_get(dev, cs35l36->num_supplies, in cs35l36_i2c_probe()
1719 cs35l36->supplies); in cs35l36_i2c_probe()
1726 cs35l36->pdata = *pdata; in cs35l36_i2c_probe()
1731 return -ENOMEM; in cs35l36_i2c_probe()
1733 if (i2c_client->dev.of_node) { in cs35l36_i2c_probe()
1740 cs35l36->pdata = *pdata; in cs35l36_i2c_probe()
1743 ret = regulator_bulk_enable(cs35l36->num_supplies, cs35l36->supplies); in cs35l36_i2c_probe()
1750 cs35l36->reset_gpio = devm_gpiod_get_optional(dev, "reset", in cs35l36_i2c_probe()
1752 if (IS_ERR(cs35l36->reset_gpio)) { in cs35l36_i2c_probe()
1753 ret = PTR_ERR(cs35l36->reset_gpio); in cs35l36_i2c_probe()
1754 cs35l36->reset_gpio = NULL; in cs35l36_i2c_probe()
1755 if (ret == -EBUSY) { in cs35l36_i2c_probe()
1763 if (cs35l36->reset_gpio) in cs35l36_i2c_probe()
1764 gpiod_set_value_cansleep(cs35l36->reset_gpio, 1); in cs35l36_i2c_probe()
1769 ret = regmap_read(cs35l36->regmap, CS35L36_SW_RESET, &reg_id); in cs35l36_i2c_probe()
1778 ret = -ENODEV; in cs35l36_i2c_probe()
1782 ret = regmap_read(cs35l36->regmap, CS35L36_REV_ID, &reg_revid); in cs35l36_i2c_probe()
1784 dev_err(&i2c_client->dev, "Get Revision ID failed %d\n", ret); in cs35l36_i2c_probe()
1788 cs35l36->rev_id = reg_revid >> 8; in cs35l36_i2c_probe()
1790 ret = regmap_read(cs35l36->regmap, CS35L36_OTP_MEM30, &l37_id_reg); in cs35l36_i2c_probe()
1792 dev_err(&i2c_client->dev, "Failed to read otp_id Register %d\n", in cs35l36_i2c_probe()
1798 cs35l36->chip_version = CS35L36_12V_L37; in cs35l36_i2c_probe()
1800 cs35l36->chip_version = CS35L36_10V_L36; in cs35l36_i2c_probe()
1802 switch (cs35l36->rev_id) { in cs35l36_i2c_probe()
1804 ret = regmap_register_patch(cs35l36->regmap, in cs35l36_i2c_probe()
1820 ret = regmap_register_patch(cs35l36->regmap, in cs35l36_i2c_probe()
1831 if (pdata->vpbr_config.is_present) in cs35l36_i2c_probe()
1834 irq_d = irq_get_irq_data(i2c_client->irq); in cs35l36_i2c_probe()
1836 dev_err(&i2c_client->dev, "Invalid IRQ: %d\n", i2c_client->irq); in cs35l36_i2c_probe()
1837 ret = -ENODEV; in cs35l36_i2c_probe()
1853 dev_err(cs35l36->dev, "Invalid IRQ polarity: %d\n", irq_pol); in cs35l36_i2c_probe()
1854 ret = -EINVAL; in cs35l36_i2c_probe()
1858 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_i2c_probe()
1862 ret = devm_request_threaded_irq(dev, i2c_client->irq, NULL, cs35l36_irq, in cs35l36_i2c_probe()
1870 regmap_update_bits(cs35l36->regmap, CS35L36_PAD_INTERFACE, in cs35l36_i2c_probe()
1873 /* Set interrupt masks for critical errors */ in cs35l36_i2c_probe()
1874 regmap_write(cs35l36->regmap, CS35L36_INT1_MASK, in cs35l36_i2c_probe()
1876 regmap_write(cs35l36->regmap, CS35L36_INT3_MASK, in cs35l36_i2c_probe()
1879 dev_info(&i2c_client->dev, "Cirrus Logic CS35L%d, Revision: %02X\n", in cs35l36_i2c_probe()
1880 cs35l36->chip_version, reg_revid >> 8); in cs35l36_i2c_probe()
1894 gpiod_set_value_cansleep(cs35l36->reset_gpio, 0); in cs35l36_i2c_probe()
1897 regulator_bulk_disable(cs35l36->num_supplies, cs35l36->supplies); in cs35l36_i2c_probe()
1905 /* Reset interrupt masks for device removal */ in cs35l36_i2c_remove()
1906 regmap_write(cs35l36->regmap, CS35L36_INT1_MASK, in cs35l36_i2c_remove()
1908 regmap_write(cs35l36->regmap, CS35L36_INT3_MASK, in cs35l36_i2c_remove()
1911 if (cs35l36->reset_gpio) in cs35l36_i2c_remove()
1912 gpiod_set_value_cansleep(cs35l36->reset_gpio, 0); in cs35l36_i2c_remove()
1914 regulator_bulk_disable(cs35l36->num_supplies, cs35l36->supplies); in cs35l36_i2c_remove()