Dario Binacchi | d284157 | 2020-12-30 00:06:35 +0100 | [diff] [blame] | 1 | // 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 Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <fdtdec.h> |
Dario Binacchi | d284157 | 2020-12-30 00:06:35 +0100 | [diff] [blame] | 10 | #include <asm/io.h> |
| 11 | #include "clk.h" |
| 12 | |
| 13 | static 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 | |
| 23 | void 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 | } |