Skip to contentSkip to conversation

ASoC: Intel: add bytcr-wm5102 machine driver

PATCH In review [email protected] 3 participants 5 messages Jun 3, 2017 – Jun 5, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: add bytcr-wm5102 machine driver

From: Paulo Sergio Travaglia <[email protected]>

based on bytcr-rt5640 machine driver and android kernel source released by Lenovo [1]

This currently targets Baytrail Lenovo Yoga 2 Tablets (tested with 1051F)

- use arizona specific constants
- set clock to codecs using snd_soc_codec_set_sysclk
- map codec member from snd_soc_dai and set pll using snd_soc_codec_set_pll

NOTE: Currently only routes to Headphones are supported (Speaker seems to need power/activation)

[1] - https://goo.gl/J1TR6n

sound/soc/intel/Kconfig +13 -0
index 67968ef..8a6a25a 100644
@@ -151,6 +151,19 @@ config SND_SOC_INTEL_BYTCR_RT5640_MACH
           Say Y if you have such a device.
           If unsure select "N".
 
+config SND_SOC_INTEL_BYTCR_WM5102_MACH
+        tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with WM5102 codec"
+	depends on X86 && SPI && ACPI
+	select SND_SOC_WM5102
+	select SND_SST_ATOM_HIFI2_PLATFORM
+	select SND_SST_IPC_ACPI
+	select SND_SOC_INTEL_SST_MATCH if ACPI
+	help
+          This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
+          platforms with WM5102 audio codec.
+          Say Y if you have such a device.
+          If unsure select "N".
+
 config SND_SOC_INTEL_BYTCR_RT5651_MACH
         tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with RT5651 codec"
 	depends on X86 && I2C && ACPI
sound/soc/intel/atom/sst/sst_acpi.c +13 -2
index dd250b8..1669c46 100644
@@ -240,10 +240,17 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)
 }
 
 
-static int is_byt_cr(struct device *dev, bool *bytcr)
+static int is_byt_cr(struct device *dev, struct sst_acpi_mach *mach, bool *bytcr)
 {
 	int status = 0;
 
+	/* Lenovo Yoga2 exception - acpi_ipc_irq_index is the 1st index,
+	   but iosf_mbi_read (bios_status) returns 0 for bits 26:27 */
+	if (!strcmp(mach->drv_name, "bytcr_wm5102")) {
+		*bytcr = true;
+		return status;
+	}
+
 	if (IS_ENABLED(CONFIG_IOSF_MBI)) {
 		static const struct x86_cpu_id cpu_ids[] = {
 			{ X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
@@ -320,7 +327,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
-	ret = is_byt_cr(dev, &bytcr);
+	ret = is_byt_cr(dev, mach, &bytcr);
 	if (!((ret < 0) || (bytcr == false))) {
 		dev_info(dev, "Detected Baytrail-CR platform\n");
 
@@ -492,6 +499,10 @@ static struct sst_acpi_mach sst_acpi_bytcr[] = {
 						&byt_rvp_platform_data },
 	{"INTCCFFD", "bytcr_rt5640", "intel/fw_sst_0f28.bin", "bytcr_rt5640", NULL,
 						&byt_rvp_platform_data },
+	{"WM510204", "bytcr_wm5102", "intel/fw_sst_0f28.bin", "bytcr_wm5102", NULL,
+						&byt_rvp_platform_data },
+	{"WM510205", "bytcr_wm5102", "intel/fw_sst_0f28.bin", "bytcr_wm5102", NULL,
+						&byt_rvp_platform_data },
 	{"10EC5651", "bytcr_rt5651", "intel/fw_sst_0f28.bin", "bytcr_rt5651", NULL,
 						&byt_rvp_platform_data },
 	{"DLGS7212", "bytcht_da7213", "intel/fw_sst_0f28.bin", "bytcht_da7213", NULL,
sound/soc/intel/boards/Makefile +2 -0
index 56896e0..396e5cf 100644
@@ -6,6 +6,7 @@ snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
 snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
 snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o
+snd-soc-sst-bytcr-wm5102-objs := bytcr_wm5102.o
 snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o
 snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o
 snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o
@@ -24,6 +25,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
 obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
+obj-$(CONFIG_SND_SOC_INTEL_BYTCR_WM5102_MACH) += snd-soc-sst-bytcr-wm5102.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o
sound/soc/intel/boards/bytcr_wm5102.c new file +769 -0

769 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 10 lines
sound/soc/intel/atom/sst/sst_acpi.c +0 -1
index dd250b8..1669c46 100644
@@ -240,10 +240,17 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)
  }
 
 
-static int is_byt_cr(struct device *dev, bool *bytcr)

sound/soc/intel/atom/sst/sst_acpi.c static int sst_platform_get_resources(struct intel_sst_drv *ctx) · line 252

Quoted 10 lines
sound/soc/intel/atom/sst/sst_acpi.c +7 -0
+static int is_byt_cr(struct device *dev, struct sst_acpi_mach *mach, bool *bytcr)
  {
  	int status = 0;
 
+	/* Lenovo Yoga2 exception - acpi_ipc_irq_index is the 1st index,
+	   but iosf_mbi_read (bios_status) returns 0 for bits 26:27 */
+	if (!strcmp(mach->drv_name, "bytcr_wm5102")) {
+		*bytcr = true;
+		return status;
+	}

well no, this isn't the right way to do this. quirks need to be based on real hardware information (e.g. DMI) and not a driver name.

The rest looks more of less ok, it's not clear to me if all the quirks are needed and make sense.

#2 lore raw

Hi Pierre,how are you?

Quoted 12 lines

Review

Quoted 10 lines

+static int is_byt_cr(struct device *dev, struct sst_acpi_mach *mach, bool *bytcr)

  {
        int status = 0;

+ /* Lenovo Yoga2 exception - acpi_ipc_irq_index is the 1st index,

(quoted diff) +5 -0
+          but iosf_mbi_read (bios_status) returns 0 for bits 26:27 */
+       if (!strcmp(mach->drv_name, "bytcr_wm5102")) {
+               *bytcr = true;
+               return status;
+       }
Quoted 2 lines

well no, this isn't the right way to do this. quirks need to be based on real hardware information (e.g. DMI) and not a driver name.

Thanks for the review. Could I use dmi_match function inside is_byt_cr?

git diff HEAD sound/soc/intel/atom/sst/sst_acpi.c

(quoted diff) +0 -0

b/sound/soc/intel/atom/sst/sst_acpi.c
index dd250b8..a99d5a5 100644

sound/soc/intel/atom/sst/sst_acpi.c +3 -0
@@ -244,6 +244,13 @@ static int is_byt_cr(struct device *dev, bool *bytcr)
 {
        int status = 0;
 
+       /* Lenovo Yoga2 exception - acpi_ipc_irq_index is the 1st index,
+          but iosf_mbi_read (bios_status) returns 0 for bits 26:27 */
+       if (dmi_match(DMI_SYS_VENDOR, "LENOVO") &&

dmi_match(DMI_CHASSIS_VERSION, "1051F")) {
+ *bytcr = true;
+ return status;
+ }
+

        if (IS_ENABLED(CONFIG_IOSF_MBI)) {

...

Quoted 3 lines

The rest looks more of less ok, it's not clear to me if all the quirks are needed and make sense.

Inside machine driver code, I can confirm these as necessary:

- SSP0 usage
- 25Mhz Clock

About the other quirks: To be honest, as I started using bycr_rt5640 as base, I avoided touching other parts of the code.

I'll understand if this is not adequated to be pushed upstream. Besides, the codec side changes (arizona/wm5102 - not sent with this patch)
are not ready to be pushed due some hardcoding & an issue with regulator part (arizona-code will only detected codec chip if arizona-ldo1 is marked as built-in; as a module it is not working)

Regards
Paulo Sérgio Travaglia (Pstglia)
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
Quoted 13 lines · Paulo Sergio

Hi Pierre,how are you?

Quoted 11 lines
Quoted 10 lines

+static int is_byt_cr(struct device *dev, struct sst_acpi_mach *mach, bool *bytcr)

   {
         int status = 0;

+ /* Lenovo Yoga2 exception - acpi_ipc_irq_index is the 1st index,

(quoted diff) +5 -0
+          but iosf_mbi_read (bios_status) returns 0 for bits 26:27 */
+       if (!strcmp(mach->drv_name, "bytcr_wm5102")) {
+               *bytcr = true;
+               return status;
+       }
Quoted 3 lines
Quoted 2 lines

well no, this isn't the right way to do this. quirks need to be based on real hardware information (e.g. DMI) and not a driver name.

Thanks for the review. Could I use dmi_match function inside is_byt_cr?

Yes, however it's the first time I see a quirk based on DMI_CHASSIS_VERSION. we use PRODUCT or BOARD usually.

Quoted 40 lines

git diff HEAD sound/soc/intel/atom/sst/sst_acpi.c

sound/soc/intel/atom/sst/sst_acpi.c +7 -0
index dd250b8..a99d5a5 100644
@@ -244,6 +244,13 @@ static int is_byt_cr(struct device *dev, bool *bytcr)
  {
         int status = 0;
 
+       /* Lenovo Yoga2 exception - acpi_ipc_irq_index is the 1st index,
+          but iosf_mbi_read (bios_status) returns 0 for bits 26:27 */
+       if (dmi_match(DMI_SYS_VENDOR, "LENOVO") &&
 dmi_match(DMI_CHASSIS_VERSION, "1051F")) {
+               *bytcr = true;
+               return status;
+       }
+
         if (IS_ENABLED(CONFIG_IOSF_MBI)) {
...
Quoted 4 lines

The rest looks more of less ok, it's not clear to me if all the quirks are needed and make sense.

Inside machine driver code, I can confirm these as necessary:

- SSP0 usage
- 25Mhz Clock

About the other quirks: To be honest, as I started using bycr_rt5640 as base, I avoided touching other parts of the code.

I'll understand if this is not adequated to be pushed upstream. Besides, the codec side changes (arizona/wm5102 - not sent with this patch)
are not ready to be pushed due some hardcoding & an issue with regulator part (arizona-code will only detected codec chip if arizona-ldo1 is marked as built-in; as a module it is not working)

Quoted 2 lines

Regards
Paulo Sérgio Travaglia (Pstglia)

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

well no, this isn't the right way to do this. quirks need to be based on real hardware information (e.g. DMI) and not a driver name.

Thanks for the review. Could I use dmi_match function inside is_byt_cr?

Yes, however it's the first time I see a quirk based on DMI_CHASSIS_VERSION. we use PRODUCT or BOARD usually.

Not a problem. I can change it. I have these info available from dmi:

bios_date: 08/01/2014
bios_vendor: LENOVO
bios_version: 01WT17WW
board_asset_tag: NO Asset Tag
board_name: INVALID
board_serial: HA07YER9
board_vendor: LENOVO
board_version: SDK9A6N2HVWIN
chassis_asset_tag: NO Asset Tag
chassis_serial: HA07YER9
chassis_type: 11
chassis_vendor: LENOVO
chassis_version: 1051F
modalias: dmi:bvnLENOVO:bvr01WT17WW:bd08/01/2014:svnLENOVO:pn60073:pvr1051F:rvnLENOVO:rnINVALID:rvrSDK9A6N2HVWIN:cvnLENOVO:ct11:cvr1051F:
product_name: 60073
product_serial: HA07YER9
product_uuid: 39FFE49E-1918-884A-9499-CC7705A289C9
product_version: 1051F
sys_vendor: LENOVO
uevent: MODALIAS=dmi:bvnLENOVO:bvr01WT17WW:bd08/01/2014:svnLENOVO:pn60073:pvr1051F:rvnLENOVO:rnINVALID:rvrSDK9A6N2HVWIN:cvnLENOVO:ct11:cvr1051F: