11/* SPDX-License-Identifier: MIT */
22
33#include "adt.h"
4+ #include "dart.h"
45#include "pmgr.h"
56#include "utils.h"
67
@@ -21,6 +22,27 @@ 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+
2446int isp_init (void )
2547{
2648 int err = 0 ;
@@ -37,6 +59,23 @@ int isp_init(void)
3759 return -1 ;
3860 }
3961
62+ enum dart_type_t type ;
63+ const char * type_s ;
64+ if (adt_is_compatible (adt , node , "dart,t8020" )) {
65+ type = DART_T8020 ;
66+ type_s = "t8020" ;
67+ } else if (adt_is_compatible (adt , node , "dart,t6000" )) {
68+ type = DART_T6000 ;
69+ type_s = "t6000" ;
70+ } else if (adt_is_compatible (adt , node , "dart,t8110" )) {
71+ type = DART_T8110 ;
72+ type_s = "t8110" ;
73+ } else {
74+ printf ("isp: dart %s is of an unknown type\n" , dart_path );
75+ return -1 ;
76+ }
77+ printf ("isp: found dart type: %s\n" , type_s );
78+
4079 int dart_domain_count = 3 ; // TODO get from dt
4180 for (int index = 0 ; index < dart_domain_count ; index ++ ) {
4281 u64 base ;
@@ -58,23 +97,15 @@ int isp_init(void)
5897 if (err < 0 )
5998 goto out ;
6099
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 ++ ;
100+ switch (type ) {
101+ case DART_T8020 :
102+ isp_ctrr_init_t8020 (base , config , length );
103+ break ;
104+ case DART_T8110 :
105+ break ;
106+ case DART_T6000 :
107+ break ;
74108 }
75-
76- write32 (base + DART_T8020_TCR_OFF , DART_T8020_TCR_TRANSLATE_ENABLE );
77- write32 (base + 0x13c , 0x20000 );
78109 }
79110
80111out :
0 commit comments