2020-07-06 08:37:54 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Clock drivers for Qualcomm IPQ40xx
|
|
|
|
*
|
2020-10-08 20:05:10 +00:00
|
|
|
* Copyright (c) 2020 Sartura Ltd.
|
2020-07-06 08:37:54 +00:00
|
|
|
*
|
|
|
|
* Author: Robert Marko <robert.marko@sartura.hr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <clk-uclass.h>
|
2020-10-28 12:56:23 +00:00
|
|
|
#include <common.h>
|
2020-07-06 08:37:54 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2020-09-10 14:00:00 +00:00
|
|
|
#include <dt-bindings/clock/qcom,ipq4019-gcc.h>
|
|
|
|
|
2020-07-06 08:37:54 +00:00
|
|
|
struct msm_clk_priv {
|
|
|
|
phys_addr_t base;
|
|
|
|
};
|
|
|
|
|
|
|
|
ulong msm_set_rate(struct clk *clk, ulong rate)
|
|
|
|
{
|
|
|
|
switch (clk->id) {
|
2020-09-10 14:00:00 +00:00
|
|
|
case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/
|
2020-07-06 08:37:54 +00:00
|
|
|
/* This clock is already initialized by SBL1 */
|
2020-10-08 20:05:10 +00:00
|
|
|
return 0;
|
2020-07-06 08:37:54 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int msm_clk_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct msm_clk_priv *priv = dev_get_priv(dev);
|
|
|
|
|
2020-10-28 12:56:23 +00:00
|
|
|
priv->base = dev_read_addr(dev);
|
2020-07-06 08:37:54 +00:00
|
|
|
if (priv->base == FDT_ADDR_T_NONE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ulong msm_clk_set_rate(struct clk *clk, ulong rate)
|
|
|
|
{
|
|
|
|
return msm_set_rate(clk, rate);
|
|
|
|
}
|
|
|
|
|
2020-10-08 20:05:10 +00:00
|
|
|
static int msm_enable(struct clk *clk)
|
|
|
|
{
|
|
|
|
switch (clk->id) {
|
|
|
|
case GCC_BLSP1_QUP1_SPI_APPS_CLK: /*SPI1*/
|
|
|
|
/* This clock is already initialized by SBL1 */
|
|
|
|
return 0;
|
2020-10-08 20:05:14 +00:00
|
|
|
case GCC_PRNG_AHB_CLK: /*PRNG*/
|
|
|
|
/* This clock is already initialized by SBL1 */
|
|
|
|
return 0;
|
2020-10-08 20:05:10 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-06 08:37:54 +00:00
|
|
|
static struct clk_ops msm_clk_ops = {
|
|
|
|
.set_rate = msm_clk_set_rate,
|
2020-10-08 20:05:10 +00:00
|
|
|
.enable = msm_enable,
|
2020-07-06 08:37:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct udevice_id msm_clk_ids[] = {
|
|
|
|
{ .compatible = "qcom,gcc-ipq4019" },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(clk_msm) = {
|
|
|
|
.name = "clk_msm",
|
|
|
|
.id = UCLASS_CLK,
|
|
|
|
.of_match = msm_clk_ids,
|
|
|
|
.ops = &msm_clk_ops,
|
|
|
|
.priv_auto_alloc_size = sizeof(struct msm_clk_priv),
|
|
|
|
.probe = msm_clk_probe,
|
|
|
|
};
|