| 205 | } |
| 206 | |
| 207 | static int |
| 208 | aw_rtc_attach(device_t dev) |
| 209 | { |
| 210 | struct aw_rtc_softc *sc = device_get_softc(dev); |
| 211 | uint32_t val; |
| 212 | int rid = 0; |
| 213 | |
| 214 | sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); |
| 215 | if (!sc->res) { |
| 216 | device_printf(dev, "could not allocate resources\n"); |
| 217 | return (ENXIO); |
| 218 | } |
| 219 | |
| 220 | sc->conf = (struct aw_rtc_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; |
| 221 | val = RTC_READ(sc, LOSC_CTRL_REG); |
| 222 | val |= LOSC_AUTO_SW_EN; |
| 223 | val |= LOSC_MAGIC | LOSC_GSM | LOSC_OSC_SRC; |
| 224 | RTC_WRITE(sc, LOSC_CTRL_REG, val); |
| 225 | |
| 226 | DELAY(100); |
| 227 | |
| 228 | if (bootverbose) { |
| 229 | val = RTC_READ(sc, sc->conf->rtc_losc_sta); |
| 230 | if ((val & LOSC_OSC_SRC) == 0) |
| 231 | device_printf(dev, "Using internal oscillator\n"); |
| 232 | else |
| 233 | device_printf(dev, "Using external oscillator\n"); |
| 234 | } |
| 235 | |
| 236 | aw_rtc_install_clocks(sc, dev); |
| 237 | |
| 238 | clock_register(dev, RTC_RES_US); |
| 239 | |
| 240 | return (0); |
| 241 | } |
| 242 | |
| 243 | static int |
| 244 | aw_rtc_detach(device_t dev) |
nothing calls this directly
no test coverage detected