Lines Matching +full:qoriq +full:- +full:tmu

1 /*-
3 * SPDX-License-Identifier: BSD-2-Clause
31 * Thermometer driver for QorIQ SoCs.
116 { 0, "cpu-thermal", 0 },
121 { 0, "ddr-controller", 0 },
122 { 1, "core-cluster", 1 },
127 { 0, "ddr-controller", 0 },
130 { 3, "core-cluster", 3 },
135 { 0, "ddr-controller", 0 },
138 { 3, "core-cluster", 3 },
144 { 0, "core-cluster", 0 },
148 /* Note: tmu[1..7] not [0..6]. */
151 { 1, "ddr-controller1", 0 },
152 { 2, "ddr-controller2", 1 },
153 { 3, "ddr-controller3", 2 },
154 { 4, "core-cluster1", 3 },
155 { 5, "core-cluster2", 4 },
156 { 6, "core-cluster3", 5 },
157 { 7, "core-cluster4", 6 },
162 { 0, "cluster6-7", 0 },
163 { 1, "ddr-cluster5", 1 },
165 { 3, "dce-qbman-hsio2", 3 },
166 { 4, "ccn-dpaa-tbu", 4 },
167 { 5, "cluster4-hsio3", 5 },
168 { 6, "cluster2-3", 6 },
190 {"fsl,qoriq-tmu", 1},
191 {"fsl,imx8mq-tmu", 1},
199 val = sc->little_endian ? htole32(val): htobe32(val); in WR4()
200 bus_write_4(sc->mem_res, addr, val); in WR4()
208 val = bus_read_4(sc->mem_res, addr); in RD4()
209 return (sc->little_endian ? le32toh(val): be32toh(val)); in RD4()
220 for (timeout = 1000; timeout > 0; timeout--) { in qoriq_therm_read_temp()
221 val = RD4(sc, TMU_TRITSR(sensor->site_id)); in qoriq_therm_read_temp()
227 device_printf(sc->dev, "Sensor %s timeouted\n", sensor->name); in qoriq_therm_read_temp()
230 if (sc->ver == 1) in qoriq_therm_read_temp()
233 *temp = (int)(val & 0x1FF) * 1000 - 273100; in qoriq_therm_read_temp()
244 if (id >= sc->ntsensors) in qoriq_therm_get_temp()
246 return(qoriq_therm_read_temp(sc, sc->tsensors + id, val)); in qoriq_therm_get_temp()
258 if (req->newptr != NULL) in qoriq_therm_sysctl_temperature()
264 if (id >= sc->ntsensors) in qoriq_therm_sysctl_temperature()
266 rv = qoriq_therm_read_temp(sc, sc->tsensors + id, &val); in qoriq_therm_sysctl_temperature()
290 for (i = sc->ntsensors - 1; i >= 0; i--) { in qoriq_therm_init_sysctl()
292 SYSCTL_CHILDREN(oid), OID_AUTO, sc->tsensors[i].name, in qoriq_therm_init_sysctl()
308 nranges = OF_getencprop_alloc_multi(node, "fsl,tmu-range", in qoriq_therm_fdt_calib()
311 device_printf(sc->dev, "Invalid 'tmu-range' property\n"); in qoriq_therm_fdt_calib()
319 ncalibs = OF_getencprop_alloc_multi(node, "fsl,tmu-calibration", in qoriq_therm_fdt_calib()
322 device_printf(sc->dev, "Invalid 'tmu-calibration' property\n"); in qoriq_therm_fdt_calib()
340 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in qoriq_therm_probe()
343 device_set_desc(dev, "QorIQ temperature sensors"); in qoriq_therm_probe()
357 sc->dev = dev; in qoriq_therm_attach()
358 node = ofw_bus_get_node(sc->dev); in qoriq_therm_attach()
359 sc->little_endian = OF_hasprop(node, "little-endian"); in qoriq_therm_attach()
364 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in qoriq_therm_attach()
366 if (sc->mem_res == NULL) { in qoriq_therm_attach()
372 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); in qoriq_therm_attach()
373 if (sc->irq_res == NULL) { in qoriq_therm_attach()
379 if ((bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, in qoriq_therm_attach()
380 qoriq_therm_intr, NULL, sc, &sc->irq_ih))) { in qoriq_therm_attach()
386 rv = clk_get_by_ofw_index(dev, 0, 0, &sc->clk); in qoriq_therm_attach()
391 if (sc->clk != NULL) { in qoriq_therm_attach()
392 rv = clk_enable(sc->clk); in qoriq_therm_attach()
399 sc->ver = (RD4(sc, TMU_VERSION) >> 8) & 0xFF; in qoriq_therm_attach()
408 while (soc != NULL && soc->name != NULL) { in qoriq_therm_attach()
409 if (ofw_bus_node_is_compatible(root, soc->name)) in qoriq_therm_attach()
415 sc->tsensors = default_sensors; in qoriq_therm_attach()
416 sc->ntsensors = nitems(default_sensors); in qoriq_therm_attach()
418 sc->tsensors = soc->tsensors; in qoriq_therm_attach()
419 sc->ntsensors = soc->ntsensors; in qoriq_therm_attach()
430 if (sc->ver == 1) { in qoriq_therm_attach()
436 for (int i = 0; i < sc->ntsensors; i++) in qoriq_therm_attach()
437 WR4(sc, TMUV2_TMSAR(sc->tsensors[i].site_id), 0xE); in qoriq_therm_attach()
443 device_printf(sc->dev, in qoriq_therm_attach()
449 if (sc->ver == 1) { in qoriq_therm_attach()
450 for (int i = 0; i < sc->ntsensors; i++) in qoriq_therm_attach()
451 sites |= 1 << (15 - sc->tsensors[i].site_id); in qoriq_therm_attach()
454 for (int i = 0; i < sc->ntsensors; i++) in qoriq_therm_attach()
455 sites |= 1 << sc->tsensors[i].site_id; in qoriq_therm_attach()
462 device_printf(sc->dev, "Cannot initialize sysctls\n"); in qoriq_therm_attach()
471 if (sc->irq_ih != NULL) in qoriq_therm_attach()
472 bus_teardown_intr(dev, sc->irq_res, sc->irq_ih); in qoriq_therm_attach()
474 if (sc->clk != NULL) in qoriq_therm_attach()
475 clk_release(sc->clk); in qoriq_therm_attach()
476 if (sc->irq_res != NULL) in qoriq_therm_attach()
477 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); in qoriq_therm_attach()
478 if (sc->mem_res != NULL) in qoriq_therm_attach()
479 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); in qoriq_therm_attach()
490 if (sc->irq_ih != NULL) in qoriq_therm_detach()
491 bus_teardown_intr(dev, sc->irq_res, sc->irq_ih); in qoriq_therm_detach()
493 if (sc->clk != NULL) in qoriq_therm_detach()
494 clk_release(sc->clk); in qoriq_therm_detach()
495 if (sc->irq_res != NULL) in qoriq_therm_detach()
496 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res); in qoriq_therm_detach()
497 if (sc->mem_res != NULL) in qoriq_therm_detach()
498 bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); in qoriq_therm_detach()