blob: 06b60dc8b8d6d844c52113fd15bb3a408bc4ad55 [file] [log] [blame]
Jim Liu25688562022-04-19 13:32:20 +08001/* SPDX-License-Identifier: GPL-2.0+ */
2
3#ifndef _CLK_NPCM_H_
4#define _CLK_NPCM_H_
5
6#include <clk-uclass.h>
7
8/* Register offsets */
9#define CLKSEL 0x04 /* clock source selection */
10#define CLKDIV1 0x08 /* clock divider 1 */
11#define CLKDIV2 0x2C /* clock divider 2 */
12#define CLKDIV3 0x58 /* clock divider 3 */
13#define PLLCON0 0x0C /* pll0 control */
14#define PLLCON1 0x10 /* pll1 control */
15#define PLLCON2 0x54 /* pll2 control */
16
17/* CLKSEL bit filed */
18#define NPCM7XX_CPUCKSEL GENMASK(1, 0)
19#define NPCM8XX_CPUCKSEL GENMASK(2, 0)
20#define SDCKSEL GENMASK(7, 6)
21#define UARTCKSEL GENMASK(9, 8)
22#define TIMCKSEL GENMASK(15, 14)
23
24/* CLKDIV1 bit filed */
25#define SPI3CKDIV GENMASK(10, 6)
26#define MMCCKDIV GENMASK(15, 11)
27#define UARTDIV1 GENMASK(20, 16)
28#define TIMCKDIV GENMASK(25, 21)
29#define CLK4DIV GENMASK(27, 26)
30
31/* CLKDIV2 bit filed */
32#define APB5CKDIV GENMASK(23, 22)
33#define APB2CKDIV GENMASK(27, 26)
34
35/* CLKDIV3 bit filed */
36#define SPIXCKDIV GENMASK(5, 1)
37#define SPI0CKDIV GENMASK(10, 6)
38#define UARTDIV2 GENMASK(15, 11)
39#define SPI1CKDIV GENMASK(23, 16)
40
41/* PLLCON bit filed */
42#define PLLCON_INDV GENMASK(5, 0)
43#define PLLCON_OTDV1 GENMASK(10, 8)
44#define PLLCON_OTDV2 GENMASK(15, 13)
45#define PLLCON_FBDV GENMASK(27, 16)
46
47/* Flags */
48#define DIV_TYPE1 BIT(0) /* div = clkdiv + 1 */
49#define DIV_TYPE2 BIT(1) /* div = 1 << clkdiv */
50#define PRE_DIV2 BIT(2) /* Pre divisor = 2 */
51#define POST_DIV2 BIT(3) /* Post divisor = 2 */
52#define FIXED_PARENT BIT(4) /* clock source is fixed */
53
54/* Parameters of PLL configuration */
55struct npcm_clk_pll {
56 const int id;
57 const int parent_id;
58 u32 reg;
59 u32 flags;
60};
61
62/* Parent clock id to clksel mapping */
63struct parent_data {
64 int id;
65 int clksel;
66};
67
68/* Parameters of parent selection */
69struct npcm_clk_select {
70 const int id;
71 const struct parent_data *parents;
72 u32 reg;
73 u32 mask;
74 u8 num_parents;
75 u32 flags;
76};
77
78/* Parameters of clock divider */
79struct npcm_clk_div {
80 const int id;
81 u32 reg;
82 u32 mask;
83 u32 flags;
84};
85
86struct npcm_clk_data {
87 struct npcm_clk_pll *clk_plls;
88 int num_plls;
89 struct npcm_clk_select *clk_selectors;
90 int num_selectors;
91 struct npcm_clk_div *clk_dividers;
92 int num_dividers;
93 int refclk_id;
94 int pll0_id;
95};
96
97struct npcm_clk_priv {
98 void __iomem *base;
99 struct npcm_clk_data *clk_data;
100 int num_clks;
101};
102
103extern const struct clk_ops npcm_clk_ops;
104
105#endif