| 609 | } |
| 610 | |
| 611 | static int |
| 612 | tsadc_attach(device_t dev) |
| 613 | { |
| 614 | struct tsadc_softc *sc; |
| 615 | phandle_t node; |
| 616 | uint32_t val; |
| 617 | int i, rid, rv; |
| 618 | |
| 619 | sc = device_get_softc(dev); |
| 620 | sc->dev = dev; |
| 621 | node = ofw_bus_get_node(sc->dev); |
| 622 | sc->conf = (struct tsadc_conf *) |
| 623 | ofw_bus_search_compatible(dev, compat_data)->ocd_data; |
| 624 | sc->alarm_temp = 90000; |
| 625 | |
| 626 | rid = 0; |
| 627 | sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, |
| 628 | RF_ACTIVE); |
| 629 | if (sc->mem_res == NULL) { |
| 630 | device_printf(dev, "Cannot allocate memory resources\n"); |
| 631 | goto fail; |
| 632 | } |
| 633 | |
| 634 | rid = 0; |
| 635 | sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); |
| 636 | if (sc->irq_res == NULL) { |
| 637 | device_printf(dev, "Cannot allocate IRQ resources\n"); |
| 638 | goto fail; |
| 639 | } |
| 640 | |
| 641 | if ((bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, |
| 642 | tsadc_intr, NULL, sc, &sc->irq_ih))) { |
| 643 | device_printf(dev, |
| 644 | "WARNING: unable to register interrupt handler\n"); |
| 645 | goto fail; |
| 646 | } |
| 647 | |
| 648 | /* FDT resources */ |
| 649 | rv = hwreset_get_by_ofw_name(dev, 0, "tsadc-apb", &sc->hwreset); |
| 650 | if (rv != 0) { |
| 651 | device_printf(dev, "Cannot get 'tsadc-apb' reset\n"); |
| 652 | goto fail; |
| 653 | } |
| 654 | rv = clk_get_by_ofw_name(dev, 0, "tsadc", &sc->tsadc_clk); |
| 655 | if (rv != 0) { |
| 656 | device_printf(dev, "Cannot get 'tsadc' clock: %d\n", rv); |
| 657 | goto fail; |
| 658 | } |
| 659 | rv = clk_get_by_ofw_name(dev, 0, "apb_pclk", &sc->apb_pclk_clk); |
| 660 | if (rv != 0) { |
| 661 | device_printf(dev, "Cannot get 'apb_pclk' clock: %d\n", rv); |
| 662 | goto fail; |
| 663 | } |
| 664 | |
| 665 | /* grf is optional */ |
| 666 | rv = syscon_get_by_ofw_property(dev, node, "rockchip,grf", &sc->grf); |
| 667 | if (rv != 0 && rv != ENOENT) { |
| 668 | device_printf(dev, "Cannot get 'grf' syscon: %d\n", rv); |
nothing calls this directly
no test coverage detected