aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc-acpi-intel-match.h32
-rw-r--r--include/sound/soc-acpi.h111
-rw-r--r--include/sound/soc.h14
-rw-r--r--sound/soc/Kconfig3
-rw-r--r--sound/soc/Makefile6
-rw-r--r--sound/soc/codecs/hdac_hdmi.c51
-rw-r--r--sound/soc/intel/Kconfig302
-rw-r--r--sound/soc/intel/Makefile2
-rw-r--r--sound/soc/intel/atom/sst-mfld-platform-compress.c2
-rw-r--r--sound/soc/intel/atom/sst-mfld-platform.h2
-rw-r--r--sound/soc/intel/atom/sst/sst_acpi.c312
-rw-r--r--sound/soc/intel/atom/sst/sst_loader.c1
-rw-r--r--sound/soc/intel/atom/sst/sst_stream.c1
-rw-r--r--sound/soc/intel/boards/Kconfig265
-rw-r--r--sound/soc/intel/boards/bxt_da7219_max98357a.c16
-rw-r--r--sound/soc/intel/boards/bytcht_da7213.c23
-rw-r--r--sound/soc/intel/boards/bytcht_es8316.c27
-rw-r--r--sound/soc/intel/boards/bytcht_nocodec.c10
-rw-r--r--sound/soc/intel/boards/bytcr_rt5640.c118
-rw-r--r--sound/soc/intel/boards/bytcr_rt5651.c297
-rw-r--r--sound/soc/intel/boards/cht_bsw_max98090_ti.c179
-rw-r--r--sound/soc/intel/boards/cht_bsw_rt5645.c128
-rw-r--r--sound/soc/intel/boards/cht_bsw_rt5672.c68
-rw-r--r--sound/soc/intel/boards/kbl_rt5663_max98927.c76
-rw-r--r--sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c1
-rw-r--r--sound/soc/intel/boards/skl_nau88l25_max98357a.c16
-rw-r--r--sound/soc/intel/boards/skl_nau88l25_ssm4567.c16
-rw-r--r--sound/soc/intel/common/Makefile4
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-byt-match.c196
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-cht-match.c194
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c64
-rw-r--r--sound/soc/intel/common/sst-acpi.c36
-rw-r--r--sound/soc/intel/common/sst-acpi.h82
-rw-r--r--sound/soc/intel/common/sst-firmware.c3
-rw-r--r--sound/soc/intel/skylake/skl-messages.c23
-rw-r--r--sound/soc/intel/skylake/skl-pcm.c46
-rw-r--r--sound/soc/intel/skylake/skl-topology.c68
-rw-r--r--sound/soc/intel/skylake/skl-topology.h7
-rw-r--r--sound/soc/intel/skylake/skl.c50
-rw-r--r--sound/soc/intel/skylake/skl.h4
-rw-r--r--sound/soc/soc-acpi.c (renamed from sound/soc/intel/common/sst-match-acpi.c)56
41 files changed, 1774 insertions, 1138 deletions
diff --git a/include/sound/soc-acpi-intel-match.h b/include/sound/soc-acpi-intel-match.h
new file mode 100644
index 000000000000..1a9191cd4bb3
--- /dev/null
+++ b/include/sound/soc-acpi-intel-match.h
@@ -0,0 +1,32 @@
1
2/*
3 * Copyright (C) 2017, Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License version
7 * 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __LINUX_SND_SOC_ACPI_INTEL_MATCH_H
17#define __LINUX_SND_SOC_ACPI_INTEL_MATCH_H
18
19#include <linux/stddef.h>
20#include <linux/acpi.h>
21
22/*
23 * these tables are not constants, some fields can be used for
24 * pdata or machine ops
25 */
26extern struct snd_soc_acpi_mach snd_soc_acpi_intel_haswell_machines[];
27extern struct snd_soc_acpi_mach snd_soc_acpi_intel_broadwell_machines[];
28extern struct snd_soc_acpi_mach snd_soc_acpi_intel_baytrail_legacy_machines[];
29extern struct snd_soc_acpi_mach snd_soc_acpi_intel_baytrail_machines[];
30extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[];
31
32#endif
diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h
new file mode 100644
index 000000000000..a7d8d335b043
--- /dev/null
+++ b/include/sound/soc-acpi.h
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License version
6 * 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __LINUX_SND_SOC_ACPI_H
16#define __LINUX_SND_SOC_ACPI_H
17
18#include <linux/stddef.h>
19#include <linux/acpi.h>
20
21struct snd_soc_acpi_package_context {
22 char *name; /* package name */
23 int length; /* number of elements */
24 struct acpi_buffer *format;
25 struct acpi_buffer *state;
26 bool data_valid;
27};
28
29#if IS_ENABLED(CONFIG_ACPI)
30/* translation fron HID to I2C name, needed for DAI codec_name */
31const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
32bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
33 struct snd_soc_acpi_package_context *ctx);
34#else
35static inline const char *
36snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
37{
38 return NULL;
39}
40static inline bool
41snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
42 struct snd_soc_acpi_package_context *ctx)
43{
44 return false;
45}
46#endif
47
48/* acpi match */
49struct snd_soc_acpi_mach *
50snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
51
52/* acpi check hid */
53bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);
54
55/**
56 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
57 * related to the hardware, except for the firmware and topology file names.
58 * A platform supported by legacy and Sound Open Firmware (SOF) would expose
59 * all firmware/topology related fields.
60 *
61 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
62 * @drv_name: machine driver name
63 * @fw_filename: firmware file name. Used when SOF is not enabled.
64 * @board: board name
65 * @machine_quirk: pointer to quirk, usually based on DMI information when
66 * ACPI ID alone is not sufficient, wrong or misleading
67 * @quirk_data: data used to uniquely identify a machine, usually a list of
68 * audio codecs whose presence if checked with ACPI
69 * @pdata: intended for platform data or machine specific-ops. This structure
70 * is not constant since this field may be updated at run-time
71 * @sof_fw_filename: Sound Open Firmware file name, if enabled
72 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
73 * @asoc_plat_name: ASoC platform name, used for binding machine drivers
74 * if non NULL
75 * @new_mach_data: machine driver private data fixup
76 */
77/* Descriptor for SST ASoC machine driver */
78struct snd_soc_acpi_mach {
79 const u8 id[ACPI_ID_LEN];
80 const char *drv_name;
81 const char *fw_filename;
82 const char *board;
83 struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
84 const void *quirk_data;
85 void *pdata;
86 const char *sof_fw_filename;
87 const char *sof_tplg_filename;
88 const char *asoc_plat_name;
89 struct platform_device * (*new_mach_data)(void *pdata);
90};
91
92#define SND_SOC_ACPI_MAX_CODECS 3
93
94/**
95 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
96 * apart from the matched one, this data will be passed to the quirk function
97 * to match with the ACPI detected devices
98 *
99 * @num_codecs: number of secondary codecs used in the platform
100 * @codecs: holds the codec IDs
101 *
102 */
103struct snd_soc_acpi_codecs {
104 int num_codecs;
105 u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
106};
107
108/* check all codecs */
109struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
110
111#endif
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 0668cbd9f0b5..1a7323238c49 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1821,6 +1821,20 @@ struct snd_soc_dai *snd_soc_find_dai(
1821 1821
1822#include <sound/soc-dai.h> 1822#include <sound/soc-dai.h>
1823 1823
1824static inline
1825struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
1826 const char *dai_name)
1827{
1828 struct snd_soc_pcm_runtime *rtd;
1829
1830 list_for_each_entry(rtd, &card->rtd_list, list) {
1831 if (!strcmp(rtd->codec_dai->name, dai_name))
1832 return rtd->codec_dai;
1833 }
1834
1835 return NULL;
1836}
1837
1824#ifdef CONFIG_DEBUG_FS 1838#ifdef CONFIG_DEBUG_FS
1825extern struct dentry *snd_soc_debugfs_root; 1839extern struct dentry *snd_soc_debugfs_root;
1826#endif 1840#endif
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index c0abad2067e1..d22758165496 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -36,6 +36,9 @@ config SND_SOC_COMPRESS
36config SND_SOC_TOPOLOGY 36config SND_SOC_TOPOLOGY
37 bool 37 bool
38 38
39config SND_SOC_ACPI
40 tristate
41
39# All the supported SoCs 42# All the supported SoCs
40source "sound/soc/adi/Kconfig" 43source "sound/soc/adi/Kconfig"
41source "sound/soc/amd/Kconfig" 44source "sound/soc/amd/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index bf8c1e2ce0bf..5327f4d6c668 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -15,6 +15,12 @@ ifneq ($(CONFIG_SND_SOC_AC97_BUS),)
15snd-soc-core-objs += soc-ac97.o 15snd-soc-core-objs += soc-ac97.o
16endif 16endif
17 17
18ifneq ($(CONFIG_SND_SOC_ACPI),)
19snd-soc-acpi-objs := soc-acpi.o
20endif
21
22obj-$(CONFIG_SND_SOC_ACPI) += snd-soc-acpi.o
23
18obj-$(CONFIG_SND_SOC) += snd-soc-core.o 24obj-$(CONFIG_SND_SOC) += snd-soc-core.o
19obj-$(CONFIG_SND_SOC) += codecs/ 25obj-$(CONFIG_SND_SOC) += codecs/
20obj-$(CONFIG_SND_SOC) += generic/ 26obj-$(CONFIG_SND_SOC) += generic/
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index e824d47cc22b..f3b4f4dfae6a 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -942,7 +942,8 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev,
942 if (!se) 942 if (!se)
943 return -ENOMEM; 943 return -ENOMEM;
944 944
945 sprintf(kc_name, "Pin %d port %d Input", pin->nid, port->id); 945 snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input",
946 pin->nid, port->id);
946 kc->name = devm_kstrdup(&edev->hdac.dev, kc_name, GFP_KERNEL); 947 kc->name = devm_kstrdup(&edev->hdac.dev, kc_name, GFP_KERNEL);
947 if (!kc->name) 948 if (!kc->name)
948 return -ENOMEM; 949 return -ENOMEM;
@@ -1452,6 +1453,8 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
1452 int i, num_nodes; 1453 int i, num_nodes;
1453 struct hdac_device *hdac = &edev->hdac; 1454 struct hdac_device *hdac = &edev->hdac;
1454 struct hdac_hdmi_priv *hdmi = edev->private_data; 1455 struct hdac_hdmi_priv *hdmi = edev->private_data;
1456 struct hdac_hdmi_cvt *temp_cvt, *cvt_next;
1457 struct hdac_hdmi_pin *temp_pin, *pin_next;
1455 int ret; 1458 int ret;
1456 1459
1457 hdac_hdmi_skl_enable_all_pins(hdac); 1460 hdac_hdmi_skl_enable_all_pins(hdac);
@@ -1481,32 +1484,54 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
1481 case AC_WID_AUD_OUT: 1484 case AC_WID_AUD_OUT:
1482 ret = hdac_hdmi_add_cvt(edev, nid); 1485 ret = hdac_hdmi_add_cvt(edev, nid);
1483 if (ret < 0) 1486 if (ret < 0)
1484 return ret; 1487 goto free_widgets;
1485 break; 1488 break;
1486 1489
1487 case AC_WID_PIN: 1490 case AC_WID_PIN:
1488 ret = hdac_hdmi_add_pin(edev, nid); 1491 ret = hdac_hdmi_add_pin(edev, nid);
1489 if (ret < 0) 1492 if (ret < 0)
1490 return ret; 1493 goto free_widgets;
1491 break; 1494 break;
1492 } 1495 }
1493 } 1496 }
1494 1497
1495 hdac->end_nid = nid; 1498 hdac->end_nid = nid;
1496 1499
1497 if (!hdmi->num_pin || !hdmi->num_cvt) 1500 if (!hdmi->num_pin || !hdmi->num_cvt) {
1498 return -EIO; 1501 ret = -EIO;
1502 goto free_widgets;
1503 }
1499 1504
1500 ret = hdac_hdmi_create_dais(hdac, dais, hdmi, hdmi->num_cvt); 1505 ret = hdac_hdmi_create_dais(hdac, dais, hdmi, hdmi->num_cvt);
1501 if (ret) { 1506 if (ret) {
1502 dev_err(&hdac->dev, "Failed to create dais with err: %d\n", 1507 dev_err(&hdac->dev, "Failed to create dais with err: %d\n",
1503 ret); 1508 ret);
1504 return ret; 1509 goto free_widgets;
1505 } 1510 }
1506 1511
1507 *num_dais = hdmi->num_cvt; 1512 *num_dais = hdmi->num_cvt;
1513 ret = hdac_hdmi_init_dai_map(edev);
1514 if (ret < 0)
1515 goto free_widgets;
1516
1517 return ret;
1518
1519free_widgets:
1520 list_for_each_entry_safe(temp_cvt, cvt_next, &hdmi->cvt_list, head) {
1521 list_del(&temp_cvt->head);
1522 kfree(temp_cvt->name);
1523 kfree(temp_cvt);
1524 }
1525
1526 list_for_each_entry_safe(temp_pin, pin_next, &hdmi->pin_list, head) {
1527 for (i = 0; i < temp_pin->num_ports; i++)
1528 temp_pin->ports[i].pin = NULL;
1529 kfree(temp_pin->ports);
1530 list_del(&temp_pin->head);
1531 kfree(temp_pin);
1532 }
1508 1533
1509 return hdac_hdmi_init_dai_map(edev); 1534 return ret;
1510} 1535}
1511 1536
1512static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) 1537static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
@@ -1894,6 +1919,9 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
1894 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1919 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1895 struct hdac_hdmi_port *port; 1920 struct hdac_hdmi_port *port;
1896 1921
1922 if (!pcm)
1923 return;
1924
1897 if (list_empty(&pcm->port_list)) 1925 if (list_empty(&pcm->port_list))
1898 return; 1926 return;
1899 1927
@@ -1912,6 +1940,9 @@ static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
1912 struct hdac_hdmi_priv *hdmi = edev->private_data; 1940 struct hdac_hdmi_priv *hdmi = edev->private_data;
1913 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1941 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1914 1942
1943 if (!pcm)
1944 return false;
1945
1915 if (list_empty(&pcm->port_list)) 1946 if (list_empty(&pcm->port_list))
1916 return false; 1947 return false;
1917 1948
@@ -1925,6 +1956,9 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
1925 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); 1956 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
1926 struct hdac_hdmi_port *port; 1957 struct hdac_hdmi_port *port;
1927 1958
1959 if (!pcm)
1960 return 0;
1961
1928 if (list_empty(&pcm->port_list)) 1962 if (list_empty(&pcm->port_list))
1929 return 0; 1963 return 0;
1930 1964
@@ -1978,6 +2012,9 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
1978 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; 2012 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached;
1979 hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; 2013 hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc;
1980 2014
2015 if (!hdac_id)
2016 return -ENODEV;
2017
1981 if (hdac_id->driver_data) 2018 if (hdac_id->driver_data)
1982 hdmi_priv->drv_data = 2019 hdmi_priv->drv_data =
1983 (struct hdac_hdmi_drv_data *)hdac_id->driver_data; 2020 (struct hdac_hdmi_drv_data *)hdac_id->driver_data;
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index b3c7f554ec30..bb8be10b8437 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -1,19 +1,3 @@
1config SND_MFLD_MACHINE
2 tristate "SOC Machine Audio driver for Intel Medfield MID platform"
3 depends on INTEL_SCU_IPC
4 select SND_SOC_SN95031
5 select SND_SST_ATOM_HIFI2_PLATFORM
6 select SND_SST_IPC_PCI
7 help
8 This adds support for ASoC machine driver for Intel(R) MID Medfield platform
9 used as alsa device in audio substem in Intel(R) MID devices
10 Say Y if you have such a device.
11 If unsure select "N".
12
13config SND_SST_ATOM_HIFI2_PLATFORM
14 tristate
15 select SND_SOC_COMPRESS
16
17config SND_SST_IPC 1config SND_SST_IPC
18 tristate 2 tristate
19 3
@@ -27,10 +11,12 @@ config SND_SST_IPC_ACPI
27 select SND_SOC_INTEL_SST 11 select SND_SOC_INTEL_SST
28 select IOSF_MBI 12 select IOSF_MBI
29 13
14config SND_SOC_INTEL_COMMON
15 tristate
16
30config SND_SOC_INTEL_SST 17config SND_SOC_INTEL_SST
31 tristate 18 tristate
32 select SND_SOC_INTEL_SST_ACPI if ACPI 19 select SND_SOC_INTEL_SST_ACPI if ACPI
33 select SND_SOC_INTEL_SST_MATCH if ACPI
34 20
35config SND_SOC_INTEL_SST_FIRMWARE 21config SND_SOC_INTEL_SST_FIRMWARE
36 tristate 22 tristate
@@ -39,280 +25,42 @@ config SND_SOC_INTEL_SST_FIRMWARE
39config SND_SOC_INTEL_SST_ACPI 25config SND_SOC_INTEL_SST_ACPI
40 tristate 26 tristate
41 27
42config SND_SOC_INTEL_SST_MATCH 28config SND_SOC_ACPI_INTEL_MATCH
43 tristate 29 tristate
30 select SND_SOC_ACPI if ACPI
31
32config SND_SOC_INTEL_SST_TOPLEVEL
33 tristate "Intel ASoC SST drivers"
34 depends on X86 || COMPILE_TEST
35 select SND_SOC_INTEL_MACH
36 select SND_SOC_INTEL_COMMON
44 37
45config SND_SOC_INTEL_HASWELL 38config SND_SOC_INTEL_HASWELL
46 tristate 39 tristate "Intel ASoC SST driver for Haswell/Broadwell"
40 depends on SND_SOC_INTEL_SST_TOPLEVEL && SND_DMA_SGBUF
41 depends on DMADEVICES
47 select SND_SOC_INTEL_SST 42 select SND_SOC_INTEL_SST
48 select SND_SOC_INTEL_SST_FIRMWARE 43 select SND_SOC_INTEL_SST_FIRMWARE
49 44
50config SND_SOC_INTEL_BAYTRAIL 45config SND_SOC_INTEL_BAYTRAIL
51 tristate 46 tristate "Intel ASoC SST driver for Baytrail (legacy)"
52 select SND_SOC_INTEL_SST 47 depends on SND_SOC_INTEL_SST_TOPLEVEL
53 select SND_SOC_INTEL_SST_FIRMWARE
54
55config SND_SOC_INTEL_HASWELL_MACH
56 tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint"
57 depends on X86_INTEL_LPSS && I2C && I2C_DESIGNWARE_PLATFORM
58 depends on DMADEVICES
59 select SND_SOC_INTEL_HASWELL
60 select SND_SOC_RT5640
61 help
62 This adds support for the Lynxpoint Audio DSP on Intel(R) Haswell
63 Ultrabook platforms.
64 Say Y if you have such a device.
65 If unsure select "N".
66
67config SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH
68 tristate "ASoC Audio driver for Broxton with DA7219 and MAX98357A in I2S Mode"
69 depends on X86 && ACPI && I2C
70 select SND_SOC_INTEL_SKYLAKE
71 select SND_SOC_DA7219
72 select SND_SOC_MAX98357A
73 select SND_SOC_DMIC
74 select SND_SOC_HDAC_HDMI
75 select SND_HDA_DSP_LOADER
76 help
77 This adds support for ASoC machine driver for Broxton-P platforms
78 with DA7219 + MAX98357A I2S audio codec.
79 Say Y if you have such a device.
80 If unsure select "N".
81
82config SND_SOC_INTEL_BXT_RT298_MACH
83 tristate "ASoC Audio driver for Broxton with RT298 I2S mode"
84 depends on X86 && ACPI && I2C
85 select SND_SOC_INTEL_SKYLAKE
86 select SND_SOC_RT298
87 select SND_SOC_DMIC
88 select SND_SOC_HDAC_HDMI
89 select SND_HDA_DSP_LOADER
90 help
91 This adds support for ASoC machine driver for Broxton platforms
92 with RT286 I2S audio codec.
93 Say Y if you have such a device.
94 If unsure select "N".
95
96config SND_SOC_INTEL_BYT_RT5640_MACH
97 tristate "ASoC Audio driver for Intel Baytrail with RT5640 codec"
98 depends on X86_INTEL_LPSS && I2C
99 depends on DMADEVICES 48 depends on DMADEVICES
100 depends on SND_SST_IPC_ACPI = n
101 select SND_SOC_INTEL_BAYTRAIL
102 select SND_SOC_RT5640
103 help
104 This adds audio driver for Intel Baytrail platform based boards
105 with the RT5640 audio codec. This driver is deprecated, use
106 SND_SOC_INTEL_BYTCR_RT5640_MACH instead for better functionality.
107
108config SND_SOC_INTEL_BYT_MAX98090_MACH
109 tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec"
110 depends on X86_INTEL_LPSS && I2C
111 depends on DMADEVICES
112 depends on SND_SST_IPC_ACPI = n
113 select SND_SOC_INTEL_BAYTRAIL
114 select SND_SOC_MAX98090
115 help
116 This adds audio driver for Intel Baytrail platform based boards
117 with the MAX98090 audio codec.
118
119config SND_SOC_INTEL_BDW_RT5677_MACH
120 tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
121 depends on X86_INTEL_LPSS && GPIOLIB && I2C
122 depends on DMADEVICES
123 select SND_SOC_INTEL_HASWELL
124 select SND_SOC_RT5677
125 help
126 This adds support for Intel Broadwell platform based boards with
127 the RT5677 audio codec.
128
129config SND_SOC_INTEL_BROADWELL_MACH
130 tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
131 depends on X86_INTEL_LPSS && I2C && I2C_DESIGNWARE_PLATFORM
132 depends on DMADEVICES
133 select SND_SOC_INTEL_HASWELL
134 select SND_SOC_RT286
135 help
136 This adds support for the Wilcatpoint Audio DSP on Intel(R) Broadwell
137 Ultrabook platforms.
138 Say Y if you have such a device.
139 If unsure select "N".
140
141config SND_SOC_INTEL_BYTCR_RT5640_MACH
142 tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with RT5640 codec"
143 depends on X86 && I2C && ACPI
144 select SND_SOC_RT5640
145 select SND_SST_ATOM_HIFI2_PLATFORM
146 select SND_SST_IPC_ACPI
147 select SND_SOC_INTEL_SST_MATCH if ACPI
148 help
149 This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
150 platforms with RT5640 audio codec.
151 Say Y if you have such a device.
152 If unsure select "N".
153
154config SND_SOC_INTEL_BYTCR_RT5651_MACH
155 tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with RT5651 codec"
156 depends on X86 && I2C && ACPI
157 select SND_SOC_RT5651
158 select SND_SST_ATOM_HIFI2_PLATFORM
159 select SND_SST_IPC_ACPI
160 select SND_SOC_INTEL_SST_MATCH if ACPI
161 help
162 This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
163 platforms with RT5651 audio codec.
164 Say Y if you have such a device.
165 If unsure select "N".
166
167config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
168 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec"
169 depends on X86_INTEL_LPSS && I2C && ACPI
170 select SND_SOC_RT5670
171 select SND_SST_ATOM_HIFI2_PLATFORM
172 select SND_SST_IPC_ACPI
173 select SND_SOC_INTEL_SST_MATCH if ACPI
174 help
175 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
176 platforms with RT5672 audio codec.
177 Say Y if you have such a device.
178 If unsure select "N".
179
180config SND_SOC_INTEL_CHT_BSW_RT5645_MACH
181 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5645/5650 codec"
182 depends on X86_INTEL_LPSS && I2C && ACPI
183 select SND_SOC_RT5645
184 select SND_SST_ATOM_HIFI2_PLATFORM
185 select SND_SST_IPC_ACPI
186 select SND_SOC_INTEL_SST_MATCH if ACPI
187 help
188 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
189 platforms with RT5645/5650 audio codec.
190 If unsure select "N".
191
192config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH
193 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with MAX98090 & TI codec"
194 depends on X86_INTEL_LPSS && I2C && ACPI
195 select SND_SOC_MAX98090
196 select SND_SOC_TS3A227E
197 select SND_SST_ATOM_HIFI2_PLATFORM
198 select SND_SST_IPC_ACPI
199 select SND_SOC_INTEL_SST_MATCH if ACPI
200 help
201 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
202 platforms with MAX98090 audio codec it also can support TI jack chip as aux device.
203 If unsure select "N".
204
205config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
206 tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with DA7212/7213 codec"
207 depends on X86_INTEL_LPSS && I2C && ACPI
208 select SND_SOC_DA7213
209 select SND_SST_ATOM_HIFI2_PLATFORM
210 select SND_SST_IPC_ACPI
211 select SND_SOC_INTEL_SST_MATCH if ACPI
212 help
213 This adds support for ASoC machine driver for Intel(R) Baytrail & CherryTrail
214 platforms with DA7212/7213 audio codec.
215 If unsure select "N".
216
217config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
218 tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with ES8316 codec"
219 depends on X86_INTEL_LPSS && I2C && ACPI
220 select SND_SOC_ES8316
221 select SND_SST_ATOM_HIFI2_PLATFORM
222 select SND_SST_IPC_ACPI
223 select SND_SOC_INTEL_SST_MATCH if ACPI
224 help
225 This adds support for ASoC machine driver for Intel(R) Baytrail &
226 Cherrytrail platforms with ES8316 audio codec.
227 If unsure select "N".
228
229config SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH
230 tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail platform with no codec (MinnowBoard MAX, Up)"
231 depends on X86_INTEL_LPSS && I2C && ACPI
232 select SND_SST_ATOM_HIFI2_PLATFORM
233 select SND_SST_IPC_ACPI
234 select SND_SOC_INTEL_SST_MATCH if ACPI
235 help
236 This adds support for ASoC machine driver for the MinnowBoard Max or
237 Up boards and provides access to I2S signals on the Low-Speed
238 connector
239 If unsure select "N".
240
241config SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH
242 tristate "ASoC Audio driver for KBL with RT5663 and MAX98927 in I2S Mode"
243 depends on X86_INTEL_LPSS && I2C
244 select SND_SOC_INTEL_SST 49 select SND_SOC_INTEL_SST
245 select SND_SOC_INTEL_SKYLAKE 50 select SND_SOC_INTEL_SST_FIRMWARE
246 select SND_SOC_RT5663
247 select SND_SOC_MAX98927
248 select SND_SOC_DMIC
249 select SND_SOC_HDAC_HDMI
250 help
251 This adds support for ASoC Onboard Codec I2S machine driver. This will
252 create an alsa sound card for RT5663 + MAX98927.
253 Say Y if you have such a device.
254 If unsure select "N".
255 51
256config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH 52config SND_SST_ATOM_HIFI2_PLATFORM
257 tristate "ASoC Audio driver for KBL with RT5663, RT5514 and MAX98927 in I2S Mode" 53 tristate "Intel ASoC SST driver for HiFi2 platforms (*field, *trail)"
258 depends on X86_INTEL_LPSS && I2C && SPI 54 depends on SND_SOC_INTEL_SST_TOPLEVEL && X86
259 select SND_SOC_INTEL_SST 55 select SND_SOC_COMPRESS
260 select SND_SOC_INTEL_SKYLAKE
261 select SND_SOC_RT5663
262 select SND_SOC_RT5514
263 select SND_SOC_RT5514_SPI
264 select SND_SOC_MAX98927
265 select SND_SOC_HDAC_HDMI
266 help
267 This adds support for ASoC Onboard Codec I2S machine driver. This will
268 create an alsa sound card for RT5663 + RT5514 + MAX98927.
269 Say Y if you have such a device.
270 If unsure select "N".
271 56
272config SND_SOC_INTEL_SKYLAKE 57config SND_SOC_INTEL_SKYLAKE
273 tristate 58 tristate "Intel ASoC SST driver for SKL/BXT/KBL/GLK/CNL"
59 depends on SND_SOC_INTEL_SST_TOPLEVEL && PCI && ACPI
274 select SND_HDA_EXT_CORE 60 select SND_HDA_EXT_CORE
275 select SND_HDA_DSP_LOADER 61 select SND_HDA_DSP_LOADER
276 select SND_SOC_TOPOLOGY 62 select SND_SOC_TOPOLOGY
277 select SND_SOC_INTEL_SST 63 select SND_SOC_INTEL_SST
278 64
279config SND_SOC_INTEL_SKL_RT286_MACH 65# ASoC codec drivers
280 tristate "ASoC Audio driver for SKL with RT286 I2S mode" 66source "sound/soc/intel/boards/Kconfig"
281 depends on X86 && ACPI && I2C
282 select SND_SOC_INTEL_SKYLAKE
283 select SND_SOC_RT286
284 select SND_SOC_DMIC
285 select SND_SOC_HDAC_HDMI
286 help
287 This adds support for ASoC machine driver for Skylake platforms
288 with RT286 I2S audio codec.
289 Say Y if you have such a device.
290 If unsure select "N".
291
292config SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH
293 tristate "ASoC Audio driver for SKL with NAU88L25 and SSM4567 in I2S Mode"
294 depends on X86_INTEL_LPSS && I2C
295 select SND_SOC_INTEL_SKYLAKE
296 select SND_SOC_NAU8825
297 select SND_SOC_SSM4567
298 select SND_SOC_DMIC
299 select SND_SOC_HDAC_HDMI
300 help
301 This adds support for ASoC Onboard Codec I2S machine driver. This will
302 create an alsa sound card for NAU88L25 + SSM4567.
303 Say Y if you have such a device.
304 If unsure select "N".
305
306config SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH
307 tristate "ASoC Audio driver for SKL with NAU88L25 and MAX98357A in I2S Mode"
308 depends on X86_INTEL_LPSS && I2C
309 select SND_SOC_INTEL_SKYLAKE
310 select SND_SOC_NAU8825
311 select SND_SOC_MAX98357A
312 select SND_SOC_DMIC
313 select SND_SOC_HDAC_HDMI
314 help
315 This adds support for ASoC Onboard Codec I2S machine driver. This will
316 create an alsa sound card for NAU88L25 + MAX98357A.
317 Say Y if you have such a device.
318 If unsure select "N".
diff --git a/sound/soc/intel/Makefile b/sound/soc/intel/Makefile
index 62f37ffffdf0..b973d457e834 100644
--- a/sound/soc/intel/Makefile
+++ b/sound/soc/intel/Makefile
@@ -1,6 +1,6 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2# Core support 2# Core support
3obj-$(CONFIG_SND_SOC_INTEL_SST) += common/ 3obj-$(CONFIG_SND_SOC_INTEL_COMMON) += common/
4 4
5# Platform Support 5# Platform Support
6obj-$(CONFIG_SND_SOC_INTEL_HASWELL) += haswell/ 6obj-$(CONFIG_SND_SOC_INTEL_HASWELL) += haswell/
diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c
index 1bead81bb510..1dbcab5a6ff0 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-compress.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c
@@ -259,7 +259,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream,
259 return stream->compr_ops->set_metadata(sst->dev, stream->id, metadata); 259 return stream->compr_ops->set_metadata(sst->dev, stream->id, metadata);
260} 260}
261 261
262struct snd_compr_ops sst_platform_compr_ops = { 262const struct snd_compr_ops sst_platform_compr_ops = {
263 263
264 .open = sst_platform_compr_open, 264 .open = sst_platform_compr_open,
265 .free = sst_platform_compr_free, 265 .free = sst_platform_compr_free,
diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h
index cb32cc7e5ec1..31a58c25472c 100644
--- a/sound/soc/intel/atom/sst-mfld-platform.h
+++ b/sound/soc/intel/atom/sst-mfld-platform.h
@@ -25,7 +25,7 @@
25#include "sst-atom-controls.h" 25#include "sst-atom-controls.h"
26 26
27extern struct sst_device *sst; 27extern struct sst_device *sst;
28extern struct snd_compr_ops sst_platform_compr_ops; 28extern const struct snd_compr_ops sst_platform_compr_ops;
29 29
30#define SST_MONO 1 30#define SST_MONO 1
31#define SST_STEREO 2 31#define SST_STEREO 2
diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c
index 0e928d54305d..32d6e02e2104 100644
--- a/sound/soc/intel/atom/sst/sst_acpi.c
+++ b/sound/soc/intel/atom/sst/sst_acpi.c
@@ -23,7 +23,6 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/miscdevice.h>
27#include <linux/platform_device.h> 26#include <linux/platform_device.h>
28#include <linux/firmware.h> 27#include <linux/firmware.h>
29#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
@@ -41,9 +40,10 @@
41#include <acpi/acpi_bus.h> 40#include <acpi/acpi_bus.h>
42#include <asm/cpu_device_id.h> 41#include <asm/cpu_device_id.h>
43#include <asm/iosf_mbi.h> 42#include <asm/iosf_mbi.h>
43#include <sound/soc-acpi.h>
44#include <sound/soc-acpi-intel-match.h>
44#include "../sst-mfld-platform.h" 45#include "../sst-mfld-platform.h"
45#include "../../common/sst-dsp.h" 46#include "../../common/sst-dsp.h"
46#include "../../common/sst-acpi.h"
47#include "sst.h" 47#include "sst.h"
48 48
49/* LPE viewpoint addresses */ 49/* LPE viewpoint addresses */
@@ -239,19 +239,26 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)
239 return 0; 239 return 0;
240} 240}
241 241
242static int is_byt(void)
243{
244 bool status = false;
245 static const struct x86_cpu_id cpu_ids[] = {
246 { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
247 {}
248 };
249 if (x86_match_cpu(cpu_ids))
250 status = true;
251 return status;
252}
242 253
243static int is_byt_cr(struct device *dev, bool *bytcr) 254static int is_byt_cr(struct device *dev, bool *bytcr)
244{ 255{
245 int status = 0; 256 int status = 0;
246 257
247 if (IS_ENABLED(CONFIG_IOSF_MBI)) { 258 if (IS_ENABLED(CONFIG_IOSF_MBI)) {
248 static const struct x86_cpu_id cpu_ids[] = {
249 { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
250 {}
251 };
252 u32 bios_status; 259 u32 bios_status;
253 260
254 if (!x86_match_cpu(cpu_ids) || !iosf_mbi_available()) { 261 if (!is_byt() || !iosf_mbi_available()) {
255 /* bail silently */ 262 /* bail silently */
256 return status; 263 return status;
257 } 264 }
@@ -285,7 +292,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
285 int ret = 0; 292 int ret = 0;
286 struct intel_sst_drv *ctx; 293 struct intel_sst_drv *ctx;
287 const struct acpi_device_id *id; 294 const struct acpi_device_id *id;
288 struct sst_acpi_mach *mach; 295 struct snd_soc_acpi_mach *mach;
289 struct platform_device *mdev; 296 struct platform_device *mdev;
290 struct platform_device *plat_dev; 297 struct platform_device *plat_dev;
291 struct sst_platform_info *pdata; 298 struct sst_platform_info *pdata;
@@ -297,13 +304,17 @@ static int sst_acpi_probe(struct platform_device *pdev)
297 return -ENODEV; 304 return -ENODEV;
298 dev_dbg(dev, "for %s\n", id->id); 305 dev_dbg(dev, "for %s\n", id->id);
299 306
300 mach = (struct sst_acpi_mach *)id->driver_data; 307 mach = (struct snd_soc_acpi_mach *)id->driver_data;
301 mach = sst_acpi_find_machine(mach); 308 mach = snd_soc_acpi_find_machine(mach);
302 if (mach == NULL) { 309 if (mach == NULL) {
303 dev_err(dev, "No matching machine driver found\n"); 310 dev_err(dev, "No matching machine driver found\n");
304 return -ENODEV; 311 return -ENODEV;
305 } 312 }
306 313
314 if (is_byt())
315 mach->pdata = &byt_rvp_platform_data;
316 else
317 mach->pdata = &chv_platform_data;
307 pdata = mach->pdata; 318 pdata = mach->pdata;
308 319
309 ret = kstrtouint(id->id, 16, &dev_id); 320 ret = kstrtouint(id->id, 16, &dev_id);
@@ -381,286 +392,9 @@ static int sst_acpi_remove(struct platform_device *pdev)
381 return 0; 392 return 0;
382} 393}
383 394
384static unsigned long cht_machine_id;
385
386#define CHT_SURFACE_MACH 1
387#define BYT_THINKPAD_10 2
388
389static int cht_surface_quirk_cb(const struct dmi_system_id *id)
390{
391 cht_machine_id = CHT_SURFACE_MACH;
392 return 1;
393}
394
395static int byt_thinkpad10_quirk_cb(const struct dmi_system_id *id)
396{
397 cht_machine_id = BYT_THINKPAD_10;
398 return 1;
399}
400
401
402static const struct dmi_system_id byt_table[] = {
403 {
404 .callback = byt_thinkpad10_quirk_cb,
405 .matches = {
406 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
407 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 10"),
408 },
409 },
410 {
411 .callback = byt_thinkpad10_quirk_cb,
412 .matches = {
413 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
414 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Tablet B"),
415 },
416 },
417 {
418 .callback = byt_thinkpad10_quirk_cb,
419 .matches = {
420 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
421 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"),
422 },
423 },
424 { }
425};
426
427static const struct dmi_system_id cht_table[] = {
428 {
429 .callback = cht_surface_quirk_cb,
430 .matches = {
431 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
432 DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
433 },
434 },
435 { }
436};
437
438
439static struct sst_acpi_mach cht_surface_mach = {
440 .id = "10EC5640",
441 .drv_name = "cht-bsw-rt5645",
442 .fw_filename = "intel/fw_sst_22a8.bin",
443 .board = "cht-bsw",
444 .pdata = &chv_platform_data,
445};
446
447static struct sst_acpi_mach byt_thinkpad_10 = {
448 .id = "10EC5640",
449 .drv_name = "cht-bsw-rt5672",
450 .fw_filename = "intel/fw_sst_0f28.bin",
451 .board = "cht-bsw",
452 .pdata = &byt_rvp_platform_data,
453};
454
455static struct sst_acpi_mach *cht_quirk(void *arg)
456{
457 struct sst_acpi_mach *mach = arg;
458
459 dmi_check_system(cht_table);
460
461 if (cht_machine_id == CHT_SURFACE_MACH)
462 return &cht_surface_mach;
463 else
464 return mach;
465}
466
467static struct sst_acpi_mach *byt_quirk(void *arg)
468{
469 struct sst_acpi_mach *mach = arg;
470
471 dmi_check_system(byt_table);
472
473 if (cht_machine_id == BYT_THINKPAD_10)
474 return &byt_thinkpad_10;
475 else
476 return mach;
477}
478
479
480static struct sst_acpi_mach sst_acpi_bytcr[] = {
481 {
482 .id = "10EC5640",
483 .drv_name = "bytcr_rt5640",
484 .fw_filename = "intel/fw_sst_0f28.bin",
485 .board = "bytcr_rt5640",
486 .machine_quirk = byt_quirk,
487 .pdata = &byt_rvp_platform_data,
488 },
489 {
490 .id = "10EC5642",
491 .drv_name = "bytcr_rt5640",
492 .fw_filename = "intel/fw_sst_0f28.bin",
493 .board = "bytcr_rt5640",
494 .pdata = &byt_rvp_platform_data
495 },
496 {
497 .id = "INTCCFFD",
498 .drv_name = "bytcr_rt5640",
499 .fw_filename = "intel/fw_sst_0f28.bin",
500 .board = "bytcr_rt5640",
501 .pdata = &byt_rvp_platform_data
502 },
503 {
504 .id = "10EC5651",
505 .drv_name = "bytcr_rt5651",
506 .fw_filename = "intel/fw_sst_0f28.bin",
507 .board = "bytcr_rt5651",
508 .pdata = &byt_rvp_platform_data
509 },
510 {
511 .id = "DLGS7212",
512 .drv_name = "bytcht_da7213",
513 .fw_filename = "intel/fw_sst_0f28.bin",
514 .board = "bytcht_da7213",
515 .pdata = &byt_rvp_platform_data
516 },
517 {
518 .id = "DLGS7213",
519 .drv_name = "bytcht_da7213",
520 .fw_filename = "intel/fw_sst_0f28.bin",
521 .board = "bytcht_da7213",
522 .pdata = &byt_rvp_platform_data
523 },
524 /* some Baytrail platforms rely on RT5645, use CHT machine driver */
525 {
526 .id = "10EC5645",
527 .drv_name = "cht-bsw-rt5645",
528 .fw_filename = "intel/fw_sst_0f28.bin",
529 .board = "cht-bsw",
530 .pdata = &byt_rvp_platform_data
531 },
532 {
533 .id = "10EC5648",
534 .drv_name = "cht-bsw-rt5645",
535 .fw_filename = "intel/fw_sst_0f28.bin",
536 .board = "cht-bsw",
537 .pdata = &byt_rvp_platform_data
538 },
539#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
540 /*
541 * This is always last in the table so that it is selected only when
542 * enabled explicitly and there is no codec-related information in SSDT
543 */
544 {
545 .id = "80860F28",
546 .drv_name = "bytcht_nocodec",
547 .fw_filename = "intel/fw_sst_0f28.bin",
548 .board = "bytcht_nocodec",
549 .pdata = &byt_rvp_platform_data
550 },
551#endif
552 {},
553};
554
555/* Cherryview-based platforms: CherryTrail and Braswell */
556static struct sst_acpi_mach sst_acpi_chv[] = {
557 {
558 .id = "10EC5670",
559 .drv_name = "cht-bsw-rt5672",
560 .fw_filename = "intel/fw_sst_22a8.bin",
561 .board = "cht-bsw",
562 .pdata = &chv_platform_data
563 },
564 {
565 .id = "10EC5672",
566 .drv_name = "cht-bsw-rt5672",
567 .fw_filename = "intel/fw_sst_22a8.bin",
568 .board = "cht-bsw",
569 .pdata = &chv_platform_data
570 },
571 {
572 .id = "10EC5645",
573 .drv_name = "cht-bsw-rt5645",
574 .fw_filename = "intel/fw_sst_22a8.bin",
575 .board = "cht-bsw",
576 .pdata = &chv_platform_data
577 },
578 {
579 .id = "10EC5650",
580 .drv_name = "cht-bsw-rt5645",
581 .fw_filename = "intel/fw_sst_22a8.bin",
582 .board = "cht-bsw",
583 .pdata = &chv_platform_data
584 },
585 {
586 .id = "10EC3270",
587 .drv_name = "cht-bsw-rt5645",
588 .fw_filename = "intel/fw_sst_22a8.bin",
589 .board = "cht-bsw",
590 .pdata = &chv_platform_data
591 },
592
593 {
594 .id = "193C9890",
595 .drv_name = "cht-bsw-max98090",
596 .fw_filename = "intel/fw_sst_22a8.bin",
597 .board = "cht-bsw",
598 .pdata = &chv_platform_data
599 },
600 {
601 .id = "DLGS7212",
602 .drv_name = "bytcht_da7213",
603 .fw_filename = "intel/fw_sst_22a8.bin",
604 .board = "bytcht_da7213",
605 .pdata = &chv_platform_data
606 },
607 {
608 .id = "DLGS7213",
609 .drv_name = "bytcht_da7213",
610 .fw_filename = "intel/fw_sst_22a8.bin",
611 .board = "bytcht_da7213",
612 .pdata = &chv_platform_data
613 },
614 {
615 .id = "ESSX8316",
616 .drv_name = "bytcht_es8316",
617 .fw_filename = "intel/fw_sst_22a8.bin",
618 .board = "bytcht_es8316",
619 .pdata = &chv_platform_data
620 },
621 /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
622 {
623 .id = "10EC5640",
624 .drv_name = "bytcr_rt5640",
625 .fw_filename = "intel/fw_sst_22a8.bin",
626 .board = "bytcr_rt5640",
627 .machine_quirk = cht_quirk,
628 .pdata = &chv_platform_data
629 },
630 {
631 .id = "10EC3276",
632 .drv_name = "bytcr_rt5640",
633 .fw_filename = "intel/fw_sst_22a8.bin",
634 .board = "bytcr_rt5640",
635 .pdata = &chv_platform_data
636 },
637 /* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
638 {
639 .id = "10EC5651",
640 .drv_name = "bytcr_rt5651",
641 .fw_filename = "intel/fw_sst_22a8.bin",
642 .board = "bytcr_rt5651",
643 .pdata = &chv_platform_data
644 },
645#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
646 /*
647 * This is always last in the table so that it is selected only when
648 * enabled explicitly and there is no codec-related information in SSDT
649 */
650 {
651 .id = "808622A8",
652 .drv_name = "bytcht_nocodec",
653 .fw_filename = "intel/fw_sst_22a8.bin",
654 .board = "bytcht_nocodec",
655 .pdata = &chv_platform_data
656 },
657#endif
658 {},
659};
660
661static const struct acpi_device_id sst_acpi_ids[] = { 395static const struct acpi_device_id sst_acpi_ids[] = {
662 { "80860F28", (unsigned long)&sst_acpi_bytcr}, 396 { "80860F28", (unsigned long)&snd_soc_acpi_intel_baytrail_machines},
663 { "808622A8", (unsigned long) &sst_acpi_chv}, 397 { "808622A8", (unsigned long)&snd_soc_acpi_intel_cherrytrail_machines},
664 { }, 398 { },
665}; 399};
666 400
diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
index 33917146d9c4..a686eef2cf7f 100644
--- a/sound/soc/intel/atom/sst/sst_loader.c
+++ b/sound/soc/intel/atom/sst/sst_loader.c
@@ -415,7 +415,6 @@ int sst_load_fw(struct intel_sst_drv *sst_drv_ctx)
415 return ret_val; 415 return ret_val;
416 } 416 }
417 417
418 BUG_ON(!sst_drv_ctx->fw_in_mem);
419 block = sst_create_block(sst_drv_ctx, 0, FW_DWNL_ID); 418 block = sst_create_block(sst_drv_ctx, 0, FW_DWNL_ID);
420 if (block == NULL) 419 if (block == NULL)
421 return -ENOMEM; 420 return -ENOMEM;
diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c
index 83d8dda15233..65e257b17a7e 100644
--- a/sound/soc/intel/atom/sst/sst_stream.c
+++ b/sound/soc/intel/atom/sst/sst_stream.c
@@ -45,7 +45,6 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params)
45 void *data = NULL; 45 void *data = NULL;
46 46
47 dev_dbg(sst_drv_ctx->dev, "Enter\n"); 47 dev_dbg(sst_drv_ctx->dev, "Enter\n");
48 BUG_ON(!params);
49 48
50 str_params = (struct snd_sst_params *)params; 49 str_params = (struct snd_sst_params *)params;
51 memset(&alloc_param, 0, sizeof(alloc_param)); 50 memset(&alloc_param, 0, sizeof(alloc_param));
diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
new file mode 100644
index 000000000000..6f754708a48c
--- /dev/null
+++ b/sound/soc/intel/boards/Kconfig
@@ -0,0 +1,265 @@
1config SND_SOC_INTEL_MACH
2 tristate "Intel Audio machine drivers"
3 depends on SND_SOC_INTEL_SST_TOPLEVEL
4 select SND_SOC_ACPI_INTEL_MATCH if ACPI
5
6if SND_SOC_INTEL_MACH
7
8config SND_MFLD_MACHINE
9 tristate "SOC Machine Audio driver for Intel Medfield MID platform"
10 depends on INTEL_SCU_IPC
11 select SND_SOC_SN95031
12 depends on SND_SST_ATOM_HIFI2_PLATFORM
13 select SND_SST_IPC_PCI
14 help
15 This adds support for ASoC machine driver for Intel(R) MID Medfield platform
16 used as alsa device in audio substem in Intel(R) MID devices
17 Say Y if you have such a device.
18 If unsure select "N".
19
20config SND_SOC_INTEL_HASWELL_MACH
21 tristate "ASoC Audio DSP support for Intel Haswell Lynxpoint"
22 depends on X86_INTEL_LPSS && I2C && I2C_DESIGNWARE_PLATFORM
23 depends on SND_SOC_INTEL_HASWELL
24 select SND_SOC_RT5640
25 help
26 This adds support for the Lynxpoint Audio DSP on Intel(R) Haswell
27 Ultrabook platforms.
28 Say Y if you have such a device.
29 If unsure select "N".
30
31config SND_SOC_INTEL_BDW_RT5677_MACH
32 tristate "ASoC Audio driver for Intel Broadwell with RT5677 codec"
33 depends on X86_INTEL_LPSS && GPIOLIB && I2C
34 depends on SND_SOC_INTEL_HASWELL
35 select SND_SOC_RT5677
36 help
37 This adds support for Intel Broadwell platform based boards with
38 the RT5677 audio codec.
39
40config SND_SOC_INTEL_BROADWELL_MACH
41 tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint"
42 depends on X86_INTEL_LPSS && I2C && I2C_DESIGNWARE_PLATFORM
43 depends on SND_SOC_INTEL_HASWELL
44 select SND_SOC_RT286
45 help
46 This adds support for the Wilcatpoint Audio DSP on Intel(R) Broadwell
47 Ultrabook platforms.
48 Say Y if you have such a device.
49 If unsure select "N".
50
51config SND_SOC_INTEL_BYT_MAX98090_MACH
52 tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec"
53 depends on X86_INTEL_LPSS && I2C
54 depends on SND_SST_IPC_ACPI = n
55 depends on SND_SOC_INTEL_BAYTRAIL
56 select SND_SOC_MAX98090
57 help
58 This adds audio driver for Intel Baytrail platform based boards
59 with the MAX98090 audio codec.
60
61config SND_SOC_INTEL_BYT_RT5640_MACH
62 tristate "ASoC Audio driver for Intel Baytrail with RT5640 codec"
63 depends on X86_INTEL_LPSS && I2C
64 depends on SND_SST_IPC_ACPI = n
65 depends on SND_SOC_INTEL_BAYTRAIL
66 select SND_SOC_RT5640
67 help
68 This adds audio driver for Intel Baytrail platform based boards
69 with the RT5640 audio codec. This driver is deprecated, use
70 SND_SOC_INTEL_BYTCR_RT5640_MACH instead for better functionality.
71
72config SND_SOC_INTEL_BYTCR_RT5640_MACH
73 tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with RT5640 codec"
74 depends on X86 && I2C && ACPI
75 select SND_SOC_RT5640
76 depends on SND_SST_ATOM_HIFI2_PLATFORM
77 select SND_SST_IPC_ACPI
78 help
79 This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
80 platforms with RT5640 audio codec.
81 Say Y if you have such a device.
82 If unsure select "N".
83
84config SND_SOC_INTEL_BYTCR_RT5651_MACH
85 tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with RT5651 codec"
86 depends on X86 && I2C && ACPI
87 select SND_SOC_RT5651
88 depends on SND_SST_ATOM_HIFI2_PLATFORM
89 select SND_SST_IPC_ACPI
90 help
91 This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
92 platforms with RT5651 audio codec.
93 Say Y if you have such a device.
94 If unsure select "N".
95
96config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
97 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec"
98 depends on X86_INTEL_LPSS && I2C && ACPI
99 select SND_SOC_RT5670
100 depends on SND_SST_ATOM_HIFI2_PLATFORM
101 select SND_SST_IPC_ACPI
102 help
103 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
104 platforms with RT5672 audio codec.
105 Say Y if you have such a device.
106 If unsure select "N".
107
108config SND_SOC_INTEL_CHT_BSW_RT5645_MACH
109 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5645/5650 codec"
110 depends on X86_INTEL_LPSS && I2C && ACPI
111 select SND_SOC_RT5645
112 depends on SND_SST_ATOM_HIFI2_PLATFORM
113 select SND_SST_IPC_ACPI
114 help
115 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
116 platforms with RT5645/5650 audio codec.
117 If unsure select "N".
118
119config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH
120 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with MAX98090 & TI codec"
121 depends on X86_INTEL_LPSS && I2C && ACPI
122 select SND_SOC_MAX98090
123 select SND_SOC_TS3A227E
124 depends on SND_SST_ATOM_HIFI2_PLATFORM
125 select SND_SST_IPC_ACPI
126 help
127 This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
128 platforms with MAX98090 audio codec it also can support TI jack chip as aux device.
129 If unsure select "N".
130
131config SND_SOC_INTEL_BYT_CHT_DA7213_MACH
132 tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with DA7212/7213 codec"
133 depends on X86_INTEL_LPSS && I2C && ACPI
134 select SND_SOC_DA7213
135 depends on SND_SST_ATOM_HIFI2_PLATFORM
136 select SND_SST_IPC_ACPI
137 help
138 This adds support for ASoC machine driver for Intel(R) Baytrail & CherryTrail
139 platforms with DA7212/7213 audio codec.
140 If unsure select "N".
141
142config SND_SOC_INTEL_BYT_CHT_ES8316_MACH
143 tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with ES8316 codec"
144 depends on X86_INTEL_LPSS && I2C && ACPI
145 select SND_SOC_ES8316
146 depends on SND_SST_ATOM_HIFI2_PLATFORM
147 select SND_SST_IPC_ACPI
148 help
149 This adds support for ASoC machine driver for Intel(R) Baytrail &
150 Cherrytrail platforms with ES8316 audio codec.
151 If unsure select "N".
152
153config SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH
154 tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail platform with no codec (MinnowBoard MAX, Up)"
155 depends on X86_INTEL_LPSS && I2C && ACPI
156 depends on SND_SST_ATOM_HIFI2_PLATFORM
157 select SND_SST_IPC_ACPI
158 help
159 This adds support for ASoC machine driver for the MinnowBoard Max or
160 Up boards and provides access to I2S signals on the Low-Speed
161 connector
162 If unsure select "N".
163
164config SND_SOC_INTEL_SKL_RT286_MACH
165 tristate "ASoC Audio driver for SKL with RT286 I2S mode"
166 depends on X86 && ACPI && I2C
167 depends on SND_SOC_INTEL_SKYLAKE
168 select SND_SOC_RT286
169 select SND_SOC_DMIC
170 select SND_SOC_HDAC_HDMI
171 help
172 This adds support for ASoC machine driver for Skylake platforms
173 with RT286 I2S audio codec.
174 Say Y if you have such a device.
175 If unsure select "N".
176
177config SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH
178 tristate "ASoC Audio driver for SKL with NAU88L25 and SSM4567 in I2S Mode"
179 depends on X86_INTEL_LPSS && I2C
180 depends on SND_SOC_INTEL_SKYLAKE
181 select SND_SOC_NAU8825
182 select SND_SOC_SSM4567
183 select SND_SOC_DMIC
184 select SND_SOC_HDAC_HDMI
185 help
186 This adds support for ASoC Onboard Codec I2S machine driver. This will
187 create an alsa sound card for NAU88L25 + SSM4567.
188 Say Y if you have such a device.
189 If unsure select "N".
190
191config SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH
192 tristate "ASoC Audio driver for SKL with NAU88L25 and MAX98357A in I2S Mode"
193 depends on X86_INTEL_LPSS && I2C
194 depends on SND_SOC_INTEL_SKYLAKE
195 select SND_SOC_NAU8825
196 select SND_SOC_MAX98357A
197 select SND_SOC_DMIC
198 select SND_SOC_HDAC_HDMI
199 help
200 This adds support for ASoC Onboard Codec I2S machine driver. This will
201 create an alsa sound card for NAU88L25 + MAX98357A.
202 Say Y if you have such a device.
203 If unsure select "N".
204
205config SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH
206 tristate "ASoC Audio driver for Broxton with DA7219 and MAX98357A in I2S Mode"
207 depends on X86 && ACPI && I2C
208 depends on SND_SOC_INTEL_SKYLAKE
209 select SND_SOC_DA7219
210 select SND_SOC_MAX98357A
211 select SND_SOC_DMIC
212 select SND_SOC_HDAC_HDMI
213 select SND_HDA_DSP_LOADER
214 help
215 This adds support for ASoC machine driver for Broxton-P platforms
216 with DA7219 + MAX98357A I2S audio codec.
217 Say Y if you have such a device.
218 If unsure select "N".
219
220config SND_SOC_INTEL_BXT_RT298_MACH
221 tristate "ASoC Audio driver for Broxton with RT298 I2S mode"
222 depends on X86 && ACPI && I2C
223 depends on SND_SOC_INTEL_SKYLAKE
224 select SND_SOC_RT298
225 select SND_SOC_DMIC
226 select SND_SOC_HDAC_HDMI
227 select SND_HDA_DSP_LOADER
228 help
229 This adds support for ASoC machine driver for Broxton platforms
230 with RT286 I2S audio codec.
231 Say Y if you have such a device.
232 If unsure select "N".
233
234config SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH
235 tristate "ASoC Audio driver for KBL with RT5663 and MAX98927 in I2S Mode"
236 depends on X86_INTEL_LPSS && I2C
237 select SND_SOC_INTEL_SST
238 depends on SND_SOC_INTEL_SKYLAKE
239 select SND_SOC_RT5663
240 select SND_SOC_MAX98927
241 select SND_SOC_DMIC
242 select SND_SOC_HDAC_HDMI
243 help
244 This adds support for ASoC Onboard Codec I2S machine driver. This will
245 create an alsa sound card for RT5663 + MAX98927.
246 Say Y if you have such a device.
247 If unsure select "N".
248
249config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH
250 tristate "ASoC Audio driver for KBL with RT5663, RT5514 and MAX98927 in I2S Mode"
251 depends on X86_INTEL_LPSS && I2C && SPI
252 select SND_SOC_INTEL_SST
253 depends on SND_SOC_INTEL_SKYLAKE
254 select SND_SOC_RT5663
255 select SND_SOC_RT5514
256 select SND_SOC_RT5514_SPI
257 select SND_SOC_MAX98927
258 select SND_SOC_HDAC_HDMI
259 help
260 This adds support for ASoC Onboard Codec I2S machine driver. This will
261 create an alsa sound card for RT5663 + RT5514 + MAX98927.
262 Say Y if you have such a device.
263 If unsure select "N".
264
265endif
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index ce35ec7884d1..f8a91a6f2a17 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -55,20 +55,6 @@ enum {
55 BXT_DPCM_AUDIO_HDMI3_PB, 55 BXT_DPCM_AUDIO_HDMI3_PB,
56}; 56};
57 57
58static inline struct snd_soc_dai *bxt_get_codec_dai(struct snd_soc_card *card)
59{
60 struct snd_soc_pcm_runtime *rtd;
61
62 list_for_each_entry(rtd, &card->rtd_list, list) {
63
64 if (!strncmp(rtd->codec_dai->name, BXT_DIALOG_CODEC_DAI,
65 strlen(BXT_DIALOG_CODEC_DAI)))
66 return rtd->codec_dai;
67 }
68
69 return NULL;
70}
71
72static int platform_clock_control(struct snd_soc_dapm_widget *w, 58static int platform_clock_control(struct snd_soc_dapm_widget *w,
73 struct snd_kcontrol *k, int event) 59 struct snd_kcontrol *k, int event)
74{ 60{
@@ -77,7 +63,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
77 struct snd_soc_card *card = dapm->card; 63 struct snd_soc_card *card = dapm->card;
78 struct snd_soc_dai *codec_dai; 64 struct snd_soc_dai *codec_dai;
79 65
80 codec_dai = bxt_get_codec_dai(card); 66 codec_dai = snd_soc_card_get_codec_dai(card, BXT_DIALOG_CODEC_DAI);
81 if (!codec_dai) { 67 if (!codec_dai) {
82 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); 68 dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n");
83 return -EIO; 69 return -EIO;
diff --git a/sound/soc/intel/boards/bytcht_da7213.c b/sound/soc/intel/boards/bytcht_da7213.c
index 18873e23f404..c4d82ad41bd7 100644
--- a/sound/soc/intel/boards/bytcht_da7213.c
+++ b/sound/soc/intel/boards/bytcht_da7213.c
@@ -27,9 +27,9 @@
27#include <sound/pcm.h> 27#include <sound/pcm.h>
28#include <sound/pcm_params.h> 28#include <sound/pcm_params.h>
29#include <sound/soc.h> 29#include <sound/soc.h>
30#include <sound/soc-acpi.h>
30#include "../../codecs/da7213.h" 31#include "../../codecs/da7213.h"
31#include "../atom/sst-atom-controls.h" 32#include "../atom/sst-atom-controls.h"
32#include "../common/sst-acpi.h"
33 33
34static const struct snd_kcontrol_new controls[] = { 34static const struct snd_kcontrol_new controls[] = {
35 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 35 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
@@ -185,19 +185,11 @@ static struct snd_soc_dai_link dailink[] = {
185 .dpcm_playback = 1, 185 .dpcm_playback = 1,
186 .ops = &aif1_ops, 186 .ops = &aif1_ops,
187 }, 187 },
188 [MERR_DPCM_COMPR] = {
189 .name = "Compressed Port",
190 .stream_name = "Compress",
191 .cpu_dai_name = "compress-cpu-dai",
192 .codec_dai_name = "snd-soc-dummy-dai",
193 .codec_name = "snd-soc-dummy",
194 .platform_name = "sst-mfld-platform",
195 },
196 /* CODEC<->CODEC link */ 188 /* CODEC<->CODEC link */
197 /* back ends */ 189 /* back ends */
198 { 190 {
199 .name = "SSP2-Codec", 191 .name = "SSP2-Codec",
200 .id = 1, 192 .id = 0,
201 .cpu_dai_name = "ssp2-port", 193 .cpu_dai_name = "ssp2-port",
202 .platform_name = "sst-mfld-platform", 194 .platform_name = "sst-mfld-platform",
203 .no_pcm = 1, 195 .no_pcm = 1,
@@ -231,19 +223,18 @@ static char codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
231 223
232static int bytcht_da7213_probe(struct platform_device *pdev) 224static int bytcht_da7213_probe(struct platform_device *pdev)
233{ 225{
234 int ret_val = 0;
235 int i;
236 struct snd_soc_card *card; 226 struct snd_soc_card *card;
237 struct sst_acpi_mach *mach; 227 struct snd_soc_acpi_mach *mach;
238 const char *i2c_name = NULL; 228 const char *i2c_name = NULL;
239 int dai_index = 0; 229 int dai_index = 0;
230 int ret_val = 0;
231 int i;
240 232
241 mach = (&pdev->dev)->platform_data; 233 mach = (&pdev->dev)->platform_data;
242 card = &bytcht_da7213_card; 234 card = &bytcht_da7213_card;
243 card->dev = &pdev->dev; 235 card->dev = &pdev->dev;
244 236
245 /* fix index of codec dai */ 237 /* fix index of codec dai */
246 dai_index = MERR_DPCM_COMPR + 1;
247 for (i = 0; i < ARRAY_SIZE(dailink); i++) { 238 for (i = 0; i < ARRAY_SIZE(dailink); i++) {
248 if (!strcmp(dailink[i].codec_name, "i2c-DLGS7213:00")) { 239 if (!strcmp(dailink[i].codec_name, "i2c-DLGS7213:00")) {
249 dai_index = i; 240 dai_index = i;
@@ -252,8 +243,8 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
252 } 243 }
253 244
254 /* fixup codec name based on HID */ 245 /* fixup codec name based on HID */
255 i2c_name = sst_acpi_find_name_from_hid(mach->id); 246 i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
256 if (i2c_name != NULL) { 247 if (i2c_name) {
257 snprintf(codec_name, sizeof(codec_name), 248 snprintf(codec_name, sizeof(codec_name),
258 "%s%s", "i2c-", i2c_name); 249 "%s%s", "i2c-", i2c_name);
259 dailink[dai_index].codec_name = codec_name; 250 dailink[dai_index].codec_name = codec_name;
diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index 52635462dac6..8088396717e3 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -29,28 +29,14 @@
29#include <sound/pcm.h> 29#include <sound/pcm.h>
30#include <sound/pcm_params.h> 30#include <sound/pcm_params.h>
31#include <sound/soc.h> 31#include <sound/soc.h>
32#include <sound/soc-acpi.h>
32#include "../atom/sst-atom-controls.h" 33#include "../atom/sst-atom-controls.h"
33#include "../common/sst-acpi.h"
34#include "../common/sst-dsp.h" 34#include "../common/sst-dsp.h"
35 35
36struct byt_cht_es8316_private { 36struct byt_cht_es8316_private {
37 struct clk *mclk; 37 struct clk *mclk;
38}; 38};
39 39
40#define CODEC_DAI1 "ES8316 HiFi"
41
42static inline struct snd_soc_dai *get_codec_dai(struct snd_soc_card *card)
43{
44 struct snd_soc_pcm_runtime *rtd;
45
46 list_for_each_entry(rtd, &card->rtd_list, list) {
47 if (!strncmp(rtd->codec_dai->name, CODEC_DAI1,
48 strlen(CODEC_DAI1)))
49 return rtd->codec_dai;
50 }
51 return NULL;
52}
53
54static const struct snd_soc_dapm_widget byt_cht_es8316_widgets[] = { 40static const struct snd_soc_dapm_widget byt_cht_es8316_widgets[] = {
55 SND_SOC_DAPM_HP("Headphone", NULL), 41 SND_SOC_DAPM_HP("Headphone", NULL),
56 42
@@ -208,22 +194,13 @@ static struct snd_soc_dai_link byt_cht_es8316_dais[] = {
208 .ops = &byt_cht_es8316_aif1_ops, 194 .ops = &byt_cht_es8316_aif1_ops,
209 }, 195 },
210 196
211 [MERR_DPCM_COMPR] = {
212 .name = "Compressed Port",
213 .stream_name = "Compress",
214 .cpu_dai_name = "compress-cpu-dai",
215 .codec_dai_name = "snd-soc-dummy-dai",
216 .codec_name = "snd-soc-dummy",
217 .platform_name = "sst-mfld-platform",
218 },
219
220 /* back ends */ 197 /* back ends */
221 { 198 {
222 /* Only SSP2 has been tested here, so BYT-CR platforms that 199 /* Only SSP2 has been tested here, so BYT-CR platforms that
223 * require SSP0 will not work. 200 * require SSP0 will not work.
224 */ 201 */
225 .name = "SSP2-Codec", 202 .name = "SSP2-Codec",
226 .id = 1, 203 .id = 0,
227 .cpu_dai_name = "ssp2-port", 204 .cpu_dai_name = "ssp2-port",
228 .platform_name = "sst-mfld-platform", 205 .platform_name = "sst-mfld-platform",
229 .no_pcm = 1, 206 .no_pcm = 1,
diff --git a/sound/soc/intel/boards/bytcht_nocodec.c b/sound/soc/intel/boards/bytcht_nocodec.c
index 1dd9441806fa..b80ec027a0e8 100644
--- a/sound/soc/intel/boards/bytcht_nocodec.c
+++ b/sound/soc/intel/boards/bytcht_nocodec.c
@@ -133,19 +133,11 @@ static struct snd_soc_dai_link dais[] = {
133 .dpcm_playback = 1, 133 .dpcm_playback = 1,
134 .ops = &aif1_ops, 134 .ops = &aif1_ops,
135 }, 135 },
136 [MERR_DPCM_COMPR] = {
137 .name = "Compressed Port",
138 .stream_name = "Compress",
139 .cpu_dai_name = "compress-cpu-dai",
140 .codec_dai_name = "snd-soc-dummy-dai",
141 .codec_name = "snd-soc-dummy",
142 .platform_name = "sst-mfld-platform",
143 },
144 /* CODEC<->CODEC link */ 136 /* CODEC<->CODEC link */
145 /* back ends */ 137 /* back ends */
146 { 138 {
147 .name = "SSP2-LowSpeed Connector", 139 .name = "SSP2-LowSpeed Connector",
148 .id = 1, 140 .id = 0,
149 .cpu_dai_name = "ssp2-port", 141 .cpu_dai_name = "ssp2-port",
150 .platform_name = "sst-mfld-platform", 142 .platform_name = "sst-mfld-platform",
151 .no_pcm = 1, 143 .no_pcm = 1,
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 4a76b099a508..f2c0fc415e52 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -22,19 +22,19 @@
22#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/acpi.h> 24#include <linux/acpi.h>
25#include <linux/clk.h>
25#include <linux/device.h> 26#include <linux/device.h>
26#include <linux/dmi.h> 27#include <linux/dmi.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <asm/cpu_device_id.h> 29#include <asm/cpu_device_id.h>
29#include <asm/platform_sst_audio.h> 30#include <asm/platform_sst_audio.h>
30#include <linux/clk.h>
31#include <sound/pcm.h> 31#include <sound/pcm.h>
32#include <sound/pcm_params.h> 32#include <sound/pcm_params.h>
33#include <sound/soc.h> 33#include <sound/soc.h>
34#include <sound/jack.h> 34#include <sound/jack.h>
35#include <sound/soc-acpi.h>
35#include "../../codecs/rt5640.h" 36#include "../../codecs/rt5640.h"
36#include "../atom/sst-atom-controls.h" 37#include "../atom/sst-atom-controls.h"
37#include "../common/sst-acpi.h"
38#include "../common/sst-dsp.h" 38#include "../common/sst-dsp.h"
39 39
40enum { 40enum {
@@ -44,13 +44,13 @@ enum {
44 BYT_RT5640_IN3_MAP, 44 BYT_RT5640_IN3_MAP,
45}; 45};
46 46
47#define BYT_RT5640_MAP(quirk) ((quirk) & 0xff) 47#define BYT_RT5640_MAP(quirk) ((quirk) & GENMASK(7, 0))
48#define BYT_RT5640_DMIC_EN BIT(16) 48#define BYT_RT5640_DMIC_EN BIT(16)
49#define BYT_RT5640_MONO_SPEAKER BIT(17) 49#define BYT_RT5640_MONO_SPEAKER BIT(17)
50#define BYT_RT5640_DIFF_MIC BIT(18) /* defaut is single-ended */ 50#define BYT_RT5640_DIFF_MIC BIT(18) /* defaut is single-ended */
51#define BYT_RT5640_SSP2_AIF2 BIT(19) /* default is using AIF1 */ 51#define BYT_RT5640_SSP2_AIF2 BIT(19) /* default is using AIF1 */
52#define BYT_RT5640_SSP0_AIF1 BIT(20) 52#define BYT_RT5640_SSP0_AIF1 BIT(20)
53#define BYT_RT5640_SSP0_AIF2 BIT(21) 53#define BYT_RT5640_SSP0_AIF2 BIT(21)
54#define BYT_RT5640_MCLK_EN BIT(22) 54#define BYT_RT5640_MCLK_EN BIT(22)
55#define BYT_RT5640_MCLK_25MHZ BIT(23) 55#define BYT_RT5640_MCLK_25MHZ BIT(23)
56 56
@@ -145,22 +145,6 @@ static void log_quirks(struct device *dev)
145#define BYT_CODEC_DAI1 "rt5640-aif1" 145#define BYT_CODEC_DAI1 "rt5640-aif1"
146#define BYT_CODEC_DAI2 "rt5640-aif2" 146#define BYT_CODEC_DAI2 "rt5640-aif2"
147 147
148static inline struct snd_soc_dai *byt_get_codec_dai(struct snd_soc_card *card)
149{
150 struct snd_soc_pcm_runtime *rtd;
151
152 list_for_each_entry(rtd, &card->rtd_list, list) {
153 if (!strncmp(rtd->codec_dai->name, BYT_CODEC_DAI1,
154 strlen(BYT_CODEC_DAI1)))
155 return rtd->codec_dai;
156 if (!strncmp(rtd->codec_dai->name, BYT_CODEC_DAI2,
157 strlen(BYT_CODEC_DAI2)))
158 return rtd->codec_dai;
159
160 }
161 return NULL;
162}
163
164static int platform_clock_control(struct snd_soc_dapm_widget *w, 148static int platform_clock_control(struct snd_soc_dapm_widget *w,
165 struct snd_kcontrol *k, int event) 149 struct snd_kcontrol *k, int event)
166{ 150{
@@ -170,7 +154,10 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
170 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); 154 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
171 int ret; 155 int ret;
172 156
173 codec_dai = byt_get_codec_dai(card); 157 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
158 if (!codec_dai)
159 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2);
160
174 if (!codec_dai) { 161 if (!codec_dai) {
175 dev_err(card->dev, 162 dev_err(card->dev,
176 "Codec dai not found; Unable to set platform clock\n"); 163 "Codec dai not found; Unable to set platform clock\n");
@@ -178,7 +165,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
178 } 165 }
179 166
180 if (SND_SOC_DAPM_EVENT_ON(event)) { 167 if (SND_SOC_DAPM_EVENT_ON(event)) {
181 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk) { 168 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
182 ret = clk_prepare_enable(priv->mclk); 169 ret = clk_prepare_enable(priv->mclk);
183 if (ret < 0) { 170 if (ret < 0) {
184 dev_err(card->dev, 171 dev_err(card->dev,
@@ -199,7 +186,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
199 48000 * 512, 186 48000 * 512,
200 SND_SOC_CLOCK_IN); 187 SND_SOC_CLOCK_IN);
201 if (!ret) { 188 if (!ret) {
202 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk) 189 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN)
203 clk_disable_unprepare(priv->mclk); 190 clk_disable_unprepare(priv->mclk);
204 } 191 }
205 } 192 }
@@ -376,8 +363,8 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
376 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 363 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
377 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"), 364 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),
378 }, 365 },
379 .driver_data = (unsigned long *)(BYT_RT5640_IN1_MAP | 366 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
380 BYT_RT5640_MCLK_EN), 367 BYT_RT5640_MCLK_EN),
381 }, 368 },
382 { 369 {
383 .callback = byt_rt5640_quirk_cb, 370 .callback = byt_rt5640_quirk_cb,
@@ -385,12 +372,11 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
385 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 372 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
386 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TAF"), 373 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TAF"),
387 }, 374 },
388 .driver_data = (unsigned long *)(BYT_RT5640_IN1_MAP | 375 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
389 BYT_RT5640_MONO_SPEAKER | 376 BYT_RT5640_MONO_SPEAKER |
390 BYT_RT5640_DIFF_MIC | 377 BYT_RT5640_DIFF_MIC |
391 BYT_RT5640_SSP0_AIF2 | 378 BYT_RT5640_SSP0_AIF2 |
392 BYT_RT5640_MCLK_EN 379 BYT_RT5640_MCLK_EN),
393 ),
394 }, 380 },
395 { 381 {
396 .callback = byt_rt5640_quirk_cb, 382 .callback = byt_rt5640_quirk_cb,
@@ -398,9 +384,9 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
398 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "DellInc."), 384 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "DellInc."),
399 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5830"), 385 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5830"),
400 }, 386 },
401 .driver_data = (unsigned long *)(BYT_RT5640_DMIC2_MAP | 387 .driver_data = (void *)(BYT_RT5640_DMIC2_MAP |
402 BYT_RT5640_DMIC_EN | 388 BYT_RT5640_DMIC_EN |
403 BYT_RT5640_MCLK_EN), 389 BYT_RT5640_MCLK_EN),
404 }, 390 },
405 { 391 {
406 .callback = byt_rt5640_quirk_cb, 392 .callback = byt_rt5640_quirk_cb,
@@ -408,8 +394,8 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
408 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), 394 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
409 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP ElitePad 1000 G2"), 395 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP ElitePad 1000 G2"),
410 }, 396 },
411 .driver_data = (unsigned long *)(BYT_RT5640_IN1_MAP | 397 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
412 BYT_RT5640_MCLK_EN), 398 BYT_RT5640_MCLK_EN),
413 }, 399 },
414 { 400 {
415 .callback = byt_rt5640_quirk_cb, 401 .callback = byt_rt5640_quirk_cb,
@@ -417,8 +403,8 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
417 DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), 403 DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
418 DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"), 404 DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"),
419 }, 405 },
420 .driver_data = (unsigned long *)(BYT_RT5640_DMIC1_MAP | 406 .driver_data = (void *)(BYT_RT5640_DMIC1_MAP |
421 BYT_RT5640_DMIC_EN), 407 BYT_RT5640_DMIC_EN),
422 }, 408 },
423 { 409 {
424 .callback = byt_rt5640_quirk_cb, 410 .callback = byt_rt5640_quirk_cb,
@@ -426,9 +412,9 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
426 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"), 412 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
427 DMI_MATCH(DMI_BOARD_NAME, "tPAD"), 413 DMI_MATCH(DMI_BOARD_NAME, "tPAD"),
428 }, 414 },
429 .driver_data = (unsigned long *)(BYT_RT5640_IN3_MAP | 415 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
430 BYT_RT5640_MCLK_EN | 416 BYT_RT5640_MCLK_EN |
431 BYT_RT5640_SSP0_AIF1), 417 BYT_RT5640_SSP0_AIF1),
432 }, 418 },
433 { 419 {
434 .callback = byt_rt5640_quirk_cb, 420 .callback = byt_rt5640_quirk_cb,
@@ -436,7 +422,7 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
436 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 422 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
437 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"), 423 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
438 }, 424 },
439 .driver_data = (unsigned long *)(BYT_RT5640_IN1_MAP | 425 .driver_data = (void *)(BYT_RT5640_IN1_MAP |
440 BYT_RT5640_MCLK_EN | 426 BYT_RT5640_MCLK_EN |
441 BYT_RT5640_SSP0_AIF1), 427 BYT_RT5640_SSP0_AIF1),
442 428
@@ -446,9 +432,9 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
446 .matches = { 432 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 433 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
448 }, 434 },
449 .driver_data = (unsigned long *)(BYT_RT5640_IN3_MAP | 435 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
450 BYT_RT5640_MCLK_EN | 436 BYT_RT5640_MCLK_EN |
451 BYT_RT5640_SSP0_AIF1), 437 BYT_RT5640_SSP0_AIF1),
452 438
453 }, 439 },
454 {} 440 {}
@@ -456,12 +442,12 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
456 442
457static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) 443static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
458{ 444{
459 int ret;
460 struct snd_soc_codec *codec = runtime->codec;
461 struct snd_soc_card *card = runtime->card; 445 struct snd_soc_card *card = runtime->card;
462 const struct snd_soc_dapm_route *custom_map;
463 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); 446 struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
447 struct snd_soc_codec *codec = runtime->codec;
448 const struct snd_soc_dapm_route *custom_map;
464 int num_routes; 449 int num_routes;
450 int ret;
465 451
466 card->dapm.idle_bias_off = true; 452 card->dapm.idle_bias_off = true;
467 453
@@ -549,7 +535,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
549 snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone"); 535 snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
550 snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); 536 snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker");
551 537
552 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && priv->mclk) { 538 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
553 /* 539 /*
554 * The firmware might enable the clock at 540 * The firmware might enable the clock at
555 * boot (this information may or may not 541 * boot (this information may or may not
@@ -693,18 +679,10 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = {
693 .dpcm_playback = 1, 679 .dpcm_playback = 1,
694 .ops = &byt_rt5640_aif1_ops, 680 .ops = &byt_rt5640_aif1_ops,
695 }, 681 },
696 [MERR_DPCM_COMPR] = {
697 .name = "Baytrail Compressed Port",
698 .stream_name = "Baytrail Compress",
699 .cpu_dai_name = "compress-cpu-dai",
700 .codec_dai_name = "snd-soc-dummy-dai",
701 .codec_name = "snd-soc-dummy",
702 .platform_name = "sst-mfld-platform",
703 },
704 /* back ends */ 682 /* back ends */
705 { 683 {
706 .name = "SSP2-Codec", 684 .name = "SSP2-Codec",
707 .id = 1, 685 .id = 0,
708 .cpu_dai_name = "ssp2-port", /* overwritten for ssp0 routing */ 686 .cpu_dai_name = "ssp2-port", /* overwritten for ssp0 routing */
709 .platform_name = "sst-mfld-platform", 687 .platform_name = "sst-mfld-platform",
710 .no_pcm = 1, 688 .no_pcm = 1,
@@ -758,12 +736,12 @@ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
758 736
759static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) 737static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
760{ 738{
761 int ret_val = 0; 739 struct byt_rt5640_private *priv;
762 struct sst_acpi_mach *mach; 740 struct snd_soc_acpi_mach *mach;
763 const char *i2c_name = NULL; 741 const char *i2c_name = NULL;
742 int ret_val = 0;
743 int dai_index = 0;
764 int i; 744 int i;
765 int dai_index;
766 struct byt_rt5640_private *priv;
767 745
768 is_bytcr = false; 746 is_bytcr = false;
769 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC); 747 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
@@ -776,7 +754,6 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
776 snd_soc_card_set_drvdata(&byt_rt5640_card, priv); 754 snd_soc_card_set_drvdata(&byt_rt5640_card, priv);
777 755
778 /* fix index of codec dai */ 756 /* fix index of codec dai */
779 dai_index = MERR_DPCM_COMPR + 1;
780 for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) { 757 for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) {
781 if (!strcmp(byt_rt5640_dais[i].codec_name, "i2c-10EC5640:00")) { 758 if (!strcmp(byt_rt5640_dais[i].codec_name, "i2c-10EC5640:00")) {
782 dai_index = i; 759 dai_index = i;
@@ -785,8 +762,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
785 } 762 }
786 763
787 /* fixup codec name based on HID */ 764 /* fixup codec name based on HID */
788 i2c_name = sst_acpi_find_name_from_hid(mach->id); 765 i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
789 if (i2c_name != NULL) { 766 if (i2c_name) {
790 snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name), 767 snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
791 "%s%s", "i2c-", i2c_name); 768 "%s%s", "i2c-", i2c_name);
792 769
@@ -819,7 +796,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
819 /* format specified: 2 64-bit integers */ 796 /* format specified: 2 64-bit integers */
820 struct acpi_buffer format = {sizeof("NN"), "NN"}; 797 struct acpi_buffer format = {sizeof("NN"), "NN"};
821 struct acpi_buffer state = {0, NULL}; 798 struct acpi_buffer state = {0, NULL};
822 struct sst_acpi_package_context pkg_ctx; 799 struct snd_soc_acpi_package_context pkg_ctx;
823 bool pkg_found = false; 800 bool pkg_found = false;
824 801
825 state.length = sizeof(chan_package); 802 state.length = sizeof(chan_package);
@@ -831,7 +808,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
831 pkg_ctx.state = &state; 808 pkg_ctx.state = &state;
832 pkg_ctx.data_valid = false; 809 pkg_ctx.data_valid = false;
833 810
834 pkg_found = sst_acpi_find_package_from_hid(mach->id, &pkg_ctx); 811 pkg_found = snd_soc_acpi_find_package_from_hid(mach->id,
812 &pkg_ctx);
835 if (pkg_found) { 813 if (pkg_found) {
836 if (chan_package.aif_value == 1) { 814 if (chan_package.aif_value == 1) {
837 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); 815 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n");
@@ -891,7 +869,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
891 byt_rt5640_cpu_dai_name; 869 byt_rt5640_cpu_dai_name;
892 } 870 }
893 871
894 if ((byt_rt5640_quirk & BYT_RT5640_MCLK_EN) && (is_valleyview())) { 872 if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
895 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); 873 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
896 if (IS_ERR(priv->mclk)) { 874 if (IS_ERR(priv->mclk)) {
897 ret_val = PTR_ERR(priv->mclk); 875 ret_val = PTR_ERR(priv->mclk);
diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
index 4a3516b38c2c..d955836c6870 100644
--- a/sound/soc/intel/boards/bytcr_rt5651.c
+++ b/sound/soc/intel/boards/bytcr_rt5651.c
@@ -21,24 +21,124 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/acpi.h> 23#include <linux/acpi.h>
24#include <linux/clk.h>
24#include <linux/device.h> 25#include <linux/device.h>
25#include <linux/dmi.h> 26#include <linux/dmi.h>
26#include <linux/slab.h> 27#include <linux/slab.h>
28#include <asm/platform_sst_audio.h>
27#include <sound/pcm.h> 29#include <sound/pcm.h>
28#include <sound/pcm_params.h> 30#include <sound/pcm_params.h>
29#include <sound/soc.h> 31#include <sound/soc.h>
30#include <sound/jack.h> 32#include <sound/jack.h>
33#include <sound/soc-acpi.h>
31#include "../../codecs/rt5651.h" 34#include "../../codecs/rt5651.h"
32#include "../atom/sst-atom-controls.h" 35#include "../atom/sst-atom-controls.h"
33 36
37enum {
38 BYT_RT5651_DMIC_MAP,
39 BYT_RT5651_IN1_MAP,
40 BYT_RT5651_IN2_MAP,
41};
42
43#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(7, 0))
44#define BYT_RT5651_DMIC_EN BIT(16)
45#define BYT_RT5651_MCLK_EN BIT(17)
46#define BYT_RT5651_MCLK_25MHZ BIT(18)
47
48struct byt_rt5651_private {
49 struct clk *mclk;
50 struct snd_soc_jack jack;
51};
52
53static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP |
54 BYT_RT5651_DMIC_EN |
55 BYT_RT5651_MCLK_EN;
56
57static void log_quirks(struct device *dev)
58{
59 if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_DMIC_MAP)
60 dev_info(dev, "quirk DMIC_MAP enabled");
61 if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN1_MAP)
62 dev_info(dev, "quirk IN1_MAP enabled");
63 if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_MAP)
64 dev_info(dev, "quirk IN2_MAP enabled");
65 if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN)
66 dev_info(dev, "quirk DMIC enabled");
67 if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN)
68 dev_info(dev, "quirk MCLK_EN enabled");
69 if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ)
70 dev_info(dev, "quirk MCLK_25MHZ enabled");
71}
72
73#define BYT_CODEC_DAI1 "rt5651-aif1"
74
75static int platform_clock_control(struct snd_soc_dapm_widget *w,
76 struct snd_kcontrol *k, int event)
77{
78 struct snd_soc_dapm_context *dapm = w->dapm;
79 struct snd_soc_card *card = dapm->card;
80 struct snd_soc_dai *codec_dai;
81 struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
82 int ret;
83
84 codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1);
85 if (!codec_dai) {
86 dev_err(card->dev,
87 "Codec dai not found; Unable to set platform clock\n");
88 return -EIO;
89 }
90
91 if (SND_SOC_DAPM_EVENT_ON(event)) {
92 if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) {
93 ret = clk_prepare_enable(priv->mclk);
94 if (ret < 0) {
95 dev_err(card->dev,
96 "could not configure MCLK state");
97 return ret;
98 }
99 }
100 ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1,
101 48000 * 512,
102 SND_SOC_CLOCK_IN);
103 } else {
104 /*
105 * Set codec clock source to internal clock before
106 * turning off the platform clock. Codec needs clock
107 * for Jack detection and button press
108 */
109 ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_RCCLK,
110 48000 * 512,
111 SND_SOC_CLOCK_IN);
112 if (!ret)
113 if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN)
114 clk_disable_unprepare(priv->mclk);
115 }
116
117 if (ret < 0) {
118 dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
119 return ret;
120 }
121
122 return 0;
123}
124
34static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = { 125static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = {
35 SND_SOC_DAPM_HP("Headphone", NULL), 126 SND_SOC_DAPM_HP("Headphone", NULL),
36 SND_SOC_DAPM_MIC("Headset Mic", NULL), 127 SND_SOC_DAPM_MIC("Headset Mic", NULL),
37 SND_SOC_DAPM_MIC("Internal Mic", NULL), 128 SND_SOC_DAPM_MIC("Internal Mic", NULL),
38 SND_SOC_DAPM_SPK("Speaker", NULL), 129 SND_SOC_DAPM_SPK("Speaker", NULL),
130 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
131 platform_clock_control, SND_SOC_DAPM_PRE_PMU |
132 SND_SOC_DAPM_POST_PMD),
133
39}; 134};
40 135
41static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = { 136static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
137 {"Headphone", NULL, "Platform Clock"},
138 {"Headset Mic", NULL, "Platform Clock"},
139 {"Internal Mic", NULL, "Platform Clock"},
140 {"Speaker", NULL, "Platform Clock"},
141
42 {"AIF1 Playback", NULL, "ssp2 Tx"}, 142 {"AIF1 Playback", NULL, "ssp2 Tx"},
43 {"ssp2 Tx", NULL, "codec_out0"}, 143 {"ssp2 Tx", NULL, "codec_out0"},
44 {"ssp2 Tx", NULL, "codec_out1"}, 144 {"ssp2 Tx", NULL, "codec_out1"},
@@ -47,38 +147,30 @@ static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
47 {"ssp2 Rx", NULL, "AIF1 Capture"}, 147 {"ssp2 Rx", NULL, "AIF1 Capture"},
48 148
49 {"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */ 149 {"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */
50 {"IN2P", NULL, "Headset Mic"},
51 {"Headphone", NULL, "HPOL"}, 150 {"Headphone", NULL, "HPOL"},
52 {"Headphone", NULL, "HPOR"}, 151 {"Headphone", NULL, "HPOR"},
53 {"Speaker", NULL, "LOUTL"}, 152 {"Speaker", NULL, "LOUTL"},
54 {"Speaker", NULL, "LOUTR"}, 153 {"Speaker", NULL, "LOUTR"},
55}; 154};
56 155
57static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic1_map[] = { 156static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic_map[] = {
58 {"DMIC1", NULL, "Internal Mic"}, 157 {"IN2P", NULL, "Headset Mic"},
59}; 158 {"DMIC L1", NULL, "Internal Mic"},
60 159 {"DMIC R1", NULL, "Internal Mic"},
61static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic2_map[] = {
62 {"DMIC2", NULL, "Internal Mic"},
63}; 160};
64 161
65static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = { 162static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = {
66 {"Internal Mic", NULL, "micbias1"}, 163 {"Internal Mic", NULL, "micbias1"},
164 {"IN2P", NULL, "Headset Mic"},
67 {"IN1P", NULL, "Internal Mic"}, 165 {"IN1P", NULL, "Internal Mic"},
68}; 166};
69 167
70enum { 168static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_map[] = {
71 BYT_RT5651_DMIC1_MAP, 169 {"Internal Mic", NULL, "micbias1"},
72 BYT_RT5651_DMIC2_MAP, 170 {"IN1P", NULL, "Headset Mic"},
73 BYT_RT5651_IN1_MAP, 171 {"IN2P", NULL, "Internal Mic"},
74}; 172};
75 173
76#define BYT_RT5651_MAP(quirk) ((quirk) & 0xff)
77#define BYT_RT5651_DMIC_EN BIT(16)
78
79static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC1_MAP |
80 BYT_RT5651_DMIC_EN;
81
82static const struct snd_kcontrol_new byt_rt5651_controls[] = { 174static const struct snd_kcontrol_new byt_rt5651_controls[] = {
83 SOC_DAPM_PIN_SWITCH("Headphone"), 175 SOC_DAPM_PIN_SWITCH("Headphone"),
84 SOC_DAPM_PIN_SWITCH("Headset Mic"), 176 SOC_DAPM_PIN_SWITCH("Headset Mic"),
@@ -86,6 +178,17 @@ static const struct snd_kcontrol_new byt_rt5651_controls[] = {
86 SOC_DAPM_PIN_SWITCH("Speaker"), 178 SOC_DAPM_PIN_SWITCH("Speaker"),
87}; 179};
88 180
181static struct snd_soc_jack_pin bytcr_jack_pins[] = {
182 {
183 .pin = "Headphone",
184 .mask = SND_JACK_HEADPHONE,
185 },
186 {
187 .pin = "Headset Mic",
188 .mask = SND_JACK_MICROPHONE,
189 },
190};
191
89static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, 192static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream,
90 struct snd_pcm_hw_params *params) 193 struct snd_pcm_hw_params *params)
91{ 194{
@@ -103,9 +206,26 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream,
103 return ret; 206 return ret;
104 } 207 }
105 208
106 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1, 209 if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) {
107 params_rate(params) * 50, 210 /* 2x25 bit slots on SSP2 */
108 params_rate(params) * 512); 211 ret = snd_soc_dai_set_pll(codec_dai, 0,
212 RT5651_PLL1_S_BCLK1,
213 params_rate(params) * 50,
214 params_rate(params) * 512);
215 } else {
216 if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) {
217 ret = snd_soc_dai_set_pll(codec_dai, 0,
218 RT5651_PLL1_S_MCLK,
219 25000000,
220 params_rate(params) * 512);
221 } else {
222 ret = snd_soc_dai_set_pll(codec_dai, 0,
223 RT5651_PLL1_S_MCLK,
224 19200000,
225 params_rate(params) * 512);
226 }
227 }
228
109 if (ret < 0) { 229 if (ret < 0) {
110 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); 230 dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
111 return ret; 231 return ret;
@@ -114,33 +234,60 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream,
114 return 0; 234 return 0;
115} 235}
116 236
237static int byt_rt5651_quirk_cb(const struct dmi_system_id *id)
238{
239 byt_rt5651_quirk = (unsigned long)id->driver_data;
240 return 1;
241}
242
117static const struct dmi_system_id byt_rt5651_quirk_table[] = { 243static const struct dmi_system_id byt_rt5651_quirk_table[] = {
244 {
245 .callback = byt_rt5651_quirk_cb,
246 .matches = {
247 DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
248 DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"),
249 },
250 .driver_data = (void *)(BYT_RT5651_DMIC_MAP |
251 BYT_RT5651_DMIC_EN),
252 },
253 {
254 .callback = byt_rt5651_quirk_cb,
255 .matches = {
256 DMI_MATCH(DMI_SYS_VENDOR, "KIANO"),
257 DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"),
258 },
259 .driver_data = (void *)(BYT_RT5651_IN2_MAP),
260 },
118 {} 261 {}
119}; 262};
120 263
121static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) 264static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
122{ 265{
123 int ret;
124 struct snd_soc_card *card = runtime->card; 266 struct snd_soc_card *card = runtime->card;
267 struct snd_soc_codec *codec = runtime->codec;
268 struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
125 const struct snd_soc_dapm_route *custom_map; 269 const struct snd_soc_dapm_route *custom_map;
126 int num_routes; 270 int num_routes;
271 int ret;
127 272
128 card->dapm.idle_bias_off = true; 273 card->dapm.idle_bias_off = true;
129 274
130 dmi_check_system(byt_rt5651_quirk_table);
131 switch (BYT_RT5651_MAP(byt_rt5651_quirk)) { 275 switch (BYT_RT5651_MAP(byt_rt5651_quirk)) {
132 case BYT_RT5651_IN1_MAP: 276 case BYT_RT5651_IN1_MAP:
133 custom_map = byt_rt5651_intmic_in1_map; 277 custom_map = byt_rt5651_intmic_in1_map;
134 num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_map); 278 num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_map);
135 break; 279 break;
136 case BYT_RT5651_DMIC2_MAP: 280 case BYT_RT5651_IN2_MAP:
137 custom_map = byt_rt5651_intmic_dmic2_map; 281 custom_map = byt_rt5651_intmic_in2_map;
138 num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic2_map); 282 num_routes = ARRAY_SIZE(byt_rt5651_intmic_in2_map);
139 break; 283 break;
140 default: 284 default:
141 custom_map = byt_rt5651_intmic_dmic1_map; 285 custom_map = byt_rt5651_intmic_dmic_map;
142 num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic1_map); 286 num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic_map);
143 } 287 }
288 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
289 if (ret)
290 return ret;
144 291
145 ret = snd_soc_add_card_controls(card, byt_rt5651_controls, 292 ret = snd_soc_add_card_controls(card, byt_rt5651_controls,
146 ARRAY_SIZE(byt_rt5651_controls)); 293 ARRAY_SIZE(byt_rt5651_controls));
@@ -151,6 +298,40 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
151 snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone"); 298 snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
152 snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); 299 snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker");
153 300
301 if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) {
302 /*
303 * The firmware might enable the clock at
304 * boot (this information may or may not
305 * be reflected in the enable clock register).
306 * To change the rate we must disable the clock
307 * first to cover these cases. Due to common
308 * clock framework restrictions that do not allow
309 * to disable a clock that has not been enabled,
310 * we need to enable the clock first.
311 */
312 ret = clk_prepare_enable(priv->mclk);
313 if (!ret)
314 clk_disable_unprepare(priv->mclk);
315
316 if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ)
317 ret = clk_set_rate(priv->mclk, 25000000);
318 else
319 ret = clk_set_rate(priv->mclk, 19200000);
320
321 if (ret)
322 dev_err(card->dev, "unable to set MCLK rate\n");
323 }
324
325 ret = snd_soc_card_jack_new(runtime->card, "Headset",
326 SND_JACK_HEADSET, &priv->jack,
327 bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins));
328 if (ret) {
329 dev_err(runtime->dev, "Headset jack creation failed %d\n", ret);
330 return ret;
331 }
332
333 rt5651_set_jack_detect(codec, &priv->jack);
334
154 return ret; 335 return ret;
155} 336}
156 337
@@ -253,19 +434,11 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = {
253 .dpcm_playback = 1, 434 .dpcm_playback = 1,
254 .ops = &byt_rt5651_aif1_ops, 435 .ops = &byt_rt5651_aif1_ops,
255 }, 436 },
256 [MERR_DPCM_COMPR] = {
257 .name = "Compressed Port",
258 .stream_name = "Compress",
259 .cpu_dai_name = "compress-cpu-dai",
260 .codec_dai_name = "snd-soc-dummy-dai",
261 .codec_name = "snd-soc-dummy",
262 .platform_name = "sst-mfld-platform",
263 },
264 /* CODEC<->CODEC link */ 437 /* CODEC<->CODEC link */
265 /* back ends */ 438 /* back ends */
266 { 439 {
267 .name = "SSP2-Codec", 440 .name = "SSP2-Codec",
268 .id = 1, 441 .id = 0,
269 .cpu_dai_name = "ssp2-port", 442 .cpu_dai_name = "ssp2-port",
270 .platform_name = "sst-mfld-platform", 443 .platform_name = "sst-mfld-platform",
271 .no_pcm = 1, 444 .no_pcm = 1,
@@ -296,13 +469,65 @@ static struct snd_soc_card byt_rt5651_card = {
296 .fully_routed = true, 469 .fully_routed = true,
297}; 470};
298 471
472static char byt_rt5651_codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
473
299static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) 474static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
300{ 475{
476 struct byt_rt5651_private *priv;
477 struct snd_soc_acpi_mach *mach;
478 const char *i2c_name = NULL;
301 int ret_val = 0; 479 int ret_val = 0;
480 int dai_index = 0;
481 int i;
482
483 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
484 if (!priv)
485 return -ENOMEM;
302 486
303 /* register the soc card */ 487 /* register the soc card */
304 byt_rt5651_card.dev = &pdev->dev; 488 byt_rt5651_card.dev = &pdev->dev;
305 489
490 mach = byt_rt5651_card.dev->platform_data;
491 snd_soc_card_set_drvdata(&byt_rt5651_card, priv);
492
493 /* fix index of codec dai */
494 for (i = 0; i < ARRAY_SIZE(byt_rt5651_dais); i++) {
495 if (!strcmp(byt_rt5651_dais[i].codec_name, "i2c-10EC5651:00")) {
496 dai_index = i;
497 break;
498 }
499 }
500
501 /* fixup codec name based on HID */
502 i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
503 if (i2c_name) {
504 snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name),
505 "%s%s", "i2c-", i2c_name);
506
507 byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name;
508 }
509
510 /* check quirks before creating card */
511 dmi_check_system(byt_rt5651_quirk_table);
512 log_quirks(&pdev->dev);
513
514 if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) {
515 priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
516 if (IS_ERR(priv->mclk)) {
517 dev_err(&pdev->dev,
518 "Failed to get MCLK from pmc_plt_clk_3: %ld\n",
519 PTR_ERR(priv->mclk));
520 /*
521 * Fall back to bit clock usage for -ENOENT (clock not
522 * available likely due to missing dependencies), bail
523 * for all other errors, including -EPROBE_DEFER
524 */
525 if (ret_val != -ENOENT)
526 return ret_val;
527 byt_rt5651_quirk &= ~BYT_RT5651_MCLK_EN;
528 }
529 }
530
306 ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5651_card); 531 ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5651_card);
307 532
308 if (ret_val) { 533 if (ret_val) {
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index 455a55af7ad2..d3e1c7e12004 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -23,6 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/acpi.h> 25#include <linux/acpi.h>
26#include <linux/clk.h>
26#include <sound/pcm.h> 27#include <sound/pcm.h>
27#include <sound/pcm_params.h> 28#include <sound/pcm_params.h>
28#include <sound/soc.h> 29#include <sound/soc.h>
@@ -35,15 +36,48 @@
35#define CHT_CODEC_DAI "HiFi" 36#define CHT_CODEC_DAI "HiFi"
36 37
37struct cht_mc_private { 38struct cht_mc_private {
39 struct clk *mclk;
38 struct snd_soc_jack jack; 40 struct snd_soc_jack jack;
39 bool ts3a227e_present; 41 bool ts3a227e_present;
40}; 42};
41 43
44static int platform_clock_control(struct snd_soc_dapm_widget *w,
45 struct snd_kcontrol *k, int event)
46{
47 struct snd_soc_dapm_context *dapm = w->dapm;
48 struct snd_soc_card *card = dapm->card;
49 struct snd_soc_dai *codec_dai;
50 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
51 int ret;
52
53 codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
54 if (!codec_dai) {
55 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
56 return -EIO;
57 }
58
59 if (SND_SOC_DAPM_EVENT_ON(event)) {
60 ret = clk_prepare_enable(ctx->mclk);
61 if (ret < 0) {
62 dev_err(card->dev,
63 "could not configure MCLK state");
64 return ret;
65 }
66 } else {
67 clk_disable_unprepare(ctx->mclk);
68 }
69
70 return 0;
71}
72
42static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { 73static const struct snd_soc_dapm_widget cht_dapm_widgets[] = {
43 SND_SOC_DAPM_HP("Headphone", NULL), 74 SND_SOC_DAPM_HP("Headphone", NULL),
44 SND_SOC_DAPM_MIC("Headset Mic", NULL), 75 SND_SOC_DAPM_MIC("Headset Mic", NULL),
45 SND_SOC_DAPM_MIC("Int Mic", NULL), 76 SND_SOC_DAPM_MIC("Int Mic", NULL),
46 SND_SOC_DAPM_SPK("Ext Spk", NULL), 77 SND_SOC_DAPM_SPK("Ext Spk", NULL),
78 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
79 platform_clock_control, SND_SOC_DAPM_PRE_PMU |
80 SND_SOC_DAPM_POST_PMD),
47}; 81};
48 82
49static const struct snd_soc_dapm_route cht_audio_map[] = { 83static const struct snd_soc_dapm_route cht_audio_map[] = {
@@ -60,6 +94,10 @@ static const struct snd_soc_dapm_route cht_audio_map[] = {
60 {"codec_in0", NULL, "ssp2 Rx" }, 94 {"codec_in0", NULL, "ssp2 Rx" },
61 {"codec_in1", NULL, "ssp2 Rx" }, 95 {"codec_in1", NULL, "ssp2 Rx" },
62 {"ssp2 Rx", NULL, "HiFi Capture"}, 96 {"ssp2 Rx", NULL, "HiFi Capture"},
97 {"Headphone", NULL, "Platform Clock"},
98 {"Headset Mic", NULL, "Platform Clock"},
99 {"Int Mic", NULL, "Platform Clock"},
100 {"Ext Spk", NULL, "Platform Clock"},
63}; 101};
64 102
65static const struct snd_kcontrol_new cht_mc_controls[] = { 103static const struct snd_kcontrol_new cht_mc_controls[] = {
@@ -109,6 +147,40 @@ static struct notifier_block cht_jack_nb = {
109 .notifier_call = cht_ti_jack_event, 147 .notifier_call = cht_ti_jack_event,
110}; 148};
111 149
150static struct snd_soc_jack_pin hs_jack_pins[] = {
151 {
152 .pin = "Headphone",
153 .mask = SND_JACK_HEADPHONE,
154 },
155 {
156 .pin = "Headset Mic",
157 .mask = SND_JACK_MICROPHONE,
158 },
159};
160
161static struct snd_soc_jack_gpio hs_jack_gpios[] = {
162 {
163 .name = "hp",
164 .report = SND_JACK_HEADPHONE | SND_JACK_LINEOUT,
165 .debounce_time = 200,
166 },
167 {
168 .name = "mic",
169 .invert = 1,
170 .report = SND_JACK_MICROPHONE,
171 .debounce_time = 200,
172 },
173};
174
175static const struct acpi_gpio_params hp_gpios = { 0, 0, false };
176static const struct acpi_gpio_params mic_gpios = { 1, 0, false };
177
178static const struct acpi_gpio_mapping acpi_max98090_gpios[] = {
179 { "hp-gpios", &hp_gpios, 1 },
180 { "mic-gpios", &mic_gpios, 1 },
181 {},
182};
183
112static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) 184static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
113{ 185{
114 int ret; 186 int ret;
@@ -116,30 +188,55 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
116 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); 188 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
117 struct snd_soc_jack *jack = &ctx->jack; 189 struct snd_soc_jack *jack = &ctx->jack;
118 190
119 /** 191 if (ctx->ts3a227e_present) {
120 * TI supports 4 butons headset detection 192 /*
121 * KEY_MEDIA 193 * The jack has already been created in the
122 * KEY_VOICECOMMAND 194 * cht_max98090_headset_init() function.
123 * KEY_VOLUMEUP 195 */
124 * KEY_VOLUMEDOWN 196 snd_soc_jack_notifier_register(jack, &cht_jack_nb);
125 */ 197 return 0;
126 if (ctx->ts3a227e_present) 198 }
127 jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
128 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
129 SND_JACK_BTN_2 | SND_JACK_BTN_3;
130 else
131 jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
132 199
133 ret = snd_soc_card_jack_new(runtime->card, "Headset Jack", 200 jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
134 jack_type, jack, NULL, 0);
135 201
202 ret = snd_soc_card_jack_new(runtime->card, "Headset Jack",
203 jack_type, jack,
204 hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
136 if (ret) { 205 if (ret) {
137 dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret); 206 dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret);
138 return ret; 207 return ret;
139 } 208 }
140 209
141 if (ctx->ts3a227e_present) 210 ret = snd_soc_jack_add_gpiods(runtime->card->dev->parent, jack,
142 snd_soc_jack_notifier_register(jack, &cht_jack_nb); 211 ARRAY_SIZE(hs_jack_gpios),
212 hs_jack_gpios);
213 if (ret) {
214 /*
215 * flag error but don't bail if jack detect is broken
216 * due to platform issues or bad BIOS/configuration
217 */
218 dev_err(runtime->dev,
219 "jack detection gpios not added, error %d\n", ret);
220 }
221
222 /*
223 * The firmware might enable the clock at
224 * boot (this information may or may not
225 * be reflected in the enable clock register).
226 * To change the rate we must disable the clock
227 * first to cover these cases. Due to common
228 * clock framework restrictions that do not allow
229 * to disable a clock that has not been enabled,
230 * we need to enable the clock first.
231 */
232 ret = clk_prepare_enable(ctx->mclk);
233 if (!ret)
234 clk_disable_unprepare(ctx->mclk);
235
236 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ);
237
238 if (ret)
239 dev_err(runtime->dev, "unable to set MCLK rate\n");
143 240
144 return ret; 241 return ret;
145} 242}
@@ -188,8 +285,29 @@ static int cht_max98090_headset_init(struct snd_soc_component *component)
188{ 285{
189 struct snd_soc_card *card = component->card; 286 struct snd_soc_card *card = component->card;
190 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 287 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
288 struct snd_soc_jack *jack = &ctx->jack;
289 int jack_type;
290 int ret;
191 291
192 return ts3a227e_enable_jack_detect(component, &ctx->jack); 292 /*
293 * TI supports 4 butons headset detection
294 * KEY_MEDIA
295 * KEY_VOICECOMMAND
296 * KEY_VOLUMEUP
297 * KEY_VOLUMEDOWN
298 */
299 jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
300 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
301 SND_JACK_BTN_2 | SND_JACK_BTN_3;
302
303 ret = snd_soc_card_jack_new(card, "Headset Jack", jack_type,
304 jack, NULL, 0);
305 if (ret) {
306 dev_err(card->dev, "Headset Jack creation failed %d\n", ret);
307 return ret;
308 }
309
310 return ts3a227e_enable_jack_detect(component, jack);
193} 311}
194 312
195static const struct snd_soc_ops cht_aif1_ops = { 313static const struct snd_soc_ops cht_aif1_ops = {
@@ -232,18 +350,10 @@ static struct snd_soc_dai_link cht_dailink[] = {
232 .dpcm_playback = 1, 350 .dpcm_playback = 1,
233 .ops = &cht_aif1_ops, 351 .ops = &cht_aif1_ops,
234 }, 352 },
235 [MERR_DPCM_COMPR] = {
236 .name = "Compressed Port",
237 .stream_name = "Compress",
238 .cpu_dai_name = "compress-cpu-dai",
239 .codec_dai_name = "snd-soc-dummy-dai",
240 .codec_name = "snd-soc-dummy",
241 .platform_name = "sst-mfld-platform",
242 },
243 /* back ends */ 353 /* back ends */
244 { 354 {
245 .name = "SSP2-Codec", 355 .name = "SSP2-Codec",
246 .id = 1, 356 .id = 0,
247 .cpu_dai_name = "ssp2-port", 357 .cpu_dai_name = "ssp2-port",
248 .platform_name = "sst-mfld-platform", 358 .platform_name = "sst-mfld-platform",
249 .no_pcm = 1, 359 .no_pcm = 1,
@@ -277,6 +387,7 @@ static struct snd_soc_card snd_soc_card_cht = {
277 387
278static int snd_cht_mc_probe(struct platform_device *pdev) 388static int snd_cht_mc_probe(struct platform_device *pdev)
279{ 389{
390 struct device *dev = &pdev->dev;
280 int ret_val = 0; 391 int ret_val = 0;
281 struct cht_mc_private *drv; 392 struct cht_mc_private *drv;
282 393
@@ -289,11 +400,25 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
289 /* no need probe TI jack detection chip */ 400 /* no need probe TI jack detection chip */
290 snd_soc_card_cht.aux_dev = NULL; 401 snd_soc_card_cht.aux_dev = NULL;
291 snd_soc_card_cht.num_aux_devs = 0; 402 snd_soc_card_cht.num_aux_devs = 0;
403
404 ret_val = devm_acpi_dev_add_driver_gpios(dev->parent,
405 acpi_max98090_gpios);
406 if (ret_val)
407 dev_dbg(dev, "Unable to add GPIO mapping table\n");
292 } 408 }
293 409
294 /* register the soc card */ 410 /* register the soc card */
295 snd_soc_card_cht.dev = &pdev->dev; 411 snd_soc_card_cht.dev = &pdev->dev;
296 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); 412 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
413
414 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
415 if (IS_ERR(drv->mclk)) {
416 dev_err(&pdev->dev,
417 "Failed to get MCLK from pmc_plt_clk_3: %ld\n",
418 PTR_ERR(drv->mclk));
419 return PTR_ERR(drv->mclk);
420 }
421
297 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); 422 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
298 if (ret_val) { 423 if (ret_val) {
299 dev_err(&pdev->dev, 424 dev_err(&pdev->dev,
diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index 5bcde01d15e6..18d129caa974 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -21,20 +21,20 @@
21 */ 21 */
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/acpi.h>
25#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/acpi.h>
26#include <linux/clk.h>
26#include <linux/dmi.h> 27#include <linux/dmi.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <asm/cpu_device_id.h> 29#include <asm/cpu_device_id.h>
29#include <asm/platform_sst_audio.h> 30#include <asm/platform_sst_audio.h>
30#include <linux/clk.h>
31#include <sound/pcm.h> 31#include <sound/pcm.h>
32#include <sound/pcm_params.h> 32#include <sound/pcm_params.h>
33#include <sound/soc.h> 33#include <sound/soc.h>
34#include <sound/jack.h> 34#include <sound/jack.h>
35#include <sound/soc-acpi.h>
35#include "../../codecs/rt5645.h" 36#include "../../codecs/rt5645.h"
36#include "../atom/sst-atom-controls.h" 37#include "../atom/sst-atom-controls.h"
37#include "../common/sst-acpi.h"
38 38
39#define CHT_PLAT_CLK_3_HZ 19200000 39#define CHT_PLAT_CLK_3_HZ 19200000
40#define CHT_CODEC_DAI1 "rt5645-aif1" 40#define CHT_CODEC_DAI1 "rt5645-aif1"
@@ -53,7 +53,7 @@ struct cht_mc_private {
53 struct clk *mclk; 53 struct clk *mclk;
54}; 54};
55 55
56#define CHT_RT5645_MAP(quirk) ((quirk) & 0xff) 56#define CHT_RT5645_MAP(quirk) ((quirk) & GENMASK(7, 0))
57#define CHT_RT5645_SSP2_AIF2 BIT(16) /* default is using AIF1 */ 57#define CHT_RT5645_SSP2_AIF2 BIT(16) /* default is using AIF1 */
58#define CHT_RT5645_SSP0_AIF1 BIT(17) 58#define CHT_RT5645_SSP0_AIF1 BIT(17)
59#define CHT_RT5645_SSP0_AIF2 BIT(18) 59#define CHT_RT5645_SSP0_AIF2 BIT(18)
@@ -70,21 +70,6 @@ static void log_quirks(struct device *dev)
70 dev_info(dev, "quirk SSP0_AIF2 enabled"); 70 dev_info(dev, "quirk SSP0_AIF2 enabled");
71} 71}
72 72
73static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
74{
75 struct snd_soc_pcm_runtime *rtd;
76
77 list_for_each_entry(rtd, &card->rtd_list, list) {
78 if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI1,
79 strlen(CHT_CODEC_DAI1)))
80 return rtd->codec_dai;
81 if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI2,
82 strlen(CHT_CODEC_DAI2)))
83 return rtd->codec_dai;
84 }
85 return NULL;
86}
87
88static int platform_clock_control(struct snd_soc_dapm_widget *w, 73static int platform_clock_control(struct snd_soc_dapm_widget *w,
89 struct snd_kcontrol *k, int event) 74 struct snd_kcontrol *k, int event)
90{ 75{
@@ -94,20 +79,21 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
94 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 79 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
95 int ret; 80 int ret;
96 81
97 codec_dai = cht_get_codec_dai(card); 82 codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI1);
83 if (!codec_dai)
84 codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI2);
85
98 if (!codec_dai) { 86 if (!codec_dai) {
99 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); 87 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
100 return -EIO; 88 return -EIO;
101 } 89 }
102 90
103 if (SND_SOC_DAPM_EVENT_ON(event)) { 91 if (SND_SOC_DAPM_EVENT_ON(event)) {
104 if (ctx->mclk) { 92 ret = clk_prepare_enable(ctx->mclk);
105 ret = clk_prepare_enable(ctx->mclk); 93 if (ret < 0) {
106 if (ret < 0) { 94 dev_err(card->dev,
107 dev_err(card->dev, 95 "could not configure MCLK state");
108 "could not configure MCLK state"); 96 return ret;
109 return ret;
110 }
111 } 97 }
112 } else { 98 } else {
113 /* Set codec sysclk source to its internal clock because codec PLL will 99 /* Set codec sysclk source to its internal clock because codec PLL will
@@ -122,8 +108,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
122 return ret; 108 return ret;
123 } 109 }
124 110
125 if (ctx->mclk) 111 clk_disable_unprepare(ctx->mclk);
126 clk_disable_unprepare(ctx->mclk);
127 } 112 }
128 113
129 return 0; 114 return 0;
@@ -258,11 +243,11 @@ static const struct dmi_system_id cht_rt5645_quirk_table[] = {
258 243
259static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) 244static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
260{ 245{
261 int ret;
262 int jack_type;
263 struct snd_soc_codec *codec = runtime->codec;
264 struct snd_soc_card *card = runtime->card; 246 struct snd_soc_card *card = runtime->card;
265 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); 247 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
248 struct snd_soc_codec *codec = runtime->codec;
249 int jack_type;
250 int ret;
266 251
267 if ((cht_rt5645_quirk & CHT_RT5645_SSP2_AIF2) || 252 if ((cht_rt5645_quirk & CHT_RT5645_SSP2_AIF2) ||
268 (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) { 253 (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) {
@@ -320,26 +305,26 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
320 305
321 rt5645_set_jack_detect(codec, &ctx->jack, &ctx->jack, &ctx->jack); 306 rt5645_set_jack_detect(codec, &ctx->jack, &ctx->jack, &ctx->jack);
322 307
323 if (ctx->mclk) {
324 /*
325 * The firmware might enable the clock at
326 * boot (this information may or may not
327 * be reflected in the enable clock register).
328 * To change the rate we must disable the clock
329 * first to cover these cases. Due to common
330 * clock framework restrictions that do not allow
331 * to disable a clock that has not been enabled,
332 * we need to enable the clock first.
333 */
334 ret = clk_prepare_enable(ctx->mclk);
335 if (!ret)
336 clk_disable_unprepare(ctx->mclk);
337 308
338 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); 309 /*
310 * The firmware might enable the clock at
311 * boot (this information may or may not
312 * be reflected in the enable clock register).
313 * To change the rate we must disable the clock
314 * first to cover these cases. Due to common
315 * clock framework restrictions that do not allow
316 * to disable a clock that has not been enabled,
317 * we need to enable the clock first.
318 */
319 ret = clk_prepare_enable(ctx->mclk);
320 if (!ret)
321 clk_disable_unprepare(ctx->mclk);
322
323 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ);
324
325 if (ret)
326 dev_err(runtime->dev, "unable to set MCLK rate\n");
339 327
340 if (ret)
341 dev_err(runtime->dev, "unable to set MCLK rate\n");
342 }
343 return ret; 328 return ret;
344} 329}
345 330
@@ -460,19 +445,11 @@ static struct snd_soc_dai_link cht_dailink[] = {
460 .dpcm_playback = 1, 445 .dpcm_playback = 1,
461 .ops = &cht_aif1_ops, 446 .ops = &cht_aif1_ops,
462 }, 447 },
463 [MERR_DPCM_COMPR] = {
464 .name = "Compressed Port",
465 .stream_name = "Compress",
466 .cpu_dai_name = "compress-cpu-dai",
467 .codec_dai_name = "snd-soc-dummy-dai",
468 .codec_name = "snd-soc-dummy",
469 .platform_name = "sst-mfld-platform",
470 },
471 /* CODEC<->CODEC link */ 448 /* CODEC<->CODEC link */
472 /* back ends */ 449 /* back ends */
473 { 450 {
474 .name = "SSP2-Codec", 451 .name = "SSP2-Codec",
475 .id = 1, 452 .id = 0,
476 .cpu_dai_name = "ssp2-port", 453 .cpu_dai_name = "ssp2-port",
477 .platform_name = "sst-mfld-platform", 454 .platform_name = "sst-mfld-platform",
478 .no_pcm = 1, 455 .no_pcm = 1,
@@ -545,15 +522,15 @@ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
545 522
546static int snd_cht_mc_probe(struct platform_device *pdev) 523static int snd_cht_mc_probe(struct platform_device *pdev)
547{ 524{
548 int ret_val = 0;
549 int i;
550 struct cht_mc_private *drv;
551 struct snd_soc_card *card = snd_soc_cards[0].soc_card; 525 struct snd_soc_card *card = snd_soc_cards[0].soc_card;
552 struct sst_acpi_mach *mach; 526 struct snd_soc_acpi_mach *mach;
527 struct cht_mc_private *drv;
553 const char *i2c_name = NULL; 528 const char *i2c_name = NULL;
554 int dai_index = 0;
555 bool found = false; 529 bool found = false;
556 bool is_bytcr = false; 530 bool is_bytcr = false;
531 int dai_index = 0;
532 int ret_val = 0;
533 int i;
557 534
558 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC); 535 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC);
559 if (!drv) 536 if (!drv)
@@ -589,8 +566,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
589 } 566 }
590 567
591 /* fixup codec name based on HID */ 568 /* fixup codec name based on HID */
592 i2c_name = sst_acpi_find_name_from_hid(mach->id); 569 i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
593 if (i2c_name != NULL) { 570 if (i2c_name) {
594 snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name), 571 snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name),
595 "%s%s", "i2c-", i2c_name); 572 "%s%s", "i2c-", i2c_name);
596 cht_dailink[dai_index].codec_name = cht_rt5645_codec_name; 573 cht_dailink[dai_index].codec_name = cht_rt5645_codec_name;
@@ -622,7 +599,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
622 /* format specified: 2 64-bit integers */ 599 /* format specified: 2 64-bit integers */
623 struct acpi_buffer format = {sizeof("NN"), "NN"}; 600 struct acpi_buffer format = {sizeof("NN"), "NN"};
624 struct acpi_buffer state = {0, NULL}; 601 struct acpi_buffer state = {0, NULL};
625 struct sst_acpi_package_context pkg_ctx; 602 struct snd_soc_acpi_package_context pkg_ctx;
626 bool pkg_found = false; 603 bool pkg_found = false;
627 604
628 state.length = sizeof(chan_package); 605 state.length = sizeof(chan_package);
@@ -634,7 +611,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
634 pkg_ctx.state = &state; 611 pkg_ctx.state = &state;
635 pkg_ctx.data_valid = false; 612 pkg_ctx.data_valid = false;
636 613
637 pkg_found = sst_acpi_find_package_from_hid(mach->id, &pkg_ctx); 614 pkg_found = snd_soc_acpi_find_package_from_hid(mach->id,
615 &pkg_ctx);
638 if (pkg_found) { 616 if (pkg_found) {
639 if (chan_package.aif_value == 1) { 617 if (chan_package.aif_value == 1) {
640 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); 618 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n");
@@ -682,14 +660,12 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
682 cht_rt5645_cpu_dai_name; 660 cht_rt5645_cpu_dai_name;
683 } 661 }
684 662
685 if (is_valleyview()) { 663 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
686 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); 664 if (IS_ERR(drv->mclk)) {
687 if (IS_ERR(drv->mclk)) { 665 dev_err(&pdev->dev,
688 dev_err(&pdev->dev, 666 "Failed to get MCLK from pmc_plt_clk_3: %ld\n",
689 "Failed to get MCLK from pmc_plt_clk_3: %ld\n", 667 PTR_ERR(drv->mclk));
690 PTR_ERR(drv->mclk)); 668 return PTR_ERR(drv->mclk);
691 return PTR_ERR(drv->mclk);
692 }
693 } 669 }
694 670
695 snd_soc_card_set_drvdata(card, drv); 671 snd_soc_card_set_drvdata(card, drv);
diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c
index f597d5582223..f8f21eee9b2d 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5672.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5672.c
@@ -20,14 +20,14 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <asm/cpu_device_id.h>
24#include <sound/pcm.h> 23#include <sound/pcm.h>
25#include <sound/pcm_params.h> 24#include <sound/pcm_params.h>
26#include <sound/soc.h> 25#include <sound/soc.h>
27#include <sound/jack.h> 26#include <sound/jack.h>
27#include <sound/soc-acpi.h>
28#include "../../codecs/rt5670.h" 28#include "../../codecs/rt5670.h"
29#include "../atom/sst-atom-controls.h" 29#include "../atom/sst-atom-controls.h"
30#include "../common/sst-acpi.h" 30
31 31
32/* The platform clock #3 outputs 19.2Mhz clock to codec as I2S MCLK */ 32/* The platform clock #3 outputs 19.2Mhz clock to codec as I2S MCLK */
33#define CHT_PLAT_CLK_3_HZ 19200000 33#define CHT_PLAT_CLK_3_HZ 19200000
@@ -51,18 +51,6 @@ static struct snd_soc_jack_pin cht_bsw_headset_pins[] = {
51 }, 51 },
52}; 52};
53 53
54static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
55{
56 struct snd_soc_pcm_runtime *rtd;
57
58 list_for_each_entry(rtd, &card->rtd_list, list) {
59 if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI,
60 strlen(CHT_CODEC_DAI)))
61 return rtd->codec_dai;
62 }
63 return NULL;
64}
65
66static int platform_clock_control(struct snd_soc_dapm_widget *w, 54static int platform_clock_control(struct snd_soc_dapm_widget *w,
67 struct snd_kcontrol *k, int event) 55 struct snd_kcontrol *k, int event)
68{ 56{
@@ -72,7 +60,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
72 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 60 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
73 int ret; 61 int ret;
74 62
75 codec_dai = cht_get_codec_dai(card); 63 codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI);
76 if (!codec_dai) { 64 if (!codec_dai) {
77 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); 65 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
78 return -EIO; 66 return -EIO;
@@ -315,20 +303,12 @@ static struct snd_soc_dai_link cht_dailink[] = {
315 .dpcm_playback = 1, 303 .dpcm_playback = 1,
316 .ops = &cht_aif1_ops, 304 .ops = &cht_aif1_ops,
317 }, 305 },
318 [MERR_DPCM_COMPR] = {
319 .name = "Compressed Port",
320 .stream_name = "Compress",
321 .cpu_dai_name = "compress-cpu-dai",
322 .codec_dai_name = "snd-soc-dummy-dai",
323 .codec_name = "snd-soc-dummy",
324 .platform_name = "sst-mfld-platform",
325 },
326 306
327 /* Back End DAI links */ 307 /* Back End DAI links */
328 { 308 {
329 /* SSP2 - Codec */ 309 /* SSP2 - Codec */
330 .name = "SSP2-Codec", 310 .name = "SSP2-Codec",
331 .id = 1, 311 .id = 0,
332 .cpu_dai_name = "ssp2-port", 312 .cpu_dai_name = "ssp2-port",
333 .platform_name = "sst-mfld-platform", 313 .platform_name = "sst-mfld-platform",
334 .no_pcm = 1, 314 .no_pcm = 1,
@@ -348,9 +328,11 @@ static struct snd_soc_dai_link cht_dailink[] = {
348static int cht_suspend_pre(struct snd_soc_card *card) 328static int cht_suspend_pre(struct snd_soc_card *card)
349{ 329{
350 struct snd_soc_component *component; 330 struct snd_soc_component *component;
331 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
351 332
352 list_for_each_entry(component, &card->component_dev_list, card_list) { 333 list_for_each_entry(component, &card->component_dev_list, card_list) {
353 if (!strcmp(component->name, "i2c-10EC5670:00")) { 334 if (!strncmp(component->name,
335 ctx->codec_name, sizeof(ctx->codec_name))) {
354 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 336 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
355 337
356 dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); 338 dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n");
@@ -364,9 +346,11 @@ static int cht_suspend_pre(struct snd_soc_card *card)
364static int cht_resume_post(struct snd_soc_card *card) 346static int cht_resume_post(struct snd_soc_card *card)
365{ 347{
366 struct snd_soc_component *component; 348 struct snd_soc_component *component;
349 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
367 350
368 list_for_each_entry(component, &card->component_dev_list, card_list) { 351 list_for_each_entry(component, &card->component_dev_list, card_list) {
369 if (!strcmp(component->name, "i2c-10EC5670:00")) { 352 if (!strncmp(component->name,
353 ctx->codec_name, sizeof(ctx->codec_name))) {
370 struct snd_soc_codec *codec = snd_soc_component_to_codec(component); 354 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
371 355
372 dev_dbg(codec->dev, "enabling jack detect for resume.\n"); 356 dev_dbg(codec->dev, "enabling jack detect for resume.\n");
@@ -380,7 +364,7 @@ static int cht_resume_post(struct snd_soc_card *card)
380 364
381/* SoC card */ 365/* SoC card */
382static struct snd_soc_card snd_soc_card_cht = { 366static struct snd_soc_card snd_soc_card_cht = {
383 .name = "cherrytrailcraudio", 367 .name = "cht-bsw-rt5672",
384 .owner = THIS_MODULE, 368 .owner = THIS_MODULE,
385 .dai_link = cht_dailink, 369 .dai_link = cht_dailink,
386 .num_links = ARRAY_SIZE(cht_dailink), 370 .num_links = ARRAY_SIZE(cht_dailink),
@@ -394,25 +378,13 @@ static struct snd_soc_card snd_soc_card_cht = {
394 .resume_post = cht_resume_post, 378 .resume_post = cht_resume_post,
395}; 379};
396 380
397static bool is_valleyview(void)
398{
399 static const struct x86_cpu_id cpu_ids[] = {
400 { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
401 {}
402 };
403
404 if (!x86_match_cpu(cpu_ids))
405 return false;
406 return true;
407}
408
409#define RT5672_I2C_DEFAULT "i2c-10EC5670:00" 381#define RT5672_I2C_DEFAULT "i2c-10EC5670:00"
410 382
411static int snd_cht_mc_probe(struct platform_device *pdev) 383static int snd_cht_mc_probe(struct platform_device *pdev)
412{ 384{
413 int ret_val = 0; 385 int ret_val = 0;
414 struct cht_mc_private *drv; 386 struct cht_mc_private *drv;
415 struct sst_acpi_mach *mach = pdev->dev.platform_data; 387 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
416 const char *i2c_name; 388 const char *i2c_name;
417 int i; 389 int i;
418 390
@@ -424,7 +396,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
424 396
425 /* fixup codec name based on HID */ 397 /* fixup codec name based on HID */
426 if (mach) { 398 if (mach) {
427 i2c_name = sst_acpi_find_name_from_hid(mach->id); 399 i2c_name = snd_soc_acpi_find_name_from_hid(mach->id);
428 if (i2c_name) { 400 if (i2c_name) {
429 snprintf(drv->codec_name, sizeof(drv->codec_name), 401 snprintf(drv->codec_name, sizeof(drv->codec_name),
430 "i2c-%s", i2c_name); 402 "i2c-%s", i2c_name);
@@ -439,14 +411,12 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
439 } 411 }
440 } 412 }
441 413
442 if (is_valleyview()) { 414 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
443 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); 415 if (IS_ERR(drv->mclk)) {
444 if (IS_ERR(drv->mclk)) { 416 dev_err(&pdev->dev,
445 dev_err(&pdev->dev, 417 "Failed to get MCLK from pmc_plt_clk_3: %ld\n",
446 "Failed to get MCLK from pmc_plt_clk_3: %ld\n", 418 PTR_ERR(drv->mclk));
447 PTR_ERR(drv->mclk)); 419 return PTR_ERR(drv->mclk);
448 return PTR_ERR(drv->mclk);
449 }
450 } 420 }
451 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); 421 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
452 422
diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c
index 7f7607420706..6f9a8bcf20f3 100644
--- a/sound/soc/intel/boards/kbl_rt5663_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c
@@ -17,6 +17,7 @@
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 */ 18 */
19 19
20#include <linux/input.h>
20#include <linux/module.h> 21#include <linux/module.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <sound/core.h> 23#include <sound/core.h>
@@ -208,6 +209,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
208 int ret; 209 int ret;
209 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); 210 struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
210 struct snd_soc_codec *codec = rtd->codec; 211 struct snd_soc_codec *codec = rtd->codec;
212 struct snd_soc_jack *jack;
211 213
212 /* 214 /*
213 * Headset buttons map to the google Reference headset. 215 * Headset buttons map to the google Reference headset.
@@ -221,6 +223,13 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
221 dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); 223 dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
222 return ret; 224 return ret;
223 } 225 }
226
227 jack = &ctx->kabylake_headset;
228 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA);
229 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
230 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
231 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
232
224 rt5663_set_jack_detect(codec, &ctx->kabylake_headset); 233 rt5663_set_jack_detect(codec, &ctx->kabylake_headset);
225 return ret; 234 return ret;
226} 235}
@@ -341,13 +350,28 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
341 struct snd_interval *channels = hw_param_interval(params, 350 struct snd_interval *channels = hw_param_interval(params,
342 SNDRV_PCM_HW_PARAM_CHANNELS); 351 SNDRV_PCM_HW_PARAM_CHANNELS);
343 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 352 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
353 struct snd_soc_dpcm *dpcm = container_of(
354 params, struct snd_soc_dpcm, hw_params);
355 struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
356 struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
344 357
345 /* The ADSP will convert the FE rate to 48k, stereo */ 358 /*
346 rate->min = rate->max = 48000; 359 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
347 channels->min = channels->max = 2; 360 */
348 /* set SSP1 to 24 bit */ 361 if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
349 snd_mask_none(fmt); 362 !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
350 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); 363 !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
364 rate->min = rate->max = 48000;
365 channels->min = channels->max = 2;
366 snd_mask_none(fmt);
367 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
368 }
369 /*
370 * The speaker on the SSP0 supports S16_LE and not S24_LE.
371 * thus changing the mask here
372 */
373 if (!strcmp(be_dai_link->name, "SSP0-Codec"))
374 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
351 375
352 return 0; 376 return 0;
353} 377}
@@ -390,6 +414,43 @@ static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
390 return 0; 414 return 0;
391} 415}
392 416
417static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,
418 struct snd_pcm_hw_params *params)
419{
420 struct snd_soc_pcm_runtime *rtd = substream->private_data;
421 int ret = 0, j;
422
423 for (j = 0; j < rtd->num_codecs; j++) {
424 struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
425
426 if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
427 /*
428 * Use channel 4 and 5 for the first amp
429 */
430 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
431 if (ret < 0) {
432 dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
433 return ret;
434 }
435 }
436 if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) {
437 /*
438 * Use channel 6 and 7 for the second amp
439 */
440 ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
441 if (ret < 0) {
442 dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
443 return ret;
444 }
445 }
446 }
447 return ret;
448}
449
450static struct snd_soc_ops kabylake_ssp0_ops = {
451 .hw_params = kabylake_ssp0_hw_params,
452};
453
393static unsigned int channels_dmic[] = { 454static unsigned int channels_dmic[] = {
394 2, 4, 455 2, 4,
395}; 456};
@@ -593,12 +654,13 @@ static struct snd_soc_dai_link kabylake_dais[] = {
593 .no_pcm = 1, 654 .no_pcm = 1,
594 .codecs = max98927_codec_components, 655 .codecs = max98927_codec_components,
595 .num_codecs = ARRAY_SIZE(max98927_codec_components), 656 .num_codecs = ARRAY_SIZE(max98927_codec_components),
596 .dai_fmt = SND_SOC_DAIFMT_I2S | 657 .dai_fmt = SND_SOC_DAIFMT_DSP_B |
597 SND_SOC_DAIFMT_NB_NF | 658 SND_SOC_DAIFMT_NB_NF |
598 SND_SOC_DAIFMT_CBS_CFS, 659 SND_SOC_DAIFMT_CBS_CFS,
599 .ignore_pmdown_time = 1, 660 .ignore_pmdown_time = 1,
600 .be_hw_params_fixup = kabylake_ssp_fixup, 661 .be_hw_params_fixup = kabylake_ssp_fixup,
601 .dpcm_playback = 1, 662 .dpcm_playback = 1,
663 .ops = &kabylake_ssp0_ops,
602 }, 664 },
603 { 665 {
604 /* SSP1 - Codec */ 666 /* SSP1 - Codec */
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 69ab55956492..6072164f2d43 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -302,6 +302,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
302 * The ADSP will convert the FE rate to 48k, stereo, 24 bit 302 * The ADSP will convert the FE rate to 48k, stereo, 24 bit
303 */ 303 */
304 if (!strcmp(fe_dai_link->name, "Kbl Audio Port") || 304 if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
305 !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
305 !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) { 306 !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
306 rate->min = rate->max = 48000; 307 rate->min = rate->max = 48000;
307 channels->min = channels->max = 2; 308 channels->min = channels->max = 2;
diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 5ed0aa27b467..1b5a689dc99b 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -54,20 +54,6 @@ enum {
54 SKL_DPCM_AUDIO_HDMI3_PB, 54 SKL_DPCM_AUDIO_HDMI3_PB,
55}; 55};
56 56
57static inline struct snd_soc_dai *skl_get_codec_dai(struct snd_soc_card *card)
58{
59 struct snd_soc_pcm_runtime *rtd;
60
61 list_for_each_entry(rtd, &card->rtd_list, list) {
62
63 if (!strncmp(rtd->codec_dai->name, SKL_NUVOTON_CODEC_DAI,
64 strlen(SKL_NUVOTON_CODEC_DAI)))
65 return rtd->codec_dai;
66 }
67
68 return NULL;
69}
70
71static int platform_clock_control(struct snd_soc_dapm_widget *w, 57static int platform_clock_control(struct snd_soc_dapm_widget *w,
72 struct snd_kcontrol *k, int event) 58 struct snd_kcontrol *k, int event)
73{ 59{
@@ -76,7 +62,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
76 struct snd_soc_dai *codec_dai; 62 struct snd_soc_dai *codec_dai;
77 int ret; 63 int ret;
78 64
79 codec_dai = skl_get_codec_dai(card); 65 codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
80 if (!codec_dai) { 66 if (!codec_dai) {
81 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); 67 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
82 return -EIO; 68 return -EIO;
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index 01b8b140bb08..7bea4bc77481 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -57,20 +57,6 @@ enum {
57 SKL_DPCM_AUDIO_HDMI3_PB, 57 SKL_DPCM_AUDIO_HDMI3_PB,
58}; 58};
59 59
60static inline struct snd_soc_dai *skl_get_codec_dai(struct snd_soc_card *card)
61{
62 struct snd_soc_pcm_runtime *rtd;
63
64 list_for_each_entry(rtd, &card->rtd_list, list) {
65
66 if (!strncmp(rtd->codec_dai->name, SKL_NUVOTON_CODEC_DAI,
67 strlen(SKL_NUVOTON_CODEC_DAI)))
68 return rtd->codec_dai;
69 }
70
71 return NULL;
72}
73
74static const struct snd_kcontrol_new skylake_controls[] = { 60static const struct snd_kcontrol_new skylake_controls[] = {
75 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 61 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
76 SOC_DAPM_PIN_SWITCH("Headset Mic"), 62 SOC_DAPM_PIN_SWITCH("Headset Mic"),
@@ -86,7 +72,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
86 struct snd_soc_dai *codec_dai; 72 struct snd_soc_dai *codec_dai;
87 int ret; 73 int ret;
88 74
89 codec_dai = skl_get_codec_dai(card); 75 codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
90 if (!codec_dai) { 76 if (!codec_dai) {
91 dev_err(card->dev, "Codec dai not found\n"); 77 dev_err(card->dev, "Codec dai not found\n");
92 return -EIO; 78 return -EIO;
diff --git a/sound/soc/intel/common/Makefile b/sound/soc/intel/common/Makefile
index 0e029f354f6b..7379d8830c39 100644
--- a/sound/soc/intel/common/Makefile
+++ b/sound/soc/intel/common/Makefile
@@ -1,11 +1,11 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2snd-soc-sst-dsp-objs := sst-dsp.o 2snd-soc-sst-dsp-objs := sst-dsp.o
3snd-soc-sst-acpi-objs := sst-acpi.o 3snd-soc-sst-acpi-objs := sst-acpi.o
4snd-soc-sst-match-objs := sst-match-acpi.o
5snd-soc-sst-ipc-objs := sst-ipc.o 4snd-soc-sst-ipc-objs := sst-ipc.o
6snd-soc-sst-firmware-objs := sst-firmware.o 5snd-soc-sst-firmware-objs := sst-firmware.o
6snd-soc-acpi-intel-match-objs := soc-acpi-intel-byt-match.o soc-acpi-intel-cht-match.o soc-acpi-intel-hsw-bdw-match.o
7 7
8obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o 8obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o
9obj-$(CONFIG_SND_SOC_INTEL_SST_ACPI) += snd-soc-sst-acpi.o 9obj-$(CONFIG_SND_SOC_INTEL_SST_ACPI) += snd-soc-sst-acpi.o
10obj-$(CONFIG_SND_SOC_INTEL_SST_MATCH) += snd-soc-sst-match.o
11obj-$(CONFIG_SND_SOC_INTEL_SST_FIRMWARE) += snd-soc-sst-firmware.o 10obj-$(CONFIG_SND_SOC_INTEL_SST_FIRMWARE) += snd-soc-sst-firmware.o
11obj-$(CONFIG_SND_SOC_ACPI_INTEL_MATCH) += snd-soc-acpi-intel-match.o
diff --git a/sound/soc/intel/common/soc-acpi-intel-byt-match.c b/sound/soc/intel/common/soc-acpi-intel-byt-match.c
new file mode 100644
index 000000000000..bfe1ca68a542
--- /dev/null
+++ b/sound/soc/intel/common/soc-acpi-intel-byt-match.c
@@ -0,0 +1,196 @@
1/*
2 * soc-apci-intel-byt-match.c - tables and support for BYT ACPI enumeration.
3 *
4 * Copyright (c) 2017, Intel Corporation.
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 */
16
17#include <linux/dmi.h>
18#include <sound/soc-acpi.h>
19#include <sound/soc-acpi-intel-match.h>
20
21static unsigned long byt_machine_id;
22
23#define BYT_THINKPAD_10 1
24
25static int byt_thinkpad10_quirk_cb(const struct dmi_system_id *id)
26{
27 byt_machine_id = BYT_THINKPAD_10;
28 return 1;
29}
30
31
32static const struct dmi_system_id byt_table[] = {
33 {
34 .callback = byt_thinkpad10_quirk_cb,
35 .matches = {
36 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
37 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 10"),
38 },
39 },
40 {
41 .callback = byt_thinkpad10_quirk_cb,
42 .matches = {
43 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
44 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Tablet B"),
45 },
46 },
47 {
48 .callback = byt_thinkpad10_quirk_cb,
49 .matches = {
50 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
51 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"),
52 },
53 },
54 { }
55};
56
57static struct snd_soc_acpi_mach byt_thinkpad_10 = {
58 .id = "10EC5640",
59 .drv_name = "cht-bsw-rt5672",
60 .fw_filename = "intel/fw_sst_0f28.bin",
61 .board = "cht-bsw",
62 .sof_fw_filename = "intel/reef-byt.ri",
63 .sof_tplg_filename = "intel/reef-byt-rt5670.tplg",
64 .asoc_plat_name = "sst-mfld-platform",
65};
66
67static struct snd_soc_acpi_mach *byt_quirk(void *arg)
68{
69 struct snd_soc_acpi_mach *mach = arg;
70
71 dmi_check_system(byt_table);
72
73 if (byt_machine_id == BYT_THINKPAD_10)
74 return &byt_thinkpad_10;
75 else
76 return mach;
77}
78
79struct snd_soc_acpi_mach snd_soc_acpi_intel_baytrail_legacy_machines[] = {
80 {
81 .id = "10EC5640",
82 .drv_name = "byt-rt5640",
83 .fw_filename = "intel/fw_sst_0f28.bin-48kHz_i2s_master",
84 },
85 {
86 .id = "193C9890",
87 .drv_name = "byt-max98090",
88 .fw_filename = "intel/fw_sst_0f28.bin-48kHz_i2s_master",
89 },
90 {}
91};
92EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_baytrail_legacy_machines);
93
94struct snd_soc_acpi_mach snd_soc_acpi_intel_baytrail_machines[] = {
95 {
96 .id = "10EC5640",
97 .drv_name = "bytcr_rt5640",
98 .fw_filename = "intel/fw_sst_0f28.bin",
99 .board = "bytcr_rt5640",
100 .machine_quirk = byt_quirk,
101 .sof_fw_filename = "intel/reef-byt.ri",
102 .sof_tplg_filename = "intel/reef-byt-rt5640.tplg",
103 .asoc_plat_name = "sst-mfld-platform",
104 },
105 {
106 .id = "10EC5642",
107 .drv_name = "bytcr_rt5640",
108 .fw_filename = "intel/fw_sst_0f28.bin",
109 .board = "bytcr_rt5640",
110 .sof_fw_filename = "intel/reef-byt.ri",
111 .sof_tplg_filename = "intel/reef-byt-rt5640.tplg",
112 .asoc_plat_name = "sst-mfld-platform",
113 },
114 {
115 .id = "INTCCFFD",
116 .drv_name = "bytcr_rt5640",
117 .fw_filename = "intel/fw_sst_0f28.bin",
118 .board = "bytcr_rt5640",
119 .sof_fw_filename = "intel/reef-byt.ri",
120 .sof_tplg_filename = "intel/reef-byt-rt5640.tplg",
121 .asoc_plat_name = "sst-mfld-platform",
122 },
123 {
124 .id = "10EC5651",
125 .drv_name = "bytcr_rt5651",
126 .fw_filename = "intel/fw_sst_0f28.bin",
127 .board = "bytcr_rt5651",
128 .sof_fw_filename = "intel/reef-byt.ri",
129 .sof_tplg_filename = "intel/reef-byt-rt5651.tplg",
130 .asoc_plat_name = "sst-mfld-platform",
131 },
132 {
133 .id = "DLGS7212",
134 .drv_name = "bytcht_da7213",
135 .fw_filename = "intel/fw_sst_0f28.bin",
136 .board = "bytcht_da7213",
137 .sof_fw_filename = "intel/reef-byt.ri",
138 .sof_tplg_filename = "intel/reef-byt-da7213.tplg",
139 .asoc_plat_name = "sst-mfld-platform",
140 },
141 {
142 .id = "DLGS7213",
143 .drv_name = "bytcht_da7213",
144 .fw_filename = "intel/fw_sst_0f28.bin",
145 .board = "bytcht_da7213",
146 .sof_fw_filename = "intel/reef-byt.ri",
147 .sof_tplg_filename = "intel/reef-byt-da7213.tplg",
148 .asoc_plat_name = "sst-mfld-platform",
149 },
150 /* some Baytrail platforms rely on RT5645, use CHT machine driver */
151 {
152 .id = "10EC5645",
153 .drv_name = "cht-bsw-rt5645",
154 .fw_filename = "intel/fw_sst_0f28.bin",
155 .board = "cht-bsw",
156 .sof_fw_filename = "intel/reef-byt.ri",
157 .sof_tplg_filename = "intel/reef-byt-rt5645.tplg",
158 .asoc_plat_name = "sst-mfld-platform",
159 },
160 {
161 .id = "10EC5648",
162 .drv_name = "cht-bsw-rt5645",
163 .fw_filename = "intel/fw_sst_0f28.bin",
164 .board = "cht-bsw",
165 .sof_fw_filename = "intel/reef-byt.ri",
166 .sof_tplg_filename = "intel/reef-byt-rt5645.tplg",
167 .asoc_plat_name = "sst-mfld-platform",
168 },
169 /* use CHT driver to Baytrail Chromebooks */
170 {
171 .id = "193C9890",
172 .drv_name = "cht-bsw-max98090",
173 .fw_filename = "intel/fw_sst_0f28.bin",
174 .board = "cht-bsw",
175 .sof_fw_filename = "intel/reef-byt.ri",
176 .sof_tplg_filename = "intel/reef-byt-max98090.tplg",
177 .asoc_plat_name = "sst-mfld-platform",
178 },
179#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
180 /*
181 * This is always last in the table so that it is selected only when
182 * enabled explicitly and there is no codec-related information in SSDT
183 */
184 {
185 .id = "80860F28",
186 .drv_name = "bytcht_nocodec",
187 .fw_filename = "intel/fw_sst_0f28.bin",
188 .board = "bytcht_nocodec",
189 },
190#endif
191 {},
192};
193EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_baytrail_machines);
194
195MODULE_LICENSE("GPL v2");
196MODULE_DESCRIPTION("Intel Common ACPI Match module");
diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
new file mode 100644
index 000000000000..b50a0d53846b
--- /dev/null
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
@@ -0,0 +1,194 @@
1/*
2 * soc-apci-intel-cht-match.c - tables and support for CHT ACPI enumeration.
3 *
4 * Copyright (c) 2017, Intel Corporation.
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 */
16
17#include <linux/dmi.h>
18#include <sound/soc-acpi.h>
19#include <sound/soc-acpi-intel-match.h>
20
21static unsigned long cht_machine_id;
22
23#define CHT_SURFACE_MACH 1
24
25static int cht_surface_quirk_cb(const struct dmi_system_id *id)
26{
27 cht_machine_id = CHT_SURFACE_MACH;
28 return 1;
29}
30
31static const struct dmi_system_id cht_table[] = {
32 {
33 .callback = cht_surface_quirk_cb,
34 .matches = {
35 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
36 DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
37 },
38 },
39 { }
40};
41
42static struct snd_soc_acpi_mach cht_surface_mach = {
43 .id = "10EC5640",
44 .drv_name = "cht-bsw-rt5645",
45 .fw_filename = "intel/fw_sst_22a8.bin",
46 .board = "cht-bsw",
47 .sof_fw_filename = "intel/reef-cht.ri",
48 .sof_tplg_filename = "intel/reef-cht-rt5645.tplg",
49 .asoc_plat_name = "sst-mfld-platform",
50};
51
52static struct snd_soc_acpi_mach *cht_quirk(void *arg)
53{
54 struct snd_soc_acpi_mach *mach = arg;
55
56 dmi_check_system(cht_table);
57
58 if (cht_machine_id == CHT_SURFACE_MACH)
59 return &cht_surface_mach;
60 else
61 return mach;
62}
63
64/* Cherryview-based platforms: CherryTrail and Braswell */
65struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = {
66 {
67 .id = "10EC5670",
68 .drv_name = "cht-bsw-rt5672",
69 .fw_filename = "intel/fw_sst_22a8.bin",
70 .board = "cht-bsw",
71 .sof_fw_filename = "intel/reef-cht.ri",
72 .sof_tplg_filename = "intel/reef-cht-rt5670.tplg",
73 .asoc_plat_name = "sst-mfld-platform",
74 },
75 {
76 .id = "10EC5672",
77 .drv_name = "cht-bsw-rt5672",
78 .fw_filename = "intel/fw_sst_22a8.bin",
79 .board = "cht-bsw",
80 .sof_fw_filename = "intel/reef-cht.ri",
81 .sof_tplg_filename = "intel/reef-cht-rt5670.tplg",
82 .asoc_plat_name = "sst-mfld-platform",
83 },
84 {
85 .id = "10EC5645",
86 .drv_name = "cht-bsw-rt5645",
87 .fw_filename = "intel/fw_sst_22a8.bin",
88 .board = "cht-bsw",
89 .sof_fw_filename = "intel/reef-cht.ri",
90 .sof_tplg_filename = "intel/reef-cht-rt5645.tplg",
91 .asoc_plat_name = "sst-mfld-platform",
92 },
93 {
94 .id = "10EC5650",
95 .drv_name = "cht-bsw-rt5645",
96 .fw_filename = "intel/fw_sst_22a8.bin",
97 .board = "cht-bsw",
98 .sof_fw_filename = "intel/reef-cht.ri",
99 .sof_tplg_filename = "intel/reef-cht-rt5645.tplg",
100 .asoc_plat_name = "sst-mfld-platform",
101 },
102 {
103 .id = "10EC3270",
104 .drv_name = "cht-bsw-rt5645",
105 .fw_filename = "intel/fw_sst_22a8.bin",
106 .board = "cht-bsw",
107 .sof_fw_filename = "intel/reef-cht.ri",
108 .sof_tplg_filename = "intel/reef-cht-rt5645.tplg",
109 .asoc_plat_name = "sst-mfld-platform",
110 },
111 {
112 .id = "193C9890",
113 .drv_name = "cht-bsw-max98090",
114 .fw_filename = "intel/fw_sst_22a8.bin",
115 .board = "cht-bsw",
116 .sof_fw_filename = "intel/reef-cht.ri",
117 .sof_tplg_filename = "intel/reef-cht-max98090.tplg",
118 .asoc_plat_name = "sst-mfld-platform",
119 },
120 {
121 .id = "DLGS7212",
122 .drv_name = "bytcht_da7213",
123 .fw_filename = "intel/fw_sst_22a8.bin",
124 .board = "bytcht_da7213",
125 .sof_fw_filename = "intel/reef-cht.ri",
126 .sof_tplg_filename = "intel/reef-cht-da7213.tplg",
127 .asoc_plat_name = "sst-mfld-platform",
128 },
129 {
130 .id = "DLGS7213",
131 .drv_name = "bytcht_da7213",
132 .fw_filename = "intel/fw_sst_22a8.bin",
133 .board = "bytcht_da7213",
134 .sof_fw_filename = "intel/reef-cht.ri",
135 .sof_tplg_filename = "intel/reef-cht-da7213.tplg",
136 .asoc_plat_name = "sst-mfld-platform",
137 },
138 {
139 .id = "ESSX8316",
140 .drv_name = "bytcht_es8316",
141 .fw_filename = "intel/fw_sst_22a8.bin",
142 .board = "bytcht_es8316",
143 .sof_fw_filename = "intel/reef-cht.ri",
144 .sof_tplg_filename = "intel/reef-cht-es8316.tplg",
145 .asoc_plat_name = "sst-mfld-platform",
146 },
147 /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
148 {
149 .id = "10EC5640",
150 .drv_name = "bytcr_rt5640",
151 .fw_filename = "intel/fw_sst_22a8.bin",
152 .board = "bytcr_rt5640",
153 .machine_quirk = cht_quirk,
154 .sof_fw_filename = "intel/reef-cht.ri",
155 .sof_tplg_filename = "intel/reef-cht-rt5640.tplg",
156 .asoc_plat_name = "sst-mfld-platform",
157 },
158 {
159 .id = "10EC3276",
160 .drv_name = "bytcr_rt5640",
161 .fw_filename = "intel/fw_sst_22a8.bin",
162 .board = "bytcr_rt5640",
163 .sof_fw_filename = "intel/reef-cht.ri",
164 .sof_tplg_filename = "intel/reef-cht-rt5640.tplg",
165 .asoc_plat_name = "sst-mfld-platform",
166 },
167 /* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
168 {
169 .id = "10EC5651",
170 .drv_name = "bytcr_rt5651",
171 .fw_filename = "intel/fw_sst_22a8.bin",
172 .board = "bytcr_rt5651",
173 .sof_fw_filename = "intel/reef-cht.ri",
174 .sof_tplg_filename = "intel/reef-cht-rt5651.tplg",
175 .asoc_plat_name = "sst-mfld-platform",
176 },
177#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
178 /*
179 * This is always last in the table so that it is selected only when
180 * enabled explicitly and there is no codec-related information in SSDT
181 */
182 {
183 .id = "808622A8",
184 .drv_name = "bytcht_nocodec",
185 .fw_filename = "intel/fw_sst_22a8.bin",
186 .board = "bytcht_nocodec",
187 },
188#endif
189 {},
190};
191EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cherrytrail_machines);
192
193MODULE_LICENSE("GPL v2");
194MODULE_DESCRIPTION("Intel Common ACPI Match module");
diff --git a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c
new file mode 100644
index 000000000000..e0e8c8c27528
--- /dev/null
+++ b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c
@@ -0,0 +1,64 @@
1/*
2 * soc-apci-intel-hsw-bdw-match.c - tables and support for ACPI enumeration.
3 *
4 * Copyright (c) 2017, Intel Corporation.
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 */
16
17#include <linux/dmi.h>
18#include <sound/soc-acpi.h>
19#include <sound/soc-acpi-intel-match.h>
20
21struct snd_soc_acpi_mach snd_soc_acpi_intel_haswell_machines[] = {
22 {
23 .id = "INT33CA",
24 .drv_name = "haswell-audio",
25 .fw_filename = "intel/IntcSST1.bin",
26 .sof_fw_filename = "intel/reef-hsw.ri",
27 .sof_tplg_filename = "intel/reef-hsw.tplg",
28 .asoc_plat_name = "haswell-pcm-audio",
29 },
30 {}
31};
32EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_haswell_machines);
33
34struct snd_soc_acpi_mach snd_soc_acpi_intel_broadwell_machines[] = {
35 {
36 .id = "INT343A",
37 .drv_name = "broadwell-audio",
38 .fw_filename = "intel/IntcSST2.bin",
39 .sof_fw_filename = "intel/reef-bdw.ri",
40 .sof_tplg_filename = "intel/reef-bdw-rt286.tplg",
41 .asoc_plat_name = "haswell-pcm-audio",
42 },
43 {
44 .id = "RT5677CE",
45 .drv_name = "bdw-rt5677",
46 .fw_filename = "intel/IntcSST2.bin",
47 .sof_fw_filename = "intel/reef-bdw.ri",
48 .sof_tplg_filename = "intel/reef-bdw-rt286.tplg",
49 .asoc_plat_name = "haswell-pcm-audio",
50 },
51 {
52 .id = "INT33CA",
53 .drv_name = "haswell-audio",
54 .fw_filename = "intel/IntcSST2.bin",
55 .sof_fw_filename = "intel/reef-bdw.ri",
56 .sof_tplg_filename = "intel/reef-bdw-rt5640.tplg",
57 .asoc_plat_name = "haswell-pcm-audio",
58 },
59 {}
60};
61EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_broadwell_machines);
62
63MODULE_LICENSE("GPL v2");
64MODULE_DESCRIPTION("Intel Common ACPI Match module");
diff --git a/sound/soc/intel/common/sst-acpi.c b/sound/soc/intel/common/sst-acpi.c
index 1285cc597b6b..cf6fbbd4e378 100644
--- a/sound/soc/intel/common/sst-acpi.c
+++ b/sound/soc/intel/common/sst-acpi.c
@@ -21,7 +21,8 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22 22
23#include "sst-dsp.h" 23#include "sst-dsp.h"
24#include "sst-acpi.h" 24#include <sound/soc-acpi.h>
25#include <sound/soc-acpi-intel-match.h>
25 26
26#define SST_LPT_DSP_DMA_ADDR_OFFSET 0x0F0000 27#define SST_LPT_DSP_DMA_ADDR_OFFSET 0x0F0000
27#define SST_WPT_DSP_DMA_ADDR_OFFSET 0x0FE000 28#define SST_WPT_DSP_DMA_ADDR_OFFSET 0x0FE000
@@ -30,7 +31,7 @@
30/* Descriptor for setting up SST platform data */ 31/* Descriptor for setting up SST platform data */
31struct sst_acpi_desc { 32struct sst_acpi_desc {
32 const char *drv_name; 33 const char *drv_name;
33 struct sst_acpi_mach *machines; 34 struct snd_soc_acpi_mach *machines;
34 /* Platform resource indexes. Must set to -1 if not used */ 35 /* Platform resource indexes. Must set to -1 if not used */
35 int resindex_lpe_base; 36 int resindex_lpe_base;
36 int resindex_pcicfg_base; 37 int resindex_pcicfg_base;
@@ -49,7 +50,7 @@ struct sst_acpi_priv {
49 struct platform_device *pdev_pcm; 50 struct platform_device *pdev_pcm;
50 struct sst_pdata sst_pdata; 51 struct sst_pdata sst_pdata;
51 struct sst_acpi_desc *desc; 52 struct sst_acpi_desc *desc;
52 struct sst_acpi_mach *mach; 53 struct snd_soc_acpi_mach *mach;
53}; 54};
54 55
55static void sst_acpi_fw_cb(const struct firmware *fw, void *context) 56static void sst_acpi_fw_cb(const struct firmware *fw, void *context)
@@ -59,7 +60,7 @@ static void sst_acpi_fw_cb(const struct firmware *fw, void *context)
59 struct sst_acpi_priv *sst_acpi = platform_get_drvdata(pdev); 60 struct sst_acpi_priv *sst_acpi = platform_get_drvdata(pdev);
60 struct sst_pdata *sst_pdata = &sst_acpi->sst_pdata; 61 struct sst_pdata *sst_pdata = &sst_acpi->sst_pdata;
61 struct sst_acpi_desc *desc = sst_acpi->desc; 62 struct sst_acpi_desc *desc = sst_acpi->desc;
62 struct sst_acpi_mach *mach = sst_acpi->mach; 63 struct snd_soc_acpi_mach *mach = sst_acpi->mach;
63 64
64 sst_pdata->fw = fw; 65 sst_pdata->fw = fw;
65 if (!fw) { 66 if (!fw) {
@@ -85,7 +86,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
85 struct device *dev = &pdev->dev; 86 struct device *dev = &pdev->dev;
86 struct sst_acpi_priv *sst_acpi; 87 struct sst_acpi_priv *sst_acpi;
87 struct sst_pdata *sst_pdata; 88 struct sst_pdata *sst_pdata;
88 struct sst_acpi_mach *mach; 89 struct snd_soc_acpi_mach *mach;
89 struct sst_acpi_desc *desc; 90 struct sst_acpi_desc *desc;
90 struct resource *mmio; 91 struct resource *mmio;
91 int ret = 0; 92 int ret = 0;
@@ -99,7 +100,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
99 return -ENODEV; 100 return -ENODEV;
100 101
101 desc = (struct sst_acpi_desc *)id->driver_data; 102 desc = (struct sst_acpi_desc *)id->driver_data;
102 mach = sst_acpi_find_machine(desc->machines); 103 mach = snd_soc_acpi_find_machine(desc->machines);
103 if (mach == NULL) { 104 if (mach == NULL) {
104 dev_err(dev, "No matching ASoC machine driver found\n"); 105 dev_err(dev, "No matching ASoC machine driver found\n");
105 return -ENODEV; 106 return -ENODEV;
@@ -179,14 +180,9 @@ static int sst_acpi_remove(struct platform_device *pdev)
179 return 0; 180 return 0;
180} 181}
181 182
182static struct sst_acpi_mach haswell_machines[] = {
183 { "INT33CA", "haswell-audio", "intel/IntcSST1.bin", NULL, NULL, NULL },
184 {}
185};
186
187static struct sst_acpi_desc sst_acpi_haswell_desc = { 183static struct sst_acpi_desc sst_acpi_haswell_desc = {
188 .drv_name = "haswell-pcm-audio", 184 .drv_name = "haswell-pcm-audio",
189 .machines = haswell_machines, 185 .machines = snd_soc_acpi_intel_haswell_machines,
190 .resindex_lpe_base = 0, 186 .resindex_lpe_base = 0,
191 .resindex_pcicfg_base = 1, 187 .resindex_pcicfg_base = 1,
192 .resindex_fw_base = -1, 188 .resindex_fw_base = -1,
@@ -197,15 +193,9 @@ static struct sst_acpi_desc sst_acpi_haswell_desc = {
197 .dma_size = SST_LPT_DSP_DMA_SIZE, 193 .dma_size = SST_LPT_DSP_DMA_SIZE,
198}; 194};
199 195
200static struct sst_acpi_mach broadwell_machines[] = {
201 { "INT343A", "broadwell-audio", "intel/IntcSST2.bin", NULL, NULL, NULL },
202 { "RT5677CE", "bdw-rt5677", "intel/IntcSST2.bin", NULL, NULL, NULL },
203 {}
204};
205
206static struct sst_acpi_desc sst_acpi_broadwell_desc = { 196static struct sst_acpi_desc sst_acpi_broadwell_desc = {
207 .drv_name = "haswell-pcm-audio", 197 .drv_name = "haswell-pcm-audio",
208 .machines = broadwell_machines, 198 .machines = snd_soc_acpi_intel_broadwell_machines,
209 .resindex_lpe_base = 0, 199 .resindex_lpe_base = 0,
210 .resindex_pcicfg_base = 1, 200 .resindex_pcicfg_base = 1,
211 .resindex_fw_base = -1, 201 .resindex_fw_base = -1,
@@ -217,15 +207,9 @@ static struct sst_acpi_desc sst_acpi_broadwell_desc = {
217}; 207};
218 208
219#if !IS_ENABLED(CONFIG_SND_SST_IPC_ACPI) 209#if !IS_ENABLED(CONFIG_SND_SST_IPC_ACPI)
220static struct sst_acpi_mach baytrail_machines[] = {
221 { "10EC5640", "byt-rt5640", "intel/fw_sst_0f28.bin-48kHz_i2s_master", NULL, NULL, NULL },
222 { "193C9890", "byt-max98090", "intel/fw_sst_0f28.bin-48kHz_i2s_master", NULL, NULL, NULL },
223 {}
224};
225
226static struct sst_acpi_desc sst_acpi_baytrail_desc = { 210static struct sst_acpi_desc sst_acpi_baytrail_desc = {
227 .drv_name = "baytrail-pcm-audio", 211 .drv_name = "baytrail-pcm-audio",
228 .machines = baytrail_machines, 212 .machines = snd_soc_acpi_intel_baytrail_legacy_machines,
229 .resindex_lpe_base = 0, 213 .resindex_lpe_base = 0,
230 .resindex_pcicfg_base = 1, 214 .resindex_pcicfg_base = 1,
231 .resindex_fw_base = 2, 215 .resindex_fw_base = 2,
diff --git a/sound/soc/intel/common/sst-acpi.h b/sound/soc/intel/common/sst-acpi.h
deleted file mode 100644
index afe9b87b8bd5..000000000000
--- a/sound/soc/intel/common/sst-acpi.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License version
6 * 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <linux/stddef.h>
16#include <linux/acpi.h>
17
18struct sst_acpi_package_context {
19 char *name; /* package name */
20 int length; /* number of elements */
21 struct acpi_buffer *format;
22 struct acpi_buffer *state;
23 bool data_valid;
24};
25
26#if IS_ENABLED(CONFIG_ACPI)
27/* translation fron HID to I2C name, needed for DAI codec_name */
28const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
29bool sst_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
30 struct sst_acpi_package_context *ctx);
31#else
32static inline const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
33{
34 return NULL;
35}
36static inline bool sst_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
37 struct sst_acpi_package_context *ctx)
38{
39 return false;
40}
41#endif
42
43/* acpi match */
44struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines);
45
46/* acpi check hid */
47bool sst_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);
48
49/* Descriptor for SST ASoC machine driver */
50struct sst_acpi_mach {
51 /* ACPI ID for the matching machine driver. Audio codec for instance */
52 const u8 id[ACPI_ID_LEN];
53 /* machine driver name */
54 const char *drv_name;
55 /* firmware file name */
56 const char *fw_filename;
57
58 /* board name */
59 const char *board;
60 struct sst_acpi_mach * (*machine_quirk)(void *arg);
61 const void *quirk_data;
62 void *pdata;
63};
64
65#define SST_ACPI_MAX_CODECS 3
66
67/**
68 * struct sst_codecs: Structure to hold secondary codec information apart from
69 * the matched one, this data will be passed to the quirk function to match
70 * with the ACPI detected devices
71 *
72 * @num_codecs: number of secondary codecs used in the platform
73 * @codecs: holds the codec IDs
74 *
75 */
76struct sst_codecs {
77 int num_codecs;
78 u8 codecs[SST_ACPI_MAX_CODECS][ACPI_ID_LEN];
79};
80
81/* check all codecs */
82struct sst_acpi_mach *sst_acpi_codec_list(void *arg);
diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index a086c35f91bb..657afc02f1c4 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -19,6 +19,7 @@
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/firmware.h> 20#include <linux/firmware.h>
21#include <linux/export.h> 21#include <linux/export.h>
22#include <linux/module.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
24#include <linux/dmaengine.h> 25#include <linux/dmaengine.h>
@@ -274,7 +275,6 @@ int sst_dma_new(struct sst_dsp *sst)
274 struct sst_pdata *sst_pdata = sst->pdata; 275 struct sst_pdata *sst_pdata = sst->pdata;
275 struct sst_dma *dma; 276 struct sst_dma *dma;
276 struct resource mem; 277 struct resource mem;
277 const char *dma_dev_name;
278 int ret = 0; 278 int ret = 0;
279 279
280 if (sst->pdata->resindex_dma_base == -1) 280 if (sst->pdata->resindex_dma_base == -1)
@@ -285,7 +285,6 @@ int sst_dma_new(struct sst_dsp *sst)
285 * is attached to the ADSP IP. */ 285 * is attached to the ADSP IP. */
286 switch (sst->pdata->dma_engine) { 286 switch (sst->pdata->dma_engine) {
287 case SST_DMA_TYPE_DW: 287 case SST_DMA_TYPE_DW:
288 dma_dev_name = "dw_dmac";
289 break; 288 break;
290 default: 289 default:
291 dev_err(sst->dev, "error: invalid DMA engine %d\n", 290 dev_err(sst->dev, "error: invalid DMA engine %d\n",
diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index b9c205c8bb73..61b5bfa79d13 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -613,8 +613,10 @@ skip_buf_size_calc:
613} 613}
614 614
615#define DMA_CONTROL_ID 5 615#define DMA_CONTROL_ID 5
616#define DMA_I2S_BLOB_SIZE 21
616 617
617int skl_dsp_set_dma_control(struct skl_sst *ctx, struct skl_module_cfg *mconfig) 618int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps,
619 u32 caps_size, u32 node_id)
618{ 620{
619 struct skl_dma_control *dma_ctrl; 621 struct skl_dma_control *dma_ctrl;
620 struct skl_ipc_large_config_msg msg = {0}; 622 struct skl_ipc_large_config_msg msg = {0};
@@ -624,24 +626,27 @@ int skl_dsp_set_dma_control(struct skl_sst *ctx, struct skl_module_cfg *mconfig)
624 /* 626 /*
625 * if blob size zero, then return 627 * if blob size zero, then return
626 */ 628 */
627 if (mconfig->formats_config.caps_size == 0) 629 if (caps_size == 0)
628 return 0; 630 return 0;
629 631
630 msg.large_param_id = DMA_CONTROL_ID; 632 msg.large_param_id = DMA_CONTROL_ID;
631 msg.param_data_size = sizeof(struct skl_dma_control) + 633 msg.param_data_size = sizeof(struct skl_dma_control) + caps_size;
632 mconfig->formats_config.caps_size;
633 634
634 dma_ctrl = kzalloc(msg.param_data_size, GFP_KERNEL); 635 dma_ctrl = kzalloc(msg.param_data_size, GFP_KERNEL);
635 if (dma_ctrl == NULL) 636 if (dma_ctrl == NULL)
636 return -ENOMEM; 637 return -ENOMEM;
637 638
638 dma_ctrl->node_id = skl_get_node_id(ctx, mconfig); 639 dma_ctrl->node_id = node_id;
639 640
640 /* size in dwords */ 641 /*
641 dma_ctrl->config_length = mconfig->formats_config.caps_size / 4; 642 * NHLT blob may contain additional configs along with i2s blob.
643 * firmware expects only the i2s blob size as the config_length.
644 * So fix to i2s blob size.
645 * size in dwords.
646 */
647 dma_ctrl->config_length = DMA_I2S_BLOB_SIZE;
642 648
643 memcpy(dma_ctrl->config_data, mconfig->formats_config.caps, 649 memcpy(dma_ctrl->config_data, caps, caps_size);
644 mconfig->formats_config.caps_size);
645 650
646 err = skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)dma_ctrl); 651 err = skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)dma_ctrl);
647 652
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index a3cb204e9640..1dd97479e0c0 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -653,7 +653,7 @@ static const struct snd_soc_dai_ops skl_link_dai_ops = {
653 .trigger = skl_link_pcm_trigger, 653 .trigger = skl_link_pcm_trigger,
654}; 654};
655 655
656static struct snd_soc_dai_driver skl_platform_dai[] = { 656static struct snd_soc_dai_driver skl_fe_dai[] = {
657{ 657{
658 .name = "System Pin", 658 .name = "System Pin",
659 .ops = &skl_pcm_dai_ops, 659 .ops = &skl_pcm_dai_ops,
@@ -797,8 +797,10 @@ static struct snd_soc_dai_driver skl_platform_dai[] = {
797 .sig_bits = 32, 797 .sig_bits = 32,
798 }, 798 },
799}, 799},
800};
800 801
801/* BE CPU Dais */ 802/* BE CPU Dais */
803static struct snd_soc_dai_driver skl_platform_dai[] = {
802{ 804{
803 .name = "SSP0 Pin", 805 .name = "SSP0 Pin",
804 .ops = &skl_be_ssp_dai_ops, 806 .ops = &skl_be_ssp_dai_ops,
@@ -976,6 +978,14 @@ static struct snd_soc_dai_driver skl_platform_dai[] = {
976}, 978},
977}; 979};
978 980
981int skl_dai_load(struct snd_soc_component *cmp,
982 struct snd_soc_dai_driver *pcm_dai)
983{
984 pcm_dai->ops = &skl_pcm_dai_ops;
985
986 return 0;
987}
988
979static int skl_platform_open(struct snd_pcm_substream *substream) 989static int skl_platform_open(struct snd_pcm_substream *substream)
980{ 990{
981 struct snd_soc_pcm_runtime *rtd = substream->private_data; 991 struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -1363,6 +1373,8 @@ int skl_platform_register(struct device *dev)
1363 int ret; 1373 int ret;
1364 struct hdac_ext_bus *ebus = dev_get_drvdata(dev); 1374 struct hdac_ext_bus *ebus = dev_get_drvdata(dev);
1365 struct skl *skl = ebus_to_skl(ebus); 1375 struct skl *skl = ebus_to_skl(ebus);
1376 struct snd_soc_dai_driver *dais;
1377 int num_dais = ARRAY_SIZE(skl_platform_dai);
1366 1378
1367 INIT_LIST_HEAD(&skl->ppl_list); 1379 INIT_LIST_HEAD(&skl->ppl_list);
1368 INIT_LIST_HEAD(&skl->bind_list); 1380 INIT_LIST_HEAD(&skl->bind_list);
@@ -1372,14 +1384,38 @@ int skl_platform_register(struct device *dev)
1372 dev_err(dev, "soc platform registration failed %d\n", ret); 1384 dev_err(dev, "soc platform registration failed %d\n", ret);
1373 return ret; 1385 return ret;
1374 } 1386 }
1387
1388 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1389 GFP_KERNEL);
1390 if (!skl->dais) {
1391 ret = -ENOMEM;
1392 goto err;
1393 }
1394
1395 if (!skl->use_tplg_pcm) {
1396 dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
1397 sizeof(skl_platform_dai), GFP_KERNEL);
1398 if (!dais) {
1399 ret = -ENOMEM;
1400 goto err;
1401 }
1402
1403 skl->dais = dais;
1404 memcpy(&skl->dais[ARRAY_SIZE(skl_platform_dai)], skl_fe_dai,
1405 sizeof(skl_fe_dai));
1406 num_dais += ARRAY_SIZE(skl_fe_dai);
1407 }
1408
1375 ret = snd_soc_register_component(dev, &skl_component, 1409 ret = snd_soc_register_component(dev, &skl_component,
1376 skl_platform_dai, 1410 skl->dais, num_dais);
1377 ARRAY_SIZE(skl_platform_dai));
1378 if (ret) { 1411 if (ret) {
1379 dev_err(dev, "soc component registration failed %d\n", ret); 1412 dev_err(dev, "soc component registration failed %d\n", ret);
1380 snd_soc_unregister_platform(dev); 1413 goto err;
1381 } 1414 }
1382 1415
1416 return 0;
1417err:
1418 snd_soc_unregister_platform(dev);
1383 return ret; 1419 return ret;
1384 1420
1385} 1421}
@@ -1399,5 +1435,7 @@ int skl_platform_unregister(struct device *dev)
1399 1435
1400 snd_soc_unregister_component(dev); 1436 snd_soc_unregister_component(dev);
1401 snd_soc_unregister_platform(dev); 1437 snd_soc_unregister_platform(dev);
1438 kfree(skl->dais);
1439
1402 return 0; 1440 return 0;
1403} 1441}
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 27bcb62568fb..a072bcf209d2 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -2036,21 +2036,45 @@ static int skl_tplg_add_pipe(struct device *dev,
2036 return 0; 2036 return 0;
2037} 2037}
2038 2038
2039static int skl_tplg_fill_pin(struct device *dev, u32 tkn, 2039static int skl_tplg_get_uuid(struct device *dev, u8 *guid,
2040 struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
2041{
2042 if (uuid_tkn->token == SKL_TKN_UUID) {
2043 memcpy(guid, &uuid_tkn->uuid, 16);
2044 return 0;
2045 }
2046
2047 dev_err(dev, "Not an UUID token %d\n", uuid_tkn->token);
2048
2049 return -EINVAL;
2050}
2051
2052static int skl_tplg_fill_pin(struct device *dev,
2053 struct snd_soc_tplg_vendor_value_elem *tkn_elem,
2040 struct skl_module_pin *m_pin, 2054 struct skl_module_pin *m_pin,
2041 int pin_index, u32 value) 2055 int pin_index)
2042{ 2056{
2043 switch (tkn) { 2057 int ret;
2058
2059 switch (tkn_elem->token) {
2044 case SKL_TKN_U32_PIN_MOD_ID: 2060 case SKL_TKN_U32_PIN_MOD_ID:
2045 m_pin[pin_index].id.module_id = value; 2061 m_pin[pin_index].id.module_id = tkn_elem->value;
2046 break; 2062 break;
2047 2063
2048 case SKL_TKN_U32_PIN_INST_ID: 2064 case SKL_TKN_U32_PIN_INST_ID:
2049 m_pin[pin_index].id.instance_id = value; 2065 m_pin[pin_index].id.instance_id = tkn_elem->value;
2066 break;
2067
2068 case SKL_TKN_UUID:
2069 ret = skl_tplg_get_uuid(dev, m_pin[pin_index].id.mod_uuid.b,
2070 (struct snd_soc_tplg_vendor_uuid_elem *)tkn_elem);
2071 if (ret < 0)
2072 return ret;
2073
2050 break; 2074 break;
2051 2075
2052 default: 2076 default:
2053 dev_err(dev, "%d Not a pin token\n", value); 2077 dev_err(dev, "%d Not a pin token\n", tkn_elem->token);
2054 return -EINVAL; 2078 return -EINVAL;
2055 } 2079 }
2056 2080
@@ -2083,9 +2107,7 @@ static int skl_tplg_fill_pins_info(struct device *dev,
2083 return -EINVAL; 2107 return -EINVAL;
2084 } 2108 }
2085 2109
2086 ret = skl_tplg_fill_pin(dev, tkn_elem->token, 2110 ret = skl_tplg_fill_pin(dev, tkn_elem, m_pin, pin_count);
2087 m_pin, pin_count, tkn_elem->value);
2088
2089 if (ret < 0) 2111 if (ret < 0)
2090 return ret; 2112 return ret;
2091 2113
@@ -2170,19 +2192,6 @@ static int skl_tplg_widget_fill_fmt(struct device *dev,
2170 return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val); 2192 return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val);
2171} 2193}
2172 2194
2173static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig,
2174 struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
2175{
2176 if (uuid_tkn->token == SKL_TKN_UUID)
2177 memcpy(&mconfig->guid, &uuid_tkn->uuid, 16);
2178 else {
2179 dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token);
2180 return -EINVAL;
2181 }
2182
2183 return 0;
2184}
2185
2186static void skl_tplg_fill_pin_dynamic_val( 2195static void skl_tplg_fill_pin_dynamic_val(
2187 struct skl_module_pin *mpin, u32 pin_count, u32 value) 2196 struct skl_module_pin *mpin, u32 pin_count, u32 value)
2188{ 2197{
@@ -2488,6 +2497,7 @@ static int skl_tplg_get_token(struct device *dev,
2488 2497
2489 case SKL_TKN_U32_PIN_MOD_ID: 2498 case SKL_TKN_U32_PIN_MOD_ID:
2490 case SKL_TKN_U32_PIN_INST_ID: 2499 case SKL_TKN_U32_PIN_INST_ID:
2500 case SKL_TKN_UUID:
2491 ret = skl_tplg_fill_pins_info(dev, 2501 ret = skl_tplg_fill_pins_info(dev,
2492 mconfig, tkn_elem, dir, 2502 mconfig, tkn_elem, dir,
2493 pin_index); 2503 pin_index);
@@ -2550,6 +2560,7 @@ static int skl_tplg_get_tokens(struct device *dev,
2550 struct snd_soc_tplg_vendor_value_elem *tkn_elem; 2560 struct snd_soc_tplg_vendor_value_elem *tkn_elem;
2551 int tkn_count = 0, ret; 2561 int tkn_count = 0, ret;
2552 int off = 0, tuple_size = 0; 2562 int off = 0, tuple_size = 0;
2563 bool is_module_guid = true;
2553 2564
2554 if (block_size <= 0) 2565 if (block_size <= 0)
2555 return -EINVAL; 2566 return -EINVAL;
@@ -2565,7 +2576,15 @@ static int skl_tplg_get_tokens(struct device *dev,
2565 continue; 2576 continue;
2566 2577
2567 case SND_SOC_TPLG_TUPLE_TYPE_UUID: 2578 case SND_SOC_TPLG_TUPLE_TYPE_UUID:
2568 ret = skl_tplg_get_uuid(dev, mconfig, array->uuid); 2579 if (is_module_guid) {
2580 ret = skl_tplg_get_uuid(dev, mconfig->guid,
2581 array->uuid);
2582 is_module_guid = false;
2583 } else {
2584 ret = skl_tplg_get_token(dev, array->value, skl,
2585 mconfig);
2586 }
2587
2569 if (ret < 0) 2588 if (ret < 0)
2570 return ret; 2589 return ret;
2571 2590
@@ -3331,6 +3350,7 @@ static struct snd_soc_tplg_ops skl_tplg_ops = {
3331 .io_ops = skl_tplg_kcontrol_ops, 3350 .io_ops = skl_tplg_kcontrol_ops,
3332 .io_ops_count = ARRAY_SIZE(skl_tplg_kcontrol_ops), 3351 .io_ops_count = ARRAY_SIZE(skl_tplg_kcontrol_ops),
3333 .manifest = skl_manifest_load, 3352 .manifest = skl_manifest_load,
3353 .dai_load = skl_dai_load,
3334}; 3354};
3335 3355
3336/* 3356/*
@@ -3404,7 +3424,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus)
3404 3424
3405 ret = request_firmware(&fw, skl->tplg_name, bus->dev); 3425 ret = request_firmware(&fw, skl->tplg_name, bus->dev);
3406 if (ret < 0) { 3426 if (ret < 0) {
3407 dev_err(bus->dev, "tplg fw %s load failed with %d\n", 3427 dev_info(bus->dev, "tplg fw %s load failed with %d, falling back to dfw_sst.bin",
3408 skl->tplg_name, ret); 3428 skl->tplg_name, ret);
3409 ret = request_firmware(&fw, "dfw_sst.bin", bus->dev); 3429 ret = request_firmware(&fw, "dfw_sst.bin", bus->dev);
3410 if (ret < 0) { 3430 if (ret < 0) {
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index bc3c29161ed0..b6496513fe55 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -456,8 +456,8 @@ static inline struct skl *get_skl_ctx(struct device *dev)
456 456
457int skl_tplg_be_update_params(struct snd_soc_dai *dai, 457int skl_tplg_be_update_params(struct snd_soc_dai *dai,
458 struct skl_pipe_params *params); 458 struct skl_pipe_params *params);
459int skl_dsp_set_dma_control(struct skl_sst *ctx, 459int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps,
460 struct skl_module_cfg *mconfig); 460 u32 caps_size, u32 node_id);
461void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, 461void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
462 struct skl_pipe_params *params, int stream); 462 struct skl_pipe_params *params, int stream);
463int skl_tplg_init(struct snd_soc_platform *platform, 463int skl_tplg_init(struct snd_soc_platform *platform,
@@ -502,4 +502,7 @@ int skl_pcm_host_dma_prepare(struct device *dev,
502 struct skl_pipe_params *params); 502 struct skl_pipe_params *params);
503int skl_pcm_link_dma_prepare(struct device *dev, 503int skl_pcm_link_dma_prepare(struct device *dev,
504 struct skl_pipe_params *params); 504 struct skl_pipe_params *params);
505
506int skl_dai_load(struct snd_soc_component *cmp,
507 struct snd_soc_dai_driver *pcm_dai);
505#endif 508#endif
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index f94b484abb99..31d8634e8aa1 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -28,7 +28,7 @@
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <sound/pcm.h> 30#include <sound/pcm.h>
31#include "../common/sst-acpi.h" 31#include <sound/soc-acpi.h>
32#include <sound/hda_register.h> 32#include <sound/hda_register.h>
33#include <sound/hdaudio.h> 33#include <sound/hdaudio.h>
34#include <sound/hda_i915.h> 34#include <sound/hda_i915.h>
@@ -439,10 +439,10 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
439{ 439{
440 struct hdac_bus *bus = ebus_to_hbus(&skl->ebus); 440 struct hdac_bus *bus = ebus_to_hbus(&skl->ebus);
441 struct platform_device *pdev; 441 struct platform_device *pdev;
442 struct sst_acpi_mach *mach = driver_data; 442 struct snd_soc_acpi_mach *mach = driver_data;
443 int ret; 443 int ret;
444 444
445 mach = sst_acpi_find_machine(mach); 445 mach = snd_soc_acpi_find_machine(mach);
446 if (mach == NULL) { 446 if (mach == NULL) {
447 dev_err(bus->dev, "No matching machine driver found\n"); 447 dev_err(bus->dev, "No matching machine driver found\n");
448 return -ENODEV; 448 return -ENODEV;
@@ -462,8 +462,11 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
462 return -EIO; 462 return -EIO;
463 } 463 }
464 464
465 if (mach->pdata) 465 if (mach->pdata) {
466 skl->use_tplg_pcm =
467 ((struct skl_machine_pdata *)mach->pdata)->use_tplg_pcm;
466 dev_set_drvdata(&pdev->dev, mach->pdata); 468 dev_set_drvdata(&pdev->dev, mach->pdata);
469 }
467 470
468 skl->i2s_dev = pdev; 471 skl->i2s_dev = pdev;
469 472
@@ -875,33 +878,36 @@ static void skl_remove(struct pci_dev *pci)
875 dev_set_drvdata(&pci->dev, NULL); 878 dev_set_drvdata(&pci->dev, NULL);
876} 879}
877 880
878static struct sst_codecs skl_codecs = { 881static struct snd_soc_acpi_codecs skl_codecs = {
879 .num_codecs = 1, 882 .num_codecs = 1,
880 .codecs = {"10508825"} 883 .codecs = {"10508825"}
881}; 884};
882 885
883static struct sst_codecs kbl_codecs = { 886static struct snd_soc_acpi_codecs kbl_codecs = {
884 .num_codecs = 1, 887 .num_codecs = 1,
885 .codecs = {"10508825"} 888 .codecs = {"10508825"}
886}; 889};
887 890
888static struct sst_codecs bxt_codecs = { 891static struct snd_soc_acpi_codecs bxt_codecs = {
889 .num_codecs = 1, 892 .num_codecs = 1,
890 .codecs = {"MX98357A"} 893 .codecs = {"MX98357A"}
891}; 894};
892 895
893static struct sst_codecs kbl_poppy_codecs = { 896static struct snd_soc_acpi_codecs kbl_poppy_codecs = {
894 .num_codecs = 1, 897 .num_codecs = 1,
895 .codecs = {"10EC5663"} 898 .codecs = {"10EC5663"}
896}; 899};
897 900
898static struct sst_codecs kbl_5663_5514_codecs = { 901static struct snd_soc_acpi_codecs kbl_5663_5514_codecs = {
899 .num_codecs = 2, 902 .num_codecs = 2,
900 .codecs = {"10EC5663", "10EC5514"} 903 .codecs = {"10EC5663", "10EC5514"}
901}; 904};
902 905
906static struct skl_machine_pdata cnl_pdata = {
907 .use_tplg_pcm = true,
908};
903 909
904static struct sst_acpi_mach sst_skl_devdata[] = { 910static struct snd_soc_acpi_mach sst_skl_devdata[] = {
905 { 911 {
906 .id = "INT343A", 912 .id = "INT343A",
907 .drv_name = "skl_alc286s_i2s", 913 .drv_name = "skl_alc286s_i2s",
@@ -911,7 +917,7 @@ static struct sst_acpi_mach sst_skl_devdata[] = {
911 .id = "INT343B", 917 .id = "INT343B",
912 .drv_name = "skl_n88l25_s4567", 918 .drv_name = "skl_n88l25_s4567",
913 .fw_filename = "intel/dsp_fw_release.bin", 919 .fw_filename = "intel/dsp_fw_release.bin",
914 .machine_quirk = sst_acpi_codec_list, 920 .machine_quirk = snd_soc_acpi_codec_list,
915 .quirk_data = &skl_codecs, 921 .quirk_data = &skl_codecs,
916 .pdata = &skl_dmic_data 922 .pdata = &skl_dmic_data
917 }, 923 },
@@ -919,14 +925,14 @@ static struct sst_acpi_mach sst_skl_devdata[] = {
919 .id = "MX98357A", 925 .id = "MX98357A",
920 .drv_name = "skl_n88l25_m98357a", 926 .drv_name = "skl_n88l25_m98357a",
921 .fw_filename = "intel/dsp_fw_release.bin", 927 .fw_filename = "intel/dsp_fw_release.bin",
922 .machine_quirk = sst_acpi_codec_list, 928 .machine_quirk = snd_soc_acpi_codec_list,
923 .quirk_data = &skl_codecs, 929 .quirk_data = &skl_codecs,
924 .pdata = &skl_dmic_data 930 .pdata = &skl_dmic_data
925 }, 931 },
926 {} 932 {}
927}; 933};
928 934
929static struct sst_acpi_mach sst_bxtp_devdata[] = { 935static struct snd_soc_acpi_mach sst_bxtp_devdata[] = {
930 { 936 {
931 .id = "INT343A", 937 .id = "INT343A",
932 .drv_name = "bxt_alc298s_i2s", 938 .drv_name = "bxt_alc298s_i2s",
@@ -936,13 +942,13 @@ static struct sst_acpi_mach sst_bxtp_devdata[] = {
936 .id = "DLGS7219", 942 .id = "DLGS7219",
937 .drv_name = "bxt_da7219_max98357a_i2s", 943 .drv_name = "bxt_da7219_max98357a_i2s",
938 .fw_filename = "intel/dsp_fw_bxtn.bin", 944 .fw_filename = "intel/dsp_fw_bxtn.bin",
939 .machine_quirk = sst_acpi_codec_list, 945 .machine_quirk = snd_soc_acpi_codec_list,
940 .quirk_data = &bxt_codecs, 946 .quirk_data = &bxt_codecs,
941 }, 947 },
942 {} 948 {}
943}; 949};
944 950
945static struct sst_acpi_mach sst_kbl_devdata[] = { 951static struct snd_soc_acpi_mach sst_kbl_devdata[] = {
946 { 952 {
947 .id = "INT343A", 953 .id = "INT343A",
948 .drv_name = "kbl_alc286s_i2s", 954 .drv_name = "kbl_alc286s_i2s",
@@ -952,7 +958,7 @@ static struct sst_acpi_mach sst_kbl_devdata[] = {
952 .id = "INT343B", 958 .id = "INT343B",
953 .drv_name = "kbl_n88l25_s4567", 959 .drv_name = "kbl_n88l25_s4567",
954 .fw_filename = "intel/dsp_fw_kbl.bin", 960 .fw_filename = "intel/dsp_fw_kbl.bin",
955 .machine_quirk = sst_acpi_codec_list, 961 .machine_quirk = snd_soc_acpi_codec_list,
956 .quirk_data = &kbl_codecs, 962 .quirk_data = &kbl_codecs,
957 .pdata = &skl_dmic_data 963 .pdata = &skl_dmic_data
958 }, 964 },
@@ -960,7 +966,7 @@ static struct sst_acpi_mach sst_kbl_devdata[] = {
960 .id = "MX98357A", 966 .id = "MX98357A",
961 .drv_name = "kbl_n88l25_m98357a", 967 .drv_name = "kbl_n88l25_m98357a",
962 .fw_filename = "intel/dsp_fw_kbl.bin", 968 .fw_filename = "intel/dsp_fw_kbl.bin",
963 .machine_quirk = sst_acpi_codec_list, 969 .machine_quirk = snd_soc_acpi_codec_list,
964 .quirk_data = &kbl_codecs, 970 .quirk_data = &kbl_codecs,
965 .pdata = &skl_dmic_data 971 .pdata = &skl_dmic_data
966 }, 972 },
@@ -968,7 +974,7 @@ static struct sst_acpi_mach sst_kbl_devdata[] = {
968 .id = "MX98927", 974 .id = "MX98927",
969 .drv_name = "kbl_r5514_5663_max", 975 .drv_name = "kbl_r5514_5663_max",
970 .fw_filename = "intel/dsp_fw_kbl.bin", 976 .fw_filename = "intel/dsp_fw_kbl.bin",
971 .machine_quirk = sst_acpi_codec_list, 977 .machine_quirk = snd_soc_acpi_codec_list,
972 .quirk_data = &kbl_5663_5514_codecs, 978 .quirk_data = &kbl_5663_5514_codecs,
973 .pdata = &skl_dmic_data 979 .pdata = &skl_dmic_data
974 }, 980 },
@@ -976,7 +982,7 @@ static struct sst_acpi_mach sst_kbl_devdata[] = {
976 .id = "MX98927", 982 .id = "MX98927",
977 .drv_name = "kbl_rt5663_m98927", 983 .drv_name = "kbl_rt5663_m98927",
978 .fw_filename = "intel/dsp_fw_kbl.bin", 984 .fw_filename = "intel/dsp_fw_kbl.bin",
979 .machine_quirk = sst_acpi_codec_list, 985 .machine_quirk = snd_soc_acpi_codec_list,
980 .quirk_data = &kbl_poppy_codecs, 986 .quirk_data = &kbl_poppy_codecs,
981 .pdata = &skl_dmic_data 987 .pdata = &skl_dmic_data
982 }, 988 },
@@ -989,7 +995,7 @@ static struct sst_acpi_mach sst_kbl_devdata[] = {
989 {} 995 {}
990}; 996};
991 997
992static struct sst_acpi_mach sst_glk_devdata[] = { 998static struct snd_soc_acpi_mach sst_glk_devdata[] = {
993 { 999 {
994 .id = "INT343A", 1000 .id = "INT343A",
995 .drv_name = "glk_alc298s_i2s", 1001 .drv_name = "glk_alc298s_i2s",
@@ -998,12 +1004,14 @@ static struct sst_acpi_mach sst_glk_devdata[] = {
998 {} 1004 {}
999}; 1005};
1000 1006
1001static const struct sst_acpi_mach sst_cnl_devdata[] = { 1007static const struct snd_soc_acpi_mach sst_cnl_devdata[] = {
1002 { 1008 {
1003 .id = "INT34C2", 1009 .id = "INT34C2",
1004 .drv_name = "cnl_rt274", 1010 .drv_name = "cnl_rt274",
1005 .fw_filename = "intel/dsp_fw_cnl.bin", 1011 .fw_filename = "intel/dsp_fw_cnl.bin",
1012 .pdata = &cnl_pdata,
1006 }, 1013 },
1014 {}
1007}; 1015};
1008 1016
1009/* PCI IDs */ 1017/* PCI IDs */
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 8d9d6899f761..e00cde8200dd 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -53,6 +53,7 @@ struct skl {
53 struct platform_device *dmic_dev; 53 struct platform_device *dmic_dev;
54 struct platform_device *i2s_dev; 54 struct platform_device *i2s_dev;
55 struct snd_soc_platform *platform; 55 struct snd_soc_platform *platform;
56 struct snd_soc_dai_driver *dais;
56 57
57 struct nhlt_acpi_table *nhlt; /* nhlt ptr */ 58 struct nhlt_acpi_table *nhlt; /* nhlt ptr */
58 struct skl_sst *skl_sst; /* sst skl ctx */ 59 struct skl_sst *skl_sst; /* sst skl ctx */
@@ -73,6 +74,7 @@ struct skl {
73 struct skl_debug *debugfs; 74 struct skl_debug *debugfs;
74 u8 nr_modules; 75 u8 nr_modules;
75 struct skl_module **modules; 76 struct skl_module **modules;
77 bool use_tplg_pcm;
76}; 78};
77 79
78#define skl_to_ebus(s) (&(s)->ebus) 80#define skl_to_ebus(s) (&(s)->ebus)
@@ -85,9 +87,9 @@ struct skl_dma_params {
85 u8 stream_tag; 87 u8 stream_tag;
86}; 88};
87 89
88/* to pass dmic data */
89struct skl_machine_pdata { 90struct skl_machine_pdata {
90 u32 dmic_num; 91 u32 dmic_num;
92 bool use_tplg_pcm; /* use dais and dai links from topology */
91}; 93};
92 94
93struct skl_dsp_ops { 95struct skl_dsp_ops {
diff --git a/sound/soc/intel/common/sst-match-acpi.c b/sound/soc/soc-acpi.c
index 56d26f36a3cb..f21df28bc28e 100644
--- a/sound/soc/intel/common/sst-match-acpi.c
+++ b/sound/soc/soc-acpi.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * sst_match_apci.c - SST (LPE) match for ACPI enumeration. 2 * soc-apci.c - support for ACPI enumeration.
3 * 3 *
4 * Copyright (c) 2013-15, Intel Corporation. 4 * Copyright (c) 2013-15, Intel Corporation.
5 * 5 *
@@ -14,9 +14,9 @@
14 * more details. 14 * more details.
15 */ 15 */
16 16
17#include "sst-acpi.h" 17#include <sound/soc-acpi.h>
18 18
19static acpi_status sst_acpi_find_name(acpi_handle handle, u32 level, 19static acpi_status snd_soc_acpi_find_name(acpi_handle handle, u32 level,
20 void *context, void **ret) 20 void *context, void **ret)
21{ 21{
22 struct acpi_device *adev; 22 struct acpi_device *adev;
@@ -34,12 +34,12 @@ static acpi_status sst_acpi_find_name(acpi_handle handle, u32 level,
34 return AE_OK; 34 return AE_OK;
35} 35}
36 36
37const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]) 37const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
38{ 38{
39 const char *name = NULL; 39 const char *name = NULL;
40 acpi_status status; 40 acpi_status status;
41 41
42 status = acpi_get_devices(hid, sst_acpi_find_name, NULL, 42 status = acpi_get_devices(hid, snd_soc_acpi_find_name, NULL,
43 (void **)&name); 43 (void **)&name);
44 44
45 if (ACPI_FAILURE(status) || name[0] == '\0') 45 if (ACPI_FAILURE(status) || name[0] == '\0')
@@ -47,9 +47,9 @@ const char *sst_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
47 47
48 return name; 48 return name;
49} 49}
50EXPORT_SYMBOL_GPL(sst_acpi_find_name_from_hid); 50EXPORT_SYMBOL_GPL(snd_soc_acpi_find_name_from_hid);
51 51
52static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level, 52static acpi_status snd_soc_acpi_mach_match(acpi_handle handle, u32 level,
53 void *context, void **ret) 53 void *context, void **ret)
54{ 54{
55 unsigned long long sta; 55 unsigned long long sta;
@@ -63,26 +63,27 @@ static acpi_status sst_acpi_mach_match(acpi_handle handle, u32 level,
63 return AE_OK; 63 return AE_OK;
64} 64}
65 65
66bool sst_acpi_check_hid(const u8 hid[ACPI_ID_LEN]) 66bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN])
67{ 67{
68 acpi_status status; 68 acpi_status status;
69 bool found = false; 69 bool found = false;
70 70
71 status = acpi_get_devices(hid, sst_acpi_mach_match, &found, NULL); 71 status = acpi_get_devices(hid, snd_soc_acpi_mach_match, &found, NULL);
72 72
73 if (ACPI_FAILURE(status)) 73 if (ACPI_FAILURE(status))
74 return false; 74 return false;
75 75
76 return found; 76 return found;
77} 77}
78EXPORT_SYMBOL_GPL(sst_acpi_check_hid); 78EXPORT_SYMBOL_GPL(snd_soc_acpi_check_hid);
79 79
80struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines) 80struct snd_soc_acpi_mach *
81snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
81{ 82{
82 struct sst_acpi_mach *mach; 83 struct snd_soc_acpi_mach *mach;
83 84
84 for (mach = machines; mach->id[0]; mach++) { 85 for (mach = machines; mach->id[0]; mach++) {
85 if (sst_acpi_check_hid(mach->id) == true) { 86 if (snd_soc_acpi_check_hid(mach->id) == true) {
86 if (mach->machine_quirk == NULL) 87 if (mach->machine_quirk == NULL)
87 return mach; 88 return mach;
88 89
@@ -92,14 +93,14 @@ struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines)
92 } 93 }
93 return NULL; 94 return NULL;
94} 95}
95EXPORT_SYMBOL_GPL(sst_acpi_find_machine); 96EXPORT_SYMBOL_GPL(snd_soc_acpi_find_machine);
96 97
97static acpi_status sst_acpi_find_package(acpi_handle handle, u32 level, 98static acpi_status snd_soc_acpi_find_package(acpi_handle handle, u32 level,
98 void *context, void **ret) 99 void *context, void **ret)
99{ 100{
100 struct acpi_device *adev; 101 struct acpi_device *adev;
101 acpi_status status = AE_OK; 102 acpi_status status = AE_OK;
102 struct sst_acpi_package_context *pkg_ctx = context; 103 struct snd_soc_acpi_package_context *pkg_ctx = context;
103 104
104 pkg_ctx->data_valid = false; 105 pkg_ctx->data_valid = false;
105 106
@@ -137,37 +138,38 @@ static acpi_status sst_acpi_find_package(acpi_handle handle, u32 level,
137 return AE_OK; 138 return AE_OK;
138} 139}
139 140
140bool sst_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], 141bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
141 struct sst_acpi_package_context *ctx) 142 struct snd_soc_acpi_package_context *ctx)
142{ 143{
143 acpi_status status; 144 acpi_status status;
144 145
145 status = acpi_get_devices(hid, sst_acpi_find_package, ctx, NULL); 146 status = acpi_get_devices(hid, snd_soc_acpi_find_package, ctx, NULL);
146 147
147 if (ACPI_FAILURE(status) || !ctx->data_valid) 148 if (ACPI_FAILURE(status) || !ctx->data_valid)
148 return false; 149 return false;
149 150
150 return true; 151 return true;
151} 152}
152EXPORT_SYMBOL_GPL(sst_acpi_find_package_from_hid); 153EXPORT_SYMBOL_GPL(snd_soc_acpi_find_package_from_hid);
153 154
154struct sst_acpi_mach *sst_acpi_codec_list(void *arg) 155struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
155{ 156{
156 struct sst_acpi_mach *mach = arg; 157 struct snd_soc_acpi_mach *mach = arg;
157 struct sst_codecs *codec_list = (struct sst_codecs *) mach->quirk_data; 158 struct snd_soc_acpi_codecs *codec_list =
159 (struct snd_soc_acpi_codecs *) mach->quirk_data;
158 int i; 160 int i;
159 161
160 if (mach->quirk_data == NULL) 162 if (mach->quirk_data == NULL)
161 return mach; 163 return mach;
162 164
163 for (i = 0; i < codec_list->num_codecs; i++) { 165 for (i = 0; i < codec_list->num_codecs; i++) {
164 if (sst_acpi_check_hid(codec_list->codecs[i]) != true) 166 if (snd_soc_acpi_check_hid(codec_list->codecs[i]) != true)
165 return NULL; 167 return NULL;
166 } 168 }
167 169
168 return mach; 170 return mach;
169} 171}
170EXPORT_SYMBOL_GPL(sst_acpi_codec_list); 172EXPORT_SYMBOL_GPL(snd_soc_acpi_codec_list);
171 173
172MODULE_LICENSE("GPL v2"); 174MODULE_LICENSE("GPL v2");
173MODULE_DESCRIPTION("Intel Common ACPI Match module"); 175MODULE_DESCRIPTION("ALSA SoC ACPI module");