Lines Matching +full:revision +full:- +full:id2

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8804.c -- WM8804 S/PDIF transceiver driver
5 * Copyright 2010-11 Wolfson Microelectronics plc
25 #include <sound/soc-dapm.h>
36 { 3, 0x21 }, /* R3 - PLL1 */
37 { 4, 0xFD }, /* R4 - PLL2 */
38 { 5, 0x36 }, /* R5 - PLL3 */
39 { 6, 0x07 }, /* R6 - PLL4 */
40 { 7, 0x16 }, /* R7 - PLL5 */
41 { 8, 0x18 }, /* R8 - PLL6 */
42 { 9, 0xFF }, /* R9 - SPDMODE */
43 { 10, 0x00 }, /* R10 - INTMASK */
44 { 18, 0x00 }, /* R18 - SPDTX1 */
45 { 19, 0x00 }, /* R19 - SPDTX2 */
46 { 20, 0x00 }, /* R20 - SPDTX3 */
47 { 21, 0x71 }, /* R21 - SPDTX4 */
48 { 22, 0x0B }, /* R22 - SPDTX5 */
49 { 23, 0x70 }, /* R23 - GPO0 */
50 { 24, 0x57 }, /* R24 - GPO1 */
51 { 26, 0x42 }, /* R26 - GPO2 */
52 { 27, 0x06 }, /* R27 - AIFTX */
53 { 28, 0x06 }, /* R28 - AIFRX */
54 { 29, 0x80 }, /* R29 - SPDRX1 */
55 { 30, 0x07 }, /* R30 - PWRDN */
88 regcache_mark_dirty(wm8804->regmap); \
136 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm8804_aif_event()
142 if (!wm8804->aif_pwr) in wm8804_aif_event()
144 wm8804->aif_pwr++; in wm8804_aif_event()
148 wm8804->aif_pwr--; in wm8804_aif_event()
149 if (!wm8804->aif_pwr) in wm8804_aif_event()
162 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in txsrc_put()
163 unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l; in txsrc_put()
164 unsigned int mask = 1 << e->shift_l; in txsrc_put()
168 return -EINVAL; in txsrc_put()
172 if (snd_soc_component_test_bits(component, e->reg, mask, val)) { in txsrc_put()
180 snd_soc_component_update_bits(component, e->reg, mask, val); in txsrc_put()
212 return regmap_write(wm8804->regmap, WM8804_RST_DEVID1, 0x0); in wm8804_soft_reset()
220 component = dai->component; in wm8804_set_fmt()
237 dev_err(dai->dev, "Unknown dai format\n"); in wm8804_set_fmt()
238 return -EINVAL; in wm8804_set_fmt()
253 dev_err(dai->dev, "Unknown master/slave configuration\n"); in wm8804_set_fmt()
254 return -EINVAL; in wm8804_set_fmt()
274 dev_err(dai->dev, "Unknown polarity configuration\n"); in wm8804_set_fmt()
275 return -EINVAL; in wm8804_set_fmt()
293 component = dai->component; in wm8804_hw_params()
306 dev_err(dai->dev, "Unsupported word length: %u\n", in wm8804_hw_params()
308 return -EINVAL; in wm8804_hw_params()
352 * region of 90-100MHz. in pll_factors()
358 pll_div->freqmode = post_table[i].freqmode; in pll_factors()
359 pll_div->mclkdiv = post_table[i].mclkdiv; in pll_factors()
368 return -EINVAL; in pll_factors()
371 pll_div->prescale = 0; in pll_factors()
375 pll_div->prescale = 1; in pll_factors()
382 return -EINVAL; in pll_factors()
384 pll_div->n = Ndiv; in pll_factors()
395 pll_div->k = K; in pll_factors()
404 struct snd_soc_component *component = dai->component; in wm8804_set_pll()
410 regmap_update_bits_check(wm8804->regmap, WM8804_PWRDN, in wm8804_set_pll()
413 pm_runtime_put(wm8804->dev); in wm8804_set_pll()
419 wm8804->mclk_div); in wm8804_set_pll()
424 regmap_update_bits_check(wm8804->regmap, WM8804_PWRDN, in wm8804_set_pll()
427 pm_runtime_get_sync(wm8804->dev); in wm8804_set_pll()
452 component = dai->component; in wm8804_set_sysclk()
460 dev_err(dai->dev, "OSCCLOCK is not within the " in wm8804_set_sysclk()
462 return -EINVAL; in wm8804_set_sysclk()
475 dev_err(dai->dev, "Unknown clock source: %d\n", clk_id); in wm8804_set_sysclk()
476 return -EINVAL; in wm8804_set_sysclk()
488 component = dai->component; in wm8804_set_clkdiv()
496 wm8804->mclk_div = div; in wm8804_set_clkdiv()
499 dev_err(dai->dev, "Unknown clock divider: %d\n", div_id); in wm8804_set_clkdiv()
500 return -EINVAL; in wm8804_set_clkdiv()
522 .name = "wm8804-spdif",
566 unsigned int id1, id2; in wm8804_probe() local
571 return -ENOMEM; in wm8804_probe()
575 wm8804->dev = dev; in wm8804_probe()
576 wm8804->regmap = regmap; in wm8804_probe()
578 wm8804->reset = devm_gpiod_get_optional(dev, "wlf,reset", in wm8804_probe()
580 if (IS_ERR(wm8804->reset)) { in wm8804_probe()
581 ret = PTR_ERR(wm8804->reset); in wm8804_probe()
586 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) in wm8804_probe()
587 wm8804->supplies[i].supply = wm8804_supply_names[i]; in wm8804_probe()
589 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8804->supplies), in wm8804_probe()
590 wm8804->supplies); in wm8804_probe()
596 wm8804->disable_nb[0].notifier_call = wm8804_regulator_event_0; in wm8804_probe()
597 wm8804->disable_nb[1].notifier_call = wm8804_regulator_event_1; in wm8804_probe()
600 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) { in wm8804_probe()
601 struct regulator *regulator = wm8804->supplies[i].consumer; in wm8804_probe()
604 &wm8804->disable_nb[i]); in wm8804_probe()
613 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies), in wm8804_probe()
614 wm8804->supplies); in wm8804_probe()
620 gpiod_set_value_cansleep(wm8804->reset, 1); in wm8804_probe()
628 ret = regmap_read(regmap, WM8804_DEVID2, &id2); in wm8804_probe()
634 id2 = (id2 << 8) | id1; in wm8804_probe()
636 if (id2 != 0x8805) { in wm8804_probe()
637 dev_err(dev, "Invalid device ID: %#x\n", id2); in wm8804_probe()
638 ret = -EINVAL; in wm8804_probe()
644 dev_err(dev, "Failed to read device revision: %d\n", in wm8804_probe()
648 dev_info(dev, "revision %c\n", id1 + 'A'); in wm8804_probe()
650 if (!wm8804->reset) { in wm8804_probe()
672 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies); in wm8804_probe()
689 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies), in wm8804_runtime_resume()
690 wm8804->supplies); in wm8804_runtime_resume()
692 dev_err(wm8804->dev, "Failed to enable supplies: %d\n", ret); in wm8804_runtime_resume()
696 regcache_sync(wm8804->regmap); in wm8804_runtime_resume()
699 regmap_update_bits(wm8804->regmap, WM8804_PWRDN, 0x8, 0x0); in wm8804_runtime_resume()
709 regmap_update_bits(wm8804->regmap, WM8804_PWRDN, 0x8, 0x8); in wm8804_runtime_suspend()
711 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), in wm8804_runtime_suspend()
712 wm8804->supplies); in wm8804_runtime_suspend()