aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-09-23 17:20:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-09-26 18:51:13 -0400
commit552e0c4f12fef0ad1caf21d2b57ac3a2735edef3 (patch)
tree71d7e5c19bb4ec0a614e8249eea215c3171a65ec /drivers/usb
parentda3c9c4fc5ff47da0febb7658c51d20d22e34f58 (diff)
usb/xhci: move xhci_gen_setup() away from -pci.
xhci_gen_setup() is generic so it can be used to perform the bare xhci setup even on non-pci based platform. The typedef for the function pointer is moved into the headerfile Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/xhci-pci.c91
-rw-r--r--drivers/usb/host/xhci.c89
-rw-r--r--drivers/usb/host/xhci.h2
3 files changed, 91 insertions, 91 deletions
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ca56af5e01bc..e2c82d1249c2 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -51,97 +51,6 @@ static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
51 return 0; 51 return 0;
52} 52}
53 53
54typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
55
56static int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
57{
58 struct xhci_hcd *xhci;
59 struct device *dev = hcd->self.controller;
60 int retval;
61 u32 temp;
62
63 hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2;
64
65 if (usb_hcd_is_primary_hcd(hcd)) {
66 xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL);
67 if (!xhci)
68 return -ENOMEM;
69 *((struct xhci_hcd **) hcd->hcd_priv) = xhci;
70 xhci->main_hcd = hcd;
71 /* Mark the first roothub as being USB 2.0.
72 * The xHCI driver will register the USB 3.0 roothub.
73 */
74 hcd->speed = HCD_USB2;
75 hcd->self.root_hub->speed = USB_SPEED_HIGH;
76 /*
77 * USB 2.0 roothub under xHCI has an integrated TT,
78 * (rate matching hub) as opposed to having an OHCI/UHCI
79 * companion controller.
80 */
81 hcd->has_tt = 1;
82 } else {
83 /* xHCI private pointer was set in xhci_pci_probe for the second
84 * registered roothub.
85 */
86 xhci = hcd_to_xhci(hcd);
87 temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
88 if (HCC_64BIT_ADDR(temp)) {
89 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
90 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64));
91 } else {
92 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32));
93 }
94 return 0;
95 }
96
97 xhci->cap_regs = hcd->regs;
98 xhci->op_regs = hcd->regs +
99 HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase));
100 xhci->run_regs = hcd->regs +
101 (xhci_readl(xhci, &xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
102 /* Cache read-only capability registers */
103 xhci->hcs_params1 = xhci_readl(xhci, &xhci->cap_regs->hcs_params1);
104 xhci->hcs_params2 = xhci_readl(xhci, &xhci->cap_regs->hcs_params2);
105 xhci->hcs_params3 = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
106 xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
107 xhci->hci_version = HC_VERSION(xhci->hcc_params);
108 xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
109 xhci_print_registers(xhci);
110
111 get_quirks(dev, xhci);
112
113 /* Make sure the HC is halted. */
114 retval = xhci_halt(xhci);
115 if (retval)
116 goto error;
117
118 xhci_dbg(xhci, "Resetting HCD\n");
119 /* Reset the internal HC memory state and registers. */
120 retval = xhci_reset(xhci);
121 if (retval)
122 goto error;
123 xhci_dbg(xhci, "Reset complete\n");
124
125 temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
126 if (HCC_64BIT_ADDR(temp)) {
127 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
128 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64));
129 } else {
130 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32));
131 }
132
133 xhci_dbg(xhci, "Calling HCD init\n");
134 /* Initialize HCD and host controller data structures. */
135 retval = xhci_init(hcd);
136 if (retval)
137 goto error;
138 xhci_dbg(xhci, "Called HCD init\n");
139 return 0;
140error:
141 kfree(xhci);
142 return retval;
143}
144
145static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) 54static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
146{ 55{
147 struct pci_dev *pdev = to_pci_dev(dev); 56 struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a8c3e8a34d26..2409bbe1b223 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3944,6 +3944,95 @@ int xhci_get_frame(struct usb_hcd *hcd)
3944 return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3; 3944 return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3;
3945} 3945}
3946 3946
3947int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
3948{
3949 struct xhci_hcd *xhci;
3950 struct device *dev = hcd->self.controller;
3951 int retval;
3952 u32 temp;
3953
3954 hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2;
3955
3956 if (usb_hcd_is_primary_hcd(hcd)) {
3957 xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL);
3958 if (!xhci)
3959 return -ENOMEM;
3960 *((struct xhci_hcd **) hcd->hcd_priv) = xhci;
3961 xhci->main_hcd = hcd;
3962 /* Mark the first roothub as being USB 2.0.
3963 * The xHCI driver will register the USB 3.0 roothub.
3964 */
3965 hcd->speed = HCD_USB2;
3966 hcd->self.root_hub->speed = USB_SPEED_HIGH;
3967 /*
3968 * USB 2.0 roothub under xHCI has an integrated TT,
3969 * (rate matching hub) as opposed to having an OHCI/UHCI
3970 * companion controller.
3971 */
3972 hcd->has_tt = 1;
3973 } else {
3974 /* xHCI private pointer was set in xhci_pci_probe for the second
3975 * registered roothub.
3976 */
3977 xhci = hcd_to_xhci(hcd);
3978 temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
3979 if (HCC_64BIT_ADDR(temp)) {
3980 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
3981 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64));
3982 } else {
3983 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32));
3984 }
3985 return 0;
3986 }
3987
3988 xhci->cap_regs = hcd->regs;
3989 xhci->op_regs = hcd->regs +
3990 HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase));
3991 xhci->run_regs = hcd->regs +
3992 (xhci_readl(xhci, &xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
3993 /* Cache read-only capability registers */
3994 xhci->hcs_params1 = xhci_readl(xhci, &xhci->cap_regs->hcs_params1);
3995 xhci->hcs_params2 = xhci_readl(xhci, &xhci->cap_regs->hcs_params2);
3996 xhci->hcs_params3 = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
3997 xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
3998 xhci->hci_version = HC_VERSION(xhci->hcc_params);
3999 xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
4000 xhci_print_registers(xhci);
4001
4002 get_quirks(dev, xhci);
4003
4004 /* Make sure the HC is halted. */
4005 retval = xhci_halt(xhci);
4006 if (retval)
4007 goto error;
4008
4009 xhci_dbg(xhci, "Resetting HCD\n");
4010 /* Reset the internal HC memory state and registers. */
4011 retval = xhci_reset(xhci);
4012 if (retval)
4013 goto error;
4014 xhci_dbg(xhci, "Reset complete\n");
4015
4016 temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
4017 if (HCC_64BIT_ADDR(temp)) {
4018 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
4019 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64));
4020 } else {
4021 dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32));
4022 }
4023
4024 xhci_dbg(xhci, "Calling HCD init\n");
4025 /* Initialize HCD and host controller data structures. */
4026 retval = xhci_init(hcd);
4027 if (retval)
4028 goto error;
4029 xhci_dbg(xhci, "Called HCD init\n");
4030 return 0;
4031error:
4032 kfree(xhci);
4033 return retval;
4034}
4035
3947MODULE_DESCRIPTION(DRIVER_DESC); 4036MODULE_DESCRIPTION(DRIVER_DESC);
3948MODULE_AUTHOR(DRIVER_AUTHOR); 4037MODULE_AUTHOR(DRIVER_AUTHOR);
3949MODULE_LICENSE("GPL"); 4038MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 4050656bffed..ad11c38afe85 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1647,6 +1647,7 @@ void xhci_unregister_pci(void);
1647#endif 1647#endif
1648 1648
1649/* xHCI host controller glue */ 1649/* xHCI host controller glue */
1650typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
1650void xhci_quiesce(struct xhci_hcd *xhci); 1651void xhci_quiesce(struct xhci_hcd *xhci);
1651int xhci_halt(struct xhci_hcd *xhci); 1652int xhci_halt(struct xhci_hcd *xhci);
1652int xhci_reset(struct xhci_hcd *xhci); 1653int xhci_reset(struct xhci_hcd *xhci);
@@ -1654,6 +1655,7 @@ int xhci_init(struct usb_hcd *hcd);
1654int xhci_run(struct usb_hcd *hcd); 1655int xhci_run(struct usb_hcd *hcd);
1655void xhci_stop(struct usb_hcd *hcd); 1656void xhci_stop(struct usb_hcd *hcd);
1656void xhci_shutdown(struct usb_hcd *hcd); 1657void xhci_shutdown(struct usb_hcd *hcd);
1658int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
1657 1659
1658#ifdef CONFIG_PM 1660#ifdef CONFIG_PM
1659int xhci_suspend(struct xhci_hcd *xhci); 1661int xhci_suspend(struct xhci_hcd *xhci);