Commit fd8c0b5a authored by Stephen Boyd's avatar Stephen Boyd

Merge tag 'clk-starfive-for-6.6' of...

Merge tag 'clk-starfive-for-6.6' of https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux into clk-starfive

Pull StarFive clk driver updates from Conor Dooley:

Add support for the System-Top-Group, Image-Signal-Process, Video-Output
and PLL clocks on the JH7110 SoC. These drivers come with their
associate dt-bindings & the obligatory headers containing defines of
clock indices.

To maintain backwards compatibility, the PLL driver will fall back to
using the fixed factor clocks that were merged for v6.4. The binding has
been updated to only permit sourcing the PLL clocks from the PLL's clock
controller.
Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>

* tag 'clk-starfive-for-6.6' of https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux:
  clk: starfive: Add StarFive JH7110 Video-Output clock driver
  clk: starfive: Add StarFive JH7110 Image-Signal-Process clock driver
  clk: starfive: Add StarFive JH7110 System-Top-Group clock driver
  clk: starfive: jh7110-sys: Add PLL clocks source from DTS
  clk: starfive: Add StarFive JH7110 PLL clock driver
  dt-bindings: clock: Add StarFive JH7110 Video-Output clock and reset generator
  dt-bindings: clock: Add StarFive JH7110 Image-Signal-Process clock and reset generator
  dt-bindings: clock: Add StarFive JH7110 System-Top-Group clock and reset generator
  dt-bindings: clock: jh7110-syscrg: Add PLL clock inputs
  dt-bindings: soc: starfive: Add StarFive syscon module
  dt-bindings: clock: Add StarFive JH7110 PLL clock generator
parents 06c2afb8 dae5448a
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/clock/starfive,jh7110-ispcrg.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: StarFive JH7110 Image-Signal-Process Clock and Reset Generator
maintainers:
- Xingyu Wu <xingyu.wu@starfivetech.com>
properties:
compatible:
const: starfive,jh7110-ispcrg
reg:
maxItems: 1
clocks:
items:
- description: ISP Top core
- description: ISP Top Axi
- description: NOC ISP Bus
- description: external DVP
clock-names:
items:
- const: isp_top_core
- const: isp_top_axi
- const: noc_bus_isp_axi
- const: dvp_clk
resets:
items:
- description: ISP Top core
- description: ISP Top Axi
- description: NOC ISP Bus
'#clock-cells':
const: 1
description:
See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices.
'#reset-cells':
const: 1
description:
See <dt-bindings/reset/starfive,jh7110-crg.h> for valid indices.
power-domains:
maxItems: 1
description:
ISP domain power
required:
- compatible
- reg
- clocks
- clock-names
- resets
- '#clock-cells'
- '#reset-cells'
- power-domains
additionalProperties: false
examples:
- |
#include <dt-bindings/clock/starfive,jh7110-crg.h>
#include <dt-bindings/power/starfive,jh7110-pmu.h>
#include <dt-bindings/reset/starfive,jh7110-crg.h>
ispcrg: clock-controller@19810000 {
compatible = "starfive,jh7110-ispcrg";
reg = <0x19810000 0x10000>;
clocks = <&syscrg JH7110_SYSCLK_ISP_TOP_CORE>,
<&syscrg JH7110_SYSCLK_ISP_TOP_AXI>,
<&syscrg JH7110_SYSCLK_NOC_BUS_ISP_AXI>,
<&dvp_clk>;
clock-names = "isp_top_core", "isp_top_axi",
"noc_bus_isp_axi", "dvp_clk";
resets = <&syscrg JH7110_SYSRST_ISP_TOP>,
<&syscrg JH7110_SYSRST_ISP_TOP_AXI>,
<&syscrg JH7110_SYSRST_NOC_BUS_ISP_AXI>;
#clock-cells = <1>;
#reset-cells = <1>;
power-domains = <&pwrc JH7110_PD_ISP>;
};
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/clock/starfive,jh7110-pll.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: StarFive JH7110 PLL Clock Generator
description:
These PLLs are high speed, low jitter frequency synthesizers in the JH7110.
Each PLL works in integer mode or fraction mode, with configuration
registers in the sys syscon. So the PLLs node should be a child of
SYS-SYSCON node.
The formula for calculating frequency is
Fvco = Fref * (NI + NF) / M / Q1
maintainers:
- Xingyu Wu <xingyu.wu@starfivetech.com>
properties:
compatible:
const: starfive,jh7110-pll
clocks:
maxItems: 1
description: Main Oscillator (24 MHz)
'#clock-cells':
const: 1
description:
See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices.
required:
- compatible
- clocks
- '#clock-cells'
additionalProperties: false
examples:
- |
clock-controller {
compatible = "starfive,jh7110-pll";
clocks = <&osc>;
#clock-cells = <1>;
};
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/clock/starfive,jh7110-stgcrg.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: StarFive JH7110 System-Top-Group Clock and Reset Generator
maintainers:
- Xingyu Wu <xingyu.wu@starfivetech.com>
properties:
compatible:
const: starfive,jh7110-stgcrg
reg:
maxItems: 1
clocks:
items:
- description: Main Oscillator (24 MHz)
- description: HIFI4 core
- description: STG AXI/AHB
- description: USB (125 MHz)
- description: CPU Bus
- description: HIFI4 Axi
- description: NOC STG Bus
- description: APB Bus
clock-names:
items:
- const: osc
- const: hifi4_core
- const: stg_axiahb
- const: usb_125m
- const: cpu_bus
- const: hifi4_axi
- const: nocstg_bus
- const: apb_bus
'#clock-cells':
const: 1
description:
See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices.
'#reset-cells':
const: 1
description:
See <dt-bindings/reset/starfive,jh7110-crg.h> for valid indices.
required:
- compatible
- reg
- clocks
- clock-names
- '#clock-cells'
- '#reset-cells'
additionalProperties: false
examples:
- |
#include <dt-bindings/clock/starfive,jh7110-crg.h>
stgcrg: clock-controller@10230000 {
compatible = "starfive,jh7110-stgcrg";
reg = <0x10230000 0x10000>;
clocks = <&osc>,
<&syscrg JH7110_SYSCLK_HIFI4_CORE>,
<&syscrg JH7110_SYSCLK_STG_AXIAHB>,
<&syscrg JH7110_SYSCLK_USB_125M>,
<&syscrg JH7110_SYSCLK_CPU_BUS>,
<&syscrg JH7110_SYSCLK_HIFI4_AXI>,
<&syscrg JH7110_SYSCLK_NOCSTG_BUS>,
<&syscrg JH7110_SYSCLK_APB_BUS>;
clock-names = "osc", "hifi4_core",
"stg_axiahb", "usb_125m",
"cpu_bus", "hifi4_axi",
"nocstg_bus", "apb_bus";
#clock-cells = <1>;
#reset-cells = <1>;
};
......@@ -27,6 +27,9 @@ properties:
- description: External I2S RX left/right channel clock
- description: External TDM clock
- description: External audio master clock
- description: PLL0
- description: PLL1
- description: PLL2
- items:
- description: Main Oscillator (24 MHz)
......@@ -38,6 +41,9 @@ properties:
- description: External I2S RX left/right channel clock
- description: External TDM clock
- description: External audio master clock
- description: PLL0
- description: PLL1
- description: PLL2
clock-names:
oneOf:
......@@ -52,6 +58,9 @@ properties:
- const: i2srx_lrck_ext
- const: tdm_ext
- const: mclk_ext
- const: pll0_out
- const: pll1_out
- const: pll2_out
- items:
- const: osc
......@@ -63,6 +72,9 @@ properties:
- const: i2srx_lrck_ext
- const: tdm_ext
- const: mclk_ext
- const: pll0_out
- const: pll1_out
- const: pll2_out
'#clock-cells':
const: 1
......@@ -93,12 +105,14 @@ examples:
<&gmac1_rgmii_rxin>,
<&i2stx_bclk_ext>, <&i2stx_lrck_ext>,
<&i2srx_bclk_ext>, <&i2srx_lrck_ext>,
<&tdm_ext>, <&mclk_ext>;
<&tdm_ext>, <&mclk_ext>,
<&pllclk 0>, <&pllclk 1>, <&pllclk 2>;
clock-names = "osc", "gmac1_rmii_refin",
"gmac1_rgmii_rxin",
"i2stx_bclk_ext", "i2stx_lrck_ext",
"i2srx_bclk_ext", "i2srx_lrck_ext",
"tdm_ext", "mclk_ext";
"tdm_ext", "mclk_ext",
"pll0_out", "pll1_out", "pll2_out";
#clock-cells = <1>;
#reset-cells = <1>;
};
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/clock/starfive,jh7110-voutcrg.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: StarFive JH7110 Video-Output Clock and Reset Generator
maintainers:
- Xingyu Wu <xingyu.wu@starfivetech.com>
properties:
compatible:
const: starfive,jh7110-voutcrg
reg:
maxItems: 1
clocks:
items:
- description: Vout Top core
- description: Vout Top Ahb
- description: Vout Top Axi
- description: Vout Top HDMI MCLK
- description: I2STX0 BCLK
- description: external HDMI pixel
clock-names:
items:
- const: vout_src
- const: vout_top_ahb
- const: vout_top_axi
- const: vout_top_hdmitx0_mclk
- const: i2stx0_bclk
- const: hdmitx0_pixelclk
resets:
maxItems: 1
description: Vout Top core
'#clock-cells':
const: 1
description:
See <dt-bindings/clock/starfive,jh7110-crg.h> for valid indices.
'#reset-cells':
const: 1
description:
See <dt-bindings/reset/starfive,jh7110-crg.h> for valid indices.
power-domains:
maxItems: 1
description:
Vout domain power
required:
- compatible
- reg
- clocks
- clock-names
- resets
- '#clock-cells'
- '#reset-cells'
- power-domains
additionalProperties: false
examples:
- |
#include <dt-bindings/clock/starfive,jh7110-crg.h>
#include <dt-bindings/power/starfive,jh7110-pmu.h>
#include <dt-bindings/reset/starfive,jh7110-crg.h>
voutcrg: clock-controller@295C0000 {
compatible = "starfive,jh7110-voutcrg";
reg = <0x295C0000 0x10000>;
clocks = <&syscrg JH7110_SYSCLK_VOUT_SRC>,
<&syscrg JH7110_SYSCLK_VOUT_TOP_AHB>,
<&syscrg JH7110_SYSCLK_VOUT_TOP_AXI>,
<&syscrg JH7110_SYSCLK_VOUT_TOP_HDMITX0_MCLK>,
<&syscrg JH7110_SYSCLK_I2STX0_BCLK>,
<&hdmitx0_pixelclk>;
clock-names = "vout_src", "vout_top_ahb",
"vout_top_axi", "vout_top_hdmitx0_mclk",
"i2stx0_bclk", "hdmitx0_pixelclk";
resets = <&syscrg JH7110_SYSRST_VOUT_TOP_SRC>;
#clock-cells = <1>;
#reset-cells = <1>;
power-domains = <&pwrc JH7110_PD_VOUT>;
};
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/soc/starfive/starfive,jh7110-syscon.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: StarFive JH7110 SoC system controller
maintainers:
- William Qiu <william.qiu@starfivetech.com>
description:
The StarFive JH7110 SoC system controller provides register information such
as offset, mask and shift to configure related modules such as MMC and PCIe.
properties:
compatible:
oneOf:
- items:
- const: starfive,jh7110-sys-syscon
- const: syscon
- const: simple-mfd
- items:
- enum:
- starfive,jh7110-aon-syscon
- starfive,jh7110-stg-syscon
- const: syscon
reg:
maxItems: 1
clock-controller:
$ref: /schemas/clock/starfive,jh7110-pll.yaml#
type: object
"#power-domain-cells":
const: 1
required:
- compatible
- reg
allOf:
- if:
properties:
compatible:
contains:
const: starfive,jh7110-sys-syscon
then:
required:
- clock-controller
else:
properties:
clock-controller: false
- if:
properties:
compatible:
contains:
const: starfive,jh7110-aon-syscon
then:
required:
- "#power-domain-cells"
else:
properties:
"#power-domain-cells": false
additionalProperties: false
examples:
- |
syscon@10240000 {
compatible = "starfive,jh7110-stg-syscon", "syscon";
reg = <0x10240000 0x1000>;
};
syscon@13030000 {
compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd";
reg = <0x13030000 0x1000>;
clock-controller {
compatible = "starfive,jh7110-pll";
clocks = <&osc>;
#clock-cells = <1>;
};
};
syscon@17010000 {
compatible = "starfive,jh7110-aon-syscon", "syscon";
reg = <0x17010000 0x1000>;
#power-domain-cells = <1>;
};
...
......@@ -20271,6 +20271,18 @@ S: Supported
F: Documentation/devicetree/bindings/mmc/starfive*
F: drivers/mmc/host/dw_mmc-starfive.c
STARFIVE JH7110 PLL CLOCK DRIVER
M: Xingyu Wu <xingyu.wu@starfivetech.com>
S: Supported
F: Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml
F: drivers/clk/starfive/clk-starfive-jh7110-pll.c
STARFIVE JH7110 SYSCON
M: William Qiu <william.qiu@starfivetech.com>
M: Xingyu Wu <xingyu.wu@starfivetech.com>
S: Supported
F: Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml
STARFIVE JH7110 TDM DRIVER
M: Walker Chen <walker.chen@starfivetech.com>
S: Maintained
......@@ -20320,6 +20332,7 @@ STARFIVE SOC DRIVERS
M: Conor Dooley <conor@kernel.org>
S: Maintained
T: git https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/
F: Documentation/devicetree/bindings/soc/starfive/
F: drivers/soc/starfive/
STARFIVE TRNG DRIVER
......
......@@ -21,12 +21,21 @@ config CLK_STARFIVE_JH7100_AUDIO
Say Y or M here to support the audio clocks on the StarFive JH7100
SoC.
config CLK_STARFIVE_JH7110_PLL
bool "StarFive JH7110 PLL clock support"
depends on ARCH_STARFIVE || COMPILE_TEST
default ARCH_STARFIVE
help
Say yes here to support the PLL clock controller on the
StarFive JH7110 SoC.
config CLK_STARFIVE_JH7110_SYS
bool "StarFive JH7110 system clock support"
depends on ARCH_STARFIVE || COMPILE_TEST
select AUXILIARY_BUS
select CLK_STARFIVE_JH71X0
select RESET_STARFIVE_JH7110 if RESET_CONTROLLER
select CLK_STARFIVE_JH7110_PLL
default ARCH_STARFIVE
help
Say yes here to support the system clock controller on the
......@@ -39,3 +48,27 @@ config CLK_STARFIVE_JH7110_AON
help
Say yes here to support the always-on clock controller on the
StarFive JH7110 SoC.
config CLK_STARFIVE_JH7110_STG
tristate "StarFive JH7110 System-Top-Group clock support"
depends on CLK_STARFIVE_JH7110_SYS
default m if ARCH_STARFIVE
help
Say yes here to support the System-Top-Group clock controller
on the StarFive JH7110 SoC.
config CLK_STARFIVE_JH7110_ISP
tristate "StarFive JH7110 Image-Signal-Process clock support"
depends on CLK_STARFIVE_JH7110_SYS && JH71XX_PMU
default m if ARCH_STARFIVE
help
Say yes here to support the Image-Signal-Process clock controller
on the StarFive JH7110 SoC.
config CLK_STARFIVE_JH7110_VOUT
tristate "StarFive JH7110 Video-Output clock support"
depends on CLK_STARFIVE_JH7110_SYS && JH71XX_PMU
default m if ARCH_STARFIVE
help
Say yes here to support the Video-Output clock controller
on the StarFive JH7110 SoC.
......@@ -4,5 +4,9 @@ obj-$(CONFIG_CLK_STARFIVE_JH71X0) += clk-starfive-jh71x0.o
obj-$(CONFIG_CLK_STARFIVE_JH7100) += clk-starfive-jh7100.o
obj-$(CONFIG_CLK_STARFIVE_JH7100_AUDIO) += clk-starfive-jh7100-audio.o
obj-$(CONFIG_CLK_STARFIVE_JH7110_PLL) += clk-starfive-jh7110-pll.o
obj-$(CONFIG_CLK_STARFIVE_JH7110_SYS) += clk-starfive-jh7110-sys.o
obj-$(CONFIG_CLK_STARFIVE_JH7110_AON) += clk-starfive-jh7110-aon.o
obj-$(CONFIG_CLK_STARFIVE_JH7110_STG) += clk-starfive-jh7110-stg.o
obj-$(CONFIG_CLK_STARFIVE_JH7110_ISP) += clk-starfive-jh7110-isp.o
obj-$(CONFIG_CLK_STARFIVE_JH7110_VOUT) += clk-starfive-jh7110-vout.o
// SPDX-License-Identifier: GPL-2.0
/*
* StarFive JH7110 Image-Signal-Process Clock Driver
*
* Copyright (C) 2022-2023 StarFive Technology Co., Ltd.
*/
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <dt-bindings/clock/starfive,jh7110-crg.h>
#include "clk-starfive-jh7110.h"
/* external clocks */
#define JH7110_ISPCLK_ISP_TOP_CORE (JH7110_ISPCLK_END + 0)
#define JH7110_ISPCLK_ISP_TOP_AXI (JH7110_ISPCLK_END + 1)
#define JH7110_ISPCLK_NOC_BUS_ISP_AXI (JH7110_ISPCLK_END + 2)
#define JH7110_ISPCLK_DVP_CLK (JH7110_ISPCLK_END + 3)
#define JH7110_ISPCLK_EXT_END (JH7110_ISPCLK_END + 4)
static struct clk_bulk_data jh7110_isp_top_clks[] = {
{ .id = "isp_top_core" },
{ .id = "isp_top_axi" }
};
static const struct jh71x0_clk_data jh7110_ispclk_data[] = {
/* syscon */
JH71X0__DIV(JH7110_ISPCLK_DOM4_APB_FUNC, "dom4_apb_func", 15,
JH7110_ISPCLK_ISP_TOP_AXI),
JH71X0__DIV(JH7110_ISPCLK_MIPI_RX0_PXL, "mipi_rx0_pxl", 8,
JH7110_ISPCLK_ISP_TOP_CORE),
JH71X0__INV(JH7110_ISPCLK_DVP_INV, "dvp_inv", JH7110_ISPCLK_DVP_CLK),
/* vin */
JH71X0__DIV(JH7110_ISPCLK_M31DPHY_CFG_IN, "m31dphy_cfg_in", 16,
JH7110_ISPCLK_ISP_TOP_CORE),
JH71X0__DIV(JH7110_ISPCLK_M31DPHY_REF_IN, "m31dphy_ref_in", 16,
JH7110_ISPCLK_ISP_TOP_CORE),
JH71X0__DIV(JH7110_ISPCLK_M31DPHY_TX_ESC_LAN0, "m31dphy_tx_esc_lan0", 60,
JH7110_ISPCLK_ISP_TOP_CORE),
JH71X0_GATE(JH7110_ISPCLK_VIN_APB, "vin_apb", 0,
JH7110_ISPCLK_DOM4_APB_FUNC),
JH71X0__DIV(JH7110_ISPCLK_VIN_SYS, "vin_sys", 8, JH7110_ISPCLK_ISP_TOP_CORE),
JH71X0_GATE(JH7110_ISPCLK_VIN_PIXEL_IF0, "vin_pixel_if0", 0,
JH7110_ISPCLK_MIPI_RX0_PXL),
JH71X0_GATE(JH7110_ISPCLK_VIN_PIXEL_IF1, "vin_pixel_if1", 0,
JH7110_ISPCLK_MIPI_RX0_PXL),
JH71X0_GATE(JH7110_ISPCLK_VIN_PIXEL_IF2, "vin_pixel_if2", 0,
JH7110_ISPCLK_MIPI_RX0_PXL),
JH71X0_GATE(JH7110_ISPCLK_VIN_PIXEL_IF3, "vin_pixel_if3", 0,
JH7110_ISPCLK_MIPI_RX0_PXL),
JH71X0__MUX(JH7110_ISPCLK_VIN_P_AXI_WR, "vin_p_axi_wr", 2,
JH7110_ISPCLK_MIPI_RX0_PXL,
JH7110_ISPCLK_DVP_INV),
/* ispv2_top_wrapper */
JH71X0_GMUX(JH7110_ISPCLK_ISPV2_TOP_WRAPPER_C, "ispv2_top_wrapper_c", 0, 2,
JH7110_ISPCLK_MIPI_RX0_PXL,
JH7110_ISPCLK_DVP_INV),
};
static inline int jh7110_isp_top_rst_init(struct jh71x0_clk_priv *priv)
{
struct reset_control *top_rsts;
/* The resets should be shared and other ISP modules will use its. */
top_rsts = devm_reset_control_array_get_shared(priv->dev);
if (IS_ERR(top_rsts))
return dev_err_probe(priv->dev, PTR_ERR(top_rsts),
"failed to get top resets\n");
return reset_control_deassert(top_rsts);
}
static struct clk_hw *jh7110_ispclk_get(struct of_phandle_args *clkspec, void *data)
{
struct jh71x0_clk_priv *priv = data;
unsigned int idx = clkspec->args[0];
if (idx < JH7110_ISPCLK_END)
return &priv->reg[idx].hw;
return ERR_PTR(-EINVAL);
}
#ifdef CONFIG_PM
static int jh7110_ispcrg_suspend(struct device *dev)
{
struct jh7110_top_sysclk *top = dev_get_drvdata(dev);
clk_bulk_disable_unprepare(top->top_clks_num, top->top_clks);
return 0;
}
static int jh7110_ispcrg_resume(struct device *dev)
{
struct jh7110_top_sysclk *top = dev_get_drvdata(dev);
return clk_bulk_prepare_enable(top->top_clks_num, top->top_clks);
}
static const struct dev_pm_ops jh7110_ispcrg_pm_ops = {
RUNTIME_PM_OPS(jh7110_ispcrg_suspend, jh7110_ispcrg_resume, NULL)
};
#endif
static int jh7110_ispcrg_probe(struct platform_device *pdev)
{
struct jh71x0_clk_priv *priv;
struct jh7110_top_sysclk *top;
unsigned int idx;
int ret;
priv = devm_kzalloc(&pdev->dev,
struct_size(priv, reg, JH7110_ISPCLK_END),
GFP_KERNEL);
if (!priv)
return -ENOMEM;
top = devm_kzalloc(&pdev->dev, sizeof(*top), GFP_KERNEL);
if (!top)
return -ENOMEM;
spin_lock_init(&priv->rmw_lock);
priv->dev = &pdev->dev;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
top->top_clks = jh7110_isp_top_clks;
top->top_clks_num = ARRAY_SIZE(jh7110_isp_top_clks);
ret = devm_clk_bulk_get(priv->dev, top->top_clks_num, top->top_clks);
if (ret)
return dev_err_probe(priv->dev, ret, "failed to get main clocks\n");
dev_set_drvdata(priv->dev, top);
/* enable power domain and clocks */
pm_runtime_enable(priv->dev);
ret = pm_runtime_get_sync(priv->dev);
if (ret < 0)
return dev_err_probe(priv->dev, ret, "failed to turn on power\n");
ret = jh7110_isp_top_rst_init(priv);
if (ret)
goto err_exit;
for (idx = 0; idx < JH7110_ISPCLK_END; idx++) {
u32 max = jh7110_ispclk_data[idx].max;
struct clk_parent_data parents[4] = {};
struct clk_init_data init = {
.name = jh7110_ispclk_data[idx].name,
.ops = starfive_jh71x0_clk_ops(max),
.parent_data = parents,
.num_parents =
((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
.flags = jh7110_ispclk_data[idx].flags,
};
struct jh71x0_clk *clk = &priv->reg[idx];
unsigned int i;
const char *fw_name[JH7110_ISPCLK_EXT_END - JH7110_ISPCLK_END] = {
"isp_top_core",
"isp_top_axi",
"noc_bus_isp_axi",
"dvp_clk"
};
for (i = 0; i < init.num_parents; i++) {
unsigned int pidx = jh7110_ispclk_data[idx].parents[i];
if (pidx < JH7110_ISPCLK_END)
parents[i].hw = &priv->reg[pidx].hw;
else
parents[i].fw_name = fw_name[pidx - JH7110_ISPCLK_END];
}
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
goto err_exit;
}
ret = devm_of_clk_add_hw_provider(&pdev->dev, jh7110_ispclk_get, priv);
if (ret)
goto err_exit;
ret = jh7110_reset_controller_register(priv, "rst-isp", 3);
if (ret)
goto err_exit;
return 0;
err_exit:
pm_runtime_put_sync(priv->dev);
pm_runtime_disable(priv->dev);
return ret;
}
static int jh7110_ispcrg_remove(struct platform_device *pdev)
{
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
return 0;
}
static const struct of_device_id jh7110_ispcrg_match[] = {
{ .compatible = "starfive,jh7110-ispcrg" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, jh7110_ispcrg_match);
static struct platform_driver jh7110_ispcrg_driver = {
.probe = jh7110_ispcrg_probe,
.remove = jh7110_ispcrg_remove,
.driver = {
.name = "clk-starfive-jh7110-isp",
.of_match_table = jh7110_ispcrg_match,
.pm = pm_ptr(&jh7110_ispcrg_pm_ops),
},
};
module_platform_driver(jh7110_ispcrg_driver);
MODULE_AUTHOR("Xingyu Wu <xingyu.wu@starfivetech.com>");
MODULE_DESCRIPTION("StarFive JH7110 Image-Signal-Process clock driver");
MODULE_LICENSE("GPL");
// SPDX-License-Identifier: GPL-2.0
/*
* StarFive JH7110 PLL Clock Generator Driver
*
* Copyright (C) 2023 StarFive Technology Co., Ltd.
* Copyright (C) 2023 Emil Renner Berthing <emil.renner.berthing@canonical.com>
*
* This driver is about to register JH7110 PLL clock generator and support ops.
* The JH7110 have three PLL clock, PLL0, PLL1 and PLL2.
* Each PLL clocks work in integer mode or fraction mode by some dividers,
* and the configuration registers and dividers are set in several syscon registers.
* The formula for calculating frequency is:
* Fvco = Fref * (NI + NF) / M / Q1
* Fref: OSC source clock rate
* NI: integer frequency dividing ratio of feedback divider, set by fbdiv[11:0].
* NF: fractional frequency dividing ratio, set by frac[23:0]. NF = frac[23:0] / 2^24 = 0 ~ 0.999.
* M: frequency dividing ratio of pre-divider, set by prediv[5:0].
* Q1: frequency dividing ratio of post divider, set by 2^postdiv1[1:0], eg. 1, 2, 4 or 8.
*/
#include <linux/bits.h>
#include <linux/clk-provider.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <dt-bindings/clock/starfive,jh7110-crg.h>
/* this driver expects a 24MHz input frequency from the oscillator */
#define JH7110_PLL_OSC_RATE 24000000UL
#define JH7110_PLL0_PD_OFFSET 0x18
#define JH7110_PLL0_DACPD_SHIFT 24
#define JH7110_PLL0_DACPD_MASK BIT(24)
#define JH7110_PLL0_DSMPD_SHIFT 25
#define JH7110_PLL0_DSMPD_MASK BIT(25)
#define JH7110_PLL0_FBDIV_OFFSET 0x1c
#define JH7110_PLL0_FBDIV_SHIFT 0
#define JH7110_PLL0_FBDIV_MASK GENMASK(11, 0)
#define JH7110_PLL0_FRAC_OFFSET 0x20
#define JH7110_PLL0_PREDIV_OFFSET 0x24
#define JH7110_PLL1_PD_OFFSET 0x24
#define JH7110_PLL1_DACPD_SHIFT 15
#define JH7110_PLL1_DACPD_MASK BIT(15)
#define JH7110_PLL1_DSMPD_SHIFT 16
#define JH7110_PLL1_DSMPD_MASK BIT(16)
#define JH7110_PLL1_FBDIV_OFFSET 0x24
#define JH7110_PLL1_FBDIV_SHIFT 17
#define JH7110_PLL1_FBDIV_MASK GENMASK(28, 17)
#define JH7110_PLL1_FRAC_OFFSET 0x28
#define JH7110_PLL1_PREDIV_OFFSET 0x2c
#define JH7110_PLL2_PD_OFFSET 0x2c
#define JH7110_PLL2_DACPD_SHIFT 15
#define JH7110_PLL2_DACPD_MASK BIT(15)
#define JH7110_PLL2_DSMPD_SHIFT 16
#define JH7110_PLL2_DSMPD_MASK BIT(16)
#define JH7110_PLL2_FBDIV_OFFSET 0x2c
#define JH7110_PLL2_FBDIV_SHIFT 17
#define JH7110_PLL2_FBDIV_MASK GENMASK(28, 17)
#define JH7110_PLL2_FRAC_OFFSET 0x30
#define JH7110_PLL2_PREDIV_OFFSET 0x34
#define JH7110_PLL_FRAC_SHIFT 0
#define JH7110_PLL_FRAC_MASK GENMASK(23, 0)
#define JH7110_PLL_POSTDIV1_SHIFT 28
#define JH7110_PLL_POSTDIV1_MASK GENMASK(29, 28)
#define JH7110_PLL_PREDIV_SHIFT 0
#define JH7110_PLL_PREDIV_MASK GENMASK(5, 0)
enum jh7110_pll_mode {
JH7110_PLL_MODE_FRACTION,
JH7110_PLL_MODE_INTEGER,
};
struct jh7110_pll_preset {
unsigned long freq;
u32 frac; /* frac value should be decimals multiplied by 2^24 */
unsigned fbdiv : 12; /* fbdiv value should be 8 to 4095 */
unsigned prediv : 6;
unsigned postdiv1 : 2;
unsigned mode : 1;
};
struct jh7110_pll_info {
char *name;
const struct jh7110_pll_preset *presets;
unsigned int npresets;
struct {
unsigned int pd;
unsigned int fbdiv;
unsigned int frac;
unsigned int prediv;
} offsets;
struct {
u32 dacpd;
u32 dsmpd;
u32 fbdiv;
} masks;
struct {
char dacpd;
char dsmpd;
char fbdiv;
} shifts;
};
#define _JH7110_PLL(_idx, _name, _presets) \
[_idx] = { \
.name = _name, \
.presets = _presets, \
.npresets = ARRAY_SIZE(_presets), \
.offsets = { \
.pd = JH7110_PLL##_idx##_PD_OFFSET, \
.fbdiv = JH7110_PLL##_idx##_FBDIV_OFFSET, \
.frac = JH7110_PLL##_idx##_FRAC_OFFSET, \
.prediv = JH7110_PLL##_idx##_PREDIV_OFFSET, \
}, \
.masks = { \
.dacpd = JH7110_PLL##_idx##_DACPD_MASK, \
.dsmpd = JH7110_PLL##_idx##_DSMPD_MASK, \
.fbdiv = JH7110_PLL##_idx##_FBDIV_MASK, \
}, \
.shifts = { \
.dacpd = JH7110_PLL##_idx##_DACPD_SHIFT, \
.dsmpd = JH7110_PLL##_idx##_DSMPD_SHIFT, \
.fbdiv = JH7110_PLL##_idx##_FBDIV_SHIFT, \
}, \
}
#define JH7110_PLL(idx, name, presets) _JH7110_PLL(idx, name, presets)
struct jh7110_pll_data {
struct clk_hw hw;
unsigned int idx;
};
struct jh7110_pll_priv {
struct device *dev;
struct regmap *regmap;
struct jh7110_pll_data pll[JH7110_PLLCLK_END];
};
struct jh7110_pll_regvals {
u32 dacpd;
u32 dsmpd;
u32 fbdiv;
u32 frac;
u32 postdiv1;
u32 prediv;
};
/*
* Because the pll frequency is relatively fixed,
* it cannot be set arbitrarily, so it needs a specific configuration.
* PLL0 frequency should be multiple of 125MHz (USB frequency).
*/
static const struct jh7110_pll_preset jh7110_pll0_presets[] = {
{
.freq = 375000000,
.fbdiv = 125,
.prediv = 8,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 500000000,
.fbdiv = 125,
.prediv = 6,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 625000000,
.fbdiv = 625,
.prediv = 24,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 750000000,
.fbdiv = 125,
.prediv = 4,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 875000000,
.fbdiv = 875,
.prediv = 24,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1000000000,
.fbdiv = 125,
.prediv = 3,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1250000000,
.fbdiv = 625,
.prediv = 12,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1375000000,
.fbdiv = 1375,
.prediv = 24,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1500000000,
.fbdiv = 125,
.prediv = 2,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
},
};
static const struct jh7110_pll_preset jh7110_pll1_presets[] = {
{
.freq = 1066000000,
.fbdiv = 533,
.prediv = 12,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1200000000,
.fbdiv = 50,
.prediv = 1,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1400000000,
.fbdiv = 350,
.prediv = 6,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1600000000,
.fbdiv = 200,
.prediv = 3,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
},
};
static const struct jh7110_pll_preset jh7110_pll2_presets[] = {
{
.freq = 1188000000,
.fbdiv = 99,
.prediv = 2,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
}, {
.freq = 1228800000,
.fbdiv = 256,
.prediv = 5,
.postdiv1 = 0,
.mode = JH7110_PLL_MODE_INTEGER,
},
};
static const struct jh7110_pll_info jh7110_plls[JH7110_PLLCLK_END] = {
JH7110_PLL(JH7110_PLLCLK_PLL0_OUT, "pll0_out", jh7110_pll0_presets),
JH7110_PLL(JH7110_PLLCLK_PLL1_OUT, "pll1_out", jh7110_pll1_presets),
JH7110_PLL(JH7110_PLLCLK_PLL2_OUT, "pll2_out", jh7110_pll2_presets),
};
static struct jh7110_pll_data *jh7110_pll_data_from(struct clk_hw *hw)
{
return container_of(hw, struct jh7110_pll_data, hw);
}
static struct jh7110_pll_priv *jh7110_pll_priv_from(struct jh7110_pll_data *pll)
{
return container_of(pll, struct jh7110_pll_priv, pll[pll->idx]);
}
static void jh7110_pll_regvals_get(struct regmap *regmap,
const struct jh7110_pll_info *info,
struct jh7110_pll_regvals *ret)
{
u32 val;
regmap_read(regmap, info->offsets.pd, &val);
ret->dacpd = (val & info->masks.dacpd) >> info->shifts.dacpd;
ret->dsmpd = (val & info->masks.dsmpd) >> info->shifts.dsmpd;
regmap_read(regmap, info->offsets.fbdiv, &val);
ret->fbdiv = (val & info->masks.fbdiv) >> info->shifts.fbdiv;
regmap_read(regmap, info->offsets.frac, &val);
ret->frac = (val & JH7110_PLL_FRAC_MASK) >> JH7110_PLL_FRAC_SHIFT;
ret->postdiv1 = (val & JH7110_PLL_POSTDIV1_MASK) >> JH7110_PLL_POSTDIV1_SHIFT;
regmap_read(regmap, info->offsets.prediv, &val);
ret->prediv = (val & JH7110_PLL_PREDIV_MASK) >> JH7110_PLL_PREDIV_SHIFT;
}
static unsigned long jh7110_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
{
struct jh7110_pll_data *pll = jh7110_pll_data_from(hw);
struct jh7110_pll_priv *priv = jh7110_pll_priv_from(pll);
struct jh7110_pll_regvals val;
unsigned long rate;
jh7110_pll_regvals_get(priv->regmap, &jh7110_plls[pll->idx], &val);
/*
* dacpd = dsmpd = 0: fraction mode
* dacpd = dsmpd = 1: integer mode, frac value ignored
*
* rate = parent * (fbdiv + frac/2^24) / prediv / 2^postdiv1
* = (parent * fbdiv + parent * frac / 2^24) / (prediv * 2^postdiv1)
*/
if (val.dacpd == 0 && val.dsmpd == 0)
rate = parent_rate * val.frac / (1UL << 24);
else if (val.dacpd == 1 && val.dsmpd == 1)
rate = 0;
else
return 0;
rate += parent_rate * val.fbdiv;
rate /= val.prediv << val.postdiv1;
return rate;
}
static int jh7110_pll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
{
struct jh7110_pll_data *pll = jh7110_pll_data_from(hw);
const struct jh7110_pll_info *info = &jh7110_plls[pll->idx];
const struct jh7110_pll_preset *selected = &info->presets[0];
unsigned int idx;
/* if the parent rate doesn't match our expectations the presets won't work */
if (req->best_parent_rate != JH7110_PLL_OSC_RATE) {
req->rate = jh7110_pll_recalc_rate(hw, req->best_parent_rate);
return 0;
}
/* find highest rate lower or equal to the requested rate */
for (idx = 1; idx < info->npresets; idx++) {
const struct jh7110_pll_preset *val = &info->presets[idx];
if (req->rate < val->freq)
break;
selected = val;
}
req->rate = selected->freq;
return 0;
}
static int jh7110_pll_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct jh7110_pll_data *pll = jh7110_pll_data_from(hw);
struct jh7110_pll_priv *priv = jh7110_pll_priv_from(pll);
const struct jh7110_pll_info *info = &jh7110_plls[pll->idx];
const struct jh7110_pll_preset *val;
unsigned int idx;
/* if the parent rate doesn't match our expectations the presets won't work */
if (parent_rate != JH7110_PLL_OSC_RATE)
return -EINVAL;
for (idx = 0, val = &info->presets[0]; idx < info->npresets; idx++, val++) {
if (val->freq == rate)
goto found;
}
return -EINVAL;
found:
if (val->mode == JH7110_PLL_MODE_FRACTION)
regmap_update_bits(priv->regmap, info->offsets.frac, JH7110_PLL_FRAC_MASK,
val->frac << JH7110_PLL_FRAC_SHIFT);
regmap_update_bits(priv->regmap, info->offsets.pd, info->masks.dacpd,
(u32)val->mode << info->shifts.dacpd);
regmap_update_bits(priv->regmap, info->offsets.pd, info->masks.dsmpd,
(u32)val->mode << info->shifts.dsmpd);
regmap_update_bits(priv->regmap, info->offsets.prediv, JH7110_PLL_PREDIV_MASK,
(u32)val->prediv << JH7110_PLL_PREDIV_SHIFT);
regmap_update_bits(priv->regmap, info->offsets.fbdiv, info->masks.fbdiv,
val->fbdiv << info->shifts.fbdiv);
regmap_update_bits(priv->regmap, info->offsets.frac, JH7110_PLL_POSTDIV1_MASK,
(u32)val->postdiv1 << JH7110_PLL_POSTDIV1_SHIFT);
return 0;
}
#ifdef CONFIG_DEBUG_FS
static int jh7110_pll_registers_read(struct seq_file *s, void *unused)
{
struct jh7110_pll_data *pll = s->private;
struct jh7110_pll_priv *priv = jh7110_pll_priv_from(pll);
struct jh7110_pll_regvals val;
jh7110_pll_regvals_get(priv->regmap, &jh7110_plls[pll->idx], &val);
seq_printf(s, "fbdiv=%u\n"
"frac=%u\n"
"prediv=%u\n"
"postdiv1=%u\n"
"dacpd=%u\n"
"dsmpd=%u\n",
val.fbdiv, val.frac, val.prediv, val.postdiv1,
val.dacpd, val.dsmpd);
return 0;
}
static int jh7110_pll_registers_open(struct inode *inode, struct file *f)
{
return single_open(f, jh7110_pll_registers_read, inode->i_private);
}
static const struct file_operations jh7110_pll_registers_ops = {
.owner = THIS_MODULE,
.open = jh7110_pll_registers_open,
.release = single_release,
.read = seq_read,
.llseek = seq_lseek
};
static void jh7110_pll_debug_init(struct clk_hw *hw, struct dentry *dentry)
{
struct jh7110_pll_data *pll = jh7110_pll_data_from(hw);
debugfs_create_file("registers", 0400, dentry, pll,
&jh7110_pll_registers_ops);
}
#else
#define jh7110_pll_debug_init NULL
#endif
static const struct clk_ops jh7110_pll_ops = {
.recalc_rate = jh7110_pll_recalc_rate,
.determine_rate = jh7110_pll_determine_rate,
.set_rate = jh7110_pll_set_rate,
.debug_init = jh7110_pll_debug_init,
};
static struct clk_hw *jh7110_pll_get(struct of_phandle_args *clkspec, void *data)
{
struct jh7110_pll_priv *priv = data;
unsigned int idx = clkspec->args[0];
if (idx < JH7110_PLLCLK_END)
return &priv->pll[idx].hw;
return ERR_PTR(-EINVAL);
}
static int jh7110_pll_probe(struct platform_device *pdev)
{
struct jh7110_pll_priv *priv;
unsigned int idx;
int ret;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->dev = &pdev->dev;
priv->regmap = syscon_node_to_regmap(priv->dev->of_node->parent);
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
for (idx = 0; idx < JH7110_PLLCLK_END; idx++) {
struct clk_parent_data parents = {
.index = 0,
};
struct clk_init_data init = {
.name = jh7110_plls[idx].name,
.ops = &jh7110_pll_ops,
.parent_data = &parents,
.num_parents = 1,
.flags = 0,
};
struct jh7110_pll_data *pll = &priv->pll[idx];
pll->hw.init = &init;
pll->idx = idx;
ret = devm_clk_hw_register(&pdev->dev, &pll->hw);
if (ret)
return ret;
}
return devm_of_clk_add_hw_provider(&pdev->dev, jh7110_pll_get, priv);
}
static const struct of_device_id jh7110_pll_match[] = {
{ .compatible = "starfive,jh7110-pll" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, jh7110_pll_match);
static struct platform_driver jh7110_pll_driver = {
.driver = {
.name = "clk-starfive-jh7110-pll",
.of_match_table = jh7110_pll_match,
},
};
builtin_platform_driver_probe(jh7110_pll_driver, jh7110_pll_probe);
// SPDX-License-Identifier: GPL-2.0
/*
* StarFive JH7110 System-Top-Group Clock Driver
*
* Copyright (C) 2022 Emil Renner Berthing <kernel@esmil.dk>
* Copyright (C) 2022 StarFive Technology Co., Ltd.
*/
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <dt-bindings/clock/starfive,jh7110-crg.h>
#include "clk-starfive-jh7110.h"
/* external clocks */
#define JH7110_STGCLK_OSC (JH7110_STGCLK_END + 0)
#define JH7110_STGCLK_HIFI4_CORE (JH7110_STGCLK_END + 1)
#define JH7110_STGCLK_STG_AXIAHB (JH7110_STGCLK_END + 2)
#define JH7110_STGCLK_USB_125M (JH7110_STGCLK_END + 3)
#define JH7110_STGCLK_CPU_BUS (JH7110_STGCLK_END + 4)
#define JH7110_STGCLK_HIFI4_AXI (JH7110_STGCLK_END + 5)
#define JH7110_STGCLK_NOCSTG_BUS (JH7110_STGCLK_END + 6)
#define JH7110_STGCLK_APB_BUS (JH7110_STGCLK_END + 7)
#define JH7110_STGCLK_EXT_END (JH7110_STGCLK_END + 8)
static const struct jh71x0_clk_data jh7110_stgclk_data[] = {
/* hifi4 */
JH71X0_GATE(JH7110_STGCLK_HIFI4_CLK_CORE, "hifi4_clk_core", 0,
JH7110_STGCLK_HIFI4_CORE),
/* usb */
JH71X0_GATE(JH7110_STGCLK_USB0_APB, "usb0_apb", 0, JH7110_STGCLK_APB_BUS),
JH71X0_GATE(JH7110_STGCLK_USB0_UTMI_APB, "usb0_utmi_apb", 0, JH7110_STGCLK_APB_BUS),
JH71X0_GATE(JH7110_STGCLK_USB0_AXI, "usb0_axi", 0, JH7110_STGCLK_STG_AXIAHB),
JH71X0_GDIV(JH7110_STGCLK_USB0_LPM, "usb0_lpm", 0, 2, JH7110_STGCLK_OSC),
JH71X0_GDIV(JH7110_STGCLK_USB0_STB, "usb0_stb", 0, 4, JH7110_STGCLK_OSC),
JH71X0_GATE(JH7110_STGCLK_USB0_APP_125, "usb0_app_125", 0, JH7110_STGCLK_USB_125M),
JH71X0__DIV(JH7110_STGCLK_USB0_REFCLK, "usb0_refclk", 2, JH7110_STGCLK_OSC),
/* pci-e */
JH71X0_GATE(JH7110_STGCLK_PCIE0_AXI_MST0, "pcie0_axi_mst0", 0,
JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_PCIE0_APB, "pcie0_apb", 0, JH7110_STGCLK_APB_BUS),
JH71X0_GATE(JH7110_STGCLK_PCIE0_TL, "pcie0_tl", 0, JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_PCIE1_AXI_MST0, "pcie1_axi_mst0", 0,
JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_PCIE1_APB, "pcie1_apb", 0, JH7110_STGCLK_APB_BUS),
JH71X0_GATE(JH7110_STGCLK_PCIE1_TL, "pcie1_tl", 0, JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_PCIE_SLV_MAIN, "pcie_slv_main", CLK_IS_CRITICAL,
JH7110_STGCLK_STG_AXIAHB),
/* security */
JH71X0_GATE(JH7110_STGCLK_SEC_AHB, "sec_ahb", 0, JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_SEC_MISC_AHB, "sec_misc_ahb", 0, JH7110_STGCLK_STG_AXIAHB),
/* stg mtrx */
JH71X0_GATE(JH7110_STGCLK_GRP0_MAIN, "mtrx_grp0_main", CLK_IS_CRITICAL,
JH7110_STGCLK_CPU_BUS),
JH71X0_GATE(JH7110_STGCLK_GRP0_BUS, "mtrx_grp0_bus", CLK_IS_CRITICAL,
JH7110_STGCLK_NOCSTG_BUS),
JH71X0_GATE(JH7110_STGCLK_GRP0_STG, "mtrx_grp0_stg", CLK_IS_CRITICAL,
JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_GRP1_MAIN, "mtrx_grp1_main", CLK_IS_CRITICAL,
JH7110_STGCLK_CPU_BUS),
JH71X0_GATE(JH7110_STGCLK_GRP1_BUS, "mtrx_grp1_bus", CLK_IS_CRITICAL,
JH7110_STGCLK_NOCSTG_BUS),
JH71X0_GATE(JH7110_STGCLK_GRP1_STG, "mtrx_grp1_stg", CLK_IS_CRITICAL,
JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_GRP1_HIFI, "mtrx_grp1_hifi", CLK_IS_CRITICAL,
JH7110_STGCLK_HIFI4_AXI),
/* e24_rvpi */
JH71X0_GDIV(JH7110_STGCLK_E2_RTC, "e2_rtc", 0, 24, JH7110_STGCLK_OSC),
JH71X0_GATE(JH7110_STGCLK_E2_CORE, "e2_core", 0, JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_E2_DBG, "e2_dbg", 0, JH7110_STGCLK_STG_AXIAHB),
/* dw_sgdma1p */
JH71X0_GATE(JH7110_STGCLK_DMA1P_AXI, "dma1p_axi", 0, JH7110_STGCLK_STG_AXIAHB),
JH71X0_GATE(JH7110_STGCLK_DMA1P_AHB, "dma1p_ahb", 0, JH7110_STGCLK_STG_AXIAHB),
};
static struct clk_hw *jh7110_stgclk_get(struct of_phandle_args *clkspec, void *data)
{
struct jh71x0_clk_priv *priv = data;
unsigned int idx = clkspec->args[0];
if (idx < JH7110_STGCLK_END)
return &priv->reg[idx].hw;
return ERR_PTR(-EINVAL);
}
static int jh7110_stgcrg_probe(struct platform_device *pdev)
{
struct jh71x0_clk_priv *priv;
unsigned int idx;
int ret;
priv = devm_kzalloc(&pdev->dev, struct_size(priv, reg, JH7110_STGCLK_END),
GFP_KERNEL);
if (!priv)
return -ENOMEM;
spin_lock_init(&priv->rmw_lock);
priv->dev = &pdev->dev;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
for (idx = 0; idx < JH7110_STGCLK_END; idx++) {
u32 max = jh7110_stgclk_data[idx].max;
struct clk_parent_data parents[4] = {};
struct clk_init_data init = {
.name = jh7110_stgclk_data[idx].name,
.ops = starfive_jh71x0_clk_ops(max),
.parent_data = parents,
.num_parents =
((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
.flags = jh7110_stgclk_data[idx].flags,
};
struct jh71x0_clk *clk = &priv->reg[idx];
const char *fw_name[JH7110_STGCLK_EXT_END - JH7110_STGCLK_END] = {
"osc",
"hifi4_core",
"stg_axiahb",
"usb_125m",
"cpu_bus",
"hifi4_axi",
"nocstg_bus",
"apb_bus"
};
unsigned int i;
for (i = 0; i < init.num_parents; i++) {
unsigned int pidx = jh7110_stgclk_data[idx].parents[i];
if (pidx < JH7110_STGCLK_END)
parents[i].hw = &priv->reg[pidx].hw;
else if (pidx < JH7110_STGCLK_EXT_END)
parents[i].fw_name = fw_name[pidx - JH7110_STGCLK_END];
}
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
return ret;
}
ret = devm_of_clk_add_hw_provider(&pdev->dev, jh7110_stgclk_get, priv);
if (ret)
return ret;
return jh7110_reset_controller_register(priv, "rst-stg", 2);
}
static const struct of_device_id jh7110_stgcrg_match[] = {
{ .compatible = "starfive,jh7110-stgcrg" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, jh7110_stgcrg_match);
static struct platform_driver jh7110_stgcrg_driver = {
.probe = jh7110_stgcrg_probe,
.driver = {
.name = "clk-starfive-jh7110-stg",
.of_match_table = jh7110_stgcrg_match,
},
};
module_platform_driver(jh7110_stgcrg_driver);
MODULE_AUTHOR("Xingyu Wu <xingyu.wu@starfivetech.com>");
MODULE_AUTHOR("Emil Renner Berthing <kernel@esmil.dk>");
MODULE_DESCRIPTION("StarFive JH7110 System-Top-Group clock driver");
MODULE_LICENSE("GPL");
......@@ -7,6 +7,7 @@
*/
#include <linux/auxiliary_bus.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/init.h>
#include <linux/io.h>
......@@ -389,6 +390,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
struct jh71x0_clk_priv *priv;
unsigned int idx;
int ret;
struct clk *pllclk;
priv = devm_kzalloc(&pdev->dev,
struct_size(priv, reg, JH7110_SYSCLK_END),
......@@ -402,28 +404,42 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
/*
* These PLL clocks are not actually fixed factor clocks and can be
* controlled by the syscon registers of JH7110. They will be dropped
* and registered in the PLL clock driver instead.
*/
/* 24MHz -> 1000.0MHz */
priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out",
"osc", 0, 125, 3);
if (IS_ERR(priv->pll[0]))
return PTR_ERR(priv->pll[0]);
/* 24MHz -> 1066.0MHz */
priv->pll[1] = devm_clk_hw_register_fixed_factor(priv->dev, "pll1_out",
"osc", 0, 533, 12);
if (IS_ERR(priv->pll[1]))
return PTR_ERR(priv->pll[1]);
/* 24MHz -> 1188.0MHz */
priv->pll[2] = devm_clk_hw_register_fixed_factor(priv->dev, "pll2_out",
"osc", 0, 99, 2);
if (IS_ERR(priv->pll[2]))
return PTR_ERR(priv->pll[2]);
/* Use fixed factor clocks if can not get the PLL clocks from DTS */
pllclk = clk_get(priv->dev, "pll0_out");
if (IS_ERR(pllclk)) {
/* 24MHz -> 1000.0MHz */
priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out",
"osc", 0, 125, 3);
if (IS_ERR(priv->pll[0]))
return PTR_ERR(priv->pll[0]);
} else {
clk_put(pllclk);
priv->pll[0] = NULL;
}
pllclk = clk_get(priv->dev, "pll1_out");
if (IS_ERR(pllclk)) {
/* 24MHz -> 1066.0MHz */
priv->pll[1] = devm_clk_hw_register_fixed_factor(priv->dev, "pll1_out",
"osc", 0, 533, 12);
if (IS_ERR(priv->pll[1]))
return PTR_ERR(priv->pll[1]);
} else {
clk_put(pllclk);
priv->pll[1] = NULL;
}
pllclk = clk_get(priv->dev, "pll2_out");
if (IS_ERR(pllclk)) {
/* 24MHz -> 1188.0MHz */
priv->pll[2] = devm_clk_hw_register_fixed_factor(priv->dev, "pll2_out",
"osc", 0, 99, 2);
if (IS_ERR(priv->pll[2]))
return PTR_ERR(priv->pll[2]);
} else {
clk_put(pllclk);
priv->pll[2] = NULL;
}
for (idx = 0; idx < JH7110_SYSCLK_END; idx++) {
u32 max = jh7110_sysclk_data[idx].max;
......@@ -462,6 +478,12 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
parents[i].fw_name = "tdm_ext";
else if (pidx == JH7110_SYSCLK_MCLK_EXT)
parents[i].fw_name = "mclk_ext";
else if (pidx == JH7110_SYSCLK_PLL0_OUT && !priv->pll[0])
parents[i].fw_name = "pll0_out";
else if (pidx == JH7110_SYSCLK_PLL1_OUT && !priv->pll[1])
parents[i].fw_name = "pll1_out";
else if (pidx == JH7110_SYSCLK_PLL2_OUT && !priv->pll[2])
parents[i].fw_name = "pll2_out";
else
parents[i].hw = priv->pll[pidx - JH7110_SYSCLK_PLL0_OUT];
}
......
// SPDX-License-Identifier: GPL-2.0
/*
* StarFive JH7110 Video-Output Clock Driver
*
* Copyright (C) 2022-2023 StarFive Technology Co., Ltd.
*/
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <dt-bindings/clock/starfive,jh7110-crg.h>
#include "clk-starfive-jh7110.h"
/* external clocks */
#define JH7110_VOUTCLK_VOUT_SRC (JH7110_VOUTCLK_END + 0)
#define JH7110_VOUTCLK_VOUT_TOP_AHB (JH7110_VOUTCLK_END + 1)
#define JH7110_VOUTCLK_VOUT_TOP_AXI (JH7110_VOUTCLK_END + 2)
#define JH7110_VOUTCLK_VOUT_TOP_HDMITX0_MCLK (JH7110_VOUTCLK_END + 3)
#define JH7110_VOUTCLK_I2STX0_BCLK (JH7110_VOUTCLK_END + 4)
#define JH7110_VOUTCLK_HDMITX0_PIXELCLK (JH7110_VOUTCLK_END + 5)
#define JH7110_VOUTCLK_EXT_END (JH7110_VOUTCLK_END + 6)
static struct clk_bulk_data jh7110_vout_top_clks[] = {
{ .id = "vout_src" },
{ .id = "vout_top_ahb" }
};
static const struct jh71x0_clk_data jh7110_voutclk_data[] = {
/* divider */
JH71X0__DIV(JH7110_VOUTCLK_APB, "apb", 8, JH7110_VOUTCLK_VOUT_TOP_AHB),
JH71X0__DIV(JH7110_VOUTCLK_DC8200_PIX, "dc8200_pix", 63, JH7110_VOUTCLK_VOUT_SRC),
JH71X0__DIV(JH7110_VOUTCLK_DSI_SYS, "dsi_sys", 31, JH7110_VOUTCLK_VOUT_SRC),
JH71X0__DIV(JH7110_VOUTCLK_TX_ESC, "tx_esc", 31, JH7110_VOUTCLK_VOUT_TOP_AHB),
/* dc8200 */
JH71X0_GATE(JH7110_VOUTCLK_DC8200_AXI, "dc8200_axi", 0, JH7110_VOUTCLK_VOUT_TOP_AXI),
JH71X0_GATE(JH7110_VOUTCLK_DC8200_CORE, "dc8200_core", 0, JH7110_VOUTCLK_VOUT_TOP_AXI),
JH71X0_GATE(JH7110_VOUTCLK_DC8200_AHB, "dc8200_ahb", 0, JH7110_VOUTCLK_VOUT_TOP_AHB),
JH71X0_GMUX(JH7110_VOUTCLK_DC8200_PIX0, "dc8200_pix0", 0, 2,
JH7110_VOUTCLK_DC8200_PIX,
JH7110_VOUTCLK_HDMITX0_PIXELCLK),
JH71X0_GMUX(JH7110_VOUTCLK_DC8200_PIX1, "dc8200_pix1", 0, 2,
JH7110_VOUTCLK_DC8200_PIX,
JH7110_VOUTCLK_HDMITX0_PIXELCLK),
/* LCD */
JH71X0_GMUX(JH7110_VOUTCLK_DOM_VOUT_TOP_LCD, "dom_vout_top_lcd", 0, 2,
JH7110_VOUTCLK_DC8200_PIX0,
JH7110_VOUTCLK_DC8200_PIX1),
/* dsiTx */
JH71X0_GATE(JH7110_VOUTCLK_DSITX_APB, "dsiTx_apb", 0, JH7110_VOUTCLK_DSI_SYS),
JH71X0_GATE(JH7110_VOUTCLK_DSITX_SYS, "dsiTx_sys", 0, JH7110_VOUTCLK_DSI_SYS),
JH71X0_GMUX(JH7110_VOUTCLK_DSITX_DPI, "dsiTx_dpi", 0, 2,
JH7110_VOUTCLK_DC8200_PIX,
JH7110_VOUTCLK_HDMITX0_PIXELCLK),
JH71X0_GATE(JH7110_VOUTCLK_DSITX_TXESC, "dsiTx_txesc", 0, JH7110_VOUTCLK_TX_ESC),
/* mipitx DPHY */
JH71X0_GATE(JH7110_VOUTCLK_MIPITX_DPHY_TXESC, "mipitx_dphy_txesc", 0,
JH7110_VOUTCLK_TX_ESC),
/* hdmi */
JH71X0_GATE(JH7110_VOUTCLK_HDMI_TX_MCLK, "hdmi_tx_mclk", 0,
JH7110_VOUTCLK_VOUT_TOP_HDMITX0_MCLK),
JH71X0_GATE(JH7110_VOUTCLK_HDMI_TX_BCLK, "hdmi_tx_bclk", 0,
JH7110_VOUTCLK_I2STX0_BCLK),
JH71X0_GATE(JH7110_VOUTCLK_HDMI_TX_SYS, "hdmi_tx_sys", 0, JH7110_VOUTCLK_APB),
};
static int jh7110_vout_top_rst_init(struct jh71x0_clk_priv *priv)
{
struct reset_control *top_rst;
/* The reset should be shared and other Vout modules will use its. */
top_rst = devm_reset_control_get_shared(priv->dev, NULL);
if (IS_ERR(top_rst))
return dev_err_probe(priv->dev, PTR_ERR(top_rst), "failed to get top reset\n");
return reset_control_deassert(top_rst);
}
static struct clk_hw *jh7110_voutclk_get(struct of_phandle_args *clkspec, void *data)
{
struct jh71x0_clk_priv *priv = data;
unsigned int idx = clkspec->args[0];
if (idx < JH7110_VOUTCLK_END)
return &priv->reg[idx].hw;
return ERR_PTR(-EINVAL);
}
#ifdef CONFIG_PM
static int jh7110_voutcrg_suspend(struct device *dev)
{
struct jh7110_top_sysclk *top = dev_get_drvdata(dev);
clk_bulk_disable_unprepare(top->top_clks_num, top->top_clks);
return 0;
}
static int jh7110_voutcrg_resume(struct device *dev)
{
struct jh7110_top_sysclk *top = dev_get_drvdata(dev);
return clk_bulk_prepare_enable(top->top_clks_num, top->top_clks);
}
static const struct dev_pm_ops jh7110_voutcrg_pm_ops = {
RUNTIME_PM_OPS(jh7110_voutcrg_suspend, jh7110_voutcrg_resume, NULL)
};
#endif
static int jh7110_voutcrg_probe(struct platform_device *pdev)
{
struct jh71x0_clk_priv *priv;
struct jh7110_top_sysclk *top;
unsigned int idx;
int ret;
priv = devm_kzalloc(&pdev->dev,
struct_size(priv, reg, JH7110_VOUTCLK_END),
GFP_KERNEL);
if (!priv)
return -ENOMEM;
top = devm_kzalloc(&pdev->dev, sizeof(*top), GFP_KERNEL);
if (!top)
return -ENOMEM;
spin_lock_init(&priv->rmw_lock);
priv->dev = &pdev->dev;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
top->top_clks = jh7110_vout_top_clks;
top->top_clks_num = ARRAY_SIZE(jh7110_vout_top_clks);
ret = devm_clk_bulk_get(priv->dev, top->top_clks_num, top->top_clks);
if (ret)
return dev_err_probe(priv->dev, ret, "failed to get top clocks\n");
dev_set_drvdata(priv->dev, top);
/* enable power domain and clocks */
pm_runtime_enable(priv->dev);
ret = pm_runtime_get_sync(priv->dev);
if (ret < 0)
return dev_err_probe(priv->dev, ret, "failed to turn on power\n");
ret = jh7110_vout_top_rst_init(priv);
if (ret)
goto err_exit;
for (idx = 0; idx < JH7110_VOUTCLK_END; idx++) {
u32 max = jh7110_voutclk_data[idx].max;
struct clk_parent_data parents[4] = {};
struct clk_init_data init = {
.name = jh7110_voutclk_data[idx].name,
.ops = starfive_jh71x0_clk_ops(max),
.parent_data = parents,
.num_parents =
((max & JH71X0_CLK_MUX_MASK) >> JH71X0_CLK_MUX_SHIFT) + 1,
.flags = jh7110_voutclk_data[idx].flags,
};
struct jh71x0_clk *clk = &priv->reg[idx];
unsigned int i;
const char *fw_name[JH7110_VOUTCLK_EXT_END - JH7110_VOUTCLK_END] = {
"vout_src",
"vout_top_ahb",
"vout_top_axi",
"vout_top_hdmitx0_mclk",
"i2stx0_bclk",
"hdmitx0_pixelclk"
};
for (i = 0; i < init.num_parents; i++) {
unsigned int pidx = jh7110_voutclk_data[idx].parents[i];
if (pidx < JH7110_VOUTCLK_END)
parents[i].hw = &priv->reg[pidx].hw;
else if (pidx < JH7110_VOUTCLK_EXT_END)
parents[i].fw_name = fw_name[pidx - JH7110_VOUTCLK_END];
}
clk->hw.init = &init;
clk->idx = idx;
clk->max_div = max & JH71X0_CLK_DIV_MASK;
ret = devm_clk_hw_register(&pdev->dev, &clk->hw);
if (ret)
goto err_exit;
}
ret = devm_of_clk_add_hw_provider(&pdev->dev, jh7110_voutclk_get, priv);
if (ret)
goto err_exit;
ret = jh7110_reset_controller_register(priv, "rst-vo", 4);
if (ret)
goto err_exit;
return 0;
err_exit:
pm_runtime_put_sync(priv->dev);
pm_runtime_disable(priv->dev);
return ret;
}
static int jh7110_voutcrg_remove(struct platform_device *pdev)
{
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
return 0;
}
static const struct of_device_id jh7110_voutcrg_match[] = {
{ .compatible = "starfive,jh7110-voutcrg" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, jh7110_voutcrg_match);
static struct platform_driver jh7110_voutcrg_driver = {
.probe = jh7110_voutcrg_probe,
.remove = jh7110_voutcrg_remove,
.driver = {
.name = "clk-starfive-jh7110-vout",
.of_match_table = jh7110_voutcrg_match,
.pm = pm_ptr(&jh7110_voutcrg_pm_ops),
},
};
module_platform_driver(jh7110_voutcrg_driver);
MODULE_AUTHOR("Xingyu Wu <xingyu.wu@starfivetech.com>");
MODULE_DESCRIPTION("StarFive JH7110 Video-Output clock driver");
MODULE_LICENSE("GPL");
......@@ -4,6 +4,12 @@
#include "clk-starfive-jh71x0.h"
/* top clocks of ISP/VOUT domain from JH7110 SYSCRG */
struct jh7110_top_sysclk {
struct clk_bulk_data *top_clks;
int top_clks_num;
};
int jh7110_reset_controller_register(struct jh71x0_clk_priv *priv,
const char *adev_name,
u32 adev_id);
......
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/*
* Copyright 2022 Emil Renner Berthing <kernel@esmil.dk>
* Copyright 2022 StarFive Technology Co., Ltd.
*/
#ifndef __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__
#define __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__
/* PLL clocks */
#define JH7110_PLLCLK_PLL0_OUT 0
#define JH7110_PLLCLK_PLL1_OUT 1
#define JH7110_PLLCLK_PLL2_OUT 2
#define JH7110_PLLCLK_END 3
/* SYSCRG clocks */
#define JH7110_SYSCLK_CPU_ROOT 0
#define JH7110_SYSCLK_CPU_CORE 1
......@@ -218,4 +225,77 @@
#define JH7110_AONCLK_END 14
/* STGCRG clocks */
#define JH7110_STGCLK_HIFI4_CLK_CORE 0
#define JH7110_STGCLK_USB0_APB 1
#define JH7110_STGCLK_USB0_UTMI_APB 2
#define JH7110_STGCLK_USB0_AXI 3
#define JH7110_STGCLK_USB0_LPM 4
#define JH7110_STGCLK_USB0_STB 5
#define JH7110_STGCLK_USB0_APP_125 6
#define JH7110_STGCLK_USB0_REFCLK 7
#define JH7110_STGCLK_PCIE0_AXI_MST0 8
#define JH7110_STGCLK_PCIE0_APB 9
#define JH7110_STGCLK_PCIE0_TL 10
#define JH7110_STGCLK_PCIE1_AXI_MST0 11
#define JH7110_STGCLK_PCIE1_APB 12
#define JH7110_STGCLK_PCIE1_TL 13
#define JH7110_STGCLK_PCIE_SLV_MAIN 14
#define JH7110_STGCLK_SEC_AHB 15
#define JH7110_STGCLK_SEC_MISC_AHB 16
#define JH7110_STGCLK_GRP0_MAIN 17
#define JH7110_STGCLK_GRP0_BUS 18
#define JH7110_STGCLK_GRP0_STG 19
#define JH7110_STGCLK_GRP1_MAIN 20
#define JH7110_STGCLK_GRP1_BUS 21
#define JH7110_STGCLK_GRP1_STG 22
#define JH7110_STGCLK_GRP1_HIFI 23
#define JH7110_STGCLK_E2_RTC 24
#define JH7110_STGCLK_E2_CORE 25
#define JH7110_STGCLK_E2_DBG 26
#define JH7110_STGCLK_DMA1P_AXI 27
#define JH7110_STGCLK_DMA1P_AHB 28
#define JH7110_STGCLK_END 29
/* ISPCRG clocks */
#define JH7110_ISPCLK_DOM4_APB_FUNC 0
#define JH7110_ISPCLK_MIPI_RX0_PXL 1
#define JH7110_ISPCLK_DVP_INV 2
#define JH7110_ISPCLK_M31DPHY_CFG_IN 3
#define JH7110_ISPCLK_M31DPHY_REF_IN 4
#define JH7110_ISPCLK_M31DPHY_TX_ESC_LAN0 5
#define JH7110_ISPCLK_VIN_APB 6
#define JH7110_ISPCLK_VIN_SYS 7
#define JH7110_ISPCLK_VIN_PIXEL_IF0 8
#define JH7110_ISPCLK_VIN_PIXEL_IF1 9
#define JH7110_ISPCLK_VIN_PIXEL_IF2 10
#define JH7110_ISPCLK_VIN_PIXEL_IF3 11
#define JH7110_ISPCLK_VIN_P_AXI_WR 12
#define JH7110_ISPCLK_ISPV2_TOP_WRAPPER_C 13
#define JH7110_ISPCLK_END 14
/* VOUTCRG clocks */
#define JH7110_VOUTCLK_APB 0
#define JH7110_VOUTCLK_DC8200_PIX 1
#define JH7110_VOUTCLK_DSI_SYS 2
#define JH7110_VOUTCLK_TX_ESC 3
#define JH7110_VOUTCLK_DC8200_AXI 4
#define JH7110_VOUTCLK_DC8200_CORE 5
#define JH7110_VOUTCLK_DC8200_AHB 6
#define JH7110_VOUTCLK_DC8200_PIX0 7
#define JH7110_VOUTCLK_DC8200_PIX1 8
#define JH7110_VOUTCLK_DOM_VOUT_TOP_LCD 9
#define JH7110_VOUTCLK_DSITX_APB 10
#define JH7110_VOUTCLK_DSITX_SYS 11
#define JH7110_VOUTCLK_DSITX_DPI 12
#define JH7110_VOUTCLK_DSITX_TXESC 13
#define JH7110_VOUTCLK_MIPITX_DPHY_TXESC 14
#define JH7110_VOUTCLK_HDMI_TX_MCLK 15
#define JH7110_VOUTCLK_HDMI_TX_BCLK 16
#define JH7110_VOUTCLK_HDMI_TX_SYS 17
#define JH7110_VOUTCLK_END 18
#endif /* __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__ */
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/*
* Copyright (C) 2022 Emil Renner Berthing <kernel@esmil.dk>
* Copyright (C) 2022 StarFive Technology Co., Ltd.
*/
#ifndef __DT_BINDINGS_RESET_STARFIVE_JH7110_CRG_H__
......@@ -151,4 +152,63 @@
#define JH7110_AONRST_END 8
/* STGCRG resets */
#define JH7110_STGRST_SYSCON 0
#define JH7110_STGRST_HIFI4_CORE 1
#define JH7110_STGRST_HIFI4_AXI 2
#define JH7110_STGRST_SEC_AHB 3
#define JH7110_STGRST_E24_CORE 4
#define JH7110_STGRST_DMA1P_AXI 5
#define JH7110_STGRST_DMA1P_AHB 6
#define JH7110_STGRST_USB0_AXI 7
#define JH7110_STGRST_USB0_APB 8
#define JH7110_STGRST_USB0_UTMI_APB 9
#define JH7110_STGRST_USB0_PWRUP 10
#define JH7110_STGRST_PCIE0_AXI_MST0 11
#define JH7110_STGRST_PCIE0_AXI_SLV0 12
#define JH7110_STGRST_PCIE0_AXI_SLV 13
#define JH7110_STGRST_PCIE0_BRG 14
#define JH7110_STGRST_PCIE0_CORE 15
#define JH7110_STGRST_PCIE0_APB 16
#define JH7110_STGRST_PCIE1_AXI_MST0 17
#define JH7110_STGRST_PCIE1_AXI_SLV0 18
#define JH7110_STGRST_PCIE1_AXI_SLV 19
#define JH7110_STGRST_PCIE1_BRG 20
#define JH7110_STGRST_PCIE1_CORE 21
#define JH7110_STGRST_PCIE1_APB 22
#define JH7110_STGRST_END 23
/* ISPCRG resets */
#define JH7110_ISPRST_ISPV2_TOP_WRAPPER_P 0
#define JH7110_ISPRST_ISPV2_TOP_WRAPPER_C 1
#define JH7110_ISPRST_M31DPHY_HW 2
#define JH7110_ISPRST_M31DPHY_B09_AON 3
#define JH7110_ISPRST_VIN_APB 4
#define JH7110_ISPRST_VIN_PIXEL_IF0 5
#define JH7110_ISPRST_VIN_PIXEL_IF1 6
#define JH7110_ISPRST_VIN_PIXEL_IF2 7
#define JH7110_ISPRST_VIN_PIXEL_IF3 8
#define JH7110_ISPRST_VIN_SYS 9
#define JH7110_ISPRST_VIN_P_AXI_RD 10
#define JH7110_ISPRST_VIN_P_AXI_WR 11
#define JH7110_ISPRST_END 12
/* VOUTCRG resets */
#define JH7110_VOUTRST_DC8200_AXI 0
#define JH7110_VOUTRST_DC8200_AHB 1
#define JH7110_VOUTRST_DC8200_CORE 2
#define JH7110_VOUTRST_DSITX_DPI 3
#define JH7110_VOUTRST_DSITX_APB 4
#define JH7110_VOUTRST_DSITX_RXESC 5
#define JH7110_VOUTRST_DSITX_SYS 6
#define JH7110_VOUTRST_DSITX_TXBYTEHS 7
#define JH7110_VOUTRST_DSITX_TXESC 8
#define JH7110_VOUTRST_HDMI_TX_HDMI 9
#define JH7110_VOUTRST_MIPITX_DPHY_SYS 10
#define JH7110_VOUTRST_MIPITX_DPHY_TXBYTEHS 11
#define JH7110_VOUTRST_END 12
#endif /* __DT_BINDINGS_RESET_STARFIVE_JH7110_CRG_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment