Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3128582ybc; Thu, 21 Nov 2019 03:50:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwk3y0aqWYf+Jbkwu/Or5On261tAxK0fJB4JKSVm625d/lJD4dGTju3xcTC6JPt0Yxf0vRL X-Received: by 2002:a17:906:4098:: with SMTP id u24mr13194696ejj.220.1574337054778; Thu, 21 Nov 2019 03:50:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1574337054; cv=pass; d=google.com; s=arc-20160816; b=YApeX+YTrIASA5XMM0CyZqySk8HQSI2dLVBHiqlympwdSfs9YAA2Lw/mnTZZE/ZGBs X08fHsAXSt/WEMAiIG6dcdx3kKHQDyzyhUQ8o0shc6/WuqL8wO0qjoiv6+Fv7ml/IaXA abfIQ63nt8DMZXONdGFxY/wsbuyvUrn2Saea9lSuLEcE2YHO65QRFiNy9cbB9UBwfzip YGypntuROmKzpjivSS6uW1h61VPsmwSNxgpAcvBRKqWrIZVE72DoXQW+LDDbUCNC85MC a+CShiTNgD+KbCz/7+7H4wUVl/AMBporj1z3Gm5+yIKJH8YJEfyCsvyj+2Vq4Jr3X7is TDig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:references:in-reply-to :message-id:date:subject:cc:from:dkim-signature; bh=+fz1dqtk8WvUjuLkBhg/qwGWrrmk8haUxZMDbwSv0hk=; b=T+c+MwEbw5NzQYg9/0fiK7y3D8kksPksRQvCxJxn1FS/5cdWm4larnlvk3RM7H/EVx Z56eHddc+bhJs2xsBqjqabb/NGHq9bbxLBt/fq7mkH0J+r2ywIpDzgQKKs5fnGb5LeTg uG7dyhvneb99yaPGPWg0PX8pSz6yg58pmcOAGjk/PXjKwzPd/WbjnOinjWqUwnJ2It8d H4ZGk+tPPa3BGFstHANwf/ntFoezidI5GH1DzjuVik2T8AJXS1N2h2jUGosPHeDjU3w5 JsLl35Fd9JZZouJJi+zzDwUD2JmrNXn6ly2cHWblCH87jo8z7MZojBPyY4rGls/azKTR QJHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=yzty9kIp; arc=pass (i=1); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si1557481ejk.81.2019.11.21.03.50.30; Thu, 21 Nov 2019 03:50:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=yzty9kIp; arc=pass (i=1); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbfKULtD (ORCPT + 99 others); Thu, 21 Nov 2019 06:49:03 -0500 Received: from mail-eopbgr820048.outbound.protection.outlook.com ([40.107.82.48]:15753 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726358AbfKULtD (ORCPT ); Thu, 21 Nov 2019 06:49:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M677T7kNDGEjq3FedMJ/5/gUjwcSF8CyveYY6xeoc2ISTwaecI6cEwercjFARk5HSYliQyKJH7oykNpQHqMwTVxa7eW9fZsbem31rS4ujU8ErCcG9NBWFFrml0cvwOxyPtGJWWS75b36LzPaKLvS3wr66k+uil8zcShCR15XZrx6WB6ZeBczPh/zPAolJJMnQGz9ly6lmZW6Gpfsy3fYyVxOWM72gfNApIaQ4Wf+cbs4g4kQ1verfuKbHHQJ7AqNk+rQJURnBLvvLir/dLP96pLoZfD06eCNnSlei6ekCCft6HDYyngYfjxQ9EUPCHWAVpBPbMZU8gynHnQ/1UBo4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+fz1dqtk8WvUjuLkBhg/qwGWrrmk8haUxZMDbwSv0hk=; b=UIGx5E6PJzGzYkwMvnBOHEvE4KddKXgXd5iTjQW1PIM+e1dzCwvxc+JhohgSGEdID9OFPy7aTNAljeivH6p2ofwZjABoL9AiHWfY2XegpY69qXDHoOGXN0jplzmmyOeyJSNRBP7o47t3OgZmtpLZdJuoDq/e94/RRX4Eg82LJgOR4cmG98s72/5gmhysWWmKg4bOKKLCKzvW1mwF28KUNtPuZlhSX579T4l5VOrLyAolOsIRM0HGCSrAyQwkTdecOtbqNL6XUU5PjslSqFeU7VvupFFCzDoxvZlV8aI6gW3Zsr0J7cDipvSQ/gNYIwJxNwMvzFVVJqrvVSG0q/L/Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+fz1dqtk8WvUjuLkBhg/qwGWrrmk8haUxZMDbwSv0hk=; b=yzty9kIpVyt9asNQlGEV359Dn+qndbaXPjLqqvB84fw89hpZ3MeAjvuuRT4DuzBCFo8jd05jXnvWKO2VNPEGVVHM4+qRyCgkVODveruQnFAkyD4BeY77mP6cewG0EYOMwAs9wYZL+FxA8YZkRMZKvob5jxPu7Z9fbSgWSFf4gFg= Received: from BN8PR12CA0019.namprd12.prod.outlook.com (2603:10b6:408:60::32) by BN6PR12MB1762.namprd12.prod.outlook.com (2603:10b6:404:fe::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.19; Thu, 21 Nov 2019 11:47:18 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eaa::207) by BN8PR12CA0019.outlook.office365.com (2603:10b6:408:60::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.18 via Frontend Transport; Thu, 21 Nov 2019 11:47:17 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB01.amd.com (165.204.84.17) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2451.23 via Frontend Transport; Thu, 21 Nov 2019 11:47:17 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 21 Nov 2019 05:47:17 -0600 Received: from SATLEXMB02.amd.com (10.181.40.143) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 21 Nov 2019 05:47:16 -0600 Received: from vishnu-All-Series.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Thu, 21 Nov 2019 05:47:13 -0600 From: Ravulapati Vishnu vardhan rao CC: , , , , "Ravulapati Vishnu vardhan rao" , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Dan Carpenter , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , open list Subject: [RESEND PATCH v11 1/6] ASoC: amd:Create multiple I2S platform device endpoints Date: Thu, 21 Nov 2019 17:15:56 +0530 Message-ID: <1574336761-16717-2-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574336761-16717-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> References: <1574336761-16717-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(376002)(346002)(39850400004)(136003)(428003)(199004)(189003)(70206006)(70586007)(8936002)(48376002)(11346002)(446003)(2616005)(50466002)(50226002)(81156014)(81166006)(8676002)(109986005)(356004)(6666004)(47776003)(305945005)(54906003)(478600001)(7696005)(2906002)(51416003)(76176011)(426003)(4326008)(1671002)(26005)(316002)(36756003)(53416004)(16586007)(86362001)(336012)(186003)(5660300002)(266003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1762;H:SATLEXMB01.amd.com;FPR:;SPF:None;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac5517b4-0e81-49e4-d9e1-08d76e788f75 X-MS-TrafficTypeDiagnostic: BN6PR12MB1762: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:182; X-Forefront-PRVS: 0228DDDDD7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RkFJKRrsP7E62OF3A0gF8rk3A20bcYWMe9uToR66ycgn+Q7Psk3dDFZguQgRi9n0OkzUtWvhev/rDBOOPQBVCdEk/uPp6q0V43c77PjmvUbsUVzgIfbaiKUOlCNQCO70qvPO/tjnhgSXlXd8uagUFCQyKxGZEAOEbzXHZbvOuMSSjgSDiUmQcy7MnqJg4c2BStqx5oD0aGOQGZaqjaVmllb6uellX0bCqHXEtQJaRP8cvcFn8YuIELhSMLZ0VuIeg6UtqHKL3NHVLzeFxiAFZA73PFz/VLQegVXxRQnrEk48QvqkgWyKiM+6TcUHP0xwLJYT1NKhcD9vxiznbFsAK7JvFzOepJqG7RLGXENxljobDmF0Ld63scGDGoJeTOlQhJXUkuOzv8lZuPayrMZ1+xgwzp9shys8z0Z8bAEI60u70TcLJ6ZaZYyGmNspJRdE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2019 11:47:17.7300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac5517b4-0e81-49e4-d9e1-08d76e788f75 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1762 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Creates Platform Device endpoints for multiple I2S instances: SP and BT endpoints device. Pass PCI resources like MMIO, irq to the platform devices. Signed-off-by: Ravulapati Vishnu vardhan rao Reviewed-by: Dan Carpenter --- sound/soc/amd/raven/acp3x.h | 5 +++ sound/soc/amd/raven/pci-acp3x.c | 95 +++++++++++++++++++++++++++-------------- 2 files changed, 68 insertions(+), 32 deletions(-) diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index 4f2cadd..2f15fe1 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -7,10 +7,15 @@ #include "chip_offset_byte.h" +#define ACP3x_DEVS 3 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 #define ACP3x_I2S_MODE 0 #define ACP3x_REG_START 0x1240000 #define ACP3x_REG_END 0x1250200 +#define ACP3x_I2STDM_REG_START 0x1242400 +#define ACP3x_I2STDM_REG_END 0x1242410 +#define ACP3x_BT_TDM_REG_START 0x1242800 +#define ACP3x_BT_TDM_REG_END 0x1242810 #define I2S_MODE 0x04 #define BT_TX_THRESHOLD 26 #define BT_RX_THRESHOLD 25 diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index facec24..94f5f21 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -16,17 +16,17 @@ struct acp3x_dev_data { void __iomem *acp3x_base; bool acp3x_audio_mode; struct resource *res; - struct platform_device *pdev; + struct platform_device *pdev[ACP3x_DEVS]; }; static int snd_acp3x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - int ret; - u32 addr, val; struct acp3x_dev_data *adata; - struct platform_device_info pdevinfo; + struct platform_device_info pdevinfo[ACP3x_DEVS]; unsigned int irqflags; + int ret, i; + u32 addr, val; if (pci_enable_device(pci)) { dev_err(&pci->dev, "pci_enable_device failed\n"); @@ -56,10 +56,11 @@ static int snd_acp3x_probe(struct pci_dev *pci, irqflags = 0; addr = pci_resource_start(pci, 0); - adata->acp3x_base = ioremap(addr, pci_resource_len(pci, 0)); + adata->acp3x_base = devm_ioremap(&pci->dev, addr, + pci_resource_len(pci, 0)); if (!adata->acp3x_base) { ret = -ENOMEM; - goto release_regions; + goto disable_msi; } pci_set_master(pci); pci_set_drvdata(pci, adata); @@ -68,11 +69,11 @@ static int snd_acp3x_probe(struct pci_dev *pci, switch (val) { case I2S_MODE: adata->res = devm_kzalloc(&pci->dev, - sizeof(struct resource) * 2, + sizeof(struct resource) * 4, GFP_KERNEL); if (!adata->res) { ret = -ENOMEM; - goto unmap_mmio; + goto disable_msi; } adata->res[0].name = "acp3x_i2s_iomem"; @@ -80,40 +81,67 @@ static int snd_acp3x_probe(struct pci_dev *pci, adata->res[0].start = addr; adata->res[0].end = addr + (ACP3x_REG_END - ACP3x_REG_START); - adata->res[1].name = "acp3x_i2s_irq"; - adata->res[1].flags = IORESOURCE_IRQ; - adata->res[1].start = pci->irq; - adata->res[1].end = pci->irq; + adata->res[1].name = "acp3x_i2s_sp"; + adata->res[1].flags = IORESOURCE_MEM; + adata->res[1].start = addr + ACP3x_I2STDM_REG_START; + adata->res[1].end = addr + ACP3x_I2STDM_REG_END; + + adata->res[2].name = "acp3x_i2s_bt"; + adata->res[2].flags = IORESOURCE_MEM; + adata->res[2].start = addr + ACP3x_BT_TDM_REG_START; + adata->res[2].end = addr + ACP3x_BT_TDM_REG_END; + + adata->res[3].name = "acp3x_i2s_irq"; + adata->res[3].flags = IORESOURCE_IRQ; + adata->res[3].start = pci->irq; + adata->res[3].end = adata->res[3].start; adata->acp3x_audio_mode = ACP3x_I2S_MODE; memset(&pdevinfo, 0, sizeof(pdevinfo)); - pdevinfo.name = "acp3x_rv_i2s"; - pdevinfo.id = 0; - pdevinfo.parent = &pci->dev; - pdevinfo.num_res = 2; - pdevinfo.res = adata->res; - pdevinfo.data = &irqflags; - pdevinfo.size_data = sizeof(irqflags); - - adata->pdev = platform_device_register_full(&pdevinfo); - if (IS_ERR(adata->pdev)) { - dev_err(&pci->dev, "cannot register %s device\n", - pdevinfo.name); - ret = PTR_ERR(adata->pdev); - goto unmap_mmio; + pdevinfo[0].name = "acp3x_rv_i2s_dma"; + pdevinfo[0].id = 0; + pdevinfo[0].parent = &pci->dev; + pdevinfo[0].num_res = 4; + pdevinfo[0].res = &adata->res[0]; + pdevinfo[0].data = &irqflags; + pdevinfo[0].size_data = sizeof(irqflags); + + pdevinfo[1].name = "acp3x_i2s_playcap"; + pdevinfo[1].id = 0; + pdevinfo[1].parent = &pci->dev; + pdevinfo[1].num_res = 1; + pdevinfo[1].res = &adata->res[1]; + + pdevinfo[2].name = "acp3x_i2s_playcap"; + pdevinfo[2].id = 1; + pdevinfo[2].parent = &pci->dev; + pdevinfo[2].num_res = 1; + pdevinfo[2].res = &adata->res[2]; + for (i = 0; i < ACP3x_DEVS ; i++) { + adata->pdev[i] = + platform_device_register_full(&pdevinfo[i]); + if (IS_ERR(adata->pdev[i])) { + dev_err(&pci->dev, "cannot register %s device\n", + pdevinfo[i].name); + ret = PTR_ERR(adata->pdev[i]); + goto unregister_devs; + } } break; default: dev_err(&pci->dev, "Invalid ACP audio mode : %d\n", val); ret = -ENODEV; - goto unmap_mmio; + goto disable_msi; } return 0; -unmap_mmio: +unregister_devs: + if (val == I2S_MODE) + for (i = 0 ; i < ACP3x_DEVS ; i++) + platform_device_unregister(adata->pdev[i]); +disable_msi: pci_disable_msi(pci); - iounmap(adata->acp3x_base); release_regions: pci_release_regions(pci); disable_pci: @@ -125,10 +153,12 @@ static int snd_acp3x_probe(struct pci_dev *pci, static void snd_acp3x_remove(struct pci_dev *pci) { struct acp3x_dev_data *adata = pci_get_drvdata(pci); + int i; - platform_device_unregister(adata->pdev); - iounmap(adata->acp3x_base); - + if (adata->acp3x_audio_mode == ACP3x_I2S_MODE) { + for (i = 0 ; i < ACP3x_DEVS ; i++) + platform_device_unregister(adata->pdev[i]); + } pci_disable_msi(pci); pci_release_regions(pci); pci_disable_device(pci); @@ -151,6 +181,7 @@ static struct pci_driver acp3x_driver = { module_pci_driver(acp3x_driver); +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com"); MODULE_DESCRIPTION("AMD ACP3x PCI driver"); MODULE_LICENSE("GPL v2"); -- 2.7.4