^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2014 Marvell Technology Group Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Alexandre Belloni <alexandre.belloni@free-electrons.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef __BERLIN2_DIV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define __BERLIN2_DIV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct clk_hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define BERLIN2_DIV_HAS_GATE BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define BERLIN2_DIV_HAS_MUX BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define BERLIN2_PLL_SELECT(_off, _sh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) .pll_select_offs = _off, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .pll_select_shift = _sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define BERLIN2_PLL_SWITCH(_off, _sh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) .pll_switch_offs = _off, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .pll_switch_shift = _sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define BERLIN2_DIV_SELECT(_off, _sh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .div_select_offs = _off, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) .div_select_shift = _sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define BERLIN2_DIV_SWITCH(_off, _sh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) .div_switch_offs = _off, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) .div_switch_shift = _sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define BERLIN2_DIV_D3SWITCH(_off, _sh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) .div3_switch_offs = _off, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) .div3_switch_shift = _sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define BERLIN2_DIV_GATE(_off, _sh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) .gate_offs = _off, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) .gate_shift = _sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define BERLIN2_SINGLE_DIV(_off) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) BERLIN2_DIV_GATE(_off, 0), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) BERLIN2_PLL_SELECT(_off, 1), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) BERLIN2_PLL_SWITCH(_off, 4), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) BERLIN2_DIV_SWITCH(_off, 5), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) BERLIN2_DIV_D3SWITCH(_off, 6), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) BERLIN2_DIV_SELECT(_off, 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct berlin2_div_map {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) u16 pll_select_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) u16 pll_switch_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) u16 div_select_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) u16 div_switch_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) u16 div3_switch_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u16 gate_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u8 pll_select_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u8 pll_switch_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u8 div_select_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u8 div_switch_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u8 div3_switch_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u8 gate_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct berlin2_div_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) const u8 *parent_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int num_parents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct berlin2_div_map map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u8 div_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct clk_hw *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) berlin2_div_register(const struct berlin2_div_map *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void __iomem *base, const char *name, u8 div_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) const char **parent_names, int num_parents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned long flags, spinlock_t *lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #endif /* __BERLIN2_DIV_H */