9 const INTSEL_MASK
uint32 = 0xffffff00
11 type template
func(string, *string, *string, *uint32, *uint32) int
13 // extractPadFuncFromComment
14 // line : string from file with pad config map
15 // return : pad function string
16 func extractPadFuncFromComment(line
string) string {
17 if !strings
.Contains(line
, "/*") && !strings
.Contains(line
, "*/") {
21 fields
:= strings
.Fields(line
)
22 for i
, field
:= range fields
{
23 if field
== "/*" && len(fields
) >= i
+2 {
31 func tokenCheck(c rune
) bool {
32 return c
!= '_' && c
!= '#' && !unicode
.IsLetter(c
) && !unicode
.IsNumber(c
)
36 // line : string from file with pad config map
37 // *function : the string that means the pad function
38 // *id : pad id string
39 // *dw0 : DW0 register value
40 // *dw1 : DW1 register value
43 func UseInteltoolLogTemplate(line
string, function
*string,
44 id
*string, dw0
*uint32, dw1
*uint32) int {
47 // 0x0520: 0x0000003c44000600 GPP_B12 SLP_S0#
48 // 0x0438: 0xffffffffffffffff GPP_C7 RESERVED
49 if fields
:= strings
.FieldsFunc(line
, tokenCheck
); len(fields
) >= 4 {
50 fmt
.Sscanf(fields
[1], "0x%x", &val
)
51 *dw0
= uint32(val
& 0xffffffff)
52 *dw1
= uint32(val
>> 32)
55 // Sometimes the configuration file contains compound functions such as
56 // SUSWARN#/SUSPWRDNACK. Since the template does not take this into account,
57 // need to collect all parts of the pad function back into a single word
58 for i
:= 4; i
< len(fields
); i
++ {
59 *function
+= "/" + fields
[i
]
61 // clear RO Interrupt Select (INTSEL)
68 // line : string from file with pad config map
69 // *function : the string that means the pad function
70 // *id : pad id string
71 // *dw0 : DW0 register value
72 // *dw1 : DW1 register value
75 func useGpioHTemplate(line
string, function
*string,
76 id
*string, dw0
*uint32, dw1
*uint32) int {
78 // /* RCIN# */ _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000),
79 // _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000), /* RCIN# */
80 // _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000)
81 fields
:= strings
.FieldsFunc(line
, tokenCheck
)
82 for i
, field
:= range fields
{
83 if field
== "_PAD_CFG_STRUCT" {
85 /* the number of definitions does not match the format */
89 if !strings
.Contains(fields
[i
+2], "0x") ||
!strings
.Contains(fields
[i
+3], "0x") {
90 /* definitions inside the macro do not match the pattern */
94 fmt
.Sscanf(fields
[i
+2], "0x%x", dw0
)
95 fmt
.Sscanf(fields
[i
+3], "0x%x", dw1
)
96 *function
= extractPadFuncFromComment(line
)
104 func useYourTemplate(line
string, function
*string,
105 id
*string, dw0
*uint32, dw1
*uint32) int {
107 // ADD YOUR TEMPLATE HERE
113 fmt
.Printf("ADD YOUR TEMPLATE!\n")
117 // registerInfoTemplate
118 // line : (in) string from file with pad config map
119 // *name : (out) register name
120 // *offset : (out) offset name
121 // *value : (out) register value
124 func registerInfoTemplate(line
string, name
*string, offset
*uint32, value
*uint32) int {
125 // 0x0088: 0x00ffffff (HOSTSW_OWN_GPP_F)
126 // 0x0100: 0x00000000 (GPI_IS_GPP_A)
127 if fields
:= strings
.FieldsFunc(line
, tokenCheck
); len(fields
) == 3 {
129 fmt
.Sscanf(fields
[1], "0x%x", value
)
130 fmt
.Sscanf(fields
[0], "0x%x", offset
)