Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp425555ybz; Fri, 1 May 2020 01:22:59 -0700 (PDT) X-Google-Smtp-Source: APiQypKucFK7ijKQGN9SR1afi+23kMYK7qU8V6FJFDAZ5L8ocz9XLXzEAmjr7XfCdHJDX4lqN7j2 X-Received: by 2002:a50:beca:: with SMTP id e10mr2494271edk.294.1588321379459; Fri, 01 May 2020 01:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588321379; cv=none; d=google.com; s=arc-20160816; b=Rc864fZP+0qStWG9hc8p66wiffqFd/zm9a+STZfdm1IYOZ+y+XL1p5GiZ4C44b9o0u p4ONWqLjCwv3vSuqsPeIGkOgMbiKPALcARHCFldDmB7MJtgNOUwy5jTdTJmt6VfJ7nbC 0EOcBk3CbZvgsirjHz55Zm16J5ZfzMg/+LRTmi/yaQgFVgbYFlboUw8afK7cNm19+LX8 3rTeXl/7sW4n7MT7KH8W1WCMluuVNlJBt2DBPmZyHeB54IuHALtinVQwG72BuQW0YfKn cv8vyM84HxZ9OMeuL4GLc6V4LCJm5JFi+zop61GZ2cgNQr09mRuzdPkouZ6UWOx/PYzj o44g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=TrAkM71qQqE4zT8t2pxelRb1PIwoCfKVuOb+F+fd6lc=; b=B5XQbh37GIzlAz/uyW8rDJIHXM/flnHoxOcqOujRwUa8UYNiDOoGivD/eHBcBWGgZM RhO+u0cHen03BoZoV+5zcr8y9aofCkIeJV69RVwZygbGK8QlF08Ck22bEXBdVaYo5skz yTf4Y9svhjbv+jHadsdGK/LKhUxdoTSjJ6hoAUFhEHu2j2UjJWV2h4qtK/6FK7SqFgOI XfVD8ur6tyzN5n60b234fyRriixdDrKXPV99H2ndySW/IZlKz4udbtaD1oclVFvRZZsV hX9MwPl9GIEBkkeIj6dCHX8n9zTLiEZLjynkIc8Lxf+rXmBRIfeZGaSvIF8YxZtuOcSa EFPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si1242484edw.542.2020.05.01.01.22.36; Fri, 01 May 2020 01:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728442AbgEAIVK (ORCPT + 99 others); Fri, 1 May 2020 04:21:10 -0400 Received: from inva020.nxp.com ([92.121.34.13]:33698 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728431AbgEAIVH (ORCPT ); Fri, 1 May 2020 04:21:07 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 524791A0B36; Fri, 1 May 2020 10:21:05 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D409C1A0B65; Fri, 1 May 2020 10:20:59 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 7DC67402BE; Fri, 1 May 2020 16:20:53 +0800 (SGT) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, lgirdwood@gmail.com, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] ASoC: fsl_esai: introduce SoC specific data Date: Fri, 1 May 2020 16:12:04 +0800 Message-Id: <27af074e47bf2b81e2dce67ea66a9f7301dfcb07.1588320656.git.shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a SoC specific data structure which contains the differences between the different SoCs. This makes it easier to support more differences without having to introduce a new if/else each time. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_esai.c | 46 ++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 84290be778f0..bac65ba7fbad 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -21,6 +21,17 @@ SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE) +/** + * fsl_esai_soc_data: soc specific data + * + * @imx: for imx platform + * @reset_at_xrun: flags for enable reset operaton + */ +struct fsl_esai_soc_data { + bool imx; + bool reset_at_xrun; +}; + /** * fsl_esai: ESAI private data * @@ -33,6 +44,7 @@ * @fsysclk: system clock source to derive HCK, SCK and FS * @spbaclk: SPBA clock (optional, depending on SoC design) * @task: tasklet to handle the reset operation + * @soc: soc specific data * @lock: spin lock between hw_reset() and trigger() * @fifo_depth: depth of tx/rx FIFO * @slot_width: width of each DAI slot @@ -44,7 +56,6 @@ * @sck_div: if using PSR/PM dividers for SCKx clock * @slave_mode: if fully using DAI slave mode * @synchronous: if using tx/rx synchronous mode - * @reset_at_xrun: flags for enable reset operaton * @name: driver name */ struct fsl_esai { @@ -57,6 +68,7 @@ struct fsl_esai { struct clk *fsysclk; struct clk *spbaclk; struct tasklet_struct task; + const struct fsl_esai_soc_data *soc; spinlock_t lock; /* Protect hw_reset and trigger */ u32 fifo_depth; u32 slot_width; @@ -70,10 +82,24 @@ struct fsl_esai { bool sck_div[2]; bool slave_mode; bool synchronous; - bool reset_at_xrun; char name[32]; }; +static struct fsl_esai_soc_data fsl_esai_vf610 = { + .imx = false, + .reset_at_xrun = true, +}; + +static struct fsl_esai_soc_data fsl_esai_imx35 = { + .imx = true, + .reset_at_xrun = true, +}; + +static struct fsl_esai_soc_data fsl_esai_imx6ull = { + .imx = true, + .reset_at_xrun = false, +}; + static irqreturn_t esai_isr(int irq, void *devid) { struct fsl_esai *esai_priv = (struct fsl_esai *)devid; @@ -85,7 +111,7 @@ static irqreturn_t esai_isr(int irq, void *devid) regmap_read(esai_priv->regmap, REG_ESAI_SAISR, &saisr); if ((saisr & (ESAI_SAISR_TUE | ESAI_SAISR_ROE)) && - esai_priv->reset_at_xrun) { + esai_priv->soc->reset_at_xrun) { dev_dbg(&pdev->dev, "reset module for xrun\n"); regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, ESAI_xCR_xEIE_MASK, 0); @@ -936,9 +962,11 @@ static int fsl_esai_probe(struct platform_device *pdev) esai_priv->pdev = pdev; snprintf(esai_priv->name, sizeof(esai_priv->name), "%pOFn", np); - if (of_device_is_compatible(np, "fsl,vf610-esai") || - of_device_is_compatible(np, "fsl,imx35-esai")) - esai_priv->reset_at_xrun = true; + esai_priv->soc = of_device_get_match_data(&pdev->dev); + if (!esai_priv->soc) { + dev_err(&pdev->dev, "failed to get soc data\n"); + return -ENODEV; + } /* Get the addresses and IRQ */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1063,9 +1091,9 @@ static int fsl_esai_remove(struct platform_device *pdev) } static const struct of_device_id fsl_esai_dt_ids[] = { - { .compatible = "fsl,imx35-esai", }, - { .compatible = "fsl,vf610-esai", }, - { .compatible = "fsl,imx6ull-esai", }, + { .compatible = "fsl,imx35-esai", .data = &fsl_esai_imx35 }, + { .compatible = "fsl,vf610-esai", .data = &fsl_esai_vf610 }, + { .compatible = "fsl,imx6ull-esai", .data = &fsl_esai_imx6ull }, {} }; MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); -- 2.21.0