[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250701151149.136365-1-angelogioacchino.delregno@collabora.com>
Date: Tue, 1 Jul 2025 17:11:46 +0200
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: krzk@...nel.org
Cc: robh@...nel.org,
conor+dt@...nel.org,
matthias.bgg@...il.com,
angelogioacchino.delregno@...labora.com,
ulf.hansson@...aro.org,
arnd@...db.de,
m.wilczynski@...sung.com,
nm@...com,
khilman@...libre.com,
kabel@...nel.org,
quic_hyiwei@...cinc.com,
pjp@...oraproject.org,
tudor.ambarus@...aro.org,
drew@...7.com,
u.kleine-koenig@...libre.com,
gregkh@...uxfoundation.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
laura.nao@...labora.com,
kernel@...labora.com
Subject: [RFC PATCH 0/3] MediaTek Hardware Voter driver
This RFC comes after public discussion [1] with krzk about how the
MediaTek Hardware Voter mechanism was used in the clock driver.
The logic with this implementation instead is to never write to
the HW Voter registers from external drivers, but to register a
driver to handle the voting with internal functions...
...as you can see, I've modeled the power controller to be child
of the HWV, but the clock controller still gets a handle with the
mediatek,hardware-voter property.
The intention for usage of that property now is to get a handle
to the mtk-hardware-voter driver, and call its clock en/dis vote
mtk_hardware_voter_clk_enable() function, which executes a HWV
version-specific callback doing the necessary register programming
for the available HWV version.
I thought about registering the clocks in the HWV and then get
them assigned with something like
clocks = <&hw_voter CLOCK_HW_IP CLOCK>;
...but I opted for not doing that because the implementation looks
a bit messy as, on MediaTek SoCs, there are multiple clock controllers
located in different IPs, each of them having multiple sets of HWV
registers (from 2 to 8 sets of registers, which are not contiguous
and can't be calculated with offsets), for a total of, well, didn't
really count, but it's more than 80 registers.
Also, all of the mux-gate clocks need to be voted in HWV and after
enablement the "FENC" needs to be brought up with direct MMIO writes
to the clock controller iospace.
(so: enable in HWV -> write FENC enable in clock controller)
For CLOCK_HW_IP in the example, that'd be one of:
vlpckgen, topckgen, imp-iic-wrap-{w,n,s,e,c},mminfra,dispsys0,dispsys1,
ovlsys0,ovlsys1,vencsys,vdecsys (each having dozens of voted clocks).
I'm not sure if I'm forgetting any information but in case just ask....
Ah, "just in case"! ... I've pushed a branch here [2] that contains
the same changes that I'm sending as RFC. Perhaps someone will find
that easier to browse.
Please don't mind about some commits that are not really "presentable"
in that branch (as in, there's some dirty code around) - some stuff is
quite a bit WIP (and some other is quite a bit incomplete).
Also, being this a RFC ... this wasn't tested, it may work or may not,
but that being actually working is out of scope right now, I just want
to understand if I'm walking in the right direction :-)
Cheers!
Angelo
[1]: https://lore.kernel.org/all/20250627-ingenious-tourmaline-wapiti-fa7676@krzk-bin/
[2]: https://gitlab.collabora.com/mediatek/aiot/linux/-/commits/mediatek-hwvoter-temp
AngeloGioacchino Del Regno (3):
firmware: Move MediaTek ADSP IPC driver to mediatek folder
dt-bindings: firmware: Document the MediaTek Hardware Voter (HWV)
firmware: mediatek: Add MediaTek Hardware Voter MCU driver
.../mediatek,mt6991-hardware-voter.yaml | 70 +++
drivers/firmware/Kconfig | 10 +-
drivers/firmware/Makefile | 2 +-
drivers/firmware/mediatek/Kconfig | 23 +
drivers/firmware/mediatek/Makefile | 4 +
.../firmware/{ => mediatek}/mtk-adsp-ipc.c | 0
.../firmware/mediatek/mtk-hardware-voter.c | 430 ++++++++++++++++++
.../firmware/mediatek/mtk-hardware-voter.h | 34 ++
8 files changed, 563 insertions(+), 10 deletions(-)
create mode 100644 Documentation/devicetree/bindings/firmware/mediatek,mt6991-hardware-voter.yaml
create mode 100644 drivers/firmware/mediatek/Kconfig
create mode 100644 drivers/firmware/mediatek/Makefile
rename drivers/firmware/{ => mediatek}/mtk-adsp-ipc.c (100%)
create mode 100644 drivers/firmware/mediatek/mtk-hardware-voter.c
create mode 100644 include/linux/firmware/mediatek/mtk-hardware-voter.h
--
2.49.0
Powered by blists - more mailing lists