summaryrefslogtreecommitdiffstats
path: root/drivers/clk/uniphier/clk-uniphier-mio.c
blob: a2b0e80a33948eb65bec6342f756d83205877622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#include <clk.h>
#include <dm/device.h>

#include "clk-uniphier.h"

#define UNIPHIER_MIO_CLK_GATE_SD(ch, idx)	\
	{					\
		.index = (idx),			\
		.reg = 0x20 + 0x200 * (ch),	\
		.mask = 0x00000100,		\
		.data = 0x00000100,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x110 + 0x200 * (ch),	\
		.mask = 0x00000001,		\
		.data = 0x00000001,		\
	}

#define UNIPHIER_MIO_CLK_RATE_SD(ch, idx)	\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00000000,		\
		.rate = 44444444,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00010000,		\
		.rate = 33333333,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00020000,		\
		.rate = 50000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00020000,		\
		.rate = 66666666,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00001000,		\
		.rate = 100000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00001100,		\
		.rate = 40000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00001200,		\
		.rate = 25000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x30 + 0x200 * (ch),	\
		.mask = 0x00031300,		\
		.data = 0x00001300,		\
		.rate = 22222222,		\
	}

#define UNIPHIER_MIO_CLK_GATE_USB(ch, idx)	\
	{					\
		.index = (idx),			\
		.reg = 0x20 + 0x200 * (ch),	\
		.mask = 0x30000000,		\
		.data = 0x30000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x110 + 0x200 * (ch),	\
		.mask = 0x01000000,		\
		.data = 0x01000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x114 + 0x200 * (ch),	\
		.mask = 0x00000001,		\
		.data = 0x00000001,		\
	}

#define UNIPHIER_MIO_CLK_GATE_DMAC(idx)		\
	{					\
		.index = (idx),			\
		.reg = 0x20,			\
		.mask = 0x02000000,		\
		.data = 0x02000000,		\
	},					\
	{					\
		.index = (idx),			\
		.reg = 0x110,			\
		.mask = 0x00020000,		\
		.data = 0x00020000,		\
	}

static struct uniphier_clk_gate_data uniphier_mio_clk_gate[] = {
	UNIPHIER_MIO_CLK_GATE_SD(0, 0),
	UNIPHIER_MIO_CLK_GATE_SD(1, 1),
	UNIPHIER_MIO_CLK_GATE_SD(2, 2),		/* for PH1-Pro4 only */
	UNIPHIER_MIO_CLK_GATE_USB(0, 3),
	UNIPHIER_MIO_CLK_GATE_USB(1, 4),
	UNIPHIER_MIO_CLK_GATE_USB(2, 5),
	UNIPHIER_MIO_CLK_GATE_DMAC(6),
	UNIPHIER_MIO_CLK_GATE_USB(3, 7),	/* for PH1-sLD3 only */
};

static struct uniphier_clk_rate_data uniphier_mio_clk_rate[] = {
	UNIPHIER_MIO_CLK_RATE_SD(0, 0),
	UNIPHIER_MIO_CLK_RATE_SD(1, 1),
	UNIPHIER_MIO_CLK_RATE_SD(2, 2),		/* for PH1-Pro4 only */
};

static struct uniphier_clk_soc_data uniphier_mio_clk_data = {
	.gate = uniphier_mio_clk_gate,
	.nr_gate = ARRAY_SIZE(uniphier_mio_clk_gate),
	.rate = uniphier_mio_clk_rate,
	.nr_rate = ARRAY_SIZE(uniphier_mio_clk_rate),
};

static const struct udevice_id uniphier_mio_clk_match[] = {
	{
		.compatible = "socionext,ph1-sld3-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{
		.compatible = "socionext,ph1-ld4-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{
		.compatible = "socionext,ph1-pro4-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{
		.compatible = "socionext,ph1-sld8-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{
		.compatible = "socionext,ph1-pro5-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{
		.compatible = "socionext,proxstream2-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{
		.compatible = "socionext,ph1-ld20-mioctrl",
		.data = (ulong)&uniphier_mio_clk_data,
	},
	{ /* sentinel */ }
};

U_BOOT_DRIVER(uniphier_mio_clk) = {
	.name = "uniphier-mio-clk",
	.id = UCLASS_CLK,
	.of_match = uniphier_mio_clk_match,
	.probe = uniphier_clk_probe,
	.remove = uniphier_clk_remove,
	.priv_auto_alloc_size = sizeof(struct uniphier_clk_priv),
	.ops = &uniphier_clk_ops,
};