Commit Graph

30 Commits

Author SHA1 Message Date
Emmanuel Vadot
eb80ba8d54 cpufreq: dt: Plug set but not used variable
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-02-21 11:08:23 +01:00
Adrian Chadd
05860ffdb4 cpufreq: Support operating-mode-v2 tables with no voltages
Summary:

The linux device tree documentation for this states that
for v1 voltages are required, but for v2 voltages are optional.

So, handle that here - if there's no regulator/supply provided
for a v1 opmode then error out; but keep it optional for v2.
Then just don't both doing any regulator calls if it's not configured.

This isn't the best/final solution - mmel@ has suggested that
this should be flipped around a bit and print warnings if
we get an opp-microvolt property but we don't have a regulator.

Subscribers: imp
Reviewed by: mmel, jrtc27, manu

Test Plan: * IPQ4018, with no voltage tables; the freq set is called appropriately.

Differential Revision: https://reviews.freebsd.org/D33140
2021-12-14 09:49:17 -08:00
Alexander Motin
d3a8f98acb Make CPU children explicitly share parent unit numbers.
Before this device unit number match was coincidental and broke if I
disabled some CPU device(s).  Aside of cosmetics, for some drivers
(may be considered broken) it caused talking to wrong CPUs.
2021-09-24 23:31:51 -04:00
Mateusz Guzik
ab326db897 cpufreq: clean up empty lines in .c and .h files 2020-09-01 22:11:48 +00:00
Emmanuel Vadot
4707401c75 coufreq_dt: Rename DEBUG to DPRINTF
DEBUG is a kernel configuration flag and if used cpufreq_dt.c will fail the
build of kernel.

PR:		246867
Submitted by:	Oskar Holmund (oskar.holmlund@ohdata.se)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25080
2020-06-09 09:42:39 +00:00
Emmanuel Vadot
7c96220162 cpufreq: Unbreak build. 2020-03-09 03:34:16 +00:00
Emmanuel Vadot
21d69a144e cpufreq_dt: Fix r358555
Before skipping the current cpu when trying to find the ones that
have the same opp, record that this one have this opp.

Reported by:	mmel
MFC after:	2 weeks
X-MFC-With:	r358555
2020-03-09 02:30:16 +00:00
Emmanuel Vadot
a969e975c9 cpufreq_dt: Improve multiple opp support
When looking for cpu with the same OPP starts from the root /cpus node
so each instance of cpufreq_dt will now each cpu with the same operating
point.
Also test that the node we are testing have the property "device_type" set
to be equal to "cpu".
While here add more debug printfs (off by defaults).

MFC after:	2 weeks
2020-03-02 21:19:51 +00:00
Emmanuel Vadot
ddef7bb56f cpufreq_dt: Do not fetch again hw.ncpu
MD code already set the global variable mp_ncpus according to
the tunable hw.ncpu so use the global variable directly.

Reported by:	ian
2019-12-03 22:26:55 +00:00
Emmanuel Vadot
4b23e1e53a cpufreq_dt: Do not attach the device if the cpu isn't present
If we boot with hw.ncpu=X (available on arm and arm64 at least) we
shouldn't attach the cpufreq driver as cf_set_method will try to get
the cpuid and it doesn't exists.
This solves cpufreq panicing on RockChip RK3399 when booting with
hw.ncpu=4

MFC after:	1 week
2019-12-03 22:08:54 +00:00
Emmanuel Vadot
e213223c9b Remove "all rights reserved" from copyright for the file I own.
Some of the files have both me and Jared McNeill and he gave me
permission to remove it from his files too.
2019-12-03 21:00:45 +00:00
Michal Meloun
a701764e9c Improve cpufreq_dt.
- older DT can use 'cpu0-supply' property for power supply binding.
 - don't expect that actual CPU frequency is contained in CPU
   operational point table, but read current CPU voltage directly from
   reguator. Typically, u-boot can set starting CPU frequency to any
   value.

MFC after:	2 weeks
2019-03-19 14:34:53 +00:00
Emmanuel Vadot
41a76289e6 cpufreq_dt: Add operating-points-v2 support
Oppv2 add more flexibility on regulator value for the core voltage amongst
other new thing.
For now only shared opp table is supported as I don't have hardware with
non-shared opp table.

Tested-On: OrangePi One (with oppv1 and oppv2)
Tested-On: Pine64-LTS
2018-07-19 11:31:49 +00:00
Oleksandr Tymoshenko
f7604b1b27 Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc
Change OF_getencprop_alloc semantics to be combination of malloc and
OF_getencprop and return size of the property, not number of elements
allocated.

For the use cases where number of elements is preferred introduce
OF_getencprop_alloc_multi helper function that copies semantics
of OF_getencprop_alloc prior to this change.

This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
function signatures consistent with OF_getencprop_alloc and
OF_getencprop_alloc_multi.

Functionality-wise this patch is mostly rename of OF_getencprop_alloc
to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
where 1 was used as a block size.
2018-04-09 22:06:16 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Jared McNeill
319336a943 Add generic device-tree cpufreq driver.
This driver supports two bindings:
 - cpufreq-dt: systems which share clock and voltage across all CPUs
 - arm_big_little_dt: systems which share clock and voltage across all
   CPUs in a single cluster

Reviewed by:		andrew, imp
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D7741
2016-09-06 20:43:26 +00:00
John Baldwin
7ad65edee3 Add a quirk to disable this driver for certain older laptops with an ICH2
southbridge and an Intel 82815_MC host bridge where the host bridge's
revision is less than 5.

Tested by:	mi
MFC after:	1 week
2013-02-26 18:30:47 +00:00
Sofian Brabez
61bfd86762 Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays
Reviewed by:	cognet
Approved by:	cognet
2013-01-30 18:01:20 +00:00
John Baldwin
bc136b187d Attach the cpufreq child devices with specific orders to enforce relative
priority of some of the drivers that manage the same state (e.g. ichss0
vs est0).  Specifically, powernow, est, and p4tcc are added at order 10,
ichss at order 20, and smist at order 30.  Previously, some laptops were
seeing both ichss0 and est0 attaching and stomping on each other.

XXX: This isn't quite ideal, but works with the existing hacks, I think
what we really want instead is a single "speedstep0" device for CPUs
that the ichss, est, and smist drivers probe (but with differing
priorities).

MFC after:	1 week
2008-08-13 16:09:40 +00:00
John Baldwin
463e0f91cb Probe CPUs after the PCI hierarchy on i386, amd64, and ia64. This allows
the cpufreq drivers to reliably use properties of PCI devices for quirks,
etc.
- For the legacy drivers, add CPU devices via an identify routine in the
  CPU driver itself rather than in the legacy driver's attach routine.
- Add CPU devices after Host-PCI bridges in the acpi bus driver.
- Change the ichss(4) driver to use pci_find_bsf() to locate the ICH and
  check its device ID rather than having a bogus PCI attachment that only
  checked for the ID in probe and always failed.  As a side effect, you
  can now kldload ichss after boot.
- Fix the ichss(4) driver to use the correct device_t for the ICH (and not
  for ichss0) when doing PCI config space operations to enable SpeedStep.

MFC after:	2 weeks
Reviewed by:	njl, Andriy Gapon  avg of icyb.net.ua
2008-03-10 22:18:07 +00:00
Poul-Henning Kamp
c40da00ca3 Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.
2006-05-16 14:37:58 +00:00
Nate Lawson
823d404a6d Only activate ICH speedstep if we're going to use it. No bugs were observed
due to this but it's cleaner this way.
2005-03-20 01:25:21 +00:00
Nate Lawson
97d31723e7 Make a pass through all drivers checking specs for desired behavior on
SMP systems.  It appears all drivers except ichss should attach to each
CPU and that settings should be performed on each CPU.  Add comments about
this.  Also, add a guard for p4tcc's identify method being called more than
once.
2005-02-27 02:43:02 +00:00
Nate Lawson
0dc1b976eb Support disabling individual cpufreq drivers with hints, e.g.,
hint.ichss.0.disabled="1"
2005-02-22 06:31:45 +00:00
Nate Lawson
a47331bb73 Don't attach ichss if est is present. On systems that seem to support both,
the multi-setting EST is preferable.
2005-02-20 23:41:20 +00:00
Nate Lawson
e94a0c1a18 Introduce a new method, cpufreq_drv_type(), that returns the type of the
driver.  This used to be handled by cpufreq_drv_settings() but it's
useful to get the type/flags separately from getting the settings.
(For example, you don't have to pass an array of cf_setting just to find
the driver type.)

Use this new method in our in-tree drivers to detect reliably if acpi_perf
is present and owns the hardware.  This simplifies logic in drivers as well
as fixing a bug introduced in my last commit where too many drivers attached.
2005-02-18 00:23:36 +00:00
Nate Lawson
6655857ec7 Fix the check for acpi_perf(4) so that we verify if it is fully attached
or just offering info.  In the former case, we don't probe/attach to allow
the ACPI driver precedence.  A refinement of this would be to actually
use the info provided by acpi_perf(4) to get the real CPU clock rates
instead of estimating them but since all systems that support both
acpi_perf(4) and ichss(4) export the control registers to acpi_perf(4),
it can just handle the registers on its own.
2005-02-17 01:01:40 +00:00
Nate Lawson
0a9145a2f2 Use intr_disable/restore() instead of disable_intr() since the latter is
not MI.  This should fix build on non i386 platforms.
2005-02-05 16:31:58 +00:00
Warner Losh
c4241acbb3 Don't rely on indirect inclusion of machine/bus.h to use
bus_space_{read,write}_* routines.  This doesn't matter in the current
tree, but will matter soon (the rest of the tree appears to already be
clean).
2005-02-04 17:33:31 +00:00
Nate Lawson
6c7b11ccfa Add a cpufreq driver for the SpeedStep capability in the ICH chipset. This
driver offers two settings.  Information for this driver was obtained from
the Intel datasheets and by reviewing the Linux driver.
2005-02-04 05:42:29 +00:00