atrtc.c (d6c180505a1ad3c92704a745e10ca6ef3a422488) atrtc.c (91751b1a868d2a9e01e3fa7a89e5db41295e32e2)
1/*-
2 * Copyright (c) 2008 Poul-Henning Kamp
3 * Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 230 unchanged lines hidden (view full) ---

239 }
240 return (result);
241}
242
243static int
244atrtc_attach(device_t dev)
245{
246 struct atrtc_softc *sc;
1/*-
2 * Copyright (c) 2008 Poul-Henning Kamp
3 * Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 230 unchanged lines hidden (view full) ---

239 }
240 return (result);
241}
242
243static int
244atrtc_attach(device_t dev)
245{
246 struct atrtc_softc *sc;
247 u_long s;
247 int i, diag;
248
249 sc = device_get_softc(dev);
250 if (!(sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
251 &sc->port_rid, IO_RTC, IO_RTC + 1, 2, RF_ACTIVE)))
252 device_printf(dev,"Warning: Couldn't map I/O.\n");
253 diag = rtcin(RTC_DIAG);
254 if (diag != 0)
255 printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
256 atrtc_start();
257 clock_register(dev, 1000000);
258 bzero(&sc->et, sizeof(struct eventtimer));
259 if (!atrtcclock_disable &&
260 (resource_int_value(device_get_name(dev), device_get_unit(dev),
261 "clock", &i) != 0 || i != 0)) {
262 sc->intr_rid = 0;
248 int i, diag;
249
250 sc = device_get_softc(dev);
251 if (!(sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
252 &sc->port_rid, IO_RTC, IO_RTC + 1, 2, RF_ACTIVE)))
253 device_printf(dev,"Warning: Couldn't map I/O.\n");
254 diag = rtcin(RTC_DIAG);
255 if (diag != 0)
256 printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
257 atrtc_start();
258 clock_register(dev, 1000000);
259 bzero(&sc->et, sizeof(struct eventtimer));
260 if (!atrtcclock_disable &&
261 (resource_int_value(device_get_name(dev), device_get_unit(dev),
262 "clock", &i) != 0 || i != 0)) {
263 sc->intr_rid = 0;
263 bus_delete_resource(dev, SYS_RES_IRQ, sc->intr_rid);
264 while (bus_get_resource(dev, SYS_RES_IRQ, sc->intr_rid,
265 &s, NULL) == 0 && s != 8)
266 sc->intr_rid++;
264 if (!(sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ,
265 &sc->intr_rid, 8, 8, 1, RF_ACTIVE))) {
266 device_printf(dev,"Can't map interrupt.\n");
267 return (0);
268 } else if ((bus_setup_intr(dev, sc->intr_res,
269 INTR_MPSAFE | INTR_TYPE_CLK,
270 (driver_filter_t *)rtc_intr, NULL,
271 sc, &sc->intr_handler))) {

--- 131 unchanged lines hidden ---
267 if (!(sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ,
268 &sc->intr_rid, 8, 8, 1, RF_ACTIVE))) {
269 device_printf(dev,"Can't map interrupt.\n");
270 return (0);
271 } else if ((bus_setup_intr(dev, sc->intr_res,
272 INTR_MPSAFE | INTR_TYPE_CLK,
273 (driver_filter_t *)rtc_intr, NULL,
274 sc, &sc->intr_handler))) {

--- 131 unchanged lines hidden ---