xhci.c (229086) | xhci.c (230032) |
---|---|
1/*- 2 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 25 unchanged lines hidden (view full) --- 34 35/* 36 * A few words about the design implementation: This driver emulates 37 * the concept about TDs which is found in EHCI specification. This 38 * way we avoid too much diveration among USB drivers. 39 */ 40 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 25 unchanged lines hidden (view full) --- 34 35/* 36 * A few words about the design implementation: This driver emulates 37 * the concept about TDs which is found in EHCI specification. This 38 * way we avoid too much diveration among USB drivers. 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sys/dev/usb/controller/xhci.c 229086 2011-12-31 13:34:42Z hselasky $"); | 42__FBSDID("$FreeBSD: head/sys/dev/usb/controller/xhci.c 230032 2012-01-12 21:21:20Z hselasky $"); |
43 44#include <sys/stdint.h> 45#include <sys/stddef.h> 46#include <sys/param.h> 47#include <sys/queue.h> 48#include <sys/types.h> 49#include <sys/systm.h> 50#include <sys/kernel.h> --- 2155 unchanged lines hidden (view full) --- 2206{ 2207 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); 2208 struct usb_page_search buf_inp; 2209 struct usb_page_cache *pcinp; 2210 struct xhci_input_dev_ctx *pinp; 2211 struct usb_device *hubdev; 2212 uint32_t temp; 2213 uint32_t route; | 43 44#include <sys/stdint.h> 45#include <sys/stddef.h> 46#include <sys/param.h> 47#include <sys/queue.h> 48#include <sys/types.h> 49#include <sys/systm.h> 50#include <sys/kernel.h> --- 2155 unchanged lines hidden (view full) --- 2206{ 2207 struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); 2208 struct usb_page_search buf_inp; 2209 struct usb_page_cache *pcinp; 2210 struct xhci_input_dev_ctx *pinp; 2211 struct usb_device *hubdev; 2212 uint32_t temp; 2213 uint32_t route; |
2214 uint32_t rh_port; |
|
2214 uint8_t is_hub; 2215 uint8_t index; | 2215 uint8_t is_hub; 2216 uint8_t index; |
2216 uint8_t rh_port; | 2217 uint8_t depth; |
2217 2218 index = udev->controller_slot_id; 2219 2220 DPRINTF("index=%u\n", index); 2221 2222 pcinp = &sc->sc_hw.devs[index].input_pc; 2223 2224 usbd_get_page(pcinp, 0, &buf_inp); --- 5 unchanged lines hidden (view full) --- 2230 2231 /* figure out route string and root HUB port number */ 2232 2233 for (hubdev = udev; hubdev != NULL; hubdev = hubdev->parent_hub) { 2234 2235 if (hubdev->parent_hub == NULL) 2236 break; 2237 | 2218 2219 index = udev->controller_slot_id; 2220 2221 DPRINTF("index=%u\n", index); 2222 2223 pcinp = &sc->sc_hw.devs[index].input_pc; 2224 2225 usbd_get_page(pcinp, 0, &buf_inp); --- 5 unchanged lines hidden (view full) --- 2231 2232 /* figure out route string and root HUB port number */ 2233 2234 for (hubdev = udev; hubdev != NULL; hubdev = hubdev->parent_hub) { 2235 2236 if (hubdev->parent_hub == NULL) 2237 break; 2238 |
2239 depth = hubdev->parent_hub->depth; 2240 |
|
2238 /* 2239 * NOTE: HS/FS/LS devices and the SS root HUB can have 2240 * more than 15 ports 2241 */ 2242 2243 rh_port = hubdev->port_no; 2244 | 2241 /* 2242 * NOTE: HS/FS/LS devices and the SS root HUB can have 2243 * more than 15 ports 2244 */ 2245 2246 rh_port = hubdev->port_no; 2247 |
2245 if (hubdev->parent_hub->parent_hub == NULL) | 2248 if (depth == 0) |
2246 break; 2247 | 2249 break; 2250 |
2248 route *= 16; 2249 | |
2250 if (rh_port > 15) | 2251 if (rh_port > 15) |
2251 route |= 15; 2252 else 2253 route |= rh_port; | 2252 rh_port = 15; 2253 2254 if (depth < 6) 2255 route |= rh_port << (4 * (depth - 1)); |
2254 } 2255 | 2256 } 2257 |
2258 DPRINTF("Route=0x%08x\n", route); 2259 |
|
2256 temp = XHCI_SCTX_0_ROUTE_SET(route); 2257 2258 switch (sc->sc_hw.devs[index].state) { 2259 case XHCI_ST_CONFIGURED: 2260 temp |= XHCI_SCTX_0_CTX_NUM_SET(XHCI_MAX_ENDPOINTS - 1); 2261 break; 2262 default: 2263 temp = XHCI_SCTX_0_CTX_NUM_SET(1); --- 794 unchanged lines hidden (view full) --- 3058 3059 switch (value) { 3060 case UHF_C_BH_PORT_RESET: 3061 XWRITE4(sc, oper, port, v | XHCI_PS_WRC); 3062 break; 3063 case UHF_C_PORT_CONFIG_ERROR: 3064 XWRITE4(sc, oper, port, v | XHCI_PS_CEC); 3065 break; | 2260 temp = XHCI_SCTX_0_ROUTE_SET(route); 2261 2262 switch (sc->sc_hw.devs[index].state) { 2263 case XHCI_ST_CONFIGURED: 2264 temp |= XHCI_SCTX_0_CTX_NUM_SET(XHCI_MAX_ENDPOINTS - 1); 2265 break; 2266 default: 2267 temp = XHCI_SCTX_0_CTX_NUM_SET(1); --- 794 unchanged lines hidden (view full) --- 3062 3063 switch (value) { 3064 case UHF_C_BH_PORT_RESET: 3065 XWRITE4(sc, oper, port, v | XHCI_PS_WRC); 3066 break; 3067 case UHF_C_PORT_CONFIG_ERROR: 3068 XWRITE4(sc, oper, port, v | XHCI_PS_CEC); 3069 break; |
3070 case UHF_C_PORT_SUSPEND: |
|
3066 case UHF_C_PORT_LINK_STATE: 3067 XWRITE4(sc, oper, port, v | XHCI_PS_PLC); 3068 break; 3069 case UHF_C_PORT_CONNECTION: 3070 XWRITE4(sc, oper, port, v | XHCI_PS_CSC); 3071 break; 3072 case UHF_C_PORT_ENABLE: 3073 XWRITE4(sc, oper, port, v | XHCI_PS_PEC); --- 111 unchanged lines hidden (view full) --- 3185 i |= UPS_CURRENT_CONNECT_STATUS; 3186 if (v & XHCI_PS_PED) 3187 i |= UPS_PORT_ENABLED; 3188 if (v & XHCI_PS_OCA) 3189 i |= UPS_OVERCURRENT_INDICATOR; 3190 if (v & XHCI_PS_PR) 3191 i |= UPS_RESET; 3192 if (v & XHCI_PS_PP) | 3071 case UHF_C_PORT_LINK_STATE: 3072 XWRITE4(sc, oper, port, v | XHCI_PS_PLC); 3073 break; 3074 case UHF_C_PORT_CONNECTION: 3075 XWRITE4(sc, oper, port, v | XHCI_PS_CSC); 3076 break; 3077 case UHF_C_PORT_ENABLE: 3078 XWRITE4(sc, oper, port, v | XHCI_PS_PEC); --- 111 unchanged lines hidden (view full) --- 3190 i |= UPS_CURRENT_CONNECT_STATUS; 3191 if (v & XHCI_PS_PED) 3192 i |= UPS_PORT_ENABLED; 3193 if (v & XHCI_PS_OCA) 3194 i |= UPS_OVERCURRENT_INDICATOR; 3195 if (v & XHCI_PS_PR) 3196 i |= UPS_RESET; 3197 if (v & XHCI_PS_PP) |
3193 i |= UPS_PORT_POWER; | 3198 i |= UPS_PORT_POWER_SS; |
3194 USETW(sc->sc_hub_desc.ps.wPortStatus, i); 3195 3196 i = 0; 3197 if (v & XHCI_PS_CSC) 3198 i |= UPS_C_CONNECT_STATUS; 3199 if (v & XHCI_PS_PEC) 3200 i |= UPS_C_PORT_ENABLED; 3201 if (v & XHCI_PS_OCC) --- 734 unchanged lines hidden --- | 3199 USETW(sc->sc_hub_desc.ps.wPortStatus, i); 3200 3201 i = 0; 3202 if (v & XHCI_PS_CSC) 3203 i |= UPS_C_CONNECT_STATUS; 3204 if (v & XHCI_PS_PEC) 3205 i |= UPS_C_PORT_ENABLED; 3206 if (v & XHCI_PS_OCC) --- 734 unchanged lines hidden --- |