cpufreq_dt.c (e213223c9b89a79738823f719b3d6285049f8393) cpufreq_dt.c (4b23e1e53ab4774e8e0f002ffc4402ae683c98c1)
1/*-
2 * Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.Org>
3 * Copyright (c) 2016 Jared McNeill <jmcneill@invisible.ca>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 432 unchanged lines hidden (view full) ---

441}
442
443static int
444cpufreq_dt_attach(device_t dev)
445{
446 struct cpufreq_dt_softc *sc;
447 phandle_t node;
448 phandle_t cnode, opp, copp;
1/*-
2 * Copyright (c) 2018 Emmanuel Vadot <manu@FreeBSD.Org>
3 * Copyright (c) 2016 Jared McNeill <jmcneill@invisible.ca>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 432 unchanged lines hidden (view full) ---

441}
442
443static int
444cpufreq_dt_attach(device_t dev)
445{
446 struct cpufreq_dt_softc *sc;
447 phandle_t node;
448 phandle_t cnode, opp, copp;
449 int cpu;
449 int cpu, ncpu;
450 uint64_t freq;
451 int rv = 0;
452 enum opp_version version;
453
454 sc = device_get_softc(dev);
455 sc->dev = dev;
456 node = ofw_bus_get_node(device_get_parent(dev));
450 uint64_t freq;
451 int rv = 0;
452 enum opp_version version;
453
454 sc = device_get_softc(dev);
455 sc->dev = dev;
456 node = ofw_bus_get_node(device_get_parent(dev));
457 cpu = device_get_unit(device_get_parent(dev));
457
458
459 if (TUNABLE_INT_FETCH("hw.ncpu", &ncpu)) {
460 if (cpu >= ncpu) {
461 device_printf(dev, "Not attaching as cpu is not present\n");
462 return (ENXIO);
463 }
464 }
465
458 if (regulator_get_by_ofw_property(dev, node,
459 "cpu-supply", &sc->reg) != 0) {
460 if (regulator_get_by_ofw_property(dev, node,
461 "cpu0-supply", &sc->reg) != 0) {
462 device_printf(dev, "no regulator for %s\n",
463 ofw_bus_get_name(device_get_parent(dev)));
464 return (ENXIO);
465 }

--- 25 unchanged lines hidden (view full) ---

491 OF_getencprop(node, "operating-points-v2", &opp,
492 sizeof(opp));
493 }
494
495 /*
496 * Find all CPUs that share the same opp table
497 */
498 CPU_ZERO(&sc->cpus);
466 if (regulator_get_by_ofw_property(dev, node,
467 "cpu-supply", &sc->reg) != 0) {
468 if (regulator_get_by_ofw_property(dev, node,
469 "cpu0-supply", &sc->reg) != 0) {
470 device_printf(dev, "no regulator for %s\n",
471 ofw_bus_get_name(device_get_parent(dev)));
472 return (ENXIO);
473 }

--- 25 unchanged lines hidden (view full) ---

499 OF_getencprop(node, "operating-points-v2", &opp,
500 sizeof(opp));
501 }
502
503 /*
504 * Find all CPUs that share the same opp table
505 */
506 CPU_ZERO(&sc->cpus);
499 cpu = device_get_unit(device_get_parent(dev));
500 for (cnode = node; cnode > 0; cnode = OF_peer(cnode), cpu++) {
501 copp = -1;
502 if (version == OPP_V1)
503 OF_getencprop(cnode, "operating-points", &copp,
504 sizeof(copp));
505 else if (version == OPP_V2)
506 OF_getencprop(cnode, "operating-points-v2",
507 &copp, sizeof(copp));

--- 38 unchanged lines hidden ---
507 for (cnode = node; cnode > 0; cnode = OF_peer(cnode), cpu++) {
508 copp = -1;
509 if (version == OPP_V1)
510 OF_getencprop(cnode, "operating-points", &copp,
511 sizeof(copp));
512 else if (version == OPP_V2)
513 OF_getencprop(cnode, "operating-points-v2",
514 &copp, sizeof(copp));

--- 38 unchanged lines hidden ---