ANDROID: GKI: usb: Add helper APIs to return xhci phys addresses

This is a merge of two cherry picks for simplicity and reduction of
churn.

Cherry picked from commit 787b74a487
("usb: xhci: Add helper APIs to return xhci dma addresses")
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>

Cherry picked from commit b8360b2a98
("usb: core: Remove helper APIs returning dcba dma address")
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>

dma address of secondary event ring and transfer ring are required
to pass to remote entity. Remote entity uses these addresses to
program xhci controller registers.

Change to EXPORT_SYMBOL_GPL usage instead.

(cherry picked from commit 787b74a487)
(cherry picked from commit b8360b2a98)
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 154042109
Change-Id: I9fd1e95b00f2185b01374a46d7dff3182c3b3d78
This commit is contained in:
Hemant Kumar 2016-03-22 19:34:20 -07:00 committed by Mark Salyzyn
parent 28b5ef8f1c
commit 52b86b23cc
5 changed files with 105 additions and 1 deletions

View file

@ -2257,6 +2257,30 @@ int usb_hcd_sec_event_ring_cleanup(struct usb_device *udev,
/*-------------------------------------------------------------------------*/
dma_addr_t
usb_hcd_get_sec_event_ring_dma_addr(struct usb_device *udev,
unsigned int intr_num)
{
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
if (!HCD_RH_RUNNING(hcd))
return 0;
return hcd->driver->get_sec_event_ring_dma_addr(hcd, intr_num);
}
dma_addr_t
usb_hcd_get_xfer_ring_dma_addr(struct usb_device *udev,
unsigned int intr_num)
{
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
if (!HCD_RH_RUNNING(hcd))
return 0;
return hcd->driver->get_xfer_ring_dma_addr(hcd, udev, ep);
}
int usb_hcd_get_controller_id(struct usb_device *udev)
{
struct usb_hcd *hcd = bus_to_hcd(udev->bus);

View file

@ -842,6 +842,27 @@ int usb_sec_event_ring_cleanup(struct usb_device *dev,
}
EXPORT_SYMBOL(usb_sec_event_ring_cleanup);
dma_addr_t
usb_get_sec_event_ring_dma_addr(struct usb_device *dev,
unsigned int intr_num)
{
if (dev->state == USB_STATE_NOTATTACHED)
return 0;
return usb_hcd_get_sec_event_ring_dma_addr(dev, intr_num);
}
EXPORT_SYMBOL_GPL(usb_get_sec_event_ring_dma_addr);
dma_addr_t usb_get_xfer_ring_dma_addr(struct usb_device *dev,
struct usb_host_endpoint *ep)
{
if (dev->state == USB_STATE_NOTATTACHED)
return 0;
return usb_hcd_get_xfer_ring_dma_addr(dev, ep);
}
EXPORT_SYMBOL_GPL(usb_get_xfer_ring_dma_addr);
/**
* usb_get_controller_id - returns the host controller id.
* @dev: the device whose host controller id is being queried.

View file

@ -5183,6 +5183,50 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
}
EXPORT_SYMBOL_GPL(xhci_gen_setup);
dma_addr_t xhci_get_sec_event_ring_dma_addr(struct usb_hcd *hcd,
unsigned int intr_num)
{
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
if (intr_num > xhci->max_interrupters) {
xhci_err(xhci, "intr num %d > max intrs %d\n", intr_num,
xhci->max_interrupters);
return 0;
}
if (!(xhci->xhc_state & XHCI_STATE_HALTED) &&
xhci->sec_event_ring && xhci->sec_event_ring[intr_num]
&& xhci->sec_event_ring[intr_num]->first_seg)
return xhci->sec_event_ring[intr_num]->first_seg->dma;
return 0;
}
dma_addr_t xhci_get_xfer_ring_dma_addr(struct usb_hcd *hcd,
struct usb_device *udev, struct usb_host_endpoint *ep)
{
int ret;
unsigned int ep_index;
struct xhci_virt_device *virt_dev;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
if (ret <= 0) {
xhci_err(xhci, "%s: invalid args\n", __func__);
return 0;
}
virt_dev = xhci->devs[udev->slot_id];
ep_index = xhci_get_endpoint_index(&ep->desc);
if (virt_dev->eps[ep_index].ring &&
virt_dev->eps[ep_index].ring->first_seg)
return virt_dev->eps[ep_index].ring->first_seg->dma;
return 0;
}
static int xhci_stop_endpoint(struct usb_hcd *hcd,
struct usb_device *udev, struct usb_host_endpoint *ep)
{
@ -5302,6 +5346,8 @@ static const struct hc_driver xhci_hc_driver = {
.find_raw_port_number = xhci_find_raw_port_number,
.sec_event_ring_setup = xhci_sec_event_ring_setup,
.sec_event_ring_cleanup = xhci_sec_event_ring_cleanup,
.get_sec_event_ring_dma_addr = xhci_get_sec_event_ring_dma_addr,
.get_xfer_ring_dma_addr = xhci_get_xfer_ring_dma_addr,
.stop_endpoint = xhci_stop_endpoint,
};

View file

@ -837,6 +837,11 @@ extern int usb_sec_event_ring_setup(struct usb_device *dev,
unsigned int intr_num);
extern int usb_sec_event_ring_cleanup(struct usb_device *dev,
unsigned int intr_num);
extern dma_addr_t usb_get_sec_event_ring_dma_addr(struct usb_device *dev,
unsigned int intr_num);
extern dma_addr_t usb_get_xfer_ring_dma_addr(struct usb_device *dev,
struct usb_host_endpoint *ep);
extern int usb_get_controller_id(struct usb_device *dev);
extern int usb_stop_endpoint(struct usb_device *dev,

View file

@ -410,7 +410,11 @@ struct hc_driver {
int (*sec_event_ring_setup)(struct usb_hcd *hcd, unsigned int intr_num);
int (*sec_event_ring_cleanup)(struct usb_hcd *hcd,
unsigned int intr_num);
int (*get_core_id)(struct usb_hcd *hcd);
dma_addr_t (*get_sec_event_ring_dma_addr)(struct usb_hcd *hcd,
unsigned int intr_num);
dma_addr_t (*get_xfer_ring_dma_addr)(struct usb_hcd *hcd,
struct usb_device *udev, struct usb_host_endpoint *ep);
int (*get_core_id)(struct usb_hcd *hcd);
int (*stop_endpoint)(struct usb_hcd *hcd, struct usb_device *udev,
struct usb_host_endpoint *ep);
};
@ -455,6 +459,10 @@ extern int usb_hcd_sec_event_ring_setup(struct usb_device *udev,
unsigned int intr_num);
extern int usb_hcd_sec_event_ring_cleanup(struct usb_device *udev,
unsigned int intr_num);
extern dma_addr_t usb_hcd_get_sec_event_ring_dma_addr(struct usb_device *udev,
unsigned int intr_num);
extern dma_addr_t usb_hcd_get_xfer_ring_dma_addr(struct usb_device *udev,
struct usb_host_endpoint *ep);
extern int usb_hcd_get_controller_id(struct usb_device *udev);
extern int usb_hcd_stop_endpoint(struct usb_device *udev,
struct usb_host_endpoint *ep);