|
|
@@ -172,6 +172,7 @@ struct ehci_ctrl {
|
|
|
unsigned int n_ports;
|
|
|
int ppc;
|
|
|
int last_port;
|
|
|
+ unsigned int cc_ports; /* ports handed to a companion (bitmask) */
|
|
|
unsigned int hcs;
|
|
|
unsigned int hcc;
|
|
|
|
|
|
@@ -857,6 +858,27 @@ static int ehci_port_take_change(unsigned int ctrl, unsigned int port)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+/* HCSPARAMS N_CC: the number of companion controllers. */
|
|
|
+static unsigned int n_companions(const struct ehci_ctrl *c)
|
|
|
+{
|
|
|
+ return (c->hcs >> 12) & 0x0Fu;
|
|
|
+}
|
|
|
+
|
|
|
+/* Give a non-high-speed device to the companion controller. */
|
|
|
+static void port_to_companion(struct ehci_ctrl *c, unsigned int port,
|
|
|
+ unsigned int ps)
|
|
|
+{
|
|
|
+ wr32(port_reg(c, port),
|
|
|
+ (ps & ~(PORT_RWC | PORT_PE | PORT_RESET)) | PORT_OWNER |
|
|
|
+ PORT_CSC | PORT_PEC | PORT_OCC);
|
|
|
+ if (!(c->cc_ports & (1u << port))) {
|
|
|
+ c->cc_ports |= 1u << port;
|
|
|
+ serial_puts(SERIAL_COM1, "ehci: port ");
|
|
|
+ serial_putdec(SERIAL_COM1, port + 1);
|
|
|
+ serial_puts(SERIAL_COM1, " not high-speed, handed to companion\n");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static int ehci_port_reset_once(unsigned int ctrl, unsigned int port)
|
|
|
{
|
|
|
struct ehci_ctrl *c;
|
|
|
@@ -895,8 +917,11 @@ static int ehci_port_reset_once(unsigned int ctrl, unsigned int port)
|
|
|
low/full-speed device belongs there; a high-speed one can be taken
|
|
|
over by clearing PORT_OWNER (the controller may need more than one
|
|
|
write while the port is enabled). */
|
|
|
+ /* The hardware returns a port to the EHCI when its device goes away. */
|
|
|
+ if (!(ps & PORT_OWNER))
|
|
|
+ c->cc_ports &= ~(1u << port);
|
|
|
if (ps & PORT_OWNER) {
|
|
|
- if (PORT_USB11(ps))
|
|
|
+ if (PORT_USB11(ps) || (c->cc_ports & (1u << port)))
|
|
|
return -1;
|
|
|
for (try = 0; try < 8 && (ps & PORT_OWNER); try++) {
|
|
|
wr32(port_reg(c, port),
|
|
|
@@ -910,6 +935,13 @@ static int ehci_port_reset_once(unsigned int ctrl, unsigned int port)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ /* A low-speed device (K state on an unenabled port) is never reset by
|
|
|
+ the EHCI: hand it straight to the companion (EHCI 4.2.2). */
|
|
|
+ if (!(ps & PORT_PE) && PORT_USB11(ps) && n_companions(c)) {
|
|
|
+ port_to_companion(c, port, ps);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
port_endpoints_reset(c, port);
|
|
|
c->last_port = (int)port;
|
|
|
|
|
|
@@ -968,11 +1000,13 @@ static int ehci_port_reset_once(unsigned int ctrl, unsigned int port)
|
|
|
if (!(ps & PORT_PE)) {
|
|
|
if (ps & PORT_OWNER)
|
|
|
return -1;
|
|
|
- if (PORT_USB11(ps)) {
|
|
|
- /* Low/full speed: make sure the companion owns it. */
|
|
|
- wr32(port_reg(c, port),
|
|
|
- (ps & ~(PORT_RWC | PORT_PE)) | PORT_OWNER |
|
|
|
- PORT_CSC | PORT_PEC | PORT_OCC);
|
|
|
+ /* Not enabled after the reset: the device is not high-speed
|
|
|
+ (EHCI 4.2.2), whatever the line state reads -- a full-speed
|
|
|
+ receiver on the MCP79 reports SE0 here. It belongs to the
|
|
|
+ companion. Only a controller without companions (Intel PCH
|
|
|
+ rate-matching hubs) can have a genuinely stuck HS reset. */
|
|
|
+ if (n_companions(c) || PORT_USB11(ps)) {
|
|
|
+ port_to_companion(c, port, ps);
|
|
|
return -1;
|
|
|
}
|
|
|
serial_puts(SERIAL_COM1, "ehci: reset no PED ");
|