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> |
| 9 | #include <asm/io.h> |
| 10 | #include "clk.h" |
| 11 | |
| 12 | static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg) |
| 13 | { |
| 14 | u32 v; |
| 15 | |
| 16 | v = readl(reg); |
| 17 | v &= ~mask; |
| 18 | v |= val; |
| 19 | writel(v, reg); |
| 20 | } |
| 21 | |
| 22 | void clk_ti_latch(fdt_addr_t reg, s8 shift) |
| 23 | { |
| 24 | u32 latch; |
| 25 | |
| 26 | if (shift < 0) |
| 27 | return; |
| 28 | |
| 29 | latch = 1 << shift; |
| 30 | |
| 31 | clk_ti_rmw(latch, latch, reg); |
| 32 | clk_ti_rmw(0, latch, reg); |
| 33 | readl(reg); /* OCP barrier */ |
| 34 | } |