blob: c999df213a819c22637fe9b0b817c6f366648896 [file] [log] [blame]
Dario Binacchid2841572020-12-30 00:06:35 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * TI clock utilities
4 *
5 * Copyright (C) 2020 Dario Binacchi <dariobin@libero.it>
6 */
7
8#include <common.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <fdtdec.h>
Dario Binacchid2841572020-12-30 00:06:35 +010010#include <asm/io.h>
11#include "clk.h"
12
13static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg)
14{
15 u32 v;
16
17 v = readl(reg);
18 v &= ~mask;
19 v |= val;
20 writel(v, reg);
21}
22
23void clk_ti_latch(fdt_addr_t reg, s8 shift)
24{
25 u32 latch;
26
27 if (shift < 0)
28 return;
29
30 latch = 1 << shift;
31
32 clk_ti_rmw(latch, latch, reg);
33 clk_ti_rmw(0, latch, reg);
34 readl(reg); /* OCP barrier */
35}