Commit ea427775677a4147147b64fce4d0ad1acac04e47

Authored by Adrian Cox
Committed by Marek Vasut
1 parent ede4d5e387

usb: Add endian support macros to interrupt transfers in the EHCI driver.

Update the EHCI driver to support interrupt transfers on PowerPC.

Signed-off-by: Adrian Cox <adrian@humboldt.co.uk>

Showing 1 changed file with 31 additions and 25 deletions Side-by-side Diff

drivers/usb/host/ehci-hcd.c
... ... @@ -998,8 +998,8 @@
998 998 if (!ehcic[index].periodic_list)
999 999 return -ENOMEM;
1000 1000 for (i = 0; i < 1024; i++) {
1001   - ehcic[index].periodic_list[i] = (uint32_t)periodic
1002   - | QH_LINK_TYPE_QH;
  1001 + ehcic[index].periodic_list[i] = cpu_to_hc32((uint32_t)periodic
  1002 + | QH_LINK_TYPE_QH);
1003 1003 }
1004 1004  
1005 1005 flush_dcache_range((uint32_t)ehcic[index].periodic_list,
... ... @@ -1089,7 +1089,7 @@
1089 1089 struct qTD *tds;
1090 1090 };
1091 1091  
1092   -#define NEXT_QH(qh) (struct QH *)((qh)->qh_link & ~0x1f)
  1092 +#define NEXT_QH(qh) (struct QH *)(hc32_to_cpu((qh)->qh_link) & ~0x1f)
1093 1093  
1094 1094 static int
1095 1095 enable_periodic(struct ehci_ctrl *ctrl)
1096 1096  
1097 1097  
1098 1098  
1099 1099  
1100 1100  
1101 1101  
1102 1102  
1103 1103  
... ... @@ -1184,41 +1184,47 @@
1184 1184 struct qTD *td = result->tds + i;
1185 1185 void **buf = &qh->buffer;
1186 1186  
1187   - qh->qh_link = (uint32_t)(qh+1) | QH_LINK_TYPE_QH;
  1187 + qh->qh_link = cpu_to_hc32((uint32_t)(qh+1) | QH_LINK_TYPE_QH);
1188 1188 if (i == queuesize - 1)
1189   - qh->qh_link = QH_LINK_TERMINATE;
  1189 + qh->qh_link = cpu_to_hc32(QH_LINK_TERMINATE);
1190 1190  
1191   - qh->qh_overlay.qt_next = (uint32_t)td;
1192   - qh->qh_overlay.qt_altnext = QT_NEXT_TERMINATE;
1193   - qh->qh_endpt1 = (0 << 28) | /* No NAK reload (ehci 4.9) */
  1191 + qh->qh_overlay.qt_next = cpu_to_hc32((uint32_t)td);
  1192 + qh->qh_overlay.qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
  1193 + qh->qh_endpt1 =
  1194 + cpu_to_hc32((0 << 28) | /* No NAK reload (ehci 4.9) */
1194 1195 (usb_maxpacket(dev, pipe) << 16) | /* MPS */
1195 1196 (1 << 14) |
1196 1197 QH_ENDPT1_EPS(ehci_encode_speed(dev->speed)) |
1197 1198 (usb_pipeendpoint(pipe) << 8) | /* Endpoint Number */
1198   - (usb_pipedevice(pipe) << 0);
1199   - qh->qh_endpt2 = (1 << 30) | /* 1 Tx per mframe */
1200   - (1 << 0); /* S-mask: microframe 0 */
  1199 + (usb_pipedevice(pipe) << 0));
  1200 + qh->qh_endpt2 = cpu_to_hc32((1 << 30) | /* 1 Tx per mframe */
  1201 + (1 << 0)); /* S-mask: microframe 0 */
1201 1202 if (dev->speed == USB_SPEED_LOW ||
1202 1203 dev->speed == USB_SPEED_FULL) {
1203 1204 debug("TT: port: %d, hub address: %d\n",
1204 1205 dev->portnr, dev->parent->devnum);
1205   - qh->qh_endpt2 |= (dev->portnr << 23) |
  1206 + qh->qh_endpt2 |= cpu_to_hc32((dev->portnr << 23) |
1206 1207 (dev->parent->devnum << 16) |
1207   - (0x1c << 8); /* C-mask: microframes 2-4 */
  1208 + (0x1c << 8)); /* C-mask: microframes 2-4 */
1208 1209 }
1209 1210  
1210   - td->qt_next = QT_NEXT_TERMINATE;
1211   - td->qt_altnext = QT_NEXT_TERMINATE;
  1211 + td->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
  1212 + td->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
1212 1213 debug("communication direction is '%s'\n",
1213 1214 usb_pipein(pipe) ? "in" : "out");
1214   - td->qt_token = (elementsize << 16) |
  1215 + td->qt_token = cpu_to_hc32((elementsize << 16) |
1215 1216 ((usb_pipein(pipe) ? 1 : 0) << 8) | /* IN/OUT token */
1216   - 0x80; /* active */
1217   - td->qt_buffer[0] = (uint32_t)buffer + i * elementsize;
1218   - td->qt_buffer[1] = (td->qt_buffer[0] + 0x1000) & ~0xfff;
1219   - td->qt_buffer[2] = (td->qt_buffer[0] + 0x2000) & ~0xfff;
1220   - td->qt_buffer[3] = (td->qt_buffer[0] + 0x3000) & ~0xfff;
1221   - td->qt_buffer[4] = (td->qt_buffer[0] + 0x4000) & ~0xfff;
  1217 + 0x80); /* active */
  1218 + td->qt_buffer[0] =
  1219 + cpu_to_hc32((uint32_t)buffer + i * elementsize);
  1220 + td->qt_buffer[1] =
  1221 + cpu_to_hc32((td->qt_buffer[0] + 0x1000) & ~0xfff);
  1222 + td->qt_buffer[2] =
  1223 + cpu_to_hc32((td->qt_buffer[0] + 0x2000) & ~0xfff);
  1224 + td->qt_buffer[3] =
  1225 + cpu_to_hc32((td->qt_buffer[0] + 0x3000) & ~0xfff);
  1226 + td->qt_buffer[4] =
  1227 + cpu_to_hc32((td->qt_buffer[0] + 0x4000) & ~0xfff);
1222 1228  
1223 1229 *buf = buffer + i * elementsize;
1224 1230 }
... ... @@ -1241,7 +1247,7 @@
1241 1247 /* hook up to periodic list */
1242 1248 struct QH *list = &ctrl->periodic_queue;
1243 1249 result->last->qh_link = list->qh_link;
1244   - list->qh_link = (uint32_t)result->first | QH_LINK_TYPE_QH;
  1250 + list->qh_link = cpu_to_hc32((uint32_t)result->first | QH_LINK_TYPE_QH);
1245 1251  
1246 1252 flush_dcache_range((uint32_t)result->last,
1247 1253 ALIGN_END_ADDR(struct QH, result->last, 1));
... ... @@ -1280,7 +1286,7 @@
1280 1286 /* still active */
1281 1287 invalidate_dcache_range((uint32_t)cur,
1282 1288 ALIGN_END_ADDR(struct QH, cur, 1));
1283   - if (cur->qh_overlay.qt_token & 0x80) {
  1289 + if (cur->qh_overlay.qt_token & cpu_to_hc32(0x80)) {
1284 1290 debug("Exit poll_int_queue with no completed intr transfer. "
1285 1291 "token is %x\n", cur->qh_overlay.qt_token);
1286 1292 return NULL;
... ... @@ -1311,7 +1317,7 @@
1311 1317  
1312 1318 struct QH *cur = &ctrl->periodic_queue;
1313 1319 timeout = get_timer(0) + 500; /* abort after 500ms */
1314   - while (!(cur->qh_link & QH_LINK_TERMINATE)) {
  1320 + while (!(cur->qh_link & cpu_to_hc32(QH_LINK_TERMINATE))) {
1315 1321 debug("considering %p, with qh_link %x\n", cur, cur->qh_link);
1316 1322 if (NEXT_QH(cur) == queue->first) {
1317 1323 debug("found candidate. removing from chain\n");