u-boot-brain/drivers/clk/ti/clk.c
Dario Binacchi ea45b8f28d clk: ti: add divider clock driver
The patch adds support for TI divider clock binding. The driver uses
routines provided by the common clock framework (ccf).

The code is based on the drivers/clk/ti/divider.c driver of the Linux
kernel version 5.9-rc7.
For DT binding details see:
- Documentation/devicetree/bindings/clock/ti/divider.txt

Signed-off-by: Dario Binacchi <dariobin@libero.it>
2021-01-12 10:58:04 +05:30

35 lines
518 B
C

// SPDX-License-Identifier: GPL-2.0+
/*
* TI clock utilities
*
* Copyright (C) 2020 Dario Binacchi <dariobin@libero.it>
*/
#include <common.h>
#include <asm/io.h>
#include "clk.h"
static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg)
{
u32 v;
v = readl(reg);
v &= ~mask;
v |= val;
writel(v, reg);
}
void clk_ti_latch(fdt_addr_t reg, s8 shift)
{
u32 latch;
if (shift < 0)
return;
latch = 1 << shift;
clk_ti_rmw(latch, latch, reg);
clk_ti_rmw(0, latch, reg);
readl(reg); /* OCP barrier */
}