Changeset 43b4314 in mainline for uspace/srv/hw/netif/dp8390/dp8390.c
- Timestamp:
- 2011-01-10T23:22:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4fc2b3b
- Parents:
- abe95c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390.c
rabe95c9 r43b4314 81 81 82 82 /** NE2000 retry count */ 83 #define NE2K_RETRY 10083 #define NE2K_RETRY 0x1000 84 84 85 85 /** NE2000 error messages rate limiting */ … … 186 186 memcpy(&word, buf, 1); 187 187 pio_write_16(ne2k->data_port, word); 188 } 189 } 190 191 static void ne2k_init(ne2k_t *ne2k) 192 { 193 unsigned int i; 194 195 /* Reset the ethernet card */ 196 uint8_t val = pio_read_8(ne2k->port + NE2K_RESET); 197 usleep(2000); 198 pio_write_8(ne2k->port + NE2K_RESET, val); 199 usleep(2000); 200 201 /* Reset the DP8390 */ 202 pio_write_8(ne2k->port + DP_CR, CR_STP | CR_DM_ABORT); 203 for (i = 0; i < NE2K_RETRY; i++) { 204 if (pio_read_8(ne2k->port + DP_ISR) != 0) 205 break; 188 206 } 189 207 } … … 210 228 ne2k->up = false; 211 229 212 /* Reset the ethernet card */ 213 uint8_t val = pio_read_8(ne2k->port + NE2K_RESET); 214 usleep(2000); 215 pio_write_8(ne2k->port + NE2K_RESET, val); 216 usleep(2000); 217 218 /* Reset the DP8390 */ 219 pio_write_8(ne2k->port + DP_CR, CR_STP | CR_DM_ABORT); 220 for (i = 0; i < 0x1000; i++) { 221 if (pio_read_8(ne2k->port + DP_ISR) != 0) 222 break; 223 } 230 ne2k_init(ne2k); 224 231 225 232 /* Check if the DP8390 is really there */ 226 val = pio_read_8(ne2k->port + DP_CR);233 uint8_t val = pio_read_8(ne2k->port + DP_CR); 227 234 if ((val & (CR_STP | CR_DM_ABORT)) != (CR_STP | CR_DM_ABORT)) 228 235 return EXDEV; … … 242 249 for (i = 0; i < ETH_ADDR; i++) 243 250 ne2k->mac[i] = pio_read_16(ne2k->data_port); 251 252 ne2k->probed = true; 253 return EOK; 254 } 255 256 /** Start the network interface. 257 * 258 * @param[in,out] ne2k Network interface structure. 259 * 260 * @return EOK on success. 261 * @return EXDEV if the network interface is disabled. 262 * 263 */ 264 int ne2k_up(ne2k_t *ne2k) 265 { 266 if (!ne2k->probed) 267 return EXDEV; 268 269 ne2k_init(ne2k); 244 270 245 271 /* … … 329 355 330 356 /* Finish the initialization */ 331 ne2k->probed = true;332 return EOK;333 }334 335 /** Start the network interface.336 *337 * @param[in,out] ne2k Network interface structure.338 *339 * @return EOK on success.340 * @return EXDEV if the network interface is disabled.341 *342 */343 int ne2k_up(ne2k_t *ne2k)344 {345 if (!ne2k->probed)346 return EXDEV;347 348 pio_write_8(ne2k->port + DP_CR, CR_PS_P0 | CR_STA);349 pio_write_8(ne2k->port + DP_RCR, RCR_AB);350 351 357 ne2k->up = true; 352 358 return EOK; … … 362 368 if ((ne2k->probed) && (ne2k->up)) { 363 369 pio_write_8(ne2k->port + DP_CR, CR_STP | CR_DM_ABORT); 364 365 /* Reset the ethernet card */ 366 uint8_t val = pio_read_8(ne2k->port + NE2K_RESET); 367 usleep(2000); 368 pio_write_8(ne2k->port + NE2K_RESET, val); 369 370 ne2k_init(ne2k); 370 371 ne2k->up = false; 371 372 } … … 420 421 pio_write_8(ne2k->port + DP_RBCR1, 0); 421 422 422 for (i = 0; i < 0x1000; i++) {423 for (i = 0; i < NE2K_RETRY; i++) { 423 424 if ((pio_read_8(ne2k->port + DP_ISR) & ISR_RST) != 0) 424 425 break; … … 430 431 431 432 /* Acknowledge the ISR_RDC (remote DMA) interrupt */ 432 for (i = 0; i < 0x1000; i++) {433 for (i = 0; i < NE2K_RETRY; i++) { 433 434 if ((pio_read_8(ne2k->port + DP_ISR) & ISR_RDC) != 0) 434 435 break;
Note:
See TracChangeset
for help on using the changeset viewer.