blob: 1b595df7933e2a977ecdafffe06cbaba65df2381 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Masahiro Yamadae4dfb052016-02-02 21:11:32 +09002/*
Masahiro Yamadafa1f73f2016-07-19 21:56:13 +09003 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamadae4dfb052016-02-02 21:11:32 +09005 */
6
7#ifndef __CLK_UNIPHIER_H__
8#define __CLK_UNIPHIER_H__
9
10#include <linux/kernel.h>
Masahiro Yamada49806682017-10-13 19:21:59 +090011#include <linux/types.h>
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090012
Masahiro Yamada49806682017-10-13 19:21:59 +090013#define UNIPHIER_CLK_MUX_MAX_PARENTS 8
14
15#define UNIPHIER_CLK_TYPE_END 0
16#define UNIPHIER_CLK_TYPE_FIXED_RATE 2
17#define UNIPHIER_CLK_TYPE_GATE 3
18#define UNIPHIER_CLK_TYPE_MUX 4
19
20#define UNIPHIER_CLK_ID_INVALID (U8_MAX)
21
22struct uniphier_clk_fixed_rate_data {
23 unsigned long fixed_rate;
24};
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090025
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090026struct uniphier_clk_gate_data {
Masahiro Yamada49806682017-10-13 19:21:59 +090027 u8 parent_id;
28 u16 reg;
29 u8 bit;
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090030};
31
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090032struct uniphier_clk_mux_data {
Masahiro Yamada49806682017-10-13 19:21:59 +090033 u8 parent_ids[UNIPHIER_CLK_MUX_MAX_PARENTS];
34 u8 num_parents;
35 u16 reg;
36 u32 masks[UNIPHIER_CLK_MUX_MAX_PARENTS];
37 u32 vals[UNIPHIER_CLK_MUX_MAX_PARENTS];
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090038};
39
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090040struct uniphier_clk_data {
Masahiro Yamada49806682017-10-13 19:21:59 +090041 u8 type;
42 u8 id;
43 union {
44 struct uniphier_clk_fixed_rate_data rate;
45 struct uniphier_clk_gate_data gate;
46 struct uniphier_clk_mux_data mux;
47 } data;
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090048};
49
Masahiro Yamada49806682017-10-13 19:21:59 +090050#define UNIPHIER_CLK_RATE(_id, _rate) \
51 { \
52 .type = UNIPHIER_CLK_TYPE_FIXED_RATE, \
53 .id = (_id), \
54 .data.rate = { \
55 .fixed_rate = (_rate), \
56 }, \
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090057 }
58
Masahiro Yamada49806682017-10-13 19:21:59 +090059#define UNIPHIER_CLK_GATE(_id, _parent, _reg, _bit) \
60 { \
61 .type = UNIPHIER_CLK_TYPE_GATE, \
62 .id = (_id), \
63 .data.gate = { \
64 .parent_id = (_parent), \
65 .reg = (_reg), \
66 .bit = (_bit), \
67 }, \
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090068 }
69
Masahiro Yamada49806682017-10-13 19:21:59 +090070#define UNIPHIER_CLK_GATE_SIMPLE(_id, _reg, _bit) \
71 UNIPHIER_CLK_GATE(_id, UNIPHIER_CLK_ID_INVALID, _reg, _bit)
72
73extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[];
74extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[];
Masahiro Yamada52cdec02017-10-13 19:22:00 +090075extern const struct uniphier_clk_data uniphier_pxs3_sys_clk_data[];
Masahiro Yamada49806682017-10-13 19:21:59 +090076extern const struct uniphier_clk_data uniphier_mio_clk_data[];
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090077
78#endif /* __CLK_UNIPHIER_H__ */