Skip to contentSkip to conversation

Add DM support for omap PWM backlight

PATCH Superseded Dario Binacchi 1 participant 14 messages Dec 24, 2020

Subsystems (6)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover Add DM support for omap PWM backlight

The series was born from the need to manage the PWM backlight of the display connected to my beaglebone board. To hit the target, I had to develop drivers for PWM management which in turn relied on drivers for managing timers and clocks, all developed according to the driver model. My intention was to use the SoC-specific API only at strictly necessary points in the code. My previous patches for migrating the AM335x display driver to the driver model had required the implementation of additional functions outside the concerns of the driver, (settings for dividing the pixel clock rate, configuring the display DPLL rate, ....) not being able to use the API of the related clock drivers. This series shouldn't have repeated the same kind of mistake. Furthermore, I also wanted to fix that kind of forced choice. Almost everything should have been accessible via the driver model API. In the series there are also some patches that could be submitted separately, but which I have however inserted to avoid applying future patches to incorporate them.
With this last consideration, I hope I have convincingly justified the large number of patches in the series.

The patch enabling address translation into a CPU physical address from device-tree even in case of crossing levels with #size-cells = <0>, is crucial for the series. The previous implementation was unable to perform the address translation required by the am33xx device tree. I tried to apply in a conservative way as few changes as possible and to verify the execution of all the tests already developed, as well as the new ones I added for the new feature.

The patch series can be cleanly applied to the HEAD of the master which at the time of release points to c15f44acf9 commit.

Changes in v7:
- Not all OMAP2 platform need CONFIG_TI_SYSC.
Set CONFIG_TI_SYSC as imply and disable it to fix building errors in:
nokia_rx51_defconfig
cm_t335_defconfig
- Add gd_size_cells_0 macro to fix building errors for boards that do not use CONFIG_DM.
- Add dm8168-evm-u-boot.dtsi to fix building errors for ti816x_evm_defconfig.
- Add linux/err.h header in am335x-fb.c to fix building errors for brxre1_defconfig.
- Fix building errors for:
brppt1_mmc_defconfig
brppt1_nand_defconfig
brppt1_spi_defconfig
brxre1_defconfig
brsmarc1_defconfig

Changes in v6:
- Remove the 'am3-prcm' driver.
- Add the 'simple-bus' compatible string to the prcm_clocks node.
- Remove the 'am3-scm' driver.
- Add the 'simple-bus' compatible string to the scm_clocks node.

Changes in v5:
- Create drivers/clk/ti directory.
- Move the clk-ti-mux.c file to drivers/clk/ti and rename it clk-mux.c
- Move the clk-ti-am3-dpll.c file to drivers/clk/ti with the name clk-am3-dpll.c.
- Move the clk-ti-am3-dpll-x2.c file to drivers/clk/ti with the name clk-am3-dpll-x2.c.
- Move the clk-ti.c file to drivers/clk/ti with the name clk.c.
- Move the clk-ti.h file to drivers/clk/ti with the name clk.h.
- Move the clk-ti-divider.c file to drivers/clk/ti with the name clk-divider.c.
- Move the clk-ti-gate.c file to drivers/clk/ti with the name clk-gate.c.
- Move the clk-ti-ctrl.c file to drivers/clk/ti with the name clk-ctrl.c.

Changes in v4:
- Include device_compat.h header for dev_xxx macros.
- Remove a blank line at end of file arch/arm/dts/am33xx-l4.dtsi.
- Update clk_round_rate description.
- Add Sean Anderson review.
- Include device_compat.h header for dev_xxx macros.
- Include device_compat.h header for dev_xxx macros.
- Fix compilation errors on the dev parameter of the dev_xx macros.
- Include device_compat.h header for dev_xxx macros.
- Fix compilation errors on the dev parameter of the dev_xx macros.
- Include device_compat.h header for dev_xxx macros.
- Include device_compat.h header for dev_xxx macros.
- Fix compilation errors on the dev parameter of the dev_xx macros.
- Include device_compat.h header for dev_xxx macros.
- Add Sphinx documentation for dm_flags.
- Convert GD_DM_FLG_* to enum.
- Include device_compat.h header in test/dm/test-fdt.c for dev_xxx macros.
- Include device_compat.h header for dev_xxx macros.
- Include device_compat.h header for dev_xxx macros.
- Include device_compat.h header for dev_xxx macros.
- Add Simon Glass review.
- Include device_compat.h header for dev_xxx macros.

Changes in v3:
- Remove doc/device-tree-bindings/clock/clock-bindings.txt.
- Remove doc/device-tree-bindings/clock/ti,mux.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Remove doc/device-tree-bindings/clock/ti,dpll.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Remove doc/device-tree-bindings/clock/ti,autoidle.txt.
- Remove doc/device-tree-bindings/clock/ti,divider.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Remove doc/device-tree-bindings/clock/gpio-gate-clock.txt.
- Remove doc/device-tree-bindings/clock/ti,clockdomain.txt.
- Remove doc/device-tree-bindings/clock/ti,gate.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Fix access to registers listed by device tree following resync of am33xx-clock.dtsi with Linux 5.9-rc7.
- Remove doc/device-tree-bindings/clock/ti,clkctrl.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- doc/device-tree-bindings/arm/omap,prcm.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Add to commit message the references to linux kernel dt binding documentation.
- Comment dm_flags field in the global_data structure.
- Remove doc/device-tree-bindings/arm/omap,ctrl.txt.
- Remove doc/device-tree-bindings/pinctrl/pinctrl-single.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Adds PWM_TI_EHRPWM dependency on ARCH_OMAP2PLUS in Kconfig.
- Add error message in case of invalid address.
- Remove doc/device-tree-bindings/pwm/ti,ehrpwm.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Move Kconfig symbol from drivers/pwm to drivers/bus.
- Remove the domain clock reference from the pwmss nodes of the device tree in am33xx.dtsi. The resync of am33xx.dtsi with Linux 5.9-rc7 already contains such references.
- Remove domain clock enabling/disabling. Enabling the domain clock is performed by the sysc interconnect target module driver during the pwm device probing.
- Remove doc/device-tree-bindings/pwm/ti,pwmss.txt.
- Add to commit message the references to linux kernel dt binding documentation.
- Update the DTS lcdc node of the am335x boards because of the am33xx.dtsi resynced with Linux 5.9-rc7.
- Remove clock domain enabling/disabling.
- Update the commit message.
- Add clk.h header.
- Fix an error code returned by the probe function.

Changes in v2:
- Add the clk_ prefix to the divider functions.
- Add kernel-doc comments to the exported functions.
- Merged to patch [09/31] clk: ti: refactor mux and divider clock drivers.
- Remove the 'ti_am3_prcm_clocks' driver. Handle 'prcm_clocks' node in the 'ti_am3_prcm' driver.
- Update the commit message.
- Fix a missing line in the commit message.
- Add dm_flags to global_data structure and GD_DM_FLG_SIZE_CELLS_0 macro to test without recompiling.
- Update the OF_CHECK_COUNTS macro in order to have just one #define by bringing the GD_DM_FLG_SIZE_CELLS_0 into the expression.
- Lower-case the 0xC019 hex number.
- Remove the 'ti_am3_scm_clocks' driver. Handle 'scm_clocks' node in the 'ti_am3_scm' driver.
- Update the commit message.

Dario Binacchi (28):
clk: export generic routines
dt-bindings: bus: ti-sysc: resync with Linux 5.9-rc7
bus: ti: add minimal sysc interconnect target driver
arm: dts: sync am33xx with Linux 5.9-rc7
clk: add clk_round_rate()
clk: ti: add mux clock driver
arm: ti: am33xx: add DPLL_EN_FAST_RELOCK_BYPASS macro
clk: ti: am33xx: add DPLL clock drivers
clk: ti: add divider clock driver
clk: ti: add gate clock driver
arm: dts: am335x: include am33xx-u-boot.dtsi
ti: am33xx: fix do_enable_clocks() to accept NULL parameters
clk: ti: add support for clkctrl clocks
clk: ti: omap4: add clock manager driver
arm: dts: am335x: enable prcm_clocks auto binding
clk: move clk-ti-sci driver to 'ti' directory
fdt: translate address if #size-cells = <0>
omap: timer: fix the rate setting
arm: dts: am335x: enable scm_clocks auto binding
pwm: ti: am33xx: add enhanced pwm driver
bus: ti: am33xx: add pwm subsystem driver
dm: core: add a function to decode display timings
video: omap: add panel driver
video: omap: drop domain clock enabling by SOC api
video: omap: set LCD clock rate through DM API
video: omap: split the legacy code from the DM code
video: omap: move drivers to 'ti' directory
board: ti: am335x-ice: get CDCE913 clock device

 arch/arm/Kconfig                           |    1 +
 arch/arm/dts/am335x-brppt1-mmc.dts         |   17 +-
 arch/arm/dts/am335x-brppt1-nand.dts        |   17 +-
 arch/arm/dts/am335x-brppt1-spi.dts         |   17 +-
 arch/arm/dts/am335x-brsmarc1.dts           |   20 +-
 arch/arm/dts/am335x-brxre1.dts             |   21 +-
 arch/arm/dts/am335x-chiliboard-u-boot.dtsi |    2 +
 arch/arm/dts/am335x-draco.dtsi             |   11 +-
 arch/arm/dts/am335x-evm-u-boot.dtsi        |   17 +-
 arch/arm/dts/am335x-evm.dts                |    2 +-
 arch/arm/dts/am335x-evmsk-u-boot.dtsi      |   16 +-
 arch/arm/dts/am335x-evmsk.dts              |    2 +-
 arch/arm/dts/am335x-guardian-u-boot.dtsi   |   25 +-
 arch/arm/dts/am335x-icev2-u-boot.dtsi      |    3 +
 arch/arm/dts/am335x-pdu001-u-boot.dtsi     |   20 +-
 arch/arm/dts/am335x-pxm2.dtsi              |    2 +-
 arch/arm/dts/am335x-pxm50-u-boot.dtsi      |   16 +-
 arch/arm/dts/am335x-regor-rdk-u-boot.dtsi  |    2 +
 arch/arm/dts/am335x-rut-u-boot.dtsi        |   16 +-
 arch/arm/dts/am335x-rut.dts                |    2 +-
 arch/arm/dts/am335x-shc-u-boot.dtsi        |    2 +
 arch/arm/dts/am335x-shc.dts                |    2 +-
 arch/arm/dts/am335x-wega-rdk-u-boot.dtsi   |    2 +
 arch/arm/dts/am33xx-clocks.dtsi            |  106 +-
 arch/arm/dts/am33xx-l4.dtsi                | 1962 ++++++++++++++++++++
 arch/arm/dts/am33xx-u-boot.dtsi            |    8 +
 arch/arm/dts/am33xx.dtsi                   |  721 +++----
 arch/arm/dts/da850-evm-u-boot.dtsi         |   18 +-
 arch/arm/dts/dm8168-evm-u-boot.dtsi        |   12 +
 arch/arm/include/asm/arch-am33xx/clock.h   |    1 +
 arch/arm/mach-omap2/am33xx/clock.c         |   10 +-
 arch/arm/mach-omap2/am33xx/clock_am33xx.c  |    2 +-
 arch/sandbox/dts/test.dts                  |   67 +
 arch/sandbox/include/asm/clk.h             |    9 +
 board/BuR/common/bur_common.h              |    2 +-
 board/BuR/common/common.c                  |    2 +-
 board/ti/am335x/board.c                    |    2 +-
 board/ti/am43xx/board.c                    |    2 +-
 common/fdt_support.c                       |    6 +-
 configs/cm_t335_defconfig                  |    1 +
 configs/nokia_rx51_defconfig               |    1 +
 drivers/bus/Kconfig                        |   13 +
 drivers/bus/Makefile                       |    2 +
 drivers/bus/ti-pwmss.c                     |   21 +
 drivers/bus/ti-sysc.c                      |  166 ++
 drivers/clk/Kconfig                        |    9 +-
 drivers/clk/Makefile                       |    2 +-
 drivers/clk/clk-divider.c                  |   24 +-
 drivers/clk/clk-uclass.c                   |   15 +
 drivers/clk/clk_sandbox.c                  |   17 +
 drivers/clk/clk_sandbox_test.c             |   10 +
 drivers/clk/ti/Kconfig                     |   43 +
 drivers/clk/ti/Makefile                    |   13 +
 drivers/clk/ti/clk-am3-dpll-x2.c           |   79 +
 drivers/clk/ti/clk-am3-dpll.c              |  268 +++
 drivers/clk/ti/clk-ctrl.c                  |  154 ++
 drivers/clk/ti/clk-divider.c               |  381 ++++
 drivers/clk/ti/clk-gate.c                  |   93 +
 drivers/clk/ti/clk-mux.c                   |  253 +++
 drivers/clk/{clk-ti-sci.c => ti/clk-sci.c} |    0
 drivers/clk/ti/clk.c                       |   34 +
 drivers/clk/ti/clk.h                       |   13 +
 drivers/clk/ti/omap4-cm.c                  |   22 +
 drivers/core/Kconfig                       |   12 +
 drivers/core/fdtaddr.c                     |    2 +-
 drivers/core/of_addr.c                     |   13 +-
 drivers/core/ofnode.c                      |    7 +-
 drivers/core/read.c                        |    6 +
 drivers/core/root.c                        |    3 +
 drivers/pwm/Kconfig                        |    7 +
 drivers/pwm/Makefile                       |    1 +
 drivers/pwm/pwm-ti-ehrpwm.c                |  468 +++++
 drivers/timer/omap-timer.c                 |    6 +-
 drivers/video/Kconfig                      |    5 +-
 drivers/video/Makefile                     |    2 +-
 drivers/video/ti/Kconfig                   |    8 +
 drivers/video/ti/Makefile                  |   10 +
 drivers/video/{ => ti}/am335x-fb.c         |  341 +---
 drivers/video/{ => ti}/am335x-fb.h         |    4 -
 drivers/video/ti/tilcdc-panel.c            |  172 ++
 drivers/video/ti/tilcdc-panel.h            |   14 +
 drivers/video/ti/tilcdc.c                  |  425 +++++
 drivers/video/ti/tilcdc.h                  |   38 +
 include/asm-generic/global_data.h          |   24 +
 include/clk-uclass.h                       |    8 +
 include/clk.h                              |   28 +
 include/dm/read.h                          |   24 +
 include/dt-bindings/bus/ti-sysc.h          |    6 +
 include/linux/clk-provider.h               |   57 +
 test/dm/clk.c                              |   22 +
 test/dm/test-fdt.c                         |  149 +-
 91 files changed, 5691 insertions(+), 970 deletions(-)
 create mode 100644 arch/arm/dts/am33xx-l4.dtsi
 create mode 100644 arch/arm/dts/dm8168-evm-u-boot.dtsi
 create mode 100644 drivers/bus/ti-pwmss.c
 create mode 100644 drivers/bus/ti-sysc.c
 create mode 100644 drivers/clk/ti/Kconfig
 create mode 100644 drivers/clk/ti/Makefile
 create mode 100644 drivers/clk/ti/clk-am3-dpll-x2.c
 create mode 100644 drivers/clk/ti/clk-am3-dpll.c
 create mode 100644 drivers/clk/ti/clk-ctrl.c
 create mode 100644 drivers/clk/ti/clk-divider.c
 create mode 100644 drivers/clk/ti/clk-gate.c
 create mode 100644 drivers/clk/ti/clk-mux.c
 rename drivers/clk/{clk-ti-sci.c => ti/clk-sci.c} (100%)
 create mode 100644 drivers/clk/ti/clk.c
 create mode 100644 drivers/clk/ti/clk.h
 create mode 100644 drivers/clk/ti/omap4-cm.c
 create mode 100644 drivers/pwm/pwm-ti-ehrpwm.c
 create mode 100644 drivers/video/ti/Kconfig
 create mode 100644 drivers/video/ti/Makefile
 rename drivers/video/{ => ti}/am335x-fb.c (54%)
 rename drivers/video/{ => ti}/am335x-fb.h (97%)
 create mode 100644 drivers/video/ti/tilcdc-panel.c
 create mode 100644 drivers/video/ti/tilcdc-panel.h
 create mode 100644 drivers/video/ti/tilcdc.c
 create mode 100644 drivers/video/ti/tilcdc.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v7 1/28 clk: export generic routines

Export routines that can be used by other drivers avoiding duplicating code.

---

(no changes since v2)

Changes in v2:
- Add the clk_ prefix to the divider functions.
- Add kernel-doc comments to the exported functions.

 drivers/clk/clk-divider.c    | 24 +++++++--------
 include/linux/clk-provider.h | 57 ++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 12 deletions(-)
drivers/clk/clk-divider.c +12 -12
index 8f59d7fb72..9df50a5e72 100644
@@ -28,8 +28,8 @@
 
 #define UBOOT_DM_CLK_CCF_DIVIDER "ccf_clk_divider"
 
-static unsigned int _get_table_div(const struct clk_div_table *table,
-				   unsigned int val)
+unsigned int clk_divider_get_table_div(const struct clk_div_table *table,
+				       unsigned int val)
 {
 	const struct clk_div_table *clkt;
 
@@ -49,7 +49,7 @@ static unsigned int _get_div(const struct clk_div_table *table,
 	if (flags & CLK_DIVIDER_MAX_AT_ZERO)
 		return val ? val : clk_div_mask(width) + 1;
 	if (table)
-		return _get_table_div(table, val);
+		return clk_divider_get_table_div(table, val);
 	return val + 1;
 }
 
@@ -89,8 +89,8 @@ static ulong clk_divider_recalc_rate(struct clk *clk)
 				   divider->flags, divider->width);
 }
 
-static bool _is_valid_table_div(const struct clk_div_table *table,
-				unsigned int div)
+bool clk_divider_is_valid_table_div(const struct clk_div_table *table,
+				    unsigned int div)
 {
 	const struct clk_div_table *clkt;
 
@@ -100,18 +100,18 @@ static bool _is_valid_table_div(const struct clk_div_table *table,
 	return false;
 }
 
-static bool _is_valid_div(const struct clk_div_table *table, unsigned int div,
-			  unsigned long flags)
+bool clk_divider_is_valid_div(const struct clk_div_table *table,
+			      unsigned int div, unsigned long flags)
 {
 	if (flags & CLK_DIVIDER_POWER_OF_TWO)
 		return is_power_of_2(div);
 	if (table)
-		return _is_valid_table_div(table, div);
+		return clk_divider_is_valid_table_div(table, div);
 	return true;
 }
 
-static unsigned int _get_table_val(const struct clk_div_table *table,
-				   unsigned int div)
+unsigned int clk_divider_get_table_val(const struct clk_div_table *table,
+				       unsigned int div)
 {
 	const struct clk_div_table *clkt;
 
@@ -131,7 +131,7 @@ static unsigned int _get_val(const struct clk_div_table *table,
 	if (flags & CLK_DIVIDER_MAX_AT_ZERO)
 		return (div == clk_div_mask(width) + 1) ? 0 : div;
 	if (table)
-		return  _get_table_val(table, div);
+		return clk_divider_get_table_val(table, div);
 	return div - 1;
 }
 int divider_get_val(unsigned long rate, unsigned long parent_rate,
@@ -142,7 +142,7 @@ int divider_get_val(unsigned long rate, unsigned long parent_rate,
 
 	div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
 
-	if (!_is_valid_div(table, div, flags))
+	if (!clk_divider_is_valid_div(table, div, flags))
 		return -EINVAL;
 
 	value = _get_val(table, div, flags, width);
include/linux/clk-provider.h +57 -0

69 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v7 2/28 dt-bindings: bus: ti-sysc: resync with Linux 5.9-rc7

In reply to Dario Binacchi

Add support for PRUSS SYSC type:
The PRUSS module has a SYSCFG which is unique. The SYSCFG has two additional unique fields called STANDBY_INIT and SUB_MWAIT in addition to regular IDLE_MODE and STANDBY_MODE fields. Add the bindings for this new sysc type.

Add support for MCAN on dra76x:
The dra76x MCAN generic interconnect module has a its own format for the bits in the control registers.

---

(no changes since v1)

 include/dt-bindings/bus/ti-sysc.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/dt-bindings/bus/ti-sysc.h +6 -0
index 2c005376ac..eae4274543 100644
@@ -15,6 +15,12 @@
 /* SmartReflex sysc found on 36xx and later */
 #define SYSC_OMAP3_SR_ENAWAKEUP		(1 << 26)
 
+#define SYSC_DRA7_MCAN_ENAWAKEUP	(1 << 4)
+
+/* PRUSS sysc found on AM33xx/AM43xx/AM57xx */
+#define SYSC_PRUSS_SUB_MWAIT		(1 << 5)
+#define SYSC_PRUSS_STANDBY_INIT		(1 << 4)
+
 /* SYSCONFIG STANDBYMODE/MIDLEMODE/SIDLEMODE supported by hardware */
 #define SYSC_IDLE_FORCE			0
 #define SYSC_IDLE_NO			1
Signature · 1 line
2.17.1
#3 lore raw

PATCH v7 3/28 bus: ti: add minimal sysc interconnect target driver

In reply to Dario Binacchi

We can handle the sysc interconnect target module in a generic way for many TI SoCs. Initially let's just enable domain clocks before the children are probed.

The code is loosely based on the drivers/bus/ti-sysc.c of the Linux kernel version 5.9-rc7.
For DT binding details see:
- Documentation/devicetree/bindings/bus/ti-sysc.txt

---

Changes in v7:
- Not all OMAP2 platform need CONFIG_TI_SYSC.
Set CONFIG_TI_SYSC as imply and disable it to fix building errors in:
nokia_rx51_defconfig
cm_t335_defconfig

Changes in v4:
- Include device_compat.h header for dev_xxx macros.

 arch/arm/Kconfig             |   1 +
 configs/cm_t335_defconfig    |   1 +
 configs/nokia_rx51_defconfig |   1 +
 drivers/bus/Kconfig          |   7 ++
 drivers/bus/Makefile         |   1 +
 drivers/bus/ti-sysc.c        | 166 +++++++++++++++++++++++++++++++++++
 6 files changed, 177 insertions(+)
 create mode 100644 drivers/bus/ti-sysc.c
arch/arm/Kconfig +1 -0
index fbe90875ae..6f039f7909 100644
@@ -799,6 +799,7 @@ config ARCH_OMAP2PLUS
 	select SPL_BOARD_INIT if SPL
 	select SPL_STACK_R if SPL
 	select SUPPORT_SPL
+	imply TI_SYSC
 	imply FIT
 
 config ARCH_MESON
configs/cm_t335_defconfig +1 -0
index 3112915dc1..c4fd56b673 100644
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_CPU_INIT=y
 CONFIG_ARCH_OMAP2PLUS=y
+# CONFIG_TI_SYSC is not set
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
configs/nokia_rx51_defconfig +1 -0
index d0c8929525..30a02e2bc3 100644
@@ -4,6 +4,7 @@ CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_SYS_TEXT_BASE=0x80008000
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_TARGET_NOKIA_RX51=y
+# CONFIG_TI_SYSC is not set
 # CONFIG_FIT is not set
 CONFIG_BOOTDELAY=30
 CONFIG_AUTOBOOT_KEYED=y
drivers/bus/Kconfig +7 -0
index 07a33c6287..733bec5a56 100644
@@ -5,6 +5,13 @@
 
 menu "Bus devices"
 
+config TI_SYSC
+	bool "TI sysc interconnect target module driver"
+	depends on ARCH_OMAP2PLUS
+	help
+	  Generic driver for Texas Instruments interconnect target module
+	  found on many TI SoCs.
+
 config UNIPHIER_SYSTEM_BUS
 	bool "UniPhier System Bus driver"
 	depends on ARCH_UNIPHIER
drivers/bus/Makefile +1 -0
index 0b97fc1f8b..875bb4ed42 100644
@@ -3,4 +3,5 @@
 # Makefile for the bus drivers.
 #
 
+obj-$(CONFIG_TI_SYSC)	+= ti-sysc.o
 obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o
drivers/bus/ti-sysc.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.17.1
#4 lore raw

PATCH v7 4/28 arm: dts: sync am33xx with Linux 5.9-rc7

In reply to Dario Binacchi

There have been several changes to the am33xx.dtsi, so this patch re-syncs it with Linux.

Let's add proper interconnect hierarchy for l4 interconnect instances with the related ti-sysc interconnect module data as documented in Documentation/devicetree/bindings/bus/ti-sysc.txt of the Linux kernel. With l4 interconnect hierarchy and ti-sysc interconnect target module data in place, we can simply move all the related child devices to their proper location and enable probing using ti-sysc.

The am33xx-clock.dtsi file is the same as that of the Linux kernel, except for the reg property of the node l4-wkup-clkctrl at 0. As for the am33xx.dtsi file, all the devices with drivers not yet implemented and those I was able to test with this patch have been moved to am33xx-l4.dtsi. In case of any regressions, problem devices can be reverted by moving them back and removing the related interconnect target module node.

---

(no changes since v4)

Changes in v4:
- Remove a blank line at end of file arch/arm/dts/am33xx-l4.dtsi.

 arch/arm/dts/am335x-draco.dtsi           |   11 +-
 arch/arm/dts/am335x-evm.dts              |    2 +-
 arch/arm/dts/am335x-evmsk.dts            |    2 +-
 arch/arm/dts/am335x-guardian-u-boot.dtsi |    5 -
 arch/arm/dts/am335x-pxm2.dtsi            |    2 +-
 arch/arm/dts/am335x-rut.dts              |    2 +-
 arch/arm/dts/am335x-shc.dts              |    2 +-
 arch/arm/dts/am33xx-clocks.dtsi          |  106 +-
 arch/arm/dts/am33xx-l4.dtsi              | 1962 ++++++++++++++++++++++
 arch/arm/dts/am33xx.dtsi                 |  721 +++-----
 10 files changed, 2273 insertions(+), 542 deletions(-)
 create mode 100644 arch/arm/dts/am33xx-l4.dtsi
arch/arm/dts/am335x-draco.dtsi +6 -5
index b38ff55e1d..2c125fcec9 100644
@@ -20,11 +20,6 @@
 	};
 
 	ocp {
-		uart0: serial at 44e09000 {
-			pinctrl-names = "default";
-			pinctrl-0 = <&uart0_pins>;
-			status = "okay";
-		};
 
 		i2c0: i2c at 44e0b000 {
 			pinctrl-names = "default";
@@ -112,6 +107,12 @@
 	status = "disabled";
 };
 
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins>;
+	status = "okay";
+};
+
 &uart4 {
 	status = "disabled";
 };
arch/arm/dts/am335x-evm.dts +1 -1
index 0bda4d4429..07288fb188 100644
@@ -486,7 +486,7 @@
 &epwmss0 {
 	status = "okay";
 
-	ecap0: ecap at 48300100 {
+	ecap0: ecap at 100 {
 		status = "okay";
 		pinctrl-names = "default";
 		pinctrl-0 = <&ecap0_pins>;
arch/arm/dts/am335x-evmsk.dts +1 -1
index 5762967cf7..c94c33b595 100644
@@ -531,7 +531,7 @@
 &epwmss2 {
 	status = "okay";
 
-	ecap2: ecap at 48304100 {
+	ecap2: ecap at 100 {
 		status = "okay";
 		pinctrl-names = "default";
 		pinctrl-0 = <&ecap2_pins>;
arch/arm/dts/am335x-guardian-u-boot.dtsi +0 -5
index 705ef335bf..eae027c541 100644
@@ -26,11 +26,6 @@
 	u-boot,dm-pre-reloc;
 };
 
-&rtc {
-	clocks = <&l4_per_clkctrl AM3_CLKDIV32K_CLKCTRL 0>;
-	clock-names = "int-clk";
-};
-
 &scm {
 	u-boot,dm-pre-reloc;
 };
arch/arm/dts/am335x-pxm2.dtsi +1 -1
index 19bd7e2420..645d221507 100644
@@ -148,7 +148,7 @@
 &epwmss0 {
 	status = "okay";
 
-	ecap0: ecap at 48300100 {
+	ecap0: ecap at 100 {
 		status = "okay";
 		pinctrl-names = "default";
 		pinctrl-0 = <&ecap0_pins>;
arch/arm/dts/am335x-rut.dts +1 -1
index 145247344f..cc06f5d23a 100644
@@ -174,7 +174,7 @@
 &epwmss0 {
 	status = "okay";
 
-	ecap0: ecap at 48300100 {
+	ecap0: ecap at 100 {
 		status = "okay";
 		pinctrl-names = "default";
 		pinctrl-0 = <&ecap0_pins>;
arch/arm/dts/am335x-shc.dts +1 -1
index 8e35c439e5..a41a0606b1 100644
@@ -136,7 +136,7 @@
 &epwmss1 {
 	status = "okay";
 
-	ehrpwm1: pwm at 48302200 {
+	ehrpwm1: pwm at 200 {
 		pinctrl-names = "default";
 		pinctrl-0 = <&ehrpwm1_pins>;
 		status = "okay";
arch/arm/dts/am33xx-clocks.dtsi +80 -26

220 lines not on this page · raw message

arch/arm/dts/am33xx-l4.dtsi new file +1962 -0

1,962 lines not on this page · raw message

arch/arm/dts/am33xx.dtsi +220 -501

744 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#5 lore raw

PATCH v7 5/28 clk: add clk_round_rate()

In reply to Dario Binacchi

It returns the rate which will be set if you ask clk_set_rate() to set that rate. It provides a way to query exactly what rate you'll get if you call clk_set_rate() with that same argument.
So essentially, clk_round_rate() and clk_set_rate() are equivalent except the former does not modify the clock hardware in any way.

---

(no changes since v4)

Changes in v4:
- Update clk_round_rate description.
- Add Sean Anderson review.

 arch/sandbox/include/asm/clk.h |  9 +++++++++
 drivers/clk/clk-uclass.c       | 15 +++++++++++++++
 drivers/clk/clk_sandbox.c      | 17 +++++++++++++++++
 drivers/clk/clk_sandbox_test.c | 10 ++++++++++
 include/clk-uclass.h           |  8 ++++++++
 include/clk.h                  | 28 ++++++++++++++++++++++++++++
 test/dm/clk.c                  | 22 ++++++++++++++++++++++
 7 files changed, 109 insertions(+)
arch/sandbox/include/asm/clk.h +9 -0
index c184c4bffc..0294baee27 100644
@@ -105,6 +105,15 @@ int sandbox_clk_test_get_bulk(struct udevice *dev);
  * @return:	The rate of the clock.
  */
 ulong sandbox_clk_test_get_rate(struct udevice *dev, int id);
+/**
+ * sandbox_clk_test_round_rate - Ask the sandbox clock test device to round a
+ * clock's rate.
+ *
+ * @dev:	The sandbox clock test (client) device.
+ * @id:		The test device's clock ID to configure.
+ * @return:	The rounded rate of the clock.
+ */
+ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate);
 /**
  * sandbox_clk_test_set_rate - Ask the sandbox clock test device to set a
  * clock's rate.
drivers/clk/clk-uclass.c +15 -0
index ac954a34d2..3b8e27e4a5 100644
@@ -523,6 +523,21 @@ long long clk_get_parent_rate(struct clk *clk)
 	return pclk->rate;
 }
 
+ulong clk_round_rate(struct clk *clk, ulong rate)
+{
+	const struct clk_ops *ops;
+
+	debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
+	if (!clk_valid(clk))
+		return 0;
+
+	ops = clk_dev_ops(clk->dev);
+	if (!ops->round_rate)
+		return -ENOSYS;
+
+	return ops->round_rate(clk, rate);
+}
+
 ulong clk_set_rate(struct clk *clk, ulong rate)
 {
 	const struct clk_ops *ops;
drivers/clk/clk_sandbox.c +17 -0
index 0ff1b49633..0751e923e7 100644
@@ -30,6 +30,22 @@ static ulong sandbox_clk_get_rate(struct clk *clk)
 	return priv->rate[clk->id];
 }
 
+static ulong sandbox_clk_round_rate(struct clk *clk, ulong rate)
+{
+	struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
+
+	if (!priv->probed)
+		return -ENODEV;
+
+	if (clk->id >= SANDBOX_CLK_ID_COUNT)
+		return -EINVAL;
+
+	if (!rate)
+		return -EINVAL;
+
+	return rate;
+}
+
 static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate)
 {
 	struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
@@ -103,6 +119,7 @@ static int sandbox_clk_free(struct clk *clk)
 }
 
 static struct clk_ops sandbox_clk_ops = {
+	.round_rate	= sandbox_clk_round_rate,
 	.get_rate	= sandbox_clk_get_rate,
 	.set_rate	= sandbox_clk_set_rate,
 	.enable		= sandbox_clk_enable,
drivers/clk/clk_sandbox_test.c +10 -0
index 873383856f..f7b77aa674 100644
@@ -86,6 +86,16 @@ ulong sandbox_clk_test_get_rate(struct udevice *dev, int id)
 	return clk_get_rate(sbct->clkps[id]);
 }
 
+ulong sandbox_clk_test_round_rate(struct udevice *dev, int id, ulong rate)
+{
+	struct sandbox_clk_test *sbct = dev_get_priv(dev);
+
+	if (id < 0 || id >= SANDBOX_CLK_TEST_ID_COUNT)
+		return -EINVAL;
+
+	return clk_round_rate(sbct->clkps[id], rate);
+}
+
 ulong sandbox_clk_test_set_rate(struct udevice *dev, int id, ulong rate)
 {
 	struct sandbox_clk_test *sbct = dev_get_priv(dev);
include/clk-uclass.h +8 -0
index dac42dab36..50e8681b55 100644
@@ -61,6 +61,14 @@ struct clk_ops {
 	 * @return 0 if OK, or a negative error code.
 	 */
 	int (*rfree)(struct clk *clock);
+	/**
+	 * round_rate() - Adjust a rate to the exact rate a clock can provide.
+	 *
+	 * @clk:	The clock to manipulate.
+	 * @rate:	Desidered clock rate in Hz.
+	 * @return rounded rate in Hz, or -ve error code.
+	 */
+	ulong (*round_rate)(struct clk *clk, ulong rate);
 	/**
 	 * get_rate() - Get current clock rate.
 	 *
include/clk.h +28 -0
index a62e2efa2c..ca6b85fa6f 100644
@@ -366,6 +366,29 @@ struct clk *clk_get_parent(struct clk *clk);
  */
 long long clk_get_parent_rate(struct clk *clk);
 
+/**
+ * clk_round_rate() - Adjust a rate to the exact rate a clock can provide
+ *
+ * This answers the question "if I were to pass @rate to clk_set_rate(),
+ * what clock rate would I end up with?" without changing the hardware
+ * in any way.  In other words:
+ *
+ *   rate = clk_round_rate(clk, r);
+ *
+ * and:
+ *
+ *   rate = clk_set_rate(clk, r);
+ *
+ * are equivalent except the former does not modify the clock hardware
+ * in any way.
+ *
+ * @clk: A clock struct that was previously successfully requested by
+ *       clk_request/get_by_*().
+ * @rate: desired clock rate in Hz.
+ * @return rounded rate in Hz, or -ve error code.
+ */
+ulong clk_round_rate(struct clk *clk, ulong rate);
+
 /**
  * clk_set_rate() - Set current clock rate.
  *
@@ -482,6 +505,11 @@ static inline long long clk_get_parent_rate(struct clk *clk)
 	return -ENOSYS;
 }
 
+static inline ulong clk_round_rate(struct clk *clk, ulong rate)
+{
+	return -ENOSYS;
+}
+
 static inline ulong clk_set_rate(struct clk *clk, ulong rate)
 {
 	return -ENOSYS;
test/dm/clk.c +22 -0
index edca3b49f6..21997ed892 100644
@@ -112,6 +112,28 @@ static int dm_test_clk(struct unit_test_state *uts)
 	rate = sandbox_clk_test_set_rate(dev_test, SANDBOX_CLK_TEST_ID_I2C, 0);
 	ut_assert(IS_ERR_VALUE(rate));
 
+	ut_asserteq(10000, sandbox_clk_test_get_rate(dev_test,
+						     SANDBOX_CLK_TEST_ID_SPI));
+	ut_asserteq(20000, sandbox_clk_test_get_rate(dev_test,
+						     SANDBOX_CLK_TEST_ID_I2C));
+
+	ut_asserteq(5000, sandbox_clk_test_round_rate(dev_test,
+						      SANDBOX_CLK_TEST_ID_SPI,
+						      5000));
+	ut_asserteq(7000, sandbox_clk_test_round_rate(dev_test,
+						      SANDBOX_CLK_TEST_ID_I2C,
+						      7000));
+
+	ut_asserteq(10000, sandbox_clk_test_get_rate(dev_test,
+						     SANDBOX_CLK_TEST_ID_SPI));
+	ut_asserteq(20000, sandbox_clk_test_get_rate(dev_test,
+						     SANDBOX_CLK_TEST_ID_I2C));
+
+	rate = sandbox_clk_test_round_rate(dev_test, SANDBOX_CLK_TEST_ID_SPI, 0);
+	ut_assert(IS_ERR_VALUE(rate));
+	rate = sandbox_clk_test_round_rate(dev_test, SANDBOX_CLK_TEST_ID_I2C, 0);
+	ut_assert(IS_ERR_VALUE(rate));
+
 	ut_asserteq(10000, sandbox_clk_test_get_rate(dev_test,
 						     SANDBOX_CLK_TEST_ID_SPI));
 	ut_asserteq(20000, sandbox_clk_test_get_rate(dev_test,
Signature · 1 line
2.17.1
#6 lore raw

PATCH v7 6/28 clk: ti: add mux clock driver

In reply to Dario Binacchi

The driver manages a register-mapped multiplexer with multiple input clock signals or parents, one of which can be selected as output. It uses routines provided by the common clock framework (ccf).

The code is based on the drivers/clk/ti/mux.c driver of the Linux kernel version 5.9-rc7.
For DT binding details see:
- Documentation/devicetree/bindings/clock/ti/mux.txt

---

(no changes since v5)

Changes in v5:
- Create drivers/clk/ti directory.
- Move the clk-ti-mux.c file to drivers/clk/ti and rename it clk-mux.c

Changes in v4:
- Include device_compat.h header for dev_xxx macros.

Changes in v3:
- Remove doc/device-tree-bindings/clock/clock-bindings.txt.
- Remove doc/device-tree-bindings/clock/ti,mux.txt.
- Add to commit message the references to linux kernel dt binding documentation.

 drivers/clk/Kconfig      |   1 +
 drivers/clk/Makefile     |   1 +
 drivers/clk/ti/Kconfig   |  10 ++
 drivers/clk/ti/Makefile  |   6 +
 drivers/clk/ti/clk-mux.c | 276 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 294 insertions(+)
 create mode 100644 drivers/clk/ti/Kconfig
 create mode 100644 drivers/clk/ti/Makefile
 create mode 100644 drivers/clk/ti/clk-mux.c
drivers/clk/Kconfig +1 -0
index 4dfbad7986..9e54929039 100644
@@ -179,6 +179,7 @@ source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/sunxi/Kconfig"
 source "drivers/clk/sifive/Kconfig"
 source "drivers/clk/tegra/Kconfig"
+source "drivers/clk/ti/Kconfig"
 source "drivers/clk/uniphier/Kconfig"
 
 config ICS8N3QV01
drivers/clk/Makefile +1 -0
index d1e295ac7c..2581fe0a19 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o
 obj-y += analogbits/
 obj-y += imx/
 obj-y += tegra/
+obj-y += ti/
 obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
 obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
drivers/clk/ti/Kconfig new file +10 -0
new file mode 100644
index 0000000000..be4f26817f
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2020 Dario Binacchi <[email protected]>
+#
+
+config CLK_TI_MUX
+	bool "TI mux clock driver"
+	depends on CLK && OF_CONTROL && CLK_CCF
+	help
+	  This enables the mux clock driver support on TI's SoCs.
drivers/clk/ti/Makefile new file +6 -0
new file mode 100644
index 0000000000..5faf68d30e
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2020 Dario Binacchi <[email protected]>
+#
+
+obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o
drivers/clk/ti/clk-mux.c new file +276 -0

276 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

PATCH v7 7/28 arm: ti: am33xx: add DPLL_EN_FAST_RELOCK_BYPASS macro

In reply to Dario Binacchi

Add missing DPLL_EN_FAST_RELOCK_BYPASS macro. Used to put the DPLL in idle bypass fast relock mode.

---

(no changes since v1)

 arch/arm/include/asm/arch-am33xx/clock.h | 1 +
 1 file changed, 1 insertion(+)
arch/arm/include/asm/arch-am33xx/clock.h +1 -0
index dc7a9b188d..5d775902bb 100644
@@ -66,6 +66,7 @@
 #define DPLL_EN_STOP			1
 #define DPLL_EN_MN_BYPASS		4
 #define DPLL_EN_LOW_POWER_BYPASS	5
+#define DPLL_EN_FAST_RELOCK_BYPASS	6
 #define DPLL_EN_LOCK			7
 
 /* CM_IDLEST_DPLL fields */
Signature · 1 line
2.17.1
#8 lore raw

PATCH v7 8/28 clk: ti: am33xx: add DPLL clock drivers

In reply to Dario Binacchi

The digital phase-locked loop (DPLL) provides all interface clocks and functional clocks to the processor of the AM33xx device. The AM33xx device integrates five different DPLLs:
* Core DPLL
* Per DPLL
* LCD DPLL
* DDR DPLL
* MPU DPLL

The patch adds support for the compatible strings:
* "ti,am3-dpll-core-clock"
* "ti,am3-dpll-no-gate-clock"
* "ti,am3-dpll-no-gate-j-type-clock"
* "ti,am3-dpll-x2-clock"

The code is loosely based on the drivers/clk/ti/dpll.c drivers of the Linux kernel version 5.9-rc7.
For DT binding details see:
- Documentation/devicetree/bindings/clock/ti/dpll.txt

---

(no changes since v5)

Changes in v5:
- Move the clk-ti-am3-dpll.c file to drivers/clk/ti with the name clk-am3-dpll.c.
- Move the clk-ti-am3-dpll-x2.c file to drivers/clk/ti with the name clk-am3-dpll-x2.c.

Changes in v4:
- Include device_compat.h header for dev_xxx macros.
- Fix compilation errors on the dev parameter of the dev_xx macros.

Changes in v3:
- Remove doc/device-tree-bindings/clock/ti,dpll.txt.
- Add to commit message the references to linux kernel dt binding documentation.

 drivers/clk/ti/Kconfig           |   7 +
 drivers/clk/ti/Makefile          |   1 +
 drivers/clk/ti/clk-am3-dpll-x2.c |  79 +++++++++
 drivers/clk/ti/clk-am3-dpll.c    | 268 +++++++++++++++++++++++++++++++
 4 files changed, 355 insertions(+)
 create mode 100644 drivers/clk/ti/clk-am3-dpll-x2.c
 create mode 100644 drivers/clk/ti/clk-am3-dpll.c
drivers/clk/ti/Kconfig +7 -0
index be4f26817f..c430dd9b8a 100644
@@ -3,6 +3,13 @@
 # Copyright (C) 2020 Dario Binacchi <[email protected]>
 #
 
+config CLK_TI_AM3_DPLL
+	bool "TI AM33XX Digital Phase-Locked Loop (DPLL) clock drivers"
+	depends on CLK && OF_CONTROL
+	help
+	  This enables the DPLL clock drivers support on AM33XX SoCs. The DPLL
+	  provides all interface clocks and functional clocks to the processor.
+
 config CLK_TI_MUX
 	bool "TI mux clock driver"
 	depends on CLK && OF_CONTROL && CLK_CCF
drivers/clk/ti/Makefile +1 -0
index 5faf68d30e..9e14b83cfe 100644
@@ -3,4 +3,5 @@
 # Copyright (C) 2020 Dario Binacchi <[email protected]>
 #
 
+obj-$(CONFIG_CLK_TI_AM3_DPLL) += clk-am3-dpll.o clk-am3-dpll-x2.o
 obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o
drivers/clk/ti/clk-am3-dpll-x2.c new file +79 -0

79 lines not on this page · raw message

drivers/clk/ti/clk-am3-dpll.c new file +268 -0

268 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw

PATCH v7 9/28 clk: ti: add divider clock driver

In reply to Dario Binacchi

The patch adds support for TI divider clock binding. The driver uses routines provided by the common clock framework (ccf).

The code is based on the drivers/clk/ti/divider.c driver of the Linux kernel version 5.9-rc7.
For DT binding details see:
- Documentation/devicetree/bindings/clock/ti/divider.txt

---

(no changes since v5)

Changes in v5:
- Move the clk-ti.c file to drivers/clk/ti with the name clk.c.
- Move the clk-ti.h file to drivers/clk/ti with the name clk.h.
- Move the clk-ti-divider.c file to drivers/clk/ti with the name clk-divider.c.

Changes in v4:
- Include device_compat.h header for dev_xxx macros.
- Fix compilation errors on the dev parameter of the dev_xx macros.

Changes in v3:
- Remove doc/device-tree-bindings/clock/ti,autoidle.txt.
- Remove doc/device-tree-bindings/clock/ti,divider.txt.
- Add to commit message the references to linux kernel dt binding documentation.

Changes in v2:
- Merged to patch [09/31] clk: ti: refactor mux and divider clock drivers.

 drivers/clk/ti/Kconfig       |   6 +
 drivers/clk/ti/Makefile      |   3 +
 drivers/clk/ti/clk-divider.c | 381 +++++++++++++++++++++++++++++++++++
 drivers/clk/ti/clk-mux.c     |  27 +--
 drivers/clk/ti/clk.c         |  34 ++++
 drivers/clk/ti/clk.h         |  13 ++
 6 files changed, 439 insertions(+), 25 deletions(-)
 create mode 100644 drivers/clk/ti/clk-divider.c
 create mode 100644 drivers/clk/ti/clk.c
 create mode 100644 drivers/clk/ti/clk.h
drivers/clk/ti/Kconfig +6 -0
index c430dd9b8a..87eea86c6f 100644
@@ -10,6 +10,12 @@ config CLK_TI_AM3_DPLL
 	  This enables the DPLL clock drivers support on AM33XX SoCs. The DPLL
 	  provides all interface clocks and functional clocks to the processor.
 
+config CLK_TI_DIVIDER
+	bool "TI divider clock driver"
+	depends on CLK && OF_CONTROL && CLK_CCF
+	help
+	  This enables the divider clock driver support on TI's SoCs.
+
 config CLK_TI_MUX
 	bool "TI mux clock driver"
 	depends on CLK && OF_CONTROL && CLK_CCF
drivers/clk/ti/Makefile +3 -0
index 9e14b83cfe..fd7094cff0 100644
@@ -3,5 +3,8 @@
 # Copyright (C) 2020 Dario Binacchi <[email protected]>
 #
 
+obj-$(CONFIG_ARCH_OMAP2PLUS) += clk.o
+
 obj-$(CONFIG_CLK_TI_AM3_DPLL) += clk-am3-dpll.o clk-am3-dpll-x2.o
+obj-$(CONFIG_CLK_TI_DIVIDER) += clk-divider.o
 obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o
drivers/clk/ti/clk-divider.c new file +381 -0

381 lines not on this page · raw message

drivers/clk/ti/clk-mux.c +2 -25
index 9720c84513..35470255af 100644
@@ -13,6 +13,7 @@
 #include <clk-uclass.h>
 #include <asm/io.h>
 #include <linux/clk-provider.h>
+#include "clk.h"
 
 struct clk_ti_mux_priv {
 	struct clk_bulk parents;
@@ -24,30 +25,6 @@ struct clk_ti_mux_priv {
 	s32 latch;
 };
 
-static void clk_ti_mux_rmw(u32 val, u32 mask, fdt_addr_t reg)
-{
-	u32 v;
-
-	v = readl(reg);
-	v &= ~mask;
-	v |= val;
-	writel(v, reg);
-}
-
-static void clk_ti_mux_latch(fdt_addr_t reg, s8 shift)
-{
-	u32 latch;
-
-	if (shift < 0)
-		return;
-
-	latch = 1 << shift;
-
-	clk_ti_mux_rmw(latch, latch, reg);
-	clk_ti_mux_rmw(0, latch, reg);
-	readl(reg);		/* OCP barrier */
-}
-
 static struct clk *clk_ti_mux_get_parent_by_index(struct clk_bulk *parents,
 						  int index)
 {
@@ -120,7 +97,7 @@ static int clk_ti_mux_set_parent(struct clk *clk, struct clk *parent)
 
 	val |= index << priv->shift;
 	writel(val, priv->reg);
-	clk_ti_mux_latch(priv->reg, priv->latch);
+	clk_ti_latch(priv->reg, priv->latch);
 	return 0;
 }
 
drivers/clk/ti/clk.c new file +34 -0
new file mode 100644
index 0000000000..e44b90ad6a
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * TI clock utilities
+ *
+ * Copyright (C) 2020 Dario Binacchi <[email protected]>
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include "clk.h"
+
+static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg)
+{
+	u32 v;
+
+	v = readl(reg);
+	v &= ~mask;
+	v |= val;
+	writel(v, reg);
+}
+
+void clk_ti_latch(fdt_addr_t reg, s8 shift)
+{
+	u32 latch;
+
+	if (shift < 0)
+		return;
+
+	latch = 1 << shift;
+
+	clk_ti_rmw(latch, latch, reg);
+	clk_ti_rmw(0, latch, reg);
+	readl(reg);		/* OCP barrier */
+}
drivers/clk/ti/clk.h new file +13 -0
new file mode 100644
index 0000000000..601c3823f7
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * TI clock utilities header
+ *
+ * Copyright (C) 2020 Dario Binacchi <[email protected]>
+ */
+
+#ifndef _CLK_TI_H
+#define _CLK_TI_H
+
+void clk_ti_latch(fdt_addr_t reg, s8 shift);
+
+#endif /* #ifndef _CLK_TI_H */
Signature · 1 line
2.17.1
#10 lore raw

PATCH v7 10/28 clk: ti: add gate clock driver

In reply to Dario Binacchi

The patch adds support for TI gate clock binding. The code is based on the drivers/clk/ti/gate.c driver of the Linux kernel version 5.9-rc7. For DT binding details see:
- Documentation/devicetree/bindings/clock/ti/gate.txt

---

(no changes since v5)

Changes in v5:
- Move the clk-ti-gate.c file to drivers/clk/ti with the name clk-gate.c.

Changes in v4:
- Include device_compat.h header for dev_xxx macros.

Changes in v3:
- Remove doc/device-tree-bindings/clock/gpio-gate-clock.txt.
- Remove doc/device-tree-bindings/clock/ti,clockdomain.txt.
- Remove doc/device-tree-bindings/clock/ti,gate.txt.
- Add to commit message the references to linux kernel dt binding documentation.

 drivers/clk/ti/Kconfig    |  6 +++
 drivers/clk/ti/Makefile   |  1 +
 drivers/clk/ti/clk-gate.c | 93 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+)
 create mode 100644 drivers/clk/ti/clk-gate.c
drivers/clk/ti/Kconfig +6 -0
index 87eea86c6f..30959a316a 100644
@@ -16,6 +16,12 @@ config CLK_TI_DIVIDER
 	help
 	  This enables the divider clock driver support on TI's SoCs.
 
+config CLK_TI_GATE
+	bool "TI gate clock driver"
+	depends on CLK && OF_CONTROL
+	help
+	  This enables the gate clock driver support on TI's SoCs.
+
 config CLK_TI_MUX
 	bool "TI mux clock driver"
 	depends on CLK && OF_CONTROL && CLK_CCF
drivers/clk/ti/Makefile +1 -0
index fd7094cff0..f8aa735c83 100644
@@ -7,4 +7,5 @@ obj-$(CONFIG_ARCH_OMAP2PLUS) += clk.o
 
 obj-$(CONFIG_CLK_TI_AM3_DPLL) += clk-am3-dpll.o clk-am3-dpll-x2.o
 obj-$(CONFIG_CLK_TI_DIVIDER) += clk-divider.o
+obj-$(CONFIG_CLK_TI_GATE) += clk-gate.o
 obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o
drivers/clk/ti/clk-gate.c new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
2.17.1
#11 lore raw

PATCH v7 11/28 arm: dts: am335x: include am33xx-u-boot.dtsi

In reply to Dario Binacchi

Include the SoC U-boot DTS in each am335x-<board>-u-boot.dtsi.

---

(no changes since v1)

 arch/arm/dts/am335x-chiliboard-u-boot.dtsi | 2 ++
 arch/arm/dts/am335x-evm-u-boot.dtsi        | 2 ++
 arch/arm/dts/am335x-evmsk-u-boot.dtsi      | 2 ++
 arch/arm/dts/am335x-guardian-u-boot.dtsi   | 2 ++
 arch/arm/dts/am335x-icev2-u-boot.dtsi      | 3 +++
 arch/arm/dts/am335x-pdu001-u-boot.dtsi     | 2 ++
 arch/arm/dts/am335x-pxm50-u-boot.dtsi      | 2 ++
 arch/arm/dts/am335x-regor-rdk-u-boot.dtsi  | 2 ++
 arch/arm/dts/am335x-rut-u-boot.dtsi        | 2 ++
 arch/arm/dts/am335x-shc-u-boot.dtsi        | 2 ++
 arch/arm/dts/am335x-wega-rdk-u-boot.dtsi   | 2 ++
 11 files changed, 23 insertions(+)
arch/arm/dts/am335x-chiliboard-u-boot.dtsi +2 -0
index 4f9d308039..06a13872ee 100644
@@ -4,6 +4,8 @@
  * Author: Marcin Niestroj <[email protected]>
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	chosen {
 		stdout-path = &uart0;
arch/arm/dts/am335x-evm-u-boot.dtsi +2 -0
index d7b049ef20..400a1d2cec 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	panel {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-evmsk-u-boot.dtsi +2 -0
index 599fb377e6..96798330b1 100644
@@ -5,6 +5,8 @@
  * Copyright (C) 2020 Dario Binacchi <[email protected]>
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	panel {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-guardian-u-boot.dtsi +2 -0
index eae027c541..c866ce83f3 100644
@@ -4,6 +4,8 @@
  * Copyright (C) 2018 Robert Bosch Power Tools GmbH
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	ocp {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-icev2-u-boot.dtsi +3 -0
index cc9569af03..67bfac916e 100644
@@ -2,6 +2,9 @@
 /*
  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
  */
+
+#include "am33xx-u-boot.dtsi"
+
 / {
 	xtal25mhz: xtal25mhz {
 		compatible = "fixed-clock";
arch/arm/dts/am335x-pdu001-u-boot.dtsi +2 -0
index a799fe9bc3..4f4fc411f9 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2018 EETS GmbH - https://www.eets.ch/
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	ocp {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-pxm50-u-boot.dtsi +2 -0
index 77dfe6e262..65ed948c58 100644
@@ -5,6 +5,8 @@
  * Copyright (C) 2020 Dario Binacchi <[email protected]>
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	panel {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-regor-rdk-u-boot.dtsi +2 -0
index 1ddd715875..4052d0ee21 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2020 Linumiz
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	chosen {
 		#address-cells = <1>;
arch/arm/dts/am335x-rut-u-boot.dtsi +2 -0
index b2b4aa596a..b16f75a764 100644
@@ -5,6 +5,8 @@
  * Copyright (C) 2020 Dario Binacchi <[email protected]>
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	panel {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-shc-u-boot.dtsi +2 -0
index 2975839ea7..359ae05209 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2019 Heiko Schocher <[email protected]>
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	ocp {
 		u-boot,dm-pre-reloc;
arch/arm/dts/am335x-wega-rdk-u-boot.dtsi +2 -0
index 634f1b0712..28fd62e231 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2019 DENX Software Engineering GmbH
  */
 
+#include "am33xx-u-boot.dtsi"
+
 / {
 	chosen {
 		#address-cells = <1>;
Signature · 1 line
2.17.1
#12 lore raw

PATCH v7 12/28 ti: am33xx: fix do_enable_clocks() to accept NULL parameters

In reply to Dario Binacchi

Up till this commit passing NULL as input parameter was allowed, but not handled properly. When a NULL parameter was passed to the function a data abort was raised.

---

(no changes since v1)

 arch/arm/mach-omap2/am33xx/clock.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/am33xx/clock.c +6 -4
index 8819062aaa..130ee6c6e3 100644
@@ -194,13 +194,14 @@ void do_enable_clocks(u32 *const *clk_domains,
 	u32 i, max = 100;
 
 	/* Put the clock domains in SW_WKUP mode */
-	for (i = 0; (i < max) && clk_domains[i]; i++) {
+	for (i = 0; (i < max) && clk_domains && clk_domains[i]; i++) {
 		enable_clock_domain(clk_domains[i],
 				    CD_CLKCTRL_CLKTRCTRL_SW_WKUP);
 	}
 
 	/* Clock modules that need to be put in SW_EXPLICIT_EN mode */
-	for (i = 0; (i < max) && clk_modules_explicit_en[i]; i++) {
+	for (i = 0; (i < max) && clk_modules_explicit_en &&
+	     clk_modules_explicit_en[i]; i++) {
 		enable_clock_module(clk_modules_explicit_en[i],
 				    MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN,
 				    wait_for_enable);
@@ -215,12 +216,13 @@ void do_disable_clocks(u32 *const *clk_domains,
 
 
 	/* Clock modules that need to be put in SW_DISABLE */
-	for (i = 0; (i < max) && clk_modules_disable[i]; i++)
+	for (i = 0; (i < max) && clk_modules_disable && clk_modules_disable[i];
+	     i++)
 		disable_clock_module(clk_modules_disable[i],
 				     wait_for_disable);
 
 	/* Put the clock domains in SW_SLEEP mode */
-	for (i = 0; (i < max) && clk_domains[i]; i++)
+	for (i = 0; (i < max) && clk_domains && clk_domains[i]; i++)
 		disable_clock_domain(clk_domains[i]);
 }
 
Signature · 1 line
2.17.1
#13 lore raw

PATCH v7 13/28 clk: ti: add support for clkctrl clocks

In reply to Dario Binacchi

Until now the clkctrl clocks have been enabled/disabled through platform routines. Thanks to this patch they can be enabled and configured directly by the probed devices that need to use them.

For DT binding details see Linux doc:
- Documentation/devicetree/bindings/clock/ti-clkctrl.txt

---

(no changes since v5)

Changes in v5:
- Move the clk-ti-ctrl.c file to drivers/clk/ti with the name clk-ctrl.c.

Changes in v4:
- Include device_compat.h header for dev_xxx macros.
- Fix compilation errors on the dev parameter of the dev_xx macros.

Changes in v3:
- Fix access to registers listed by device tree following resync of am33xx-clock.dtsi with Linux 5.9-rc7.
- Remove doc/device-tree-bindings/clock/ti,clkctrl.txt.
- Add to commit message the references to linux kernel dt binding documentation.

 drivers/clk/ti/Kconfig    |   6 ++
 drivers/clk/ti/Makefile   |   1 +
 drivers/clk/ti/clk-ctrl.c | 154 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 161 insertions(+)
 create mode 100644 drivers/clk/ti/clk-ctrl.c
drivers/clk/ti/Kconfig +6 -0
index 30959a316a..9e257a2eb7 100644
@@ -10,6 +10,12 @@ config CLK_TI_AM3_DPLL
 	  This enables the DPLL clock drivers support on AM33XX SoCs. The DPLL
 	  provides all interface clocks and functional clocks to the processor.
 
+config CLK_TI_CTRL
+	bool "TI OMAP4 clock controller"
+	depends on CLK && OF_CONTROL
+	help
+	  This enables the clock controller driver support on TI's SoCs.
+
 config CLK_TI_DIVIDER
 	bool "TI divider clock driver"
 	depends on CLK && OF_CONTROL && CLK_CCF
drivers/clk/ti/Makefile +1 -0
index f8aa735c83..ed45f18311 100644
@@ -6,6 +6,7 @@
 obj-$(CONFIG_ARCH_OMAP2PLUS) += clk.o
 
 obj-$(CONFIG_CLK_TI_AM3_DPLL) += clk-am3-dpll.o clk-am3-dpll-x2.o
+obj-$(CONFIG_CLK_TI_CTRL) += clk-ctrl.o
 obj-$(CONFIG_CLK_TI_DIVIDER) += clk-divider.o
 obj-$(CONFIG_CLK_TI_GATE) += clk-gate.o
 obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o
drivers/clk/ti/clk-ctrl.c new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
2.17.1