diff options
author | Arthur Heymans <arthur@aheymans.xyz> | 2017-05-01 09:40:43 +0200 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2017-10-06 13:48:12 +0000 |
commit | 128205fd087cc43f4cf9c7a947af5b951bcf2339 (patch) | |
tree | 120ad1cecbb03474a11f8675be10e210a152918f /util/autoport | |
parent | 2b9f5b5c121997e34743adf6fbe6b03676805404 (diff) |
autoport/bd82x6x.go: Improve gpio.c generation
This generates better gpio.c files where structs are initialised as
static to be able to drop some entries since those would be
initialised as 0.
This makes these files less cluttered since only relevant things are
shown:
* GPIO direction, level, invert, blink depend on GPIO mode
* GPIO level is read only on input
* GPIO invert is only valid on input
* only show when GPIO are inverted, blinking, reset by RSMRST#
Change-Id: I83382d38a4a3b7ed11b8e7077cc5fbe154e261a7
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/19508
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'util/autoport')
-rw-r--r-- | util/autoport/bd82x6x.go | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/util/autoport/bd82x6x.go b/util/autoport/bd82x6x.go index e23262c375..ee7e207d25 100644 --- a/util/autoport/bd82x6x.go +++ b/util/autoport/bd82x6x.go @@ -11,7 +11,7 @@ type bd82x6x struct { } func (b bd82x6x) writeGPIOSet(ctx Context, sb *os.File, - val uint32, set uint, partno int) { + val uint32, set uint, partno int, constraint uint32) { max := uint(32) if set == 3 { @@ -28,22 +28,24 @@ func (b bd82x6x) writeGPIOSet(ctx Context, sb *os.File, } for i := uint(0); i < max; i++ { - fmt.Fprintf(sb, " .gpio%d = %s,\n", - (set-1)*32+i, - bits[partno][(val>>i)&1]) + if ((constraint>>i)&1 == 1) { + fmt.Fprintf(sb, " .gpio%d = %s,\n", + (set-1)*32+i, + bits[partno][(val>>i)&1]) + } } } func (b bd82x6x) GPIO(ctx Context, inteltool InteltoolData) { + var constraint uint32 gpio := Create(ctx, "gpio.c") defer gpio.Close() AddROMStageFile("gpio.c", "") - gpio.WriteString(`#include <southbridge/intel/common/gpio.h> -`) + gpio.WriteString("#include <southbridge/intel/common/gpio.h>\n\n") - adresses := [3][6]int{ + addresses := [3][6]int{ {0x00, 0x04, 0x0c, 0x60, 0x2c, 0x18}, {0x30, 0x34, 0x38, 0x64, -1, -1}, {0x40, 0x44, 0x48, 0x68, -1, -1}, @@ -51,14 +53,37 @@ func (b bd82x6x) GPIO(ctx Context, inteltool InteltoolData) { for set := 1; set <= 3; set++ { for partno, part := range []string{"mode", "direction", "level", "reset", "invert", "blink"} { - addr := adresses[set-1][partno] + addr := addresses[set-1][partno] if addr < 0 { continue } - fmt.Fprintf(gpio, "const struct pch_gpio_set%d pch_gpio_set%d_%s = {\n", + fmt.Fprintf(gpio, "static const struct pch_gpio_set%d pch_gpio_set%d_%s = {\n", set, set, part) - b.writeGPIOSet(ctx, gpio, inteltool.GPIO[uint16(addr)], uint(set), partno) + constraint = 0xffffffff + switch part { + case "direction": + /* Ignored on native mode */ + constraint = inteltool.GPIO[uint16(addresses[set-1][0])] + case "level": + /* Level doesn't matter for input */ + constraint = inteltool.GPIO[uint16(addresses[set-1][0])] + constraint &^= inteltool.GPIO[uint16(addresses[set-1][1])] + case "reset": + /* Only show reset */ + constraint = inteltool.GPIO[uint16(addresses[set-1][3])] + case "invert": + /* Only on input and only show inverted GPIO */ + constraint = inteltool.GPIO[uint16(addresses[set-1][0])] + constraint &= inteltool.GPIO[uint16(addresses[set-1][1])] + constraint &= inteltool.GPIO[uint16(addresses[set-1][4])] + case "blink": + /* Only on output and only show blinking GPIO */ + constraint = inteltool.GPIO[uint16(addresses[set-1][0])] + constraint &^= inteltool.GPIO[uint16(addresses[set-1][1])] + constraint &= inteltool.GPIO[uint16(addresses[set-1][5])] + } + b.writeGPIOSet(ctx, gpio, inteltool.GPIO[uint16(addr)], uint(set), partno, constraint) gpio.WriteString("};\n\n") } } |