public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Winkler, Tomas" <tomas.winkler@intel.com>
To: Jose Abreu <Jose.Abreu@synopsys.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: Joao Pinto <Joao.Pinto@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" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 3/5] scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type
Date: Fri, 24 Apr 2020 12:00:33 +0000	[thread overview]
Message-ID: <a0656591acea47e2b6765d2411f0a362@intel.com> (raw)
In-Reply-To: <8427c06b92bae656ab3ef75c7edc980900cdf075.1587727756.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 = {

Constify the struct, if possible. 

> +	.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


  reply	other threads:[~2020-04-24 12:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 11:36 [PATCH 0/5] scsi: ufs: Misc improvements for DesignWare drivers and UFS Jose Abreu
2020-04-24 11:36 ` [PATCH 1/5] scsi: ufs: Allow UFS 3.0 as a valid version Jose Abreu
2020-04-24 11:57   ` Winkler, Tomas
2020-04-24 12:08   ` Alim Akhtar
2020-04-25 11:10   ` Christoph Hellwig
2020-04-27  7:50     ` Jose Abreu
2020-04-24 11:36 ` [PATCH 2/5] scsi: ufs: Rename tc-dwc-g210 -> tc-dwc Jose Abreu
2020-04-24 11:36 ` [PATCH 3/5] scsi: ufs: tc-dwc-pci: Use PDI ID to match Test Chip type Jose Abreu
2020-04-24 12:00   ` Winkler, Tomas [this message]
2020-04-24 12:08     ` Jose Abreu
2020-04-24 11:36 ` [PATCH 4/5] scsi: ufs: tc-dwc-pci: Allow for MSI interrupt type Jose Abreu
2020-04-24 11:55   ` Winkler, Tomas
2020-04-24 12:02     ` Jose Abreu
2020-04-24 11:37 ` [PATCH 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=a0656591acea47e2b6765d2411f0a362@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=Joao.Lima@synopsys.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=Jose.Abreu@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