2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-11-21 21:38:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Soren Brinkmann <soren.brinkmann@xilinx.com>
|
|
|
|
* Copyright (C) 2013 Xilinx, Inc. All rights reserved.
|
|
|
|
*/
|
2017-01-17 15:27:30 +00:00
|
|
|
#include <clk.h>
|
2013-11-21 21:38:54 +00:00
|
|
|
#include <common.h>
|
2017-01-17 15:27:30 +00:00
|
|
|
#include <dm.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2013-11-21 21:38:54 +00:00
|
|
|
#include <asm/arch/clk.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2013-11-21 21:38:54 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/**
|
2017-01-17 15:27:30 +00:00
|
|
|
* set_cpu_clk_info() - Setup clock information
|
2013-11-21 21:38:54 +00:00
|
|
|
*
|
|
|
|
* This function is called from common code after relocation and sets up the
|
2017-01-17 15:27:30 +00:00
|
|
|
* clock information.
|
2013-11-21 21:38:54 +00:00
|
|
|
*/
|
|
|
|
int set_cpu_clk_info(void)
|
|
|
|
{
|
2017-01-17 15:27:30 +00:00
|
|
|
struct clk clk;
|
|
|
|
struct udevice *dev;
|
|
|
|
ulong rate;
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_driver(UCLASS_CLK,
|
2020-12-29 03:34:56 +00:00
|
|
|
DM_DRIVER_GET(zynq_clk), &dev);
|
2017-01-17 15:27:30 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
clk.id = i ? ddr3x_clk : cpu_6or4x_clk;
|
|
|
|
ret = clk_request(dev, &clk);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
rate = clk_get_rate(&clk) / 1000000;
|
2022-08-05 06:16:28 +00:00
|
|
|
if (i) {
|
2017-01-17 15:27:30 +00:00
|
|
|
gd->bd->bi_ddr_freq = rate;
|
2022-08-05 06:16:28 +00:00
|
|
|
} else {
|
2017-01-17 15:27:30 +00:00
|
|
|
gd->bd->bi_arm_freq = rate;
|
2022-08-05 06:16:28 +00:00
|
|
|
gd->cpu_clk = clk_get_rate(&clk);
|
|
|
|
}
|
2017-01-17 15:27:30 +00:00
|
|
|
|
|
|
|
clk_free(&clk);
|
|
|
|
}
|
2014-01-20 10:05:37 +00:00
|
|
|
gd->bd->bi_dsp_freq = 0;
|
|
|
|
|
2013-11-21 21:38:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|