aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinayak Holikatti <vinholikatti@gmail.com>2013-02-25 11:14:33 -0500
committerJames Bottomley <JBottomley@Parallels.com>2013-02-25 11:56:32 -0500
commite0eca63e342124cff4307eafb43908cab5b3cf88 (patch)
tree3e5c881c16ba56157905fdc492029a7ad2ddfbcc
parent3b1d05807a9a68c6d0580e9248247a774a4d3be6 (diff)
[SCSI] ufs: Separate PCI code into glue driver
This patch separates PCI code from ufshcd.c and makes it as a core driver module and adds a new file ufshcd-pci.c as PCI glue driver. [jejb: strip __devinit and devexit_p()] Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Namjae Jeon <linkinjeon@gmail.com> Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org> Tested-by: Maya Erez <merez@codeaurora.org> Signed-off-by: Vinayak Holikatti <vinholikatti@gmail.com> Signed-off-by: Santosh Yaraganavi <santoshsy@gmail.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/ufs/Kconfig26
-rw-r--r--drivers/scsi/ufs/Makefile1
-rw-r--r--drivers/scsi/ufs/ufshcd-pci.c211
-rw-r--r--drivers/scsi/ufs/ufshcd.c327
-rw-r--r--drivers/scsi/ufs/ufshcd.h202
5 files changed, 440 insertions, 327 deletions
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8ee40dff3dfb..0371047c5922 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -33,7 +33,27 @@
33# this program. 33# this program.
34 34
35config SCSI_UFSHCD 35config SCSI_UFSHCD
36 tristate "Universal Flash Storage host controller driver" 36 tristate "Universal Flash Storage Controller Driver Core"
37 depends on PCI && SCSI 37 depends on SCSI
38 ---help--- 38 ---help---
39 This is a generic driver which supports PCIe UFS Host controllers. 39 This selects the support for UFS devices in Linux, say Y and make
40 sure that you know the name of your UFS host adapter (the card
41 inside your computer that "speaks" the UFS protocol, also
42 called UFS Host Controller), because you will be asked for it.
43 The module will be called ufshcd.
44
45 To compile this driver as a module, choose M here and read
46 <file:Documentation/scsi/ufs.txt>.
47 However, do not compile this as a module if your root file system
48 (the one containing the directory /) is located on a UFS device.
49
50config SCSI_UFSHCD_PCI
51 tristate "PCI bus based UFS Controller support"
52 depends on SCSI_UFSHCD && PCI
53 ---help---
54 This selects the PCI UFS Host Controller Interface. Select this if
55 you have UFS Host Controller with PCI Interface.
56
57 If you have a controller with this interface, say Y or M here.
58
59 If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index adf7895a6a91..9eda0dfbd6df 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,2 +1,3 @@
1# UFSHCD makefile 1# UFSHCD makefile
2obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o 2obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
3obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
new file mode 100644
index 000000000000..5cb1d75f5868
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -0,0 +1,211 @@
1/*
2 * Universal Flash Storage Host controller PCI glue driver
3 *
4 * This code is based on drivers/scsi/ufs/ufshcd-pci.c
5 * Copyright (C) 2011-2013 Samsung India Software Operations
6 *
7 * Authors:
8 * Santosh Yaraganavi <santosh.sy@samsung.com>
9 * Vinayak Holikatti <h.vinayak@samsung.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 * See the COPYING file in the top-level directory or visit
16 * <http://www.gnu.org/licenses/gpl-2.0.html>
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This program is provided "AS IS" and "WITH ALL FAULTS" and
24 * without warranty of any kind. You are solely responsible for
25 * determining the appropriateness of using and distributing
26 * the program and assume all risks associated with your exercise
27 * of rights with respect to the program, including but not limited
28 * to infringement of third party rights, the risks and costs of
29 * program errors, damage to or loss of data, programs or equipment,
30 * and unavailability or interruption of operations. Under no
31 * circumstances will the contributor of this Program be liable for
32 * any damages of any kind arising from your use or distribution of
33 * this program.
34 */
35
36#include "ufshcd.h"
37#include <linux/pci.h>
38
39#ifdef CONFIG_PM
40/**
41 * ufshcd_pci_suspend - suspend power management function
42 * @pdev: pointer to PCI device handle
43 * @state: power state
44 *
45 * Returns -ENOSYS
46 */
47static int ufshcd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
48{
49 /*
50 * TODO:
51 * 1. Call ufshcd_suspend
52 * 2. Do bus specific power management
53 */
54
55 return -ENOSYS;
56}
57
58/**
59 * ufshcd_pci_resume - resume power management function
60 * @pdev: pointer to PCI device handle
61 *
62 * Returns -ENOSYS
63 */
64static int ufshcd_pci_resume(struct pci_dev *pdev)
65{
66 /*
67 * TODO:
68 * 1. Call ufshcd_resume.
69 * 2. Do bus specific wake up
70 */
71
72 return -ENOSYS;
73}
74#endif /* CONFIG_PM */
75
76/**
77 * ufshcd_pci_shutdown - main function to put the controller in reset state
78 * @pdev: pointer to PCI device handle
79 */
80static void ufshcd_pci_shutdown(struct pci_dev *pdev)
81{
82 ufshcd_hba_stop((struct ufs_hba *)pci_get_drvdata(pdev));
83}
84
85/**
86 * ufshcd_pci_remove - de-allocate PCI/SCSI host and host memory space
87 * data structure memory
88 * @pdev - pointer to PCI handle
89 */
90static void ufshcd_pci_remove(struct pci_dev *pdev)
91{
92 struct ufs_hba *hba = pci_get_drvdata(pdev);
93
94 disable_irq(pdev->irq);
95 free_irq(pdev->irq, hba);
96 ufshcd_remove(hba);
97 pci_release_regions(pdev);
98 pci_set_drvdata(pdev, NULL);
99 pci_clear_master(pdev);
100 pci_disable_device(pdev);
101}
102
103/**
104 * ufshcd_set_dma_mask - Set dma mask based on the controller
105 * addressing capability
106 * @pdev: PCI device structure
107 *
108 * Returns 0 for success, non-zero for failure
109 */
110static int ufshcd_set_dma_mask(struct pci_dev *pdev)
111{
112 int err;
113
114 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
115 && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
116 return 0;
117 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
118 if (!err)
119 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
120 return err;
121}
122
123/**
124 * ufshcd_pci_probe - probe routine of the driver
125 * @pdev: pointer to PCI device handle
126 * @id: PCI device id
127 *
128 * Returns 0 on success, non-zero value on failure
129 */
130static int
131ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
132{
133 struct ufs_hba *hba;
134 void __iomem *mmio_base;
135 int err;
136
137 err = pci_enable_device(pdev);
138 if (err) {
139 dev_err(&pdev->dev, "pci_enable_device failed\n");
140 goto out_error;
141 }
142
143 pci_set_master(pdev);
144
145
146 err = pci_request_regions(pdev, UFSHCD);
147 if (err < 0) {
148 dev_err(&pdev->dev, "request regions failed\n");
149 goto out_disable;
150