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
|
/*
* Samsung Exynos SoC series NPU driver
*
* Copyright (c) 2017 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/io.h>
#include <linux/delay.h>
#include "npu-config.h"
#include "npu-exynos.h"
#include "npu-exynos9820.h"
#include "npu-debug.h"
#include "npu-log.h"
#define CLK_INDEX(name) NPU_##name
#define REGISTER_CLK(name)[CLK_INDEX(name)] = {#name, NULL}
extern int npu_clk_set_rate(struct device *dev, u32 index, ulong frequency);
extern ulong npu_clk_get_rate(struct device *dev, u32 index);
extern int npu_clk_enable(struct device *dev, u32 index);
extern int npu_clk_disable(struct device *dev, u32 index);
enum npu_clk_index {
CLK_INDEX(npu)
};
struct npu_clk npu_clk_array[] = {
REGISTER_CLK(npu)
};
const u32 npu_clk_array_size = ARRAY_SIZE(npu_clk_array);
int npu_exynos_clk_cfg(struct npu_exynos *exynos)
{
return 0;
}
int npu_exynos_clk_on(struct npu_exynos *exynos)
{
npu_clk_enable(exynos->dev, CLK_INDEX(npu));
npu_clk_get_rate(exynos->dev, CLK_INDEX(npu));
return 0;
}
int npu_exynos_clk_off(struct npu_exynos *exynos)
{
npu_clk_disable(exynos->dev, CLK_INDEX(npu));
return 0;
}
int npu_exynos_clk_dump(struct npu_exynos *exynos)
{
int ret = 0;
struct npu_reg *reg;
void *npu0cmu_base;
void *npu1cmu_base;
u32 val;
npu0cmu_base = ioremap_nocache(0x15A80000, 0x2000);
if (!npu0cmu_base) {
npu_err("fail(npu0cmu_base) in ioremap\n");
ret = -EINVAL;
goto p_err;
}
npu1cmu_base = ioremap_nocache(0x15A80000, 0x2000);
if (!npu1cmu_base) {
npu_err("fail(npu1cmu_base) in ioremap\n");
ret = -EINVAL;
goto p_err;
}
reg = &npu0_cmuclk_regs[MUX_CLKCMU_NPU0_BUS];
npu_readl(npu0cmu_base, reg, &val);
npu_info("[REG][%s][0x%04X], val(R):[0x%08X]\n", reg->name, reg->offset, val);
reg = &npu0_cmuclk_regs[MUX_CLKCMU_NPU0_CPU];
npu_readl(npu0cmu_base, reg, &val);
npu_info("[REG][%s][0x%04X], val(R):[0x%08X]\n", reg->name, reg->offset, val);
reg = &npu0_cmuclk_regs[DIV_CLKCMU_NPU0_BUS];
npu_readl(npu0cmu_base, reg, &val);
npu_info("[REG][%s][0x%04X], val(R):[0x%08X]\n", reg->name, reg->offset, val);
reg = &npu0_cmuclk_regs[DIV_CLKCMU_NPU0_CPU];
npu_readl(npu0cmu_base, reg, &val);
npu_info("[REG][%s][0x%04X], val(R):[0x%08X]\n", reg->name, reg->offset, val);
reg = &npu1_cmuclk_regs[MUX_CLKCMU_NPU1_BUS];
npu_readl(npu1cmu_base, reg, &val);
npu_info("[REG][%s][0x%04X], val(R):[0x%08X]\n", reg->name, reg->offset, val);
reg = &npu1_cmuclk_regs[DIV_CLKCMU_NPU1_BUS];
npu_readl(npu1cmu_base, reg, &val);
npu_info("[REG][%s][0x%04X], val(R):[0x%08X]\n", reg->name, reg->offset, val);
p_err:
if (npu0cmu_base)
iounmap(npu0cmu_base);
if (npu1cmu_base)
iounmap(npu1cmu_base);
return ret;
}
int dummy_npu_exynos_clk_cfg(struct npu_exynos *exynos) { return 0; }
int dummy_npu_exynos_clk_on(struct npu_exynos *exynos) { return 0; }
int dummy_npu_exynos_clk_off(struct npu_exynos *exynos) { return 0; }
int dummy_npu_exynos_clk_dump(struct npu_exynos *exynos) { return 0; }
const struct npu_clk_ops npu_clk_ops = {
#ifdef CONFIG_EXYNOS_NPU_HARDWARE
.clk_cfg = npu_exynos_clk_cfg,
.clk_on = npu_exynos_clk_on,
.clk_off = npu_exynos_clk_off,
.clk_dump = npu_exynos_clk_dump
#else
.clk_cfg = dummy_npu_exynos_clk_cfg,
.clk_on = dummy_npu_exynos_clk_on,
.clk_off = dummy_npu_exynos_clk_off,
.clk_dump = dummy_npu_exynos_clk_dump
#endif
};
int npu_exynos_ctl_cfg(struct npu_exynos *exynos)
{
return 0;
}
int npu_exynos_ctl_on(struct npu_exynos *exynos)
{
return 0;
}
int npu_exynos_ctl_off(struct npu_exynos *exynos)
{
return 0;
}
int npu_exynos_ctl_dump(struct npu_exynos *exynos)
{
return 0;
}
int dummy_npu_exynos_ctl_cfg(struct npu_exynos *exynos) { return 0; }
int dummy_npu_exynos_ctl_on(struct npu_exynos *exynos) { return 0; }
int dummy_npu_exynos_ctl_off(struct npu_exynos *exynos) { return 0; }
int dummy_npu_exynos_ctl_dump(struct npu_exynos *exynos) { return 0; }
const struct npu_ctl_ops npu_ctl_ops = {
#ifdef CONFIG_EXYNOS_NPU_HARDWARE
.ctl_cfg = npu_exynos_ctl_cfg,
.ctl_on = npu_exynos_ctl_on,
.ctl_off = npu_exynos_ctl_off,
.ctl_dump = npu_exynos_ctl_dump
#else
.ctl_cfg = dummy_npu_exynos_ctl_cfg,
.ctl_on = dummy_npu_exynos_ctl_on,
.ctl_off = dummy_npu_exynos_ctl_off,
.ctl_dump = dummy_npu_exynos_ctl_dump
#endif
};
|