Lines Matching +full:adc +full:- +full:dev
1 /*-
40 #include <dev/syscon/syscon.h>
54 device_t dev; in am335x_scm_temp_sysctl() local
59 dev = (device_t)arg1; in am335x_scm_temp_sysctl()
60 sc = device_get_softc(dev); in am335x_scm_temp_sysctl()
63 for(i = 50; i > 0; i--) { in am335x_scm_temp_sysctl()
64 reg = SYSCON_READ_4(sc->syscon, SCM_BGAP_CTRL); in am335x_scm_temp_sysctl()
70 sc->sc_last_temp = in am335x_scm_temp_sysctl()
72 sc->sc_last_temp *= 10; in am335x_scm_temp_sysctl()
74 temp = sc->sc_last_temp + TZ_ZEROC; in am335x_scm_temp_sysctl()
98 am335x_scm_probe(device_t dev) in am335x_scm_probe() argument
101 if (strcmp(device_get_nameunit(dev), "am335x_scm0") != 0) in am335x_scm_probe()
104 device_set_desc(dev, "AM335x Control Module Extension"); in am335x_scm_probe()
110 am335x_scm_attach(device_t dev) in am335x_scm_attach() argument
119 sc = device_get_softc(dev); in am335x_scm_attach()
121 /* FIXME: For now; Go and kidnap syscon from opp-table */ in am335x_scm_attach()
122 opp_table = OF_finddevice("/opp-table"); in am335x_scm_attach()
123 if (opp_table == -1) { in am335x_scm_attach()
124 device_printf(dev, "Cant find /opp-table\n"); in am335x_scm_attach()
128 device_printf(dev, "/opp-table missing syscon property\n"); in am335x_scm_attach()
131 err = syscon_get_by_ofw_property(dev, opp_table, "syscon", &sc->syscon); in am335x_scm_attach()
133 device_printf(dev, "Failed to get syscon\n"); in am335x_scm_attach()
138 SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, 0); in am335x_scm_attach()
139 reg = SYSCON_READ_4(sc->syscon, SCM_BGAP_CTRL); in am335x_scm_attach()
142 SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, SCM_BGAP_CONTCONV); in am335x_scm_attach()
143 reg = SYSCON_READ_4(sc->syscon, SCM_BGAP_CTRL); in am335x_scm_attach()
145 /* Start the ADC conversion. */ in am335x_scm_attach()
147 SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, reg); in am335x_scm_attach()
150 ctx = device_get_sysctl_ctx(dev); in am335x_scm_attach()
151 tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); in am335x_scm_attach()
152 sc->sc_temp_oid = SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, in am335x_scm_attach()
154 dev, 0, am335x_scm_temp_sysctl, "IK", "Current temperature"); in am335x_scm_attach()
160 am335x_scm_detach(device_t dev) in am335x_scm_detach() argument
164 sc = device_get_softc(dev); in am335x_scm_detach()
167 if (sc->sc_temp_oid != NULL) in am335x_scm_detach()
168 sysctl_remove_oid(sc->sc_temp_oid, 1, 0); in am335x_scm_detach()
170 /* Stop the bandgap ADC. */ in am335x_scm_detach()
171 SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, SCM_BGAP_BGOFF); in am335x_scm_detach()