| 439 | } |
| 440 | |
| 441 | static int |
| 442 | atrtc_attach(device_t dev) |
| 443 | { |
| 444 | struct atrtc_softc *sc; |
| 445 | rman_res_t s; |
| 446 | int i; |
| 447 | |
| 448 | sc = device_get_softc(dev); |
| 449 | sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, |
| 450 | IO_RTC, IO_RTC + 1, 2, RF_ACTIVE); |
| 451 | if (sc->port_res == NULL) |
| 452 | device_printf(dev, "Warning: Couldn't map I/O.\n"); |
| 453 | atrtc_start(); |
| 454 | clock_register(dev, 1000000); |
| 455 | bzero(&sc->et, sizeof(struct eventtimer)); |
| 456 | if (!atrtcclock_disable && |
| 457 | (resource_int_value(device_get_name(dev), device_get_unit(dev), |
| 458 | "clock", &i) != 0 || i != 0)) { |
| 459 | sc->intr_rid = 0; |
| 460 | while (bus_get_resource(dev, SYS_RES_IRQ, sc->intr_rid, |
| 461 | &s, NULL) == 0 && s != 8) |
| 462 | sc->intr_rid++; |
| 463 | sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, |
| 464 | &sc->intr_rid, 8, 8, 1, RF_ACTIVE); |
| 465 | if (sc->intr_res == NULL) { |
| 466 | device_printf(dev, "Can't map interrupt.\n"); |
| 467 | return (0); |
| 468 | } else if ((bus_setup_intr(dev, sc->intr_res, INTR_TYPE_CLK, |
| 469 | rtc_intr, NULL, sc, &sc->intr_handler))) { |
| 470 | device_printf(dev, "Can't setup interrupt.\n"); |
| 471 | return (0); |
| 472 | } else { |
| 473 | /* Bind IRQ to BSP to avoid live migration. */ |
| 474 | bus_bind_intr(dev, sc->intr_res, 0); |
| 475 | } |
| 476 | sc->et.et_name = "RTC"; |
| 477 | sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_POW2DIV; |
| 478 | sc->et.et_quality = 0; |
| 479 | sc->et.et_frequency = 32768; |
| 480 | sc->et.et_min_period = 0x00080000; |
| 481 | sc->et.et_max_period = 0x80000000; |
| 482 | sc->et.et_start = rtc_start; |
| 483 | sc->et.et_stop = rtc_stop; |
| 484 | sc->et.et_priv = dev; |
| 485 | et_register(&sc->et); |
| 486 | } |
| 487 | return(0); |
| 488 | } |
| 489 | |
| 490 | static int |
| 491 | atrtc_isa_attach(device_t dev) |
no test coverage detected