| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * wm8996.c - WM8996 audio codec interface |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2011-2 Wolfson Microelectronics PLC. |
|---|
| 5 | 6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 8 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 9 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 10 | | - * option) any later version. |
|---|
| 11 | 7 | */ |
|---|
| 12 | 8 | |
|---|
| 13 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 347 | 343 | switch (block) { |
|---|
| 348 | 344 | case 0: |
|---|
| 349 | 345 | base = WM8996_DSP1_RX_EQ_GAINS_1; |
|---|
| 350 | | - if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) & |
|---|
| 346 | + if (snd_soc_component_read(component, WM8996_POWER_MANAGEMENT_8) & |
|---|
| 351 | 347 | WM8996_DSP1RX_SRC) |
|---|
| 352 | 348 | iface = 1; |
|---|
| 353 | 349 | else |
|---|
| .. | .. |
|---|
| 355 | 351 | break; |
|---|
| 356 | 352 | case 1: |
|---|
| 357 | 353 | base = WM8996_DSP1_RX_EQ_GAINS_2; |
|---|
| 358 | | - if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) & |
|---|
| 354 | + if (snd_soc_component_read(component, WM8996_POWER_MANAGEMENT_8) & |
|---|
| 359 | 355 | WM8996_DSP2RX_SRC) |
|---|
| 360 | 356 | iface = 1; |
|---|
| 361 | 357 | else |
|---|
| .. | .. |
|---|
| 390 | 386 | /* The EQ will be disabled while reconfiguring it, remember the |
|---|
| 391 | 387 | * current configuration. |
|---|
| 392 | 388 | */ |
|---|
| 393 | | - save = snd_soc_component_read32(component, base); |
|---|
| 389 | + save = snd_soc_component_read(component, base); |
|---|
| 394 | 390 | save &= WM8996_DSP1RX_EQ_ENA; |
|---|
| 395 | 391 | |
|---|
| 396 | 392 | for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++) |
|---|
| .. | .. |
|---|
| 676 | 672 | timeout--; |
|---|
| 677 | 673 | } |
|---|
| 678 | 674 | |
|---|
| 679 | | - ret = snd_soc_component_read32(component, WM8996_DC_SERVO_2); |
|---|
| 675 | + ret = snd_soc_component_read(component, WM8996_DC_SERVO_2); |
|---|
| 680 | 676 | dev_dbg(component->dev, "DC servo state: %x\n", ret); |
|---|
| 681 | 677 | } while (timeout && ret & mask); |
|---|
| 682 | 678 | |
|---|
| .. | .. |
|---|
| 1745 | 1741 | switch (dai->id) { |
|---|
| 1746 | 1742 | case 0: |
|---|
| 1747 | 1743 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || |
|---|
| 1748 | | - (snd_soc_component_read32(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { |
|---|
| 1744 | + (snd_soc_component_read(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { |
|---|
| 1749 | 1745 | aifdata_reg = WM8996_AIF1RX_DATA_CONFIGURATION; |
|---|
| 1750 | 1746 | lrclk_reg = WM8996_AIF1_RX_LRCLK_1; |
|---|
| 1751 | 1747 | } else { |
|---|
| .. | .. |
|---|
| 1756 | 1752 | break; |
|---|
| 1757 | 1753 | case 1: |
|---|
| 1758 | 1754 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || |
|---|
| 1759 | | - (snd_soc_component_read32(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { |
|---|
| 1755 | + (snd_soc_component_read(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { |
|---|
| 1760 | 1756 | aifdata_reg = WM8996_AIF2RX_DATA_CONFIGURATION; |
|---|
| 1761 | 1757 | lrclk_reg = WM8996_AIF2_RX_LRCLK_1; |
|---|
| 1762 | 1758 | } else { |
|---|
| .. | .. |
|---|
| 1826 | 1822 | return 0; |
|---|
| 1827 | 1823 | |
|---|
| 1828 | 1824 | /* Disable SYSCLK while we reconfigure */ |
|---|
| 1829 | | - old = snd_soc_component_read32(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; |
|---|
| 1825 | + old = snd_soc_component_read(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; |
|---|
| 1830 | 1826 | snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, |
|---|
| 1831 | 1827 | WM8996_SYSCLK_ENA, 0); |
|---|
| 1832 | 1828 | |
|---|
| .. | .. |
|---|
| 1858 | 1854 | case 24576000: |
|---|
| 1859 | 1855 | ratediv = WM8996_SYSCLK_DIV; |
|---|
| 1860 | 1856 | wm8996->sysclk /= 2; |
|---|
| 1861 | | - /* fall through */ |
|---|
| 1857 | + fallthrough; |
|---|
| 1862 | 1858 | case 11289600: |
|---|
| 1863 | 1859 | case 12288000: |
|---|
| 1864 | 1860 | snd_soc_component_update_bits(component, WM8996_AIF_RATE, |
|---|
| .. | .. |
|---|
| 2082 | 2078 | snd_soc_component_write(component, WM8996_FLL_EFS_1, fll_div.lambda); |
|---|
| 2083 | 2079 | |
|---|
| 2084 | 2080 | /* Enable the bandgap if it's not already enabled */ |
|---|
| 2085 | | - ret = snd_soc_component_read32(component, WM8996_FLL_CONTROL_1); |
|---|
| 2081 | + ret = snd_soc_component_read(component, WM8996_FLL_CONTROL_1); |
|---|
| 2086 | 2082 | if (!(ret & WM8996_FLL_ENA)) |
|---|
| 2087 | 2083 | wm8996_bg_enable(component); |
|---|
| 2088 | 2084 | |
|---|
| .. | .. |
|---|
| 2121 | 2117 | break; |
|---|
| 2122 | 2118 | } |
|---|
| 2123 | 2119 | |
|---|
| 2124 | | - ret = snd_soc_component_read32(component, WM8996_INTERRUPT_RAW_STATUS_2); |
|---|
| 2120 | + ret = snd_soc_component_read(component, WM8996_INTERRUPT_RAW_STATUS_2); |
|---|
| 2125 | 2121 | if (ret & WM8996_FLL_LOCK_STS) |
|---|
| 2126 | 2122 | break; |
|---|
| 2127 | 2123 | } |
|---|
| .. | .. |
|---|
| 2228 | 2224 | |
|---|
| 2229 | 2225 | /** |
|---|
| 2230 | 2226 | * wm8996_detect - Enable default WM8996 jack detection |
|---|
| 2227 | + * @component: ASoC component |
|---|
| 2228 | + * @jack: jack pointer |
|---|
| 2229 | + * @polarity_cb: polarity callback |
|---|
| 2231 | 2230 | * |
|---|
| 2232 | 2231 | * The WM8996 has advanced accessory detection support for headsets. |
|---|
| 2233 | 2232 | * This function provides a default implementation which integrates |
|---|
| .. | .. |
|---|
| 2295 | 2294 | */ |
|---|
| 2296 | 2295 | report = SND_JACK_HEADPHONE; |
|---|
| 2297 | 2296 | |
|---|
| 2298 | | - reg = snd_soc_component_read32(component, WM8996_HEADPHONE_DETECT_2); |
|---|
| 2297 | + reg = snd_soc_component_read(component, WM8996_HEADPHONE_DETECT_2); |
|---|
| 2299 | 2298 | if (reg < 0) { |
|---|
| 2300 | 2299 | dev_err(component->dev, "Failed to read HPDET status\n"); |
|---|
| 2301 | 2300 | goto out; |
|---|
| .. | .. |
|---|
| 2328 | 2327 | wm8996->detecting = false; |
|---|
| 2329 | 2328 | |
|---|
| 2330 | 2329 | /* If the output isn't running re-clamp it */ |
|---|
| 2331 | | - if (!(snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_1) & |
|---|
| 2330 | + if (!(snd_soc_component_read(component, WM8996_POWER_MANAGEMENT_1) & |
|---|
| 2332 | 2331 | (WM8996_HPOUT1L_ENA | WM8996_HPOUT1R_RMV_SHORT))) |
|---|
| 2333 | 2332 | snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, |
|---|
| 2334 | 2333 | WM8996_HPOUT1L_RMV_SHORT | |
|---|
| .. | .. |
|---|
| 2387 | 2386 | struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); |
|---|
| 2388 | 2387 | int val, reg; |
|---|
| 2389 | 2388 | |
|---|
| 2390 | | - val = snd_soc_component_read32(component, WM8996_MIC_DETECT_3); |
|---|
| 2389 | + val = snd_soc_component_read(component, WM8996_MIC_DETECT_3); |
|---|
| 2391 | 2390 | |
|---|
| 2392 | 2391 | dev_dbg(component->dev, "Microphone event: %x\n", val); |
|---|
| 2393 | 2392 | |
|---|
| .. | .. |
|---|
| 2453 | 2452 | return; |
|---|
| 2454 | 2453 | } |
|---|
| 2455 | 2454 | |
|---|
| 2456 | | - reg = snd_soc_component_read32(component, WM8996_ACCESSORY_DETECT_MODE_2); |
|---|
| 2455 | + reg = snd_soc_component_read(component, WM8996_ACCESSORY_DETECT_MODE_2); |
|---|
| 2457 | 2456 | reg ^= WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | |
|---|
| 2458 | 2457 | WM8996_MICD_BIAS_SRC; |
|---|
| 2459 | 2458 | snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_2, |
|---|
| .. | .. |
|---|
| 2490 | 2489 | struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); |
|---|
| 2491 | 2490 | int irq_val; |
|---|
| 2492 | 2491 | |
|---|
| 2493 | | - irq_val = snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2); |
|---|
| 2492 | + irq_val = snd_soc_component_read(component, WM8996_INTERRUPT_STATUS_2); |
|---|
| 2494 | 2493 | if (irq_val < 0) { |
|---|
| 2495 | 2494 | dev_err(component->dev, "Failed to read IRQ status: %d\n", |
|---|
| 2496 | 2495 | irq_val); |
|---|
| 2497 | 2496 | return IRQ_NONE; |
|---|
| 2498 | 2497 | } |
|---|
| 2499 | | - irq_val &= ~snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2_MASK); |
|---|
| 2498 | + irq_val &= ~snd_soc_component_read(component, WM8996_INTERRUPT_STATUS_2_MASK); |
|---|
| 2500 | 2499 | |
|---|
| 2501 | 2500 | if (!irq_val) |
|---|
| 2502 | 2501 | return IRQ_NONE; |
|---|
| .. | .. |
|---|
| 2801 | 2800 | |
|---|
| 2802 | 2801 | /* This should really be moved into the regulator core */ |
|---|
| 2803 | 2802 | for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) { |
|---|
| 2804 | | - ret = regulator_register_notifier(wm8996->supplies[i].consumer, |
|---|
| 2805 | | - &wm8996->disable_nb[i]); |
|---|
| 2803 | + ret = devm_regulator_register_notifier( |
|---|
| 2804 | + wm8996->supplies[i].consumer, |
|---|
| 2805 | + &wm8996->disable_nb[i]); |
|---|
| 2806 | 2806 | if (ret != 0) { |
|---|
| 2807 | 2807 | dev_err(&i2c->dev, |
|---|
| 2808 | 2808 | "Failed to register regulator notifier: %d\n", |
|---|
| .. | .. |
|---|
| 3071 | 3071 | static int wm8996_i2c_remove(struct i2c_client *client) |
|---|
| 3072 | 3072 | { |
|---|
| 3073 | 3073 | struct wm8996_priv *wm8996 = i2c_get_clientdata(client); |
|---|
| 3074 | | - int i; |
|---|
| 3075 | 3074 | |
|---|
| 3076 | 3075 | wm8996_free_gpio(wm8996); |
|---|
| 3077 | 3076 | if (wm8996->pdata.ldo_ena > 0) { |
|---|
| 3078 | 3077 | gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); |
|---|
| 3079 | 3078 | gpio_free(wm8996->pdata.ldo_ena); |
|---|
| 3080 | 3079 | } |
|---|
| 3081 | | - for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) |
|---|
| 3082 | | - regulator_unregister_notifier(wm8996->supplies[i].consumer, |
|---|
| 3083 | | - &wm8996->disable_nb[i]); |
|---|
| 3084 | 3080 | |
|---|
| 3085 | 3081 | return 0; |
|---|
| 3086 | 3082 | } |
|---|