arm: Get rid of system_clock_scale global
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest25 patches 65 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/25 | arm: Move M-profile RAS register block into its own deviceMAINTAINERS hw/ hw/ +5 more | +148 | 8 replies | |
| 2/25 | arm: Move systick device creation from NVIC to ARMv7M objecthw/ hw/ include/ +1 more | +137 | 2 replies | |
| 3/25 | arm: Move system PPB container handling to armv7mhw/ hw/ include/ +1 more | +107 | 2 replies | |
| 4/25 | hw/timer/armv7m_systick: Add usual QEMU interface commentinclude/ | +7 | 2 replies | |
| 5/25 | hw/timer/armv7m_systick: Add input clockshw/ include/ | +15 | 2 replies | |
| 6/25 | hw/arm/armv7m: Create input clockshw/ include/ | +29 | 2 replies | |
| 7/25 | armsse: Wire up systick cpuclk clockhw/ | +3 | 2 replies | |
| 8/25 | hw/arm/mps2.c: Connect up armv7m clockshw/ | +15 | 1 reply | |
| 9/25 | clock: Provide builtin multiplier/dividerdocs/ hw/ hw/ +1 more | +100 | 12 replies | |
| 10/25 | hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realizehw/ hw/ include/ +1 more | +22 | 5 replies | |
| 11/25 | hw/arm/stm32f100: Wire up sysclk and refclkhw/ hw/ include/ | +41 | 3 replies | |
| 12/25 | hw/arm/stm32f205: Wire up sysclk and refclkhw/ hw/ include/ | +41 | 3 replies | |
| 13/25 | hw/arm/stm32f405: Wire up sysclk and refclkhw/ hw/ include/ | +40 | 3 replies | |
| 14/25 | hw/arm/stm32vldiscovery: Delete trailing blank linehw/ | +0 | 3 replies | |
| 15/25 | hw/arm/nrf51: Wire up sysclkhw/ include/ | +22 | 1 reply | |
| 16/25 | hw/arm/stellaris: split stellaris_sys_init()hw/ | +25 | 1 reply | |
| 17/25 | hw/arm/stellaris: Wire sysclk up to armv7mhw/ | +4 | 1 reply | |
| 18/25 | hw/arm/msf2_soc: Don't allocate separate MemoryRegionshw/ include/ | +11 | 1 reply | |
| 19/25 | hw/arm/msf2: Use Clock input to MSF2_SOC instead of m3clk propertyhw/ hw/ include/ | +25 | 3 replies | |
| 20/25 | hw/arm/msf2-soc: Wire up refclkhw/ include/ | +24 | 1 reply | |
| 21/25 | hw/timer/armv7m_systick: Use clock inputs instead of system_clock_scalehw/ | +82 | 3 replies | |
| 22/25 | hw/arm/stellaris: Fix code style issues in GPTM codehw/ | +8 | 1 reply | |
| 23/25 | hw/arm/stellaris: Split stellaris-gptm into its own filehw/ hw/ hw/ +3 more | +368 | 1 reply | |
| 24/25 | hw/timer/stellaris-gptm: Use Clock input instead of system_clock_scalehw/ hw/ include/ | +34 | 1 reply | |
| 25/25 | arm: Remove system_clock_scale globalhw/ hw/ hw/ +7 more | +5 | 1 reply |
Reviews trailers per patch
All 25 patches have a Reviewed-by or Acked-by.
| Patch | Alexandre Iooss | Alistair Francis | Luc Michel | Philippe Mathieu-Daudé | Damien Hedde |
|---|---|---|---|---|---|
| 1/25 | R-b | R-b | R-b | R-b | |
| 2/25 | A-b | R-b | |||
| 3/25 | R-b | R-b | |||
| 4/25 | R-b | R-b | |||
| 5/25 | R-b | R-b | |||
| 6/25 | R-b | R-b | |||
| 7/25 | A-b | R-b | |||
| 8/25 | R-b | ||||
| 9/25 | R-b | R-b | R-b | R-b | R-b |
| 10/25 | R-b | R-b | R-b | ||
| 11/25 | R-b | R-b | R-b | ||
| 12/25 | R-b | R-b | R-b | ||
| 13/25 | R-b | R-b | R-b | ||
| 14/25 | R-b | R-b | R-b | ||
| 15/25 | R-b | ||||
| 16/25 | R-b | ||||
| 17/25 | R-b | ||||
| 18/25 | R-b | ||||
| 19/25 | R-b | ||||
| 20/25 | R-b | ||||
| 21/25 | R-b | ||||
| 22/25 | R-b | ||||
| 23/25 | R-b | ||||
| 24/25 | R-b | ||||
| 25/25 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.
Cover letter [PATCH for-6.2 00/25] arm: Get rid of system_clock_scale global
This is mostly a (big) refactoring to use Clocks instead of a global. Review of the new multiplier/divider functionality I've added to the Clock API would also be interesting. If you're a maintainer for an M-profile board that isn't covered by 'make check-acceptance' then I'd appreciate it if you have time to test that this series didn't accidentally break your board...
The Arm v7M systick timer can run off one of two clocks (guest-selectable by writing the SYST_CSR.CLKSOURCE control register bit):
* the main CPU clock
* a separate 'reference clock' which the SoC and board may or may not wire up
Currently we model this as:
* the global variable system_clock_scale is set to the period in ns of the CPU clock by the board or SoC level code
* the reference clock is a fixed 1MHz, hardcoded in armv7m_systick.c
This is very old code, dating back to the first v7M support in 2007. We now have a Clock API, so we can model clocks using something a bit more complicat^Wsophisticated than a global variable.
The series starts with some refactoring to move the creation of various sub-devices including the systick timers out of the nvic object and into the 'armv7m' container object. The NVIC was doing some of this for historical reasons, but it makes more sense to have all of the "create subdevices and map them into the right place in the peripheral region of the address space" be in one place. This also means that when we start wiring Clocks up we don't have to go via the NVIC to get from the armv7m object to the systick timers.
We then add clock inputs to the systick device, which are initially ignored. Subsequent patches wire up those clock inputs in SoC and board level code. Once all the boards have wired up their clocks, we can change the systick device to use those instead of the system_clock_scale global. Finally we can delete all the places setting the global.
For some of the boards the systick reference clock is a fixed multiple/division of the CPU clock. To support this, the "clock:
Provide builtin multiplier/divider" patch enhances the Clock API to let you configure a Clock such that all its children are run at a given ratio of the parent clock.
For the different boards I have taken a variety of approaches:
* sometimes the refclk frequency was easy to determine from the SoC docs, and the patches implement that, changing the behaviour from the old 1MHz fixed refclk. This is in effect a very minor bugfix.
* in a few cases I couldn't determine the refclk frequency, so I have implemented those boards to retain the old 1MHz value, as at least no-behavioural-change
* some SoCs don't wire up the refclk at all; with this series we will correctly implement that (the SYST_CSR.CLKSOURCE control register bit in the systick device is then read-only), so again a minor bugfix
In some SoCs the refclk should theoretically be guest-programmable; we didn't implement that before and we still don't. I've put in a few comments noting this missing feature where relevant.
The other user of the system_clock_scale global is the GPTM timer in the stellaris board, so there's a patch converting that to also use Clock input.
There are also a few patches implementing minor cleanups I noticed along the way that I felt would be in the way if I didn't fix them up first.
NB: this series is a migration compat break for all the M-profile boards, because it adds Clock objects to vmstate structs.
I've tested this with 'make check-acceptance', which tests the emcraft-sf2 board, and I've run some stellaris and various MPS images I have locally. Other affected boards (microbit, netduino2, netduinoplus2, stm32vldiscovery) are untested (though 'make check' confirms that they at least don't crash on startup...). Testing from maintainers of those boards would be appreciated.
thanks
-- PMM
Peter Maydell (25):
arm: Move M-profile RAS register block into its own device
arm: Move systick device creation from NVIC to ARMv7M object
arm: Move system PPB container handling to armv7m hw/timer/armv7m_systick: Add usual QEMU interface comment hw/timer/armv7m_systick: Add input clocks
hw/arm/armv7m: Create input clocks
armsse: Wire up systick cpuclk clock
hw/arm/mps2.c: Connect up armv7m clocks
clock: Provide builtin multiplier/divider
hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize hw/arm/stm32f100: Wire up sysclk and refclk hw/arm/stm32f205: Wire up sysclk and refclk hw/arm/stm32f405: Wire up sysclk and refclk hw/arm/stm32vldiscovery: Delete trailing blank line hw/arm/nrf51: Wire up sysclk
hw/arm/stellaris: split stellaris_sys_init() hw/arm/stellaris: Wire sysclk up to armv7m hw/arm/msf2_soc: Don't allocate separate MemoryRegions hw/arm/msf2: Use Clock input to MSF2_SOC instead of m3clk property hw/arm/msf2-soc: Wire up refclk
hw/timer/armv7m_systick: Use clock inputs instead of
system_clock_scale
hw/arm/stellaris: Fix code style issues in GPTM code hw/arm/stellaris: Split stellaris-gptm into its own file hw/timer/stellaris-gptm: Use Clock input instead of system_clock_scale
arm: Remove system_clock_scale global
docs/devel/clocks.rst | 23 ++ include/hw/arm/armv7m.h | 24 ++ include/hw/arm/msf2-soc.h | 8 +- include/hw/arm/nrf51_soc.h | 2 + include/hw/arm/stm32f100_soc.h | 8 + include/hw/arm/stm32f205_soc.h | 8 + include/hw/arm/stm32f405_soc.h | 3 + include/hw/clock.h | 29 +++ include/hw/intc/armv7m_nvic.h | 8 - include/hw/misc/armv7m_ras.h | 37 +++ include/hw/timer/armv7m_systick.h | 36 ++- include/hw/timer/stellaris-gptm.h | 51 ++++ hw/arm/armsse.c | 20 +- hw/arm/armv7m.c | 260 +++++++++++++++++++- hw/arm/mps2.c | 17 +- hw/arm/msf2-soc.c | 68 +++-- hw/arm/msf2-som.c | 7 +- hw/arm/netduino2.c | 12 +- hw/arm/netduinoplus2.c | 12 +- hw/arm/nrf51_soc.c | 20 +- hw/arm/stellaris.c | 396 ++++-------------------------- hw/arm/stm32f100_soc.c | 47 +++- hw/arm/stm32f205_soc.c | 47 +++- hw/arm/stm32f405_soc.c | 30 +++ hw/arm/stm32vldiscovery.c | 13 +- hw/core/clock-vmstate.c | 24 +- hw/core/clock.c | 29 ++- hw/intc/armv7m_nvic.c | 274 +-------------------- hw/misc/armv7m_ras.c | 93 +++++++ hw/timer/armv7m_systick.c | 116 ++++++--- hw/timer/stellaris-gptm.c | 332 +++++++++++++++++++++++++ MAINTAINERS | 2 + hw/arm/Kconfig | 1 + hw/misc/meson.build | 2 + hw/timer/Kconfig | 3 + hw/timer/meson.build | 1 + 36 files changed, 1292 insertions(+), 771 deletions(-) create mode 100644 include/hw/misc/armv7m_ras.h create mode 100644 include/hw/timer/stellaris-gptm.h create mode 100644 hw/misc/armv7m_ras.c create mode 100644 hw/timer/stellaris-gptm.c
Signature · 1 line
2.20.1