mbox series

[v8,00/22] Move PMC clocks into Tegra PMC driver

Message ID 1578986667-16041-1-git-send-email-skomatineni@nvidia.com (mailing list archive)
Headers show
Series Move PMC clocks into Tegra PMC driver | expand

Message

Sowjanya Komatineni Jan. 14, 2020, 7:24 a.m. UTC
This patch series moves Tegra PMC clocks from clock driver to pmc driver
along with the device trees changes and audio driver which uses one of
the pmc clock for audio mclk.

Tegra PMC has clk_out_1, clk_out_2, clk_out_3 and blink controls which
are currently registered by Tegra clock driver using clk_regiser_mux and
clk_register_gate which performs direct Tegra PMC register access.

When Tegra PMC is in secure mode, any access from non-secure world will
not go through.

This patch series adds these Tegra PMC clocks and blink controls to Tegra
PMC driver with PMC as clock provider and removes them from Tegra clock
driver.

PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 thru Tegra210
and clock driver does inital parent configuration for it and enables them.
But this clock should be taken care by audio driver as there is no need
to have this clock pre enabled.

So, this series also includes patch that updates ASoC utils to take
care of parent configuration for mclk if device tree don't specify
initial parent configuration using assigned-clock-parents and enable
audio mclk during utils init.

DTs are also updated to use clk_out_1 as audio mclk rather than extern1.

This series also includes a patch for mclk fallback to extern1 when
retrieving mclk fails to have this backward compatible of new DT with
old kernels.

[v8]:	Changes between v7 and v8 are
	- v7 minor feedback

	- Audio mclk is needed only for audio, but there is some unknown
	  dependency of audio mclk and suspend-resume on Tegra30 where when
	  mclk is disable, suspend-resume doesn't work.
	  So v8 undoes v7 change of mclk enable and disable during machine
	  startup and shutdown and keeps audio mclk enabled in ASoC driver
	  tegra_asoc_utils_init.

	- change in the patches order.

	  Note:
	  - Patches 1 thru 5 are to change CLK_M_DIV clocks to OSC_DIV clocks.
	    OSC_DIV clocks uses same ID as CLK_M_DIV clocks during the
	    transition to replace CLK_M_DIV with OSC_DIV.
	  - Patches 8 and 10 registers pmc clocks as pmc_clk_out_1/2/3, and
	    pmc_blink to avoid using same clock names as pmc clocks from
	    tegra_car provider to have them functionally work with all the
	    transition patches.
	  - Patch 11 adds audio mclk fallback to extern1 to have new DT work
	    with old kernels. This patch need to be back-ported.
	  - Patch 18 adds audio mclk parent configuration when DT doesn't
	    specify parent configs. This patch retrieves pmc_clk_out_1 as audio
	    mclk so added this patch after all DT updates to use pmc clocks
	    from tegra_pmc.
	  - Patch 19 does audio mclk enable during utils init to have it
	    enabled all the time.
	  - Patch 20 and 21 removes PMC clocks from clock driver and their IDs
	    at the end of PMC clocks transition to tegra_pmc.
	

[v7]:	Changes between v6 and v7 are
	- v6 minor feedback
	- Added DT id for Tegra OSC to use in device tree for pmc clock
	  parent.

[v6]:	Changes between v5 and v6 are
	- v5 feedback
	- Added ASoC machine startup and shutdown callbacks to control audio
	  mclk enable/disable and removed default mclk enable from clock driver.
	- Updated tegra_asoc_utils_set_rate to disable mclk only during PLLA
	  rate change and removed disabling PLLA as its already taken care by
	  pll clock driver.
	- Removed tegra_asoc_utils_set_rate call from utils_init as set_rate
	  is set during machine hw_params and during utils_init mclk is
	  already in disabled state and this causes warning during mclk disable
	  in utils_set_rate.

[v5]:	Changes between v4 and v5 are
	- v4 feedback
	- updated dt-binding pmc YAML schema with more description on power
	  gate nodes and pad configuration state nodes.
	- update tegra_asoc_utils_set_rate to disable audio mclk only if
	  its in enable state.

[v4]:	Changes between v3 and v4 are
	- v3 Feedback
	- Updated clocks clk_m_div2 and clk_m_div4 as osc_div2 and osc_div4.
	  Tegra don't have clk_m_div2, clk_m_div4 and they should actually
	  be osc_div2 and osc_div4 clocks from osc pads.
	- Fixed PMC clock parents to use osc, osc_div2, osc_div4.
	  This is not a functional bug fix but correction to use proper parent
	  name.
	- Register each PMC clock as single clock rather than separate
	  mux and gate clocks.
	- Update ASoC utils to use resource managed APIs rather than
	  using clk_get and clk_put.
	- Updated device tree and ASoC driver to use clk_out_1 instead of
	  clk_out_1_mux as PMC clocks are registered as single clock.
	- Update clock driver init_table to not enable audio related clocks
	  as ASoC utils will do audio clock enables.

[v3]:	Changes between v2 and v3 are
	- Removes set parent of clk_out_1_mux to extern1 and enabling
	  extern1 from the clock driver.
	- Doesn't enable clk_out_1 and blink by default in pmc driver
	- Updates ASoC driver to take care of audio mclk parent
	  configuration incase if device tree don't specify assigned
	  clock parent properties and enables mclk using both clk_out_1
	  and extern1.
	- updates all device trees using extern1 as mclk in sound node
	  to use clk_out_1 from pmc.
	- patch for YAML format pmc dt-binding
	- Includes v2 feedback

[v2]:	Changes between v1 and v2 are
	- v2 includes patches for adding clk_out_1, clk_out_2, clk_out_3,
	  blink controls to Tegra PMC driver and removing clk-tegra-pmc.
	- feedback related to pmc clocks in Tegra PMC driver from v1
	- Removed patches for WB0 PLLM overrides and PLLE IDDQ PMC programming
	  by the clock driver using helper functions from Tegra PMC.

 	  Note:
	  To use helper functions from PMC driver, PMC early init need to
	  happen prior to using helper functions and these helper functions are
	  for PLLM Override and PLLE IDDQ programming in PMC during PLLM/PLLE
	  clock registration which happen in clock_init prior to Tegra PMC
	  probe.
	  Moving PLLM/PLLE clocks registration to happen after Tegra PMC
	  impacts other clocks EMC, MC and corresponding tegra_emc_init and
	  tegra_mc_init.
	  This implementation of configuring PMC registers thru helper
	  functions in clock driver needs proper changes across PMC, Clock,
	  EMC and MC inits to have it work across all Tegra platforms.

	  Currently PLLM Override is not enabled in the bootloader so proper
	  patches for this fix will be taken care separately.

[v1]:	v1 includes patches for below fixes.
	- adding clk_out_1, clk_out_2, clk_out_3, blink controls to Tegra PMC
	  driver and removing clk-tegra-pmc.
	- updated clock provider from tegra_car to pmc in the device tree
	  tegra210-smaug.dts that uses clk_out_2.
	- Added helper functions in PMC driver for WB0 PLLM overrides and PLLE
	  IDDQ programming to use by clock driver and updated clock driver to
	  use these helper functions and removed direct PMC access from clock
	  driver and all pmc base address references in clock driver.

Sowjanya Komatineni (22):
  dt-bindings: clock: tegra: Add IDs for OSC clocks
  clk: tegra: Add support for OSC_DIV fixed clocks
  clk: tegra: Add Tegra OSC to clock lookup
  clk: tegra: Fix Tegra PMC clock out parents
  clk: tegra: Remove CLK_M_DIV fixed clocks
  dt-bindings: tegra: Convert Tegra PMC bindings to YAML
  dt-bindings: soc: tegra-pmc: Add Tegra PMC clock bindings
  soc: tegra: Add Tegra PMC clocks registration into PMC driver
  dt-bindings: soc: tegra-pmc: Add id for Tegra PMC 32KHz blink clock
  soc: tegra: Add support for 32KHz blink clock
  ASoC: tegra: Add fallback implementation for audio mclk
  ASoC: tegra: Use device managed resource APIs to get the clock
  ARM: dts: tegra: Add clock-cells property to pmc
  arm64: tegra: Add clock-cells property to Tegra PMC node
  ARM: tegra: Update sound node clocks in device tree
  arm64: tegra: smaug: Change clk_out_2 provider to pmc
  ASoC: nau8825: change Tegra clk_out_2 provider to tegra_pmc
  ASoC: tegra: Add audio mclk parent configuration
  ASoC: tegra: Enable audio mclk during tegra_asoc_utils_init
  clk: tegra: Remove tegra_pmc_clk_init along with clk ids
  dt-bindings: clock: tegra: Remove pmc clock ids from clock dt-bindings
  clk: tegra: Remove audio clocks configuration from clock driver

 .../bindings/arm/tegra/nvidia,tegra20-pmc.txt      | 300 -----------------
 .../bindings/arm/tegra/nvidia,tegra20-pmc.yaml     | 354 +++++++++++++++++++++
 .../devicetree/bindings/sound/nau8825.txt          |   2 +-
 arch/arm/boot/dts/tegra114-dalmore.dts             |   8 +-
 arch/arm/boot/dts/tegra114.dtsi                    |   4 +-
 arch/arm/boot/dts/tegra124-apalis-v1.2.dtsi        |   8 +-
 arch/arm/boot/dts/tegra124-apalis.dtsi             |   8 +-
 arch/arm/boot/dts/tegra124-jetson-tk1.dts          |   8 +-
 arch/arm/boot/dts/tegra124-nyan.dtsi               |   8 +-
 arch/arm/boot/dts/tegra124-venice2.dts             |   8 +-
 arch/arm/boot/dts/tegra124.dtsi                    |   4 +-
 arch/arm/boot/dts/tegra20.dtsi                     |   4 +-
 arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi         |   8 +-
 arch/arm/boot/dts/tegra30-apalis.dtsi              |   8 +-
 arch/arm/boot/dts/tegra30-beaver.dts               |   8 +-
 arch/arm/boot/dts/tegra30-cardhu.dtsi              |   8 +-
 arch/arm/boot/dts/tegra30-colibri.dtsi             |   8 +-
 arch/arm/boot/dts/tegra30.dtsi                     |   4 +-
 arch/arm64/boot/dts/nvidia/tegra132.dtsi           |   4 +-
 arch/arm64/boot/dts/nvidia/tegra210-smaug.dts      |   2 +-
 arch/arm64/boot/dts/nvidia/tegra210.dtsi           |   6 +-
 drivers/clk/tegra/Makefile                         |   1 -
 drivers/clk/tegra/clk-id.h                         |  12 +-
 drivers/clk/tegra/clk-tegra-fixed.c                |  37 ++-
 drivers/clk/tegra/clk-tegra-pmc.c                  | 122 -------
 drivers/clk/tegra/clk-tegra114.c                   |  43 +--
 drivers/clk/tegra/clk-tegra124.c                   |  48 ++-
 drivers/clk/tegra/clk-tegra20.c                    |   9 +-
 drivers/clk/tegra/clk-tegra210.c                   |  32 +-
 drivers/clk/tegra/clk-tegra30.c                    |  33 +-
 drivers/clk/tegra/clk.h                            |   1 -
 drivers/soc/tegra/pmc.c                            | 354 +++++++++++++++++++++
 include/dt-bindings/clock/tegra114-car.h           |  18 +-
 include/dt-bindings/clock/tegra124-car-common.h    |  18 +-
 include/dt-bindings/clock/tegra20-car.h            |   2 +-
 include/dt-bindings/clock/tegra210-car.h           |  18 +-
 include/dt-bindings/clock/tegra30-car.h            |  18 +-
 include/dt-bindings/soc/tegra-pmc.h                |  16 +
 sound/soc/tegra/tegra_alc5632.c                    |   7 +-
 sound/soc/tegra/tegra_asoc_utils.c                 | 126 ++++----
 sound/soc/tegra/tegra_asoc_utils.h                 |   1 -
 sound/soc/tegra/tegra_max98090.c                   |  22 +-
 sound/soc/tegra/tegra_rt5640.c                     |  22 +-
 sound/soc/tegra/tegra_rt5677.c                     |   7 +-
 sound/soc/tegra/tegra_sgtl5000.c                   |   7 +-
 sound/soc/tegra/tegra_wm8753.c                     |  22 +-
 sound/soc/tegra/tegra_wm8903.c                     |  22 +-
 sound/soc/tegra/tegra_wm9712.c                     |   8 +-
 sound/soc/tegra/trimslice.c                        |  18 +-
 49 files changed, 1041 insertions(+), 775 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt
 create mode 100644 Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.yaml
 delete mode 100644 drivers/clk/tegra/clk-tegra-pmc.c
 create mode 100644 include/dt-bindings/soc/tegra-pmc.h

Comments

Thierry Reding Feb. 17, 2020, 9:59 a.m. UTC | #1
On Mon, Jan 13, 2020 at 11:24:05PM -0800, Sowjanya Komatineni wrote:
> This patch series moves Tegra PMC clocks from clock driver to pmc driver
> along with the device trees changes and audio driver which uses one of
> the pmc clock for audio mclk.
> 
> Tegra PMC has clk_out_1, clk_out_2, clk_out_3 and blink controls which
> are currently registered by Tegra clock driver using clk_regiser_mux and
> clk_register_gate which performs direct Tegra PMC register access.
> 
> When Tegra PMC is in secure mode, any access from non-secure world will
> not go through.
> 
> This patch series adds these Tegra PMC clocks and blink controls to Tegra
> PMC driver with PMC as clock provider and removes them from Tegra clock
> driver.
> 
> PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 thru Tegra210
> and clock driver does inital parent configuration for it and enables them.
> But this clock should be taken care by audio driver as there is no need
> to have this clock pre enabled.
> 
> So, this series also includes patch that updates ASoC utils to take
> care of parent configuration for mclk if device tree don't specify
> initial parent configuration using assigned-clock-parents and enable
> audio mclk during utils init.
> 
> DTs are also updated to use clk_out_1 as audio mclk rather than extern1.
> 
> This series also includes a patch for mclk fallback to extern1 when
> retrieving mclk fails to have this backward compatible of new DT with
> old kernels.
> 
> [v8]:	Changes between v7 and v8 are
> 	- v7 minor feedback
> 
> 	- Audio mclk is needed only for audio, but there is some unknown
> 	  dependency of audio mclk and suspend-resume on Tegra30 where when
> 	  mclk is disable, suspend-resume doesn't work.
> 	  So v8 undoes v7 change of mclk enable and disable during machine
> 	  startup and shutdown and keeps audio mclk enabled in ASoC driver
> 	  tegra_asoc_utils_init.
> 
> 	- change in the patches order.
> 
> 	  Note:
> 	  - Patches 1 thru 5 are to change CLK_M_DIV clocks to OSC_DIV clocks.
> 	    OSC_DIV clocks uses same ID as CLK_M_DIV clocks during the
> 	    transition to replace CLK_M_DIV with OSC_DIV.
> 	  - Patches 8 and 10 registers pmc clocks as pmc_clk_out_1/2/3, and
> 	    pmc_blink to avoid using same clock names as pmc clocks from
> 	    tegra_car provider to have them functionally work with all the
> 	    transition patches.
> 	  - Patch 11 adds audio mclk fallback to extern1 to have new DT work
> 	    with old kernels. This patch need to be back-ported.
> 	  - Patch 18 adds audio mclk parent configuration when DT doesn't
> 	    specify parent configs. This patch retrieves pmc_clk_out_1 as audio
> 	    mclk so added this patch after all DT updates to use pmc clocks
> 	    from tegra_pmc.
> 	  - Patch 19 does audio mclk enable during utils init to have it
> 	    enabled all the time.
> 	  - Patch 20 and 21 removes PMC clocks from clock driver and their IDs
> 	    at the end of PMC clocks transition to tegra_pmc.
> 	
> 
> [v7]:	Changes between v6 and v7 are
> 	- v6 minor feedback
> 	- Added DT id for Tegra OSC to use in device tree for pmc clock
> 	  parent.
> 
> [v6]:	Changes between v5 and v6 are
> 	- v5 feedback
> 	- Added ASoC machine startup and shutdown callbacks to control audio
> 	  mclk enable/disable and removed default mclk enable from clock driver.
> 	- Updated tegra_asoc_utils_set_rate to disable mclk only during PLLA
> 	  rate change and removed disabling PLLA as its already taken care by
> 	  pll clock driver.
> 	- Removed tegra_asoc_utils_set_rate call from utils_init as set_rate
> 	  is set during machine hw_params and during utils_init mclk is
> 	  already in disabled state and this causes warning during mclk disable
> 	  in utils_set_rate.
> 
> [v5]:	Changes between v4 and v5 are
> 	- v4 feedback
> 	- updated dt-binding pmc YAML schema with more description on power
> 	  gate nodes and pad configuration state nodes.
> 	- update tegra_asoc_utils_set_rate to disable audio mclk only if
> 	  its in enable state.
> 
> [v4]:	Changes between v3 and v4 are
> 	- v3 Feedback
> 	- Updated clocks clk_m_div2 and clk_m_div4 as osc_div2 and osc_div4.
> 	  Tegra don't have clk_m_div2, clk_m_div4 and they should actually
> 	  be osc_div2 and osc_div4 clocks from osc pads.
> 	- Fixed PMC clock parents to use osc, osc_div2, osc_div4.
> 	  This is not a functional bug fix but correction to use proper parent
> 	  name.
> 	- Register each PMC clock as single clock rather than separate
> 	  mux and gate clocks.
> 	- Update ASoC utils to use resource managed APIs rather than
> 	  using clk_get and clk_put.
> 	- Updated device tree and ASoC driver to use clk_out_1 instead of
> 	  clk_out_1_mux as PMC clocks are registered as single clock.
> 	- Update clock driver init_table to not enable audio related clocks
> 	  as ASoC utils will do audio clock enables.
> 
> [v3]:	Changes between v2 and v3 are
> 	- Removes set parent of clk_out_1_mux to extern1 and enabling
> 	  extern1 from the clock driver.
> 	- Doesn't enable clk_out_1 and blink by default in pmc driver
> 	- Updates ASoC driver to take care of audio mclk parent
> 	  configuration incase if device tree don't specify assigned
> 	  clock parent properties and enables mclk using both clk_out_1
> 	  and extern1.
> 	- updates all device trees using extern1 as mclk in sound node
> 	  to use clk_out_1 from pmc.
> 	- patch for YAML format pmc dt-binding
> 	- Includes v2 feedback
> 
> [v2]:	Changes between v1 and v2 are
> 	- v2 includes patches for adding clk_out_1, clk_out_2, clk_out_3,
> 	  blink controls to Tegra PMC driver and removing clk-tegra-pmc.
> 	- feedback related to pmc clocks in Tegra PMC driver from v1
> 	- Removed patches for WB0 PLLM overrides and PLLE IDDQ PMC programming
> 	  by the clock driver using helper functions from Tegra PMC.
> 
>  	  Note:
> 	  To use helper functions from PMC driver, PMC early init need to
> 	  happen prior to using helper functions and these helper functions are
> 	  for PLLM Override and PLLE IDDQ programming in PMC during PLLM/PLLE
> 	  clock registration which happen in clock_init prior to Tegra PMC
> 	  probe.
> 	  Moving PLLM/PLLE clocks registration to happen after Tegra PMC
> 	  impacts other clocks EMC, MC and corresponding tegra_emc_init and
> 	  tegra_mc_init.
> 	  This implementation of configuring PMC registers thru helper
> 	  functions in clock driver needs proper changes across PMC, Clock,
> 	  EMC and MC inits to have it work across all Tegra platforms.
> 
> 	  Currently PLLM Override is not enabled in the bootloader so proper
> 	  patches for this fix will be taken care separately.
> 
> [v1]:	v1 includes patches for below fixes.
> 	- adding clk_out_1, clk_out_2, clk_out_3, blink controls to Tegra PMC
> 	  driver and removing clk-tegra-pmc.
> 	- updated clock provider from tegra_car to pmc in the device tree
> 	  tegra210-smaug.dts that uses clk_out_2.
> 	- Added helper functions in PMC driver for WB0 PLLM overrides and PLLE
> 	  IDDQ programming to use by clock driver and updated clock driver to
> 	  use these helper functions and removed direct PMC access from clock
> 	  driver and all pmc base address references in clock driver.
> 
> Sowjanya Komatineni (22):
>   dt-bindings: clock: tegra: Add IDs for OSC clocks
>   clk: tegra: Add support for OSC_DIV fixed clocks
>   clk: tegra: Add Tegra OSC to clock lookup
>   clk: tegra: Fix Tegra PMC clock out parents
>   clk: tegra: Remove CLK_M_DIV fixed clocks
>   dt-bindings: tegra: Convert Tegra PMC bindings to YAML
>   dt-bindings: soc: tegra-pmc: Add Tegra PMC clock bindings
>   soc: tegra: Add Tegra PMC clocks registration into PMC driver
>   dt-bindings: soc: tegra-pmc: Add id for Tegra PMC 32KHz blink clock
>   soc: tegra: Add support for 32KHz blink clock
>   ASoC: tegra: Add fallback implementation for audio mclk
>   ASoC: tegra: Use device managed resource APIs to get the clock
>   ARM: dts: tegra: Add clock-cells property to pmc
>   arm64: tegra: Add clock-cells property to Tegra PMC node
>   ARM: tegra: Update sound node clocks in device tree
>   arm64: tegra: smaug: Change clk_out_2 provider to pmc
>   ASoC: nau8825: change Tegra clk_out_2 provider to tegra_pmc
>   ASoC: tegra: Add audio mclk parent configuration
>   ASoC: tegra: Enable audio mclk during tegra_asoc_utils_init
>   clk: tegra: Remove tegra_pmc_clk_init along with clk ids
>   dt-bindings: clock: tegra: Remove pmc clock ids from clock dt-bindings
>   clk: tegra: Remove audio clocks configuration from clock driver
> 
>  .../bindings/arm/tegra/nvidia,tegra20-pmc.txt      | 300 -----------------
>  .../bindings/arm/tegra/nvidia,tegra20-pmc.yaml     | 354 +++++++++++++++++++++
>  .../devicetree/bindings/sound/nau8825.txt          |   2 +-
>  arch/arm/boot/dts/tegra114-dalmore.dts             |   8 +-
>  arch/arm/boot/dts/tegra114.dtsi                    |   4 +-
>  arch/arm/boot/dts/tegra124-apalis-v1.2.dtsi        |   8 +-
>  arch/arm/boot/dts/tegra124-apalis.dtsi             |   8 +-
>  arch/arm/boot/dts/tegra124-jetson-tk1.dts          |   8 +-
>  arch/arm/boot/dts/tegra124-nyan.dtsi               |   8 +-
>  arch/arm/boot/dts/tegra124-venice2.dts             |   8 +-
>  arch/arm/boot/dts/tegra124.dtsi                    |   4 +-
>  arch/arm/boot/dts/tegra20.dtsi                     |   4 +-
>  arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi         |   8 +-
>  arch/arm/boot/dts/tegra30-apalis.dtsi              |   8 +-
>  arch/arm/boot/dts/tegra30-beaver.dts               |   8 +-
>  arch/arm/boot/dts/tegra30-cardhu.dtsi              |   8 +-
>  arch/arm/boot/dts/tegra30-colibri.dtsi             |   8 +-
>  arch/arm/boot/dts/tegra30.dtsi                     |   4 +-
>  arch/arm64/boot/dts/nvidia/tegra132.dtsi           |   4 +-
>  arch/arm64/boot/dts/nvidia/tegra210-smaug.dts      |   2 +-
>  arch/arm64/boot/dts/nvidia/tegra210.dtsi           |   6 +-
>  drivers/clk/tegra/Makefile                         |   1 -
>  drivers/clk/tegra/clk-id.h                         |  12 +-
>  drivers/clk/tegra/clk-tegra-fixed.c                |  37 ++-
>  drivers/clk/tegra/clk-tegra-pmc.c                  | 122 -------
>  drivers/clk/tegra/clk-tegra114.c                   |  43 +--
>  drivers/clk/tegra/clk-tegra124.c                   |  48 ++-
>  drivers/clk/tegra/clk-tegra20.c                    |   9 +-
>  drivers/clk/tegra/clk-tegra210.c                   |  32 +-
>  drivers/clk/tegra/clk-tegra30.c                    |  33 +-
>  drivers/clk/tegra/clk.h                            |   1 -
>  drivers/soc/tegra/pmc.c                            | 354 +++++++++++++++++++++
>  include/dt-bindings/clock/tegra114-car.h           |  18 +-
>  include/dt-bindings/clock/tegra124-car-common.h    |  18 +-
>  include/dt-bindings/clock/tegra20-car.h            |   2 +-
>  include/dt-bindings/clock/tegra210-car.h           |  18 +-
>  include/dt-bindings/clock/tegra30-car.h            |  18 +-
>  include/dt-bindings/soc/tegra-pmc.h                |  16 +
>  sound/soc/tegra/tegra_alc5632.c                    |   7 +-
>  sound/soc/tegra/tegra_asoc_utils.c                 | 126 ++++----
>  sound/soc/tegra/tegra_asoc_utils.h                 |   1 -
>  sound/soc/tegra/tegra_max98090.c                   |  22 +-
>  sound/soc/tegra/tegra_rt5640.c                     |  22 +-
>  sound/soc/tegra/tegra_rt5677.c                     |   7 +-
>  sound/soc/tegra/tegra_sgtl5000.c                   |   7 +-
>  sound/soc/tegra/tegra_wm8753.c                     |  22 +-
>  sound/soc/tegra/tegra_wm8903.c                     |  22 +-
>  sound/soc/tegra/tegra_wm9712.c                     |   8 +-
>  sound/soc/tegra/trimslice.c                        |  18 +-
>  49 files changed, 1041 insertions(+), 775 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt
>  create mode 100644 Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.yaml
>  delete mode 100644 drivers/clk/tegra/clk-tegra-pmc.c
>  create mode 100644 include/dt-bindings/soc/tegra-pmc.h

I've applied patches 1-10 and 13-16 to the Tegra tree, but I think it
should be fine for Mark to pick up the ASoC patches into his tree,
right?

As I mentioned in my reply to patch 20, I think we need to hold off on
applying patches 20-22 until all the rest have been merged, otherwise
we'll regress.

Thierry
Dmitry Osipenko March 4, 2020, 7:26 p.m. UTC | #2
17.02.2020 12:59, Thierry Reding пишет:
...
> I've applied patches 1-10 and 13-16 to the Tegra tree, but I think it
> should be fine for Mark to pick up the ASoC patches into his tree,
> right?
> 
> As I mentioned in my reply to patch 20, I think we need to hold off on
> applying patches 20-22 until all the rest have been merged, otherwise
> we'll regress.

Hello Thierry and Sowjanya,

I was trying today's next-20200304 and found that WiFi / Bluetooth got
broken:

[   23.130017] ieee80211 phy0: brcmf_proto_bcdc_query_dcmd:
brcmf_proto_bcdc_msg failed w/status -110
[   23.130167] ieee80211 phy0: brcmf_cfg80211_get_channel: chanspec
failed (-110)
[   25.690008] ieee80211 phy0: brcmf_proto_bcdc_query_dcmd:
brcmf_proto_bcdc_msg failed w/status -110
[   30.811972] ieee80211 phy0: brcmf_dongle_scantime: Scan assoc time
error (-110)
[   33.370184] ieee80211 phy0: brcmf_netdev_open: failed to bring up
cfg80211
[   35.929994] ieee80211 phy0: brcmf_proto_bcdc_query_dcmd:
brcmf_proto_bcdc_msg failed w/status -110
[   35.930181] ieee80211 phy0: brcmf_cfg80211_get_channel: chanspec
failed (-110)

The fix is to replace TEGRA30_CLK_BLINK with TEGRA_PMC_CLK_BLINK in a
device-tree.

I'm not sure that the TEGRA30_CLK_BLINK breakage is expected to happen
because all clk/tegra/ PMC code is still in place. Please take a look,
thanks in advance.
Dmitry Osipenko March 4, 2020, 9:22 p.m. UTC | #3
04.03.2020 22:26, Dmitry Osipenko пишет:
> 17.02.2020 12:59, Thierry Reding пишет:
> ...
>> I've applied patches 1-10 and 13-16 to the Tegra tree, but I think it
>> should be fine for Mark to pick up the ASoC patches into his tree,
>> right?
>>
>> As I mentioned in my reply to patch 20, I think we need to hold off on
>> applying patches 20-22 until all the rest have been merged, otherwise
>> we'll regress.
> 
> Hello Thierry and Sowjanya,
> 
> I was trying today's next-20200304 and found that WiFi / Bluetooth got
> broken:
> 
> [   23.130017] ieee80211 phy0: brcmf_proto_bcdc_query_dcmd:
> brcmf_proto_bcdc_msg failed w/status -110
> [   23.130167] ieee80211 phy0: brcmf_cfg80211_get_channel: chanspec
> failed (-110)
> [   25.690008] ieee80211 phy0: brcmf_proto_bcdc_query_dcmd:
> brcmf_proto_bcdc_msg failed w/status -110
> [   30.811972] ieee80211 phy0: brcmf_dongle_scantime: Scan assoc time
> error (-110)
> [   33.370184] ieee80211 phy0: brcmf_netdev_open: failed to bring up
> cfg80211
> [   35.929994] ieee80211 phy0: brcmf_proto_bcdc_query_dcmd:
> brcmf_proto_bcdc_msg failed w/status -110
> [   35.930181] ieee80211 phy0: brcmf_cfg80211_get_channel: chanspec
> failed (-110)
> 
> The fix is to replace TEGRA30_CLK_BLINK with TEGRA_PMC_CLK_BLINK in a
> device-tree.
> 
> I'm not sure that the TEGRA30_CLK_BLINK breakage is expected to happen
> because all clk/tegra/ PMC code is still in place. Please take a look,
> thanks in advance.

This happens because the unused "pmc_blink" is getting auto-disabled by
the CCF. Which means that it's wrong to apply this series partially.

@Thierry, please re-apply it all properly. All patches, excluding patch
#11, should be applied. Thanks in advance.
Thierry Reding March 25, 2020, 9:27 p.m. UTC | #4
On Mon, Jan 13, 2020 at 11:24:05PM -0800, Sowjanya Komatineni wrote:
> This patch series moves Tegra PMC clocks from clock driver to pmc driver
> along with the device trees changes and audio driver which uses one of
> the pmc clock for audio mclk.
> 
> Tegra PMC has clk_out_1, clk_out_2, clk_out_3 and blink controls which
> are currently registered by Tegra clock driver using clk_regiser_mux and
> clk_register_gate which performs direct Tegra PMC register access.
> 
> When Tegra PMC is in secure mode, any access from non-secure world will
> not go through.
> 
> This patch series adds these Tegra PMC clocks and blink controls to Tegra
> PMC driver with PMC as clock provider and removes them from Tegra clock
> driver.
> 
> PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 thru Tegra210
> and clock driver does inital parent configuration for it and enables them.
> But this clock should be taken care by audio driver as there is no need
> to have this clock pre enabled.
> 
> So, this series also includes patch that updates ASoC utils to take
> care of parent configuration for mclk if device tree don't specify
> initial parent configuration using assigned-clock-parents and enable
> audio mclk during utils init.
> 
> DTs are also updated to use clk_out_1 as audio mclk rather than extern1.
> 
> This series also includes a patch for mclk fallback to extern1 when
> retrieving mclk fails to have this backward compatible of new DT with
> old kernels.
> 
> [v8]:	Changes between v7 and v8 are
> 	- v7 minor feedback
> 
> 	- Audio mclk is needed only for audio, but there is some unknown
> 	  dependency of audio mclk and suspend-resume on Tegra30 where when
> 	  mclk is disable, suspend-resume doesn't work.
> 	  So v8 undoes v7 change of mclk enable and disable during machine
> 	  startup and shutdown and keeps audio mclk enabled in ASoC driver
> 	  tegra_asoc_utils_init.
> 
> 	- change in the patches order.
> 
> 	  Note:
> 	  - Patches 1 thru 5 are to change CLK_M_DIV clocks to OSC_DIV clocks.
> 	    OSC_DIV clocks uses same ID as CLK_M_DIV clocks during the
> 	    transition to replace CLK_M_DIV with OSC_DIV.
> 	  - Patches 8 and 10 registers pmc clocks as pmc_clk_out_1/2/3, and
> 	    pmc_blink to avoid using same clock names as pmc clocks from
> 	    tegra_car provider to have them functionally work with all the
> 	    transition patches.
> 	  - Patch 11 adds audio mclk fallback to extern1 to have new DT work
> 	    with old kernels. This patch need to be back-ported.
> 	  - Patch 18 adds audio mclk parent configuration when DT doesn't
> 	    specify parent configs. This patch retrieves pmc_clk_out_1 as audio
> 	    mclk so added this patch after all DT updates to use pmc clocks
> 	    from tegra_pmc.
> 	  - Patch 19 does audio mclk enable during utils init to have it
> 	    enabled all the time.
> 	  - Patch 20 and 21 removes PMC clocks from clock driver and their IDs
> 	    at the end of PMC clocks transition to tegra_pmc.
> 	
> 
> [v7]:	Changes between v6 and v7 are
> 	- v6 minor feedback
> 	- Added DT id for Tegra OSC to use in device tree for pmc clock
> 	  parent.
> 
> [v6]:	Changes between v5 and v6 are
> 	- v5 feedback
> 	- Added ASoC machine startup and shutdown callbacks to control audio
> 	  mclk enable/disable and removed default mclk enable from clock driver.
> 	- Updated tegra_asoc_utils_set_rate to disable mclk only during PLLA
> 	  rate change and removed disabling PLLA as its already taken care by
> 	  pll clock driver.
> 	- Removed tegra_asoc_utils_set_rate call from utils_init as set_rate
> 	  is set during machine hw_params and during utils_init mclk is
> 	  already in disabled state and this causes warning during mclk disable
> 	  in utils_set_rate.
> 
> [v5]:	Changes between v4 and v5 are
> 	- v4 feedback
> 	- updated dt-binding pmc YAML schema with more description on power
> 	  gate nodes and pad configuration state nodes.
> 	- update tegra_asoc_utils_set_rate to disable audio mclk only if
> 	  its in enable state.
> 
> [v4]:	Changes between v3 and v4 are
> 	- v3 Feedback
> 	- Updated clocks clk_m_div2 and clk_m_div4 as osc_div2 and osc_div4.
> 	  Tegra don't have clk_m_div2, clk_m_div4 and they should actually
> 	  be osc_div2 and osc_div4 clocks from osc pads.
> 	- Fixed PMC clock parents to use osc, osc_div2, osc_div4.
> 	  This is not a functional bug fix but correction to use proper parent
> 	  name.
> 	- Register each PMC clock as single clock rather than separate
> 	  mux and gate clocks.
> 	- Update ASoC utils to use resource managed APIs rather than
> 	  using clk_get and clk_put.
> 	- Updated device tree and ASoC driver to use clk_out_1 instead of
> 	  clk_out_1_mux as PMC clocks are registered as single clock.
> 	- Update clock driver init_table to not enable audio related clocks
> 	  as ASoC utils will do audio clock enables.
> 
> [v3]:	Changes between v2 and v3 are
> 	- Removes set parent of clk_out_1_mux to extern1 and enabling
> 	  extern1 from the clock driver.
> 	- Doesn't enable clk_out_1 and blink by default in pmc driver
> 	- Updates ASoC driver to take care of audio mclk parent
> 	  configuration incase if device tree don't specify assigned
> 	  clock parent properties and enables mclk using both clk_out_1
> 	  and extern1.
> 	- updates all device trees using extern1 as mclk in sound node
> 	  to use clk_out_1 from pmc.
> 	- patch for YAML format pmc dt-binding
> 	- Includes v2 feedback
> 
> [v2]:	Changes between v1 and v2 are
> 	- v2 includes patches for adding clk_out_1, clk_out_2, clk_out_3,
> 	  blink controls to Tegra PMC driver and removing clk-tegra-pmc.
> 	- feedback related to pmc clocks in Tegra PMC driver from v1
> 	- Removed patches for WB0 PLLM overrides and PLLE IDDQ PMC programming
> 	  by the clock driver using helper functions from Tegra PMC.
> 
>  	  Note:
> 	  To use helper functions from PMC driver, PMC early init need to
> 	  happen prior to using helper functions and these helper functions are
> 	  for PLLM Override and PLLE IDDQ programming in PMC during PLLM/PLLE
> 	  clock registration which happen in clock_init prior to Tegra PMC
> 	  probe.
> 	  Moving PLLM/PLLE clocks registration to happen after Tegra PMC
> 	  impacts other clocks EMC, MC and corresponding tegra_emc_init and
> 	  tegra_mc_init.
> 	  This implementation of configuring PMC registers thru helper
> 	  functions in clock driver needs proper changes across PMC, Clock,
> 	  EMC and MC inits to have it work across all Tegra platforms.
> 
> 	  Currently PLLM Override is not enabled in the bootloader so proper
> 	  patches for this fix will be taken care separately.
> 
> [v1]:	v1 includes patches for below fixes.
> 	- adding clk_out_1, clk_out_2, clk_out_3, blink controls to Tegra PMC
> 	  driver and removing clk-tegra-pmc.
> 	- updated clock provider from tegra_car to pmc in the device tree
> 	  tegra210-smaug.dts that uses clk_out_2.
> 	- Added helper functions in PMC driver for WB0 PLLM overrides and PLLE
> 	  IDDQ programming to use by clock driver and updated clock driver to
> 	  use these helper functions and removed direct PMC access from clock
> 	  driver and all pmc base address references in clock driver.
> 
> Sowjanya Komatineni (22):
>   dt-bindings: clock: tegra: Add IDs for OSC clocks
>   clk: tegra: Add support for OSC_DIV fixed clocks
>   clk: tegra: Add Tegra OSC to clock lookup
>   clk: tegra: Fix Tegra PMC clock out parents
>   clk: tegra: Remove CLK_M_DIV fixed clocks
>   dt-bindings: tegra: Convert Tegra PMC bindings to YAML
>   dt-bindings: soc: tegra-pmc: Add Tegra PMC clock bindings
>   soc: tegra: Add Tegra PMC clocks registration into PMC driver
>   dt-bindings: soc: tegra-pmc: Add id for Tegra PMC 32KHz blink clock
>   soc: tegra: Add support for 32KHz blink clock
>   ASoC: tegra: Add fallback implementation for audio mclk
>   ASoC: tegra: Use device managed resource APIs to get the clock
>   ARM: dts: tegra: Add clock-cells property to pmc
>   arm64: tegra: Add clock-cells property to Tegra PMC node
>   ARM: tegra: Update sound node clocks in device tree
>   arm64: tegra: smaug: Change clk_out_2 provider to pmc
>   ASoC: nau8825: change Tegra clk_out_2 provider to tegra_pmc
>   ASoC: tegra: Add audio mclk parent configuration
>   ASoC: tegra: Enable audio mclk during tegra_asoc_utils_init
>   clk: tegra: Remove tegra_pmc_clk_init along with clk ids
>   dt-bindings: clock: tegra: Remove pmc clock ids from clock dt-bindings
>   clk: tegra: Remove audio clocks configuration from clock driver

Liam, Mark,

there's a few runtime dependencies between the various patches in this
series, so I think it'd probably be best if I picked up the ASoC patches
into the Tegra tree and let them soak for a day or two in linux-next to
make sure everything is there and in the right order.

Do you mind if I pick them up and send to you as a pull request in the
next few days?

If you'd prefer to pick these up yourself that should be fine as well.
They've all got acks from me and the runtime dependencies are causing
annoying, though harmless, warnings during boot, so I think it'd be fine
as long as all the patches end up getting merged for v5.7-rc1.

If you do decide to pick these up yourselves, please omit patch 11 in
the series since that doesn't do what it's expected to.

Thierry
Mark Brown March 27, 2020, 3:45 p.m. UTC | #5
On Wed, Mar 25, 2020 at 10:27:08PM +0100, Thierry Reding wrote:

> there's a few runtime dependencies between the various patches in this
> series, so I think it'd probably be best if I picked up the ASoC patches
> into the Tegra tree and let them soak for a day or two in linux-next to
> make sure everything is there and in the right order.

> Do you mind if I pick them up and send to you as a pull request in the
> next few days?

I guess, I think I lost track of what was going on with this as it
seemed to continually be getting lots of discussions:

Acked-by: Mark Brown <broonie@kernel.org>
Jon Hunter April 21, 2020, 1:52 p.m. UTC | #6
On 14/01/2020 07:24, Sowjanya Komatineni wrote:
> This patch series moves Tegra PMC clocks from clock driver to pmc driver
> along with the device trees changes and audio driver which uses one of
> the pmc clock for audio mclk.
> 
> Tegra PMC has clk_out_1, clk_out_2, clk_out_3 and blink controls which
> are currently registered by Tegra clock driver using clk_regiser_mux and
> clk_register_gate which performs direct Tegra PMC register access.
> 
> When Tegra PMC is in secure mode, any access from non-secure world will
> not go through.
> 
> This patch series adds these Tegra PMC clocks and blink controls to Tegra
> PMC driver with PMC as clock provider and removes them from Tegra clock
> driver.
> 
> PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 thru Tegra210
> and clock driver does inital parent configuration for it and enables them.
> But this clock should be taken care by audio driver as there is no need
> to have this clock pre enabled.
> 
> So, this series also includes patch that updates ASoC utils to take
> care of parent configuration for mclk if device tree don't specify
> initial parent configuration using assigned-clock-parents and enable
> audio mclk during utils init.
> 
> DTs are also updated to use clk_out_1 as audio mclk rather than extern1.
> 
> This series also includes a patch for mclk fallback to extern1 when
> retrieving mclk fails to have this backward compatible of new DT with
> old kernels.


On the current mainline kernel I am seeing the following WARNING on boot
for tegra20-ventana, tegra30-cardhu-a04 and tegra124-jetson-tk1 ...

[   10.723511] ------------[ cut here ]------------

[   10.730901] WARNING: CPU: 0 PID: 126 at /dvs/git/dirty/git-master_l4t-upstream/kernel/drivers/clk/clk.c:954 clk_core_disable+0xf4/0x280

[   10.745986] cdev1 already disabled

[   10.752309] Modules linked in: snd_soc_tegra_wm8903(+) snd_soc_tegra20_i2s snd_soc_tegra_utils snd_soc_tegra_pcm snd_soc_wm8903 snd_soc_core ac97_bus snd_pcm_dmaengine snd_pcm snd_timer snd soundcore snd_soc_tegra20_das

[   10.778071] CPU: 0 PID: 126 Comm: systemd-udevd Not tainted 5.7.0-rc2-next-20200420-g6735c84f78e4 #1

[   10.790485] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)

[   10.800088] [<c0311a70>] (unwind_backtrace) from [<c030bd14>] (show_stack+0x10/0x14)

[   10.811227] [<c030bd14>] (show_stack) from [<c0714710>] (dump_stack+0xc0/0xd4)

[   10.821863] [<c0714710>] (dump_stack) from [<c0345b64>] (__warn+0xe0/0xf8)

[   10.832118] [<c0345b64>] (__warn) from [<c0345bf0>] (warn_slowpath_fmt+0x74/0xb8)

[   10.843006] [<c0345bf0>] (warn_slowpath_fmt) from [<c0812dcc>] (clk_core_disable+0xf4/0x280)

[   10.854863] [<c0812dcc>] (clk_core_disable) from [<c0812f70>] (clk_core_disable_lock+0x18/0x24)

[   10.867021] [<c0812f70>] (clk_core_disable_lock) from [<bf072230>] (tegra_asoc_utils_set_rate+0x74/0x2b4 [snd_soc_tegra_utils])

[   10.882055] [<bf072230>] (tegra_asoc_utils_set_rate [snd_soc_tegra_utils]) from [<bf072504>] (tegra_asoc_utils_init+0x94/0xb90 [snd_soc_tegra_utils])

[   10.899177] [<bf072504>] (tegra_asoc_utils_init [snd_soc_tegra_utils]) from [<bf07c558>] (tegra_wm8903_driver_probe+0x294/0x310 [snd_soc_tegra_wm8903])

[   10.916562] [<bf07c558>] (tegra_wm8903_driver_probe [snd_soc_tegra_wm8903]) from [<c09d2944>] (platform_drv_probe+0x48/0x98)

[   10.931678] [<c09d2944>] (platform_drv_probe) from [<c09d09f0>] (really_probe+0x218/0x348)

[   10.943886] [<c09d09f0>] (really_probe) from [<c09d0c60>] (driver_probe_device+0x60/0x168)

[   10.956140] [<c09d0c60>] (driver_probe_device) from [<c09d0f10>] (device_driver_attach+0x58/0x60)

[   10.969029] [<c09d0f10>] (device_driver_attach) from [<c09d0f98>] (__driver_attach+0x80/0xbc)

[   10.981613] [<c09d0f98>] (__driver_attach) from [<c09ced9c>] (bus_for_each_dev+0x74/0xb4)

[   10.993891] [<c09ced9c>] (bus_for_each_dev) from [<c09cfd90>] (bus_add_driver+0x164/0x1e8)

[   11.006298] [<c09cfd90>] (bus_add_driver) from [<c09d1a1c>] (driver_register+0x7c/0x114)

[   11.018586] [<c09d1a1c>] (driver_register) from [<c0302040>] (do_one_initcall+0x54/0x22c)

[   11.031016] [<c0302040>] (do_one_initcall) from [<c03ddc98>] (do_init_module+0x60/0x210)

[   11.043370] [<c03ddc98>] (do_init_module) from [<c03dcdac>] (load_module+0x1f9c/0x2480)

[   11.055684] [<c03dcdac>] (load_module) from [<c03dd4b4>] (sys_finit_module+0xac/0xd8)

[   11.067843] [<c03dd4b4>] (sys_finit_module) from [<c03002a0>] (__sys_trace_return+0x0/0x20)

[   11.080560] Exception stack(0xede3bfa8 to 0xede3bff0)

[   11.089988] bfa0:                   b6eb9a8c 00000000 00000010 b6eb91bc 00000000 b6eb9cd0

[   11.102625] bfc0: b6eb9a8c 00000000 fca6e200 0000017b 00555918 bea799ac 00000000 00564640

[   11.115289] bfe0: bea798a8 bea79898 b6eb3951 b6f61f42

[   11.124833] ---[ end trace 3752c80347dfd3ca ]---


It appears that some of the patches in this series made v5.7-rc1 but not
all and I am guessing the ASoC changes are the ones we are missing to
avoid this.

Sowjanya, any ideas on the best way to resolve this for v5.7?

Cheers
Jon