blob: 77ebae180998575b9718cc9844d43ff7935605ac [file] [log] [blame]
Masahiro Yamadae4dfb052016-02-02 21:11:32 +09001/*
Masahiro Yamadafa1f73f2016-07-19 21:56:13 +09002 * Copyright (C) 2016 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamadae4dfb052016-02-02 21:11:32 +09004 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef __CLK_UNIPHIER_H__
9#define __CLK_UNIPHIER_H__
10
11#include <linux/kernel.h>
Masahiro Yamada49806682017-10-13 19:21:59 +090012#include <linux/types.h>
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090013
Masahiro Yamada49806682017-10-13 19:21:59 +090014#define UNIPHIER_CLK_MUX_MAX_PARENTS 8
15
16#define UNIPHIER_CLK_TYPE_END 0
17#define UNIPHIER_CLK_TYPE_FIXED_RATE 2
18#define UNIPHIER_CLK_TYPE_GATE 3
19#define UNIPHIER_CLK_TYPE_MUX 4
20
21#define UNIPHIER_CLK_ID_INVALID (U8_MAX)
22
23struct uniphier_clk_fixed_rate_data {
24 unsigned long fixed_rate;
25};
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090026
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090027struct uniphier_clk_gate_data {
Masahiro Yamada49806682017-10-13 19:21:59 +090028 u8 parent_id;
29 u16 reg;
30 u8 bit;
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090031};
32
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090033struct uniphier_clk_mux_data {
Masahiro Yamada49806682017-10-13 19:21:59 +090034 u8 parent_ids[UNIPHIER_CLK_MUX_MAX_PARENTS];
35 u8 num_parents;
36 u16 reg;
37 u32 masks[UNIPHIER_CLK_MUX_MAX_PARENTS];
38 u32 vals[UNIPHIER_CLK_MUX_MAX_PARENTS];
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090039};
40
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090041struct uniphier_clk_data {
Masahiro Yamada49806682017-10-13 19:21:59 +090042 u8 type;
43 u8 id;
44 union {
45 struct uniphier_clk_fixed_rate_data rate;
46 struct uniphier_clk_gate_data gate;
47 struct uniphier_clk_mux_data mux;
48 } data;
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090049};
50
Masahiro Yamada49806682017-10-13 19:21:59 +090051#define UNIPHIER_CLK_RATE(_id, _rate) \
52 { \
53 .type = UNIPHIER_CLK_TYPE_FIXED_RATE, \
54 .id = (_id), \
55 .data.rate = { \
56 .fixed_rate = (_rate), \
57 }, \
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090058 }
59
Masahiro Yamada49806682017-10-13 19:21:59 +090060#define UNIPHIER_CLK_GATE(_id, _parent, _reg, _bit) \
61 { \
62 .type = UNIPHIER_CLK_TYPE_GATE, \
63 .id = (_id), \
64 .data.gate = { \
65 .parent_id = (_parent), \
66 .reg = (_reg), \
67 .bit = (_bit), \
68 }, \
Masahiro Yamada8bdfe0a2016-10-17 22:18:01 +090069 }
70
Masahiro Yamada49806682017-10-13 19:21:59 +090071#define UNIPHIER_CLK_GATE_SIMPLE(_id, _reg, _bit) \
72 UNIPHIER_CLK_GATE(_id, UNIPHIER_CLK_ID_INVALID, _reg, _bit)
73
74extern const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[];
75extern const struct uniphier_clk_data uniphier_ld20_sys_clk_data[];
Masahiro Yamada52cdec02017-10-13 19:22:00 +090076extern const struct uniphier_clk_data uniphier_pxs3_sys_clk_data[];
Masahiro Yamada49806682017-10-13 19:21:59 +090077extern const struct uniphier_clk_data uniphier_mio_clk_data[];
Masahiro Yamadae4dfb052016-02-02 21:11:32 +090078
79#endif /* __CLK_UNIPHIER_H__ */