10 // generateOutputFile - generates include file
11 // parser : parser data structure
12 func generateOutputFile(parser
*parser
.ParserData
) (err error
) {
14 config
.OutputGenFile
.WriteString(`/* SPDX-License-Identifier: GPL-2.0-only */
21 /* Pad configuration was generated automatically using intelp2m utility */
22 static const struct pad_config gpio_table[] = {
26 config
.OutputGenFile
.WriteString(`};
28 #endif /* CFG_GPIO_H */
35 // Command line arguments
36 inputFileName
:= flag
.String("file",
38 "the path to the inteltool log file\n")
40 outputFileName
:= flag
.String("o",
42 "the path to the generated file with GPIO configuration\n")
44 ignFlag
:= flag
.Bool("ign",
46 "exclude fields that should be ignored from advanced macros\n")
48 nonCheckFlag
:= flag
.Bool("n",
50 "Generate macros without checking.\n" +
51 "\tIn this case, some fields of the configuration registers\n" +
52 "\tDW0 will be ignored.\n")
54 infoLevels
:= []*bool {
55 flag
.Bool("i", false, "Show pads function in the comments"),
56 flag
.Bool("ii", false, "Show DW0/DW1 value in the comments"),
57 flag
.Bool("iii", false, "Show ignored bit fields in the comments"),
58 flag
.Bool("iiii", false, "Show target PAD_CFG() macro in the comments"),
61 template
:= flag
.Int("t", 0, "template type number\n"+
62 "\t0 - inteltool.log (default)\n"+
64 "\t2 - your template\n\t")
66 platform
:= flag
.String("p", "snr", "set platform:\n"+
67 "\tsnr - Sunrise PCH or Skylake/Kaby Lake SoC\n"+
68 "\tlbg - Lewisburg PCH with Xeon SP\n"+
69 "\tapl - Apollo Lake SoC\n"+
70 "\tcnl - CannonLake-LP or Whiskeylake/Coffelake/Cometlake-U SoC\n")
72 filedstyle
:= flag
.String("fld", "none", "set fileds macros style:\n"+
73 "\tcb - use coreboot style for bit fields macros\n"+
74 "\tfsp - use fsp style\n"+
75 "\traw - do not convert, print as is\n")
79 config
.IgnoredFieldsFlagSet(*ignFlag
)
80 config
.NonCheckingFlagSet(*nonCheckFlag
)
82 for level
, flag
:= range infoLevels
{
84 config
.InfoLevelSet(level
+ 1)
85 fmt
.Printf("Info level: Use level %d!\n", level
+ 1)
90 if !config
.TemplateSet(*template
) {
91 fmt
.Printf("Error! Unknown template format of input file!\n")
95 if valid
:= config
.PlatformSet(*platform
); valid
!= 0 {
96 fmt
.Printf("Error: invalid platform -%s!\n", *platform
)
100 fmt
.Println("Log file:", *inputFileName
)
101 fmt
.Println("Output generated file:", *outputFileName
)
103 inputRegDumpFile
, err
:= os
.Open(*inputFileName
)
105 fmt
.Printf("Error: inteltool log file was not found!\n")
109 if config
.FldStyleSet(*filedstyle
) != 0 {
110 fmt
.Printf("Error! Unknown bit fields style option -%s!\n", *filedstyle
)
114 // create dir for output files
115 err
= os
.MkdirAll("generate", os
.ModePerm
)
117 fmt
.Printf("Error! Can not create a directory for the generated files!\n")
121 // create empty gpio.h file
122 outputGenFile
, err
:= os
.Create(*outputFileName
)
124 fmt
.Printf("Error: unable to generate GPIO config file!\n")
128 defer inputRegDumpFile
.Close()
129 defer outputGenFile
.Close()
131 config
.OutputGenFile
= outputGenFile
132 config
.InputRegDumpFile
= inputRegDumpFile
134 parser
:= parser
.ParserData
{}
138 err
= generateOutputFile(&parser
)
140 fmt
.Printf("Error! Can not create the file with GPIO configuration!\n")