Index: sys/dev/cpufreq/cpufreq_dt.c =================================================================== --- sys/dev/cpufreq/cpufreq_dt.c +++ sys/dev/cpufreq/cpufreq_dt.c @@ -51,10 +51,10 @@ #include "cpufreq_if.h" -#if 0 -#define DEBUG(dev, msg...) device_printf(dev, "cpufreq_dt: " msg); +#ifdef DEBUG +#define DPRINTF(dev, msg...) device_printf(dev, "cpufreq_dt: " msg); #else -#define DEBUG(dev, msg...) +#define DPRINTF(dev, msg...) #endif enum opp_version { @@ -110,12 +110,12 @@ sc = device_get_softc(dev); - DEBUG(dev, "Looking for freq %ju\n", freq); + DPRINTF(dev, "Looking for freq %ju\n", freq); for (n = 0; n < sc->nopp; n++) if (CPUFREQ_CMP(sc->opp[n].freq, freq)) return (&sc->opp[n]); - DEBUG(dev, "Couldn't find one\n"); + DPRINTF(dev, "Couldn't find one\n"); return (NULL); } @@ -144,7 +144,7 @@ sc = device_get_softc(dev); - DEBUG(dev, "cpufreq_dt_get\n"); + DPRINTF(dev, "cpufreq_dt_get\n"); if (clk_get_freq(sc->clk, &freq) != 0) return (ENXIO); @@ -156,7 +156,7 @@ cpufreq_dt_opp_to_setting(dev, opp, set); - DEBUG(dev, "Current freq %dMhz\n", set->freq); + DPRINTF(dev, "Current freq %dMhz\n", set->freq); return (0); } @@ -170,10 +170,10 @@ sc = device_get_softc(dev); - DEBUG(dev, "Working on cpu %d\n", sc->cpu); - DEBUG(dev, "We have %d cpu on this dev\n", CPU_COUNT(&sc->cpus)); + DPRINTF(dev, "Working on cpu %d\n", sc->cpu); + DPRINTF(dev, "We have %d cpu on this dev\n", CPU_COUNT(&sc->cpus)); if (!CPU_ISSET(sc->cpu, &sc->cpus)) { - DEBUG(dev, "Not for this CPU\n"); + DPRINTF(dev, "Not for this CPU\n"); return (0); } @@ -205,26 +205,26 @@ device_printf(dev, "Couldn't find an opp for this freq\n"); return (EINVAL); } - DEBUG(sc->dev, "Current freq %ju, uvolt: %d\n", freq, uvolt); - DEBUG(sc->dev, "Target freq %ju, , uvolt: %d\n", + DPRINTF(sc->dev, "Current freq %ju, uvolt: %d\n", freq, uvolt); + DPRINTF(sc->dev, "Target freq %ju, , uvolt: %d\n", opp->freq, opp->uvolt_target); if (uvolt < opp->uvolt_target) { - DEBUG(dev, "Changing regulator from %u to %u\n", + DPRINTF(dev, "Changing regulator from %u to %u\n", uvolt, opp->uvolt_target); error = regulator_set_voltage(sc->reg, opp->uvolt_min, opp->uvolt_max); if (error != 0) { - DEBUG(dev, "Failed, backout\n"); + DPRINTF(dev, "Failed, backout\n"); return (ENXIO); } } - DEBUG(dev, "Setting clk to %ju\n", opp->freq); + DPRINTF(dev, "Setting clk to %ju\n", opp->freq); error = clk_set_freq(sc->clk, opp->freq, CLK_SET_ROUND_DOWN); if (error != 0) { - DEBUG(dev, "Failed, backout\n"); + DPRINTF(dev, "Failed, backout\n"); /* Restore previous voltage (best effort) */ error = regulator_set_voltage(sc->reg, copp->uvolt_min, @@ -233,13 +233,13 @@ } if (uvolt > opp->uvolt_target) { - DEBUG(dev, "Changing regulator from %u to %u\n", + DPRINTF(dev, "Changing regulator from %u to %u\n", uvolt, opp->uvolt_target); error = regulator_set_voltage(sc->reg, opp->uvolt_min, opp->uvolt_max); if (error != 0) { - DEBUG(dev, "Failed to switch regulator to %d\n", + DPRINTF(dev, "Failed to switch regulator to %d\n", opp->uvolt_target); /* Restore previous CPU frequency (best effort) */ (void)clk_set_freq(sc->clk, copp->freq, 0); @@ -270,7 +270,7 @@ struct cpufreq_dt_softc *sc; ssize_t n; - DEBUG(dev, "cpufreq_dt_settings\n"); + DPRINTF(dev, "cpufreq_dt_settings\n"); if (sets == NULL || count == NULL) return (EINVAL); @@ -464,7 +464,7 @@ node = ofw_bus_get_node(device_get_parent(dev)); sc->cpu = device_get_unit(device_get_parent(dev)); - DEBUG(dev, "cpu=%d\n", sc->cpu); + DPRINTF(dev, "cpu=%d\n", sc->cpu); if (sc->cpu >= mp_ncpus) { device_printf(dev, "Not attaching as cpu is not present\n"); return (ENXIO); @@ -518,12 +518,12 @@ if (strcmp(device_type, "cpu") != 0) continue; if (cpu == sc->cpu) { - DEBUG(dev, "Skipping our cpu\n"); + DPRINTF(dev, "Skipping our cpu\n"); CPU_SET(cpu, &sc->cpus); cpu++; continue; } - DEBUG(dev, "Testing CPU %d\n", cpu); + DPRINTF(dev, "Testing CPU %d\n", cpu); copp = -1; if (version == OPP_V1) OF_getencprop(cnode, "operating-points", &copp, @@ -532,7 +532,8 @@ OF_getencprop(cnode, "operating-points-v2", &copp, sizeof(copp)); if (opp == copp) { - DEBUG(dev, "CPU %d is using the same opp as this one (%d)\n", cpu, sc->cpu); + DPRINTF(dev, "CPU %d is using the same opp as this one (%d)\n", + cpu, sc->cpu); CPU_SET(cpu, &sc->cpus); } cpu++;