forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/soc/rockchip/pm_domains.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Rockchip Generic power domain support.
34 *
45 * Copyright (c) 2015 ROCKCHIP, Co. Ltd.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107
118 #include <linux/module.h>
....@@ -30,7 +27,9 @@
3027 #include <dt-bindings/power/rv1126-power.h>
3128 #include <dt-bindings/power/rk1808-power.h>
3229 #include <dt-bindings/power/rk3036-power.h>
30
+#include <dt-bindings/power/rk3066-power.h>
3331 #include <dt-bindings/power/rk3128-power.h>
32
+#include <dt-bindings/power/rk3188-power.h>
3433 #include <dt-bindings/power/rk3228-power.h>
3534 #include <dt-bindings/power/rk3288-power.h>
3635 #include <dt-bindings/power/rk3328-power.h>
....@@ -38,9 +37,12 @@
3837 #include <dt-bindings/power/rk3368-power.h>
3938 #include <dt-bindings/power/rk3399-power.h>
4039 #include <dt-bindings/power/rk3528-power.h>
40
+#include <dt-bindings/power/rk3562-power.h>
4141 #include <dt-bindings/power/rk3568-power.h>
42
+#include <dt-bindings/power/rk3588-power.h>
4243
4344 struct rockchip_domain_info {
45
+ const char *name;
4446 int pwr_mask;
4547 int status_mask;
4648 int req_mask;
....@@ -49,9 +51,15 @@
4951 bool active_wakeup;
5052 int pwr_w_mask;
5153 int req_w_mask;
54
+ int mem_status_mask;
55
+ int repair_status_mask;
56
+ int clk_ungate_mask;
57
+ int clk_ungate_w_mask;
58
+ int mem_num;
5259 bool keepon_startup;
5360 bool always_on;
5461 u32 pwr_offset;
62
+ u32 mem_offset;
5563 u32 req_offset;
5664 };
5765
....@@ -61,6 +69,12 @@
6169 u32 req_offset;
6270 u32 idle_offset;
6371 u32 ack_offset;
72
+ u32 mem_pwr_offset;
73
+ u32 chain_status_offset;
74
+ u32 mem_status_offset;
75
+ u32 repair_status_offset;
76
+ u32 clk_ungate_offset;
77
+ u32 mem_sd_offset;
6478
6579 u32 core_pwrcnt_offset;
6680 u32 gpu_pwrcnt_offset;
....@@ -79,17 +93,26 @@
7993 #define QOS_SATURATION 0x14
8094 #define QOS_EXTCONTROL 0x18
8195
96
+#define SHAPING_NBPKTMAX0 0x0
97
+
8298 struct rockchip_pm_domain {
8399 struct generic_pm_domain genpd;
84100 const struct rockchip_domain_info *info;
85101 struct rockchip_pmu *pmu;
86102 int num_qos;
103
+ int num_shaping;
87104 struct regmap **qos_regmap;
105
+ struct regmap **shaping_regmap;
88106 u32 *qos_save_regs[MAX_QOS_REGS_NUM];
107
+ u32 *shaping_save_regs;
108
+ bool *qos_is_need_init[MAX_QOS_REGS_NUM];
109
+ bool *shaping_is_need_init;
89110 int num_clks;
90111 struct clk_bulk_data *clks;
91112 bool is_ignore_pwr;
92113 bool is_qos_saved;
114
+ bool is_qos_need_init;
115
+ bool is_shaping_need_init;
93116 struct regulator *supply;
94117 };
95118
....@@ -123,8 +146,9 @@
123146
124147 #define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd)
125148
126
-#define DOMAIN(pwr, status, req, idle, ack, wakeup, keepon) \
149
+#define DOMAIN(_name, pwr, status, req, idle, ack, wakeup, keepon) \
127150 { \
151
+ .name = _name, \
128152 .pwr_mask = (pwr), \
129153 .status_mask = (status), \
130154 .req_mask = (req), \
....@@ -134,8 +158,9 @@
134158 .keepon_startup = (keepon), \
135159 }
136160
137
-#define DOMAIN_M(pwr, status, req, idle, ack, wakeup, keepon) \
161
+#define DOMAIN_M(_name, pwr, status, req, idle, ack, wakeup, keepon) \
138162 { \
163
+ .name = _name, \
139164 .pwr_w_mask = (pwr) << 16, \
140165 .pwr_mask = (pwr), \
141166 .status_mask = (status), \
....@@ -161,8 +186,26 @@
161186 .keepon_startup = keepon, \
162187 }
163188
164
-#define DOMAIN_M_O(pwr, status, p_offset, req, idle, ack, r_offset, wakeup, keepon) \
189
+#define DOMAIN_M_C_SD(_name, pwr, status, req, idle, ack, clk, mem, wakeup, keepon) \
165190 { \
191
+ .name = _name, \
192
+ .pwr_w_mask = (pwr) << 16, \
193
+ .pwr_mask = (pwr), \
194
+ .status_mask = (status), \
195
+ .req_w_mask = (req) << 16, \
196
+ .req_mask = (req), \
197
+ .idle_mask = (idle), \
198
+ .ack_mask = (ack), \
199
+ .clk_ungate_mask = (clk), \
200
+ .clk_ungate_w_mask = (clk) << 16, \
201
+ .mem_num = (mem), \
202
+ .active_wakeup = wakeup, \
203
+ .keepon_startup = keepon, \
204
+}
205
+
206
+#define DOMAIN_M_O(_name, pwr, status, p_offset, req, idle, ack, r_offset, wakeup, keepon) \
207
+{ \
208
+ .name = _name, \
166209 .pwr_w_mask = (pwr) << 16, \
167210 .pwr_mask = (pwr), \
168211 .status_mask = (status), \
....@@ -176,8 +219,28 @@
176219 .req_offset = r_offset, \
177220 }
178221
179
-#define DOMAIN_RK3036(req, ack, idle, wakeup) \
222
+#define DOMAIN_M_O_R(_name, p_offset, pwr, status, m_offset, m_status, r_status, r_offset, req, idle, ack, wakeup, keepon) \
180223 { \
224
+ .name = _name, \
225
+ .pwr_offset = p_offset, \
226
+ .pwr_w_mask = (pwr) << 16, \
227
+ .pwr_mask = (pwr), \
228
+ .status_mask = (status), \
229
+ .mem_offset = m_offset, \
230
+ .mem_status_mask = (m_status), \
231
+ .repair_status_mask = (r_status), \
232
+ .req_offset = r_offset, \
233
+ .req_w_mask = (req) << 16, \
234
+ .req_mask = (req), \
235
+ .idle_mask = (idle), \
236
+ .ack_mask = (ack), \
237
+ .active_wakeup = wakeup, \
238
+ .keepon_startup = keepon, \
239
+}
240
+
241
+#define DOMAIN_RK3036(_name, req, ack, idle, wakeup) \
242
+{ \
243
+ .name = _name, \
181244 .req_mask = (req), \
182245 .req_w_mask = (req) << 16, \
183246 .ack_mask = (ack), \
....@@ -185,50 +248,62 @@
185248 .active_wakeup = wakeup, \
186249 }
187250
188
-#define DOMAIN_PX30(pwr, status, req, wakeup) \
189
- DOMAIN_M(pwr, status, req, (req) << 16, req, wakeup, false)
251
+#define DOMAIN_PX30(name, pwr, status, req, wakeup) \
252
+ DOMAIN_M(name, pwr, status, req, (req) << 16, req, wakeup, false)
190253
191
-#define DOMAIN_PX30_PROTECT(pwr, status, req, wakeup) \
192
- DOMAIN_M(pwr, status, req, (req) << 16, req, wakeup, true)
254
+#define DOMAIN_PX30_PROTECT(name, pwr, status, req, wakeup) \
255
+ DOMAIN_M(name, pwr, status, req, (req) << 16, req, wakeup, true)
193256
194
-#define DOMAIN_RV1126(pwr, req, idle, wakeup) \
195
- DOMAIN_M(pwr, pwr, req, idle, idle, wakeup, false)
257
+#define DOMAIN_RV1126(name, pwr, req, idle, wakeup) \
258
+ DOMAIN_M(name, pwr, pwr, req, idle, idle, wakeup, false)
196259
197
-#define DOMAIN_RV1126_PROTECT(pwr, req, idle, wakeup) \
198
- DOMAIN_M(pwr, pwr, req, idle, idle, wakeup, true)
260
+#define DOMAIN_RV1126_PROTECT(name, pwr, req, idle, wakeup) \
261
+ DOMAIN_M(name, pwr, pwr, req, idle, idle, wakeup, true)
199262
200
-#define DOMAIN_RV1126_O(pwr, req, idle, r_offset, wakeup) \
201
- DOMAIN_M_O(pwr, pwr, 0, req, idle, idle, r_offset, wakeup, false)
263
+#define DOMAIN_RV1126_O(name, pwr, req, idle, r_offset, wakeup) \
264
+ DOMAIN_M_O(name, pwr, pwr, 0, req, idle, idle, r_offset, wakeup, false)
202265
203
-#define DOMAIN_RK3288(pwr, status, req, wakeup) \
204
- DOMAIN(pwr, status, req, req, (req) << 16, wakeup, false)
266
+#define DOMAIN_RK3288(name, pwr, status, req, wakeup) \
267
+ DOMAIN(name, pwr, status, req, req, (req) << 16, wakeup, false)
205268
206
-#define DOMAIN_RK3288_PROTECT(pwr, status, req, wakeup) \
207
- DOMAIN(pwr, status, req, req, (req) << 16, wakeup, true)
269
+#define DOMAIN_RK3288_PROTECT(name, pwr, status, req, wakeup) \
270
+ DOMAIN(name, pwr, status, req, req, (req) << 16, wakeup, true)
208271
209
-#define DOMAIN_RK3328(pwr, status, req, wakeup) \
210
- DOMAIN_M(pwr, pwr, req, (req) << 10, req, wakeup, false)
272
+#define DOMAIN_RK3328(name, pwr, status, req, wakeup) \
273
+ DOMAIN_M(name, pwr, pwr, req, (req) << 10, req, wakeup, false)
211274
212
-#define DOMAIN_RK3368(pwr, status, req, wakeup) \
213
- DOMAIN(pwr, status, req, (req) << 16, req, wakeup, false)
275
+#define DOMAIN_RK3368(name, pwr, status, req, wakeup) \
276
+ DOMAIN(name, pwr, status, req, (req) << 16, req, wakeup, false)
214277
215
-#define DOMAIN_RK3368_PROTECT(pwr, status, req, wakeup) \
216
- DOMAIN(pwr, status, req, (req) << 16, req, wakeup, true)
278
+#define DOMAIN_RK3368_PROTECT(name, pwr, status, req, wakeup) \
279
+ DOMAIN(name, pwr, status, req, (req) << 16, req, wakeup, true)
217280
218
-#define DOMAIN_RK3399(pwr, status, req, wakeup) \
219
- DOMAIN(pwr, status, req, req, req, wakeup, false)
281
+#define DOMAIN_RK3399(name, pwr, status, req, wakeup) \
282
+ DOMAIN(name, pwr, status, req, req, req, wakeup, false)
220283
221
-#define DOMAIN_RK3399_PROTECT(pwr, status, req, wakeup) \
222
- DOMAIN(pwr, status, req, req, req, wakeup, true)
284
+#define DOMAIN_RK3399_PROTECT(name, pwr, status, req, wakeup) \
285
+ DOMAIN(name, pwr, status, req, req, req, wakeup, true)
223286
224287 #define DOMAIN_RK3528(pwr, req, always, wakeup) \
225288 DOMAIN_M_A(pwr, pwr, req, req, req, always, wakeup, false)
226289
227
-#define DOMAIN_RK3568(pwr, req, wakeup) \
228
- DOMAIN_M(pwr, pwr, req, req, req, wakeup, false)
290
+#define DOMAIN_RK3562(name, pwr, req, mem, wakeup) \
291
+ DOMAIN_M_C_SD(name, pwr, pwr, req, req, req, req, mem, wakeup, false)
229292
230
-#define DOMAIN_RK3568_PROTECT(pwr, req, wakeup) \
231
- DOMAIN_M(pwr, pwr, req, req, req, wakeup, true)
293
+#define DOMAIN_RK3562_PROTECT(name, pwr, req, mem, wakeup) \
294
+ DOMAIN_M_C_SD(name, pwr, pwr, req, req, req, req, mem, wakeup, true)
295
+
296
+#define DOMAIN_RK3568(name, pwr, req, wakeup) \
297
+ DOMAIN_M(name, pwr, pwr, req, req, req, wakeup, false)
298
+
299
+#define DOMAIN_RK3568_PROTECT(name, pwr, req, wakeup) \
300
+ DOMAIN_M(name, pwr, pwr, req, req, req, wakeup, true)
301
+
302
+#define DOMAIN_RK3588(name, p_offset, pwr, status, m_offset, m_status, r_status, r_offset, req, idle, wakeup) \
303
+ DOMAIN_M_O_R(name, p_offset, pwr, status, m_offset, m_status, r_status, r_offset, req, idle, idle, wakeup, false)
304
+
305
+#define DOMAIN_RK3588_P(name, p_offset, pwr, status, m_offset, m_status, r_status, r_offset, req, idle, wakeup) \
306
+ DOMAIN_M_O_R(name, p_offset, pwr, status, m_offset, m_status, r_status, r_offset, req, idle, idle, wakeup, true)
232307
233308 static bool rockchip_pmu_domain_is_idle(struct rockchip_pm_domain *pd)
234309 {
....@@ -246,6 +321,42 @@
246321
247322 regmap_read(pmu->regmap, pmu->info->ack_offset, &val);
248323 return val;
324
+}
325
+
326
+static int rockchip_pmu_ungate_clk(struct rockchip_pm_domain *pd, bool ungate)
327
+{
328
+ const struct rockchip_domain_info *pd_info = pd->info;
329
+ struct rockchip_pmu *pmu = pd->pmu;
330
+ unsigned int val;
331
+
332
+ if (!pd_info->clk_ungate_mask)
333
+ return 0;
334
+ if (!pmu->info->clk_ungate_offset)
335
+ return 0;
336
+
337
+ val = ungate ? (pd_info->clk_ungate_mask | pd_info->clk_ungate_w_mask) :
338
+ pd_info->clk_ungate_w_mask;
339
+ regmap_write(pmu->regmap, pmu->info->clk_ungate_offset, val);
340
+
341
+ return 0;
342
+}
343
+
344
+static int rockchip_pmu_mem_shut_down(struct rockchip_pm_domain *pd, bool sd)
345
+{
346
+ const struct rockchip_domain_info *pd_info = pd->info;
347
+ struct rockchip_pmu *pmu = pd->pmu;
348
+ unsigned int i;
349
+
350
+ if (!pd_info->mem_num)
351
+ return 0;
352
+ if (!pmu->info->mem_sd_offset)
353
+ return 0;
354
+
355
+ for (i = 0; i < pd_info->mem_num; i++)
356
+ regmap_write(pmu->regmap, pmu->info->mem_sd_offset,
357
+ (sd << i) | (1 << (i + 16)));
358
+
359
+ return 0;
249360 }
250361
251362 static int rockchip_pmu_set_idle_request(struct rockchip_pm_domain *pd,
....@@ -326,6 +437,45 @@
326437 }
327438 EXPORT_SYMBOL(rockchip_pmu_idle_request);
328439
440
+static int rockchip_pmu_save_shaping(struct rockchip_pm_domain *pd)
441
+{
442
+ int i;
443
+
444
+ for (i = 0; i < pd->num_shaping; i++)
445
+ regmap_read(pd->shaping_regmap[i], SHAPING_NBPKTMAX0,
446
+ &pd->shaping_save_regs[i]);
447
+
448
+ return 0;
449
+}
450
+
451
+static int rockchip_pmu_restore_shaping(struct rockchip_pm_domain *pd)
452
+{
453
+ int i;
454
+
455
+ for (i = 0; i < pd->num_shaping; i++)
456
+ regmap_write(pd->shaping_regmap[i], SHAPING_NBPKTMAX0,
457
+ pd->shaping_save_regs[i]);
458
+
459
+ return 0;
460
+}
461
+
462
+static void rockchip_pmu_init_shaping(struct rockchip_pm_domain *pd)
463
+{
464
+ int i;
465
+
466
+ if (!pd->is_shaping_need_init)
467
+ return;
468
+
469
+ for (i = 0; i < pd->num_shaping; i++)
470
+ if (pd->shaping_is_need_init[i])
471
+ regmap_write(pd->shaping_regmap[i], SHAPING_NBPKTMAX0,
472
+ pd->shaping_save_regs[i]);
473
+
474
+ kfree(pd->shaping_is_need_init);
475
+ pd->shaping_is_need_init = NULL;
476
+ pd->is_shaping_need_init = false;
477
+}
478
+
329479 static int rockchip_pmu_save_qos(struct rockchip_pm_domain *pd)
330480 {
331481 int i;
....@@ -347,7 +497,8 @@
347497 QOS_EXTCONTROL,
348498 &pd->qos_save_regs[4][i]);
349499 }
350
- return 0;
500
+
501
+ return rockchip_pmu_save_shaping(pd);
351502 }
352503
353504 static int rockchip_pmu_restore_qos(struct rockchip_pm_domain *pd)
....@@ -372,7 +523,48 @@
372523 pd->qos_save_regs[4][i]);
373524 }
374525
375
- return 0;
526
+ return rockchip_pmu_restore_shaping(pd);
527
+}
528
+
529
+static void rockchip_pmu_init_qos(struct rockchip_pm_domain *pd)
530
+{
531
+ int i;
532
+
533
+ rockchip_pmu_init_shaping(pd);
534
+
535
+ if (!pd->is_qos_need_init)
536
+ return;
537
+
538
+ for (i = 0; i < pd->num_qos; i++) {
539
+ if (pd->qos_is_need_init[0][i])
540
+ regmap_write(pd->qos_regmap[i],
541
+ QOS_PRIORITY,
542
+ pd->qos_save_regs[0][i]);
543
+
544
+ if (pd->qos_is_need_init[1][i])
545
+ regmap_write(pd->qos_regmap[i],
546
+ QOS_MODE,
547
+ pd->qos_save_regs[1][i]);
548
+
549
+ if (pd->qos_is_need_init[2][i])
550
+ regmap_write(pd->qos_regmap[i],
551
+ QOS_BANDWIDTH,
552
+ pd->qos_save_regs[2][i]);
553
+
554
+ if (pd->qos_is_need_init[3][i])
555
+ regmap_write(pd->qos_regmap[i],
556
+ QOS_SATURATION,
557
+ pd->qos_save_regs[3][i]);
558
+
559
+ if (pd->qos_is_need_init[4][i])
560
+ regmap_write(pd->qos_regmap[i],
561
+ QOS_EXTCONTROL,
562
+ pd->qos_save_regs[4][i]);
563
+ }
564
+
565
+ kfree(pd->qos_is_need_init[0]);
566
+ pd->qos_is_need_init[0] = NULL;
567
+ pd->is_qos_need_init = false;
376568 }
377569
378570 int rockchip_save_qos(struct device *dev)
....@@ -421,10 +613,88 @@
421613 }
422614 EXPORT_SYMBOL(rockchip_restore_qos);
423615
616
+static bool rockchip_pmu_domain_is_mem_on(struct rockchip_pm_domain *pd)
617
+{
618
+ struct rockchip_pmu *pmu = pd->pmu;
619
+ unsigned int val;
620
+
621
+ regmap_read(pmu->regmap,
622
+ pmu->info->mem_status_offset + pd->info->mem_offset, &val);
623
+
624
+ /* 1'b0: power on, 1'b1: power off */
625
+ return !(val & pd->info->mem_status_mask);
626
+}
627
+
628
+static bool rockchip_pmu_domain_is_chain_on(struct rockchip_pm_domain *pd)
629
+{
630
+ struct rockchip_pmu *pmu = pd->pmu;
631
+ unsigned int val;
632
+
633
+ regmap_read(pmu->regmap,
634
+ pmu->info->chain_status_offset + pd->info->mem_offset, &val);
635
+
636
+ /* 1'b1: power on, 1'b0: power off */
637
+ return val & pd->info->mem_status_mask;
638
+}
639
+
640
+static int rockchip_pmu_domain_mem_reset(struct rockchip_pm_domain *pd)
641
+{
642
+ struct rockchip_pmu *pmu = pd->pmu;
643
+ struct generic_pm_domain *genpd = &pd->genpd;
644
+ bool is_on;
645
+ int ret = 0;
646
+
647
+ ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_chain_on, pd, is_on,
648
+ is_on == true, 0, 10000);
649
+ if (ret) {
650
+ dev_err(pmu->dev,
651
+ "failed to get chain status '%s', target_on=1, val=%d\n",
652
+ genpd->name, is_on);
653
+ goto error;
654
+ }
655
+
656
+ udelay(60);
657
+
658
+ regmap_write(pmu->regmap, pmu->info->mem_pwr_offset + pd->info->pwr_offset,
659
+ (pd->info->pwr_mask | pd->info->pwr_w_mask));
660
+ dsb(sy);
661
+
662
+ ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_mem_on, pd, is_on,
663
+ is_on == false, 0, 10000);
664
+ if (ret) {
665
+ dev_err(pmu->dev,
666
+ "failed to get mem status '%s', target_on=0, val=%d\n",
667
+ genpd->name, is_on);
668
+ goto error;
669
+ }
670
+
671
+ regmap_write(pmu->regmap, pmu->info->mem_pwr_offset + pd->info->pwr_offset,
672
+ pd->info->pwr_w_mask);
673
+ dsb(sy);
674
+
675
+ ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_mem_on, pd, is_on,
676
+ is_on == true, 0, 10000);
677
+ if (ret) {
678
+ dev_err(pmu->dev,
679
+ "failed to get mem status '%s', target_on=1, val=%d\n",
680
+ genpd->name, is_on);
681
+ }
682
+
683
+error:
684
+
685
+ return ret;
686
+}
687
+
424688 static bool rockchip_pmu_domain_is_on(struct rockchip_pm_domain *pd)
425689 {
426690 struct rockchip_pmu *pmu = pd->pmu;
427691 unsigned int val;
692
+
693
+ if (pd->info->repair_status_mask) {
694
+ regmap_read(pmu->regmap, pmu->info->repair_status_offset, &val);
695
+ /* 1'b1: power on, 1'b0: power off */
696
+ return val & pd->info->repair_status_mask;
697
+ }
428698
429699 /* check idle status for idle-only domains */
430700 if (pd->info->status_mask == 0)
....@@ -442,15 +712,19 @@
442712 struct rockchip_pmu *pmu = pd->pmu;
443713 struct generic_pm_domain *genpd = &pd->genpd;
444714 u32 pd_pwr_offset = 0;
445
- bool is_on;
715
+ bool is_on, is_mem_on = false;
446716 int ret = 0;
717
+
718
+ if (pd->info->pwr_mask == 0)
719
+ return 0;
720
+
721
+ if (on && pd->info->mem_status_mask)
722
+ is_mem_on = rockchip_pmu_domain_is_mem_on(pd);
447723
448724 if (pd->info->pwr_offset)
449725 pd_pwr_offset = pd->info->pwr_offset;
450726
451
- if (pd->info->pwr_mask == 0)
452
- return 0;
453
- else if (pd->info->pwr_w_mask)
727
+ if (pd->info->pwr_w_mask)
454728 regmap_write(pmu->regmap, pmu->info->pwr_offset + pd_pwr_offset,
455729 on ? pd->info->pwr_w_mask :
456730 (pd->info->pwr_mask | pd->info->pwr_w_mask));
....@@ -460,6 +734,12 @@
460734 on ? 0 : -1U);
461735
462736 dsb(sy);
737
+
738
+ if (is_mem_on) {
739
+ ret = rockchip_pmu_domain_mem_reset(pd);
740
+ if (ret)
741
+ goto error;
742
+ }
463743
464744 ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_on, pd, is_on,
465745 is_on == on, 0, 10000);
....@@ -485,8 +765,8 @@
485765 if (pm_domain_always_on && !power_on)
486766 return 0;
487767
488
- if (!power_on && (soc_is_px30s())) {
489
- if (genpd->name && !strcmp(genpd->name, "pd_gpu"))
768
+ if (!power_on && soc_is_px30s()) {
769
+ if (genpd->name && !strcmp(genpd->name, "gpu"))
490770 return 0;
491771 }
492772
....@@ -514,6 +794,7 @@
514794 rockchip_pmu_unlock(pd);
515795 return ret;
516796 }
797
+ rockchip_pmu_ungate_clk(pd, true);
517798
518799 if (!power_on) {
519800 rockchip_pmu_save_qos(pd);
....@@ -526,6 +807,7 @@
526807 genpd->name);
527808 goto out;
528809 }
810
+ rockchip_pmu_mem_shut_down(pd, true);
529811 }
530812
531813 ret = rockchip_do_pmu_set_power_domain(pd, power_on);
....@@ -536,6 +818,7 @@
536818 }
537819
538820 if (power_on) {
821
+ rockchip_pmu_mem_shut_down(pd, false);
539822 /* if powering up, leave idle mode */
540823 ret = rockchip_pmu_set_idle_request(pd, false);
541824 if (ret) {
....@@ -546,9 +829,12 @@
546829
547830 if (pd->is_qos_saved)
548831 rockchip_pmu_restore_qos(pd);
832
+ if (pd->is_qos_need_init || pd->is_shaping_need_init)
833
+ rockchip_pmu_init_qos(pd);
549834 }
550835
551836 out:
837
+ rockchip_pmu_ungate_clk(pd, false);
552838 clk_bulk_disable(pd->num_clks, pd->clks);
553839
554840 if (!power_on && !IS_ERR(pd->supply))
....@@ -676,44 +962,31 @@
676962 pm_clk_destroy(dev);
677963 }
678964
679
-static void rockchip_pd_qos_init(struct rockchip_pm_domain *pd,
680
- bool **qos_is_need_init)
965
+static void rockchip_pd_qos_init(struct rockchip_pm_domain *pd)
681966 {
682
- int i, is_pd_on;
967
+ int is_pd_on, ret = 0;
968
+
969
+ if (!pd->is_qos_need_init) {
970
+ kfree(pd->qos_is_need_init[0]);
971
+ pd->qos_is_need_init[0] = NULL;
972
+ }
973
+ if (!pd->is_shaping_need_init) {
974
+ kfree(pd->shaping_is_need_init);
975
+ pd->shaping_is_need_init = NULL;
976
+ }
977
+ if (!pd->is_qos_need_init && !pd->is_shaping_need_init)
978
+ return;
683979
684980 is_pd_on = rockchip_pmu_domain_is_on(pd);
685
- if (!is_pd_on)
686
- rockchip_pd_power(pd, true);
687
-
688
- for (i = 0; i < pd->num_qos; i++) {
689
- if (qos_is_need_init[0][i])
690
- regmap_write(pd->qos_regmap[i],
691
- QOS_PRIORITY,
692
- pd->qos_save_regs[0][i]);
693
-
694
- if (qos_is_need_init[1][i])
695
- regmap_write(pd->qos_regmap[i],
696
- QOS_MODE,
697
- pd->qos_save_regs[1][i]);
698
-
699
- if (qos_is_need_init[2][i])
700
- regmap_write(pd->qos_regmap[i],
701
- QOS_BANDWIDTH,
702
- pd->qos_save_regs[2][i]);
703
-
704
- if (qos_is_need_init[3][i])
705
- regmap_write(pd->qos_regmap[i],
706
- QOS_SATURATION,
707
- pd->qos_save_regs[3][i]);
708
-
709
- if (qos_is_need_init[4][i])
710
- regmap_write(pd->qos_regmap[i],
711
- QOS_EXTCONTROL,
712
- pd->qos_save_regs[4][i]);
981
+ if (is_pd_on) {
982
+ ret = clk_bulk_enable(pd->num_clks, pd->clks);
983
+ if (ret < 0) {
984
+ dev_err(pd->pmu->dev, "failed to enable clocks\n");
985
+ return;
986
+ }
987
+ rockchip_pmu_init_qos(pd);
988
+ clk_bulk_disable(pd->num_clks, pd->clks);
713989 }
714
-
715
- if (!is_pd_on)
716
- rockchip_pd_power(pd, false);
717990 }
718991
719992 static int rockchip_pd_add_alwasy_on_flag(struct rockchip_pm_domain *pd)
....@@ -736,6 +1009,79 @@
7361009 return 0;
7371010 }
7381011
1012
+static int rockchip_pd_of_get_shaping(struct rockchip_pm_domain *pd,
1013
+ struct device_node *node)
1014
+{
1015
+ struct rockchip_pmu *pmu = pd->pmu;
1016
+ struct device_node *shaping_node;
1017
+ int num_shaping = 0, num_shaping_reg = 0;
1018
+ int error, i;
1019
+ u32 val;
1020
+
1021
+ num_shaping = of_count_phandle_with_args(node, "pm_shaping", NULL);
1022
+
1023
+ for (i = 0; i < num_shaping; i++) {
1024
+ shaping_node = of_parse_phandle(node, "pm_shaping", i);
1025
+ if (shaping_node && of_device_is_available(shaping_node))
1026
+ pd->num_shaping++;
1027
+ of_node_put(shaping_node);
1028
+ }
1029
+
1030
+ if (pd->num_shaping > 0) {
1031
+ pd->shaping_regmap = devm_kcalloc(pmu->dev, pd->num_shaping,
1032
+ sizeof(*pd->shaping_regmap),
1033
+ GFP_KERNEL);
1034
+ if (!pd->shaping_regmap)
1035
+ return -ENOMEM;
1036
+ pd->shaping_save_regs = devm_kmalloc(pmu->dev, sizeof(u32) *
1037
+ pd->num_shaping,
1038
+ GFP_KERNEL);
1039
+ if (!pd->shaping_save_regs)
1040
+ return -ENOMEM;
1041
+ pd->shaping_is_need_init = kcalloc(pd->num_shaping, sizeof(bool),
1042
+ GFP_KERNEL);
1043
+ if (!pd->shaping_is_need_init)
1044
+ return -ENOMEM;
1045
+ for (i = 0; i < num_shaping; i++) {
1046
+ shaping_node = of_parse_phandle(node, "pm_shaping", i);
1047
+ if (!shaping_node) {
1048
+ error = -ENODEV;
1049
+ goto err_free_init;
1050
+ }
1051
+ if (of_device_is_available(shaping_node)) {
1052
+ pd->shaping_regmap[num_shaping_reg] =
1053
+ syscon_node_to_regmap(shaping_node);
1054
+ if (IS_ERR(pd->shaping_regmap[num_shaping_reg])) {
1055
+ of_node_put(shaping_node);
1056
+ error = -ENODEV;
1057
+ goto err_free_init;
1058
+ }
1059
+ if (!of_property_read_u32(shaping_node,
1060
+ "shaping-init",
1061
+ &val)) {
1062
+ pd->shaping_save_regs[i] = val;
1063
+ pd->shaping_is_need_init[i] = true;
1064
+ pd->is_shaping_need_init = true;
1065
+ }
1066
+ num_shaping_reg++;
1067
+ }
1068
+ of_node_put(shaping_node);
1069
+ if (num_shaping_reg > pd->num_shaping) {
1070
+ error = -EINVAL;
1071
+ goto err_free_init;
1072
+ }
1073
+ }
1074
+ }
1075
+
1076
+ return 0;
1077
+
1078
+err_free_init:
1079
+ kfree(pd->shaping_is_need_init);
1080
+ pd->shaping_is_need_init = NULL;
1081
+
1082
+ return error;
1083
+}
1084
+
7391085 static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
7401086 struct device_node *node)
7411087 {
....@@ -746,27 +1092,27 @@
7461092 int i, j;
7471093 u32 id, val;
7481094 int error;
749
- bool *qos_is_need_init[MAX_QOS_REGS_NUM] = { NULL };
750
- bool is_qos_need_init = false;
7511095
7521096 error = of_property_read_u32(node, "reg", &id);
7531097 if (error) {
7541098 dev_err(pmu->dev,
755
- "%s: failed to retrieve domain id (reg): %d\n",
756
- node->name, error);
1099
+ "%pOFn: failed to retrieve domain id (reg): %d\n",
1100
+ node, error);
7571101 return -EINVAL;
7581102 }
7591103
7601104 if (id >= pmu->info->num_domains) {
761
- dev_err(pmu->dev, "%s: invalid domain id %d\n",
762
- node->name, id);
1105
+ dev_err(pmu->dev, "%pOFn: invalid domain id %d\n",
1106
+ node, id);
7631107 return -EINVAL;
7641108 }
1109
+ if (pmu->genpd_data.domains[id])
1110
+ return 0;
7651111
7661112 pd_info = &pmu->info->domain_info[id];
7671113 if (!pd_info) {
768
- dev_err(pmu->dev, "%s: undefined domain id %d\n",
769
- node->name, id);
1114
+ dev_err(pmu->dev, "%pOFn: undefined domain id %d\n",
1115
+ node, id);
7701116 return -EINVAL;
7711117 }
7721118
....@@ -786,8 +1132,8 @@
7861132 if (!pd->clks)
7871133 return -ENOMEM;
7881134 } else {
789
- dev_dbg(pmu->dev, "%s: doesn't have clocks: %d\n",
790
- node->name, pd->num_clks);
1135
+ dev_dbg(pmu->dev, "%pOFn: doesn't have clocks: %d\n",
1136
+ node, pd->num_clks);
7911137 pd->num_clks = 0;
7921138 }
7931139
....@@ -796,8 +1142,8 @@
7961142 if (IS_ERR(pd->clks[i].clk)) {
7971143 error = PTR_ERR(pd->clks[i].clk);
7981144 dev_err(pmu->dev,
799
- "%s: failed to get clk at index %d: %d\n",
800
- node->name, i, error);
1145
+ "%pOFn: failed to get clk at index %d: %d\n",
1146
+ node, i, error);
8011147 return error;
8021148 }
8031149 }
....@@ -833,18 +1179,19 @@
8331179 error = -ENOMEM;
8341180 goto err_unprepare_clocks;
8351181 }
836
- qos_is_need_init[0] = kzalloc(sizeof(bool) *
837
- MAX_QOS_REGS_NUM *
838
- pd->num_qos,
839
- GFP_KERNEL);
840
- if (!qos_is_need_init[0]) {
1182
+ pd->qos_is_need_init[0] = kzalloc(sizeof(bool) *
1183
+ MAX_QOS_REGS_NUM *
1184
+ pd->num_qos,
1185
+ GFP_KERNEL);
1186
+ if (!pd->qos_is_need_init[0]) {
8411187 error = -ENOMEM;
8421188 goto err_unprepare_clocks;
8431189 }
8441190 for (i = 1; i < MAX_QOS_REGS_NUM; i++) {
8451191 pd->qos_save_regs[i] = pd->qos_save_regs[i - 1] +
8461192 num_qos;
847
- qos_is_need_init[i] = qos_is_need_init[i - 1] + num_qos;
1193
+ pd->qos_is_need_init[i] = pd->qos_is_need_init[i - 1] +
1194
+ num_qos;
8481195 }
8491196
8501197 for (j = 0; j < num_qos; j++) {
....@@ -865,71 +1212,72 @@
8651212 "priority-init",
8661213 &val)) {
8671214 pd->qos_save_regs[0][j] = val;
868
- qos_is_need_init[0][j] = true;
869
- is_qos_need_init = true;
1215
+ pd->qos_is_need_init[0][j] = true;
1216
+ pd->is_qos_need_init = true;
8701217 }
8711218
8721219 if (!of_property_read_u32(qos_node,
8731220 "mode-init",
8741221 &val)) {
8751222 pd->qos_save_regs[1][j] = val;
876
- qos_is_need_init[1][j] = true;
877
- is_qos_need_init = true;
1223
+ pd->qos_is_need_init[1][j] = true;
1224
+ pd->is_qos_need_init = true;
8781225 }
8791226
8801227 if (!of_property_read_u32(qos_node,
8811228 "bandwidth-init",
8821229 &val)) {
8831230 pd->qos_save_regs[2][j] = val;
884
- qos_is_need_init[2][j] = true;
885
- is_qos_need_init = true;
1231
+ pd->qos_is_need_init[2][j] = true;
1232
+ pd->is_qos_need_init = true;
8861233 }
8871234
8881235 if (!of_property_read_u32(qos_node,
8891236 "saturation-init",
8901237 &val)) {
8911238 pd->qos_save_regs[3][j] = val;
892
- qos_is_need_init[3][j] = true;
893
- is_qos_need_init = true;
1239
+ pd->qos_is_need_init[3][j] = true;
1240
+ pd->is_qos_need_init = true;
8941241 }
8951242
8961243 if (!of_property_read_u32(qos_node,
8971244 "extcontrol-init",
8981245 &val)) {
8991246 pd->qos_save_regs[4][j] = val;
900
- qos_is_need_init[4][j] = true;
901
- is_qos_need_init = true;
1247
+ pd->qos_is_need_init[4][j] = true;
1248
+ pd->is_qos_need_init = true;
9021249 }
9031250
9041251 num_qos_reg++;
9051252 }
9061253 of_node_put(qos_node);
907
- if (num_qos_reg > pd->num_qos)
1254
+ if (num_qos_reg > pd->num_qos) {
1255
+ error = -EINVAL;
9081256 goto err_unprepare_clocks;
1257
+ }
9091258 }
9101259 }
9111260
912
- pd->genpd.name = node->name;
1261
+ error = rockchip_pd_of_get_shaping(pd, node);
1262
+ if (error)
1263
+ goto err_unprepare_clocks;
1264
+
1265
+ if (pd->info->name)
1266
+ pd->genpd.name = pd->info->name;
1267
+ else
1268
+ pd->genpd.name = kbasename(node->full_name);
9131269 pd->genpd.power_off = rockchip_pd_power_off;
9141270 pd->genpd.power_on = rockchip_pd_power_on;
9151271 pd->genpd.attach_dev = rockchip_pd_attach_dev;
9161272 pd->genpd.detach_dev = rockchip_pd_detach_dev;
9171273 if (pd_info->active_wakeup)
9181274 pd->genpd.flags |= GENPD_FLAG_ACTIVE_WAKEUP;
919
- if (pd_info->always_on) {
920
- if (rockchip_pd_add_alwasy_on_flag(pd))
1275
+ if (pd_info->always_on || pd_info->keepon_startup) {
1276
+ error = rockchip_pd_add_alwasy_on_flag(pd);
1277
+ if (error)
9211278 goto err_unprepare_clocks;
9221279 }
923
-#ifndef MODULE
924
- if (pd_info->keepon_startup) {
925
- if (rockchip_pd_add_alwasy_on_flag(pd))
926
- goto err_unprepare_clocks;
927
- }
928
-#endif
929
- if (is_qos_need_init)
930
- rockchip_pd_qos_init(pd, &qos_is_need_init[0]);
931
-
932
- kfree(qos_is_need_init[0]);
1280
+ rockchip_pd_qos_init(pd);
9331281
9341282 pm_genpd_init(&pd->genpd, NULL, !rockchip_pmu_domain_is_on(pd));
9351283
....@@ -937,7 +1285,8 @@
9371285 return 0;
9381286
9391287 err_unprepare_clocks:
940
- kfree(qos_is_need_init[0]);
1288
+ kfree(pd->qos_is_need_init[0]);
1289
+ pd->qos_is_need_init[0] = NULL;
9411290 clk_bulk_unprepare(pd->num_clks, pd->clks);
9421291 err_put_clocks:
9431292 clk_bulk_put(pd->num_clks, pd->clks);
....@@ -1009,24 +1358,24 @@
10091358 error = of_property_read_u32(parent, "reg", &idx);
10101359 if (error) {
10111360 dev_err(pmu->dev,
1012
- "%s: failed to retrieve domain id (reg): %d\n",
1013
- parent->name, error);
1361
+ "%pOFn: failed to retrieve domain id (reg): %d\n",
1362
+ parent, error);
10141363 goto err_out;
10151364 }
10161365 parent_domain = pmu->genpd_data.domains[idx];
10171366
10181367 error = rockchip_pm_add_one_domain(pmu, np);
10191368 if (error) {
1020
- dev_err(pmu->dev, "failed to handle node %s: %d\n",
1021
- np->name, error);
1369
+ dev_err(pmu->dev, "failed to handle node %pOFn: %d\n",
1370
+ np, error);
10221371 goto err_out;
10231372 }
10241373
10251374 error = of_property_read_u32(np, "reg", &idx);
10261375 if (error) {
10271376 dev_err(pmu->dev,
1028
- "%s: failed to retrieve domain id (reg): %d\n",
1029
- np->name, error);
1377
+ "%pOFn: failed to retrieve domain id (reg): %d\n",
1378
+ np, error);
10301379 goto err_out;
10311380 }
10321381 child_domain = pmu->genpd_data.domains[idx];
....@@ -1062,37 +1411,15 @@
10621411 return error;
10631412 }
10641413
1065
-#ifndef MODULE
1066
-static void rockchip_pd_keepon_do_release(struct generic_pm_domain *genpd,
1067
- struct rockchip_pm_domain *pd)
1068
-{
1069
- struct pm_domain_data *pm_data;
1070
- int enable_count;
1071
-
1072
- pd->genpd.flags &= (~GENPD_FLAG_ALWAYS_ON);
1073
- list_for_each_entry(pm_data, &genpd->dev_list, list_node) {
1074
- if (!atomic_read(&pm_data->dev->power.usage_count)) {
1075
- enable_count = 0;
1076
- if (!pm_runtime_enabled(pm_data->dev)) {
1077
- pm_runtime_enable(pm_data->dev);
1078
- enable_count = 1;
1079
- }
1080
- pm_runtime_get_sync(pm_data->dev);
1081
- pm_runtime_put_sync(pm_data->dev);
1082
- if (enable_count)
1083
- pm_runtime_disable(pm_data->dev);
1084
- }
1085
- }
1086
-}
1087
-
1088
-static int __init rockchip_pd_keepon_release(void)
1414
+#ifdef MODULE
1415
+void rockchip_pd_disable_unused(void)
10891416 {
10901417 struct generic_pm_domain *genpd;
10911418 struct rockchip_pm_domain *pd;
10921419 int i;
10931420
10941421 if (!g_pmu)
1095
- return 0;
1422
+ return;
10961423
10971424 for (i = 0; i < g_pmu->genpd_data.num_domains; i++) {
10981425 genpd = g_pmu->genpd_data.domains[i];
....@@ -1100,10 +1427,44 @@
11001427 pd = to_rockchip_pd(genpd);
11011428 if (pd->info->always_on)
11021429 continue;
1103
- if (pd->info->keepon_startup)
1104
- rockchip_pd_keepon_do_release(genpd, pd);
1430
+ if (pd->info->keepon_startup &&
1431
+ (genpd->flags & GENPD_FLAG_ALWAYS_ON))
1432
+ genpd->flags &= (~GENPD_FLAG_ALWAYS_ON);
1433
+ queue_work(pm_wq, &genpd->power_off_work);
11051434 }
11061435 }
1436
+}
1437
+EXPORT_SYMBOL_GPL(rockchip_pd_disable_unused);
1438
+#else
1439
+static void rockchip_pd_keepon_do_release(void)
1440
+{
1441
+ struct generic_pm_domain *genpd;
1442
+ struct rockchip_pm_domain *pd;
1443
+ int i;
1444
+
1445
+ if (!g_pmu)
1446
+ return;
1447
+
1448
+ for (i = 0; i < g_pmu->genpd_data.num_domains; i++) {
1449
+ genpd = g_pmu->genpd_data.domains[i];
1450
+ if (genpd) {
1451
+ pd = to_rockchip_pd(genpd);
1452
+ if (pd->info->always_on)
1453
+ continue;
1454
+ if (!pd->info->keepon_startup)
1455
+ continue;
1456
+ if (!(genpd->flags & GENPD_FLAG_ALWAYS_ON))
1457
+ continue;
1458
+ genpd->flags &= (~GENPD_FLAG_ALWAYS_ON);
1459
+ queue_work(pm_wq, &genpd->power_off_work);
1460
+ }
1461
+ }
1462
+}
1463
+
1464
+static int __init rockchip_pd_keepon_release(void)
1465
+{
1466
+ rockchip_pd_keepon_do_release();
1467
+
11071468 return 0;
11081469 }
11091470 late_initcall_sync(rockchip_pd_keepon_release);
....@@ -1111,14 +1472,32 @@
11111472
11121473 static void __iomem *pd_base;
11131474
1475
+static void dump_offset(const char *name, u32 offset)
1476
+{
1477
+ if (!offset)
1478
+ return;
1479
+
1480
+ pr_warn("%-9s 0x%04x: ", name, offset);
1481
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 4, pd_base + offset, 16, false);
1482
+}
1483
+
11141484 void rockchip_dump_pmu(void)
11151485 {
1116
- if (pd_base) {
1117
- pr_warn("PMU:\n");
1118
- print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET,
1119
- 32, 4, pd_base,
1120
- 0x100, false);
1121
- }
1486
+ if (!pd_base)
1487
+ return;
1488
+
1489
+ pr_warn("PMU:\n");
1490
+ dump_offset("pwr", g_pmu->info->pwr_offset);
1491
+ dump_offset("status", g_pmu->info->status_offset);
1492
+ dump_offset("req", g_pmu->info->req_offset);
1493
+ dump_offset("idle", g_pmu->info->idle_offset);
1494
+ dump_offset("ack", g_pmu->info->ack_offset);
1495
+ dump_offset("mem_pwr", g_pmu->info->mem_pwr_offset);
1496
+ dump_offset("chain_st", g_pmu->info->chain_status_offset);
1497
+ dump_offset("mem_st", g_pmu->info->mem_status_offset);
1498
+ dump_offset("repair_st", g_pmu->info->repair_status_offset);
1499
+ dump_offset("clkungate", g_pmu->info->clk_ungate_offset);
1500
+ dump_offset("mem_sd", g_pmu->info->mem_sd_offset);
11221501 }
11231502 EXPORT_SYMBOL_GPL(rockchip_dump_pmu);
11241503
....@@ -1208,16 +1587,16 @@
12081587 for_each_available_child_of_node(np, node) {
12091588 error = rockchip_pm_add_one_domain(pmu, node);
12101589 if (error) {
1211
- dev_err(dev, "failed to handle node %s: %d\n",
1212
- node->name, error);
1590
+ dev_err(dev, "failed to handle node %pOFn: %d\n",
1591
+ node, error);
12131592 of_node_put(node);
12141593 goto err_out;
12151594 }
12161595
12171596 error = rockchip_pm_add_subdomain(pmu, node);
12181597 if (error < 0) {
1219
- dev_err(dev, "failed to handle subdomain node %s: %d\n",
1220
- node->name, error);
1598
+ dev_err(dev, "failed to handle subdomain node %pOFn: %d\n",
1599
+ node, error);
12211600 of_node_put(node);
12221601 goto err_out;
12231602 }
....@@ -1246,133 +1625,149 @@
12461625 }
12471626
12481627 static const struct rockchip_domain_info px30_pm_domains[] = {
1249
- [PX30_PD_USB] = DOMAIN_PX30(BIT(5), BIT(5), BIT(10), true),
1250
- [PX30_PD_SDCARD] = DOMAIN_PX30(BIT(8), BIT(8), BIT(9), false),
1251
- [PX30_PD_GMAC] = DOMAIN_PX30(BIT(10), BIT(10), BIT(6), false),
1252
- [PX30_PD_MMC_NAND] = DOMAIN_PX30(BIT(11), BIT(11), BIT(5), false),
1253
- [PX30_PD_VPU] = DOMAIN_PX30(BIT(12), BIT(12), BIT(14), false),
1254
- [PX30_PD_VO] = DOMAIN_PX30_PROTECT(BIT(13), BIT(13), BIT(7), false),
1255
- [PX30_PD_VI] = DOMAIN_PX30_PROTECT(BIT(14), BIT(14), BIT(8), false),
1256
- [PX30_PD_GPU] = DOMAIN_PX30(BIT(15), BIT(15), BIT(2), false),
1628
+ [PX30_PD_USB] = DOMAIN_PX30("usb", BIT(5), BIT(5), BIT(10), true),
1629
+ [PX30_PD_SDCARD] = DOMAIN_PX30("sdcard", BIT(8), BIT(8), BIT(9), false),
1630
+ [PX30_PD_GMAC] = DOMAIN_PX30("gmac", BIT(10), BIT(10), BIT(6), false),
1631
+ [PX30_PD_MMC_NAND] = DOMAIN_PX30("mmc_nand", BIT(11), BIT(11), BIT(5), false),
1632
+ [PX30_PD_VPU] = DOMAIN_PX30("vpu", BIT(12), BIT(12), BIT(14), false),
1633
+ [PX30_PD_VO] = DOMAIN_PX30_PROTECT("vo", BIT(13), BIT(13), BIT(7), false),
1634
+ [PX30_PD_VI] = DOMAIN_PX30_PROTECT("vi", BIT(14), BIT(14), BIT(8), false),
1635
+ [PX30_PD_GPU] = DOMAIN_PX30("gpu", BIT(15), BIT(15), BIT(2), false),
12571636 };
12581637
12591638 static const struct rockchip_domain_info rv1126_pm_domains[] = {
1260
- [RV1126_PD_CRYPTO] = DOMAIN_RV1126_O(BIT(10), BIT(4), BIT(20), 0x4, false),
1261
- [RV1126_PD_VEPU] = DOMAIN_RV1126(BIT(2), BIT(9), BIT(9), false),
1262
- [RV1126_PD_VI] = DOMAIN_RV1126(BIT(4), BIT(6), BIT(6), false),
1263
- [RV1126_PD_VO] = DOMAIN_RV1126_PROTECT(BIT(5), BIT(7), BIT(7), false),
1264
- [RV1126_PD_ISPP] = DOMAIN_RV1126(BIT(1), BIT(8), BIT(8), false),
1265
- [RV1126_PD_VDPU] = DOMAIN_RV1126(BIT(3), BIT(10), BIT(10), false),
1266
- [RV1126_PD_NVM] = DOMAIN_RV1126(BIT(7), BIT(11), BIT(11), false),
1267
- [RV1126_PD_SDIO] = DOMAIN_RV1126(BIT(8), BIT(13), BIT(13), false),
1268
- [RV1126_PD_USB] = DOMAIN_RV1126(BIT(9), BIT(15), BIT(15), true),
1269
- [RV1126_PD_NPU] = DOMAIN_RV1126_O(BIT(0), BIT(2), BIT(18), 0x4, false),
1639
+ [RV1126_PD_CRYPTO] = DOMAIN_RV1126_O("crypto", BIT(10), BIT(4), BIT(20), 0x4, false),
1640
+ [RV1126_PD_VEPU] = DOMAIN_RV1126("vepu", BIT(2), BIT(9), BIT(9), false),
1641
+ [RV1126_PD_VI] = DOMAIN_RV1126("vi", BIT(4), BIT(6), BIT(6), false),
1642
+ [RV1126_PD_VO] = DOMAIN_RV1126_PROTECT("vo", BIT(5), BIT(7), BIT(7), false),
1643
+ [RV1126_PD_ISPP] = DOMAIN_RV1126("ispp", BIT(1), BIT(8), BIT(8), false),
1644
+ [RV1126_PD_VDPU] = DOMAIN_RV1126("vdpu", BIT(3), BIT(10), BIT(10), false),
1645
+ [RV1126_PD_NVM] = DOMAIN_RV1126("nvm", BIT(7), BIT(11), BIT(11), false),
1646
+ [RV1126_PD_SDIO] = DOMAIN_RV1126("sdio", BIT(8), BIT(13), BIT(13), false),
1647
+ [RV1126_PD_USB] = DOMAIN_RV1126("usb", BIT(9), BIT(15), BIT(15), true),
1648
+ [RV1126_PD_NPU] = DOMAIN_RV1126_O("npu", BIT(0), BIT(2), BIT(18), 0x4, false),
12701649 };
12711650
12721651 static const struct rockchip_domain_info rk1808_pm_domains[] = {
1273
- [RK1808_VD_NPU] = DOMAIN_PX30(BIT(15), BIT(15), BIT(2), false),
1274
- [RK1808_PD_PCIE] = DOMAIN_PX30(BIT(9), BIT(9), BIT(4), true),
1275
- [RK1808_PD_VPU] = DOMAIN_PX30(BIT(13), BIT(13), BIT(7), false),
1276
- [RK1808_PD_VIO] = DOMAIN_PX30_PROTECT(BIT(14), BIT(14), BIT(8), false),
1652
+ [RK1808_VD_NPU] = DOMAIN_PX30("npu", BIT(15), BIT(15), BIT(2), false),
1653
+ [RK1808_PD_PCIE] = DOMAIN_PX30("pcie", BIT(9), BIT(9), BIT(4), true),
1654
+ [RK1808_PD_VPU] = DOMAIN_PX30("vpu", BIT(13), BIT(13), BIT(7), false),
1655
+ [RK1808_PD_VIO] = DOMAIN_PX30_PROTECT("vio", BIT(14), BIT(14), BIT(8), false),
12771656 };
12781657
12791658 static const struct rockchip_domain_info rk3036_pm_domains[] = {
1280
- [RK3036_PD_MSCH] = DOMAIN_RK3036(BIT(14), BIT(23), BIT(30), true),
1281
- [RK3036_PD_CORE] = DOMAIN_RK3036(BIT(13), BIT(17), BIT(24), false),
1282
- [RK3036_PD_PERI] = DOMAIN_RK3036(BIT(12), BIT(18), BIT(25), false),
1283
- [RK3036_PD_VIO] = DOMAIN_RK3036(BIT(11), BIT(19), BIT(26), false),
1284
- [RK3036_PD_VPU] = DOMAIN_RK3036(BIT(10), BIT(20), BIT(27), false),
1285
- [RK3036_PD_GPU] = DOMAIN_RK3036(BIT(9), BIT(21), BIT(28), false),
1286
- [RK3036_PD_SYS] = DOMAIN_RK3036(BIT(8), BIT(22), BIT(29), false),
1659
+ [RK3036_PD_MSCH] = DOMAIN_RK3036("msch", BIT(14), BIT(23), BIT(30), true),
1660
+ [RK3036_PD_CORE] = DOMAIN_RK3036("core", BIT(13), BIT(17), BIT(24), false),
1661
+ [RK3036_PD_PERI] = DOMAIN_RK3036("peri", BIT(12), BIT(18), BIT(25), false),
1662
+ [RK3036_PD_VIO] = DOMAIN_RK3036("vio", BIT(11), BIT(19), BIT(26), false),
1663
+ [RK3036_PD_VPU] = DOMAIN_RK3036("vpu", BIT(10), BIT(20), BIT(27), false),
1664
+ [RK3036_PD_GPU] = DOMAIN_RK3036("gpu", BIT(9), BIT(21), BIT(28), false),
1665
+ [RK3036_PD_SYS] = DOMAIN_RK3036("sys", BIT(8), BIT(22), BIT(29), false),
1666
+};
1667
+
1668
+static const struct rockchip_domain_info rk3066_pm_domains[] = {
1669
+ [RK3066_PD_GPU] = DOMAIN("gpu", BIT(9), BIT(9), BIT(3), BIT(24), BIT(29), false, false),
1670
+ [RK3066_PD_VIDEO] = DOMAIN("video", BIT(8), BIT(8), BIT(4), BIT(23), BIT(28), false, false),
1671
+ [RK3066_PD_VIO] = DOMAIN("vio", BIT(7), BIT(7), BIT(5), BIT(22), BIT(27), false, true),
1672
+ [RK3066_PD_PERI] = DOMAIN("peri", BIT(6), BIT(6), BIT(2), BIT(25), BIT(30), false, false),
1673
+ [RK3066_PD_CPU] = DOMAIN("cpu", 0, BIT(5), BIT(1), BIT(26), BIT(31), false, false),
12871674 };
12881675
12891676 static const struct rockchip_domain_info rk3128_pm_domains[] = {
1290
- [RK3128_PD_CORE] = DOMAIN_RK3288(BIT(0), BIT(0), BIT(4), false),
1291
- [RK3128_PD_MSCH] = DOMAIN_RK3288(0, 0, BIT(6), true),
1292
- [RK3128_PD_VIO] = DOMAIN_RK3288_PROTECT(BIT(3), BIT(3), BIT(2), false),
1293
- [RK3128_PD_VIDEO] = DOMAIN_RK3288(BIT(2), BIT(2), BIT(1), false),
1294
- [RK3128_PD_GPU] = DOMAIN_RK3288(BIT(1), BIT(1), BIT(3), false),
1677
+ [RK3128_PD_CORE] = DOMAIN_RK3288("core", BIT(0), BIT(0), BIT(4), false),
1678
+ [RK3128_PD_MSCH] = DOMAIN_RK3288("msch", 0, 0, BIT(6), true),
1679
+ [RK3128_PD_VIO] = DOMAIN_RK3288_PROTECT("vio", BIT(3), BIT(3), BIT(2), false),
1680
+ [RK3128_PD_VIDEO] = DOMAIN_RK3288("video", BIT(2), BIT(2), BIT(1), false),
1681
+ [RK3128_PD_GPU] = DOMAIN_RK3288("gpu", BIT(1), BIT(1), BIT(3), false),
1682
+};
1683
+
1684
+static const struct rockchip_domain_info rk3188_pm_domains[] = {
1685
+ [RK3188_PD_GPU] = DOMAIN("gpu", BIT(9), BIT(9), BIT(3), BIT(24), BIT(29), false, false),
1686
+ [RK3188_PD_VIDEO] = DOMAIN("video", BIT(8), BIT(8), BIT(4), BIT(23), BIT(28), false, false),
1687
+ [RK3188_PD_VIO] = DOMAIN("vio", BIT(7), BIT(7), BIT(5), BIT(22), BIT(27), false, true),
1688
+ [RK3188_PD_PERI] = DOMAIN("peri", BIT(6), BIT(6), BIT(2), BIT(25), BIT(30), false, false),
1689
+ [RK3188_PD_CPU] = DOMAIN("cpu", BIT(5), BIT(5), BIT(1), BIT(26), BIT(31), false, false),
12951690 };
12961691
12971692 static const struct rockchip_domain_info rk3228_pm_domains[] = {
1298
- [RK3228_PD_CORE] = DOMAIN_RK3036(BIT(0), BIT(0), BIT(16), true),
1299
- [RK3228_PD_MSCH] = DOMAIN_RK3036(BIT(1), BIT(1), BIT(17), true),
1300
- [RK3228_PD_BUS] = DOMAIN_RK3036(BIT(2), BIT(2), BIT(18), true),
1301
- [RK3228_PD_SYS] = DOMAIN_RK3036(BIT(3), BIT(3), BIT(19), true),
1302
- [RK3228_PD_VIO] = DOMAIN_RK3036(BIT(4), BIT(4), BIT(20), false),
1303
- [RK3228_PD_VOP] = DOMAIN_RK3036(BIT(5), BIT(5), BIT(21), false),
1304
- [RK3228_PD_VPU] = DOMAIN_RK3036(BIT(6), BIT(6), BIT(22), false),
1305
- [RK3228_PD_RKVDEC] = DOMAIN_RK3036(BIT(7), BIT(7), BIT(23), false),
1306
- [RK3228_PD_GPU] = DOMAIN_RK3036(BIT(8), BIT(8), BIT(24), false),
1307
- [RK3228_PD_PERI] = DOMAIN_RK3036(BIT(9), BIT(9), BIT(25), true),
1308
- [RK3228_PD_GMAC] = DOMAIN_RK3036(BIT(10), BIT(10), BIT(26), false),
1693
+ [RK3228_PD_CORE] = DOMAIN_RK3036("core", BIT(0), BIT(0), BIT(16), true),
1694
+ [RK3228_PD_MSCH] = DOMAIN_RK3036("msch", BIT(1), BIT(1), BIT(17), true),
1695
+ [RK3228_PD_BUS] = DOMAIN_RK3036("bus", BIT(2), BIT(2), BIT(18), true),
1696
+ [RK3228_PD_SYS] = DOMAIN_RK3036("sys", BIT(3), BIT(3), BIT(19), true),
1697
+ [RK3228_PD_VIO] = DOMAIN_RK3036("vio", BIT(4), BIT(4), BIT(20), false),
1698
+ [RK3228_PD_VOP] = DOMAIN_RK3036("vop", BIT(5), BIT(5), BIT(21), false),
1699
+ [RK3228_PD_VPU] = DOMAIN_RK3036("vpu", BIT(6), BIT(6), BIT(22), false),
1700
+ [RK3228_PD_RKVDEC] = DOMAIN_RK3036("vdec", BIT(7), BIT(7), BIT(23), false),
1701
+ [RK3228_PD_GPU] = DOMAIN_RK3036("gpu", BIT(8), BIT(8), BIT(24), false),
1702
+ [RK3228_PD_PERI] = DOMAIN_RK3036("peri", BIT(9), BIT(9), BIT(25), true),
1703
+ [RK3228_PD_GMAC] = DOMAIN_RK3036("gmac", BIT(10), BIT(10), BIT(26), false),
13091704 };
13101705
13111706 static const struct rockchip_domain_info rk3288_pm_domains[] = {
1312
- [RK3288_PD_VIO] = DOMAIN_RK3288_PROTECT(BIT(7), BIT(7), BIT(4), false),
1313
- [RK3288_PD_HEVC] = DOMAIN_RK3288(BIT(14), BIT(10), BIT(9), false),
1314
- [RK3288_PD_VIDEO] = DOMAIN_RK3288(BIT(8), BIT(8), BIT(3), false),
1315
- [RK3288_PD_GPU] = DOMAIN_RK3288(BIT(9), BIT(9), BIT(2), false),
1707
+ [RK3288_PD_VIO] = DOMAIN_RK3288_PROTECT("vio", BIT(7), BIT(7), BIT(4), false),
1708
+ [RK3288_PD_HEVC] = DOMAIN_RK3288("hevc", BIT(14), BIT(10), BIT(9), false),
1709
+ [RK3288_PD_VIDEO] = DOMAIN_RK3288("video", BIT(8), BIT(8), BIT(3), false),
1710
+ [RK3288_PD_GPU] = DOMAIN_RK3288("gpu", BIT(9), BIT(9), BIT(2), false),
13161711 };
13171712
13181713 static const struct rockchip_domain_info rk3328_pm_domains[] = {
1319
- [RK3328_PD_CORE] = DOMAIN_RK3328(0, BIT(0), BIT(0), false),
1320
- [RK3328_PD_GPU] = DOMAIN_RK3328(0, BIT(1), BIT(1), false),
1321
- [RK3328_PD_BUS] = DOMAIN_RK3328(0, BIT(2), BIT(2), true),
1322
- [RK3328_PD_MSCH] = DOMAIN_RK3328(0, BIT(3), BIT(3), true),
1323
- [RK3328_PD_PERI] = DOMAIN_RK3328(0, BIT(4), BIT(4), true),
1324
- [RK3328_PD_VIDEO] = DOMAIN_RK3328(0, BIT(5), BIT(5), false),
1325
- [RK3328_PD_HEVC] = DOMAIN_RK3328(0, BIT(6), BIT(6), false),
1326
- [RK3328_PD_VIO] = DOMAIN_RK3328(0, BIT(8), BIT(8), false),
1327
- [RK3328_PD_VPU] = DOMAIN_RK3328(0, BIT(9), BIT(9), false),
1714
+ [RK3328_PD_CORE] = DOMAIN_RK3328("core", 0, BIT(0), BIT(0), false),
1715
+ [RK3328_PD_GPU] = DOMAIN_RK3328("gpu", 0, BIT(1), BIT(1), false),
1716
+ [RK3328_PD_BUS] = DOMAIN_RK3328("bus", 0, BIT(2), BIT(2), true),
1717
+ [RK3328_PD_MSCH] = DOMAIN_RK3328("msch", 0, BIT(3), BIT(3), true),
1718
+ [RK3328_PD_PERI] = DOMAIN_RK3328("peri", 0, BIT(4), BIT(4), true),
1719
+ [RK3328_PD_VIDEO] = DOMAIN_RK3328("video", 0, BIT(5), BIT(5), false),
1720
+ [RK3328_PD_HEVC] = DOMAIN_RK3328("hevc", 0, BIT(6), BIT(6), false),
1721
+ [RK3328_PD_VIO] = DOMAIN_RK3328("vio", 0, BIT(8), BIT(8), false),
1722
+ [RK3328_PD_VPU] = DOMAIN_RK3328("vpu", 0, BIT(9), BIT(9), false),
13281723 };
13291724
13301725 static const struct rockchip_domain_info rk3366_pm_domains[] = {
1331
- [RK3366_PD_PERI] = DOMAIN_RK3368(BIT(10), BIT(10), BIT(6), true),
1332
- [RK3366_PD_VIO] = DOMAIN_RK3368_PROTECT(BIT(14), BIT(14), BIT(8), false),
1333
- [RK3366_PD_VIDEO] = DOMAIN_RK3368(BIT(13), BIT(13), BIT(7), false),
1334
- [RK3366_PD_RKVDEC] = DOMAIN_RK3368(BIT(11), BIT(11), BIT(7), false),
1335
- [RK3366_PD_WIFIBT] = DOMAIN_RK3368(BIT(8), BIT(8), BIT(9), false),
1336
- [RK3366_PD_VPU] = DOMAIN_RK3368(BIT(12), BIT(12), BIT(7), false),
1337
- [RK3366_PD_GPU] = DOMAIN_RK3368(BIT(15), BIT(15), BIT(2), false),
1726
+ [RK3366_PD_PERI] = DOMAIN_RK3368("peri", BIT(10), BIT(10), BIT(6), true),
1727
+ [RK3366_PD_VIO] = DOMAIN_RK3368_PROTECT("vio", BIT(14), BIT(14), BIT(8), false),
1728
+ [RK3366_PD_VIDEO] = DOMAIN_RK3368("video", BIT(13), BIT(13), BIT(7), false),
1729
+ [RK3366_PD_RKVDEC] = DOMAIN_RK3368("rkvdec", BIT(11), BIT(11), BIT(7), false),
1730
+ [RK3366_PD_WIFIBT] = DOMAIN_RK3368("wifibt", BIT(8), BIT(8), BIT(9), false),
1731
+ [RK3366_PD_VPU] = DOMAIN_RK3368("vpu", BIT(12), BIT(12), BIT(7), false),
1732
+ [RK3366_PD_GPU] = DOMAIN_RK3368("gpu", BIT(15), BIT(15), BIT(2), false),
13381733 };
13391734
13401735 static const struct rockchip_domain_info rk3368_pm_domains[] = {
1341
- [RK3368_PD_PERI] = DOMAIN_RK3368(BIT(13), BIT(12), BIT(6), true),
1342
- [RK3368_PD_VIO] = DOMAIN_RK3368_PROTECT(BIT(15), BIT(14), BIT(8), false),
1343
- [RK3368_PD_VIDEO] = DOMAIN_RK3368(BIT(14), BIT(13), BIT(7), false),
1344
- [RK3368_PD_GPU_0] = DOMAIN_RK3368(BIT(16), BIT(15), BIT(2), false),
1345
- [RK3368_PD_GPU_1] = DOMAIN_RK3368(BIT(17), BIT(16), BIT(2), false),
1736
+ [RK3368_PD_PERI] = DOMAIN_RK3368("peri", BIT(13), BIT(12), BIT(6), true),
1737
+ [RK3368_PD_VIO] = DOMAIN_RK3368_PROTECT("vio", BIT(15), BIT(14), BIT(8), false),
1738
+ [RK3368_PD_VIDEO] = DOMAIN_RK3368("video", BIT(14), BIT(13), BIT(7), false),
1739
+ [RK3368_PD_GPU_0] = DOMAIN_RK3368("gpu_0", BIT(16), BIT(15), BIT(2), false),
1740
+ [RK3368_PD_GPU_1] = DOMAIN_RK3368("gpu_1", BIT(17), BIT(16), BIT(2), false),
13461741 };
13471742
13481743 static const struct rockchip_domain_info rk3399_pm_domains[] = {
1349
- [RK3399_PD_TCPD0] = DOMAIN_RK3399(BIT(8), BIT(8), 0, false),
1350
- [RK3399_PD_TCPD1] = DOMAIN_RK3399(BIT(9), BIT(9), 0, false),
1351
- [RK3399_PD_CCI] = DOMAIN_RK3399(BIT(10), BIT(10), 0, true),
1352
- [RK3399_PD_CCI0] = DOMAIN_RK3399(0, 0, BIT(15), true),
1353
- [RK3399_PD_CCI1] = DOMAIN_RK3399(0, 0, BIT(16), true),
1354
- [RK3399_PD_PERILP] = DOMAIN_RK3399(BIT(11), BIT(11), BIT(1), true),
1355
- [RK3399_PD_PERIHP] = DOMAIN_RK3399(BIT(12), BIT(12), BIT(2), true),
1356
- [RK3399_PD_CENTER] = DOMAIN_RK3399(BIT(13), BIT(13), BIT(14), true),
1357
- [RK3399_PD_VIO] = DOMAIN_RK3399_PROTECT(BIT(14), BIT(14), BIT(17), false),
1358
- [RK3399_PD_GPU] = DOMAIN_RK3399(BIT(15), BIT(15), BIT(0), false),
1359
- [RK3399_PD_VCODEC] = DOMAIN_RK3399(BIT(16), BIT(16), BIT(3), false),
1360
- [RK3399_PD_VDU] = DOMAIN_RK3399(BIT(17), BIT(17), BIT(4), false),
1361
- [RK3399_PD_RGA] = DOMAIN_RK3399(BIT(18), BIT(18), BIT(5), false),
1362
- [RK3399_PD_IEP] = DOMAIN_RK3399(BIT(19), BIT(19), BIT(6), false),
1363
- [RK3399_PD_VO] = DOMAIN_RK3399_PROTECT(BIT(20), BIT(20), 0, false),
1364
- [RK3399_PD_VOPB] = DOMAIN_RK3399_PROTECT(0, 0, BIT(7), false),
1365
- [RK3399_PD_VOPL] = DOMAIN_RK3399_PROTECT(0, 0, BIT(8), false),
1366
- [RK3399_PD_ISP0] = DOMAIN_RK3399(BIT(22), BIT(22), BIT(9), false),
1367
- [RK3399_PD_ISP1] = DOMAIN_RK3399(BIT(23), BIT(23), BIT(10), false),
1368
- [RK3399_PD_HDCP] = DOMAIN_RK3399_PROTECT(BIT(24), BIT(24), BIT(11), false),
1369
- [RK3399_PD_GMAC] = DOMAIN_RK3399(BIT(25), BIT(25), BIT(23), true),
1370
- [RK3399_PD_EMMC] = DOMAIN_RK3399(BIT(26), BIT(26), BIT(24), true),
1371
- [RK3399_PD_USB3] = DOMAIN_RK3399(BIT(27), BIT(27), BIT(12), true),
1372
- [RK3399_PD_EDP] = DOMAIN_RK3399_PROTECT(BIT(28), BIT(28), BIT(22), false),
1373
- [RK3399_PD_GIC] = DOMAIN_RK3399(BIT(29), BIT(29), BIT(27), true),
1374
- [RK3399_PD_SD] = DOMAIN_RK3399(BIT(30), BIT(30), BIT(28), true),
1375
- [RK3399_PD_SDIOAUDIO] = DOMAIN_RK3399(BIT(31), BIT(31), BIT(29), true),
1744
+ [RK3399_PD_TCPD0] = DOMAIN_RK3399("tcpd0", BIT(8), BIT(8), 0, false),
1745
+ [RK3399_PD_TCPD1] = DOMAIN_RK3399("tcpd1", BIT(9), BIT(9), 0, false),
1746
+ [RK3399_PD_CCI] = DOMAIN_RK3399("cci", BIT(10), BIT(10), 0, true),
1747
+ [RK3399_PD_CCI0] = DOMAIN_RK3399("cci0", 0, 0, BIT(15), true),
1748
+ [RK3399_PD_CCI1] = DOMAIN_RK3399("cci1", 0, 0, BIT(16), true),
1749
+ [RK3399_PD_PERILP] = DOMAIN_RK3399("perilp", BIT(11), BIT(11), BIT(1), true),
1750
+ [RK3399_PD_PERIHP] = DOMAIN_RK3399("perihp", BIT(12), BIT(12), BIT(2), true),
1751
+ [RK3399_PD_CENTER] = DOMAIN_RK3399("center", BIT(13), BIT(13), BIT(14), true),
1752
+ [RK3399_PD_VIO] = DOMAIN_RK3399_PROTECT("vio", BIT(14), BIT(14), BIT(17), false),
1753
+ [RK3399_PD_GPU] = DOMAIN_RK3399("gpu", BIT(15), BIT(15), BIT(0), false),
1754
+ [RK3399_PD_VCODEC] = DOMAIN_RK3399("vcodec", BIT(16), BIT(16), BIT(3), false),
1755
+ [RK3399_PD_VDU] = DOMAIN_RK3399("vdu", BIT(17), BIT(17), BIT(4), false),
1756
+ [RK3399_PD_RGA] = DOMAIN_RK3399("rga", BIT(18), BIT(18), BIT(5), false),
1757
+ [RK3399_PD_IEP] = DOMAIN_RK3399("iep", BIT(19), BIT(19), BIT(6), false),
1758
+ [RK3399_PD_VO] = DOMAIN_RK3399_PROTECT("vo", BIT(20), BIT(20), 0, false),
1759
+ [RK3399_PD_VOPB] = DOMAIN_RK3399_PROTECT("vopb", 0, 0, BIT(7), false),
1760
+ [RK3399_PD_VOPL] = DOMAIN_RK3399_PROTECT("vopl", 0, 0, BIT(8), false),
1761
+ [RK3399_PD_ISP0] = DOMAIN_RK3399("isp0", BIT(22), BIT(22), BIT(9), false),
1762
+ [RK3399_PD_ISP1] = DOMAIN_RK3399("isp1", BIT(23), BIT(23), BIT(10), false),
1763
+ [RK3399_PD_HDCP] = DOMAIN_RK3399_PROTECT("hdcp", BIT(24), BIT(24), BIT(11), false),
1764
+ [RK3399_PD_GMAC] = DOMAIN_RK3399("gmac", BIT(25), BIT(25), BIT(23), true),
1765
+ [RK3399_PD_EMMC] = DOMAIN_RK3399("emmc", BIT(26), BIT(26), BIT(24), true),
1766
+ [RK3399_PD_USB3] = DOMAIN_RK3399("usb3", BIT(27), BIT(27), BIT(12), true),
1767
+ [RK3399_PD_EDP] = DOMAIN_RK3399_PROTECT("edp", BIT(28), BIT(28), BIT(22), false),
1768
+ [RK3399_PD_GIC] = DOMAIN_RK3399("gic", BIT(29), BIT(29), BIT(27), true),
1769
+ [RK3399_PD_SD] = DOMAIN_RK3399("sd", BIT(30), BIT(30), BIT(28), true),
1770
+ [RK3399_PD_SDIOAUDIO] = DOMAIN_RK3399("sdioaudio", BIT(31), BIT(31), BIT(29), true),
13761771 };
13771772
13781773 static const struct rockchip_domain_info rk3528_pm_domains[] = {
....@@ -1387,16 +1782,60 @@
13871782 [RK3528_PD_VPU] = DOMAIN_RK3528(0, BIT(8), true, false),
13881783 };
13891784
1785
+static const struct rockchip_domain_info rk3562_pm_domains[] = {
1786
+ [RK3562_PD_GPU] = DOMAIN_RK3562("gpu", BIT(0), BIT(1), 0, false),
1787
+ [RK3562_PD_NPU] = DOMAIN_RK3562("npu", BIT(1), BIT(2), 0, false),
1788
+ [RK3562_PD_VDPU] = DOMAIN_RK3562("vdpu", BIT(2), BIT(6), 0, false),
1789
+ [RK3562_PD_VEPU] = DOMAIN_RK3562("vepu", BIT(3), BIT(7), 0, false),
1790
+ [RK3562_PD_RGA] = DOMAIN_RK3562("rga", BIT(4), BIT(5), 0, false),
1791
+ [RK3562_PD_VI] = DOMAIN_RK3562("vi", BIT(5), BIT(3), 0, false),
1792
+ [RK3562_PD_VO] = DOMAIN_RK3562_PROTECT("vo", BIT(6), BIT(4), 16, false),
1793
+ [RK3562_PD_PHP] = DOMAIN_RK3562("php", BIT(7), BIT(8), 0, false),
1794
+};
1795
+
13901796 static const struct rockchip_domain_info rk3568_pm_domains[] = {
1391
- [RK3568_PD_NPU] = DOMAIN_RK3568(BIT(1), BIT(2), false),
1392
- [RK3568_PD_GPU] = DOMAIN_RK3568(BIT(0), BIT(1), false),
1393
- [RK3568_PD_VI] = DOMAIN_RK3568(BIT(6), BIT(3), false),
1394
- [RK3568_PD_VO] = DOMAIN_RK3568_PROTECT(BIT(7), BIT(4), false),
1395
- [RK3568_PD_RGA] = DOMAIN_RK3568(BIT(5), BIT(5), false),
1396
- [RK3568_PD_VPU] = DOMAIN_RK3568(BIT(2), BIT(6), false),
1397
- [RK3568_PD_RKVDEC] = DOMAIN_RK3568(BIT(4), BIT(8), false),
1398
- [RK3568_PD_RKVENC] = DOMAIN_RK3568(BIT(3), BIT(7), false),
1399
- [RK3568_PD_PIPE] = DOMAIN_RK3568(BIT(8), BIT(11), false),
1797
+ [RK3568_PD_NPU] = DOMAIN_RK3568("npu", BIT(1), BIT(2), false),
1798
+ [RK3568_PD_GPU] = DOMAIN_RK3568("gpu", BIT(0), BIT(1), false),
1799
+ [RK3568_PD_VI] = DOMAIN_RK3568("vi", BIT(6), BIT(3), false),
1800
+ [RK3568_PD_VO] = DOMAIN_RK3568_PROTECT("vo", BIT(7), BIT(4), false),
1801
+ [RK3568_PD_RGA] = DOMAIN_RK3568("rga", BIT(5), BIT(5), false),
1802
+ [RK3568_PD_VPU] = DOMAIN_RK3568("vpu", BIT(2), BIT(6), false),
1803
+ [RK3568_PD_RKVDEC] = DOMAIN_RK3568("rkvdec", BIT(4), BIT(8), false),
1804
+ [RK3568_PD_RKVENC] = DOMAIN_RK3568("rkvenc", BIT(3), BIT(7), false),
1805
+ [RK3568_PD_PIPE] = DOMAIN_RK3568("pipe", BIT(8), BIT(11), false),
1806
+};
1807
+
1808
+static const struct rockchip_domain_info rk3588_pm_domains[] = {
1809
+ /* name p_offset pwr status m_offset m_status r_status r_offset req idle wakeup */
1810
+ [RK3588_PD_GPU] = DOMAIN_RK3588("gpu", 0x0, BIT(0), 0, 0x0, 0, BIT(1), 0x0, BIT(0), BIT(0), false),
1811
+ [RK3588_PD_NPU] = DOMAIN_RK3588("npu", 0x0, BIT(1), BIT(1), 0x0, 0, 0, 0x0, 0, 0, false),
1812
+ [RK3588_PD_VCODEC] = DOMAIN_RK3588("vcodec", 0x0, BIT(2), BIT(2), 0x0, 0, 0, 0x0, 0, 0, false),
1813
+ [RK3588_PD_NPUTOP] = DOMAIN_RK3588("nputop", 0x0, BIT(3), 0, 0x0, BIT(11), BIT(2), 0x0, BIT(1), BIT(1), false),
1814
+ [RK3588_PD_NPU1] = DOMAIN_RK3588("npu1", 0x0, BIT(4), 0, 0x0, BIT(12), BIT(3), 0x0, BIT(2), BIT(2), false),
1815
+ [RK3588_PD_NPU2] = DOMAIN_RK3588("npu2", 0x0, BIT(5), 0, 0x0, BIT(13), BIT(4), 0x0, BIT(3), BIT(3), false),
1816
+ [RK3588_PD_VENC0] = DOMAIN_RK3588("venc0", 0x0, BIT(6), 0, 0x0, BIT(14), BIT(5), 0x0, BIT(4), BIT(4), false),
1817
+ [RK3588_PD_VENC1] = DOMAIN_RK3588("venc1", 0x0, BIT(7), 0, 0x0, BIT(15), BIT(6), 0x0, BIT(5), BIT(5), false),
1818
+ [RK3588_PD_RKVDEC0] = DOMAIN_RK3588("rkvdec0", 0x0, BIT(8), 0, 0x0, BIT(16), BIT(7), 0x0, BIT(6), BIT(6), false),
1819
+ [RK3588_PD_RKVDEC1] = DOMAIN_RK3588("rkvdec1", 0x0, BIT(9), 0, 0x0, BIT(17), BIT(8), 0x0, BIT(7), BIT(7), false),
1820
+ [RK3588_PD_VDPU] = DOMAIN_RK3588("vdpu", 0x0, BIT(10), 0, 0x0, BIT(18), BIT(9), 0x0, BIT(8), BIT(8), false),
1821
+ [RK3588_PD_RGA30] = DOMAIN_RK3588("rga30", 0x0, BIT(11), 0, 0x0, BIT(19), BIT(10), 0x0, 0, 0, false),
1822
+ [RK3588_PD_AV1] = DOMAIN_RK3588("av1", 0x0, BIT(12), 0, 0x0, BIT(20), BIT(11), 0x0, BIT(9), BIT(9), false),
1823
+ [RK3588_PD_VI] = DOMAIN_RK3588("vi", 0x0, BIT(13), 0, 0x0, BIT(21), BIT(12), 0x0, BIT(10), BIT(10), false),
1824
+ [RK3588_PD_FEC] = DOMAIN_RK3588("fec", 0x0, BIT(14), 0, 0x0, BIT(22), BIT(13), 0x0, 0, 0, false),
1825
+ [RK3588_PD_ISP1] = DOMAIN_RK3588("isp1", 0x0, BIT(15), 0, 0x0, BIT(23), BIT(14), 0x0, BIT(11), BIT(11), false),
1826
+ [RK3588_PD_RGA31] = DOMAIN_RK3588("rga31", 0x4, BIT(0), 0, 0x0, BIT(24), BIT(15), 0x0, BIT(12), BIT(12), false),
1827
+ [RK3588_PD_VOP] = DOMAIN_RK3588_P("vop", 0x4, BIT(1), 0, 0x0, BIT(25), BIT(16), 0x0, BIT(13) | BIT(14), BIT(13) | BIT(14), false),
1828
+ [RK3588_PD_VO0] = DOMAIN_RK3588_P("vo0", 0x4, BIT(2), 0, 0x0, BIT(26), BIT(17), 0x0, BIT(15), BIT(15), false),
1829
+ [RK3588_PD_VO1] = DOMAIN_RK3588_P("vo1", 0x4, BIT(3), 0, 0x0, BIT(27), BIT(18), 0x4, BIT(0), BIT(16), false),
1830
+ [RK3588_PD_AUDIO] = DOMAIN_RK3588("audio", 0x4, BIT(4), 0, 0x0, BIT(28), BIT(19), 0x4, BIT(1), BIT(17), false),
1831
+ [RK3588_PD_PHP] = DOMAIN_RK3588("php", 0x4, BIT(5), 0, 0x0, BIT(29), BIT(20), 0x4, BIT(5), BIT(21), false),
1832
+ [RK3588_PD_GMAC] = DOMAIN_RK3588("gmac", 0x4, BIT(6), 0, 0x0, BIT(30), BIT(21), 0x0, 0, 0, false),
1833
+ [RK3588_PD_PCIE] = DOMAIN_RK3588("pcie", 0x4, BIT(7), 0, 0x0, BIT(31), BIT(22), 0x0, 0, 0, true),
1834
+ [RK3588_PD_NVM] = DOMAIN_RK3588("nvm", 0x4, BIT(8), BIT(24), 0x4, 0, 0, 0x4, BIT(2), BIT(18), false),
1835
+ [RK3588_PD_NVM0] = DOMAIN_RK3588("nvm0", 0x4, BIT(9), 0, 0x4, BIT(1), BIT(23), 0x0, 0, 0, false),
1836
+ [RK3588_PD_SDIO] = DOMAIN_RK3588("sdio", 0x4, BIT(10), 0, 0x4, BIT(2), BIT(24), 0x4, BIT(3), BIT(19), false),
1837
+ [RK3588_PD_USB] = DOMAIN_RK3588("usb", 0x4, BIT(11), 0, 0x4, BIT(3), BIT(25), 0x4, BIT(4), BIT(20), true),
1838
+ [RK3588_PD_SDMMC] = DOMAIN_RK3588("sdmmc", 0x4, BIT(13), 0, 0x4, BIT(5), BIT(26), 0x0, 0, 0, false),
14001839 };
14011840
14021841 static const struct rockchip_pmu_info px30_pmu = {
....@@ -1408,17 +1847,6 @@
14081847
14091848 .num_domains = ARRAY_SIZE(px30_pm_domains),
14101849 .domain_info = px30_pm_domains,
1411
-};
1412
-
1413
-static const struct rockchip_pmu_info rv1126_pmu = {
1414
- .pwr_offset = 0x110,
1415
- .status_offset = 0x108,
1416
- .req_offset = 0xc0,
1417
- .idle_offset = 0xd8,
1418
- .ack_offset = 0xd0,
1419
-
1420
- .num_domains = ARRAY_SIZE(rv1126_pm_domains),
1421
- .domain_info = rv1126_pm_domains,
14221850 };
14231851
14241852 static const struct rockchip_pmu_info rk1808_pmu = {
....@@ -1441,6 +1869,17 @@
14411869 .domain_info = rk3036_pm_domains,
14421870 };
14431871
1872
+static const struct rockchip_pmu_info rk3066_pmu = {
1873
+ .pwr_offset = 0x08,
1874
+ .status_offset = 0x0c,
1875
+ .req_offset = 0x38, /* PMU_MISC_CON1 */
1876
+ .idle_offset = 0x0c,
1877
+ .ack_offset = 0x0c,
1878
+
1879
+ .num_domains = ARRAY_SIZE(rk3066_pm_domains),
1880
+ .domain_info = rk3066_pm_domains,
1881
+};
1882
+
14441883 static const struct rockchip_pmu_info rk3128_pmu = {
14451884 .pwr_offset = 0x04,
14461885 .status_offset = 0x08,
....@@ -1450,6 +1889,17 @@
14501889
14511890 .num_domains = ARRAY_SIZE(rk3128_pm_domains),
14521891 .domain_info = rk3128_pm_domains,
1892
+};
1893
+
1894
+static const struct rockchip_pmu_info rk3188_pmu = {
1895
+ .pwr_offset = 0x08,
1896
+ .status_offset = 0x0c,
1897
+ .req_offset = 0x38, /* PMU_MISC_CON1 */
1898
+ .idle_offset = 0x0c,
1899
+ .ack_offset = 0x0c,
1900
+
1901
+ .num_domains = ARRAY_SIZE(rk3188_pm_domains),
1902
+ .domain_info = rk3188_pm_domains,
14531903 };
14541904
14551905 static const struct rockchip_pmu_info rk3228_pmu = {
....@@ -1528,11 +1978,7 @@
15281978 .idle_offset = 0x64,
15291979 .ack_offset = 0x68,
15301980
1531
- .core_pwrcnt_offset = 0xac,
1532
- .gpu_pwrcnt_offset = 0xac,
1533
-
1534
- .core_power_transition_time = 6, /* 0.25us */
1535
- .gpu_power_transition_time = 6, /* 0.25us */
1981
+ /* ARM Trusted Firmware manages power transition times */
15361982
15371983 .num_domains = ARRAY_SIZE(rk3399_pm_domains),
15381984 .domain_info = rk3399_pm_domains,
....@@ -1549,6 +1995,19 @@
15491995 .domain_info = rk3528_pm_domains,
15501996 };
15511997
1998
+static const struct rockchip_pmu_info rk3562_pmu = {
1999
+ .pwr_offset = 0x210,
2000
+ .status_offset = 0x230,
2001
+ .req_offset = 0x110,
2002
+ .idle_offset = 0x128,
2003
+ .ack_offset = 0x120,
2004
+ .clk_ungate_offset = 0x140,
2005
+ .mem_sd_offset = 0x300,
2006
+
2007
+ .num_domains = ARRAY_SIZE(rk3562_pm_domains),
2008
+ .domain_info = rk3562_pm_domains,
2009
+};
2010
+
15522011 static const struct rockchip_pmu_info rk3568_pmu = {
15532012 .pwr_offset = 0xa0,
15542013 .status_offset = 0x98,
....@@ -1560,85 +2019,103 @@
15602019 .domain_info = rk3568_pm_domains,
15612020 };
15622021
2022
+static const struct rockchip_pmu_info rk3588_pmu = {
2023
+ .pwr_offset = 0x14c,
2024
+ .status_offset = 0x180,
2025
+ .req_offset = 0x10c,
2026
+ .idle_offset = 0x120,
2027
+ .ack_offset = 0x118,
2028
+ .mem_pwr_offset = 0x1a0,
2029
+ .chain_status_offset = 0x1f0,
2030
+ .mem_status_offset = 0x1f8,
2031
+ .repair_status_offset = 0x290,
2032
+
2033
+ .num_domains = ARRAY_SIZE(rk3588_pm_domains),
2034
+ .domain_info = rk3588_pm_domains,
2035
+};
2036
+
2037
+static const struct rockchip_pmu_info rv1126_pmu = {
2038
+ .pwr_offset = 0x110,
2039
+ .status_offset = 0x108,
2040
+ .req_offset = 0xc0,
2041
+ .idle_offset = 0xd8,
2042
+ .ack_offset = 0xd0,
2043
+
2044
+ .num_domains = ARRAY_SIZE(rv1126_pm_domains),
2045
+ .domain_info = rv1126_pm_domains,
2046
+};
2047
+
15632048 static const struct of_device_id rockchip_pm_domain_dt_match[] = {
1564
-#ifdef CONFIG_CPU_PX30
15652049 {
15662050 .compatible = "rockchip,px30-power-controller",
15672051 .data = (void *)&px30_pmu,
15682052 },
1569
-#endif
1570
-#ifdef CONFIG_CPU_RV1126
1571
- {
1572
- .compatible = "rockchip,rv1126-power-controller",
1573
- .data = (void *)&rv1126_pmu,
1574
- },
1575
-#endif
1576
-#ifdef CONFIG_CPU_RK1808
15772053 {
15782054 .compatible = "rockchip,rk1808-power-controller",
15792055 .data = (void *)&rk1808_pmu,
15802056 },
1581
-#endif
1582
-#ifdef CONFIG_CPU_RK3036
15832057 {
15842058 .compatible = "rockchip,rk3036-power-controller",
15852059 .data = (void *)&rk3036_pmu,
15862060 },
1587
-#endif
1588
-#ifdef CONFIG_CPU_RK312X
2061
+ {
2062
+ .compatible = "rockchip,rk3066-power-controller",
2063
+ .data = (void *)&rk3066_pmu,
2064
+ },
15892065 {
15902066 .compatible = "rockchip,rk3128-power-controller",
15912067 .data = (void *)&rk3128_pmu,
15922068 },
1593
-#endif
1594
-#ifdef CONFIG_CPU_RK322X
2069
+ {
2070
+ .compatible = "rockchip,rk3188-power-controller",
2071
+ .data = (void *)&rk3188_pmu,
2072
+ },
15952073 {
15962074 .compatible = "rockchip,rk3228-power-controller",
15972075 .data = (void *)&rk3228_pmu,
15982076 },
1599
-#endif
1600
-#ifdef CONFIG_CPU_RK3288
16012077 {
16022078 .compatible = "rockchip,rk3288-power-controller",
16032079 .data = (void *)&rk3288_pmu,
16042080 },
1605
-#endif
1606
-#ifdef CONFIG_CPU_RK3328
16072081 {
16082082 .compatible = "rockchip,rk3328-power-controller",
16092083 .data = (void *)&rk3328_pmu,
16102084 },
1611
-#endif
1612
-#ifdef CONFIG_CPU_RK3366
16132085 {
16142086 .compatible = "rockchip,rk3366-power-controller",
16152087 .data = (void *)&rk3366_pmu,
16162088 },
1617
-#endif
1618
-#ifdef CONFIG_CPU_RK3368
16192089 {
16202090 .compatible = "rockchip,rk3368-power-controller",
16212091 .data = (void *)&rk3368_pmu,
16222092 },
1623
-#endif
1624
-#ifdef CONFIG_CPU_RK3399
16252093 {
16262094 .compatible = "rockchip,rk3399-power-controller",
16272095 .data = (void *)&rk3399_pmu,
16282096 },
1629
-#endif
16302097 #ifdef CONFIG_CPU_RK3528
16312098 {
16322099 .compatible = "rockchip,rk3528-power-controller",
16332100 .data = (void *)&rk3528_pmu,
16342101 },
16352102 #endif
1636
-#ifdef CONFIG_CPU_RK3568
2103
+ {
2104
+ .compatible = "rockchip,rk3562-power-controller",
2105
+ .data = (void *)&rk3562_pmu,
2106
+ },
16372107 {
16382108 .compatible = "rockchip,rk3568-power-controller",
16392109 .data = (void *)&rk3568_pmu,
16402110 },
1641
-#endif
2111
+ {
2112
+ .compatible = "rockchip,rk3588-power-controller",
2113
+ .data = (void *)&rk3588_pmu,
2114
+ },
2115
+ {
2116
+ .compatible = "rockchip,rv1126-power-controller",
2117
+ .data = (void *)&rv1126_pmu,
2118
+ },
16422119 { /* sentinel */ },
16432120 };
16442121 MODULE_DEVICE_TABLE(of, rockchip_pm_domain_dt_match);
....@@ -1671,4 +2148,3 @@
16712148
16722149 MODULE_DESCRIPTION("ROCKCHIP PM Domain Driver");
16732150 MODULE_LICENSE("GPL");
1674
-MODULE_ALIAS("platform:rockchip-pm-domain");