1*3504395fSJisheng Zhang /* SPDX-License-Identifier: GPL-2.0 */ 26f9ba9b4SAlexandre Belloni /* 36f9ba9b4SAlexandre Belloni * Copyright (c) 2014 Marvell Technology Group Ltd. 46f9ba9b4SAlexandre Belloni * 56f9ba9b4SAlexandre Belloni * Alexandre Belloni <alexandre.belloni@free-electrons.com> 66f9ba9b4SAlexandre Belloni * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> 76f9ba9b4SAlexandre Belloni */ 86f9ba9b4SAlexandre Belloni #ifndef __BERLIN2_DIV_H 96f9ba9b4SAlexandre Belloni #define __BERLIN2_DIV_H 106f9ba9b4SAlexandre Belloni 11f6475e29SStephen Boyd struct clk_hw; 126f9ba9b4SAlexandre Belloni 136f9ba9b4SAlexandre Belloni #define BERLIN2_DIV_HAS_GATE BIT(0) 146f9ba9b4SAlexandre Belloni #define BERLIN2_DIV_HAS_MUX BIT(1) 156f9ba9b4SAlexandre Belloni 166f9ba9b4SAlexandre Belloni #define BERLIN2_PLL_SELECT(_off, _sh) \ 176f9ba9b4SAlexandre Belloni .pll_select_offs = _off, \ 186f9ba9b4SAlexandre Belloni .pll_select_shift = _sh 196f9ba9b4SAlexandre Belloni 206f9ba9b4SAlexandre Belloni #define BERLIN2_PLL_SWITCH(_off, _sh) \ 216f9ba9b4SAlexandre Belloni .pll_switch_offs = _off, \ 226f9ba9b4SAlexandre Belloni .pll_switch_shift = _sh 236f9ba9b4SAlexandre Belloni 246f9ba9b4SAlexandre Belloni #define BERLIN2_DIV_SELECT(_off, _sh) \ 256f9ba9b4SAlexandre Belloni .div_select_offs = _off, \ 266f9ba9b4SAlexandre Belloni .div_select_shift = _sh 276f9ba9b4SAlexandre Belloni 286f9ba9b4SAlexandre Belloni #define BERLIN2_DIV_SWITCH(_off, _sh) \ 296f9ba9b4SAlexandre Belloni .div_switch_offs = _off, \ 306f9ba9b4SAlexandre Belloni .div_switch_shift = _sh 316f9ba9b4SAlexandre Belloni 326f9ba9b4SAlexandre Belloni #define BERLIN2_DIV_D3SWITCH(_off, _sh) \ 336f9ba9b4SAlexandre Belloni .div3_switch_offs = _off, \ 346f9ba9b4SAlexandre Belloni .div3_switch_shift = _sh 356f9ba9b4SAlexandre Belloni 366f9ba9b4SAlexandre Belloni #define BERLIN2_DIV_GATE(_off, _sh) \ 376f9ba9b4SAlexandre Belloni .gate_offs = _off, \ 386f9ba9b4SAlexandre Belloni .gate_shift = _sh 396f9ba9b4SAlexandre Belloni 406f9ba9b4SAlexandre Belloni #define BERLIN2_SINGLE_DIV(_off) \ 416f9ba9b4SAlexandre Belloni BERLIN2_DIV_GATE(_off, 0), \ 426f9ba9b4SAlexandre Belloni BERLIN2_PLL_SELECT(_off, 1), \ 436f9ba9b4SAlexandre Belloni BERLIN2_PLL_SWITCH(_off, 4), \ 446f9ba9b4SAlexandre Belloni BERLIN2_DIV_SWITCH(_off, 5), \ 456f9ba9b4SAlexandre Belloni BERLIN2_DIV_D3SWITCH(_off, 6), \ 466f9ba9b4SAlexandre Belloni BERLIN2_DIV_SELECT(_off, 7) 476f9ba9b4SAlexandre Belloni 486f9ba9b4SAlexandre Belloni struct berlin2_div_map { 496f9ba9b4SAlexandre Belloni u16 pll_select_offs; 506f9ba9b4SAlexandre Belloni u16 pll_switch_offs; 516f9ba9b4SAlexandre Belloni u16 div_select_offs; 526f9ba9b4SAlexandre Belloni u16 div_switch_offs; 536f9ba9b4SAlexandre Belloni u16 div3_switch_offs; 546f9ba9b4SAlexandre Belloni u16 gate_offs; 556f9ba9b4SAlexandre Belloni u8 pll_select_shift; 566f9ba9b4SAlexandre Belloni u8 pll_switch_shift; 576f9ba9b4SAlexandre Belloni u8 div_select_shift; 586f9ba9b4SAlexandre Belloni u8 div_switch_shift; 596f9ba9b4SAlexandre Belloni u8 div3_switch_shift; 606f9ba9b4SAlexandre Belloni u8 gate_shift; 616f9ba9b4SAlexandre Belloni }; 626f9ba9b4SAlexandre Belloni 636f9ba9b4SAlexandre Belloni struct berlin2_div_data { 646f9ba9b4SAlexandre Belloni const char *name; 656f9ba9b4SAlexandre Belloni const u8 *parent_ids; 666f9ba9b4SAlexandre Belloni int num_parents; 676f9ba9b4SAlexandre Belloni unsigned long flags; 686f9ba9b4SAlexandre Belloni struct berlin2_div_map map; 696f9ba9b4SAlexandre Belloni u8 div_flags; 706f9ba9b4SAlexandre Belloni }; 716f9ba9b4SAlexandre Belloni 72f6475e29SStephen Boyd struct clk_hw * 736f9ba9b4SAlexandre Belloni berlin2_div_register(const struct berlin2_div_map *map, 746f9ba9b4SAlexandre Belloni void __iomem *base, const char *name, u8 div_flags, 756f9ba9b4SAlexandre Belloni const char **parent_names, int num_parents, 766f9ba9b4SAlexandre Belloni unsigned long flags, spinlock_t *lock); 776f9ba9b4SAlexandre Belloni 786f9ba9b4SAlexandre Belloni #endif /* __BERLIN2_DIV_H */ 79