Commit d3595d13 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Greg Kroah-Hartman

usb: gadget: ci13xxx: move global variables inside struct ci13xxx

Make global variables that are specific for each UDC instance part of
struct ci13xxx.
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1155a7b8
...@@ -74,9 +74,6 @@ ...@@ -74,9 +74,6 @@
#define DMA_ADDR_INVALID (~(dma_addr_t)0) #define DMA_ADDR_INVALID (~(dma_addr_t)0)
/* ctrl register bank access */
static DEFINE_SPINLOCK(udc_lock);
/* control endpoint description */ /* control endpoint description */
static const struct usb_endpoint_descriptor static const struct usb_endpoint_descriptor
ctrl_endpt_out_desc = { ctrl_endpt_out_desc = {
...@@ -134,14 +131,6 @@ static int ffs_nr(u32 x) ...@@ -134,14 +131,6 @@ static int ffs_nr(u32 x)
/****************************************************************************** /******************************************************************************
* HW block * HW block
*****************************************************************************/ *****************************************************************************/
/* register bank descriptor */
static struct {
unsigned lpm; /* is LPM? */
void __iomem *abs; /* bus map offset */
void __iomem *cap; /* bus map offset + CAP offset */
void __iomem *op; /* bus map offset + OP offset */
size_t size; /* bank size */
} hw_bank;
/* MSM specific */ /* MSM specific */
#define ABS_AHBBURST (0x0090UL) #define ABS_AHBBURST (0x0090UL)
...@@ -150,7 +139,7 @@ static struct { ...@@ -150,7 +139,7 @@ static struct {
#define CAP_CAPLENGTH (0x000UL) #define CAP_CAPLENGTH (0x000UL)
#define CAP_HCCPARAMS (0x008UL) #define CAP_HCCPARAMS (0x008UL)
#define CAP_DCCPARAMS (0x024UL) #define CAP_DCCPARAMS (0x024UL)
#define ABS_TESTMODE (hw_bank.lpm ? 0x0FCUL : 0x138UL) #define ABS_TESTMODE (udc->hw_bank.lpm ? 0x0FCUL : 0x138UL)
/* offset to CAPLENTGH (addr + data) */ /* offset to CAPLENTGH (addr + data) */
#define OP_USBCMD (0x000UL) #define OP_USBCMD (0x000UL)
#define OP_USBSTS (0x004UL) #define OP_USBSTS (0x004UL)
...@@ -159,17 +148,14 @@ static struct { ...@@ -159,17 +148,14 @@ static struct {
#define OP_ENDPTLISTADDR (0x018UL) #define OP_ENDPTLISTADDR (0x018UL)
#define OP_PORTSC (0x044UL) #define OP_PORTSC (0x044UL)
#define OP_DEVLC (0x084UL) #define OP_DEVLC (0x084UL)
#define OP_USBMODE (hw_bank.lpm ? 0x0C8UL : 0x068UL) #define OP_USBMODE (udc->hw_bank.lpm ? 0x0C8UL : 0x068UL)
#define OP_ENDPTSETUPSTAT (hw_bank.lpm ? 0x0D8UL : 0x06CUL) #define OP_ENDPTSETUPSTAT (udc->hw_bank.lpm ? 0x0D8UL : 0x06CUL)
#define OP_ENDPTPRIME (hw_bank.lpm ? 0x0DCUL : 0x070UL) #define OP_ENDPTPRIME (udc->hw_bank.lpm ? 0x0DCUL : 0x070UL)
#define OP_ENDPTFLUSH (hw_bank.lpm ? 0x0E0UL : 0x074UL) #define OP_ENDPTFLUSH (udc->hw_bank.lpm ? 0x0E0UL : 0x074UL)
#define OP_ENDPTSTAT (hw_bank.lpm ? 0x0E4UL : 0x078UL) #define OP_ENDPTSTAT (udc->hw_bank.lpm ? 0x0E4UL : 0x078UL)
#define OP_ENDPTCOMPLETE (hw_bank.lpm ? 0x0E8UL : 0x07CUL) #define OP_ENDPTCOMPLETE (udc->hw_bank.lpm ? 0x0E8UL : 0x07CUL)
#define OP_ENDPTCTRL (hw_bank.lpm ? 0x0ECUL : 0x080UL) #define OP_ENDPTCTRL (udc->hw_bank.lpm ? 0x0ECUL : 0x080UL)
#define OP_LAST (hw_bank.lpm ? 0x12CUL : 0x0C0UL) #define OP_LAST (udc->hw_bank.lpm ? 0x12CUL : 0x0C0UL)
/* maximum number of enpoints: valid only after hw_device_reset() */
static unsigned hw_ep_max;
/** /**
* hw_ep_bit: calculates the bit number * hw_ep_bit: calculates the bit number
...@@ -183,11 +169,11 @@ static inline int hw_ep_bit(int num, int dir) ...@@ -183,11 +169,11 @@ static inline int hw_ep_bit(int num, int dir)
return num + (dir ? 16 : 0); return num + (dir ? 16 : 0);
} }
static int ep_to_bit(int n) static int ep_to_bit(struct ci13xxx *udc, int n)
{ {
int fill = 16 - hw_ep_max / 2; int fill = 16 - udc->hw_ep_max / 2;
if (n >= hw_ep_max / 2) if (n >= udc->hw_ep_max / 2)
n += fill; n += fill;
return n; return n;
...@@ -252,29 +238,30 @@ static u32 hw_test_and_write(void __iomem *base, u32 addr, u32 mask, u32 data) ...@@ -252,29 +238,30 @@ static u32 hw_test_and_write(void __iomem *base, u32 addr, u32 mask, u32 data)
return (reg & mask) >> ffs_nr(mask); return (reg & mask) >> ffs_nr(mask);
} }
static int hw_device_init(void __iomem *base, uintptr_t cap_offset) static int hw_device_init(struct ci13xxx *udc, void __iomem *base,
uintptr_t cap_offset)
{ {
u32 reg; u32 reg;
/* bank is a module variable */ /* bank is a module variable */
hw_bank.abs = base; udc->hw_bank.abs = base;
hw_bank.cap = hw_bank.abs; udc->hw_bank.cap = udc->hw_bank.abs;
hw_bank.cap += cap_offset; udc->hw_bank.cap += cap_offset;
hw_bank.op = hw_bank.cap + ioread8(hw_bank.cap); udc->hw_bank.op = udc->hw_bank.cap + ioread8(udc->hw_bank.cap);
reg = hw_read(hw_bank.cap, CAP_HCCPARAMS, HCCPARAMS_LEN) >> reg = hw_read(udc->hw_bank.cap, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
ffs_nr(HCCPARAMS_LEN); ffs_nr(HCCPARAMS_LEN);
hw_bank.lpm = reg; udc->hw_bank.lpm = reg;
hw_bank.size = hw_bank.op - hw_bank.abs; udc->hw_bank.size = udc->hw_bank.op - udc->hw_bank.abs;
hw_bank.size += OP_LAST; udc->hw_bank.size += OP_LAST;
hw_bank.size /= sizeof(u32); udc->hw_bank.size /= sizeof(u32);
reg = hw_read(hw_bank.cap, CAP_DCCPARAMS, DCCPARAMS_DEN) >> reg = hw_read(udc->hw_bank.cap, CAP_DCCPARAMS, DCCPARAMS_DEN) >>
ffs_nr(DCCPARAMS_DEN); ffs_nr(DCCPARAMS_DEN);
hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */ udc->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
if (hw_ep_max == 0 || hw_ep_max > ENDPT_MAX) if (udc->hw_ep_max == 0 || udc->hw_ep_max > ENDPT_MAX)
return -ENODEV; return -ENODEV;
/* setup lock mode ? */ /* setup lock mode ? */
...@@ -294,11 +281,11 @@ static int hw_device_init(void __iomem *base, uintptr_t cap_offset) ...@@ -294,11 +281,11 @@ static int hw_device_init(void __iomem *base, uintptr_t cap_offset)
static int hw_device_reset(struct ci13xxx *udc) static int hw_device_reset(struct ci13xxx *udc)
{ {
/* should flush & stop before reset */ /* should flush & stop before reset */
hw_write(hw_bank.op, OP_ENDPTFLUSH, ~0, ~0); hw_write(udc->hw_bank.op, OP_ENDPTFLUSH, ~0, ~0);
hw_write(hw_bank.op, OP_USBCMD, USBCMD_RS, 0); hw_write(udc->hw_bank.op, OP_USBCMD, USBCMD_RS, 0);
hw_write(hw_bank.op, OP_USBCMD, USBCMD_RST, USBCMD_RST); hw_write(udc->hw_bank.op, OP_USBCMD, USBCMD_RST, USBCMD_RST);
while (hw_read(hw_bank.op, OP_USBCMD, USBCMD_RST)) while (hw_read(udc->hw_bank.op, OP_USBCMD, USBCMD_RST))
udelay(10); /* not RTOS friendly */ udelay(10); /* not RTOS friendly */
...@@ -307,17 +294,19 @@ static int hw_device_reset(struct ci13xxx *udc) ...@@ -307,17 +294,19 @@ static int hw_device_reset(struct ci13xxx *udc)
CI13XXX_CONTROLLER_RESET_EVENT); CI13XXX_CONTROLLER_RESET_EVENT);
if (udc->udc_driver->flags & CI13XXX_DISABLE_STREAMING) if (udc->udc_driver->flags & CI13XXX_DISABLE_STREAMING)
hw_write(hw_bank.op, OP_USBMODE, USBMODE_SDIS, USBMODE_SDIS); hw_write(udc->hw_bank.op, OP_USBMODE, USBMODE_SDIS,
USBMODE_SDIS);
/* USBMODE should be configured step by step */ /* USBMODE should be configured step by step */
hw_write(hw_bank.op, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE); hw_write(udc->hw_bank.op, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
hw_write(hw_bank.op, OP_USBMODE, USBMODE_CM, USBMODE_CM_DEVICE); hw_write(udc->hw_bank.op, OP_USBMODE, USBMODE_CM, USBMODE_CM_DEVICE);
/* HW >= 2.3 */ /* HW >= 2.3 */
hw_write(hw_bank.op, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM); hw_write(udc->hw_bank.op, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM);
if (hw_read(hw_bank.op, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DEVICE) { if (hw_read(udc->hw_bank.op, OP_USBMODE, USBMODE_CM) !=
USBMODE_CM_DEVICE) {
pr_err("cannot enter in device mode"); pr_err("cannot enter in device mode");
pr_err("lpm = %i", hw_bank.lpm); pr_err("lpm = %i", udc->hw_bank.lpm);
return -ENODEV; return -ENODEV;
} }
...@@ -331,17 +320,17 @@ static int hw_device_reset(struct ci13xxx *udc) ...@@ -331,17 +320,17 @@ static int hw_device_reset(struct ci13xxx *udc)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_device_state(u32 dma) static int hw_device_state(struct ci13xxx *udc, u32 dma)
{ {
if (dma) { if (dma) {
hw_write(hw_bank.op, OP_ENDPTLISTADDR, ~0, dma); hw_write(udc->hw_bank.op, OP_ENDPTLISTADDR, ~0, dma);
/* interrupt, error, port change, reset, sleep/suspend */ /* interrupt, error, port change, reset, sleep/suspend */
hw_write(hw_bank.op, OP_USBINTR, ~0, hw_write(udc->hw_bank.op, OP_USBINTR, ~0,
USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI); USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
hw_write(hw_bank.op, OP_USBCMD, USBCMD_RS, USBCMD_RS); hw_write(udc->hw_bank.op, OP_USBCMD, USBCMD_RS, USBCMD_RS);
} else { } else {
hw_write(hw_bank.op, OP_USBCMD, USBCMD_RS, 0); hw_write(udc->hw_bank.op, OP_USBCMD, USBCMD_RS, 0);
hw_write(hw_bank.op, OP_USBINTR, ~0, 0); hw_write(udc->hw_bank.op, OP_USBINTR, ~0, 0);
} }
return 0; return 0;
} }
...@@ -353,16 +342,16 @@ static int hw_device_state(u32 dma) ...@@ -353,16 +342,16 @@ static int hw_device_state(u32 dma)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_ep_flush(int num, int dir) static int hw_ep_flush(struct ci13xxx *udc, int num, int dir)
{ {
int n = hw_ep_bit(num, dir); int n = hw_ep_bit(num, dir);
do { do {
/* flush any pending transfer */ /* flush any pending transfer */
hw_write(hw_bank.op, OP_ENDPTFLUSH, BIT(n), BIT(n)); hw_write(udc->hw_bank.op, OP_ENDPTFLUSH, BIT(n), BIT(n));
while (hw_read(hw_bank.op, OP_ENDPTFLUSH, BIT(n))) while (hw_read(udc->hw_bank.op, OP_ENDPTFLUSH, BIT(n)))
cpu_relax(); cpu_relax();
} while (hw_read(hw_bank.op, OP_ENDPTSTAT, BIT(n))); } while (hw_read(udc->hw_bank.op, OP_ENDPTSTAT, BIT(n)));
return 0; return 0;
} }
...@@ -374,10 +363,10 @@ static int hw_ep_flush(int num, int dir) ...@@ -374,10 +363,10 @@ static int hw_ep_flush(int num, int dir)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_ep_disable(int num, int dir) static int hw_ep_disable(struct ci13xxx *udc, int num, int dir)
{ {
hw_ep_flush(num, dir); hw_ep_flush(udc, num, dir);
hw_write(hw_bank.op, OP_ENDPTCTRL + num * sizeof(u32), hw_write(udc->hw_bank.op, OP_ENDPTCTRL + num * sizeof(u32),
dir ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0); dir ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0);
return 0; return 0;
} }
...@@ -390,7 +379,7 @@ static int hw_ep_disable(int num, int dir) ...@@ -390,7 +379,7 @@ static int hw_ep_disable(int num, int dir)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_ep_enable(int num, int dir, int type) static int hw_ep_enable(struct ci13xxx *udc, int num, int dir, int type)
{ {
u32 mask, data; u32 mask, data;
...@@ -413,7 +402,7 @@ static int hw_ep_enable(int num, int dir, int type) ...@@ -413,7 +402,7 @@ static int hw_ep_enable(int num, int dir, int type)
mask |= ENDPTCTRL_RXE; /* enable */ mask |= ENDPTCTRL_RXE; /* enable */
data |= ENDPTCTRL_RXE; data |= ENDPTCTRL_RXE;
} }
hw_write(hw_bank.op, OP_ENDPTCTRL + num * sizeof(u32), mask, data); hw_write(udc->hw_bank.op, OP_ENDPTCTRL + num * sizeof(u32), mask, data);
return 0; return 0;
} }
...@@ -424,11 +413,12 @@ static int hw_ep_enable(int num, int dir, int type) ...@@ -424,11 +413,12 @@ static int hw_ep_enable(int num, int dir, int type)
* *
* This function returns 1 if endpoint halted * This function returns 1 if endpoint halted
*/ */
static int hw_ep_get_halt(int num, int dir) static int hw_ep_get_halt(struct ci13xxx *udc, int num, int dir)
{ {
u32 mask = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS; u32 mask = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
return !!hw_read(hw_bank.op, OP_ENDPTCTRL + num * sizeof(u32), mask); return !!hw_read(udc->hw_bank.op, OP_ENDPTCTRL + num * sizeof(u32),
mask);
} }
/** /**
...@@ -438,10 +428,10 @@ static int hw_ep_get_halt(int num, int dir) ...@@ -438,10 +428,10 @@ static int hw_ep_get_halt(int num, int dir)
* *
* This function returns setup status * This function returns setup status
*/ */
static int hw_test_and_clear_setup_status(int n) static int hw_test_and_clear_setup_status(struct ci13xxx *udc, int n)
{ {
n = ep_to_bit(n); n = ep_to_bit(udc, n);
return hw_test_and_clear(hw_bank.op, OP_ENDPTSETUPSTAT, BIT(n)); return hw_test_and_clear(udc->hw_bank.op, OP_ENDPTSETUPSTAT, BIT(n));
} }
/** /**
...@@ -452,20 +442,20 @@ static int hw_test_and_clear_setup_status(int n) ...@@ -452,20 +442,20 @@ static int hw_test_and_clear_setup_status(int n)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_ep_prime(int num, int dir, int is_ctrl) static int hw_ep_prime(struct ci13xxx *udc, int num, int dir, int is_ctrl)
{ {
int n = hw_ep_bit(num, dir); int n = hw_ep_bit(num, dir);
if (is_ctrl && dir == RX && if (is_ctrl && dir == RX &&
hw_read(hw_bank.op, OP_ENDPTSETUPSTAT, BIT(num))) hw_read(udc->hw_bank.op, OP_ENDPTSETUPSTAT, BIT(num)))
return -EAGAIN; return -EAGAIN;
hw_write(hw_bank.op, OP_ENDPTPRIME, BIT(n), BIT(n)); hw_write(udc->hw_bank.op, OP_ENDPTPRIME, BIT(n), BIT(n));
while (hw_read(hw_bank.op, OP_ENDPTPRIME, BIT(n))) while (hw_read(udc->hw_bank.op, OP_ENDPTPRIME, BIT(n)))
cpu_relax(); cpu_relax();
if (is_ctrl && dir == RX && if (is_ctrl && dir == RX &&
hw_read(hw_bank.op, OP_ENDPTSETUPSTAT, BIT(num))) hw_read(udc->hw_bank.op, OP_ENDPTSETUPSTAT, BIT(num)))
return -EAGAIN; return -EAGAIN;
/* status shoult be tested according with manual but it doesn't work */ /* status shoult be tested according with manual but it doesn't work */
...@@ -481,7 +471,7 @@ static int hw_ep_prime(int num, int dir, int is_ctrl) ...@@ -481,7 +471,7 @@ static int hw_ep_prime(int num, int dir, int is_ctrl)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_ep_set_halt(int num, int dir, int value) static int hw_ep_set_halt(struct ci13xxx *udc, int num, int dir, int value)
{ {
if (value != 0 && value != 1) if (value != 0 && value != 1)
return -EINVAL; return -EINVAL;
...@@ -492,10 +482,10 @@ static int hw_ep_set_halt(int num, int dir, int value) ...@@ -492,10 +482,10 @@ static int hw_ep_set_halt(int num, int dir, int value)
u32 mask_xr = dir ? ENDPTCTRL_TXR : ENDPTCTRL_RXR; u32 mask_xr = dir ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
/* data toggle - reserved for EP0 but it's in ESS */ /* data toggle - reserved for EP0 but it's in ESS */
hw_write(hw_bank.op, addr, mask_xs|mask_xr, hw_write(udc->hw_bank.op, addr, mask_xs|mask_xr,
value ? mask_xs : mask_xr); value ? mask_xs : mask_xr);
} while (value != hw_ep_get_halt(num, dir)); } while (value != hw_ep_get_halt(udc, num, dir));
return 0; return 0;
} }
...@@ -507,13 +497,14 @@ static int hw_ep_set_halt(int num, int dir, int value) ...@@ -507,13 +497,14 @@ static int hw_ep_set_halt(int num, int dir, int value)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_intr_clear(int n) static int hw_intr_clear(struct ci13xxx *udc, int n)
{ {
if (n >= REG_BITS) if (n >= REG_BITS)
return -EINVAL; return -EINVAL;
hw_write(hw_bank.op, OP_USBINTR, BIT(n), 0); hw_write(udc->hw_bank.op, OP_USBINTR, BIT(n), 0);
hw_write(hw_bank.op, OP_USBSTS, BIT(n), BIT(n)); hw_write(udc->hw_bank.op, OP_USBSTS, BIT(n), BIT(n));
return 0; return 0;
} }
...@@ -524,15 +515,16 @@ static int hw_intr_clear(int n) ...@@ -524,15 +515,16 @@ static int hw_intr_clear(int n)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_intr_force(int n) static int hw_intr_force(struct ci13xxx *udc, int n)
{ {
if (n >= REG_BITS) if (n >= REG_BITS)
return -EINVAL; return -EINVAL;
hw_write(hw_bank.cap, ABS_TESTMODE, TESTMODE_FORCE, TESTMODE_FORCE); hw_write(udc->hw_bank.cap, ABS_TESTMODE, TESTMODE_FORCE,
hw_write(hw_bank.op, OP_USBINTR, BIT(n), BIT(n)); TESTMODE_FORCE);
hw_write(hw_bank.op, OP_USBSTS, BIT(n), BIT(n)); hw_write(udc->hw_bank.op, OP_USBINTR, BIT(n), BIT(n));
hw_write(hw_bank.cap, ABS_TESTMODE, TESTMODE_FORCE, 0); hw_write(udc->hw_bank.op, OP_USBSTS, BIT(n), BIT(n));
hw_write(udc->hw_bank.cap, ABS_TESTMODE, TESTMODE_FORCE, 0);
return 0; return 0;
} }
...@@ -541,10 +533,11 @@ static int hw_intr_force(int n) ...@@ -541,10 +533,11 @@ static int hw_intr_force(int n)
* *
* This function returns true if high speed port * This function returns true if high speed port
*/ */
static int hw_port_is_high_speed(void) static int hw_port_is_high_speed(struct ci13xxx *udc)
{ {
return hw_bank.lpm ? hw_read(hw_bank.op, OP_DEVLC, DEVLC_PSPD) : return udc->hw_bank.lpm
hw_read(hw_bank.op, OP_PORTSC, PORTSC_HSP); ? hw_read(udc->hw_bank.op, OP_DEVLC, DEVLC_PSPD)
: hw_read(udc->hw_bank.op, OP_PORTSC, PORTSC_HSP);
} }
/** /**
...@@ -552,9 +545,10 @@ static int hw_port_is_high_speed(void) ...@@ -552,9 +545,10 @@ static int hw_port_is_high_speed(void)
* *
* This function returns port test mode value * This function returns port test mode value
*/ */
static u8 hw_port_test_get(void) static u8 hw_port_test_get(struct ci13xxx *udc)
{ {
return hw_read(hw_bank.op, OP_PORTSC, PORTSC_PTC) >> ffs_nr(PORTSC_PTC); return hw_read(udc->hw_bank.op, OP_PORTSC, PORTSC_PTC) >>
ffs_nr(PORTSC_PTC);
} }
/** /**
...@@ -563,14 +557,15 @@ static u8 hw_port_test_get(void) ...@@ -563,14 +557,15 @@ static u8 hw_port_test_get(void)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_port_test_set(u8 mode) static int hw_port_test_set(struct ci13xxx *udc, u8 mode)
{ {
const u8 TEST_MODE_MAX = 7; const u8 TEST_MODE_MAX = 7;
if (mode > TEST_MODE_MAX) if (mode > TEST_MODE_MAX)
return -EINVAL; return -EINVAL;
hw_write(hw_bank.op, OP_PORTSC, PORTSC_PTC, mode << ffs_nr(PORTSC_PTC)); hw_write(udc->hw_bank.op, OP_PORTSC, PORTSC_PTC,
mode << ffs_nr(PORTSC_PTC));
return 0; return 0;
} }
...@@ -579,9 +574,9 @@ static int hw_port_test_set(u8 mode) ...@@ -579,9 +574,9 @@ static int hw_port_test_set(u8 mode)
* *
* This function returns register data * This function returns register data
*/ */
static u32 hw_read_intr_enable(void) static u32 hw_read_intr_enable(struct ci13xxx *udc)
{ {
return hw_read(hw_bank.op, OP_USBINTR, ~0); return hw_read(udc->hw_bank.op, OP_USBINTR, ~0);
} }
/** /**
...@@ -589,9 +584,9 @@ static u32 hw_read_intr_enable(void) ...@@ -589,9 +584,9 @@ static u32 hw_read_intr_enable(void)
* *
* This function returns register data * This function returns register data
*/ */
static u32 hw_read_intr_status(void) static u32 hw_read_intr_status(struct ci13xxx *udc)
{ {
return hw_read(hw_bank.op, OP_USBSTS, ~0); return hw_read(udc->hw_bank.op, OP_USBSTS, ~0);
} }
/** /**
...@@ -601,15 +596,15 @@ static u32 hw_read_intr_status(void) ...@@ -601,15 +596,15 @@ static u32 hw_read_intr_status(void)
* *
* This function returns number of registers read * This function returns number of registers read
*/ */
static size_t hw_register_read(u32 *buf, size_t size) static size_t hw_register_read(struct ci13xxx *udc, u32 *buf, size_t size)
{ {
unsigned i; unsigned i;
if (size > hw_bank.size) if (size > udc->hw_bank.size)
size = hw_bank.size; size = udc->hw_bank.size;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
buf[i] = hw_read(hw_bank.cap, i * sizeof(u32), ~0); buf[i] = hw_read(udc->hw_bank.cap, i * sizeof(u32), ~0);
return size; return size;
} }
...@@ -621,18 +616,18 @@ static size_t hw_register_read(u32 *buf, size_t size) ...@@ -621,18 +616,18 @@ static size_t hw_register_read(u32 *buf, size_t size)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_register_write(u16 addr, u32 data) static int hw_register_write(struct ci13xxx *udc, u16 addr, u32 data)
{ {
/* align */ /* align */
addr /= sizeof(u32); addr /= sizeof(u32);
if (addr >= hw_bank.size) if (addr >= udc->hw_bank.size)
return -EINVAL; return -EINVAL;
/* align */ /* align */
addr *= sizeof(u32); addr *= sizeof(u32);
hw_write(hw_bank.cap, addr, ~0, data); hw_write(udc->hw_bank.cap, addr, ~0, data);
return 0; return 0;
} }
...@@ -643,10 +638,10 @@ static int hw_register_write(u16 addr, u32 data) ...@@ -643,10 +638,10 @@ static int hw_register_write(u16 addr, u32 data)
* *
* This function returns complete status * This function returns complete status
*/ */
static int hw_test_and_clear_complete(int n) static int hw_test_and_clear_complete(struct ci13xxx *udc, int n)
{ {
n = ep_to_bit(n); n = ep_to_bit(udc, n);
return hw_test_and_clear(hw_bank.op, OP_ENDPTCOMPLETE, BIT(n)); return hw_test_and_clear(udc->hw_bank.op, OP_ENDPTCOMPLETE, BIT(n));
} }
/** /**
...@@ -655,11 +650,11 @@ static int hw_test_and_clear_complete(int n) ...@@ -655,11 +650,11 @@ static int hw_test_and_clear_complete(int n)
* *
* This function returns active interrutps * This function returns active interrutps
*/ */
static u32 hw_test_and_clear_intr_active(void) static u32 hw_test_and_clear_intr_active(struct ci13xxx *udc)
{ {
u32 reg = hw_read_intr_status() & hw_read_intr_enable(); u32 reg = hw_read_intr_status(udc) & hw_read_intr_enable(udc);
hw_write(hw_bank.op, OP_USBSTS, ~0, reg); hw_write(udc->hw_bank.op, OP_USBSTS, ~0, reg);
return reg; return reg;
} }
...@@ -669,9 +664,9 @@ static u32 hw_test_and_clear_intr_active(void) ...@@ -669,9 +664,9 @@ static u32 hw_test_and_clear_intr_active(void)
* *
* This function returns guard value * This function returns guard value
*/ */
static int hw_test_and_clear_setup_guard(void) static int hw_test_and_clear_setup_guard(struct ci13xxx *udc)
{ {
return hw_test_and_write(hw_bank.op, OP_USBCMD, USBCMD_SUTW, 0); return hw_test_and_write(udc->hw_bank.op, OP_USBCMD, USBCMD_SUTW, 0);
} }
/** /**
...@@ -680,9 +675,9 @@ static int hw_test_and_clear_setup_guard(void) ...@@ -680,9 +675,9 @@ static int hw_test_and_clear_setup_guard(void)
* *
* This function returns guard value * This function returns guard value
*/ */
static int hw_test_and_set_setup_guard(void) static int hw_test_and_set_setup_guard(struct ci13xxx *udc)
{ {
return hw_test_and_write(hw_bank.op, OP_USBCMD, USBCMD_SUTW, return hw_test_and_write(udc->hw_bank.op, OP_USBCMD, USBCMD_SUTW,
USBCMD_SUTW); USBCMD_SUTW);
} }
...@@ -692,10 +687,10 @@ static int hw_test_and_set_setup_guard(void) ...@@ -692,10 +687,10 @@ static int hw_test_and_set_setup_guard(void)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_usb_set_address(u8 value) static int hw_usb_set_address(struct ci13xxx *udc, u8 value)
{ {
/* advance */ /* advance */
hw_write(hw_bank.op, OP_DEVICEADDR, hw_write(udc->hw_bank.op, OP_DEVICEADDR,
DEVICEADDR_USBADR | DEVICEADDR_USBADRA, DEVICEADDR_USBADR | DEVICEADDR_USBADRA,
value << ffs_nr(DEVICEADDR_USBADR) | DEVICEADDR_USBADRA); value << ffs_nr(DEVICEADDR_USBADR) | DEVICEADDR_USBADRA);
return 0; return 0;
...@@ -707,21 +702,21 @@ static int hw_usb_set_address(u8 value) ...@@ -707,21 +702,21 @@ static int hw_usb_set_address(u8 value)
* *
* This function returns an error code * This function returns an error code
*/ */
static int hw_usb_reset(void) static int hw_usb_reset(struct ci13xxx *udc)
{ {
hw_usb_set_address(0); hw_usb_set_address(udc, 0);
/* ESS flushes only at end?!? */ /* ESS flushes only at end?!? */
hw_write(hw_bank.op, OP_ENDPTFLUSH, ~0, ~0); hw_write(udc->hw_bank.op, OP_ENDPTFLUSH, ~0, ~0);
/* clear setup token semaphores */ /* clear setup token semaphores */
hw_write(hw_bank.op, OP_ENDPTSETUPSTAT, 0, 0); hw_write(udc->hw_bank.op, OP_ENDPTSETUPSTAT, 0, 0);
/* clear complete status */ /* clear complete status */
hw_write(hw_bank.op, OP_ENDPTCOMPLETE, 0, 0); hw_write(udc->hw_bank.op, OP_ENDPTCOMPLETE, 0, 0);
/* wait until all bits cleared */ /* wait until all bits cleared */
while (hw_read(hw_bank.op, OP_ENDPTPRIME, ~0)) while (hw_read(udc->hw_bank.op, OP_ENDPTPRIME, ~0))
udelay(10); /* not RTOS friendly */ udelay(10); /* not RTOS friendly */
/* reset all endpoints ? */ /* reset all endpoints ? */
...@@ -1023,12 +1018,12 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr, ...@@ -1023,12 +1018,12 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
return 0; return 0;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
n += scnprintf(buf + n, PAGE_SIZE - n, n += scnprintf(buf + n, PAGE_SIZE - n,
"status = %08x\n", hw_read_intr_status()); "status = %08x\n", hw_read_intr_status(udc));
n += scnprintf(buf + n, PAGE_SIZE - n, n += scnprintf(buf + n, PAGE_SIZE - n,
"enable = %08x\n", hw_read_intr_enable()); "enable = %08x\n", hw_read_intr_enable(udc));
n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n", n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n",
isr_statistics.test); isr_statistics.test);
...@@ -1072,7 +1067,7 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr, ...@@ -1072,7 +1067,7 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
} }
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return n; return n;
} }
...@@ -1101,17 +1096,17 @@ static ssize_t store_inters(struct device *dev, struct device_attribute *attr, ...@@ -1101,17 +1096,17 @@ static ssize_t store_inters(struct device *dev, struct device_attribute *attr,
goto done; goto done;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (en) { if (en) {
if (hw_intr_force(bit)) if (hw_intr_force(udc, bit))
dev_err(dev, "invalid bit number\n"); dev_err(dev, "invalid bit number\n");
else else
isr_statistics.test++; isr_statistics.test++;
} else { } else {
if (hw_intr_clear(bit)) if (hw_intr_clear(udc, bit))
dev_err(dev, "invalid bit number\n"); dev_err(dev, "invalid bit number\n");
} }
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
done: done:
return count; return count;
...@@ -1136,9 +1131,9 @@ static ssize_t show_port_test(struct device *dev, ...@@ -1136,9 +1131,9 @@ static ssize_t show_port_test(struct device *dev,
return 0; return 0;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
mode = hw_port_test_get(); mode = hw_port_test_get(udc);
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return scnprintf(buf, PAGE_SIZE, "mode = %u\n", mode); return scnprintf(buf, PAGE_SIZE, "mode = %u\n", mode);
} }
...@@ -1167,10 +1162,10 @@ static ssize_t store_port_test(struct device *dev, ...@@ -1167,10 +1162,10 @@ static ssize_t store_port_test(struct device *dev,
goto done; goto done;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (hw_port_test_set(mode)) if (hw_port_test_set(udc, mode))
dev_err(dev, "invalid mode\n"); dev_err(dev, "invalid mode\n");
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
done: done:
return count; return count;
...@@ -1196,10 +1191,11 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr, ...@@ -1196,10 +1191,11 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
return 0; return 0;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
for (i = 0; i < hw_ep_max/2; i++) { for (i = 0; i < udc->hw_ep_max/2; i++) {
struct ci13xxx_ep *mEpRx = &udc->ci13xxx_ep[i]; struct ci13xxx_ep *mEpRx = &udc->ci13xxx_ep[i];
struct ci13xxx_ep *mEpTx = &udc->ci13xxx_ep[i + hw_ep_max/2]; struct ci13xxx_ep *mEpTx =
&udc->ci13xxx_ep[i + udc->hw_ep_max/2];
n += scnprintf(buf + n, PAGE_SIZE - n, n += scnprintf(buf + n, PAGE_SIZE - n,
"EP=%02i: RX=%08X TX=%08X\n", "EP=%02i: RX=%08X TX=%08X\n",
i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma); i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma);
...@@ -1210,7 +1206,7 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr, ...@@ -1210,7 +1206,7 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
*((u32 *)mEpTx->qh.ptr + j)); *((u32 *)mEpTx->qh.ptr + j));
} }
} }
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return n; return n;
} }
...@@ -1242,9 +1238,9 @@ static ssize_t show_registers(struct device *dev, ...@@ -1242,9 +1238,9 @@ static ssize_t show_registers(struct device *dev,
return 0; return 0;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
k = hw_register_read(dump, DUMP_ENTRIES); k = hw_register_read(udc, dump, DUMP_ENTRIES);
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
n += scnprintf(buf + n, PAGE_SIZE - n, n += scnprintf(buf + n, PAGE_SIZE - n,
...@@ -1279,10 +1275,10 @@ static ssize_t store_registers(struct device *dev, ...@@ -1279,10 +1275,10 @@ static ssize_t store_registers(struct device *dev,
goto done; goto done;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (hw_register_write(addr, data)) if (hw_register_write(udc, addr, data))
dev_err(dev, "invalid address range\n"); dev_err(dev, "invalid address range\n");
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
done: done:
return count; return count;
...@@ -1310,23 +1306,23 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr, ...@@ -1310,23 +1306,23 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
return 0; return 0;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
for (i = 0; i < hw_ep_max; i++) for (i = 0; i < udc->hw_ep_max; i++)
list_for_each(ptr, &udc->ci13xxx_ep[i].qh.queue) list_for_each(ptr, &udc->ci13xxx_ep[i].qh.queue)
{ {
req = list_entry(ptr, struct ci13xxx_req, queue); req = list_entry(ptr, struct ci13xxx_req, queue);
n += scnprintf(buf + n, PAGE_SIZE - n, n += scnprintf(buf + n, PAGE_SIZE - n,
"EP=%02i: TD=%08X %s\n", "EP=%02i: TD=%08X %s\n",
i % hw_ep_max/2, (u32)req->dma, i % udc->hw_ep_max/2, (u32)req->dma,
((i < hw_ep_max/2) ? "RX" : "TX")); ((i < udc->hw_ep_max/2) ? "RX" : "TX"));
for (j = 0; j < qSize; j++) for (j = 0; j < qSize; j++)
n += scnprintf(buf + n, PAGE_SIZE - n, n += scnprintf(buf + n, PAGE_SIZE - n,
" %04X: %08X\n", j, " %04X: %08X\n", j,
*((u32 *)req->ptr + j)); *((u32 *)req->ptr + j));
} }
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return n; return n;
} }
...@@ -1430,6 +1426,7 @@ static inline u8 _usb_addr(struct ci13xxx_ep *ep) ...@@ -1430,6 +1426,7 @@ static inline u8 _usb_addr(struct ci13xxx_ep *ep)
*/ */
static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
{ {
struct ci13xxx *udc = mEp->udc;
unsigned i; unsigned i;
int ret = 0; int ret = 0;
unsigned length = mReq->req.length; unsigned length = mReq->req.length;
...@@ -1503,14 +1500,15 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) ...@@ -1503,14 +1500,15 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
else else
mReqPrev->ptr->next = mReq->dma & TD_ADDR_MASK; mReqPrev->ptr->next = mReq->dma & TD_ADDR_MASK;
wmb(); wmb();
if (hw_read(hw_bank.op, OP_ENDPTPRIME, BIT(n))) if (hw_read(udc->hw_bank.op, OP_ENDPTPRIME, BIT(n)))
goto done; goto done;
do { do {
hw_write(hw_bank.op, OP_USBCMD, USBCMD_ATDTW, hw_write(udc->hw_bank.op, OP_USBCMD, USBCMD_ATDTW,
USBCMD_ATDTW); USBCMD_ATDTW);
tmp_stat = hw_read(hw_bank.op, OP_ENDPTSTAT, BIT(n)); tmp_stat = hw_read(udc->hw_bank.op, OP_ENDPTSTAT,
} while (!hw_read(hw_bank.op, OP_USBCMD, USBCMD_ATDTW)); BIT(n));
hw_write(hw_bank.op, OP_USBCMD, USBCMD_ATDTW, 0); } while (!hw_read(udc->hw_bank.op, OP_USBCMD, USBCMD_ATDTW));
hw_write(udc->hw_bank.op, OP_USBCMD, USBCMD_ATDTW, 0);
if (tmp_stat) if (tmp_stat)
goto done; goto done;
} }
...@@ -1522,7 +1520,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) ...@@ -1522,7 +1520,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
wmb(); /* synchronize before ep prime */ wmb(); /* synchronize before ep prime */
ret = hw_ep_prime(mEp->num, mEp->dir, ret = hw_ep_prime(udc, mEp->num, mEp->dir,
mEp->type == USB_ENDPOINT_XFER_CONTROL); mEp->type == USB_ENDPOINT_XFER_CONTROL);
done: done:
return ret; return ret;
...@@ -1593,7 +1591,7 @@ __acquires(mEp->lock) ...@@ -1593,7 +1591,7 @@ __acquires(mEp->lock)
if (mEp == NULL) if (mEp == NULL)
return -EINVAL; return -EINVAL;
hw_ep_flush(mEp->num, mEp->dir); hw_ep_flush(mEp->udc, mEp->num, mEp->dir);
while (!list_empty(&mEp->qh.queue)) { while (!list_empty(&mEp->qh.queue)) {
...@@ -1630,11 +1628,11 @@ static int _gadget_stop_activity(struct usb_gadget *gadget) ...@@ -1630,11 +1628,11 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
if (gadget == NULL) if (gadget == NULL)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
udc->gadget.speed = USB_SPEED_UNKNOWN; udc->gadget.speed = USB_SPEED_UNKNOWN;
udc->remote_wakeup = 0; udc->remote_wakeup = 0;
udc->suspended = 0; udc->suspended = 0;
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
/* flush all endpoints */ /* flush all endpoints */
gadget_for_each_ep(ep, gadget) { gadget_for_each_ep(ep, gadget) {
...@@ -1682,12 +1680,12 @@ __acquires(udc->lock) ...@@ -1682,12 +1680,12 @@ __acquires(udc->lock)
dbg_event(0xFF, "BUS RST", 0); dbg_event(0xFF, "BUS RST", 0);
spin_unlock(udc->lock); spin_unlock(&udc->lock);
retval = _gadget_stop_activity(&udc->gadget); retval = _gadget_stop_activity(&udc->gadget);
if (retval) if (retval)
goto done; goto done;
retval = hw_usb_reset(); retval = hw_usb_reset(udc);
if (retval) if (retval)
goto done; goto done;
...@@ -1695,7 +1693,7 @@ __acquires(udc->lock) ...@@ -1695,7 +1693,7 @@ __acquires(udc->lock)
if (udc->status == NULL) if (udc->status == NULL)
retval = -ENOMEM; retval = -ENOMEM;
spin_lock(udc->lock); spin_lock(&udc->lock);
done: done:
if (retval) if (retval)
...@@ -1767,7 +1765,7 @@ __acquires(mEp->lock) ...@@ -1767,7 +1765,7 @@ __acquires(mEp->lock)
dir = (le16_to_cpu(setup->wIndex) & USB_ENDPOINT_DIR_MASK) ? dir = (le16_to_cpu(setup->wIndex) & USB_ENDPOINT_DIR_MASK) ?
TX : RX; TX : RX;
num = le16_to_cpu(setup->wIndex) & USB_ENDPOINT_NUMBER_MASK; num = le16_to_cpu(setup->wIndex) & USB_ENDPOINT_NUMBER_MASK;
*(u16 *)req->buf = hw_ep_get_halt(num, dir); *(u16 *)req->buf = hw_ep_get_halt(udc, num, dir);
} }
/* else do nothing; reserved for future use */ /* else do nothing; reserved for future use */
...@@ -1804,10 +1802,10 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req) ...@@ -1804,10 +1802,10 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req)
trace("%p, %p", ep, req); trace("%p, %p", ep, req);
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (udc->test_mode) if (udc->test_mode)
hw_port_test_set(udc->test_mode); hw_port_test_set(udc, udc->test_mode);
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
} }
/** /**
...@@ -1901,7 +1899,7 @@ __acquires(udc->lock) ...@@ -1901,7 +1899,7 @@ __acquires(udc->lock)
return; return;
} }
for (i = 0; i < hw_ep_max; i++) { for (i = 0; i < udc->hw_ep_max; i++) {
struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
int type, num, dir, err = -EINVAL; int type, num, dir, err = -EINVAL;
struct usb_ctrlrequest req; struct usb_ctrlrequest req;
...@@ -1909,7 +1907,7 @@ __acquires(udc->lock) ...@@ -1909,7 +1907,7 @@ __acquires(udc->lock)
if (mEp->ep.desc == NULL) if (mEp->ep.desc == NULL)
continue; /* not configured */ continue; /* not configured */
if (hw_test_and_clear_complete(i)) { if (hw_test_and_clear_complete(udc, i)) {
err = isr_tr_complete_low(mEp); err = isr_tr_complete_low(mEp);
if (mEp->type == USB_ENDPOINT_XFER_CONTROL) { if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
if (err > 0) /* needs status phase */ if (err > 0) /* needs status phase */
...@@ -1917,17 +1915,17 @@ __acquires(udc->lock) ...@@ -1917,17 +1915,17 @@ __acquires(udc->lock)
if (err < 0) { if (err < 0) {
dbg_event(_usb_addr(mEp), dbg_event(_usb_addr(mEp),
"ERROR", err); "ERROR", err);
spin_unlock(udc->lock); spin_unlock(&udc->lock);
if (usb_ep_set_halt(&mEp->ep)) if (usb_ep_set_halt(&mEp->ep))
dev_err(&udc->gadget.dev, dev_err(&udc->gadget.dev,
"error: ep_set_halt\n"); "error: ep_set_halt\n");
spin_lock(udc->lock); spin_lock(&udc->lock);
} }
} }
} }
if (mEp->type != USB_ENDPOINT_XFER_CONTROL || if (mEp->type != USB_ENDPOINT_XFER_CONTROL ||
!hw_test_and_clear_setup_status(i)) !hw_test_and_clear_setup_status(udc, i))
continue; continue;
if (i != 0) { if (i != 0) {
...@@ -1945,9 +1943,9 @@ __acquires(udc->lock) ...@@ -1945,9 +1943,9 @@ __acquires(udc->lock)
/* read_setup_packet */ /* read_setup_packet */
do { do {
hw_test_and_set_setup_guard(); hw_test_and_set_setup_guard(udc);
memcpy(&req, &mEp->qh.ptr->setup, sizeof(req)); memcpy(&req, &mEp->qh.ptr->setup, sizeof(req));
} while (!hw_test_and_clear_setup_guard()); } while (!hw_test_and_clear_setup_guard(udc));
type = req.bRequestType; type = req.bRequestType;
...@@ -1966,12 +1964,12 @@ __acquires(udc->lock) ...@@ -1966,12 +1964,12 @@ __acquires(udc->lock)
dir = num & USB_ENDPOINT_DIR_MASK; dir = num & USB_ENDPOINT_DIR_MASK;
num &= USB_ENDPOINT_NUMBER_MASK; num &= USB_ENDPOINT_NUMBER_MASK;
if (dir) /* TX */ if (dir) /* TX */
num += hw_ep_max/2; num += udc->hw_ep_max/2;
if (!udc->ci13xxx_ep[num].wedge) { if (!udc->ci13xxx_ep[num].wedge) {
spin_unlock(udc->lock); spin_unlock(&udc->lock);
err = usb_ep_clear_halt( err = usb_ep_clear_halt(
&udc->ci13xxx_ep[num].ep); &udc->ci13xxx_ep[num].ep);
spin_lock(udc->lock); spin_lock(&udc->lock);
if (err) if (err)
break; break;
} }
...@@ -2003,7 +2001,8 @@ __acquires(udc->lock) ...@@ -2003,7 +2001,8 @@ __acquires(udc->lock)
if (le16_to_cpu(req.wLength) != 0 || if (le16_to_cpu(req.wLength) != 0 ||
le16_to_cpu(req.wIndex) != 0) le16_to_cpu(req.wIndex) != 0)
break; break;
err = hw_usb_set_address((u8)le16_to_cpu(req.wValue)); err = hw_usb_set_address(udc,
(u8)le16_to_cpu(req.wValue));
if (err) if (err)
break; break;
err = isr_setup_status_phase(udc); err = isr_setup_status_phase(udc);
...@@ -2018,11 +2017,11 @@ __acquires(udc->lock) ...@@ -2018,11 +2017,11 @@ __acquires(udc->lock)
dir = num & USB_ENDPOINT_DIR_MASK; dir = num & USB_ENDPOINT_DIR_MASK;
num &= USB_ENDPOINT_NUMBER_MASK; num &= USB_ENDPOINT_NUMBER_MASK;
if (dir) /* TX */ if (dir) /* TX */
num += hw_ep_max/2; num += udc->hw_ep_max/2;
spin_unlock(udc->lock); spin_unlock(&udc->lock);
err = usb_ep_set_halt(&udc->ci13xxx_ep[num].ep); err = usb_ep_set_halt(&udc->ci13xxx_ep[num].ep);
spin_lock(udc->lock); spin_lock(&udc->lock);
if (!err) if (!err)
isr_setup_status_phase(udc); isr_setup_status_phase(udc);
} else if (type == (USB_DIR_OUT|USB_RECIP_DEVICE)) { } else if (type == (USB_DIR_OUT|USB_RECIP_DEVICE)) {
...@@ -2060,20 +2059,20 @@ __acquires(udc->lock) ...@@ -2060,20 +2059,20 @@ __acquires(udc->lock)
if (req.wLength == 0) /* no data phase */ if (req.wLength == 0) /* no data phase */
udc->ep0_dir = TX; udc->ep0_dir = TX;
spin_unlock(udc->lock); spin_unlock(&udc->lock);
err = udc->driver->setup(&udc->gadget, &req); err = udc->driver->setup(&udc->gadget, &req);
spin_lock(udc->lock); spin_lock(&udc->lock);
break; break;
} }
if (err < 0) { if (err < 0) {
dbg_event(_usb_addr(mEp), "ERROR", err); dbg_event(_usb_addr(mEp), "ERROR", err);
spin_unlock(udc->lock); spin_unlock(&udc->lock);
if (usb_ep_set_halt(&mEp->ep)) if (usb_ep_set_halt(&mEp->ep))
dev_err(&udc->gadget.dev, dev_err(&udc->gadget.dev,
"error: ep_set_halt\n"); "error: ep_set_halt\n");
spin_lock(udc->lock); spin_lock(&udc->lock);
} }
} }
} }
...@@ -2133,7 +2132,7 @@ static int ep_enable(struct usb_ep *ep, ...@@ -2133,7 +2132,7 @@ static int ep_enable(struct usb_ep *ep,
* is always enabled * is always enabled
*/ */
if (mEp->num) if (mEp->num)
retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type); retval |= hw_ep_enable(mEp->udc, mEp->num, mEp->dir, mEp->type);
spin_unlock_irqrestore(mEp->lock, flags); spin_unlock_irqrestore(mEp->lock, flags);
return retval; return retval;
...@@ -2166,7 +2165,7 @@ static int ep_disable(struct usb_ep *ep) ...@@ -2166,7 +2165,7 @@ static int ep_disable(struct usb_ep *ep)
dbg_event(_usb_addr(mEp), "DISABLE", 0); dbg_event(_usb_addr(mEp), "DISABLE", 0);
retval |= _ep_nuke(mEp); retval |= _ep_nuke(mEp);
retval |= hw_ep_disable(mEp->num, mEp->dir); retval |= hw_ep_disable(mEp->udc, mEp->num, mEp->dir);
if (mEp->type == USB_ENDPOINT_XFER_CONTROL) if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
mEp->dir = (mEp->dir == TX) ? RX : TX; mEp->dir = (mEp->dir == TX) ? RX : TX;
...@@ -2332,7 +2331,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req) ...@@ -2332,7 +2331,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
dbg_event(_usb_addr(mEp), "DEQUEUE", 0); dbg_event(_usb_addr(mEp), "DEQUEUE", 0);
hw_ep_flush(mEp->num, mEp->dir); hw_ep_flush(mEp->udc, mEp->num, mEp->dir);
/* pop request */ /* pop request */
list_del_init(&mReq->queue); list_del_init(&mReq->queue);
...@@ -2384,7 +2383,7 @@ static int ep_set_halt(struct usb_ep *ep, int value) ...@@ -2384,7 +2383,7 @@ static int ep_set_halt(struct usb_ep *ep, int value)
direction = mEp->dir; direction = mEp->dir;
do { do {
dbg_event(_usb_addr(mEp), "HALT", value); dbg_event(_usb_addr(mEp), "HALT", value);
retval |= hw_ep_set_halt(mEp->num, mEp->dir, value); retval |= hw_ep_set_halt(mEp->udc, mEp->num, mEp->dir, value);
if (!value) if (!value)
mEp->wedge = 0; mEp->wedge = 0;
...@@ -2443,7 +2442,7 @@ static void ep_fifo_flush(struct usb_ep *ep) ...@@ -2443,7 +2442,7 @@ static void ep_fifo_flush(struct usb_ep *ep)
spin_lock_irqsave(mEp->lock, flags); spin_lock_irqsave(mEp->lock, flags);
dbg_event(_usb_addr(mEp), "FFLUSH", 0); dbg_event(_usb_addr(mEp), "FFLUSH", 0);
hw_ep_flush(mEp->num, mEp->dir); hw_ep_flush(mEp->udc, mEp->num, mEp->dir);
spin_unlock_irqrestore(mEp->lock, flags); spin_unlock_irqrestore(mEp->lock, flags);
} }
...@@ -2476,19 +2475,19 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active) ...@@ -2476,19 +2475,19 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
if (!(udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS)) if (!(udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS))
return -EOPNOTSUPP; return -EOPNOTSUPP;
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
udc->vbus_active = is_active; udc->vbus_active = is_active;
if (udc->driver) if (udc->driver)
gadget_ready = 1; gadget_ready = 1;
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
if (gadget_ready) { if (gadget_ready) {
if (is_active) { if (is_active) {
pm_runtime_get_sync(&_gadget->dev); pm_runtime_get_sync(&_gadget->dev);
hw_device_reset(udc); hw_device_reset(udc);
hw_device_state(udc->ep0out->qh.dma); hw_device_state(udc, udc->ep0out->qh.dma);
} else { } else {
hw_device_state(0); hw_device_state(udc, 0);
if (udc->udc_driver->notify_event) if (udc->udc_driver->notify_event)
udc->udc_driver->notify_event(udc, udc->udc_driver->notify_event(udc,
CI13XXX_CONTROLLER_STOPPED_EVENT); CI13XXX_CONTROLLER_STOPPED_EVENT);
...@@ -2508,20 +2507,20 @@ static int ci13xxx_wakeup(struct usb_gadget *_gadget) ...@@ -2508,20 +2507,20 @@ static int ci13xxx_wakeup(struct usb_gadget *_gadget)
trace(); trace();
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (!udc->remote_wakeup) { if (!udc->remote_wakeup) {
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
trace("remote wakeup feature is not enabled\n"); trace("remote wakeup feature is not enabled\n");
goto out; goto out;
} }
if (!hw_read(hw_bank.op, OP_PORTSC, PORTSC_SUSP)) { if (!hw_read(udc->hw_bank.op, OP_PORTSC, PORTSC_SUSP)) {
ret = -EINVAL; ret = -EINVAL;
trace("port is not suspended\n"); trace("port is not suspended\n");
goto out; goto out;
} }
hw_write(hw_bank.op, OP_PORTSC, PORTSC_FPR, PORTSC_FPR); hw_write(udc->hw_bank.op, OP_PORTSC, PORTSC_FPR, PORTSC_FPR);
out: out:
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return ret; return ret;
} }
...@@ -2594,22 +2593,23 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2594,22 +2593,23 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
return -ENOMEM; return -ENOMEM;
} }
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
info("hw_ep_max = %d", hw_ep_max); info("hw_ep_max = %d", udc->hw_ep_max);
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;
retval = 0; retval = 0;
for (i = 0; i < hw_ep_max/2; i++) { for (i = 0; i < udc->hw_ep_max/2; i++) {
for (j = RX; j <= TX; j++) { for (j = RX; j <= TX; j++) {
int k = i + j * hw_ep_max/2; int k = i + j * udc->hw_ep_max/2;
struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[k]; struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[k];
scnprintf(mEp->name, sizeof(mEp->name), "ep%i%s", i, scnprintf(mEp->name, sizeof(mEp->name), "ep%i%s", i,
(j == TX) ? "in" : "out"); (j == TX) ? "in" : "out");
mEp->lock = udc->lock; mEp->udc = udc;
mEp->lock = &udc->lock;
mEp->device = &udc->gadget.dev; mEp->device = &udc->gadget.dev;
mEp->td_pool = udc->td_pool; mEp->td_pool = udc->td_pool;
...@@ -2618,10 +2618,10 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2618,10 +2618,10 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
mEp->ep.maxpacket = CTRL_PAYLOAD_MAX; mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
INIT_LIST_HEAD(&mEp->qh.queue); INIT_LIST_HEAD(&mEp->qh.queue);
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
mEp->qh.ptr = dma_pool_alloc(udc->qh_pool, GFP_KERNEL, mEp->qh.ptr = dma_pool_alloc(udc->qh_pool, GFP_KERNEL,
&mEp->qh.dma); &mEp->qh.dma);
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (mEp->qh.ptr == NULL) if (mEp->qh.ptr == NULL)
retval = -ENOMEM; retval = -ENOMEM;
else else
...@@ -2646,7 +2646,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2646,7 +2646,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
if (retval) if (retval)
goto done; goto done;
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
udc->ep0out->ep.desc = &ctrl_endpt_out_desc; udc->ep0out->ep.desc = &ctrl_endpt_out_desc;
retval = usb_ep_enable(&udc->ep0out->ep); retval = usb_ep_enable(&udc->ep0out->ep);
if (retval) if (retval)
...@@ -2656,16 +2656,16 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2656,16 +2656,16 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
retval = usb_ep_enable(&udc->ep0in->ep); retval = usb_ep_enable(&udc->ep0in->ep);
if (retval) if (retval)
return retval; return retval;
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
udc->gadget.ep0 = &udc->ep0in->ep; udc->gadget.ep0 = &udc->ep0in->ep;
/* bind gadget */ /* bind gadget */
driver->driver.bus = NULL; driver->driver.bus = NULL;
udc->gadget.dev.driver = &driver->driver; udc->gadget.dev.driver = &driver->driver;
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
retval = bind(&udc->gadget); /* MAY SLEEP */ retval = bind(&udc->gadget); /* MAY SLEEP */
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (retval) { if (retval) {
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;
...@@ -2684,12 +2684,12 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, ...@@ -2684,12 +2684,12 @@ static int ci13xxx_start(struct usb_gadget_driver *driver,
} }
} }
retval = hw_device_state(udc->ep0out->qh.dma); retval = hw_device_state(udc, udc->ep0out->qh.dma);
if (retval) if (retval)
pm_runtime_put_sync(&udc->gadget.dev); pm_runtime_put_sync(&udc->gadget.dev);
done: done:
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return retval; return retval;
} }
...@@ -2712,29 +2712,29 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) ...@@ -2712,29 +2712,29 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver)
driver != udc->driver) driver != udc->driver)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (!(udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) || if (!(udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) ||
udc->vbus_active) { udc->vbus_active) {
hw_device_state(0); hw_device_state(udc, 0);
if (udc->udc_driver->notify_event) if (udc->udc_driver->notify_event)
udc->udc_driver->notify_event(udc, udc->udc_driver->notify_event(udc,
CI13XXX_CONTROLLER_STOPPED_EVENT); CI13XXX_CONTROLLER_STOPPED_EVENT);
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
_gadget_stop_activity(&udc->gadget); _gadget_stop_activity(&udc->gadget);
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
pm_runtime_put(&udc->gadget.dev); pm_runtime_put(&udc->gadget.dev);
} }
/* unbind gadget */ /* unbind gadget */
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
driver->unbind(&udc->gadget); /* MAY SLEEP */ driver->unbind(&udc->gadget); /* MAY SLEEP */
spin_lock_irqsave(udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;
/* free resources */ /* free resources */
for (i = 0; i < hw_ep_max; i++) { for (i = 0; i < udc->hw_ep_max; i++) {
struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
if (mEp->num) if (mEp->num)
...@@ -2747,7 +2747,7 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) ...@@ -2747,7 +2747,7 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver)
udc->gadget.ep0 = NULL; udc->gadget.ep0 = NULL;
udc->driver = NULL; udc->driver = NULL;
spin_unlock_irqrestore(udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
if (udc->td_pool != NULL) { if (udc->td_pool != NULL) {
dma_pool_destroy(udc->td_pool); dma_pool_destroy(udc->td_pool);
...@@ -2783,16 +2783,16 @@ static irqreturn_t udc_irq(void) ...@@ -2783,16 +2783,16 @@ static irqreturn_t udc_irq(void)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
spin_lock(udc->lock); spin_lock(&udc->lock);
if (udc->udc_driver->flags & CI13XXX_REGS_SHARED) { if (udc->udc_driver->flags & CI13XXX_REGS_SHARED) {
if (hw_read(hw_bank.op, OP_USBMODE, USBMODE_CM) != if (hw_read(udc->hw_bank.op, OP_USBMODE, USBMODE_CM) !=
USBMODE_CM_DEVICE) { USBMODE_CM_DEVICE) {
spin_unlock(udc->lock); spin_unlock(&udc->lock);
return IRQ_NONE; return IRQ_NONE;
} }
} }
intr = hw_test_and_clear_intr_active(); intr = hw_test_and_clear_intr_active(udc);
if (intr) { if (intr) {
isr_statistics.hndl.buf[isr_statistics.hndl.idx++] = intr; isr_statistics.hndl.buf[isr_statistics.hndl.idx++] = intr;
isr_statistics.hndl.idx &= ISR_MASK; isr_statistics.hndl.idx &= ISR_MASK;
...@@ -2805,12 +2805,12 @@ static irqreturn_t udc_irq(void) ...@@ -2805,12 +2805,12 @@ static irqreturn_t udc_irq(void)
} }
if (USBi_PCI & intr) { if (USBi_PCI & intr) {
isr_statistics.pci++; isr_statistics.pci++;
udc->gadget.speed = hw_port_is_high_speed() ? udc->gadget.speed = hw_port_is_high_speed(udc) ?
USB_SPEED_HIGH : USB_SPEED_FULL; USB_SPEED_HIGH : USB_SPEED_FULL;
if (udc->suspended && udc->driver->resume) { if (udc->suspended && udc->driver->resume) {
spin_unlock(udc->lock); spin_unlock(&udc->lock);
udc->driver->resume(&udc->gadget); udc->driver->resume(&udc->gadget);
spin_lock(udc->lock); spin_lock(&udc->lock);
udc->suspended = 0; udc->suspended = 0;
} }
} }
...@@ -2824,9 +2824,9 @@ static irqreturn_t udc_irq(void) ...@@ -2824,9 +2824,9 @@ static irqreturn_t udc_irq(void)
if (udc->gadget.speed != USB_SPEED_UNKNOWN && if (udc->gadget.speed != USB_SPEED_UNKNOWN &&
udc->driver->suspend) { udc->driver->suspend) {
udc->suspended = 1; udc->suspended = 1;
spin_unlock(udc->lock); spin_unlock(&udc->lock);
udc->driver->suspend(&udc->gadget); udc->driver->suspend(&udc->gadget);
spin_lock(udc->lock); spin_lock(&udc->lock);
} }
isr_statistics.sli++; isr_statistics.sli++;
} }
...@@ -2835,7 +2835,7 @@ static irqreturn_t udc_irq(void) ...@@ -2835,7 +2835,7 @@ static irqreturn_t udc_irq(void)
isr_statistics.none++; isr_statistics.none++;
retval = IRQ_NONE; retval = IRQ_NONE;
} }
spin_unlock(udc->lock); spin_unlock(&udc->lock);
return retval; return retval;
} }
...@@ -2880,7 +2880,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2880,7 +2880,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
if (udc == NULL) if (udc == NULL)
return -ENOMEM; return -ENOMEM;
udc->lock = &udc_lock; spin_lock_init(&udc->lock);
udc->regs = regs; udc->regs = regs;
udc->udc_driver = driver; udc->udc_driver = driver;
...@@ -2899,7 +2899,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, ...@@ -2899,7 +2899,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
udc->gadget.dev.parent = dev; udc->gadget.dev.parent = dev;
udc->gadget.dev.release = udc_release; udc->gadget.dev.release = udc_release;
retval = hw_device_init(regs, capoffset); retval = hw_device_init(udc, regs, capoffset);
if (retval < 0) if (retval < 0)
goto free_udc; goto free_udc;
......
...@@ -94,6 +94,7 @@ struct ci13xxx_ep { ...@@ -94,6 +94,7 @@ struct ci13xxx_ep {
int wedge; int wedge;
/* global resources */ /* global resources */
struct ci13xxx *udc;
spinlock_t *lock; spinlock_t *lock;
struct device *device; struct device *device;
struct dma_pool *td_pool; struct dma_pool *td_pool;
...@@ -113,9 +114,17 @@ struct ci13xxx_udc_driver { ...@@ -113,9 +114,17 @@ struct ci13xxx_udc_driver {
void (*notify_event) (struct ci13xxx *udc, unsigned event); void (*notify_event) (struct ci13xxx *udc, unsigned event);
}; };
struct hw_bank {
unsigned lpm; /* is LPM? */
void __iomem *abs; /* bus map offset */
void __iomem *cap; /* bus map offset + CAP offset */
void __iomem *op; /* bus map offset + OP offset */
size_t size; /* bank size */
};
/* CI13XXX UDC descriptor & global resources */ /* CI13XXX UDC descriptor & global resources */
struct ci13xxx { struct ci13xxx {
spinlock_t *lock; /* ctrl register bank access */ spinlock_t lock; /* ctrl register bank access */
void __iomem *regs; /* registers address space */ void __iomem *regs; /* registers address space */
struct dma_pool *qh_pool; /* DMA pool for queue heads */ struct dma_pool *qh_pool; /* DMA pool for queue heads */
...@@ -126,11 +135,14 @@ struct ci13xxx { ...@@ -126,11 +135,14 @@ struct ci13xxx {
struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */
u32 ep0_dir; /* ep0 direction */ u32 ep0_dir; /* ep0 direction */
struct ci13xxx_ep *ep0out, *ep0in; struct ci13xxx_ep *ep0out, *ep0in;
unsigned hw_ep_max; /* number of hw endpoints */
u8 remote_wakeup; /* Is remote wakeup feature u8 remote_wakeup; /* Is remote wakeup feature
enabled by the host? */ enabled by the host? */
u8 suspended; /* suspended by the host */ u8 suspended; /* suspended by the host */
u8 test_mode; /* the selected test mode */ u8 test_mode; /* the selected test mode */
struct hw_bank hw_bank;
struct usb_gadget_driver *driver; /* 3rd party gadget driver */ struct usb_gadget_driver *driver; /* 3rd party gadget driver */
struct ci13xxx_udc_driver *udc_driver; /* device controller driver */ struct ci13xxx_udc_driver *udc_driver; /* device controller driver */
int vbus_active; /* is VBUS active */ int vbus_active; /* is VBUS active */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment