From: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RESEND PATCH v2 08/15] arm: socfpga: agilex: Add clock manager support
Date: Tue, 9 Jul 2019 22:15:31 +0200 [thread overview]
Message-ID: <27826f23-82c4-14f6-1bba-eefccba3f6ac@gmail.com> (raw)
In-Reply-To: <1562230572-24033-9-git-send-email-ley.foon.tan@intel.com>
Am 04.07.2019 um 10:56 schrieb Ley Foon Tan:
> Add clock manager support for Agilex.
>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
>
> ---
> v2:
> - Get clocks from clock DM.
Wait, can you explain this a bit more? If you get clocks from DM, why is
this arch-specific driver needed at all? Can't you just convert the
callers into calling into the right clock driver directly?
Regards,
Simon
> ---
> arch/arm/mach-socfpga/Makefile | 4 +
> arch/arm/mach-socfpga/clock_manager_agilex.c | 87 +++++++++++++++++++
> .../include/mach/clock_manager_agilex.h | 2 +
> 3 files changed, 93 insertions(+)
> create mode 100644 arch/arm/mach-socfpga/clock_manager_agilex.c
>
> diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile
> index 11370cf4c4..5bb36d07df 100644
> --- a/arch/arm/mach-socfpga/Makefile
> +++ b/arch/arm/mach-socfpga/Makefile
> @@ -40,6 +40,10 @@ obj-y += wrap_pinmux_config_s10.o
> obj-y += wrap_pll_config_s10.o
> endif
>
> +ifdef CONFIG_TARGET_SOCFPGA_AGILEX
> +obj-y += clock_manager_agilex.o
> +endif
> +
> ifdef CONFIG_SPL_BUILD
> ifdef CONFIG_TARGET_SOCFPGA_GEN5
> obj-y += spl_gen5.o
> diff --git a/arch/arm/mach-socfpga/clock_manager_agilex.c b/arch/arm/mach-socfpga/clock_manager_agilex.c
> new file mode 100644
> index 0000000000..5159415fbf
> --- /dev/null
> +++ b/arch/arm/mach-socfpga/clock_manager_agilex.c
> @@ -0,0 +1,87 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2019 Intel Corporation <www.intel.com>
> + *
> + */
> +
> +#include <clk.h>
> +#include <common.h>
> +#include <dm.h>
> +#include <asm/arch/clock_manager.h>
> +#include <asm/arch/system_manager.h>
> +#include <asm/io.h>
> +#include <dt-bindings/clock/stratix10-clock.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static const struct socfpga_system_manager *sysmgr_regs =
> + (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
> +
> +static ulong cm_get_rate_dm(u32 id)
> +{
> + struct udevice *dev;
> + struct clk clk;
> + ulong rate;
> + int ret;
> +
> + ret = uclass_get_device_by_driver(UCLASS_CLK,
> + DM_GET_DRIVER(socfpga_agilex_clk),
> + &dev);
> + if (ret)
> + return 0;
> +
> + clk.id = id;
> + ret = clk_request(dev, &clk);
> + if (ret < 0)
> + return 0;
> +
> + rate = clk_get_rate(&clk);
> +
> + clk_free(&clk);
> +
> + if ((rate == (unsigned long)-ENOSYS) ||
> + (rate == (unsigned long)-ENXIO) ||
> + (rate == (unsigned long)-EIO)) {
> + debug("%s id %u: clk_get_rate err: %ld\n",
> + __func__, id, rate);
> + return 0;
> + }
> +
> + return rate;
> +}
> +
> +static u32 cm_get_rate_dm_khz(u32 id)
> +{
> + return cm_get_rate_dm(id) / 1000;
> +}
> +
> +unsigned long cm_get_mpu_clk_hz(void)
> +{
> + return cm_get_rate_dm(STRATIX10_MPU_CLK);
> +}
> +
> +unsigned int cm_get_l4_sys_free_clk_hz(void)
> +{
> + return cm_get_rate_dm(STRATIX10_L4_SYS_FREE_CLK);
> +}
> +
> +u32 cm_get_qspi_controller_clk_hz(void)
> +{
> + return readl(&sysmgr_regs->boot_scratch_cold0);
> +}
> +
> +void cm_print_clock_quick_summary(void)
> +{
> + printf("MPU %10d kHz\n",
> + cm_get_rate_dm_khz(STRATIX10_MPU_CLK));
> + printf("L4 Main %8d kHz\n",
> + cm_get_rate_dm_khz(STRATIX10_L4_MAIN_CLK));
> + printf("L4 sys free %8d kHz\n",
> + cm_get_rate_dm_khz(STRATIX10_L4_SYS_FREE_CLK));
> + printf("L4 MP %8d kHz\n",
> + cm_get_rate_dm_khz(STRATIX10_L4_MP_CLK));
> + printf("L4 SP %8d kHz\n",
> + cm_get_rate_dm_khz(STRATIX10_L4_SP_CLK));
> + printf("SDMMC %8d kHz\n",
> + cm_get_rate_dm_khz(STRATIX10_SDMMC_CLK));
> +}
> diff --git a/arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h b/arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h
> index bf5e7c8775..c4d27bad72 100644
> --- a/arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h
> +++ b/arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h
> @@ -25,6 +25,8 @@ const unsigned int cm_get_osc_clk_hz(void);
> const unsigned int cm_get_intosc_clk_hz(void);
> const unsigned int cm_get_fpga_clk_hz(void);
>
> +unsigned long cm_get_mpu_clk_hz(void);
> +
> #define CLKMGR_EOSC1_HZ 25000000
> #define CLKMGR_INTOSC_HZ 400000000
> #define CLKMGR_FPGA_CLK_HZ 50000000
>
next prev parent reply other threads:[~2019-07-09 20:15 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-04 8:55 [U-Boot] [RESEND PATCH v2 00/15] Add Intel Agilex SoC support Ley Foon Tan
2019-07-04 8:55 ` [U-Boot] [RESEND PATCH v2 01/15] arm: socfpga: agilex: Add base address for Intel Agilex SoC Ley Foon Tan
2019-07-09 19:40 ` Simon Goldschmidt
2019-07-04 8:55 ` [U-Boot] [RESEND PATCH v2 02/15] arm: socfpga: Move firewall code to firewall file Ley Foon Tan
2019-07-09 19:41 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 03/15] arm: socfpga: Move Stratix10 and Agilex reset manager common code Ley Foon Tan
2019-07-09 19:56 ` Simon Goldschmidt
2019-07-10 22:48 ` Ley Foon Tan
2019-07-12 10:27 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 04/15] arm: socfpga: agilex: Add reset manager support Ley Foon Tan
2019-07-09 20:01 ` Simon Goldschmidt
2019-07-09 20:33 ` Marek Vasut
2019-07-09 20:43 ` Simon Goldschmidt
2019-07-09 21:06 ` Marek Vasut
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 05/15] arm: socfpga: Move Stratix10 and Agilex system manager common code Ley Foon Tan
2019-07-09 20:04 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 06/15] arm: socfpga: agilex: Add system manager support Ley Foon Tan
2019-07-09 20:08 ` Simon Goldschmidt
2019-07-10 22:56 ` Ley Foon Tan
2019-07-12 10:50 ` Simon Goldschmidt
2019-08-06 9:24 ` Ley Foon Tan
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 07/15] clk: agilex: Add clock driver for Agilex Ley Foon Tan
2019-07-09 20:13 ` Simon Goldschmidt
2019-07-10 23:03 ` Ley Foon Tan
2019-07-12 10:47 ` Simon Goldschmidt
2019-08-06 9:19 ` Ley Foon Tan
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 08/15] arm: socfpga: agilex: Add clock manager support Ley Foon Tan
2019-07-09 20:15 ` Simon Goldschmidt [this message]
2019-07-10 23:08 ` Ley Foon Tan
2019-07-12 10:30 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 09/15] arm: socfpga: agilex: Add CCU support for Agilex Ley Foon Tan
2019-07-09 20:19 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 10/15] ddr: altera: Restructure Stratix 10 SDRAM driver Ley Foon Tan
2019-07-09 20:35 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 11/15] ddr: altera: agilex: Add SDRAM driver for Agilex Ley Foon Tan
2019-07-09 20:37 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 12/15] board: intel: agilex: Add socdk board support for Intel Agilex SoC Ley Foon Tan
2019-07-09 20:38 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 13/15] arm: socfpga: agilex: Add SPL for " Ley Foon Tan
2019-07-09 20:39 ` Simon Goldschmidt
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 14/15] arm: dts: agilex: Add base dtsi and devkit dts Ley Foon Tan
2019-07-09 20:41 ` Simon Goldschmidt
2019-07-10 22:40 ` Ley Foon Tan
2019-07-04 8:56 ` [U-Boot] [RESEND PATCH v2 15/15] arm: socfpga: agilex: Enable Agilex SoC build Ley Foon Tan
2019-07-09 20:42 ` Simon Goldschmidt
2019-07-09 19:35 ` [U-Boot] [RESEND PATCH v2 00/15] Add Intel Agilex SoC support Simon Goldschmidt
2019-07-10 12:36 ` Tom Rini
2019-07-10 13:08 ` Simon Goldschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27826f23-82c4-14f6-1bba-eefccba3f6ac@gmail.com \
--to=simon.k.r.goldschmidt@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox