MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tsadc_attach

Function tsadc_attach

freebsd/arm64/rockchip/rk_tsadc.c:611–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609}
610
611static int
612tsadc_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);

Callers

nothing calls this directly

Calls 13

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
bus_setup_intrFunction · 0.85
tsadc_initFunction · 0.85
tsadc_init_tsensorFunction · 0.85
tsadc_init_sysctlFunction · 0.85
bus_generic_attachFunction · 0.85
sysctl_ctx_freeFunction · 0.85
bus_teardown_intrFunction · 0.85
bus_release_resourceFunction · 0.85
RD4Function · 0.50

Tested by

no test coverage detected