1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Atmel Corporation
4 * Wenyou.Yang <wenyou.yang@atmel.com>
11 * pmc_read() - read content at address base + off into val
14 * @off: offset to read from
15 * @val: where the content of base + off is stored
19 void pmc_read(void __iomem *base, unsigned int off, unsigned int *val)
21 *val = readl(base + off);
25 * pmc_write() - write content of val at address base + off
28 * @off: offset to write to
29 * @val: content to be written at base + off
33 void pmc_write(void __iomem *base, unsigned int off, unsigned int val)
35 writel(val, base + off);
39 * pmc_update_bits() - update a set of bits at address base + off
42 * @off: offset to be updated
43 * @mask: mask of bits to be updated
44 * @bits: the new value to be updated
48 void pmc_update_bits(void __iomem *base, unsigned int off,
49 unsigned int mask, unsigned int bits)
53 tmp = readl(base + off);
55 writel(tmp | (bits & mask), base + off);
59 * at91_clk_mux_val_to_index() - get parent index in mux table
61 * @table: clock mux table
62 * @num_parents: clock number of parents
63 * @val: clock id who's mux index should be retrieved
65 * @return: clock index in mux table or a negative error number in case of
68 int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val)
72 if (!table || !num_parents)
75 for (i = 0; i < num_parents; i++) {
84 * at91_clk_mux_index_to_val() - get parent ID corresponding to an entry in
87 * @table: clock's mux table
88 * @num_parents: clock's number of parents
89 * @index: index in mux table which clock's ID should be retrieved
91 * @return: clock ID or a negative error number in case of failure
93 int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index)
95 if (!table || !num_parents || index < 0 || index > num_parents)