linux/drivers
Sugar Zhang b3cfac5e37 clk: rockchip: Add support for clk input / output switch
This patch add support switch for clk-bidirection which located
at GRF, such as SAIx_MCLK_{IN OUT} which share the same pin.
and these config maybe located in many pieces of GRF,
which hard to addressed in one single clk driver. so, we add
this simple helper driver to address this situation.

In order to simplify implement and usage, and also for safety
clk usage (avoid high freq glitch), we set all clk out as disabled
(which means Input default for clk-bidrection) in the pre-stage,
such boot-loader or init by HW default. And then set a safety freq
before enable clk-out, such as "assign-clock-rates" or clk_set_rate
in drivers.

e.g.

1. mclk{out,in}_sai0 define:

  mclkin_sai0: mclkin-sai0 {
      compatible = "fixed-clock";
      #clock-cells = <0>;
      clock-frequency = <12288000>;
      clock-output-names = "mclk_sai0_from_io";
  };

  mclkout_sai0: mclkout-sai0@ff040070 {
      compatible = "rockchip,clk-out";
      reg = <0 0xff040070 0 0x4>;
      clocks = <&cru MCLK_SAI0_OUT2IO>;
      #clock-cells = <0>;
      clock-output-names = "mclk_sai0_to_io";
      rockchip,bit-shift = <4>;
      //example with PD if reg access needed
      power-domains = <&power RK3562_PD_VO>;
  };

Note:

clock-output-names of mclkin_sai0 should equal to strings in drivers. such as:

drivers/clk/rockchip/clk-rk3562.c:
PNAME(clk_sai0_p) = { "clk_sai0_src", "clk_sai0_frac", "xin_osc0_half", "mclk_sai0_from_io" };

2. mclkout_sai0 usage:

  &ext_codec {
      clocks = <&mclkout_sai0>;
      clock-names = "mclk";
      assigned-clocks = <&mclkout_sai0>;
      assigned-clock-rates = <12288000>;
      pinctrl-names = "default";
      pinctrl-0 = <&i2s0m0_mclk>;
  };

  clk_summary on sai0 work:

  cat /sys/kernel/debug/clk/clk_summary | egrep "pll|sai0"

  clk_sai0_src                1        1        0  1188000000          0     0  50000
    clk_sai0_frac             1        1        0    12288000          0     0  50000
      clk_sai0                1        1        0    12288000          0     0  50000
        mclk_sai0             1        1        0    12288000          0     0  50000
          mclk_sai0_out2io    1        1        0    12288000          0     0  50000
            mclk_sai0_to_io   1        1        0    12288000          0     0  50000

  example with PD if reg access needed:

  * PD status when mclk_sai0_to_io on:

  cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

  domain                          status          children
    /device                                                runtime status
  ----------------------------------------------------------------------
  ...

  vo                              on
    /devices/platform/clocks/ff040070.mclkout-sai0         active
  ...

  * PD status when mclk_sai0_to_io off:

  cat /sys/kernel/debug/pm_genpd/pm_genpd_summary

  domain                          status          children
    /device                                                runtime status
  ----------------------------------------------------------------------
  ...

  vo                              off-0
    /devices/platform/clocks/ff040070.mclkout-sai0         suspended
  ...

3. mclkin_sai0 usage:

  please override freq of mclkin as the real external clkin, such as:

  &mclkin_sai0 {
      clock-frequency = <24576000>;
  }

  &ext_codec {
      clocks = <&mclkin_sai0>;
      clock-names = "mclk";
      assigned-clocks = <&cru CLK_SAI0>;
      assigned-clock-parents = <&mclkin_sai0>;
      pinctrl-names = "default";
      pinctrl-0 = <&i2s0m0_mclk>;
  };

  clk_summary on sai0 work:

  cat /sys/kernel/debug/clk/clk_summary | egrep "pll|sai0"

  mclk_sai0_from_io          1        1        0    12288000          0     0  50000
    clk_sai0                 1        1        0    12288000          0     0  50000
      mclk_sai0              1        1        0    12288000          0     0  50000
        mclk_sai0_out2io     0        0        0    12288000          0     0  50000
          mclk_sai0_to_io    0        0        0    12288000          0     0  50000

Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Change-Id: Ibe8286bb98ea1fc3bc6421c30f6e46fc0b1b0d88
2023-02-21 09:50:13 +08:00
..
accessibility
acpi PCI: rockchip: Add ACPI support 2022-07-22 16:14:12 +08:00
amba
android Merge tag 'ASB-2022-07-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 18:11:10 +08:00
ata Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
atm
auxdisplay
base MALI: rockchip: upgrade bifrost DDK to g15p0-01eac0, from g13p0-01eac0 2022-11-22 14:13:04 +08:00
bcma
block
bluetooth Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
bus
cdrom
char hwrng: rockchip: add RK_RNG support 2022-12-16 10:15:56 +08:00
clk clk: rockchip: Add support for clk input / output switch 2023-02-21 09:50:13 +08:00
clocksource Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
connector
counter
cpufreq cpufreq: rockchip: Add support to add length 2023-01-14 10:59:54 +08:00
cpuidle
crypto crypto: rockchip: Kconfig: select crypto v3 if RK3562 2023-02-06 11:28:26 +08:00
dax
dca
devfreq PM / devfreq: rockchip_dmc: Add support for rk3562 2023-02-10 14:28:01 +08:00
dio
dma Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
dma-buf dma-buf: Rename CONFIG_DMABUF_DEBUG_ADVANCED to CONFIG_RK_DMABUF_DEBUG_ADVANCED 2023-02-09 14:21:20 +08:00
edac
eisa
extcon UPSTREAM: extcon: Add EXTCON_DISP_CVBS and EXTCON_DISP_EDP 2022-11-16 09:52:56 +08:00
firewire
firmware soc: rockchip: rk_fiq_debugger fix the 'cpu' to unsigned long 2023-02-02 09:52:12 +08:00
fpga
fsi
gnss
gpio gpio: rockchip: Sync with upstream 2023-02-08 19:32:41 +08:00
gpu drm/rockchip: dsi2: fix mode valid func when work in dual channel dsi 2023-02-20 15:01:41 +08:00
greybus
headset_observe
hid Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
hsi
hv
hwmon hwmon: (pwm-fan) Add system monitor notifier 2022-09-29 14:16:27 +08:00
hwspinlock hwspinlock: rockchip: amend to use new helpers 2022-09-21 15:43:01 +08:00
hwtracing
i2c i2c: rk3x: adjust the divisor after mcu is done for thunder-boot 2022-12-13 18:47:16 +08:00
i3c
ide
idle
iio BACKPORT: iio: adc: rockchip_saradc: add voltage notifier so get referenced voltage once at probe 2023-02-08 09:52:11 +08:00
infiniband
input input: touchscreen: gsl3673_800x1280: Fix build as module 2023-02-15 19:59:40 +08:00
interconnect
iommu iommu/rockchip: Do not disable vop_mmu runtime PM when shutdown 2023-02-16 14:11:36 +08:00
ipack
irqchip irqchip/gic-v3: get free page instead of kmalloc for itt 2022-12-07 18:15:05 +08:00
isdn
leds
lightnvm
macintosh
mailbox mailbox: rockchip: initcall early when CONFIG_ROCKCHIP_THUNDER_BOOT=y 2022-08-15 19:58:54 +08:00
mcb
md
media media: rockchip: isp: dvfs for multi dev on/off 2023-02-17 18:47:21 +08:00
memory
memstick
message
mfd Revert "mfd: Add support for Maxim MAX96776" 2022-11-23 09:48:37 +08:00
misc misc: rk803: add retry while reading device id. 2022-12-16 17:06:24 +08:00
mmc mmc: sdhci-of-dwcmshc: Sync code with kernel 4.19 2023-02-17 14:22:21 +08:00
most
mtd mtd: spi-nor: gigadevice: Support New devices 2023-02-06 09:09:14 +08:00
mux
net net: phy: rk630phy: Fix typo 2023-02-15 19:52:10 +08:00
nfc
ntb
nubus
nvdimm
nvme
nvmem nvmem: rockchip-otp: Add support for rk3562 2023-02-02 19:02:07 +08:00
of Merge tag 'ASB-2022-04-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:40:39 +08:00
opp Merge tag 'ASB-2022-04-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:40:39 +08:00
oprofile
parisc
parport
pci PCI: rockchip: dw: Fix warning in initial progress 2023-02-15 15:13:06 +08:00
pcmcia
perf
phy phy: rockchip-naneng-combo: Support phy grf reset 2023-02-20 14:21:04 +08:00
pinctrl pinctrl/rockchip: Sync with upstream 2023-02-08 17:33:34 +08:00
platform
pnp
power power: supply: rk818_battery: Fix compile warning 2022-11-08 09:25:51 +08:00
powercap
pps
ps3
ptp
pwm pwm: rockchip: release clk if pinctrl check failed 2023-02-15 18:42:57 +08:00
rapidio
ras
regulator regulator: fan53555: add tcs452x 2023-02-15 18:39:49 +08:00
remoteproc
reset
rk_nand drivers: rk_nand: fix compile warning 2022-11-17 16:46:48 +08:00
rkflash drivers: rkflash: Fix the error definition of SFC dll cells 2022-12-01 22:59:08 +08:00
rknpu driver: rknpu: Update rknpu driver, version: 0.8.5 2023-02-02 19:02:08 +08:00
rpmsg rpmsg: rockchip: add rk3562 support 2023-02-08 11:51:59 +08:00
rtc rtc: rockchip: get match data with device_get_match_data 2023-02-01 14:42:56 +08:00
s390
sbus
scsi Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
sfi
sh
siox
slimbus
soc soc: rockchip: pm-config: support sleep config for mem_lite/mem_ultra 2023-02-17 18:43:41 +08:00
soundwire
spi spi: rockchip: Sync with upstream 2023-02-07 20:30:52 +08:00
spmi
ssb
staging Revert "staging: android: add timed gpio driver to present vibrator control interface to userspace" 2023-01-05 10:15:39 +08:00
target
tc
tee
thermal thermal: rockchip: Support the rk3562 SoC in thermal driver 2023-02-02 19:02:07 +08:00
thunderbolt
tty Merge tag 'ASB-2022-06-05_12-5.10' of https://android.googlesource.com/kernel/common 2022-07-15 17:58:38 +08:00
uio
usb Revert "usb: gadget: add transfer_type in struct usb_ep for rockchip" 2023-02-02 10:06:36 +08:00
vdpa
vfio
vhost
video vdieo: rockchip: mpp: fix av1d iommu compile warning 2023-02-15 17:52:24 +08:00
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile