x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / drivers / scsi / ufs / tc-dwc-g210-pci.c
blobc09a0fef0fe60c0d2bf26e283235aea52317f15c
1 /*
2 * Synopsys G210 Test Chip driver
4 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
6 * Authors: Joao Pinto <jpinto@synopsys.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include "ufshcd.h"
14 #include "ufshcd-dwc.h"
15 #include "tc-dwc-g210.h"
17 #include <linux/pci.h>
18 #include <linux/pm_runtime.h>
20 /* Test Chip type expected values */
21 #define TC_G210_20BIT 20
22 #define TC_G210_40BIT 40
23 #define TC_G210_INV 0
25 static int tc_type = TC_G210_INV;
26 module_param(tc_type, int, 0);
27 MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
29 static int tc_dwc_g210_pci_suspend(struct device *dev)
31 return ufshcd_system_suspend(dev_get_drvdata(dev));
34 static int tc_dwc_g210_pci_resume(struct device *dev)
36 return ufshcd_system_resume(dev_get_drvdata(dev));
39 static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
41 return ufshcd_runtime_suspend(dev_get_drvdata(dev));
44 static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
46 return ufshcd_runtime_resume(dev_get_drvdata(dev));
49 static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
51 return ufshcd_runtime_idle(dev_get_drvdata(dev));
54 /**
55 * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
57 static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
58 .name = "tc-dwc-g210-pci",
59 .link_startup_notify = ufshcd_dwc_link_startup_notify,
62 /**
63 * tc_dwc_g210_pci_shutdown - main function to put the controller in reset state
64 * @pdev: pointer to PCI device handle
66 static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
68 ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
71 /**
72 * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
73 * data structure memory
74 * @pdev - pointer to PCI handle
76 static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
78 struct ufs_hba *hba = pci_get_drvdata(pdev);
80 pm_runtime_forbid(&pdev->dev);
81 pm_runtime_get_noresume(&pdev->dev);
82 ufshcd_remove(hba);
85 /**
86 * tc_dwc_g210_pci_probe - probe routine of the driver
87 * @pdev: pointer to PCI device handle
88 * @id: PCI device id
90 * Returns 0 on success, non-zero value on failure
92 static int
93 tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
95 struct ufs_hba *hba;
96 void __iomem *mmio_base;
97 int err;
99 /* Check Test Chip type and set the specific setup routine */
100 if (tc_type == TC_G210_20BIT) {
101 tc_dwc_g210_pci_hba_vops.phy_initialization =
102 tc_dwc_g210_config_20_bit;
103 } else if (tc_type == TC_G210_40BIT) {
104 tc_dwc_g210_pci_hba_vops.phy_initialization =
105 tc_dwc_g210_config_40_bit;
106 } else {
107 dev_err(&pdev->dev, "test chip version not specified\n");
108 return -EPERM;
111 err = pcim_enable_device(pdev);
112 if (err) {
113 dev_err(&pdev->dev, "pcim_enable_device failed\n");
114 return err;
117 pci_set_master(pdev);
119 err = pcim_iomap_regions(pdev, 1 << 0, UFSHCD);
120 if (err < 0) {
121 dev_err(&pdev->dev, "request and iomap failed\n");
122 return err;
125 mmio_base = pcim_iomap_table(pdev)[0];
127 err = ufshcd_alloc_host(&pdev->dev, &hba);
128 if (err) {
129 dev_err(&pdev->dev, "Allocation failed\n");
130 return err;
133 INIT_LIST_HEAD(&hba->clk_list_head);
135 hba->vops = &tc_dwc_g210_pci_hba_vops;
137 err = ufshcd_init(hba, mmio_base, pdev->irq);
138 if (err) {
139 dev_err(&pdev->dev, "Initialization failed\n");
140 return err;
143 pci_set_drvdata(pdev, hba);
144 pm_runtime_put_noidle(&pdev->dev);
145 pm_runtime_allow(&pdev->dev);
147 return 0;
150 static const struct dev_pm_ops tc_dwc_g210_pci_pm_ops = {
151 .suspend = tc_dwc_g210_pci_suspend,
152 .resume = tc_dwc_g210_pci_resume,
153 .runtime_suspend = tc_dwc_g210_pci_runtime_suspend,
154 .runtime_resume = tc_dwc_g210_pci_runtime_resume,
155 .runtime_idle = tc_dwc_g210_pci_runtime_idle,
158 static const struct pci_device_id tc_dwc_g210_pci_tbl[] = {
159 { PCI_VENDOR_ID_SYNOPSYS, 0xB101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
160 { PCI_VENDOR_ID_SYNOPSYS, 0xB102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
161 { } /* terminate list */
164 MODULE_DEVICE_TABLE(pci, tc_dwc_g210_pci_tbl);
166 static struct pci_driver tc_dwc_g210_pci_driver = {
167 .name = "tc-dwc-g210-pci",
168 .id_table = tc_dwc_g210_pci_tbl,
169 .probe = tc_dwc_g210_pci_probe,
170 .remove = tc_dwc_g210_pci_remove,
171 .shutdown = tc_dwc_g210_pci_shutdown,
172 .driver = {
173 .pm = &tc_dwc_g210_pci_pm_ops
177 module_pci_driver(tc_dwc_g210_pci_driver);
179 MODULE_AUTHOR("Joao Pinto <Joao.Pinto@synopsys.com>");
180 MODULE_DESCRIPTION("Synopsys Test Chip G210 PCI glue driver");
181 MODULE_LICENSE("Dual BSD/GPL");