dm: usb: xhci: Use a function to get xhci_ctrl

Rather than getting this directly from struct usb_device, call a function
to obtain it. This will make it possible for driver model to provide it
another way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Marek Vasut <marex@denx.de>
This commit is contained in:
Simon Glass 2015-03-25 12:22:49 -06:00
parent c3980ad3b5
commit 7c1deec0af
3 changed files with 18 additions and 11 deletions

View file

@ -353,7 +353,7 @@ static void giveback_first_trb(struct usb_device *udev, int ep_index,
int start_cycle, int start_cycle,
struct xhci_generic_trb *start_trb) struct xhci_generic_trb *start_trb)
{ {
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
/* /*
* Pass all the TRBs to the hardware at once and make sure this write * Pass all the TRBs to the hardware at once and make sure this write
@ -477,7 +477,7 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected)
*/ */
static void abort_td(struct usb_device *udev, int ep_index) static void abort_td(struct usb_device *udev, int ep_index)
{ {
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring; struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring;
union xhci_trb *event; union xhci_trb *event;
u32 field; u32 field;
@ -554,7 +554,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
int start_cycle; int start_cycle;
u32 field = 0; u32 field = 0;
u32 length_field = 0; u32 length_field = 0;
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
int slot_id = udev->slot_id; int slot_id = udev->slot_id;
int ep_index; int ep_index;
struct xhci_virt_device *virt_dev; struct xhci_virt_device *virt_dev;
@ -748,7 +748,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
u32 length_field; u32 length_field;
u64 buf_64 = 0; u64 buf_64 = 0;
struct xhci_generic_trb *start_trb; struct xhci_generic_trb *start_trb;
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
int slot_id = udev->slot_id; int slot_id = udev->slot_id;
int ep_index; int ep_index;
u32 trb_fields[4]; u32 trb_fields[4];

View file

@ -110,6 +110,11 @@ static struct descriptor {
static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT]; static struct xhci_ctrl xhcic[CONFIG_USB_MAX_CONTROLLER_COUNT];
struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev)
{
return udev->controller;
}
/** /**
* Waits for as per specified amount of time * Waits for as per specified amount of time
* for the "result" to match with "done" * for the "result" to match with "done"
@ -250,7 +255,7 @@ static int xhci_configure_endpoints(struct usb_device *udev, bool ctx_change)
{ {
struct xhci_container_ctx *in_ctx; struct xhci_container_ctx *in_ctx;
struct xhci_virt_device *virt_dev; struct xhci_virt_device *virt_dev;
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
union xhci_trb *event; union xhci_trb *event;
virt_dev = ctrl->devs[udev->slot_id]; virt_dev = ctrl->devs[udev->slot_id];
@ -298,7 +303,7 @@ static int xhci_set_configuration(struct usb_device *udev)
int ep_index; int ep_index;
unsigned int dir; unsigned int dir;
unsigned int ep_type; unsigned int ep_type;
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
int num_of_ep; int num_of_ep;
int ep_flag = 0; int ep_flag = 0;
u64 trb_64 = 0; u64 trb_64 = 0;
@ -382,7 +387,7 @@ static int xhci_set_configuration(struct usb_device *udev)
static int xhci_address_device(struct usb_device *udev) static int xhci_address_device(struct usb_device *udev)
{ {
int ret = 0; int ret = 0;
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
struct xhci_slot_ctx *slot_ctx; struct xhci_slot_ctx *slot_ctx;
struct xhci_input_control_ctx *ctrl_ctx; struct xhci_input_control_ctx *ctrl_ctx;
struct xhci_virt_device *virt_dev; struct xhci_virt_device *virt_dev;
@ -463,8 +468,8 @@ static int xhci_address_device(struct usb_device *udev)
*/ */
int usb_alloc_device(struct usb_device *udev) int usb_alloc_device(struct usb_device *udev)
{ {
struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
union xhci_trb *event; union xhci_trb *event;
struct xhci_ctrl *ctrl = udev->controller;
int ret; int ret;
/* /*
@ -510,7 +515,7 @@ int usb_alloc_device(struct usb_device *udev)
*/ */
int xhci_check_maxpacket(struct usb_device *udev) int xhci_check_maxpacket(struct usb_device *udev)
{ {
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
unsigned int slot_id = udev->slot_id; unsigned int slot_id = udev->slot_id;
int ep_index = 0; /* control endpoint */ int ep_index = 0; /* control endpoint */
struct xhci_container_ctx *in_ctx; struct xhci_container_ctx *in_ctx;
@ -640,7 +645,7 @@ static int xhci_submit_root(struct usb_device *udev, unsigned long pipe,
int len, srclen; int len, srclen;
uint32_t reg; uint32_t reg;
volatile uint32_t *status_reg; volatile uint32_t *status_reg;
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
struct xhci_hcor *hcor = ctrl->hcor; struct xhci_hcor *hcor = ctrl->hcor;
if ((req->requesttype & USB_RT_PORT) && if ((req->requesttype & USB_RT_PORT) &&
@ -904,7 +909,7 @@ int
submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer, submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer,
int length, struct devrequest *setup) int length, struct devrequest *setup)
{ {
struct xhci_ctrl *ctrl = udev->controller; struct xhci_ctrl *ctrl = xhci_get_ctrl(udev);
int ret = 0; int ret = 0;
if (usb_pipetype(pipe) != PIPE_CONTROL) { if (usb_pipetype(pipe) != PIPE_CONTROL) {

View file

@ -1259,4 +1259,6 @@ int xhci_alloc_virt_device(struct usb_device *udev);
int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr, int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr,
struct xhci_hcor *hcor); struct xhci_hcor *hcor);
struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev);
#endif /* HOST_XHCI_H_ */ #endif /* HOST_XHCI_H_ */