Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp634745ybz; Fri, 24 Apr 2020 06:47:32 -0700 (PDT) X-Google-Smtp-Source: APiQypJdR1Wl3KECqlxEX2B8W6nzsTjOp2/ontKFbiJSs07kbzC4ebIY5lFyiDTbmALL4JgQlebN X-Received: by 2002:a17:906:1ec3:: with SMTP id m3mr7385509ejj.88.1587736051932; Fri, 24 Apr 2020 06:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587736051; cv=none; d=google.com; s=arc-20160816; b=GNK9Jmy4QWnQ38DeIQjXKFX1oRCtGVYC0q/XoHTOZvxdPKWsFO8P2vTL3TBUdZs0ds cCQamHyZ471aTF/ApK7SqG6yb5MIjIGgd4lFRrApzH7gHChf7ahXGdEMEpgvMJhOHbiR 9RW6JL0/SNvhrDCHZiqnJzJhYLyZZ1Ae3S8cV/FlKnhvVRW0NCBkQ2DqOZyp4P0g2ye/ ibvP69OitLu3GwnwdPaLzeN92LgpFS7Mfg1m5wIlAyPr0xOoGq6XR64mYwwZAk6JAnxh EhQRfblcv0u7uthjqhZxFN7Eh0uKWFM9qW3Tb/NhazJNx0uP2DhL9okTeSfEtzUPK/0M mTFw== 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=Io+b40lBo7ehT5jlmDbvYS69Ly+WXDKnQsXVoO+Hf4vD4TlouBxPOWxY/KBe2mpSI6 589Dj7FYynig0hsPTGG5gOhRm6niW6NqiN1sbKUK8IuzMKYdalDv2KZZZ1AU3l1W4Bnu eYprxyfbptcLuntn7FzD9HChUXKr949BPBKYjAJIV5jj4jXyz1iWns+4jzfw16y6Kx3J V28qD2lBFect2PLeujwBx15rsbv4zrWCNInimbYRXMCMQtZFMGNBEyO7ZGN0YHPT2HVU jiXv1uPBx/tbqBbemgpJ4ayL3qjl96dQ8743YrtyhgUuwggH02nMKQkrAzAdfVs0p7/o HbyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=KWXwb1gY; 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 m7si3173965ejr.512.2020.04.24.06.47.08; Fri, 24 Apr 2020 06:47:31 -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=KWXwb1gY; 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 S1728239AbgDXNpS (ORCPT + 99 others); Fri, 24 Apr 2020 09:45:18 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.73.133]:45454 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727015AbgDXNpE (ORCPT ); Fri, 24 Apr 2020 09:45:04 -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 0C251404B6; Fri, 24 Apr 2020 13:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1587735904; bh=JwK+rd4eKzzIt8cqna9j4dEcQEMTpAfxKj9SeaP4h+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=KWXwb1gYt4ioueSNvprp50XXuY8d/bJRxuoP07/XWsJGckluZ+4N4tO9gCDT7iDtt npTy/BGkFcHyJWQPs8+I1Zvx0SAoYZTnghsG1RHXqaQR/aSopzd4H1tphyVsDyqQx2 gQZqbrLSn309II6mNokyhxPQCUy2/i3CnnGqBKUT/2+I35XO+7CTKZU6xmfEWYT2yO jwnbHQgC4HbR0dbOsgXW5YN0Af5560Rm/SlLHzb/dWF2sI1yYmCxZDMTIv755t6uRK Tjb6X19IVEQuT07IV0gb7RrrTZXnwL3lahrQYkafeC5fxvASMFc0IDkHTyyB++NA18 ZzF5TcB09RZnQ== Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by mailhost.synopsys.com (Postfix) with ESMTP id CAF60A0067; Fri, 24 Apr 2020 13:45:02 +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 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 Message-Id: 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