Maxim Polyakov has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/45168 )
Change subject: util/intelp2m: Update output fotmat of generated gpio.h ......................................................................
util/intelp2m: Update output fotmat of generated gpio.h
Update the format of the generated gpio.h file:
For PAD_CFG*() macro:
/* GPIO_39 - LPSS_UART0_TXD */ --> (i) /* DW0: 0x44000400, DW1: 0x00003100 */ --> (ii) /* DW0 : PAD_TRIG(OFF) - IGNORED */ --> (iii, iiii) PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD),
For fields:
/* GPIO_39 - LPSS_UART0_TXD */ --> (i) /* DW0: 0x44000400, DW1: 0x00003100 */ --> (ii) /* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), */ --> (iii) /* DW0 : PAD_TRIG(OFF) - IGNORED */ --> (iiii) _PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(OFF), PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)),
TEST = ./intelp2m -n -file inteltool.log; ./intelp2m -fld cb -file inteltool.log; ./intelp2m -fld fsp -file inteltool.log; ./intelp2m -fld raw -file inteltool.log. Before and after the patch, gpio.h is no different.
Change-Id: I760f4aadece786ea455fb7569f42e06fefce2b61 Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com --- M util/intelp2m/description.md M util/intelp2m/fields/cb/cb.go M util/intelp2m/parser/parser.go M util/intelp2m/platforms/common/macro.go 4 files changed, 84 insertions(+), 93 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/68/45168/1
diff --git a/util/intelp2m/description.md b/util/intelp2m/description.md index add9c2c..0380d1f 100644 --- a/util/intelp2m/description.md +++ b/util/intelp2m/description.md @@ -79,34 +79,13 @@ ```
```c -/* GPP_A10 - CLKOUT_LPC1 DW0: 0x44000500, DW1: 0x00000000 */ +/* GPP_A10 - CLKOUT_LPC1 */ +/* DW0: 0x44000500, DW1: 0x00000000 */ /* PAD_CFG_NF(GPP_A10, NONE, DEEP, NF1), */ /* DW0 : 0x04000100 - IGNORED */ _PAD_CFG_STRUCT(GPP_A10, 0x44000500, 0x00000000), ```
-### FSP-style macro - -The utility allows to generate macros that include fsp/edk2-palforms style bitfields: - -```bash -(shell)$ ./intelp2m -fld fsp -p lbg -file ../crb-inteltool.log -``` - -```c -{ GPIO_SKL_H_GPP_A12, { GpioPadModeGpio, GpioHostOwnAcpi, GpioDirInInvOut, GpioOutLow, GpioIntSci | GpioIntLvlEdgDis, GpioResetNormal, GpioTermNone, GpioPadConfigLock }, /* GPIO */ -``` - -```bash -(shell)$ ./intelp2m -iiii -fld fsp -p lbg -file ../crb-inteltool.log -``` - -```c -/* GPP_A12 - GPIO DW0: 0x80880102, DW1: 0x00000000 */ -/* PAD_CFG_GPI_SCI(GPP_A12, NONE, PLTRST, LEVEL, INVERT), */ -{ GPIO_SKL_H_GPP_A12, { GpioPadModeGpio, GpioHostOwnAcpi, GpioDirInInvOut, GpioOutLow, GpioIntSci | GpioIntLvlEdgDis, GpioResetNormal, GpioTermNone, GpioPadConfigLock }, -``` - ### Macro Check
After generating the macro, the utility checks all used @@ -129,17 +108,9 @@ ### Information level
The utility can generate additional information about the bit -fields of the DW0 and DW1 configuration registers: - -```c -/* GPIO_39 - LPSS_UART0_TXD (DW0: 0x44000400, DW1: 0x00003100) */ --> (2) -/* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), */ --> (3) -/* DW0 : PAD_TRIG(OFF) - IGNORED */ --> (4) -_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(OFF), PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)), -``` - -Using the options -i, -ii, -iii, -iiii you can set the info level -from (1) to (4): +fields of the DW0 and DW1 configuration registers. Using the +options -i, -ii, -iii, -iiii you can set the info level from +1 to 4:
```bash (shell)$./intelp2m -i -file /path/to/inteltool.log @@ -147,33 +118,13 @@ (shell)$./intelp2m -iii -file /path/to/inteltool.log (shell)$./intelp2m -iiii -file /path/to/inteltool.log ``` -(1) : print /* GPIO_39 - LPSS_UART0_TXD */ - -(2) : print initial raw values of configuration registers from -inteltool dump -DW0: 0x44000400, DW1: 0x00003100 - -(3) : print the target macro that will generate if you use the --n option -PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), - -(4) : print decoded fields from (3) as macros -DW0 : PAD_TRIG(OFF) - IGNORED - -### Ignoring Fields - -Utilities can generate the _PAD_CFG_STRUCT macro and exclude fields -from it that are not in the corresponding PAD_CFG_*() macro: - -```bash -(shell)$ ./intelp2m -iiii -fld cb -ign -file /path/to/inteltool.log -```
```c -/* GPIO_39 - LPSS_UART0_TXD DW0: 0x44000400, DW1: 0x00003100 */ -/* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), */ -/* DW0 : PAD_TRIG(OFF) - IGNORED */ -_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP), PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)), +/* GPIO_39 - LPSS_UART0_TXD */ --> (i) +/* DW0: 0x44000400, DW1: 0x00003100 */ --> (ii) +/* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), */ --> (iii) +/* DW0 : PAD_TRIG(OFF) - IGNORED */ --> (iiii) +_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(OFF), PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)), ```
If you generate macros without checking, you can see bit fields that @@ -184,19 +135,51 @@ ```
```c -/* GPIO_39 - LPSS_UART0_TXD DW0: 0x44000400, DW1: 0x00003100 */ +/* GPIO_39 - LPSS_UART0_TXD */ --> (i) +/* DW0: 0x44000400, DW1: 0x00003100 */ --> (ii) +/* DW0 : PAD_TRIG(OFF) - IGNORED */ --> (iii, iiii) PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), -/* DW0 : PAD_TRIG(OFF) - IGNORED */ ``` +### Ignoring Fields + +Utilities can generate the _PAD_CFG_STRUCT macro and exclude fields +from it that are not in the corresponding PAD_CFG_*() macro:
```bash -(shell)$ ./intelp2m -n -file /path/to/inteltool.log +(shell)$ ./intelp2m -iiii -fld cb -ign -file /path/to/inteltool.log ```
```c /* GPIO_39 - LPSS_UART0_TXD */ -PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), +/* DW0: 0x44000400, DW1: 0x00003100 */ +/* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD), */ +/* DW0 : PAD_TRIG(OFF) - IGNORED */ +_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP), PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)), ``` + +### FSP-style macro + +The utility allows to generate macros that include fsp/edk2-palforms style bitfields: + +```bash +(shell)$ ./intelp2m -fld fsp -p lbg -file ../crb-inteltool.log +``` + +```c +{ GPIO_SKL_H_GPP_A12, { GpioPadModeGpio, GpioHostOwnAcpi, GpioDirInInvOut, GpioOutLow, GpioIntSci | GpioIntLvlEdgDis, GpioResetNormal, GpioTermNone, GpioPadConfigLock }, /* GPIO */ +``` + +```bash +(shell)$ ./intelp2m -iiii -fld fsp -p lbg -file ../crb-inteltool.log +``` + +```c +/* GPP_A12 - GPIO */ +/* DW0: 0x80880102, DW1: 0x00000000 */ +/* PAD_CFG_GPI_SCI(GPP_A12, NONE, PLTRST, LEVEL, INVERT), */ +{ GPIO_SKL_H_GPP_A12, { GpioPadModeGpio, GpioHostOwnAcpi, GpioDirInInvOut, GpioOutLow, GpioIntSci | GpioIntLvlEdgDis, GpioResetNormal, GpioTermNone, GpioPadConfigLock }, +``` + ### Supports Chipsets
Sunrise PCH, Lewisburg PCH, Apollo Lake SoC, CannonLake-LP SoCs diff --git a/util/intelp2m/fields/cb/cb.go b/util/intelp2m/fields/cb/cb.go index 61f59c4..0e254dd 100644 --- a/util/intelp2m/fields/cb/cb.go +++ b/util/intelp2m/fields/cb/cb.go @@ -50,7 +50,7 @@ generate( &field { prefix : "PAD_FUNC", - unhide : config.InfoLevelGet() <= 3 || dw0.GetPadMode() != 0, + unhide : config.InfoLevelGet() < 3 || dw0.GetPadMode() != 0, configurator : func() { macro.Padfn() }, },
diff --git a/util/intelp2m/parser/parser.go b/util/intelp2m/parser/parser.go index d4c04cd..c35d4e7 100644 --- a/util/intelp2m/parser/parser.go +++ b/util/intelp2m/parser/parser.go @@ -66,9 +66,9 @@ // macro : string of the generated macro func (info *padInfo) padInfoMacroFprint(macro string) { info.generate(2, "\n") - info.generate(1, "\t/* %s - %s ", info.id, info.function) - info.generate(2, "DW0: 0x%0.8x, DW1: 0x%0.8x ", info.dw0, info.dw1) - info.generate(1, "*/\n") + info.generate(1, "\t/* %s - %s */", info.id, info.function) + info.generate(2, "\n\t/* DW0: 0x%0.8x, DW1: 0x%0.8x */", info.dw0, info.dw1) + info.generate(1, "\n") info.generate(0, "\t%s", macro) if config.InfoLevelGet() == 0 { info.generate(0, "\t/* %s */", info.function) diff --git a/util/intelp2m/platforms/common/macro.go b/util/intelp2m/platforms/common/macro.go index e30ef22..51705bb 100644 --- a/util/intelp2m/platforms/common/macro.go +++ b/util/intelp2m/platforms/common/macro.go @@ -292,32 +292,33 @@ return macro }
-// AddToMacroIgnoredMask - Print info about ignored field mask -// title - warning message -func (macro *Macro) AddToMacroIgnoredMask() *Macro { - if config.InfoLevelGet() < 4 || config.IsFspStyleMacro() { +// DecodeIgnored - Add info about ignored field mask +// reg : PAD_CFG_DW0 or PAD_CFG_DW1 register +func (macro *Macro) DecodeIgnored(reg uint8) *Macro { + var decode = map[uint8]func() { + PAD_CFG_DW0: macro.Fields.DecodeDW0, + PAD_CFG_DW1: macro.Fields.DecodeDW1, + } + decodefn, valid := decode[reg] + if !valid || config.IsFspStyleMacro() { return macro } - dw0 := macro.Register(PAD_CFG_DW0) - dw1 := macro.Register(PAD_CFG_DW1) - // Get mask of ignored bit fields. - dw0Ignored := dw0.IgnoredFieldsGet() - dw1Ignored := dw1.IgnoredFieldsGet() - if dw0Ignored != 0 { - dw0temp := dw0.ValueGet() - dw0.ValueSet(dw0Ignored) - macro.Add("\n\t/* DW0 : ") - macro.Fields.DecodeDW0() + dw := macro.Register(reg) + ignored := dw.IgnoredFieldsGet() + if ignored != 0 { + temp := dw.ValueGet() + dw.ValueSet(ignored) + if !config.IsNonCheckingFlagUsed() { + macro.Add("\n\t") + } + regnum := strconv.Itoa(int(reg)) + macro.Add("/* DW" + regnum + " : ") + decodefn() macro.Add(" - IGNORED */") - dw0.ValueSet(dw0temp) - } - if dw1Ignored != 0 { - dw1temp := dw1.ValueGet() - dw1.ValueSet(dw1Ignored) - macro.Add("\n\t/* DW1 : ") - macro.Fields.DecodeDW1() - macro.Add(" - IGNORED */") - dw1.ValueSet(dw1temp) + if config.IsNonCheckingFlagUsed() { + macro.Add("\n\t") + } + dw.ValueSet(temp) } return macro } @@ -338,7 +339,9 @@ reference := macro.Get() macro.Clear() macro.Add("/* ").Add(reference).Add(" */") - macro.AddToMacroIgnoredMask() + if config.InfoLevelGet() >= 4 { + macro.DecodeIgnored(PAD_CFG_DW0).DecodeIgnored(PAD_CFG_DW1) + } macro.Add("\n\t") } if config.AreFieldsIgnored() { @@ -409,8 +412,13 @@ }
if config.IsNonCheckingFlagUsed() { - macro.AddToMacroIgnoredMask() - return macro.Get() + body := macro.Get() + if config.InfoLevelGet() >= 3 { + macro.Clear().DecodeIgnored(PAD_CFG_DW0).DecodeIgnored(PAD_CFG_DW1) + comment := macro.Get() + return comment + body + } + return body }
return macro.check().Get()