From: Jose Abreu <Jose.Abreu@synopsys.com>
To: linux-scsi@vger.kernel.org
Cc: Joao Pinto <Joao.Pinto@synopsys.com>,
Jose Abreu <Jose.Abreu@synopsys.com>,
Joao Lima <Joao.Lima@synopsys.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/5] scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type
Date: Fri, 24 Apr 2020 15:44:47 +0200 [thread overview]
Message-ID: <f41c99a205e4e0fc85e9ebdd3a294f58c76960a6.1587735561.git.Jose.Abreu@synopsys.com> (raw)
In-Reply-To: <cover.1587735561.git.Jose.Abreu@synopsys.com>
In-Reply-To: <cover.1587735561.git.Jose.Abreu@synopsys.com>
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 <Jose.Abreu@synopsys.com>
---
Cc: Joao Lima <Joao.Lima@synopsys.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Avri Altman <avri.altman@wdc.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
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 <linux/pci.h>
#include <linux/pm_runtime.h>
+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
next prev parent reply other threads:[~2020-04-24 13:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 13:44 [PATCH v2 0/5] scsi: ufs: Misc improvements for DesignWare drivers and UFS Jose Abreu
2020-04-24 13:44 ` [PATCH v2 1/5] scsi: ufs: Allow UFS 3.0 as a valid version Jose Abreu
2020-04-24 15:57 ` [EXT] " Bean Huo (beanhuo)
2020-04-29 6:49 ` Jose Abreu
2020-04-29 12:59 ` Bean Huo (beanhuo)
2020-04-30 8:14 ` Jose Abreu
2020-06-10 3:39 ` Alim Akhtar
2020-06-12 9:40 ` Jose Abreu
2020-04-24 13:44 ` [PATCH v2 2/5] scsi: ufs: Rename tc-dwc-g210 -> tc-dwc Jose Abreu
2020-04-24 13:44 ` Jose Abreu [this message]
2020-04-24 13:44 ` [PATCH v2 4/5] scsi: ufs: tc-dwc-pci: Allow for MSI interrupt type Jose Abreu
2020-04-24 13:44 ` [PATCH v2 5/5] MAINTAINERS: Change Maintainers for SCSI UFS DWC Drivers Jose Abreu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f41c99a205e4e0fc85e9ebdd3a294f58c76960a6.1587735561.git.Jose.Abreu@synopsys.com \
--to=jose.abreu@synopsys.com \
--cc=Joao.Lima@synopsys.com \
--cc=Joao.Pinto@synopsys.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®