summaryrefslogtreecommitdiffstats
path: root/drivers/clk/ti/clk.c
blob: e44b90ad6abed5ca3a86d418e241cafbf84622d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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 */
}