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

Function ti_adc_attach

freebsd/arm/ti/ti_adc.c:747–915  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745}
746
747static int
748ti_adc_attach(device_t dev)
749{
750 int err, rid, i;
751 struct ti_adc_softc *sc;
752 uint32_t rev, reg;
753 phandle_t node, child;
754 pcell_t cell;
755 int *channels;
756 int nwire_configs;
757 int *wire_configs;
758
759 sc = device_get_softc(dev);
760 sc->sc_dev = dev;
761
762 node = ofw_bus_get_node(dev);
763
764 sc->sc_tsc_wires = 0;
765 sc->sc_coord_readouts = 1;
766 sc->sc_x_plate_resistance = 0;
767 sc->sc_charge_delay = DEFAULT_CHARGE_DELAY;
768 /* Read "tsc" node properties */
769 child = ofw_bus_find_child(node, "tsc");
770 if (child != 0 && OF_hasprop(child, "ti,wires")) {
771 if ((OF_getencprop(child, "ti,wires", &cell, sizeof(cell))) > 0)
772 sc->sc_tsc_wires = cell;
773 if ((OF_getencprop(child, "ti,coordinate-readouts", &cell,
774 sizeof(cell))) > 0)
775 sc->sc_coord_readouts = cell;
776 if ((OF_getencprop(child, "ti,x-plate-resistance", &cell,
777 sizeof(cell))) > 0)
778 sc->sc_x_plate_resistance = cell;
779 if ((OF_getencprop(child, "ti,charge-delay", &cell,
780 sizeof(cell))) > 0)
781 sc->sc_charge_delay = cell;
782 nwire_configs = OF_getencprop_alloc_multi(child,
783 "ti,wire-config", sizeof(*wire_configs),
784 (void **)&wire_configs);
785 if (nwire_configs != sc->sc_tsc_wires) {
786 device_printf(sc->sc_dev,
787 "invalid number of ti,wire-config: %d (should be %d)\n",
788 nwire_configs, sc->sc_tsc_wires);
789 OF_prop_free(wire_configs);
790 return (EINVAL);
791 }
792 err = ti_adc_config_wires(sc, wire_configs, nwire_configs);
793 OF_prop_free(wire_configs);
794 if (err)
795 return (EINVAL);
796 }
797
798 /* Read "adc" node properties */
799 child = ofw_bus_find_child(node, "adc");
800 if (child != 0) {
801 sc->sc_adc_nchannels = OF_getencprop_alloc_multi(child,
802 "ti,adc-channels", sizeof(*channels), (void **)&channels);
803 if (sc->sc_adc_nchannels > 0) {
804 for (i = 0; i < sc->sc_adc_nchannels; i++)

Callers

nothing calls this directly

Calls 15

device_get_softcFunction · 0.85
device_printfFunction · 0.85
ti_adc_config_wiresFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
ti_sysc_clock_enableFunction · 0.85
device_get_parentFunction · 0.85
bus_release_resourceFunction · 0.85
bus_setup_intrFunction · 0.85
ti_adc_idlestep_initFunction · 0.85
ti_adc_inputs_initFunction · 0.85
ti_adc_sysctl_initFunction · 0.85

Tested by

no test coverage detected