1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20static int __maybe_unused ehci_lpm_set_da(struct ehci_hcd *ehci,
21 int dev_addr, int port_num)
22{
23 u32 __iomem portsc;
24
25 ehci_dbg(ehci, "set dev address %d for port %d\n", dev_addr, port_num);
26 if (port_num > HCS_N_PORTS(ehci->hcs_params)) {
27 ehci_dbg(ehci, "invalid port number %d\n", port_num);
28 return -ENODEV;
29 }
30 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_num-1]);
31 portsc &= ~PORT_DEV_ADDR;
32 portsc |= dev_addr<<25;
33 ehci_writel(ehci, portsc, &ehci->regs->port_status[port_num-1]);
34 return 0;
35}
36
37
38
39
40
41static int __maybe_unused ehci_lpm_check(struct ehci_hcd *ehci, int port)
42{
43 u32 __iomem *portsc ;
44 u32 val32;
45 int retval;
46
47 portsc = &ehci->regs->port_status[port-1];
48 val32 = ehci_readl(ehci, portsc);
49 if (!(val32 & PORT_DEV_ADDR)) {
50 ehci_dbg(ehci, "LPM: no device attached\n");
51 return -ENODEV;
52 }
53 val32 |= PORT_LPM;
54 ehci_writel(ehci, val32, portsc);
55 msleep(5);
56 val32 |= PORT_SUSPEND;
57 ehci_dbg(ehci, "Sending LPM 0x%08x to port %d\n", val32, port);
58 ehci_writel(ehci, val32, portsc);
59
60 msleep(10);
61 retval = handshake(ehci, &ehci->regs->port_status[port-1], PORT_SSTS,
62 PORTSC_SUSPEND_STS_ACK, 125);
63 dbg_port(ehci, "LPM", port, val32);
64 if (retval != -ETIMEDOUT) {
65 ehci_dbg(ehci, "LPM: device ACK for LPM\n");
66 val32 |= PORT_LPM;
67
68
69
70
71 ehci_writel(ehci, val32, portsc);
72 msleep(10);
73 val32 |= PORT_RESUME;
74 ehci_writel(ehci, val32, portsc);
75 } else {
76 ehci_dbg(ehci, "LPM: device does not ACK, disable LPM %d\n",
77 retval);
78 val32 &= ~PORT_LPM;
79 retval = -ETIMEDOUT;
80 ehci_writel(ehci, val32, portsc);
81 }
82
83 return retval;
84}
85