From patchwork Tue Jun 20 22:27:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 110706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3987709vqr; Tue, 20 Jun 2023 15:55:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KfMK7gEydjlDFBUrrKwmhC5O6si3aXm5btgg1bIktx7pO2bLp5xEX7sH3q+ffqUwGNdSu X-Received: by 2002:a05:6a20:160e:b0:122:1da3:40a7 with SMTP id l14-20020a056a20160e00b001221da340a7mr4888874pzj.30.1687301706337; Tue, 20 Jun 2023 15:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687301706; cv=none; d=google.com; s=arc-20160816; b=oy0FvVH8/CDjWSw8ZjkG13gtzxn2A/P63NTHiz6eDOlDRTUni132v8ZYNtRdLkroeW Pswz1XmvOTVCqdJW4OAtNh5/RApQBl0xd5VZxcFgBeRQcXzdIgrKRYtfm9DOC/AAJC22 0+PvukCV3VSmCKEfLt4zbZ071ec1Rn8IqtDSSbuAgxpvbCbY7L/BWRJNd7e/TDnN48tx Z2Wrs/SbELX467UOrPXNoaUnA5lJVosX9GiMw7/fLLLRvY6z+aoN5hj1bJMIOs8avo8f mgLSHO+QETBRFYzLOeBbboFQD7Rf4cR989DgkLFPyU2Mn4Ut2f0kzOplNSVEPJ3VleUf gI9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/1KrZe4b0OrD/DxV9OwnxJKlKZaA01ezv5/soj7mUa4=; b=SVdXi5XDYNx9jRHzcknbk45iNBZrgVSvOTPy/tem4rPvCqoswi8zqTLLpyOmwrrC7F IM9WN6wReD+MUJJrEpHMag61gYmhUth+dTm7LW8qNq1wQmV55cuhaWwca1ePKT9BRn1k pGEUq2SueF1KAFK3KgRg4e78nl+9fMiQa3TB6BktpkXnt53IJcXg0k4xXC0qtkYR6ram Ax061SmJRRT5PlJH/nowCmwY0oSdIvl2Ida9P9qX3KHhfkWtW7TW/DHG1zsLMnA0TSWw ZXssUsW5oWC/msvmqyBl3rhGveByloTMxbtPnNev38SLJXj/BWNZcrLEukVW28e6KrlL KRKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CN+qrRhj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be8-20020a170902aa0800b001b3414a1fa9si2813160plb.175.2023.06.20.15.54.53; Tue, 20 Jun 2023 15:55:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=CN+qrRhj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbjFTW15 (ORCPT + 99 others); Tue, 20 Jun 2023 18:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjFTW1y (ORCPT ); Tue, 20 Jun 2023 18:27:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0C7D173F for ; Tue, 20 Jun 2023 15:27:52 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7DA8C6606F70; Tue, 20 Jun 2023 23:27:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687300071; bh=ySaaRuf0YxKRdkILyJHmqoCwfptq1Xrue2J0JYrw0F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CN+qrRhjql9jWIRKd6ej9ZbQuADjjef6nYEvuz6Z22k88O1AilgvwNIFabL+3juvI ui6V6/1DuMfeUZGhmRzN1Jek3XYMRfoiTiEqI3+pEPi9OhMnQmmTDGGapHKIKOQzWQ SK1s//MjeQaKKdw8x0gx7LlWPRhxXo0nugM2tYztiMXm7K5QRBxVTpuJekgVefSx6l zXlSwbtuRQAwbw/XtYBdVrwTAoLVVb+L7qjGJ+c8MnL0s/ehBIHgVu7AOZjddARfF3 2oDrfGvk7d+DsOhc7HSMuai/Q01splYuhB1I7MliVeTe4nWSVYVozhQBNxWTH9riVy LI3bEklh+0orQ== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Vijendar Mukunda , Syed Saba Kareem , Arnd Bergmann , Randy Dunlap , Charles Keepax , Kuninori Morimoto , Venkata Prasad Potturu Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 1/2] ASoC: amd: vangogh: Add ACPI probe support Date: Wed, 21 Jun 2023 01:27:42 +0300 Message-ID: <20230620222743.274432-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620222743.274432-1-cristian.ciocaltea@collabora.com> References: <20230620222743.274432-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769264074030224248?= X-GMAIL-MSGID: =?utf-8?q?1769264074030224248?= Remove the acp5x machine driver from pci-acp5x child devices and enable probing via ACPI match table. Co-developed-by: Lucas Tanure Signed-off-by: Lucas Tanure Signed-off-by: Cristian Ciocaltea --- sound/soc/amd/vangogh/acp5x-mach.c | 39 +++++++++--------------------- sound/soc/amd/vangogh/acp5x.h | 2 +- sound/soc/amd/vangogh/pci-acp5x.c | 3 --- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index e5bcd1e6eb73..1b54eadc4979 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -22,7 +22,6 @@ #define DRV_NAME "acp5x_mach" #define DUAL_CHANNEL 2 -#define VG_JUPITER 1 #define ACP5X_NAU8821_BCLK 3072000 #define ACP5X_NAU8821_FREQ_OUT 12288000 #define ACP5X_NAU8821_COMP_NAME "i2c-NVTN2020:00" @@ -31,7 +30,6 @@ #define ACP5X_CS35L41_COMP_RNAME "spi-VLV1776:01" #define ACP5X_CS35L41_DAI_NAME "cs35l41-pcm" -static unsigned long acp5x_machine_id; static struct snd_soc_jack vg_headset; SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("acp5x_i2s_dma.0"))); @@ -331,24 +329,6 @@ static struct snd_soc_card acp5x_8821_35l41_card = { .num_controls = ARRAY_SIZE(acp5x_8821_controls), }; -static int acp5x_vg_quirk_cb(const struct dmi_system_id *id) -{ - acp5x_machine_id = VG_JUPITER; - - return 1; -} - -static const struct dmi_system_id acp5x_vg_quirk_table[] = { - { - .callback = acp5x_vg_quirk_cb, - .matches = { - DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Valve"), - DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jupiter"), - } - }, - {} -}; - static int acp5x_probe(struct platform_device *pdev) { struct acp5x_platform_info *machine; @@ -356,18 +336,14 @@ static int acp5x_probe(struct platform_device *pdev) struct snd_soc_card *card; int ret; + card = (struct snd_soc_card *)device_get_match_data(dev); + if (!card) + return -EINVAL; + machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL); if (!machine) return -ENOMEM; - dmi_check_system(acp5x_vg_quirk_table); - switch (acp5x_machine_id) { - case VG_JUPITER: - card = &acp5x_8821_35l41_card; - break; - default: - return -ENODEV; - } card->dev = dev; platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); @@ -379,10 +355,17 @@ static int acp5x_probe(struct platform_device *pdev) return 0; } +static const struct acpi_device_id acp5x_acpi_match[] = { + { "AMDI3541", (kernel_ulong_t)&acp5x_8821_35l41_card }, + {}, +}; +MODULE_DEVICE_TABLE(acpi, acp5x_acpi_match); + static struct platform_driver acp5x_mach_driver = { .driver = { .name = "acp5x_mach", .pm = &snd_soc_pm_ops, + .acpi_match_table = acp5x_acpi_match, }, .probe = acp5x_probe, }; diff --git a/sound/soc/amd/vangogh/acp5x.h b/sound/soc/amd/vangogh/acp5x.h index ac1936a8c43f..2d9b182af109 100644 --- a/sound/soc/amd/vangogh/acp5x.h +++ b/sound/soc/amd/vangogh/acp5x.h @@ -23,7 +23,7 @@ #define ACP_ERR_INTR_MASK 0x20000000 #define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF -#define ACP5x_DEVS 4 +#define ACP5x_DEVS 3 #define ACP5x_REG_START 0x1240000 #define ACP5x_REG_END 0x1250200 #define ACP5x_I2STDM_REG_START 0x1242400 diff --git a/sound/soc/amd/vangogh/pci-acp5x.c b/sound/soc/amd/vangogh/pci-acp5x.c index c4634a8a17cd..ab2fcb34518f 100644 --- a/sound/soc/amd/vangogh/pci-acp5x.c +++ b/sound/soc/amd/vangogh/pci-acp5x.c @@ -222,9 +222,6 @@ static int snd_acp5x_probe(struct pci_dev *pci, pdevinfo[2].num_res = 1; pdevinfo[2].res = &adata->res[2]; - pdevinfo[3].name = "acp5x_mach"; - pdevinfo[3].id = 0; - pdevinfo[3].parent = &pci->dev; for (i = 0; i < ACP5x_DEVS; i++) { adata->pdev[i] = platform_device_register_full(&pdevinfo[i]); From patchwork Tue Jun 20 22:27:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 110704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3983132vqr; Tue, 20 Jun 2023 15:43:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fh3AMVm9zGm6+Kk8QSmqCFJ+0x7/L311evmRqN6jQbBHncCyMvHbkKMMZv/jHFLRBgZLw X-Received: by 2002:a92:4b02:0:b0:340:6c4f:d311 with SMTP id m2-20020a924b02000000b003406c4fd311mr9610259ilg.28.1687301030871; Tue, 20 Jun 2023 15:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687301030; cv=none; d=google.com; s=arc-20160816; b=SVdkQPrnX6EhOEBpJullPB681MhHN0Z3J9HilegonVGJzl2ckMLQPJF9Z8mnRRu0bZ 9vt3CqPwHZs/Lt2GKsqPSR5FeAWoxtXDHjxm75O+MlqTtw8KccIs3exxKIqk5KC8wXSj IQyW7SEBjRwYFVUav1OedMe6cZldoACjpVa96maUTvxB4Bmwhx3hg9ZJpOY507M4oynK iWEjZZ5HtBk6cyXoJ1mfOf1JROaLn+CEIdRf/lDg0uifCgtpM4JVt+/eR1UT1ZJZZzUV kU77kHRBPm9zjICHeKwUNvkLuqDKBIky0yuGH3rmYLYHD7gHmm4XYU8IiltahXe2YA9R g4kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fExjErg2s5elyUZMIYEEMEyfpHTl7v6gn/mXOuEO8R0=; b=gKDJU48x8gPhScL+lmrb3qNZx+P0xuy3q5qEAVrLlUKS7sjpA4Fgnnqb1YOT+J067+ FncuuHIc2yvGegY6uXAIspHpyG0dDa2+lu8B5GbJBVyyKj47a6rNA5DSv7rpN3VuKJVw RPzNXhIKOTmq55X0y1CDD+rPXQnGREGPABQ5p0T3D5vMPr1XfXtQfkjG4+7x0Zq/kf/a S2ittWvcNxZeYty6yfb4qpo4FwOpcYT5KXT4a+x4EKrZLyG5tRzeFnB3GL4Hu73gMS2P 6hW+946Mzd56uE1o1nYbn0x16z0oawKFgTzvHFA+wfmSqWbT//aWyZ+tiKmi024Yrme0 bxPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lUo+ML6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a17090a6a8100b0025be44ddcb9si7228814pjj.186.2023.06.20.15.43.35; Tue, 20 Jun 2023 15:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lUo+ML6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjFTW2B (ORCPT + 99 others); Tue, 20 Jun 2023 18:28:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbjFTW16 (ORCPT ); Tue, 20 Jun 2023 18:27:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A08371992 for ; Tue, 20 Jun 2023 15:27:55 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 422646606F8A; Tue, 20 Jun 2023 23:27:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687300074; bh=AABODhCwuN310nfbb59NmJs3LQPMprqxWGfMIvFY3mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUo+ML6SNU3j6mdfvL0VPxuazXyHIUsbSvRx5TX0sUIT7AbUCSZiz7AR7Kd2vfqpr E97MCrekGllfOfKE6LaF5HIT1sSGU/32ocNgkrbmgZlgcXvoXIs/t+NR1RN2xv4SAx u+VnYUY0qgEPHTdj17gYBV9kQCcX4OUADBpjG4b0SgeDddLE60qHQJk45ne+VQo9SK c3MWMzb7ZbuixO5nkn5wHDfd3YKieoBmt/Veac0wWhULte5C92dUMc5xfWnmTc/bg0 Ae6ORipDm47y75JFd5C8ZpfGPhT0x34iJkNGV3SrOV1H3fdi6sFWxR9TZbA0Owmirh FeGqtG0m+eKOQ== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Vijendar Mukunda , Syed Saba Kareem , Arnd Bergmann , Randy Dunlap , Charles Keepax , Kuninori Morimoto , Venkata Prasad Potturu Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 2/2] ASoC: amd: vangogh: Add support for NAU8821/MAX98388 variant Date: Wed, 21 Jun 2023 01:27:43 +0300 Message-ID: <20230620222743.274432-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620222743.274432-1-cristian.ciocaltea@collabora.com> References: <20230620222743.274432-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769263365590146922?= X-GMAIL-MSGID: =?utf-8?q?1769263365590146922?= Extend the Vangogh machine driver to support a variant based on the Nuvoton NAU88L21 Codec and the Analog Devices MAX98388 Speaker Amplifier. Co-developed-by: Lucas Tanure Signed-off-by: Lucas Tanure Signed-off-by: Cristian Ciocaltea --- sound/soc/amd/Kconfig | 5 +- sound/soc/amd/vangogh/acp5x-mach.c | 132 +++++++++++++++++++++++++++-- 2 files changed, 130 insertions(+), 7 deletions(-) diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index 57d5e342a8eb..fb6bee51ad03 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -79,14 +79,15 @@ config SND_SOC_AMD_ACP5x ACP DMA driver, CPU DAI driver. config SND_SOC_AMD_VANGOGH_MACH - tristate "AMD Vangogh support for NAU8821 CS35L41" + tristate "AMD Vangogh support for NAU8821/CS35L41/MAX98388" select SND_SOC_NAU8821 select SND_SOC_CS35L41_SPI + select SND_SOC_MAX98388 select SND_AMD_ACP_CONFIG depends on SND_SOC_AMD_ACP5x && I2C && SPI_MASTER help This option enables machine driver for Vangogh platform - using NAU8821 and CS35L41 codecs. + using NAU8821 and either CS35L41 or MAX98388 codecs. Say m if you have such a device. If unsure select "N". diff --git a/sound/soc/amd/vangogh/acp5x-mach.c b/sound/soc/amd/vangogh/acp5x-mach.c index 1b54eadc4979..0870eb027a84 100644 --- a/sound/soc/amd/vangogh/acp5x-mach.c +++ b/sound/soc/amd/vangogh/acp5x-mach.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Machine driver for AMD Vangogh platform using NAU8821 & CS35L41 - * codecs. + * Machine driver for AMD Vangogh platform using either + * NAU8821 & CS35L41 or NAU8821 & MAX98388 codecs. * * Copyright 2021 Advanced Micro Devices, Inc. */ @@ -29,6 +29,9 @@ #define ACP5X_CS35L41_COMP_LNAME "spi-VLV1776:00" #define ACP5X_CS35L41_COMP_RNAME "spi-VLV1776:01" #define ACP5X_CS35L41_DAI_NAME "cs35l41-pcm" +#define ACP5X_M98388_COMP_LNAME "i2c-ADS8388:00" +#define ACP5X_M98388_COMP_RNAME "i2c-ADS8388:01" +#define ACP5X_M98388_DAI_NAME "max98388-aif1" static struct snd_soc_jack vg_headset; @@ -290,8 +293,6 @@ static struct snd_soc_dai_link acp5x_8821_35l41_dai[] = { }, }; - - static const struct snd_soc_dapm_widget acp5x_8821_35l41_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -329,6 +330,126 @@ static struct snd_soc_card acp5x_8821_35l41_card = { .num_controls = ARRAY_SIZE(acp5x_8821_controls), }; +static int acp5x_max98388_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct acp5x_platform_info *machine = snd_soc_card_get_drvdata(rtd->card); + struct snd_pcm_runtime *runtime = substream->runtime; + + machine->play_i2s_instance = I2S_HS_INSTANCE; + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &constraints_rates); + return 0; +} + +static int acp5x_max98388_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_dai *dai = snd_soc_card_get_codec_dai(rtd->card, + ACP5X_M98388_DAI_NAME); + int ret; + + ret = snd_soc_dai_set_fmt(dai, + SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF); + if (ret < 0) + dev_err(dai->dev, "Failed to set format: %d\n", ret); + + return ret; +} + +static const struct snd_soc_ops acp5x_max98388_play_ops = { + .startup = acp5x_max98388_startup, + .hw_params = acp5x_max98388_hw_params, +}; + +static struct snd_soc_codec_conf acp5x_max98388_conf[] = { + { + .dlc = COMP_CODEC_CONF(ACP5X_M98388_COMP_LNAME), + .name_prefix = "Left", + }, + { + .dlc = COMP_CODEC_CONF(ACP5X_M98388_COMP_RNAME), + .name_prefix = "Right", + }, +}; + +SND_SOC_DAILINK_DEF(max98388, DAILINK_COMP_ARRAY(COMP_CODEC(ACP5X_M98388_COMP_LNAME, + ACP5X_M98388_DAI_NAME), + COMP_CODEC(ACP5X_M98388_COMP_RNAME, + ACP5X_M98388_DAI_NAME))); + +static struct snd_soc_dai_link acp5x_8221_98388_dai[] = { + { + .name = "acp5x-8821-play", + .stream_name = "Playback/Capture", + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBC_CFC, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &acp5x_8821_ops, + .init = acp5x_8821_init, + SND_SOC_DAILINK_REG(acp5x_i2s, nau8821, platform), + }, + { + .name = "acp5x-max98388-play", + .stream_name = "MAX98388 Playback", + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBC_CFC, + .dpcm_playback = 1, + .playback_only = 1, + .ops = &acp5x_max98388_play_ops, + SND_SOC_DAILINK_REG(acp5x_bt, max98388, platform), + }, +}; + +static const struct snd_soc_dapm_widget acp5x_8821_98388_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SPK("SPK", NULL), +}; + +static const struct snd_soc_dapm_route acp5x_8821_98388_route[] = { + { "Headphone", NULL, "HPOL" }, + { "Headphone", NULL, "HPOR" }, + { "MICL", NULL, "Headset Mic" }, + { "MICR", NULL, "Headset Mic" }, + { "DMIC", NULL, "Int Mic" }, + + { "Headphone", NULL, "Platform Clock" }, + { "Headset Mic", NULL, "Platform Clock" }, + { "Int Mic", NULL, "Platform Clock" }, + + { "SPK", NULL, "Left BE_OUT" }, + { "SPK", NULL, "Right BE_OUT" }, +}; + +static struct snd_soc_card acp5x_8221_max98388_card = { + .name = "acp5x-98388", + .owner = THIS_MODULE, + .dai_link = acp5x_8221_98388_dai, + .num_links = ARRAY_SIZE(acp5x_8221_98388_dai), + .dapm_widgets = acp5x_8821_98388_widgets, + .num_dapm_widgets = ARRAY_SIZE(acp5x_8821_98388_widgets), + .dapm_routes = acp5x_8821_98388_route, + .num_dapm_routes = ARRAY_SIZE(acp5x_8821_98388_route), + .codec_conf = acp5x_max98388_conf, + .num_configs = ARRAY_SIZE(acp5x_max98388_conf), + .controls = acp5x_8821_controls, + .num_controls = ARRAY_SIZE(acp5x_8821_controls), +}; + static int acp5x_probe(struct platform_device *pdev) { struct acp5x_platform_info *machine; @@ -357,6 +478,7 @@ static int acp5x_probe(struct platform_device *pdev) static const struct acpi_device_id acp5x_acpi_match[] = { { "AMDI3541", (kernel_ulong_t)&acp5x_8821_35l41_card }, + { "AMDI8821", (kernel_ulong_t)&acp5x_8221_max98388_card }, {}, }; MODULE_DEVICE_TABLE(acpi, acp5x_acpi_match); @@ -373,6 +495,6 @@ static struct platform_driver acp5x_mach_driver = { module_platform_driver(acp5x_mach_driver); MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); -MODULE_DESCRIPTION("NAU8821 & CS35L41 audio support"); +MODULE_DESCRIPTION("NAU8821/CS35L41 & NAU8821/MAX98388 audio support"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRV_NAME);