arm64: Realtek RTD1619 clock and reset controllers
Subsystems (5)
cover arm64: Realtek RTD1619 clock and reset controllers
Hi Andreas,
This series adds clock and reset controllers for the Realtek RTD1619 SoC.
cylee12 (6):
dt-bindings: clock: add bindings for RTD1619 clocks
dt-bindings: reset: add bindings for rtd1619 reset controls
clk: realtek: add common clock support for Realtek SoCs
clk: realtek: add reset controller support for Realtek SoCs
clk: realtek: add rtd1619 controllers
dt-bindings: clk: realtek: add rtd1619 clock controller bindings
.../bindings/clock/realtek,clocks.txt | 38 ++ drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/realtek/Kconfig | 21 + drivers/clk/realtek/Makefile | 12 + drivers/clk/realtek/clk-pll-dif.c | 81 +++ drivers/clk/realtek/clk-pll-psaud.c | 120 ++++ drivers/clk/realtek/clk-pll.c | 400 +++++++++++++ drivers/clk/realtek/clk-pll.h | 151 +++++ drivers/clk/realtek/clk-regmap-gate.c | 89 +++ drivers/clk/realtek/clk-regmap-gate.h | 26 + drivers/clk/realtek/clk-regmap-mux.c | 63 ++ drivers/clk/realtek/clk-regmap-mux.h | 26 + drivers/clk/realtek/clk-rtd1619-cc.c | 553 ++++++++++++++++++ drivers/clk/realtek/clk-rtd1619-ic.c | 112 ++++ drivers/clk/realtek/common.c | 320 ++++++++++ drivers/clk/realtek/common.h | 123 ++++ drivers/clk/realtek/reset.c | 107 ++++ drivers/clk/realtek/reset.h | 37 ++ include/dt-bindings/clock/rtk,clock-rtd1619.h | 88 +++ include/dt-bindings/reset/rtk,reset-rtd1619.h | 124 ++++ 21 files changed, 2493 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/realtek,clocks.txt create mode 100644 drivers/clk/realtek/Kconfig create mode 100644 drivers/clk/realtek/Makefile create mode 100644 drivers/clk/realtek/clk-pll-dif.c create mode 100644 drivers/clk/realtek/clk-pll-psaud.c create mode 100644 drivers/clk/realtek/clk-pll.c create mode 100644 drivers/clk/realtek/clk-pll.h create mode 100644 drivers/clk/realtek/clk-regmap-gate.c create mode 100644 drivers/clk/realtek/clk-regmap-gate.h create mode 100644 drivers/clk/realtek/clk-regmap-mux.c create mode 100644 drivers/clk/realtek/clk-regmap-mux.h create mode 100644 drivers/clk/realtek/clk-rtd1619-cc.c create mode 100644 drivers/clk/realtek/clk-rtd1619-ic.c create mode 100644 drivers/clk/realtek/common.c create mode 100644 drivers/clk/realtek/common.h create mode 100644 drivers/clk/realtek/reset.c create mode 100644 drivers/clk/realtek/reset.h create mode 100644 include/dt-bindings/clock/rtk,clock-rtd1619.h create mode 100644 include/dt-bindings/reset/rtk,reset-rtd1619.h
Signature · 7 lines
2.24.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/6 dt-bindings: clock: add bindings for RTD1619 clocks
From: cylee12 <[email protected]>
Add devicetree binding for Realtek RTD1619 clocks.
--- include/dt-bindings/clock/rtk,clock-rtd1619.h | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 include/dt-bindings/clock/rtk,clock-rtd1619.h
include/dt-bindings/clock/rtk,clock-rtd1619.h new file +88 -0
@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __DT_BINDINGS_RTK_CLOCK_RTD1619_H +#define __DT_BINDINGS_RTK_CLOCK_RTD1619_H + +#define CC_PLL_SCPU 0 +#define CC_PLL_BUS 2 +#define CC_CLK_SYS 3 +#define CC_CLK_SYS_SB2 4 +#define CC_PLL_DCSB 5 +#define CC_CLK_SYSH 6 +#define CC_PLL_DDSA 7 +#define CC_PLL_DDSB 8 +#define CC_PLL_GPU 9 +#define CC_CLK_GPU 10 +#define CC_PLL_VE1 11 +#define CC_PLL_VE2 12 +#define CC_CLK_VE1 13 +#define CC_CLK_VE2 14 +#define CC_CLK_VE3 15 +#define CC_CLK_VE2_BPU 16 +#define CC_PLL_DIF 17 +#define CC_PLL_PSAUD1A 18 +#define CC_PLL_PSAUD2A 19 + +#define CC_CKE_MISC 33 +#define CC_CKE_PCIE0 34 +#define CC_CKE_GSPI 35 +#define CC_CKE_SDS 36 +#define CC_CKE_HDMI 37 +#define CC_CKE_LSADC 38 +#define CC_CKE_SE 39 +#define CC_CKE_CP 40 +#define CC_CKE_MD 41 +#define CC_CKE_TP 42 +#define CC_CKE_RSA 43 +#define CC_CKE_NF 44 +#define CC_CKE_EMMC 45 +#define CC_CKE_SD 46 +#define CC_CKE_SDIO_IP 47 +#define CC_CKE_MIPI 48 +#define CC_CKE_EMMC_IP 49 +#define CC_CKE_SDIO 50 +#define CC_CKE_SD_IP 51 +#define CC_CKE_CABLERX 52 +#define CC_CKE_TPB 53 +#define CC_CKE_SC1 54 +#define CC_CKE_I2C3 55 +#define CC_CKE_JPEG 56 +#define CC_CKE_SC0 57 +#define CC_CKE_HDMIRX 58 +#define CC_CKE_HSE 59 +#define CC_CKE_UR2 60 +#define CC_CKE_UR1 61 +#define CC_CKE_FAN 62 +#define CC_CKE_SATA_WRAP_SYS 63 +#define CC_CKE_SATA_WRAP_SYSH 64 +#define CC_CKE_SATA_MAC_SYSH 65 +#define CC_CKE_R2RDSC 66 +#define CC_CKE_PCIE1 67 +#define CC_CKE_I2C4 68 +#define CC_CKE_I2C5 69 +#define CC_CKE_EDP 70 +#define CC_CKE_TSIO_TRX 71 +#define CC_CKE_TVE 72 +#define CC_CKE_VO 73 + +#define CC_CLK_MAX 74 + + +#define IC_CKE_CEC0 2 +#define IC_CKE_CBUSRX_SYS 3 +#define IC_CKE_CBUSTX_SYS 4 +#define IC_CKE_CBUS_SYS 5 +#define IC_CKE_CBUS_OSC 6 +#define IC_CKE_IR 7 +#define IC_CKE_UR0 8 +#define IC_CKE_I2C0 9 +#define IC_CKE_I2C1 10 +#define IC_CKE_ETN_250M 11 +#define IC_CKE_ETN_SYS 12 +#define IC_CKE_USB_DRD 13 +#define IC_CKE_USB_HOST 14 +#define IC_CKE_USB_U3_HOST 15 +#define IC_CKE_USB 16 +#define IC_CLK_MAX 17 + +#endif /* __DT_BINDINGS_RTK_CLOCK_RTD1619_H */ +
Signature · 1 line
2.24.0
Re: [PATCH 1/6] dt-bindings: clock: add bindings for RTD1619 clocks
Hi James and Cheng-Yu,
Am 03.12.19 um 08:45 schrieb James Tai:
Quoted 1 line
From: cylee12 <[email protected]>
Please fix the author (git commit --amend --author="...") and use an appropriate git config setting (and communication to your team) to avoid this reoccurring for new commits - already pointed out to James.
BTW I wonder why we have so many seemingly unrelated people in CC (Mediatek, RISC-V) that the patches and responses keep hanging in mailing list moderation?
include/dt-bindings/clock/rtk,clock-rtd1619.h
Quoted 15 lines
Add devicetree binding for Realtek RTD1619 clocks.
Signed-off-by Cheng-Yu Lee <[email protected]>Signed-off-by James Tai <[email protected]>--- include/dt-bindings/clock/rtk,clock-rtd1619.h | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 include/dt-bindings/clock/rtk,clock-rtd1619.hinclude/dt-bindings/clock/rtk,clock-rtd1619.h new file +0
-0
NAK for the filename. "rtk," is not a registered vendor prefix [1], so you cannot use it anywhere in bindings. Please use the registered prefix "realtek," and compare the other Realtek bindings headers that got accepted already. The order of SoC vs. name seems wrong.
include/dt-bindings/clock/rtk,clock-rtd1619.h line 1
Quoted 2 lines
include/dt-bindings/clock/rtk,clock-rtd1619.h new file +1
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0-only */
Why restrict these trivial numbers to GPLv2? Please compare the .dtsi and .yaml files where this may get #include'd, and keep non-Linux OSes such as BSDs in mind for any DT bindings; it's supposed to be an OS-neutral interface contract that anyone can implement.
include/dt-bindings/clock/rtk,clock-rtd1619.h line 3
Quoted 2 lines
include/dt-bindings/clock/rtk,clock-rtd1619.h new file +2
-0+#ifndef __DT_BINDINGS_RTK_CLOCK_RTD1619_H +#define __DT_BINDINGS_RTK_CLOCK_RTD1619_H
May need adjustments based on the filename, same for the #endif.
include/dt-bindings/clock/rtk,clock-rtd1619.h line 6
Quoted 3 lines
include/dt-bindings/clock/rtk,clock-rtd1619.h new file +3
-0+ +#define CC_PLL_SCPU 0 +#define CC_PLL_BUS 2
Please tab-indent the indices for readability.
Quoted 72 lines
include/dt-bindings/clock/rtk,clock-rtd1619.h new file +72
-0+#define CC_CLK_SYS 3 +#define CC_CLK_SYS_SB2 4 +#define CC_PLL_DCSB 5 +#define CC_CLK_SYSH 6 +#define CC_PLL_DDSA 7 +#define CC_PLL_DDSB 8 +#define CC_PLL_GPU 9 +#define CC_CLK_GPU 10 +#define CC_PLL_VE1 11 +#define CC_PLL_VE2 12 +#define CC_CLK_VE1 13 +#define CC_CLK_VE2 14 +#define CC_CLK_VE3 15 +#define CC_CLK_VE2_BPU 16 +#define CC_PLL_DIF 17 +#define CC_PLL_PSAUD1A 18 +#define CC_PLL_PSAUD2A 19 + +#define CC_CKE_MISC 33 +#define CC_CKE_PCIE0 34 +#define CC_CKE_GSPI 35 +#define CC_CKE_SDS 36 +#define CC_CKE_HDMI 37 +#define CC_CKE_LSADC 38 +#define CC_CKE_SE 39 +#define CC_CKE_CP 40 +#define CC_CKE_MD 41 +#define CC_CKE_TP 42 +#define CC_CKE_RSA 43 +#define CC_CKE_NF 44 +#define CC_CKE_EMMC 45 +#define CC_CKE_SD 46 +#define CC_CKE_SDIO_IP 47 +#define CC_CKE_MIPI 48 +#define CC_CKE_EMMC_IP 49 +#define CC_CKE_SDIO 50 +#define CC_CKE_SD_IP 51 +#define CC_CKE_CABLERX 52 +#define CC_CKE_TPB 53 +#define CC_CKE_SC1 54 +#define CC_CKE_I2C3 55 +#define CC_CKE_JPEG 56 +#define CC_CKE_SC0 57 +#define CC_CKE_HDMIRX 58 +#define CC_CKE_HSE 59 +#define CC_CKE_UR2 60 +#define CC_CKE_UR1 61 +#define CC_CKE_FAN 62 +#define CC_CKE_SATA_WRAP_SYS 63 +#define CC_CKE_SATA_WRAP_SYSH 64 +#define CC_CKE_SATA_MAC_SYSH 65 +#define CC_CKE_R2RDSC 66 +#define CC_CKE_PCIE1 67 +#define CC_CKE_I2C4 68 +#define CC_CKE_I2C5 69 +#define CC_CKE_EDP 70 +#define CC_CKE_TSIO_TRX 71 +#define CC_CKE_TVE 72 +#define CC_CKE_VO 73 + +#define CC_CLK_MAX 74 + + +#define IC_CKE_CEC0 2 +#define IC_CKE_CBUSRX_SYS 3 +#define IC_CKE_CBUSTX_SYS 4 +#define IC_CKE_CBUS_SYS 5 +#define IC_CKE_CBUS_OSC 6 +#define IC_CKE_IR 7 +#define IC_CKE_UR0 8 +#define IC_CKE_I2C0 9 +#define IC_CKE_I2C1 10
include/dt-bindings/clock/rtk,clock-rtd1619.h line 88
Quoted 10 lines
include/dt-bindings/clock/rtk,clock-rtd1619.h new file +10
-0+#define IC_CKE_ETN_250M 11 +#define IC_CKE_ETN_SYS 12 +#define IC_CKE_USB_DRD 13 +#define IC_CKE_USB_HOST 14 +#define IC_CKE_USB_U3_HOST 15 +#define IC_CKE_USB 16 +#define IC_CLK_MAX 17 + +#endif /* __DT_BINDINGS_RTK_CLOCK_RTD1619_H */ +
Trailing empty line.
Regards,
Andreas
Signature · 4 lines
SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)
RE: [PATCH 1/6] dt-bindings: clock: add bindings for RTD1619 clocks
Hi Andreas,
Quoted 5 lines
Hi James and Cheng-Yu,
Am 03.12.19 um 08:45 schrieb James Tai:
Quoted 1 line
From: cylee12 <[email protected]>
Quoted 7 lines
Please fix the author (git commit --amend --author="...") and use an appropriate git config setting (and communication to your team) to avoid this reoccurring for new commits - already pointed out to James.
BTW I wonder why we have so many seemingly unrelated people in CC (Mediatek, RISC-V) that the patches and responses keep hanging in mailing list moderation?
I used the "get_maintainer.pl" to find the email address of maintainers. However, I'm so sorry for mistakenly adding some unrelated people to this mail.
Regards,
James
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 1/6] dt-bindings: clock: add bindings for RTD1619 clocks
Hi James,
[fixing Palmer]
Am 04.12.19 um 05:11 schrieb James Tai:
Quoted 7 lines
Quoted 7 lines
Am 03.12.19 um 08:45 schrieb James Tai:
Quoted 1 line
From: cylee12 <[email protected]>
Please fix the author (git commit --amend --author="...") and use an appropriate git config setting (and communication to your team) to avoid this reoccurring for new commits - already pointed out to James.
Quoted 6 lines
Quoted 3 lines
BTW I wonder why we have so many seemingly unrelated people in CC (Mediatek, RISC-V) that the patches and responses keep hanging in mailing list moderation?
I used the "get_maintainer.pl" to find the email address of maintainers. However, I'm so sorry for mistakenly adding some unrelated people to this mail.
Here's my git-send-email cccmd config that I recommend:
$ git config sendemail.cccmd scripts/get_maintainer.pl --nogit-fallback --norolestats
--nogit-fallback suppresses Git history to be checked for previous contributors, saving time and avoiding unrelated or outdated people.
--norolestats suppresses extensive "(...)" comments for the email addresses, which might wrap and break during transmission or when people reply.
In addition you obviously need to configure sendemail.to, and you may want to add multiple cc lines to [sendemail] in your .git/config to ensure all mails including cover letters reach LKML and LAKML, too:
$ git config --get-all sendemail.to [email protected] $ git config --get-all sendemail.cc [email protected] [email protected]
Further, you need to ensure that you are sending from the right branch, so that the latest MAINTAINERS file and scripts get used. As Paul pointed out, Palmer's address is fixed in both linux-next and linux, so it is really puzzling where you got that old address from...
Not understanding your setup, you'll have to debug on your own where those addresses came from. Try git send-email --dry-run to review the CC addresses before you send. You could also temporarily use --rolestats to see the MAINTAINERS section they came from.
On the bright side, this time your patches arrived threaded correctly.
Regards,
Andreas
Signature · 4 lines
SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)
PATCH 2/6 dt-bindings: reset: add bindings for rtd1619 reset controls
In reply to James TaiFrom: cylee12 <[email protected]>
Add devicetree binding for Realtek RTD1619 SoC reset controls.
--- include/dt-bindings/reset/rtk,reset-rtd1619.h | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 include/dt-bindings/reset/rtk,reset-rtd1619.h
include/dt-bindings/reset/rtk,reset-rtd1619.h new file +124 -0
@@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __DT_BINDINGS_RTK_RESET_RTD1619_H +#define __DT_BINDINGS_RTK_RESET_RTD1619_H + +#define CC_RSTN_REG_BANK_1 (0x0000) +#define CC_RSTN_REG_BANK_2 (0x0100) +#define CC_RSTN_REG_BANK_3 (0x0200) +#define CC_RSTN_REG_BANK_4 (0x0300) +#define CC_RSTN_REG_BANK_6 (0x0400) +#define CC_RSTN_REG_BANK_7 (0x0500) + +#define CC_RSTN_MISC (CC_RSTN_REG_BANK_1 | 0x00) +#define CC_RSTN_DIP (CC_RSTN_REG_BANK_1 | 0x02) +#define CC_RSTN_GSPI (CC_RSTN_REG_BANK_1 | 0x04) +#define CC_RSTN_SDS (CC_RSTN_REG_BANK_1 | 0x06) +#define CC_RSTN_SDS_REG (CC_RSTN_REG_BANK_1 | 0x08) +#define CC_RSTN_SDS_PHY (CC_RSTN_REG_BANK_1 | 0x0a) +#define CC_RSTN_VE1 (CC_RSTN_REG_BANK_1 | 0x0c) +#define CC_RSTN_VE2 (CC_RSTN_REG_BANK_1 | 0x0e) +#define CC_RSTN_R2RDSC_A00 (CC_RSTN_REG_BANK_1 | 0x10) +#define CC_RSTN_RSA (CC_RSTN_REG_BANK_1 | 0x12) +#define CC_RSTN_GPU (CC_RSTN_REG_BANK_1 | 0x14) +#define CC_RSTN_DC_PHY (CC_RSTN_REG_BANK_1 | 0x16) +#define CC_RSTN_DCPHY_CRT (CC_RSTN_REG_BANK_1 | 0x18) +#define CC_RSTN_LSADC (CC_RSTN_REG_BANK_1 | 0x1a) +#define CC_RSTN_SE (CC_RSTN_REG_BANK_1 | 0x1c) +#define CC_RSTN_HSE_A00 (CC_RSTN_REG_BANK_1 | 0x1e) + +#define CC_RSTN_JPEG (CC_RSTN_REG_BANK_2 | 0x00) +#define CC_RSTN_SD (CC_RSTN_REG_BANK_2 | 0x02) +#define CC_RSTN_EMMC_A00 (CC_RSTN_REG_BANK_2 | 0x04) +#define CC_RSTN_SDIO (CC_RSTN_REG_BANK_2 | 0x06) +#define CC_RSTN_PCR_CNT (CC_RSTN_REG_BANK_2 | 0x08) +#define CC_RSTN_PCIE0_STITCH (CC_RSTN_REG_BANK_2 | 0x0a) +#define CC_RSTN_PCIE0_PHY (CC_RSTN_REG_BANK_2 | 0x0c) +#define CC_RSTN_PCIE0 (CC_RSTN_REG_BANK_2 | 0x0e) +#define CC_RSTN_PCIE0_CORE (CC_RSTN_REG_BANK_2 | 0x10) +#define CC_RSTN_PCIE0_POWER (CC_RSTN_REG_BANK_2 | 0x12) +#define CC_RSTN_PCIE0_NONSTITCH (CC_RSTN_REG_BANK_2 | 0x14) +#define CC_RSTN_PCIE0_PHY_MDIO (CC_RSTN_REG_BANK_2 | 0x16) +#define CC_RSTN_PCIE0_SGMII_MDIO (CC_RSTN_REG_BANK_2 | 0x18) +#define CC_RSTN_UR2 (CC_RSTN_REG_BANK_2 | 0x1a) +#define CC_RSTN_UR1 (CC_RSTN_REG_BANK_2 | 0x1c) +#define CC_RSTN_MISC_SC0 (CC_RSTN_REG_BANK_2 | 0x1e) + +#define CC_RSTN_AE (CC_RSTN_REG_BANK_3 | 0x00) +#define CC_RSTN_CABLERX (CC_RSTN_REG_BANK_3 | 0x02) +#define CC_RSTN_MD_A00 (CC_RSTN_REG_BANK_3 | 0x04) +#define CC_RSTN_TP_A00 (CC_RSTN_REG_BANK_3 | 0x06) +#define CC_RSTN_NF_A00 (CC_RSTN_REG_BANK_3 | 0x08) +#define CC_RSTN_MISC_SC1 (CC_RSTN_REG_BANK_3 | 0x0a) +#define CC_RSTN_I2C_3 (CC_RSTN_REG_BANK_3 | 0x0c) +#define CC_RSTN_FAN (CC_RSTN_REG_BANK_3 | 0x0e) +#define CC_RSTN_TVE (CC_RSTN_REG_BANK_3 | 0x10) +#define CC_RSTN_AIO (CC_RSTN_REG_BANK_3 | 0x12) +#define CC_RSTN_VO (CC_RSTN_REG_BANK_3 | 0x14) +#define CC_RSTN_MIPI_A00 (CC_RSTN_REG_BANK_3 | 0x16) +#define CC_RSTN_HDMIRX (CC_RSTN_REG_BANK_3 | 0x18) +#define CC_RSTN_HDMIRX_WRAP (CC_RSTN_REG_BANK_3 | 0x1a) +#define CC_RSTN_HDMI (CC_RSTN_REG_BANK_3 | 0x1c) +#define CC_RSTN_DISP (CC_RSTN_REG_BANK_3 | 0x1e) + +#define CC_RSTN_SATA_PHY_POW1 (CC_RSTN_REG_BANK_4 | 0x00) +#define CC_RSTN_SATA_PHY_POW0 (CC_RSTN_REG_BANK_4 | 0x02) +#define CC_RSTN_SATA_MDIO1 (CC_RSTN_REG_BANK_4 | 0x04) +#define CC_RSTN_SATA_MDIO0 (CC_RSTN_REG_BANK_4 | 0x06) +#define CC_RSTN_SATA_WRAP (CC_RSTN_REG_BANK_4 | 0x08) +#define CC_RSTN_SATA_MAC_P1 (CC_RSTN_REG_BANK_4 | 0x0a) +#define CC_RSTN_SATA_MAC_P0 (CC_RSTN_REG_BANK_4 | 0x0c) +#define CC_RSTN_SATA_MAC_COM (CC_RSTN_REG_BANK_4 | 0x0e) +#define CC_RSTN_PCIE1_STITCH (CC_RSTN_REG_BANK_4 | 0x10) +#define CC_RSTN_PCIE1_PHY (CC_RSTN_REG_BANK_4 | 0x12) +#define CC_RSTN_PCIE1 (CC_RSTN_REG_BANK_4 | 0x14) +#define CC_RSTN_PCIE1_CORE (CC_RSTN_REG_BANK_4 | 0x16) +#define CC_RSTN_PCIE1_POWER (CC_RSTN_REG_BANK_4 | 0x18) +#define CC_RSTN_PCIE1_NONSTITCH (CC_RSTN_REG_BANK_4 | 0x1a) +#define CC_RSTN_PCIE1_PHY_MDIO (CC_RSTN_REG_BANK_4 | 0x1c) +#define CC_RSTN_HDMITOP (CC_RSTN_REG_BANK_4 | 0x1e) + +#define CC_RSTN_HSE (CC_RSTN_REG_BANK_6 | 0x06) +#define CC_RSTN_R2RDSC (CC_RSTN_REG_BANK_6 | 0x08) +#define CC_RSTN_EMMC (CC_RSTN_REG_BANK_6 | 0x0a) +#define CC_RSTN_NF (CC_RSTN_REG_BANK_6 | 0x0c) +#define CC_RSTN_MD (CC_RSTN_REG_BANK_6 | 0x0e) +#define CC_RSTN_TPB (CC_RSTN_REG_BANK_6 | 0x18) +#define CC_RSTN_TP (CC_RSTN_REG_BANK_6 | 0x1a) +#define CC_RSTN_MIPI (CC_RSTN_REG_BANK_6 | 0x1c) + +#define CC_RSTN_TPB_A00 (CC_RSTN_REG_BANK_7 | 0x00) +#define CC_RSTN_I2C_4 (CC_RSTN_REG_BANK_7 | 0x02) +#define CC_RSTN_I2C_5 (CC_RSTN_REG_BANK_7 | 0x04) +#define CC_RSTN_TSIO (CC_RSTN_REG_BANK_7 | 0x06) +#define CC_RSTN_VE3 (CC_RSTN_REG_BANK_7 | 0x08) +#define CC_RSTN_EDP (CC_RSTN_REG_BANK_7 | 0x0a) + +/* 0x98007088 */ +#define IC_RSTN_VFD 0x0000 +#define IC_RSTN_IR 0x0001 +#define IC_RSTN_CEC0 0x0002 +#define IC_RSTN_CEC1 0x0003 +#define IC_RSTN_DP 0x0004 +#define IC_RSTN_CBUSTX 0x0005 +#define IC_RSTN_CBUSRX 0x0006 +#define IC_RSTN_EFUSE 0x0007 +#define IC_RSTN_UR0 0x0008 +#define IC_RSTN_GMAC 0x0009 +#define IC_RSTN_GPHY 0x000a +#define IC_RSTN_I2C_0 0x000b +#define IC_RSTN_I2C_1 0x000c +#define IC_RSTN_CBUS 0x000d +#define IC_RSTN_USB_DRD 0x000e +#define IC_RSTN_USB_HOST 0x000f +#define IC_RSTN_USB_PHY_0 0x0010 +#define IC_RSTN_USB_PHY_1 0x0011 +#define IC_RSTN_USB_PHY_2 0x0012 +#define IC_RSTN_USB 0x0013 +#define IC_RSTN_TYPE_C 0x0014 +#define IC_RSTN_USB_U3_HOST 0x0015 +#define IC_RSTN_USB3_PHY0_POW 0x0016 +#define IC_RSTN_USB3_P0_MDIO 0x0017 +#define IC_RSTN_USB3_PHY1_POW 0x0018 +#define IC_RSTN_USB3_P1_MDIO 0x0019 + +#endif
Signature · 1 line
2.24.0
PATCH 3/6 clk: realtek: add common clock support for Realtek SoCs
In reply to James TaiFrom: cylee12 <[email protected]>
This patch adds common clock support for Realtek SoCs, including PLLs, Mux clocks and Gate clocks.
--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/realtek/Kconfig | 10 + drivers/clk/realtek/Makefile | 9 + drivers/clk/realtek/clk-pll-dif.c | 81 ++++++ drivers/clk/realtek/clk-pll-psaud.c | 120 ++++++++ drivers/clk/realtek/clk-pll.c | 400 ++++++++++++++++++++++++++ drivers/clk/realtek/clk-pll.h | 151 ++++++++++ drivers/clk/realtek/clk-regmap-gate.c | 89 ++++++ drivers/clk/realtek/clk-regmap-gate.h | 26 ++ drivers/clk/realtek/clk-regmap-mux.c | 63 ++++ drivers/clk/realtek/clk-regmap-mux.h | 26 ++ drivers/clk/realtek/common.c | 320 +++++++++++++++++++++ drivers/clk/realtek/common.h | 123 ++++++++ 14 files changed, 1420 insertions(+) create mode 100644 drivers/clk/realtek/Kconfig create mode 100644 drivers/clk/realtek/Makefile create mode 100644 drivers/clk/realtek/clk-pll-dif.c create mode 100644 drivers/clk/realtek/clk-pll-psaud.c create mode 100644 drivers/clk/realtek/clk-pll.c create mode 100644 drivers/clk/realtek/clk-pll.h create mode 100644 drivers/clk/realtek/clk-regmap-gate.c create mode 100644 drivers/clk/realtek/clk-regmap-gate.h create mode 100644 drivers/clk/realtek/clk-regmap-mux.c create mode 100644 drivers/clk/realtek/clk-regmap-mux.h create mode 100644 drivers/clk/realtek/common.c create mode 100644 drivers/clk/realtek/common.h
drivers/clk/Kconfig +1 -0
@@ -317,6 +317,7 @@ source "drivers/clk/mediatek/Kconfig" source "drivers/clk/meson/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/qcom/Kconfig" +source "drivers/clk/realtek/Kconfig" source "drivers/clk/renesas/Kconfig" source "drivers/clk/samsung/Kconfig" source "drivers/clk/sifive/Kconfig"
drivers/clk/Makefile +1 -0
@@ -95,6 +95,7 @@ obj-$(CONFIG_COMMON_CLK_NXP) += nxp/ obj-$(CONFIG_MACH_PISTACHIO) += pistachio/ obj-$(CONFIG_COMMON_CLK_PXA) += pxa/ obj-$(CONFIG_COMMON_CLK_QCOM) += qcom/ +obj-$(CONFIG_COMMON_CLK_REALTEK) += realtek/ obj-y += renesas/ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ obj-$(CONFIG_COMMON_CLK_SAMSUNG) += samsung/
drivers/clk/realtek/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +config COMMON_CLK_REALTEK + bool "Clock driver for realtek" + select MFD_SYSCON + +config CLK_PLL_PSAUD + bool + +config CLK_PLL_DIF + bool
drivers/clk/realtek/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_COMMON_CLK_REALTEK) += clk-rtk.o + +clk-rtk-y += common.o +clk-rtk-y += clk-regmap-mux.o +clk-rtk-y += clk-regmap-gate.o +clk-rtk-y += clk-pll.o +clk-rtk-$(CONFIG_CLK_PLL_PSAUD) += clk-pll-psaud.o +clk-rtk-$(CONFIG_CLK_PLL_DIF) += clk-pll-dif.o
drivers/clk/realtek/clk-pll-dif.c new file +81 -0
81 lines not on this page · raw message
drivers/clk/realtek/clk-pll-psaud.c new file +120 -0
120 lines not on this page · raw message
drivers/clk/realtek/clk-pll.c new file +400 -0
400 lines not on this page · raw message
drivers/clk/realtek/clk-pll.h new file +151 -0
151 lines not on this page · raw message
drivers/clk/realtek/clk-regmap-gate.c new file +89 -0
89 lines not on this page · raw message
drivers/clk/realtek/clk-regmap-gate.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2017 Realtek Semiconductor Corporation +* Author: Cheng-Yu Lee <[email protected]> +*/ + +#ifndef __CLK_REALTEK_CLK_MMIO_GATE_H +#define __CLK_REALTEK_CLK_MMIO_GATE_H + +#include "common.h" + +struct clk_regmap_gate { +struct clk_regmap clkr; +int gate_ofs; +uint8_t bit_idx; +spinlock_t *lock; +int write_en:1 ; +}; + +#define to_clk_regmap_gate (_hw) \ + container_of(to_clk_regmap(_hw), struct clk_regmap_gate, clkr) +#define __clk_regmap_gate_hw (_p) __clk_regmap_hw(&(_p)->clkr) + +extern const struct clk_ops clk_regmap_gate_ops; + +#endif
drivers/clk/realtek/clk-regmap-mux.c new file +63 -0
63 lines not on this page · raw message
drivers/clk/realtek/clk-regmap-mux.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2017 Realtek Semiconductor Corporation +* Author: Cheng-Yu Lee <[email protected]> +*/ + +#ifndef __CLK_REALTEK_CLK_MMIO_MUX_H +#define __CLK_REALTEK_CLK_MMIO_MUX_H + +#include "common.h" + +struct clk_regmap_mux { +struct clk_regmap clkr; +int mux_ofs; +unsigned int mask; +unsigned int shift; +spinlock_t *lock; +}; + +#define to_clk_regmap_mux (_hw) \ + container_of(to_clk_regmap(_hw), struct clk_regmap_mux, clkr) +#define __clk_regmap_mux_hw (_p) __clk_regmap_hw(&(_p)->clkr) + +extern const struct clk_ops clk_regmap_mux_ops; + +#endif
drivers/clk/realtek/common.c new file +320 -0
320 lines not on this page · raw message
drivers/clk/realtek/common.h new file +123 -0
123 lines not on this page · raw message
Signature · 7 lines
2.24.0 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH 3/6] clk: realtek: add common clock support for Realtek SoCs
Hi James,
[dropping Palmer]
Am 03.12.19 um 08:45 schrieb James Tai:
Quoted 1 line
From: cylee12 <[email protected]>
Please fix the author name.
Quoted 3 lines
This patch adds common clock support for Realtek SoCs, including PLLs, Mux clocks and Gate clocks.
Can you be more specific here, please? Is this compatible back to RTD1195 or RTD1295 or just 1619 forward? I only see RTD1619 in 5/6. And not a single .dtsi patch is included in this series for testing it.
Quoted 19 lines
Signed-off-by Cheng-Yu Lee <[email protected]>Signed-off-by James Tai <[email protected]>--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/realtek/Kconfig | 10 + drivers/clk/realtek/Makefile | 9 + drivers/clk/realtek/clk-pll-dif.c | 81 ++++++ drivers/clk/realtek/clk-pll-psaud.c | 120 ++++++++ drivers/clk/realtek/clk-pll.c | 400 ++++++++++++++++++++++++++ drivers/clk/realtek/clk-pll.h | 151 ++++++++++ drivers/clk/realtek/clk-regmap-gate.c | 89 ++++++ drivers/clk/realtek/clk-regmap-gate.h | 26 ++ drivers/clk/realtek/clk-regmap-mux.c | 63 ++++ drivers/clk/realtek/clk-regmap-mux.h | 26 ++ drivers/clk/realtek/common.c | 320 +++++++++++++++++++++ drivers/clk/realtek/common.h | 123 ++++++++ 14 files changed, 1420 insertions(+)
This patch is way too large for me to review. Please split this up further into logically self-contained, compile-testable patches.
Quoted 30 lines
create mode 100644 drivers/clk/realtek/Kconfig create mode 100644 drivers/clk/realtek/Makefile create mode 100644 drivers/clk/realtek/clk-pll-dif.c create mode 100644 drivers/clk/realtek/clk-pll-psaud.c create mode 100644 drivers/clk/realtek/clk-pll.c create mode 100644 drivers/clk/realtek/clk-pll.h create mode 100644 drivers/clk/realtek/clk-regmap-gate.c create mode 100644 drivers/clk/realtek/clk-regmap-gate.h create mode 100644 drivers/clk/realtek/clk-regmap-mux.c create mode 100644 drivers/clk/realtek/clk-regmap-mux.h create mode 100644 drivers/clk/realtek/common.c create mode 100644 drivers/clk/realtek/common.hdrivers/clk/Kconfig +1
-0@@ -317,6 +317,7 @@ source "drivers/clk/mediatek/Kconfig" source "drivers/clk/meson/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/qcom/Kconfig" +source "drivers/clk/realtek/Kconfig" source "drivers/clk/renesas/Kconfig" source "drivers/clk/samsung/Kconfig" source "drivers/clk/sifive/Kconfig"drivers/clk/Makefile +0
-0
drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_NXP) += nxp/ · line 98
Quoted 4 lines
drivers/clk/Makefile +1
-0@@ -95,6 +95,7 @@ obj-$(CONFIG_COMMON_CLK_NXP) += nxp/ obj-$(CONFIG_MACH_PISTACHIO) += pistachio/ obj-$(CONFIG_COMMON_CLK_PXA) += pxa/ obj-$(CONFIG_COMMON_CLK_QCOM) += qcom/ +obj-$(CONFIG_COMMON_CLK_REALTEK) += realtek/
Should we take the Renesas approach here and allow for COMPILE_TEST?
drivers/clk/realtek/Kconfig line 2
Quoted 11 lines
drivers/clk/Makefile +0
-0obj-y += renesas/ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ obj-$(CONFIG_COMMON_CLK_SAMSUNG) += samsung/drivers/clk/realtek/Kconfig new file +2
-0@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +config COMMON_CLK_REALTEK
I would personally think that it's not necessary to prefix with COMMON_ here, even if based on CONFIG_COMMON_CLK framework, since Realtek is no longer common. Stephen/Michael?
Which brings us to the next aspect, is this really universally common for Realtek? Are they compatible with old MIPS SoCs and Arm SoCs from departments other than DHC? (e.g., Smart TV)
If the answer to any of these is no, then please rename the Kconfig symbol to the oldest SoC for uniqueness, e.g., RTD1195.
drivers/clk/realtek/Kconfig line 3
Quoted 1 line
drivers/clk/realtek/Kconfig new file +1
-0+ bool "Clock driver for realtek"
Spelling.
drivers/clk/realtek/Kconfig line 4
Quoted 1 line
drivers/clk/realtek/Kconfig new file +1
-0+ select MFD_SYSCON
Please add help text and include SoC names.
drivers/clk/realtek/Kconfig line 6
Quoted 2 lines
drivers/clk/realtek/Kconfig new file +2
-0+ +config CLK_PLL_PSAUD
Too generic name.
drivers/clk/realtek/Kconfig line 9
Quoted 3 lines
drivers/clk/realtek/Kconfig new file +3
-0+ bool + +config CLK_PLL_DIF
Ditto.
Quoted 22 lines
drivers/clk/realtek/Kconfig new file +1
-0+ booldrivers/clk/realtek/Makefile new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_COMMON_CLK_REALTEK) += clk-rtk.o + +clk-rtk-y += common.o +clk-rtk-y += clk-regmap-mux.o +clk-rtk-y += clk-regmap-gate.o +clk-rtk-y += clk-pll.o +clk-rtk-$(CONFIG_CLK_PLL_PSAUD) += clk-pll-psaud.o +clk-rtk-$(CONFIG_CLK_PLL_DIF) += clk-pll-dif.odrivers/clk/realtek/clk-pll-dif.c new file +0
-0
drivers/clk/realtek/clk-pll-dif.c line 1
Quoted 1 line
drivers/clk/realtek/clk-pll-dif.c new file +1
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0-only
Can you relicense this code as GPL-2.0-or-later? For Makefile and Kconfig it doesn't matter, just for low-level code that could become relevant for debuggers like OpenOCD, which is licensed GPLv2+.
drivers/clk/realtek/clk-pll-dif.c line 2
Quoted 1 line
drivers/clk/realtek/clk-pll-dif.c new file +1
-0+/*
Care to elaborate here what "dif" is? :)
drivers/clk/realtek/clk-pll-dif.c line 10
Quoted 8 lines
drivers/clk/realtek/clk-pll-dif.c new file +8
-0+* Copyright (c) 2019 Realtek Semiconductor Corporation +* Author: Cheng-Yu Lee <[email protected]> +*/ + +#include <linux/clk-provider.h> +#include <linux/clk.h> +#include <linux/spinlock.h> +#include <linux/delay.h>
Insert white line here?
drivers/clk/realtek/clk-pll-dif.c line 18
Quoted 8 lines
drivers/clk/realtek/clk-pll-dif.c new file +8
-0+#include "common.h" +#include "clk-pll.h" + +static int clk_pll_dif_enable (struct clk_hw *hw) +{ +struct clk_pll_dif *pll =to_clk_pll_dif (hw); + +pr_debug ("%pC: %s\n" , hw->clk, __func__);
Please review debug and info messages for whether they are still needed
- in particular for info below I assume no.
drivers/clk/realtek/clk-pll-dif.c line 23
Quoted 5 lines
drivers/clk/realtek/clk-pll-dif.c new file +5
-0+ +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x0C ,0x00000048 ); +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x08 ,0x00020c00 ); +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x04 ,0x204004ca ); +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x00 ,0x8000a000 );
This is way too much dark magic!
Start with giving the offsets symbolic names, please.
Next, construct the value from symbolic constants. You will see me use BIT() and GENMASK() macros elsewhere; please adopt those conventions.
drivers/clk/realtek/clk-pll-dif.c line 24
Quoted 1 line
drivers/clk/realtek/clk-pll-dif.c new file +1
-0+udelay (100 );
Is this from some internal datasheet? Otherwise, from some MCU clocks that I've previously implemented, I would expect there to be some status bit indicating readyness that we should poll rather than trusting a hardcoded delay. I don't see a single read below, nor any explanatory comment.
drivers/clk/realtek/clk-pll-dif.c line 37
Quoted 13 lines
drivers/clk/realtek/clk-pll-dif.c new file +13
-0+ +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x08 ,0x00420c00 ); +udelay (50 ); + +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x08 ,0x00420c03 ); +udelay (200 ); + +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x0C ,0x00000078 ); +udelay (100 ); + +clk_regmap_write (&pll->clkr, pll->pll_ofs +0x04 ,0x204084ca ); + +/* ssc control */
This lonely comment seems kind of redundant with ssc_ofs vs. pll_ofs.
drivers/clk/realtek/clk-pll-dif.c line 47
Quoted 10 lines
drivers/clk/realtek/clk-pll-dif.c new file +10
-0+clk_regmap_write (&pll->clkr, pll->ssc_ofs +0x00 ,0x00000004 ); +clk_regmap_write (&pll->clkr, pll->ssc_ofs +0x04 ,0x00006800 ); +clk_regmap_write (&pll->clkr, pll->ssc_ofs +0x0C ,0x00000000 ); +clk_regmap_write (&pll->clkr, pll->ssc_ofs +0x10 ,0x00000000 ); +clk_regmap_write (&pll->clkr, pll->ssc_ofs +0x08 ,0x001e1f98 ); +clk_regmap_write (&pll->clkr, pll->ssc_ofs +0x00 ,0x00000005 ); + pll->status =1 ; + +return 0 ; +}
[snip]
I'll stop reviewing here and am waiting for a v2.
Thanks,
Andreas
Signature · 4 lines
SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)
PATCH 4/6 clk: realtek: add reset controller support for Realtek SoCs
In reply to James TaiFrom: cylee12 <[email protected]>
This patch add reset control support for Realtek SoCs.
--- drivers/clk/realtek/Kconfig | 1 + drivers/clk/realtek/Makefile | 1 + drivers/clk/realtek/reset.c | 107 +++++++++++++++++++++++++++++++++++ drivers/clk/realtek/reset.h | 37 ++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 drivers/clk/realtek/reset.c create mode 100644 drivers/clk/realtek/reset.h
drivers/clk/realtek/Kconfig +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config COMMON_CLK_REALTEK bool "Clock driver for realtek" + select RESET_CONTROLLER select MFD_SYSCON config CLK_PLL_PSAUD
drivers/clk/realtek/Makefile +1 -0
@@ -7,3 +7,4 @@ clk-rtk-y += clk-regmap-gate.o clk-rtk-y += clk-pll.o clk-rtk-$(CONFIG_CLK_PLL_PSAUD) += clk-pll-psaud.o clk-rtk-$(CONFIG_CLK_PLL_DIF) += clk-pll-dif.o +clk-rtk-y += reset.o
drivers/clk/realtek/reset.c new file +107 -0
107 lines not on this page · raw message
drivers/clk/realtek/reset.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2019 Realtek Semiconductor Corporation +* Author: Cheng-Yu Lee <[email protected]> +*/ + +#ifndef __CLK_REALTEK_RESET_H +#define __CLK_REALTEK_RESET_H + +#include <linux/reset-controller.h> + +struct rtk_reset_bank { +uint32_t ofs; +uint32_t write_en; +}; + +struct rtk_reset_data { +struct reset_controller_dev rcdev; +struct rtk_reset_bank *banks; +uint32_t num_banks; +struct regmap *regmap; +unsigned long (*id_xlate)(unsigned long id); +}; + +#define to_rtk_reset_controller (r) \ + container_of(r, struct rtk_reset_data, rcdev) + +struct rtk_reset_initdata { +struct rtk_reset_bank *banks; +uint32_t num_banks; +unsigned long (*id_xlate)(unsigned long id); +}; + +int rtk_reset_controller_add (struct device *dev,struct regmap *regmap, +struct rtk_reset_initdata *initdata); + +#endif /* __CLK_REALTEK_RESET_H */
Signature · 1 line
2.24.0
Re: [PATCH 4/6] clk: realtek: add reset controller support for Realtek SoCs
Hi James,
[dropping Palmer, adding Philipp]
$subject: I prefer to have the subject start with uppercase letter, to clearly distinguish it from the lowercase prefixes (and because that's how a book or newspaper headline would start, too). Applies also to other patches in this series, e.g., "reset: Add ..." (cf. below).
Am 03.12.19 um 08:45 schrieb James Tai:
Quoted 1 line
From: cylee12 <[email protected]>
--author.
Quoted 2 lines
This patch add reset control support for Realtek SoCs.
Please don't write "This patch" in a Git commit message. You can elegantly avoid the patch vs. commit topic by using "This adds" (and note the grammar for third-person presence vs. imperative in subject).
All SoCs since the beginning of time or just RTD1619 and later? As you know, we're already using reset-simple driver for RTD1295.
Quoted 8 lines
Signed-off-by Cheng-Yu Lee <[email protected]>Signed-off-by James Tai <[email protected]>--- drivers/clk/realtek/Kconfig | 1 + drivers/clk/realtek/Makefile | 1 + drivers/clk/realtek/reset.c | 107 +++++++++++++++++++++++++++++++++++ drivers/clk/realtek/reset.h | 37 ++++++++++++
Why in the world under clk? I just introduced syscon nodes to cleanly allow accessing CRT and Iso registers from multiple independent drivers, and I have patches doing exactly that for RTD1295 and RTD1195. Please move it into drivers/reset/, also to make sure that for v2 the reset maintainers actually get CC'ed for review.
drivers/clk/realtek/Kconfig line 4
Quoted 13 lines
4 files changed, 146 insertions(+) create mode 100644 drivers/clk/realtek/reset.c create mode 100644 drivers/clk/realtek/reset.hdrivers/clk/realtek/Kconfig +1
-0@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config COMMON_CLK_REALTEK bool "Clock driver for realtek" + select RESET_CONTROLLER
No!
BTW if you would make this Kconfig option "depends on ARCH_REALTEK" then it would be selected already. However, ARCH_REALTEK || COMPILE_TEST would be preferable for noticing errors early. It doesn't make sense to allow selecting this driver for non-Realtek systems unless COMPILE_TEST asks for it.
Quoted 18 lines
drivers/clk/realtek/Kconfig +0
-0select MFD_SYSCON config CLK_PLL_PSAUDdrivers/clk/realtek/Makefile +1
-0@@ -7,3 +7,4 @@ clk-rtk-y += clk-regmap-gate.o clk-rtk-y += clk-pll.o clk-rtk-$(CONFIG_CLK_PLL_PSAUD) += clk-pll-psaud.o clk-rtk-$(CONFIG_CLK_PLL_DIF) += clk-pll-dif.o +clk-rtk-y += reset.odrivers/clk/realtek/reset.c new file +0
-0
drivers/clk/realtek/reset.c line 1
Quoted 1 line
drivers/clk/realtek/reset.c new file +1
-0@@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-only
Is GPL-2.0-or-later possible?
drivers/clk/realtek/reset.c line 7
Quoted 6 lines
drivers/clk/realtek/reset.c new file +6
-0+/* +* Copyright (C) 2019 Realtek Semiconductor Corporation +*/ + +#include <linux/of.h> +#include <linux/device.h>
Sort order.
drivers/clk/realtek/reset.c line 10
Quoted 3 lines
drivers/clk/realtek/reset.c new file +3
-0+#include <linux/regmap.h> +#include <linux/reset-controller.h> +#include <linux/slab.h>
White line please ...
drivers/clk/realtek/reset.c line 11
Quoted 1 line
drivers/clk/realtek/reset.c new file +1
-0+#include "reset.h"
... or better try to avoid this #include by driver design.
drivers/clk/realtek/reset.c line 13
Quoted 2 lines
drivers/clk/realtek/reset.c new file +2
-0+ +static int rtk_reset_assert(struct reset_controller_dev *rcdev,
rtd1619_?
drivers/clk/realtek/reset.c line 16
Quoted 3 lines
drivers/clk/realtek/reset.c new file +3
-0+ unsigned long idx) +{ +struct rtk_reset_data *data =to_rtk_reset_controller (rcdev);
_controller vs. _data looks weird.
drivers/clk/realtek/reset.c line 20
Quoted 4 lines
drivers/clk/realtek/reset.c new file +4
-0+struct rtk_reset_bank *bank = &data->banks[idx >>8 ]; +uint32_t id = idx &0xff ; +uint32_t mask = bank->write_en ? (0x3 << id) :BIT (id); +uint32_t val = bank->write_en ? (0x2 << id) :0 ;
Peeking into patch 5/6, write_en seems always 1 for CRT and 0 for a single ISO bank.
Wouldn't it be easier to just keep two different drivers, one for RTD1619-and-later with the new semantics, and one for the older simpler semantics? I was really just waiting for you to post a trivial patch that with an ack from Rob Philipp and I could apply right away. This here is huge and I don't think you realize yet how convoluted this is for trying to merge this into mainline within one merge window...
Quoted 5 lines
drivers/clk/realtek/reset.c new file +5
-0+ +return regmap_update_bits (data->regmap, bank->ofs, mask, val); +} + +static int rtk_reset_deassert(struct reset_controller_dev *rcdev,
drivers/clk/realtek/reset.c line 35
Quoted 10 lines
drivers/clk/realtek/reset.c new file +10
-0+ unsigned long idx) +{ +struct rtk_reset_data *data =to_rtk_reset_controller (rcdev); +struct rtk_reset_bank *bank = &data->banks[idx >>8 ]; +uint32_t id = idx &0xff ; +uint32_t mask = bank->write_en ? (0x3 << id) :BIT (id); +uint32_t val = mask; + +return regmap_update_bits (data->regmap, bank->ofs, mask, val); +}
The way I first read this code, there's one bit BIT(1) for writing the new status and one bit BIT(0) for checking current status? Shouldn't enable/disable then poll for the change to go into effect before returning? Otherwise the caller may make wrong assumptions.
Or is this like the write_data bit for the irq mux ISR but in bit 1? Then I am having trouble following this code and wonder why you use regmap_update_bits() in the first place, if only some bits get written anyway - use plain regmap_write() then. If I am puzzled, having seen the other code, then consider it badly maintainable for the community...
You need to make the code self-documenting by using symbolic constants instead of magic numbers, or add an inline helper. Maybe add comments.
drivers/clk/realtek/reset.c line 47
Quoted 12 lines
drivers/clk/realtek/reset.c new file +12
-0+ +static int rtk_reset_reset (struct reset_controller_dev *rcdev, +unsigned long idx) +{ +int ret; + + ret =rtk_reset_assert (rcdev, idx); +if (ret) +return ret; + +return rtk_reset_deassert (rcdev, idx); +}
Does the reset core not do this for us? (If not, shouldn't we fix that?)
drivers/clk/realtek/reset.c line 58
Quoted 11 lines
drivers/clk/realtek/reset.c new file +11
-0+ +static int rtk_reset_status (struct reset_controller_dev *rcdev, +unsigned long idx) +{ +struct rtk_reset_data *data =to_rtk_reset_controller (rcdev); +struct rtk_reset_bank *bank = &data->banks[idx >>8 ]; +uint32_t id = idx &0xff ; +uint32_t val; + +regmap_read (data->regmap, bank->ofs, &val); +return !((val >> id) &1 );
return !(val & BIT(id)); seems much more readable to me?
Without seeing bit 0 read here, the above enable/disable code would be even more confusing.
Please share what the register bits are actually called, then we can discuss what the best way of calling and using them will be.
Quoted 11 lines
drivers/clk/realtek/reset.c new file +11
-0+} + +static struct reset_control_ops rtk_reset_ops = { + .assert = rtk_reset_assert, + .deassert = rtk_reset_deassert, + .reset = rtk_reset_reset, + .status = rtk_reset_status, +}; + +static int rtk_of_reset_xlate (struct reset_controller_dev *rcdev, +const struct of_phandle_args *reset_spec)
drivers/clk/realtek/reset.c line 79
Quoted 10 lines
drivers/clk/realtek/reset.c new file +10
-0+{ +struct rtk_reset_data *data =to_rtk_reset_controller (rcdev); +int val; + + val = reset_spec->args[0 ]; +if (val >= rcdev->nr_resets) +return -EINVAL ; + +if (data->id_xlate) +return data->id_xlate (val);
This does not appear to be used in this series - how do you envision it to be used? That would need to be covered in the dt-binding then.
drivers/clk/realtek/reset.c line 85
Quoted 6 lines
drivers/clk/realtek/reset.c new file +6
-0+return val; +} + + +int rtk_reset_controller_add (struct device *dev,struct regmap *regmap, +struct rtk_reset_initdata *initdata)
Just get that initdata via DT compatible within this reset driver, like I did for irqchip.
Quoted 6 lines
drivers/clk/realtek/reset.c new file +6
-0+{ +struct rtk_reset_data *data; +struct device_node *np = dev->of_node; + + data =kzalloc (sizeof (*data),GFP_KERNEL ); +if (!data)
drivers/clk/realtek/reset.c line 101
Quoted 10 lines
drivers/clk/realtek/reset.c new file +10
-0+return -ENOMEM ; + data->regmap = regmap; + data->num_banks = initdata->num_banks; + data->banks = initdata->banks; + data->id_xlate = initdata->id_xlate; + + data->rcdev.owner =THIS_MODULE ; + data->rcdev.ops = &rtk_reset_ops; + data->rcdev.of_node = np; + data->rcdev.nr_resets = initdata->num_banks *0x100 ;
This design doesn't make much sense to me? At most a bank is going to get you 32 resets, 16 in case of the new ones, all much smaller than 256.
The theoretical-here case of mixed sizes you could just handle by exposing them as individual DT nodes, like we do today, which as a bonus would make the syscon DT node nicely self-documenting. I.e., "realtek,rtd1619-reset" vs. "realtek,rtd1195-reset".
drivers/clk/realtek/reset.c line 107
Quoted 6 lines
drivers/clk/realtek/reset.c new file +6
-0+ data->rcdev.of_xlate = rtk_of_reset_xlate; + data->rcdev.of_reset_n_cells =1 ; + +return reset_controller_register (&data->rcdev); +} +
Trailing white line.
I would expect a platform_driver here, turning above _add into _probe.
Quoted 10 lines
drivers/clk/realtek/reset.h new file +4
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2019 Realtek Semiconductor Corporation +* Author: Cheng-Yu Lee <[email protected]>
drivers/clk/realtek/reset.h line 14
Quoted 10 lines
drivers/clk/realtek/reset.h new file +10
-0+*/ + +#ifndef __CLK_REALTEK_RESET_H +#define __CLK_REALTEK_RESET_H + +#include <linux/reset-controller.h> + +struct rtk_reset_bank { + uint32_t ofs; + uint32_t write_en;
If we needed this, it might as well be bool with true/false.
drivers/clk/realtek/reset.h line 19
Quoted 5 lines
drivers/clk/realtek/reset.h new file +5
-0+}; + +struct rtk_reset_data { +struct reset_controller_dev rcdev; +struct rtk_reset_bank *banks;
const?
drivers/clk/realtek/reset.h line 22
Quoted 3 lines
drivers/clk/realtek/reset.h new file +3
-0+uint32_t num_banks; +struct regmap *regmap; +unsigned long (*id_xlate)(unsigned long id);
Drop until used?
drivers/clk/realtek/reset.h line 29
Quoted 7 lines
drivers/clk/realtek/reset.h new file +7
-0+}; + +#define to_rtk_reset_controller (r) \ + container_of(r, struct rtk_reset_data, rcdev) + +struct rtk_reset_initdata { +struct rtk_reset_bank *banks;
const?
drivers/clk/realtek/reset.h line 31
Quoted 2 lines
drivers/clk/realtek/reset.h new file +2
-0+uint32_t num_banks; +unsigned long (*id_xlate)(unsigned long id);
Drop until used?
drivers/clk/realtek/reset.h line 37
Quoted 6 lines
drivers/clk/realtek/reset.h new file +6
-0+}; + +int rtk_reset_controller_add (struct device *dev,struct regmap *regmap, +struct rtk_reset_initdata *initdata); + +#endif /* __CLK_REALTEK_RESET_H */
Regards,
Andreas
Signature · 4 lines
SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)
PATCH 5/6 clk: realtek: add rtd1619 controllers
In reply to James TaiFrom: cylee12 <[email protected]>
This patch adds CRT controller and ISO controller for RTD1619 SoC.
--- drivers/clk/realtek/Kconfig | 10 + drivers/clk/realtek/Makefile | 2 + drivers/clk/realtek/clk-rtd1619-cc.c | 553 +++++++++++++++++++++++++++ drivers/clk/realtek/clk-rtd1619-ic.c | 112 ++++++ 4 files changed, 677 insertions(+) create mode 100644 drivers/clk/realtek/clk-rtd1619-cc.c create mode 100644 drivers/clk/realtek/clk-rtd1619-ic.c
drivers/clk/realtek/Kconfig +10 -0
@@ -9,3 +9,13 @@ config CLK_PLL_PSAUD config CLK_PLL_DIF bool + +config COMMON_CLK_RTD1619 + bool "RTD1619 Clock Controller" + depends on ARCH_REALTEK || COMPILE_TEST + select COMMON_CLK_REALTEK + select CLK_PLL_PSAUD + select CLK_PLL_DIF + default ARCH_REALTEK + ---help--- + Support for the clock controller on RTD1619
drivers/clk/realtek/Makefile +2 -0
@@ -8,3 +8,5 @@ clk-rtk-y += clk-pll.o clk-rtk-$(CONFIG_CLK_PLL_PSAUD) += clk-pll-psaud.o clk-rtk-$(CONFIG_CLK_PLL_DIF) += clk-pll-dif.o clk-rtk-y += reset.o +clk-rtk-$(CONFIG_COMMON_CLK_RTD1619) += clk-rtd1619-cc.o +clk-rtk-$(CONFIG_COMMON_CLK_RTD1619) += clk-rtd1619-ic.o
drivers/clk/realtek/clk-rtd1619-cc.c new file +553 -0
553 lines not on this page · raw message
drivers/clk/realtek/clk-rtd1619-ic.c new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
2.24.0
PATCH 6/6 dt-bindings: clk: realtek: add rtd1619 clock controller bindings
In reply to James TaiFrom: cylee12 <[email protected]>
--- .../bindings/clock/realtek,clocks.txt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/realtek,clocks.txt
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +38 -0
@@ -0,0 +1,38 @@ +Realtek Clock/Reset Controller +============================== + +Realtek CRT/ISO controller device-tree binding for Realtek Platforms. + +This binding uses the common clock binding[1]. + +The controller node should be the child of a syscon node with the required +propertise: + +- compatible : + should contain only one of the following: + "realtek,rtd1619-cc" for RTD1619 CRT clock controller, + "realtek,rtd1619-ic" for RTD1619 ISO clock controller, + +- #clock-cells : should be 1. + +- #reset-cells : should be 1. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Example: + + crt@98000000 { + compatible = "realtek,rtd1619-crt", "simple-mfd", "syscon"; + reg = <0x98000000 0x1000>; + + cc: cc@98000000 { + compatible = "realtek,rtd1619-cc"; + #clock-cells = <1>; + #reset-cells = <1>; + }; + }; + + consumer { + clocks = <&cc CC_CKE_GSPI>; + }; +
Signature · 1 line
2.24.0
Re: [PATCH 6/6] dt-bindings: clk: realtek: add rtd1619 clock controller bindings
Hi James,
[dropping Palmer, adding Philipp]
Am 03.12.19 um 08:45 schrieb James Tai:
Quoted 1 line
From: cylee12 <[email protected]>
Author.
$subject: clk vs. clock prefix
Lacking a commit message here.
Quoted 5 lines
Signed-off-by Cheng-Yu Lee <[email protected]>Signed-off-by James Tai <[email protected]>--- .../bindings/clock/realtek,clocks.txt | 38 +++++++++++++++++++
Please use YAML schema for any new bindings.
Quoted 2 lines
1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/realtek,clocks.txt
This patch needs to be ordered before patches using the binding in a driver or DT. In this case it should've been squashed into 1/6.
Quoted 10 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +4
-0@@ -0,0 +1,38 @@ +Realtek Clock/Reset Controller +============================== + +Realtek CRT/ISO controller device-tree binding for Realtek Platforms.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 14
Quoted 10 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +10
-0+ +This binding uses the common clock binding[1]. + +The controller node should be the child of a syscon node with the required +propertise: + +- compatible : + should contain only one of the following: + "realtek,rtd1619-cc" for RTD1619 CRT clock controller, + "realtek,rtd1619-ic" for RTD1619 ISO clock controller,
-ic does not strike me as the best name, can we go with -iso-something for consistency?
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 24
Quoted 10 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +10
-0+ +- #clock-cells : should be 1. + +- #reset-cells : should be 1. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Example: + + crt@98000000 {
crt: syscon@...
Always prefer generic node names when possible.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 25
Quoted 1 line
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +1
-0+ compatible = "realtek,rtd1619-crt", "simple-mfd", "syscon";
1) You must not use undefined compatible strings in your example! If we want to use such compatibles (which I agree with in principle), then we need to post separate bindings patches before you do so. The big issue there is how to name them to work across SoC families. For that reason my syscon series did not include dt-bindings, to not hold us up with them. Drop it here for now?
2) You must retain the valid order, here defined by the syscon binding. Like I said for the Mjolnir .dts. If we consequently use YAML schemas, then you can check your .dts files with make dtbs_check and hopefully notice it yourself before I complain. .dtsi patches are sadly missing in this series, so you could only run limited make dt_binding_check.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 28
Quoted 3 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +3
-0+ reg = <0x98000000 0x1000>; + + cc: cc@98000000 {
But you must not give a unit address in absence of reg.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 29
Quoted 1 line
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +1
-0+ compatible = "realtek,rtd1619-cc";
reg missing. When you add it, you need #address-cells and #size-cells above, too. Also ranges for completeness. In YAML it gets compile-tested and should not sprout warnings.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 31
Quoted 2 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +2
-0+ #clock-cells = <1>; + #reset-cells = <1>;
BTW given the complex mappings that you attempt, wouldn't it be easier to use #reset-cells = <2>? In that case one could again argue that a per-bank node/driver will be easier.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 33
Quoted 2 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +2
-0+ }; + };
Haven't tested this yet, but I wonder whether we could just use "realtek,rtd1619-crt" for the clock controller directly and still use the same node as syscon mfd? If not, it might be nice to describe in the child node's reg what exactly is covered instead of just <0x0 0x1000>.
My point here is that the DT describes the hardware, but that does not dictate how the Linux drivers bind to DT. clk is no platform_driver, so you can have clk and reset drivers binding to the same DT compatible. Did that for STM32 CRT once. However, don't hide the binding under clock if it's really mfd - someone looking for reset bindings is going to have a hard time finding them under clock.
Documentation/devicetree/bindings/clock/realtek,clocks.txt line 38
Quoted 5 lines
Documentation/devicetree/bindings/clock/realtek,clocks.txt new file +5
-0+ + consumer { + clocks = <&cc CC_CKE_GSPI>; + }; +
Regards,
Andreas
Signature · 4 lines
SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)