Skip to content

Commit a46af4e

Browse files
AlanSterngregkh
authored andcommitted
USB: EHCI: define extension registers like normal ones
This patch (as1562) cleans up the definitions of the EHCI extended registers to be consistent with the definitions of the standard registers. This makes the code look a lot nicer, with no functional change. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cf61fdb commit a46af4e

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

drivers/usb/host/ehci-hcd.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
203203
/* check TDI/ARC silicon is in host mode */
204204
static int tdi_in_host_mode (struct ehci_hcd *ehci)
205205
{
206-
u32 __iomem *reg_ptr;
207206
u32 tmp;
208207

209-
reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE);
210-
tmp = ehci_readl(ehci, reg_ptr);
208+
tmp = ehci_readl(ehci, &ehci->regs->usbmode);
211209
return (tmp & 3) == USBMODE_CM_HC;
212210
}
213211

@@ -303,19 +301,17 @@ static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
303301
/* put TDI/ARC silicon into EHCI mode */
304302
static void tdi_reset (struct ehci_hcd *ehci)
305303
{
306-
u32 __iomem *reg_ptr;
307304
u32 tmp;
308305

309-
reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE);
310-
tmp = ehci_readl(ehci, reg_ptr);
306+
tmp = ehci_readl(ehci, &ehci->regs->usbmode);
311307
tmp |= USBMODE_CM_HC;
312308
/* The default byte access to MMR space is LE after
313309
* controller reset. Set the required endian mode
314310
* for transfer buffers to match the host microprocessor
315311
*/
316312
if (ehci_big_endian_mmio(ehci))
317313
tmp |= USBMODE_BE;
318-
ehci_writel(ehci, tmp, reg_ptr);
314+
ehci_writel(ehci, tmp, &ehci->regs->usbmode);
319315
}
320316

321317
/* reset a non-running (STS_HALT == 1) controller */
@@ -339,9 +335,8 @@ static int ehci_reset (struct ehci_hcd *ehci)
339335

340336
if (ehci->has_hostpc) {
341337
ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS,
342-
(u32 __iomem *)(((u8 *)ehci->regs) + USBMODE_EX));
343-
ehci_writel(ehci, TXFIFO_DEFAULT,
344-
(u32 __iomem *)(((u8 *)ehci->regs) + TXFILLTUNING));
338+
&ehci->regs->usbmode_ex);
339+
ehci_writel(ehci, TXFIFO_DEFAULT, &ehci->regs->txfill_tuning);
345340
}
346341
if (retval)
347342
return retval;

drivers/usb/host/ehci-hub.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,8 @@ static __maybe_unused void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
149149
if (ehci->has_hostpc) {
150150
port = HCS_N_PORTS(ehci->hcs_params);
151151
while (port--) {
152-
u32 __iomem *hostpc_reg;
152+
u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
153153

154-
hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
155-
+ HOSTPC0 + 4 * port);
156154
temp = ehci_readl(ehci, hostpc_reg);
157155
ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg);
158156
}
@@ -185,10 +183,8 @@ static __maybe_unused void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
185183
if (ehci->has_hostpc) {
186184
port = HCS_N_PORTS(ehci->hcs_params);
187185
while (port--) {
188-
u32 __iomem *hostpc_reg;
186+
u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
189187

190-
hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
191-
+ HOSTPC0 + 4 * port);
192188
temp = ehci_readl(ehci, hostpc_reg);
193189
ehci_writel(ehci, temp | HOSTPC_PHCD, hostpc_reg);
194190
}
@@ -285,11 +281,9 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
285281

286282
port = HCS_N_PORTS(ehci->hcs_params);
287283
while (port--) {
288-
u32 __iomem *hostpc_reg;
284+
u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
289285
u32 t3;
290286

291-
hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
292-
+ HOSTPC0 + 4 * port);
293287
t3 = ehci_readl(ehci, hostpc_reg);
294288
ehci_writel(ehci, t3 | HOSTPC_PHCD, hostpc_reg);
295289
t3 = ehci_readl(ehci, hostpc_reg);
@@ -388,10 +382,9 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
388382
i = HCS_N_PORTS(ehci->hcs_params);
389383
while (i--) {
390384
if (test_bit(i, &ehci->bus_suspended)) {
391-
u32 __iomem *hostpc_reg;
385+
u32 __iomem *hostpc_reg =
386+
&ehci->regs->hostpc[i];
392387

393-
hostpc_reg = (u32 __iomem *)((u8 *) ehci->regs
394-
+ HOSTPC0 + 4 * i);
395388
temp = ehci_readl(ehci, hostpc_reg);
396389
ehci_writel(ehci, temp & ~HOSTPC_PHCD,
397390
hostpc_reg);
@@ -667,7 +660,7 @@ static int ehci_hub_control (
667660
int ports = HCS_N_PORTS (ehci->hcs_params);
668661
u32 __iomem *status_reg = &ehci->regs->port_status[
669662
(wIndex & 0xff) - 1];
670-
u32 __iomem *hostpc_reg = NULL;
663+
u32 __iomem *hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1];
671664
u32 temp, temp1, status;
672665
unsigned long flags;
673666
int retval = 0;
@@ -680,9 +673,6 @@ static int ehci_hub_control (
680673
* power, "this is the one", etc. EHCI spec supports this.
681674
*/
682675

683-
if (ehci->has_hostpc)
684-
hostpc_reg = (u32 __iomem *)((u8 *)ehci->regs
685-
+ HOSTPC0 + 4 * ((wIndex & 0xff) - 1));
686676
spin_lock_irqsave (&ehci->lock, flags);
687677
switch (typeReq) {
688678
case ClearHubFeature:
@@ -734,7 +724,7 @@ static int ehci_hub_control (
734724
goto error;
735725

736726
/* clear phy low-power mode before resume */
737-
if (hostpc_reg) {
727+
if (ehci->has_hostpc) {
738728
temp1 = ehci_readl(ehci, hostpc_reg);
739729
ehci_writel(ehci, temp1 & ~HOSTPC_PHCD,
740730
hostpc_reg);
@@ -984,7 +974,7 @@ static int ehci_hub_control (
984974
temp &= ~PORT_WKCONN_E;
985975
temp |= PORT_WKDISC_E | PORT_WKOC_E;
986976
ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
987-
if (hostpc_reg) {
977+
if (ehci->has_hostpc) {
988978
spin_unlock_irqrestore(&ehci->lock, flags);
989979
msleep(5);/* 5ms for HCD enter low pwr mode */
990980
spin_lock_irqsave(&ehci->lock, flags);

include/linux/usb/ehci_def.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ struct ehci_regs {
111111
/* ASYNCLISTADDR: offset 0x18 */
112112
u32 async_next; /* address of next async queue head */
113113

114-
u32 reserved[9];
114+
u32 reserved1[2];
115+
116+
/* TXFILLTUNING: offset 0x24 */
117+
u32 txfill_tuning; /* TX FIFO Tuning register */
118+
#define TXFIFO_DEFAULT (8<<16) /* FIFO burst threshold 8 */
119+
120+
u32 reserved2[6];
115121

116122
/* CONFIGFLAG: offset 0x40 */
117123
u32 configured_flag;
@@ -155,26 +161,34 @@ struct ehci_regs {
155161
#define PORT_CSC (1<<1) /* connect status change */
156162
#define PORT_CONNECT (1<<0) /* device connected */
157163
#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
158-
};
159164

160-
#define USBMODE 0x68 /* USB Device mode */
165+
u32 reserved3[9];
166+
167+
/* USBMODE: offset 0x68 */
168+
u32 usbmode; /* USB Device mode */
161169
#define USBMODE_SDIS (1<<3) /* Stream disable */
162170
#define USBMODE_BE (1<<2) /* BE/LE endianness select */
163171
#define USBMODE_CM_HC (3<<0) /* host controller mode */
164172
#define USBMODE_CM_IDLE (0<<0) /* idle state */
165173

174+
u32 reserved4[7];
175+
166176
/* Moorestown has some non-standard registers, partially due to the fact that
167177
* its EHCI controller has both TT and LPM support. HOSTPCx are extensions to
168178
* PORTSCx
169179
*/
170-
#define HOSTPC0 0x84 /* HOSTPC extension */
180+
/* HOSTPC: offset 0x84 */
181+
u32 hostpc[0]; /* HOSTPC extension */
171182
#define HOSTPC_PHCD (1<<22) /* Phy clock disable */
172183
#define HOSTPC_PSPD (3<<25) /* Port speed detection */
173-
#define USBMODE_EX 0xc8 /* USB Device mode extension */
184+
185+
u32 reserved5[17];
186+
187+
/* USBMODE_EX: offset 0xc8 */
188+
u32 usbmode_ex; /* USB Device mode extension */
174189
#define USBMODE_EX_VBPS (1<<5) /* VBus Power Select On */
175190
#define USBMODE_EX_HC (3<<0) /* host controller mode */
176-
#define TXFILLTUNING 0x24 /* TX FIFO Tuning register */
177-
#define TXFIFO_DEFAULT (8<<16) /* FIFO burst threshold 8 */
191+
};
178192

179193
/* Appendix C, Debug port ... intended for use with special "debug devices"
180194
* that can help if there's no serial console. (nonstandard enumeration.)

0 commit comments

Comments
 (0)