diff options
| author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-09-23 17:20:00 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-26 18:51:13 -0400 |
| commit | da3c9c4fc5ff47da0febb7658c51d20d22e34f58 (patch) | |
| tree | 41db0a25aaeb011851a8f8833dd3bcc73c65d1b4 | |
| parent | 22d45f01a836c2f5826b8b4b9e029e5f79afec57 (diff) | |
usb/xhci: refactor xhci_pci_setup()
xhci_pci_setup() is split into three pieces:
- xhci_gen_setup()
The major remaining of xhci_pci_setup() is now containing the generic
part of the xhci setup. It allocates the xhci struct, setup
hcs_params? and friends, performs xhci_halt(), xhci_init and so one.
It also obtains the quirks via a callback
- xhci_pci_quirks()
It checks the origin of the xhci core and sets core specific quirks.
- xhci_pci_setup()
PCI specific setup functions. Besides calling xhci_gen_setup() with
xhci_pci_quirks() as an argument it performs PCI specific setup like
obtaining the address of sbrn via a PCI config space.
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>
| -rw-r--r-- | drivers/usb/host/xhci-pci.c | 81 |
1 files changed, 54 insertions, 27 deletions
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 732837eafabe..ca56af5e01bc 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
| @@ -51,11 +51,12 @@ static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev) | |||
| 51 | return 0; | 51 | return 0; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | /* called during probe() after chip reset completes */ | 54 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); |
| 55 | static int xhci_pci_setup(struct usb_hcd *hcd) | 55 | |
| 56 | static int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) | ||
| 56 | { | 57 | { |
| 57 | struct xhci_hcd *xhci; | 58 | struct xhci_hcd *xhci; |
| 58 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | 59 | struct device *dev = hcd->self.controller; |
| 59 | int retval; | 60 | int retval; |
| 60 | u32 temp; | 61 | u32 temp; |
| 61 | 62 | ||
| @@ -107,6 +108,44 @@ static int xhci_pci_setup(struct usb_hcd *hcd) | |||
| 107 | xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params); | 108 | xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params); |
| 108 | xhci_print_registers(xhci); | 109 | xhci_print_registers(xhci); |
| 109 | 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; | ||
| 140 | error: | ||
| 141 | kfree(xhci); | ||
| 142 | return retval; | ||
| 143 | } | ||
| 144 | |||
| 145 | static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | ||
| 146 | { | ||
| 147 | struct pci_dev *pdev = to_pci_dev(dev); | ||
| 148 | |||
| 110 | /* Look for vendor-specific quirks */ | 149 | /* Look for vendor-specific quirks */ |
| 111 | if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && | 150 | if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && |
| 112 | pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK) { | 151 | pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK) { |
| @@ -146,33 +185,22 @@ static int xhci_pci_setup(struct usb_hcd *hcd) | |||
| 146 | xhci->quirks |= XHCI_RESET_ON_RESUME; | 185 | xhci->quirks |= XHCI_RESET_ON_RESUME; |
| 147 | xhci_dbg(xhci, "QUIRK: Resetting on resume\n"); | 186 | xhci_dbg(xhci, "QUIRK: Resetting on resume\n"); |
| 148 | } | 187 | } |
| 188 | } | ||
| 149 | 189 | ||
| 150 | /* Make sure the HC is halted. */ | 190 | /* called during probe() after chip reset completes */ |
| 151 | retval = xhci_halt(xhci); | 191 | static int xhci_pci_setup(struct usb_hcd *hcd) |
| 152 | if (retval) | 192 | { |
| 153 | goto error; | 193 | struct xhci_hcd *xhci; |
| 194 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
| 195 | int retval; | ||
| 154 | 196 | ||
| 155 | xhci_dbg(xhci, "Resetting HCD\n"); | 197 | retval = xhci_gen_setup(hcd, xhci_pci_quirks); |
| 156 | /* Reset the internal HC memory state and registers. */ | ||
| 157 | retval = xhci_reset(xhci); | ||
| 158 | if (retval) | 198 | if (retval) |
| 159 | goto error; | 199 | return retval; |
| 160 | xhci_dbg(xhci, "Reset complete\n"); | ||
| 161 | |||
| 162 | temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params); | ||
| 163 | if (HCC_64BIT_ADDR(temp)) { | ||
| 164 | xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n"); | ||
| 165 | dma_set_mask(hcd->self.controller, DMA_BIT_MASK(64)); | ||
| 166 | } else { | ||
| 167 | dma_set_mask(hcd->self.controller, DMA_BIT_MASK(32)); | ||
| 168 | } | ||
| 169 | 200 | ||
| 170 | xhci_dbg(xhci, "Calling HCD init\n"); | 201 | xhci = hcd_to_xhci(hcd); |
| 171 | /* Initialize HCD and host controller data structures. */ | 202 | if (!usb_hcd_is_primary_hcd(hcd)) |
| 172 | retval = xhci_init(hcd); | 203 | return 0; |
| 173 | if (retval) | ||
| 174 | goto error; | ||
| 175 | xhci_dbg(xhci, "Called HCD init\n"); | ||
| 176 | 204 | ||
| 177 | pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn); | 205 | pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn); |
| 178 | xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn); | 206 | xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn); |
| @@ -182,7 +210,6 @@ static int xhci_pci_setup(struct usb_hcd *hcd) | |||
| 182 | if (!retval) | 210 | if (!retval) |
| 183 | return retval; | 211 | return retval; |
| 184 | 212 | ||
| 185 | error: | ||
| 186 | kfree(xhci); | 213 | kfree(xhci); |
| 187 | return retval; | 214 | return retval; |
| 188 | } | 215 | } |
