Changeset f123909 in mainline for uspace/drv/uhci-rhd/port.c
- Timestamp:
- 2011-03-13T23:10:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3bd96bb
- Parents:
- a9f91cd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/port.c
ra9f91cd rf123909 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb28 /** @addtogroup drvusbuhcirh 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver 33 */ 32 * @brief UHCI root hub port routines 33 */ 34 #include <libarch/ddi.h> /* pio_read and pio_write */ 34 35 #include <errno.h> 35 36 #include <str_error.h> … … 37 38 38 39 #include <usb/usb.h> /* usb_address_t */ 39 #include <usb/usbdevice.h>40 40 #include <usb/hub.h> 41 #include <usb/request.h>42 41 #include <usb/debug.h> 43 #include <usb/recognise.h>44 42 45 43 #include "port.h" … … 50 48 static int uhci_port_check(void *port); 51 49 static int uhci_port_reset_enable(int portno, void *arg); 52 /*----------------------------------------------------------------------------*/ 53 /** Initializes UHCI root hub port instance. 50 static void uhci_port_print_status( 51 uhci_port_t *port, const port_status_t value); 52 53 /** Register reading helper function. 54 * 55 * @param[in] port Structure to use. 56 * @return Error code. (Always EOK) 57 */ 58 static inline port_status_t uhci_port_read_status(uhci_port_t *port) 59 { 60 assert(port); 61 return pio_read_16(port->address); 62 } 63 /*----------------------------------------------------------------------------*/ 64 /** Register writing helper function. 65 * 66 * @param[in] port Structure to use. 67 * @param[in] value New register value. 68 * @return Error code. (Always EOK) 69 */ 70 static inline void uhci_port_write_status( 71 uhci_port_t *port, port_status_t value) 72 { 73 assert(port); 74 pio_write_16(port->address, value); 75 } 76 77 /*----------------------------------------------------------------------------*/ 78 /** Initialize UHCI root hub port instance. 54 79 * 55 80 * @param[in] port Memory structure to use. … … 60 85 * @return Error code. 61 86 * 62 * Starts the polling fibril.87 * Creates and starts the polling fibril. 63 88 */ 64 89 int uhci_port_init(uhci_port_t *port, … … 86 111 port->checker = fibril_create(uhci_port_check, port); 87 112 if (port->checker == 0) { 88 usb_log_error(" Port(%p - %d): failed to launch root hubfibril.",89 port-> address, port->number);113 usb_log_error("%s: failed to create polling fibril.", 114 port->id_string); 90 115 return ENOMEM; 91 116 } 92 117 93 118 fibril_add_ready(port->checker); 94 usb_log_debug(" Port(%p - %d): Added fibril. %x\n",95 port-> address, port->number, port->checker);96 return EOK; 97 } 98 /*----------------------------------------------------------------------------*/ 99 /** FinishesUHCI root hub port instance.119 usb_log_debug("%s: Started polling fibril(%x).\n", 120 port->id_string, port->checker); 121 return EOK; 122 } 123 /*----------------------------------------------------------------------------*/ 124 /** Cleanup UHCI root hub port instance. 100 125 * 101 126 * @param[in] port Memory structure to use. … … 105 130 void uhci_port_fini(uhci_port_t *port) 106 131 { 132 assert(port); 133 free(port->id_string); 107 134 /* TODO: Kill fibril here */ 108 135 return; … … 111 138 /** Periodically checks port status and reports new devices. 112 139 * 113 * @param[in] port Memorystructure to use.140 * @param[in] port Port structure to use. 114 141 * @return Error code. 115 142 */ … … 122 149 async_usleep(instance->wait_period_usec); 123 150 124 /* read register value */151 /* Read register value */ 125 152 port_status_t port_status = uhci_port_read_status(instance); 126 153 127 /* print the value if it's interesting */154 /* Print the value if it's interesting */ 128 155 if (port_status & ~STATUS_ALWAYS_ONE) 129 156 uhci_port_print_status(instance, port_status); … … 177 204 * @param arg Pointer to uhci_port_t of port with the new device. 178 205 * @return Error code. 206 * 207 * Resets and enables the ub port. 179 208 */ 180 209 int uhci_port_reset_enable(int portno, void *arg) … … 214 243 } 215 244 /*----------------------------------------------------------------------------*/ 216 /** Initialize s and reportsconnected device.217 * 218 * @param[in] port Memorystructure to use.245 /** Initialize and report connected device. 246 * 247 * @param[in] port Port structure to use. 219 248 * @param[in] speed Detected speed. 220 249 * @return Error code. … … 247 276 } 248 277 /*----------------------------------------------------------------------------*/ 249 /** Remove sdevice.278 /** Remove device. 250 279 * 251 280 * @param[in] port Memory structure to use. 252 281 * @return Error code. 253 282 * 254 * Does not work DDF does not support device removal. 283 * Does not work, DDF does not support device removal. 284 * Does not even free used USB address (it would be dangerous if tis driver 285 * is still running). 255 286 */ 256 287 int uhci_port_remove_device(uhci_port_t *port) … … 261 292 } 262 293 /*----------------------------------------------------------------------------*/ 263 /** Enables and disables port. 264 * 265 * @param[in] port Memory structure to use. 294 /** Enable or disable root hub port. 295 * 296 * @param[in] port Port structure to use. 297 * @param[in] enabled Port status to set. 266 298 * @return Error code. (Always EOK) 267 299 */ … … 288 320 } 289 321 /*----------------------------------------------------------------------------*/ 322 /** Print the port status value in a human friendly way 323 * 324 * @param[in] port Port structure to use. 325 * @param[in] value Port register value to print. 326 * @return Error code. (Always EOK) 327 */ 328 void uhci_port_print_status(uhci_port_t *port, const port_status_t value) 329 { 330 assert(port); 331 usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n", 332 port->id_string, value, 333 (value & STATUS_SUSPEND) ? " SUSPENDED," : "", 334 (value & STATUS_RESUME) ? " IN RESUME," : "", 335 (value & STATUS_IN_RESET) ? " IN RESET," : "", 336 (value & STATUS_LINE_D_MINUS) ? " VD-," : "", 337 (value & STATUS_LINE_D_PLUS) ? " VD+," : "", 338 (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "", 339 (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "", 340 (value & STATUS_ENABLED) ? " ENABLED," : "", 341 (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "", 342 (value & STATUS_CONNECTED) ? " CONNECTED," : "", 343 (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE" 344 ); 345 } 290 346 /** 291 347 * @}
Note:
See TracChangeset
for help on using the changeset viewer.