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);
142 if (!wm8804->aif_pwr)
144 wm8804->aif_pwr++;
148 wm8804->aif_pwr--;
149 if (!wm8804->aif_pwr)
162 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
163 unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l;
164 unsigned int mask = 1 << e->shift_l;
168 return -EINVAL;
172 if (snd_soc_component_test_bits(component, e->reg, mask, val)) {
180 snd_soc_component_update_bits(component, e->reg, mask, val);
212 return regmap_write(wm8804->regmap, WM8804_RST_DEVID1, 0x0);
220 component = dai->component;
237 dev_err(dai->dev, "Unknown dai format\n");
238 return -EINVAL;
253 dev_err(dai->dev, "Unknown master/slave configuration\n");
254 return -EINVAL;
274 dev_err(dai->dev, "Unknown polarity configuration\n");
275 return -EINVAL;
293 component = dai->component;
306 dev_err(dai->dev, "Unsupported word length: %u\n",
308 return -EINVAL;
352 * region of 90-100MHz.
358 pll_div->freqmode = post_table[i].freqmode;
359 pll_div->mclkdiv = post_table[i].mclkdiv;
368 return -EINVAL;
371 pll_div->prescale = 0;
375 pll_div->prescale = 1;
382 return -EINVAL;
384 pll_div->n = Ndiv;
395 pll_div->k = K;
404 struct snd_soc_component *component = dai->component;
410 regmap_update_bits_check(wm8804->regmap, WM8804_PWRDN,
413 pm_runtime_put(wm8804->dev);
419 wm8804->mclk_div);
424 regmap_update_bits_check(wm8804->regmap, WM8804_PWRDN,
427 pm_runtime_get_sync(wm8804->dev);
452 component = dai->component;
460 dev_err(dai->dev, "OSCCLOCK is not within the "
462 return -EINVAL;
475 dev_err(dai->dev, "Unknown clock source: %d\n", clk_id);
476 return -EINVAL;
488 component = dai->component;
496 wm8804->mclk_div = div;
499 dev_err(dai->dev, "Unknown clock divider: %d\n", div_id);
500 return -EINVAL;
522 .name = "wm8804-spdif",
566 unsigned int id1, id2;
571 return -ENOMEM;
575 wm8804->dev = dev;
576 wm8804->regmap = regmap;
578 wm8804->reset = devm_gpiod_get_optional(dev, "wlf,reset",
580 if (IS_ERR(wm8804->reset)) {
581 ret = PTR_ERR(wm8804->reset);
586 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++)
587 wm8804->supplies[i].supply = wm8804_supply_names[i];
589 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8804->supplies),
590 wm8804->supplies);
596 wm8804->disable_nb[0].notifier_call = wm8804_regulator_event_0;
597 wm8804->disable_nb[1].notifier_call = wm8804_regulator_event_1;
600 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) {
601 struct regulator *regulator = wm8804->supplies[i].consumer;
604 &wm8804->disable_nb[i]);
613 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies),
614 wm8804->supplies);
620 gpiod_set_value_cansleep(wm8804->reset, 1);
628 ret = regmap_read(regmap, WM8804_DEVID2, &id2);
634 id2 = (id2 << 8) | id1;
636 if (id2 != 0x8805) {
637 dev_err(dev, "Invalid device ID: %#x\n", id2);
638 ret = -EINVAL;
644 dev_err(dev, "Failed to read device revision: %d\n",
648 dev_info(dev, "revision %c\n", id1 + 'A');
650 if (!wm8804->reset) {
672 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
688 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies),
689 wm8804->supplies);
691 dev_err(wm8804->dev, "Failed to enable supplies: %d\n", ret);
695 regcache_sync(wm8804->regmap);
698 regmap_update_bits(wm8804->regmap, WM8804_PWRDN, 0x8, 0x0);
708 regmap_update_bits(wm8804->regmap, WM8804_PWRDN, 0x8, 0x8);
710 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies),
711 wm8804->supplies);