Lines Matching +full:soc +full:- +full:lat

1 /*-
2 * Copyright (C) 2013-2015 Daisuke Aoyama <aoyama@peach.ne.jp>
71 #define MIN_OVER_VOLTAGE -16
73 #define MSG_ERROR -999999999
85 /* ARM->VC mailbox property semaphore */
115 { "broadcom,bcm2835-vc", 1 },
116 { "broadcom,bcm2708-vc", 1 },
176 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_clock_rate()
179 device_printf(sc->dev, "can't get clock rate (id=%u)\n", in bcm2835_cpufreq_get_clock_rate()
217 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_max_clock_rate()
220 device_printf(sc->dev, "can't get max clock rate (id=%u)\n", in bcm2835_cpufreq_get_max_clock_rate()
258 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_min_clock_rate()
261 device_printf(sc->dev, "can't get min clock rate (id=%u)\n", in bcm2835_cpufreq_get_min_clock_rate()
301 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_set_clock_rate()
304 device_printf(sc->dev, "can't set clock rate (id=%u)\n", in bcm2835_cpufreq_set_clock_rate()
325 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_set_clock_rate()
328 device_printf(sc->dev, in bcm2835_cpufreq_set_clock_rate()
366 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_turbo()
369 device_printf(sc->dev, "can't get turbo\n"); in bcm2835_cpufreq_get_turbo()
373 /* result 0=non-turbo, 1=turbo */ in bcm2835_cpufreq_get_turbo()
412 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_set_turbo()
415 device_printf(sc->dev, "can't set turbo\n"); in bcm2835_cpufreq_set_turbo()
419 /* result 0=non-turbo, 1=turbo */ in bcm2835_cpufreq_set_turbo()
452 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_voltage()
455 device_printf(sc->dev, "can't get voltage\n"); in bcm2835_cpufreq_get_voltage()
492 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_max_voltage()
495 device_printf(sc->dev, "can't get max voltage\n"); in bcm2835_cpufreq_get_max_voltage()
531 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_min_voltage()
534 device_printf(sc->dev, "can't get min voltage\n"); in bcm2835_cpufreq_get_min_voltage()
573 device_printf(sc->dev, "not supported voltage: %d\n", value); in bcm2835_cpufreq_set_voltage()
583 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_set_voltage()
586 device_printf(sc->dev, "can't set voltage\n"); in bcm2835_cpufreq_set_voltage()
622 err = bcm2835_firmware_property(sc->firmware, in bcm2835_cpufreq_get_temperature()
625 device_printf(sc->dev, "can't get temperature\n"); in bcm2835_cpufreq_get_temperature()
650 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_arm_freq()
659 device_printf(sc->dev, "set clock arm_freq error\n"); in sysctl_bcm2835_cpufreq_arm_freq()
683 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_core_freq()
692 device_printf(sc->dev, "set clock core_freq error\n"); in sysctl_bcm2835_cpufreq_core_freq()
717 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_sdram_freq()
726 device_printf(sc->dev, "set clock sdram_freq error\n"); in sysctl_bcm2835_cpufreq_sdram_freq()
749 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_turbo()
754 sc->turbo_mode = BCM2835_FIRMWARE_TURBO_ON; in sysctl_bcm2835_cpufreq_turbo()
756 sc->turbo_mode = BCM2835_FIRMWARE_TURBO_OFF; in sysctl_bcm2835_cpufreq_turbo()
759 err = bcm2835_cpufreq_set_turbo(sc, sc->turbo_mode); in sysctl_bcm2835_cpufreq_turbo()
762 device_printf(sc->dev, "set turbo error\n"); in sysctl_bcm2835_cpufreq_turbo()
785 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_voltage_core()
791 sc->voltage_core = val; in sysctl_bcm2835_cpufreq_voltage_core()
795 sc->voltage_core); in sysctl_bcm2835_cpufreq_voltage_core()
798 device_printf(sc->dev, "set voltage core error\n"); in sysctl_bcm2835_cpufreq_voltage_core()
822 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_voltage_sdram_c()
828 sc->voltage_sdram_c = val; in sysctl_bcm2835_cpufreq_voltage_sdram_c()
833 sc->voltage_sdram_c); in sysctl_bcm2835_cpufreq_voltage_sdram_c()
836 device_printf(sc->dev, "set voltage sdram_c error\n"); in sysctl_bcm2835_cpufreq_voltage_sdram_c()
860 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_voltage_sdram_i()
866 sc->voltage_sdram_i = val; in sysctl_bcm2835_cpufreq_voltage_sdram_i()
870 BCM2835_FIRMWARE_VOLTAGE_ID_SDRAM_I, sc->voltage_sdram_i); in sysctl_bcm2835_cpufreq_voltage_sdram_i()
873 device_printf(sc->dev, "set voltage sdram_i error\n"); in sysctl_bcm2835_cpufreq_voltage_sdram_i()
897 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_voltage_sdram_p()
903 sc->voltage_sdram_p = val; in sysctl_bcm2835_cpufreq_voltage_sdram_p()
907 BCM2835_FIRMWARE_VOLTAGE_ID_SDRAM_P, sc->voltage_sdram_p); in sysctl_bcm2835_cpufreq_voltage_sdram_p()
910 device_printf(sc->dev, "set voltage sdram_p error\n"); in sysctl_bcm2835_cpufreq_voltage_sdram_p()
926 if (!req->newptr) in sysctl_bcm2835_cpufreq_voltage_sdram()
936 sc->voltage_sdram = val; in sysctl_bcm2835_cpufreq_voltage_sdram()
943 device_printf(sc->dev, "set voltage sdram_c error\n"); in sysctl_bcm2835_cpufreq_voltage_sdram()
950 device_printf(sc->dev, "set voltage sdram_i error\n"); in sysctl_bcm2835_cpufreq_voltage_sdram()
957 device_printf(sc->dev, "set voltage sdram_p error\n"); in sysctl_bcm2835_cpufreq_voltage_sdram()
981 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_cpufreq_temperature()
1006 if (err || !req->newptr) /* error || read request */ in sysctl_bcm2835_devcpu_temperature()
1056 sc->turbo_mode = BCM2835_FIRMWARE_TURBO_ON; in bcm2835_cpufreq_init()
1058 sc->turbo_mode = BCM2835_FIRMWARE_TURBO_OFF; in bcm2835_cpufreq_init()
1071 sc->voltage_core = voltage_core; in bcm2835_cpufreq_init()
1072 sc->voltage_sdram = voltage_sdram_c; in bcm2835_cpufreq_init()
1073 sc->voltage_sdram_c = voltage_sdram_c; in bcm2835_cpufreq_init()
1074 sc->voltage_sdram_i = voltage_sdram_i; in bcm2835_cpufreq_init()
1075 sc->voltage_sdram_p = voltage_sdram_p; in bcm2835_cpufreq_init()
1100 device_printf(sc->dev, "Boot settings:\n"); in bcm2835_cpufreq_init()
1101 device_printf(sc->dev, in bcm2835_cpufreq_init()
1104 (sc->turbo_mode == BCM2835_FIRMWARE_TURBO_ON) ? "ON":"OFF"); in bcm2835_cpufreq_init()
1106 device_printf(sc->dev, in bcm2835_cpufreq_init()
1112 device_printf(sc->dev, in bcm2835_cpufreq_init()
1119 device_printf(sc->dev, in bcm2835_cpufreq_init()
1131 device_printf(sc->dev, in bcm2835_cpufreq_init()
1135 device_printf(sc->dev, in bcm2835_cpufreq_init()
1138 (sc->turbo_mode == BCM2835_FIRMWARE_TURBO_ON) ? "ON":"OFF"); in bcm2835_cpufreq_init()
1142 sc->arm_max_freq = HZ2MHZ(arm_max_freq); in bcm2835_cpufreq_init()
1143 sc->arm_min_freq = HZ2MHZ(arm_min_freq); in bcm2835_cpufreq_init()
1144 sc->core_max_freq = HZ2MHZ(core_max_freq); in bcm2835_cpufreq_init()
1145 sc->core_min_freq = HZ2MHZ(core_min_freq); in bcm2835_cpufreq_init()
1146 sc->sdram_max_freq = HZ2MHZ(sdram_max_freq); in bcm2835_cpufreq_init()
1147 sc->sdram_min_freq = HZ2MHZ(sdram_min_freq); in bcm2835_cpufreq_init()
1148 sc->max_voltage_core = OFFSET2MVOLT(max_voltage_core); in bcm2835_cpufreq_init()
1149 sc->min_voltage_core = OFFSET2MVOLT(min_voltage_core); in bcm2835_cpufreq_init()
1152 if (sc->turbo_mode == BCM2835_FIRMWARE_TURBO_ON) { in bcm2835_cpufreq_init()
1177 cpu = device_get_parent(sc->dev); in bcm2835_cpufreq_init()
1185 "Current SoC temperature"); in bcm2835_cpufreq_init()
1189 config_intrhook_disestablish(&sc->init_hook); in bcm2835_cpufreq_init()
1199 for (compat = compat_data; compat->ocd_str != NULL; compat++) in bcm2835_cpufreq_identify()
1200 if (ofw_bus_node_is_compatible(root, compat->ocd_str)) in bcm2835_cpufreq_identify()
1203 if (compat->ocd_data == 0) in bcm2835_cpufreq_identify()
1207 if (device_find_child(parent, "bcm2835_cpufreq", -1) != NULL) in bcm2835_cpufreq_identify()
1209 if (BUS_ADD_CHILD(parent, 0, "bcm2835_cpufreq", -1) == NULL) in bcm2835_cpufreq_identify()
1232 sc->dev = dev; in bcm2835_cpufreq_attach()
1233 sc->firmware = devclass_get_device( in bcm2835_cpufreq_attach()
1235 if (sc->firmware == NULL) { in bcm2835_cpufreq_attach()
1241 sc->arm_max_freq = -1; in bcm2835_cpufreq_attach()
1242 sc->arm_min_freq = -1; in bcm2835_cpufreq_attach()
1243 sc->core_max_freq = -1; in bcm2835_cpufreq_attach()
1244 sc->core_min_freq = -1; in bcm2835_cpufreq_attach()
1245 sc->sdram_max_freq = -1; in bcm2835_cpufreq_attach()
1246 sc->sdram_min_freq = -1; in bcm2835_cpufreq_attach()
1247 sc->max_voltage_core = 0; in bcm2835_cpufreq_attach()
1248 sc->min_voltage_core = 0; in bcm2835_cpufreq_attach()
1318 "SoC temperature (thousandths of a degree C)"); in bcm2835_cpufreq_attach()
1321 /* ARM->VC lock */ in bcm2835_cpufreq_attach()
1325 sc->init_hook.ich_func = bcm2835_cpufreq_init; in bcm2835_cpufreq_attach()
1326 sc->init_hook.ich_arg = sc; in bcm2835_cpufreq_attach()
1328 if (config_intrhook_establish(&sc->init_hook) != 0) { in bcm2835_cpufreq_attach()
1358 if (cf == NULL || cf->freq < 0) in bcm2835_cpufreq_set()
1364 rate_hz = (uint32_t)MHZ2HZ(cf->freq); in bcm2835_cpufreq_set()
1366 rate_hz -= rem; in bcm2835_cpufreq_set()
1371 min_freq = sc->arm_min_freq; in bcm2835_cpufreq_set()
1372 if (sc->turbo_mode != BCM2835_FIRMWARE_TURBO_ON) in bcm2835_cpufreq_set()
1376 if (rate_hz < MHZ2HZ(min_freq) || rate_hz > MHZ2HZ(sc->arm_max_freq)) in bcm2835_cpufreq_set()
1392 * if non-turbo and lower than or equal min_freq, in bcm2835_cpufreq_set()
1395 if (sc->turbo_mode != BCM2835_FIRMWARE_TURBO_ON) { in bcm2835_cpufreq_set()
1398 if (rate_hz > MHZ2HZ(sc->arm_min_freq)) { in bcm2835_cpufreq_set()
1401 MHZ2HZ(sc->core_max_freq)); in bcm2835_cpufreq_set()
1405 MHZ2HZ(sc->sdram_max_freq)); in bcm2835_cpufreq_set()
1408 if (sc->core_min_freq < DEFAULT_CORE_FREQUENCY && in bcm2835_cpufreq_set()
1423 MHZ2HZ(sc->core_min_freq)); in bcm2835_cpufreq_set()
1427 MHZ2HZ(sc->sdram_min_freq)); in bcm2835_cpufreq_set()
1438 DPRINTF("cpufreq: %d -> %d\n", cur_freq, arm_freq); in bcm2835_cpufreq_set()
1454 cf->dev = NULL; in bcm2835_cpufreq_get()
1467 cf->freq = HZ2MHZ(arm_freq); in bcm2835_cpufreq_get()
1469 cf->volts = CPUFREQ_VAL_UNKNOWN; in bcm2835_cpufreq_get()
1471 cf->power = CPUFREQ_VAL_UNKNOWN; in bcm2835_cpufreq_get()
1473 cf->lat = TRANSITION_LATENCY; in bcm2835_cpufreq_get()
1475 cf->dev = dev; in bcm2835_cpufreq_get()
1489 freq = sc->arm_max_freq; in bcm2835_cpufreq_make_freq_list()
1490 min_freq = sc->arm_min_freq; in bcm2835_cpufreq_make_freq_list()
1494 freq -= rem; in bcm2835_cpufreq_make_freq_list()
1498 /* if non-turbo, add extra low freq */ in bcm2835_cpufreq_make_freq_list()
1499 if (sc->turbo_mode != BCM2835_FIRMWARE_TURBO_ON) in bcm2835_cpufreq_make_freq_list()
1505 volts = sc->min_voltage_core; in bcm2835_cpufreq_make_freq_list()
1508 sets[idx].lat = TRANSITION_LATENCY; in bcm2835_cpufreq_make_freq_list()
1514 sets[idx].lat = TRANSITION_LATENCY; in bcm2835_cpufreq_make_freq_list()
1532 if (sc->arm_min_freq < 0 || sc->arm_max_freq < 0) { in bcm2835_cpufreq_settings()