Commit 4f1e19b6 authored by Stephen Boyd's avatar Stephen Boyd
Browse files

Merge tag 'sunxi-clk-for-5.17-1' of...

Merge tag 'sunxi-clk-for-5.17-1' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into clk-allwinner

Pull Allwinner clk driver updates from Maxime Ripard:

Our usual PR for the Allwinner SoCs, this time enabling our
sub-framework to be built as a module, converting most drivers to
platform drivers and allow them to be built as modules, and support for
the Allwinner D1

* tag 'sunxi-clk-for-5.17-1' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux:
  clk: sunxi-ng: Add support for the D1 SoC clocks
  clk: sunxi-ng: gate: Add macros for gates with fixed dividers
  clk: sunxi-ng: mux: Add macros using clk_parent_data and clk_hw
  clk: sunxi-ng: mp: Add macros using clk_parent_data and clk_hw
  clk: sunxi-ng: div: Add macros using clk_parent_data and clk_hw
  dt-bindings: clk: Add compatibles for D1 CCUs
  clk: sunxi-ng: Allow the CCU core to be built as a module
  clk: sunxi-ng: Convert early providers to platform drivers
  clk: sunxi-ng: Allow drivers to be built as modules
  clk: sunxi-ng: Export symbols used by CCU drivers
parents fa55b7dc 35b97bb9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ properties:
      - allwinner,sun8i-v3-ccu
      - allwinner,sun8i-v3s-ccu
      - allwinner,sun9i-a80-ccu
      - allwinner,sun20i-d1-ccu
      - allwinner,sun20i-d1-r-ccu
      - allwinner,sun50i-a64-ccu
      - allwinner,sun50i-a64-r-ccu
      - allwinner,sun50i-a100-ccu
@@ -79,6 +81,7 @@ if:
      enum:
        - allwinner,sun8i-a83t-r-ccu
        - allwinner,sun8i-h3-r-ccu
        - allwinner,sun20i-d1-r-ccu
        - allwinner,sun50i-a64-r-ccu
        - allwinner,sun50i-a100-r-ccu
        - allwinner,sun50i-h6-r-ccu
@@ -99,6 +102,7 @@ else:
    properties:
      compatible:
        enum:
          - allwinner,sun20i-d1-ccu
          - allwinner,sun50i-a100-ccu
          - allwinner,sun50i-h6-ccu
          - allwinner,sun50i-h616-ccu
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ obj-$(CONFIG_PLAT_SPEAR) += spear/
obj-y					+= sprd/
obj-$(CONFIG_ARCH_STI)			+= st/
obj-$(CONFIG_ARCH_SUNXI)		+= sunxi/
obj-$(CONFIG_SUNXI_CCU)			+= sunxi-ng/
obj-y					+= sunxi-ng/
obj-$(CONFIG_ARCH_TEGRA)		+= tegra/
obj-y					+= ti/
obj-$(CONFIG_CLK_UNIPHIER)		+= uniphier/
+30 −19
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
config SUNXI_CCU
	bool "Clock support for Allwinner SoCs"
	tristate "Clock support for Allwinner SoCs"
	depends on ARCH_SUNXI || COMPILE_TEST
	select RESET_CONTROLLER
	default ARCH_SUNXI
@@ -8,42 +8,52 @@ config SUNXI_CCU
if SUNXI_CCU

config SUNIV_F1C100S_CCU
	bool "Support for the Allwinner newer F1C100s CCU"
	tristate "Support for the Allwinner newer F1C100s CCU"
	default MACH_SUNIV
	depends on MACH_SUNIV || COMPILE_TEST

config SUN20I_D1_CCU
	tristate "Support for the Allwinner D1 CCU"
	default RISCV && ARCH_SUNXI
	depends on (RISCV && ARCH_SUNXI) || COMPILE_TEST

config SUN20I_D1_R_CCU
	tristate "Support for the Allwinner D1 PRCM CCU"
	default RISCV && ARCH_SUNXI
	depends on (RISCV && ARCH_SUNXI) || COMPILE_TEST

config SUN50I_A64_CCU
	bool "Support for the Allwinner A64 CCU"
	tristate "Support for the Allwinner A64 CCU"
	default ARM64 && ARCH_SUNXI
	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN50I_A100_CCU
	bool "Support for the Allwinner A100 CCU"
	tristate "Support for the Allwinner A100 CCU"
	default ARM64 && ARCH_SUNXI
	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN50I_A100_R_CCU
	bool "Support for the Allwinner A100 PRCM CCU"
	tristate "Support for the Allwinner A100 PRCM CCU"
	default ARM64 && ARCH_SUNXI
	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN50I_H6_CCU
	bool "Support for the Allwinner H6 CCU"
	tristate "Support for the Allwinner H6 CCU"
	default ARM64 && ARCH_SUNXI
	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN50I_H616_CCU
	bool "Support for the Allwinner H616 CCU"
	tristate "Support for the Allwinner H616 CCU"
	default ARM64 && ARCH_SUNXI
	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN50I_H6_R_CCU
	bool "Support for the Allwinner H6 and H616 PRCM CCU"
	tristate "Support for the Allwinner H6 and H616 PRCM CCU"
	default ARM64 && ARCH_SUNXI
	depends on (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN4I_A10_CCU
	bool "Support for the Allwinner A10/A20 CCU"
	tristate "Support for the Allwinner A10/A20 CCU"
	default MACH_SUN4I
	default MACH_SUN7I
	depends on MACH_SUN4I || MACH_SUN7I || COMPILE_TEST
@@ -52,53 +62,54 @@ config SUN5I_CCU
	bool "Support for the Allwinner sun5i family CCM"
	default MACH_SUN5I
	depends on MACH_SUN5I || COMPILE_TEST
	depends on SUNXI_CCU=y

config SUN6I_A31_CCU
	bool "Support for the Allwinner A31/A31s CCU"
	tristate "Support for the Allwinner A31/A31s CCU"
	default MACH_SUN6I
	depends on MACH_SUN6I || COMPILE_TEST

config SUN8I_A23_CCU
	bool "Support for the Allwinner A23 CCU"
	tristate "Support for the Allwinner A23 CCU"
	default MACH_SUN8I
	depends on MACH_SUN8I || COMPILE_TEST

config SUN8I_A33_CCU
	bool "Support for the Allwinner A33 CCU"
	tristate "Support for the Allwinner A33 CCU"
	default MACH_SUN8I
	depends on MACH_SUN8I || COMPILE_TEST

config SUN8I_A83T_CCU
	bool "Support for the Allwinner A83T CCU"
	tristate "Support for the Allwinner A83T CCU"
	default MACH_SUN8I
	depends on MACH_SUN8I || COMPILE_TEST

config SUN8I_H3_CCU
	bool "Support for the Allwinner H3 CCU"
	tristate "Support for the Allwinner H3 CCU"
	default MACH_SUN8I || (ARM64 && ARCH_SUNXI)
	depends on MACH_SUN8I || (ARM64 && ARCH_SUNXI) || COMPILE_TEST

config SUN8I_V3S_CCU
	bool "Support for the Allwinner V3s CCU"
	tristate "Support for the Allwinner V3s CCU"
	default MACH_SUN8I
	depends on MACH_SUN8I || COMPILE_TEST

config SUN8I_DE2_CCU
	bool "Support for the Allwinner SoCs DE2 CCU"
	tristate "Support for the Allwinner SoCs DE2 CCU"
	default MACH_SUN8I || (ARM64 && ARCH_SUNXI)

config SUN8I_R40_CCU
	bool "Support for the Allwinner R40 CCU"
	tristate "Support for the Allwinner R40 CCU"
	default MACH_SUN8I
	depends on MACH_SUN8I || COMPILE_TEST

config SUN9I_A80_CCU
	bool "Support for the Allwinner A80 CCU"
	tristate "Support for the Allwinner A80 CCU"
	default MACH_SUN9I
	depends on MACH_SUN9I || COMPILE_TEST

config SUN8I_R_CCU
	bool "Support for Allwinner SoCs' PRCM CCUs"
	tristate "Support for Allwinner SoCs' PRCM CCUs"
	default MACH_SUN8I || (ARCH_SUNXI && ARM64)

endif
+65 −36
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0

obj-$(CONFIG_SUNXI_CCU)		+= sunxi-ccu.o

# Common objects
obj-y				+= ccu_common.o
obj-y				+= ccu_mmc_timing.o
obj-y				+= ccu_reset.o
sunxi-ccu-y			+= ccu_common.o
sunxi-ccu-y			+= ccu_mmc_timing.o
sunxi-ccu-y			+= ccu_reset.o

# Base clock types
obj-y				+= ccu_div.o
obj-y				+= ccu_frac.o
obj-y				+= ccu_gate.o
obj-y				+= ccu_mux.o
obj-y				+= ccu_mult.o
obj-y				+= ccu_phase.o
obj-y				+= ccu_sdm.o
sunxi-ccu-y			+= ccu_div.o
sunxi-ccu-y			+= ccu_frac.o
sunxi-ccu-y			+= ccu_gate.o
sunxi-ccu-y			+= ccu_mux.o
sunxi-ccu-y			+= ccu_mult.o
sunxi-ccu-y			+= ccu_phase.o
sunxi-ccu-y			+= ccu_sdm.o

# Multi-factor clocks
obj-y				+= ccu_nk.o
obj-y				+= ccu_nkm.o
obj-y				+= ccu_nkmp.o
obj-y				+= ccu_nm.o
obj-y				+= ccu_mp.o
sunxi-ccu-y			+= ccu_nk.o
sunxi-ccu-y			+= ccu_nkm.o
sunxi-ccu-y			+= ccu_nkmp.o
sunxi-ccu-y			+= ccu_nm.o
sunxi-ccu-y			+= ccu_mp.o

# SoC support
obj-$(CONFIG_SUNIV_F1C100S_CCU)	+= ccu-suniv-f1c100s.o
obj-$(CONFIG_SUN50I_A64_CCU)	+= ccu-sun50i-a64.o
obj-$(CONFIG_SUN50I_A100_CCU)	+= ccu-sun50i-a100.o
obj-$(CONFIG_SUN50I_A100_R_CCU)	+= ccu-sun50i-a100-r.o
obj-$(CONFIG_SUN50I_H6_CCU)	+= ccu-sun50i-h6.o
obj-$(CONFIG_SUN50I_H616_CCU)	+= ccu-sun50i-h616.o
obj-$(CONFIG_SUN50I_H6_R_CCU)	+= ccu-sun50i-h6-r.o
obj-$(CONFIG_SUN4I_A10_CCU)	+= ccu-sun4i-a10.o
obj-$(CONFIG_SUN5I_CCU)		+= ccu-sun5i.o
obj-$(CONFIG_SUN6I_A31_CCU)	+= ccu-sun6i-a31.o
obj-$(CONFIG_SUN8I_A23_CCU)	+= ccu-sun8i-a23.o
obj-$(CONFIG_SUN8I_A33_CCU)	+= ccu-sun8i-a33.o
obj-$(CONFIG_SUN8I_A83T_CCU)	+= ccu-sun8i-a83t.o
obj-$(CONFIG_SUN8I_H3_CCU)	+= ccu-sun8i-h3.o
obj-$(CONFIG_SUN8I_V3S_CCU)	+= ccu-sun8i-v3s.o
obj-$(CONFIG_SUN8I_DE2_CCU)	+= ccu-sun8i-de2.o
obj-$(CONFIG_SUN8I_R_CCU)	+= ccu-sun8i-r.o
obj-$(CONFIG_SUN8I_R40_CCU)	+= ccu-sun8i-r40.o
obj-$(CONFIG_SUN9I_A80_CCU)	+= ccu-sun9i-a80.o
obj-$(CONFIG_SUN9I_A80_CCU)	+= ccu-sun9i-a80-de.o
obj-$(CONFIG_SUN9I_A80_CCU)	+= ccu-sun9i-a80-usb.o
obj-$(CONFIG_SUNIV_F1C100S_CCU)	+= suniv-f1c100s-ccu.o
obj-$(CONFIG_SUN20I_D1_CCU)	+= sun20i-d1-ccu.o
obj-$(CONFIG_SUN20I_D1_R_CCU)	+= sun20i-d1-r-ccu.o
obj-$(CONFIG_SUN50I_A64_CCU)	+= sun50i-a64-ccu.o
obj-$(CONFIG_SUN50I_A100_CCU)	+= sun50i-a100-ccu.o
obj-$(CONFIG_SUN50I_A100_R_CCU)	+= sun50i-a100-r-ccu.o
obj-$(CONFIG_SUN50I_H6_CCU)	+= sun50i-h6-ccu.o
obj-$(CONFIG_SUN50I_H6_R_CCU)	+= sun50i-h6-r-ccu.o
obj-$(CONFIG_SUN50I_H616_CCU)	+= sun50i-h616-ccu.o
obj-$(CONFIG_SUN4I_A10_CCU)	+= sun4i-a10-ccu.o
obj-$(CONFIG_SUN5I_CCU)		+= sun5i-ccu.o
obj-$(CONFIG_SUN6I_A31_CCU)	+= sun6i-a31-ccu.o
obj-$(CONFIG_SUN8I_A23_CCU)	+= sun8i-a23-ccu.o
obj-$(CONFIG_SUN8I_A33_CCU)	+= sun8i-a33-ccu.o
obj-$(CONFIG_SUN8I_A83T_CCU)	+= sun8i-a83t-ccu.o
obj-$(CONFIG_SUN8I_H3_CCU)	+= sun8i-h3-ccu.o
obj-$(CONFIG_SUN8I_R40_CCU)	+= sun8i-r40-ccu.o
obj-$(CONFIG_SUN8I_V3S_CCU)	+= sun8i-v3s-ccu.o
obj-$(CONFIG_SUN8I_DE2_CCU)	+= sun8i-de2-ccu.o
obj-$(CONFIG_SUN8I_R_CCU)	+= sun8i-r-ccu.o
obj-$(CONFIG_SUN9I_A80_CCU)	+= sun9i-a80-ccu.o
obj-$(CONFIG_SUN9I_A80_CCU)	+= sun9i-a80-de-ccu.o
obj-$(CONFIG_SUN9I_A80_CCU)	+= sun9i-a80-usb-ccu.o

suniv-f1c100s-ccu-y		+= ccu-suniv-f1c100s.o
sun20i-d1-ccu-y			+= ccu-sun20i-d1.o
sun20i-d1-r-ccu-y		+= ccu-sun20i-d1-r.o
sun50i-a64-ccu-y		+= ccu-sun50i-a64.o
sun50i-a100-ccu-y		+= ccu-sun50i-a100.o
sun50i-a100-r-ccu-y		+= ccu-sun50i-a100-r.o
sun50i-h6-ccu-y			+= ccu-sun50i-h6.o
sun50i-h6-r-ccu-y		+= ccu-sun50i-h6-r.o
sun50i-h616-ccu-y		+= ccu-sun50i-h616.o
sun4i-a10-ccu-y			+= ccu-sun4i-a10.o
sun5i-ccu-y			+= ccu-sun5i.o
sun6i-a31-ccu-y			+= ccu-sun6i-a31.o
sun8i-a23-ccu-y			+= ccu-sun8i-a23.o
sun8i-a33-ccu-y			+= ccu-sun8i-a33.o
sun8i-a83t-ccu-y		+= ccu-sun8i-a83t.o
sun8i-h3-ccu-y			+= ccu-sun8i-h3.o
sun8i-r40-ccu-y			+= ccu-sun8i-r40.o
sun8i-v3s-ccu-y			+= ccu-sun8i-v3s.o
sun8i-de2-ccu-y			+= ccu-sun8i-de2.o
sun8i-r-ccu-y			+= ccu-sun8i-r.o
sun9i-a80-ccu-y			+= ccu-sun9i-a80.o
sun9i-a80-de-ccu-y		+= ccu-sun9i-a80-de.o
sun9i-a80-usb-ccu-y		+= ccu-sun9i-a80-usb.o
+140 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2020 huangzhenwei@allwinnertech.com
 * Copyright (C) 2021 Samuel Holland <samuel@sholland.org>
 */

#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/platform_device.h>

#include "ccu_common.h"
#include "ccu_reset.h"

#include "ccu_gate.h"
#include "ccu_mp.h"

#include "ccu-sun20i-d1-r.h"

static const struct clk_parent_data r_ahb_apb0_parents[] = {
	{ .fw_name = "hosc" },
	{ .fw_name = "losc" },
	{ .fw_name = "iosc" },
	{ .fw_name = "pll-periph" },
};
static SUNXI_CCU_MP_DATA_WITH_MUX(r_ahb_clk, "r-ahb",
				  r_ahb_apb0_parents, 0x000,
				  0, 5,		/* M */
				  8, 2,		/* P */
				  24, 3,	/* mux */
				  0);
static const struct clk_hw *r_ahb_hw = &r_ahb_clk.common.hw;

static SUNXI_CCU_MP_DATA_WITH_MUX(r_apb0_clk, "r-apb0",
				  r_ahb_apb0_parents, 0x00c,
				  0, 5,		/* M */
				  8, 2,		/* P */
				  24, 3,	/* mux */
				  0);
static const struct clk_hw *r_apb0_hw = &r_apb0_clk.common.hw;

static SUNXI_CCU_GATE_HWS(bus_r_timer_clk,	"bus-r-timer",	&r_apb0_hw,
			  0x11c, BIT(0), 0);
static SUNXI_CCU_GATE_HWS(bus_r_twd_clk,	"bus-r-twd",	&r_apb0_hw,
			  0x12c, BIT(0), 0);
static SUNXI_CCU_GATE_HWS(bus_r_ppu_clk,	"bus-r-ppu",	&r_apb0_hw,
			  0x1ac, BIT(0), 0);

static const struct clk_parent_data r_ir_rx_parents[] = {
	{ .fw_name = "losc" },
	{ .fw_name = "hosc" },
};
static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(r_ir_rx_clk, "r-ir-rx",
				       r_ir_rx_parents, 0x1c0,
				       0, 5,	/* M */
				       8, 2,	/* P */
				       24, 2,	/* mux */
				       BIT(31),	/* gate */
				       0);

static SUNXI_CCU_GATE_HWS(bus_r_ir_rx_clk,	"bus-r-ir-rx",	&r_apb0_hw,
			  0x1cc, BIT(0), 0);
static SUNXI_CCU_GATE_HWS(bus_r_rtc_clk,	"bus-r-rtc",	&r_ahb_hw,
			  0x20c, BIT(0), 0);
static SUNXI_CCU_GATE_HWS(bus_r_cpucfg_clk,	"bus-r-cpucfg",	&r_apb0_hw,
			  0x22c, BIT(0), 0);

static struct ccu_common *sun20i_d1_r_ccu_clks[] = {
	&r_ahb_clk.common,
	&r_apb0_clk.common,
	&bus_r_timer_clk.common,
	&bus_r_twd_clk.common,
	&bus_r_ppu_clk.common,
	&r_ir_rx_clk.common,
	&bus_r_ir_rx_clk.common,
	&bus_r_rtc_clk.common,
	&bus_r_cpucfg_clk.common,
};

static struct clk_hw_onecell_data sun20i_d1_r_hw_clks = {
	.num	= CLK_NUMBER,
	.hws	= {
		[CLK_R_AHB]		= &r_ahb_clk.common.hw,
		[CLK_R_APB0]		= &r_apb0_clk.common.hw,
		[CLK_BUS_R_TIMER]	= &bus_r_timer_clk.common.hw,
		[CLK_BUS_R_TWD]		= &bus_r_twd_clk.common.hw,
		[CLK_BUS_R_PPU]		= &bus_r_ppu_clk.common.hw,
		[CLK_R_IR_RX]		= &r_ir_rx_clk.common.hw,
		[CLK_BUS_R_IR_RX]	= &bus_r_ir_rx_clk.common.hw,
		[CLK_BUS_R_RTC]		= &bus_r_rtc_clk.common.hw,
		[CLK_BUS_R_CPUCFG]	= &bus_r_cpucfg_clk.common.hw,
	},
};

static struct ccu_reset_map sun20i_d1_r_ccu_resets[] = {
	[RST_BUS_R_TIMER]	= { 0x11c, BIT(16) },
	[RST_BUS_R_TWD]		= { 0x12c, BIT(16) },
	[RST_BUS_R_PPU]		= { 0x1ac, BIT(16) },
	[RST_BUS_R_IR_RX]	= { 0x1cc, BIT(16) },
	[RST_BUS_R_RTC]		= { 0x20c, BIT(16) },
	[RST_BUS_R_CPUCFG]	= { 0x22c, BIT(16) },
};

static const struct sunxi_ccu_desc sun20i_d1_r_ccu_desc = {
	.ccu_clks	= sun20i_d1_r_ccu_clks,
	.num_ccu_clks	= ARRAY_SIZE(sun20i_d1_r_ccu_clks),

	.hw_clks	= &sun20i_d1_r_hw_clks,

	.resets		= sun20i_d1_r_ccu_resets,
	.num_resets	= ARRAY_SIZE(sun20i_d1_r_ccu_resets),
};

static int sun20i_d1_r_ccu_probe(struct platform_device *pdev)
{
	void __iomem *reg;

	reg = devm_platform_ioremap_resource(pdev, 0);
	if (IS_ERR(reg))
		return PTR_ERR(reg);

	return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun20i_d1_r_ccu_desc);
}

static const struct of_device_id sun20i_d1_r_ccu_ids[] = {
	{ .compatible = "allwinner,sun20i-d1-r-ccu" },
	{ }
};

static struct platform_driver sun20i_d1_r_ccu_driver = {
	.probe	= sun20i_d1_r_ccu_probe,
	.driver	= {
		.name			= "sun20i-d1-r-ccu",
		.suppress_bind_attrs	= true,
		.of_match_table		= sun20i_d1_r_ccu_ids,
	},
};
module_platform_driver(sun20i_d1_r_ccu_driver);

MODULE_IMPORT_NS(SUNXI_CCU);
MODULE_LICENSE("GPL");
Loading