wcd938x.c (611ac726f9ebbb12f2113e5345ef109660954eeb) wcd938x.c (d9dbe1f9ae4b3463093fcf027d79f20bb9a337c8)
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
3
4#include <linux/module.h>
5#include <linux/slab.h>
6#include <linux/platform_device.h>
7#include <linux/device.h>
8#include <linux/delay.h>

--- 1346 unchanged lines hidden (view full) ---

1355 regmap_update_bits(rm, WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0);
1356
1357 return 0;
1358
1359}
1360
1361static int wcd938x_sdw_connect_port(struct wcd938x_sdw_ch_info *ch_info,
1362 struct sdw_port_config *port_config,
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
3
4#include <linux/module.h>
5#include <linux/slab.h>
6#include <linux/platform_device.h>
7#include <linux/device.h>
8#include <linux/delay.h>

--- 1346 unchanged lines hidden (view full) ---

1355 regmap_update_bits(rm, WCD938X_HPH_SURGE_HPHLR_SURGE_EN, 0xC0, 0xC0);
1356
1357 return 0;
1358
1359}
1360
1361static int wcd938x_sdw_connect_port(struct wcd938x_sdw_ch_info *ch_info,
1362 struct sdw_port_config *port_config,
1363 u32 mstr_port_num,
1364 u8 enable)
1365{
1366 u8 ch_mask, port_num;
1367
1368 port_num = ch_info->port_num;
1369 ch_mask = ch_info->ch_mask;
1370
1371 port_config->num = port_num;
1372
1373 if (enable)
1374 port_config->ch_mask |= ch_mask;
1375 else
1376 port_config->ch_mask &= ~ch_mask;
1377
1378 return 0;
1379}
1380
1381static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 ch_id, u8 enable)
1382{
1363 u8 enable)
1364{
1365 u8 ch_mask, port_num;
1366
1367 port_num = ch_info->port_num;
1368 ch_mask = ch_info->ch_mask;
1369
1370 port_config->num = port_num;
1371
1372 if (enable)
1373 port_config->ch_mask |= ch_mask;
1374 else
1375 port_config->ch_mask &= ~ch_mask;
1376
1377 return 0;
1378}
1379
1380static int wcd938x_connect_port(struct wcd938x_sdw_priv *wcd, u8 ch_id, u8 enable)
1381{
1383 u8 port_num, mstr_port_num;
1382 u8 port_num;
1384
1385 port_num = wcd->ch_info[ch_id].port_num;
1383
1384 port_num = wcd->ch_info[ch_id].port_num;
1386 mstr_port_num = wcd->port_map[port_num - 1];
1387
1388 return wcd938x_sdw_connect_port(&wcd->ch_info[ch_id],
1389 &wcd->port_config[port_num],
1385
1386 return wcd938x_sdw_connect_port(&wcd->ch_info[ch_id],
1387 &wcd->port_config[port_num],
1390 mstr_port_num,
1391 enable);
1392}
1393
1394static int wcd938x_codec_enable_rxclk(struct snd_soc_dapm_widget *w,
1395 struct snd_kcontrol *kcontrol,
1396 int event)
1397{
1398 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);

--- 219 unchanged lines hidden (view full) ---

1618}
1619
1620static int wcd938x_codec_aux_dac_event(struct snd_soc_dapm_widget *w,
1621 struct snd_kcontrol *kcontrol,
1622 int event)
1623{
1624 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1625 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
1388 enable);
1389}
1390
1391static int wcd938x_codec_enable_rxclk(struct snd_soc_dapm_widget *w,
1392 struct snd_kcontrol *kcontrol,
1393 int event)
1394{
1395 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);

--- 219 unchanged lines hidden (view full) ---

1615}
1616
1617static int wcd938x_codec_aux_dac_event(struct snd_soc_dapm_widget *w,
1618 struct snd_kcontrol *kcontrol,
1619 int event)
1620{
1621 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1622 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
1626 int ret = 0;
1627
1628 switch (event) {
1629 case SND_SOC_DAPM_PRE_PMU:
1630 snd_soc_component_write_field(component,
1631 WCD938X_DIGITAL_CDC_ANA_CLK_CTL,
1632 WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 1);
1633 snd_soc_component_write_field(component,
1634 WCD938X_DIGITAL_CDC_DIG_CLK_CTL,

--- 11 unchanged lines hidden (view full) ---

1646 wcd938x->hph_mode);
1647 break;
1648 case SND_SOC_DAPM_POST_PMD:
1649 snd_soc_component_write_field(component,
1650 WCD938X_DIGITAL_CDC_ANA_CLK_CTL,
1651 WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 0);
1652 break;
1653 }
1623
1624 switch (event) {
1625 case SND_SOC_DAPM_PRE_PMU:
1626 snd_soc_component_write_field(component,
1627 WCD938X_DIGITAL_CDC_ANA_CLK_CTL,
1628 WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 1);
1629 snd_soc_component_write_field(component,
1630 WCD938X_DIGITAL_CDC_DIG_CLK_CTL,

--- 11 unchanged lines hidden (view full) ---

1642 wcd938x->hph_mode);
1643 break;
1644 case SND_SOC_DAPM_POST_PMD:
1645 snd_soc_component_write_field(component,
1646 WCD938X_DIGITAL_CDC_ANA_CLK_CTL,
1647 WCD938X_ANA_RX_DIV4_CLK_EN_MASK, 0);
1648 break;
1649 }
1654 return ret;
1650 return 0;
1655
1656}
1657
1658static int wcd938x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
1659 struct snd_kcontrol *kcontrol, int event)
1660{
1661 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1662 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);

--- 198 unchanged lines hidden (view full) ---

1861}
1862
1863static int wcd938x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w,
1864 struct snd_kcontrol *kcontrol, int event)
1865{
1866 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1867 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
1868 int hph_mode = wcd938x->hph_mode;
1651
1652}
1653
1654static int wcd938x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
1655 struct snd_kcontrol *kcontrol, int event)
1656{
1657 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1658 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);

--- 198 unchanged lines hidden (view full) ---

1857}
1858
1859static int wcd938x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w,
1860 struct snd_kcontrol *kcontrol, int event)
1861{
1862 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1863 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
1864 int hph_mode = wcd938x->hph_mode;
1869 int ret = 0;
1870
1871 switch (event) {
1872 case SND_SOC_DAPM_PRE_PMU:
1873 snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2,
1874 WCD938X_AUX_PDM_WD_EN_MASK, 1);
1875 break;
1876 case SND_SOC_DAPM_POST_PMU:
1877 /* 1 msec delay as per HW requirement */

--- 19 unchanged lines hidden (view full) ---

1897 hph_mode);
1898
1899 wcd938x->flyback_cur_det_disable--;
1900 if (wcd938x->flyback_cur_det_disable == 0)
1901 snd_soc_component_write_field(component, WCD938X_FLYBACK_EN,
1902 WCD938X_EN_CUR_DET_MASK, 1);
1903 break;
1904 }
1865
1866 switch (event) {
1867 case SND_SOC_DAPM_PRE_PMU:
1868 snd_soc_component_write_field(component, WCD938X_DIGITAL_PDM_WD_CTL2,
1869 WCD938X_AUX_PDM_WD_EN_MASK, 1);
1870 break;
1871 case SND_SOC_DAPM_POST_PMU:
1872 /* 1 msec delay as per HW requirement */

--- 19 unchanged lines hidden (view full) ---

1892 hph_mode);
1893
1894 wcd938x->flyback_cur_det_disable--;
1895 if (wcd938x->flyback_cur_det_disable == 0)
1896 snd_soc_component_write_field(component, WCD938X_FLYBACK_EN,
1897 WCD938X_EN_CUR_DET_MASK, 1);
1898 break;
1899 }
1905 return ret;
1900 return 0;
1906}
1907
1908static int wcd938x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
1909 struct snd_kcontrol *kcontrol, int event)
1910{
1911 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1912 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
1913 int hph_mode = wcd938x->hph_mode;

--- 1824 unchanged lines hidden ---
1901}
1902
1903static int wcd938x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
1904 struct snd_kcontrol *kcontrol, int event)
1905{
1906 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1907 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
1908 int hph_mode = wcd938x->hph_mode;

--- 1824 unchanged lines hidden ---