Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp518777ybz; Fri, 24 Apr 2020 04:39:18 -0700 (PDT) X-Google-Smtp-Source: APiQypJlWSiKDH7rIxP4/UBcHZsTrv2OtUhIX8z3XimbObre6PyZp4hQZsRrfFwBEu92AZ84q1Ag X-Received: by 2002:a50:eac7:: with SMTP id u7mr6577076edp.190.1587728358197; Fri, 24 Apr 2020 04:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587728358; cv=none; d=google.com; s=arc-20160816; b=MNVctP1Tmdyz2Qu6yBjuPecAzw66oeZo92rGyxo4jstLee7BsLai4muf73bFL/ybIP ljxIPUh15bSr+BGJ054fSSwDXwxJTkLMVOs9CXxnBqfofDJY0ERgl6JUFoysANgM8WfA Q2O3TInPOuDLA3NL/sSoBJQVactQa6J/MRWHdOrMjNt7Heo1I8WxM6J0F+BwwbEtXvOm LrDhc35OPQZn4qNB1oexv9c4kXuSbeWFsQjYOn3Roru37RqFniQgACGTym0PxU2m6ecs Tb3XPl7Hv7DQd5Xig9Uj1YgK7Eit00NxFqyjHB7LE9LYiG92sgSVJvoIz7rbKjR6oUHU 53tQ== 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:dkim-signature; bh=LWNdBoy8a4cezAADBHfGJ6uWSU74aA+AKALGPUOxCFA=; b=HSmolE3o2VQGvCIdgNVKfQfG0t5VaGp0GLYaXsu7J63Og7NodpsE2DF3Q3cKPI/Koz FtThbtALqNOKoICK462BDCLxf30rbRPMLlbgYZ1G9Tur9Rr4Jul/dXIhFCzTDP+qoyQv BEPs3nkgSQG8NHT0ucaKTEtCQEQmzjUAkrkBdSlVQV3oGMu8vspW96/UcT2ZycPYgbsY DubQmvhr3lSL1JRy2NX5VB5VpgvfMf+QH55xmBLiqhSgDvDPdBxqbl7AgoD7DIjW/lXC EJ54cYbnsJ76FdiZqYog3fFQFDsxKt8F0Jcr6nokG4FbATrRsA3ww/BuDca2nIpSFw2O 1/Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=NqyydDht; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r15si2861375ejr.33.2020.04.24.04.38.54; Fri, 24 Apr 2020 04:39:18 -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; dkim=pass header.i=@synopsys.com header.s=mail header.b=NqyydDht; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbgDXLh2 (ORCPT + 99 others); Fri, 24 Apr 2020 07:37:28 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:43924 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726844AbgDXLhY (ORCPT ); Fri, 24 Apr 2020 07:37:24 -0400 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 98D04C0338; Fri, 24 Apr 2020 11:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1587728243; bh=JwK+rd4eKzzIt8cqna9j4dEcQEMTpAfxKj9SeaP4h+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=NqyydDhtrljf3bMIYvUQ6b17IC1XCLqf3U6t24PPt54usJ65miUylB47+4ANFUlHp XDwOKb/jN2c+YFmlgsavE8W7L/X2qW9rRnKsRQwxYAzdbrta/UMXNNjbY62cRepuTT pRddVaKyPgmlP+gBYCFIcgFd9MNrFDPiH+usqz8Ok2YgssFCr46vGx8v6APuCs+Wik iw64HcpYm/UpAfTiUQPK9kIsi+Cmg+Nw+e3ViX2/MRBr8RHI9icrS9aglkbPPt2PU9 nwKmx0WHixLRVyvCwk9y0dsYlSCHPLymOn5nqGH8wUkRN+FgPhilJ0C/6/NxSlwvn2 dIQ7Yj6j1JEig== Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by mailhost.synopsys.com (Postfix) with ESMTP id 530F8A0067; Fri, 24 Apr 2020 11:37:21 +0000 (UTC) From: Jose Abreu To: linux-scsi@vger.kernel.org Cc: Joao Pinto , Jose Abreu , Joao Lima , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type Date: Fri, 24 Apr 2020 13:36:58 +0200 Message-Id: <8427c06b92bae656ab3ef75c7edc980900cdf075.1587727756.git.Jose.Abreu@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for the addition of new Test Chips, we re-arrange the initialization sequence so that we rely on PCI ID to match for given Test Chip type. Signed-off-by: Jose Abreu --- Cc: Joao Lima Cc: Jose Abreu Cc: Alim Akhtar Cc: Avri Altman Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/scsi/ufs/tc-dwc-pci.c | 68 ++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/ufs/tc-dwc-pci.c b/drivers/scsi/ufs/tc-dwc-pci.c index aeb11f7f0c91..74a2d80d32bd 100644 --- a/drivers/scsi/ufs/tc-dwc-pci.c +++ b/drivers/scsi/ufs/tc-dwc-pci.c @@ -14,6 +14,11 @@ #include #include +struct tc_dwc_data { + struct ufs_hba_variant_ops ops; + int (*setup)(struct pci_dev *pdev, struct tc_dwc_data *data); +}; + /* Test Chip type expected values */ #define TC_G210_20BIT 20 #define TC_G210_40BIT 40 @@ -23,6 +28,20 @@ static int tc_type = TC_G210_INV; module_param(tc_type, int, 0); MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)"); +static int tc_dwc_g210_set_config(struct pci_dev *pdev, struct tc_dwc_data *data) +{ + if (tc_type == TC_G210_20BIT) { + data->ops.phy_initialization = tc_dwc_g210_config_20_bit; + } else if (tc_type == TC_G210_40BIT) { + data->ops.phy_initialization = tc_dwc_g210_config_40_bit; + } else { + dev_err(&pdev->dev, "test chip version not specified\n"); + return -EPERM; + } + + return 0; +} + static int tc_dwc_pci_suspend(struct device *dev) { return ufshcd_system_suspend(dev_get_drvdata(dev)); @@ -48,14 +67,6 @@ static int tc_dwc_pci_runtime_idle(struct device *dev) return ufshcd_runtime_idle(dev_get_drvdata(dev)); } -/* - * struct ufs_hba_dwc_vops - UFS DWC specific variant operations - */ -static struct ufs_hba_variant_ops tc_dwc_pci_hba_vops = { - .name = "tc-dwc-pci", - .link_startup_notify = ufshcd_dwc_link_startup_notify, -}; - /** * tc_dwc_pci_shutdown - main function to put the controller in reset state * @pdev: pointer to PCI device handle @@ -89,22 +100,11 @@ static void tc_dwc_pci_remove(struct pci_dev *pdev) static int tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - struct ufs_hba *hba; + struct tc_dwc_data *data = (struct tc_dwc_data *)id->driver_data; void __iomem *mmio_base; + struct ufs_hba *hba; int err; - /* Check Test Chip type and set the specific setup routine */ - if (tc_type == TC_G210_20BIT) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_20_bit; - } else if (tc_type == TC_G210_40BIT) { - tc_dwc_pci_hba_vops.phy_initialization = - tc_dwc_g210_config_40_bit; - } else { - dev_err(&pdev->dev, "test chip version not specified\n"); - return -EPERM; - } - err = pcim_enable_device(pdev); if (err) { dev_err(&pdev->dev, "pcim_enable_device failed\n"); @@ -127,7 +127,16 @@ tc_dwc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return err; } - hba->vops = &tc_dwc_pci_hba_vops; + /* Check Test Chip type and set the specific setup routine */ + if (data && data->setup) { + err = data->setup(pdev, data); + if (err) + return err; + } else { + return -ENOENT; + } + + hba->vops = &data->ops; err = ufshcd_init(hba, mmio_base, pdev->irq); if (err) { @@ -150,9 +159,20 @@ static const struct dev_pm_ops tc_dwc_pci_pm_ops = { .runtime_idle = tc_dwc_pci_runtime_idle, }; +static struct tc_dwc_data tc_dwc_g210_data = { + .setup = tc_dwc_g210_set_config, + .ops = { + .name = "tc-dwc-g210-pci", + .link_startup_notify = ufshcd_dwc_link_startup_notify, + }, +}; + +#define PCI_DEVICE_ID_SYNOPSYS_TC_G210_1 0xB101 +#define PCI_DEVICE_ID_SYNOPSYS_TC_G210_2 0xB102 + static const struct pci_device_id tc_dwc_pci_tbl[] = { - { PCI_VENDOR_ID_SYNOPSYS, 0xB101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { PCI_VENDOR_ID_SYNOPSYS, 0xB102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { PCI_DEVICE_DATA(SYNOPSYS, TC_G210_1, &tc_dwc_g210_data) }, + { PCI_DEVICE_DATA(SYNOPSYS, TC_G210_2, &tc_dwc_g210_data) }, { } /* terminate list */ }; -- 2.7.4