Skip to content

Commit d8cecca

Browse files
committed
isp/kboot: Prelim T6000 support
Handle /arm-io/isp0 and diff CTRR writes. Signed-off-by: Eileen Yoon <eyn@gmx.com>
1 parent 0098f4a commit d8cecca

File tree

2 files changed

+83
-28
lines changed

2 files changed

+83
-28
lines changed

src/isp.c

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: MIT */
22

33
#include "adt.h"
4+
#include "dart.h"
45
#include "pmgr.h"
56
#include "utils.h"
67

@@ -21,19 +22,79 @@ struct dart_tunables {
2122
u64 set;
2223
};
2324

25+
static void isp_ctrr_init_t8020(u64 base, const struct dart_tunables *config, u32 length)
26+
{
27+
/* DART error handler gets stuck w/o these */
28+
write32(base + DART_T8020_ENABLED_STREAMS, 0x1);
29+
write32(base + 0x2f0, 0x0);
30+
write32(base + DART_T8020_STREAM_SELECT, 0xffffffff);
31+
write32(base + DART_T8020_STREAM_COMMAND, DART_T8020_STREAM_COMMAND_INVALIDATE);
32+
33+
/* I think these lock CTRR? Configurable __TEXT read-only region? */
34+
int count = length / sizeof(*config);
35+
for (int i = 0; i < count; i++) {
36+
u64 offset = config->offset & 0xffff;
37+
u32 set = config->set & 0xffffffff;
38+
mask32(base + offset, read32(base + offset), set);
39+
config++;
40+
}
41+
42+
write32(base + DART_T8020_TCR_OFF, DART_T8020_TCR_TRANSLATE_ENABLE);
43+
write32(base + 0x13c, 0x20000);
44+
}
45+
46+
static void isp_ctrr_init_t6000(u64 base, const struct dart_tunables *config, u32 length)
47+
{
48+
write32(base + DART_T8020_ENABLED_STREAMS, 0x1);
49+
write32(base + 0x2f0, 0x0);
50+
write32(base + DART_T8020_STREAM_SELECT, 0xffff); // diff from t8020
51+
write32(base + DART_T8020_STREAM_COMMAND, 0x0);
52+
53+
int count = length / sizeof(*config);
54+
for (int i = 0; i < count; i++) {
55+
u64 offset = config->offset & 0xffff;
56+
u32 set = config->set & 0xffffffff;
57+
mask32(base + offset, read32(base + offset), set);
58+
config++;
59+
}
60+
61+
write32(base + DART_T8020_TCR_OFF, DART_T8020_TCR_TRANSLATE_ENABLE);
62+
write32(base + 0x13c, 0x20000);
63+
}
64+
2465
int isp_init(void)
2566
{
2667
int err = 0;
27-
const char *path = "/arm-io/isp";
28-
const char *dart_path = "/arm-io/dart-isp";
2968

30-
if (pmgr_adt_power_enable(path) < 0)
31-
return -1;
69+
const char *isp_path = "/arm-io/isp";
70+
const char *dart_path = "/arm-io/dart-isp";
3271

3372
int adt_path[8];
3473
int node = adt_path_offset_trace(adt, dart_path, adt_path);
3574
if (node < 0) {
36-
printf("isp: Error getting node %s\n", dart_path);
75+
isp_path = "/arm-io/isp0";
76+
dart_path = "/arm-io/dart-isp0";
77+
node = adt_path_offset_trace(adt, dart_path, adt_path);
78+
}
79+
if (node < 0)
80+
return 0;
81+
82+
if (pmgr_adt_power_enable(isp_path) < 0)
83+
return -1;
84+
85+
enum dart_type_t type;
86+
const char *type_s;
87+
if (adt_is_compatible(adt, node, "dart,t8020")) {
88+
type = DART_T8020;
89+
type_s = "t8020";
90+
} else if (adt_is_compatible(adt, node, "dart,t6000")) {
91+
type = DART_T6000;
92+
type_s = "t6000";
93+
} else if (adt_is_compatible(adt, node, "dart,t8110")) {
94+
type = DART_T8110;
95+
type_s = "t8110";
96+
} else {
97+
printf("isp: dart %s is of an unknown type\n", dart_path);
3798
return -1;
3899
}
39100

@@ -49,7 +110,7 @@ int isp_init(void)
49110
snprintf(prop, sizeof(prop), "dart-tunables-instance-%u", index);
50111
const struct dart_tunables *config = adt_getprop(adt, node, prop, &length);
51112
if (!config || !length) {
52-
printf("isp: Error getting ADT node %s property %s.\n", path, prop);
113+
printf("isp: Error getting ADT node %s property %s.\n", isp_path, prop);
53114
err = -1;
54115
goto out;
55116
}
@@ -58,26 +119,21 @@ int isp_init(void)
58119
if (err < 0)
59120
goto out;
60121

61-
/* DART error handler gets stuck w/o these */
62-
write32(base + DART_T8020_ENABLED_STREAMS, 0x1);
63-
write32(base + 0x2f0, 0x0);
64-
write32(base + DART_T8020_STREAM_SELECT, 0xffffffff);
65-
write32(base + DART_T8020_STREAM_COMMAND, DART_T8020_STREAM_COMMAND_INVALIDATE);
66-
67-
/* I think these lock CTRR? Coproc __TEXT read-only region? */
68-
int count = length / sizeof(*config);
69-
for (int i = 0; i < count; i++) {
70-
u64 offset = config->offset & 0xffff;
71-
u32 set = config->set & 0xffffffff;
72-
mask32(base + offset, read32(base + offset), set);
73-
config++;
122+
switch (type) {
123+
case DART_T8020:
124+
isp_ctrr_init_t8020(base, config, length);
125+
break;
126+
case DART_T6000:
127+
isp_ctrr_init_t6000(base, config, length);
128+
break;
129+
case DART_T8110:
130+
printf("isp: warning: dart type %s not tested yet!\n", type_s);
131+
isp_ctrr_init_t8020(base, config, length);
132+
break;
74133
}
75-
76-
write32(base + DART_T8020_TCR_OFF, DART_T8020_TCR_TRANSLATE_ENABLE);
77-
write32(base + 0x13c, 0x20000);
78134
}
79135

80136
out:
81-
pmgr_adt_power_disable(path);
137+
pmgr_adt_power_disable(isp_path);
82138
return err;
83139
}

src/kboot.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,13 +1803,12 @@ struct isp_segment_ranges {
18031803
static int dt_set_isp_fwdata(void)
18041804
{
18051805
const char *path = "isp";
1806-
const char *adt_path = "/arm-io/isp";
18071806

1808-
int adt_node = adt_path_offset(adt, adt_path);
1809-
if (adt_node < 0) {
1810-
printf("ADT: '%s' node not found\n", adt_path);
1807+
int adt_node = adt_path_offset(adt, "/arm-io/isp");
1808+
if (adt_node < 0)
1809+
adt_node = adt_path_offset(adt, "/arm-io/isp0");
1810+
if (adt_node < 0)
18111811
return 0;
1812-
}
18131812

18141813
u32 segments_len;
18151814
struct isp_segment_ranges *segments;

0 commit comments

Comments
 (0)