summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachel Nancollas <rachelsn@google.com>2023-04-10 13:50:29 -0400
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-11 18:59:41 +0000
commit03630f6241f454a76a7771f137bee337a8d90a41 (patch)
tree30bcdbb27d2c159504bfe1d72515899783d81546
parent9da35bc68bdd8af9e4e9e9c4a6b2f19eef6dac78 (diff)
downloadchrome-ec-03630f6241f454a76a7771f137bee337a8d90a41.tar.gz
pinmap: migrate code to Arbitrage
This commit removes pinmap code from the chromium codebase because it has been migrated to go/arbitrage. In order to use this code going forward, users should follow the steps in go/arbitrage to setup Arbitrage and the steps in https://team.git.corp.google.com/cros-arbitrage/arbitrage#zephyr-pinmap-generation to generate pinmaps. In order to develop this code going forward, developers should follow the steps in https://team.git.corp.google.com/cros-arbitrage/arbitrage/+/HEAD/documentation/dev_guide.md. For any questions, contact the Arbitrage team at arbitrage-eng@google.com. Bug: 274938064 Change-Id: I2948ee2245236d95a133758e695e51ecbb4969c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4412374 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Rachel Nancollas <rachelsn@google.com> Code-Coverage: Rachel Nancollas <rachelsn@google.com> Tested-by: Rachel Nancollas <rachelsn@google.com> Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r--util/pinmap/README.md100
-rw-r--r--util/pinmap/chips/it81302.go230
-rw-r--r--util/pinmap/chips/npcx993.go230
-rw-r--r--util/pinmap/chips/npcx993_test.go85
-rw-r--r--util/pinmap/chips/register.go15
-rw-r--r--util/pinmap/go.mod3
-rw-r--r--util/pinmap/pinmap/main.go75
-rw-r--r--util/pinmap/pm/chip.go68
-rw-r--r--util/pinmap/pm/chip_test.go64
-rw-r--r--util/pinmap/pm/generate.go222
-rw-r--r--util/pinmap/pm/generate_test.go205
-rw-r--r--util/pinmap/pm/pins.go35
-rw-r--r--util/pinmap/pm/reader.go43
-rw-r--r--util/pinmap/pm/reader_test.go52
-rw-r--r--util/pinmap/readers/csv/csv.go135
-rw-r--r--util/pinmap/readers/csv/csv_test.go58
-rw-r--r--util/pinmap/readers/csv/register.go13
-rw-r--r--util/pinmap/readers/csv/testdata/data.csv9
18 files changed, 0 insertions, 1642 deletions
diff --git a/util/pinmap/README.md b/util/pinmap/README.md
deleted file mode 100644
index 7ac924e09a..0000000000
--- a/util/pinmap/README.md
+++ /dev/null
@@ -1,100 +0,0 @@
-# pinmap
-
-## Overview
-
-This program reads a CSV (comma separated values) file and generates
-Zephyr Device Tree entries for GPIOs and other configuration.
-
-A basic Device Tree configuration is generated for I2C buses, ADC pins and GPIO
-pins with labels and nodes generated for each of the signals in the
-spreadsheet.
-
-A separate overlay Device Tree file can be used to modify the generated DTS to
-allow specific properties and parameters to be set e.g bus speeds for I2C,
-conversion parameters for ADCs etc.
-
-## Building
-
-An ebuild file will eventually be created to integrate the building of the
-utility to the standard host binary path.
-
-In the meantime, the utility can be built directly via:
-
-```
-
-cd pinmap/pinmap
-go build
-
-```
-
-This builds the `pinmap` binary in the `pinmap/pinmap` directory.
-This binary can be run directly or moved to an appropriate binary directory.
-
-## Executing
-
-Running `pinmap --help` prints a usage page.
-
-The `--reader` flag allows selecting different forms of input.
-The default is `csv`, which is expected to be the downloaded CSV from a spreadsheet.
-
-The `--column` flag selects the spreadsheet column index to use for the pin allocations.
-
-The `--chip` flag selects the EC part to be used.
-
-## Spreadsheet format
-
-An [example spreadsheet](http://go/cros-nissa-ec-pinmap) shows the format expected.
-
-The first row should contain column titles that the CSV reader can match against to retrieve the
-appropriate data. Currently the column names are fixed, but a TODO is to provide an external
-map that allows the reader to be informed which columns are to be used.
-
-Multiple EC chips may be supported in the same spreadsheet. The EC part name is set
-as one of the column headers, and this column can be selected using the `--chip` flag.
-
-An example of a working CSV file can also be viewed in the [file](readers/csv/testdata/data.csv)
-used for the unit tests.
-
-The key columns that are expected (and must match exactly) by the reader are:
-
-| Column Title | Description |
-| ----------- | ----------- |
-| Signal Name | The net name as used in the circuit |
-| Type | A drop down menu that indicates the type of pin (see the table below) |
-| Enum | If set, this string will be added to the DTS node as the `enum-name` property |
-| *chip* | This column contains the pin reference for this signal for this particular EC part number |
-
-The **Type** column indicates exactly what the type of signal is, and is used to
-generate the GPIO or other configuration flags in the DTS.
-
-| Type Name | Description |
-| ----------- | ----------- |
-| `ADC` | An analogue to digital converter signal |
-| `I2C_CLOCK` | The clock signal for an I2C bus |
-| `I2C_DATA` | The data signal for an I2C bus (ignored) |
-| `INPUT` | A GPIO input signal |
-| `INPUT_PU` | A GPIO input signal with internal pull-up |
-| `INPUT_PD` | A GPIO input signal with internal pull-down |
-| `OUTPUT` | A GPIO output signal |
-| `OUTPUT_ODR` | A GPIO output open drain signal |
-| `OUTPUT_ODL` | A GPIO output open drain signal (default low) |
-| `OTHER` | This signal is ignored, and no DTS configuration is generated for this pin |
-
-For the I2C signals, only the `I2C_CLOCK` signal is used to determine which I2C
-bus is referenced - the `I2C_DATA` signal is effectively ignored.
-
-## Example use
-
-Assume that the spreadsheet is downloaded as CSV format to the file `signals.csv`, and
-a NPCX993 EC chip is selected, the following command can be run:
-
-```
-pinmap --chip=NPCX993 --output=generated.dts --column=J signals.csv
-```
-
-The file `generated.dts` contains the DTS configuration as processed and generated by the utility.
-
-## TODO
-
-- Read signals from arbitrage (requires more data in arbitrage)
-- Build chip map from vendor data
diff --git a/util/pinmap/chips/it81302.go b/util/pinmap/chips/it81302.go
deleted file mode 100644
index 058ac9a03b..0000000000
--- a/util/pinmap/chips/it81302.go
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package chips
-
-import (
- "fmt"
- "strings"
-)
-
-// As provided by ITE.
-var it81302_pins map[string]string = map[string]string{
- "A1": "GPL5",
- "A2": "GPL4",
- "A3": "SMDAT1/GPC2",
- "A4": "SMCLK1/GPC1",
- "A5": "SMCLK0/GPB3",
- "A6": "FSCK/GPG7",
- "A7": "FMOSI/GPG4",
- "A8": "GPH6/ID6",
- "A9": "GPH4/ID4",
- "A10": "SMINT11/PD1CC2/GPF5",
- "A11": "RTS0#/SMINT9/GPF3",
- "A12": "GPF1",
- "A13": "ADC13/GPL0",
- "A14": "ADC14/GPL1",
- "A15": "ADC15/GPL2",
- "B1": "GPL6",
- "B2": "RING#/PWRFAIL#/CK32KOUT/LPCRST#/GPB7",
- "B3": "SMDAT0/GPB4",
- "B4": "SOUT0/GPB1",
- "B5": "SIN0/GPB0",
- "B6": "DTR1#/GPG1/ID7",
- "B7": "FMISO/GPG5",
- "B8": "FSCE#/GPG3",
- "B9": "GPH5/ID5",
- "B10": "GPH3/ID3",
- "B11": "DTR0#/SMINT8/GPF2",
- "B12": "CEC/GPF0",
- "B13": "GPE2",
- "B14": "GPE1",
- "B15": "ADC16/GPL3",
- "C1": "GPL7",
- "C2": "SMCLK2/PECI/GPF6",
- "C14": "DCD0#/GPJ4",
- "C15": "GPE3",
- "D1": "GPC4",
- "D2": "SMDAT2/PECIRQT#/GPF7",
- "D14": "TACH1B/SMINT7/GPJ3",
- "D15": "RIG0#/GPJ5",
- "E1": "GPB2",
- "E2": "GPC0",
- "E5": "VSTBY",
- "E6": "VFSPI",
- "E7": "DSR0#/GPG6",
- "E8": "SOUT1/SMDAT3/PD2CC2/GPH2/ID2",
- "E9": "CLKRUN#/GPH0/ID0",
- "E10": "SMINT10/PD1CC1/GPF4",
- "E11": "VSTBY",
- "E14": "SMINT5/GPJ1",
- "E15": "TACH0B/SMINT6/GPJ2",
- "F1": "PWRSW/GPE4",
- "F2": "GPC6",
- "F5": "VSTBY",
- "F6": "VSS",
- "F7": "SSCE1#/GPG0",
- "F8": "SSCE0#/GPG2",
- "F9": "SIN1/SMCLK3/PD2CC1/GPH1/ID1",
- "F10": "AVCC",
- "F11": "AVSS",
- "F14": "ADC7/CTS1#/GPI7",
- "F15": "TACH2/SMINT4/GPJ0",
- "G1": "CK32K/GPJ6",
- "G2": "GA20/GPB5",
- "G5": "VSS",
- "G6": "VSS",
- "G10": "ADC3/SMINT2/GPI3",
- "G11": "ADC5/DCD1#/GPI5",
- "G14": "ADC4/SMINT3/GPI4",
- "G15": "ADC6/DSR1#/GPI6",
- "H1": "ALERT#/SERIRQ/GPM6",
- "H2": "GPJ7",
- "H5": "VSS",
- "H6": "VSS",
- "H10": "KSI7",
- "H11": "ADC0/GPI0",
- "H14": "ADC1/SMINT0/GPI1",
- "H15": "ADC2/SMINT1/GPI2",
- "J1": "EIO3/LAD3/GPM3",
- "J2": "ECS#/LFRAME#/GPM5",
- "J5": "KBRST#/GPB6",
- "J6": "VSS",
- "J10": "KSI4",
- "J11": "KSI5",
- "J14": "KSI6",
- "J15": "KSI3/SLIN#",
- "K1": "EIO1/LAD1/GPM1",
- "K2": "EIO2/LAD2/GPM2",
- "K5": "VBAT",
- "K6": "VCC",
- "K7": "PWM5/SMDAT5/GPA5",
- "K8": "KSO1/PD1",
- "K9": "KSO5/PD5",
- "K10": "KSI2/INIT#",
- "K11": "KSO17/SMISO/GPC5",
- "K14": "KSI1/AFD#",
- "K15": "KSI0/STB#",
- "L1": "ESCK/LPCCLK/GPM4",
- "L2": "EIO0/LAD0/GPM0",
- "L5": "VSTBY",
- "L6": "VCORE",
- "L7": "PWM4/SMCLK5/GPA4",
- "L8": "PWM7/RIG1#/GPA7",
- "L9": "KSO4/PD4",
- "L10": "KSO9/BUSY",
- "L11": "VSTBY",
- "L14": "KSO16/SMOSI/GPC3",
- "L15": "KSO15",
- "M1": "ECSMI#/GPD4",
- "M2": "WRST#",
- "M14": "KSO14",
- "M15": "KSO13",
- "N1": "PWUREQ#/BBO/SMCLK2ALT/GPC7",
- "N2": "LPCPD#/GPE6",
- "N14": "KSO12/SLCT",
- "N15": "WUI14/GPK6",
- "P1": "WUI8/GPK0",
- "P2": "RI1#/GPD0",
- "P3": "L80HLAT/BAO/SMCLK4/GPE0",
- "P4": "RI2#/GPD1",
- "P5": "ECSCI#/GPD3",
- "P6": "PWM1/GPA1",
- "P7": "PWM3/GPA3",
- "P8": "GINT/CTS0#/GPD5",
- "P9": "RTS1#/GPE5",
- "P10": "KSO2/PD2",
- "P11": "KSO6/PD6",
- "P12": "KSO8/ACK#",
- "P13": "KSO10/PE",
- "P14": "KSO11/ERR#",
- "P15": "WUI15/GPK7",
- "R1": "WUI9/GPK1",
- "R2": "WUI10/GPK2",
- "R3": "WUI11/GPK3",
- "R4": "L80LLAT/SMDAT4/GPE7",
- "R5": "ERST#/LPCRST#/GPD2",
- "R6": "PWM0/GPA0",
- "R7": "PWM2/GPA2",
- "R8": "PWM6/SSCK/GPA6",
- "R9": "KSO0/PD0",
- "R10": "KSO3/PD3",
- "R11": "KSO7/PD7",
- "R12": "TACH0A/GPD6",
- "R13": "TACH1A/GPD7",
- "R14": "WUI13/GPK5",
- "R15": "WUI12/GPK4",
-}
-
-// it81302 represents an ITE81302 EC.
-type It81302 struct {
- okay []string // Nodes to enable.
-}
-
-// Name returns the name of this EC.
-func (c *It81302) Name() string {
- return "IT81302"
-}
-
-// EnabledNodes returns a list of the DTS nodes that require enabling.
-func (c *It81302) EnabledNodes() []string {
- return c.okay
-}
-
-// Adc returns the configuration of this pin as an ADC.
-func (c *It81302) Adc(p string) string {
- s, ok := it81302_pins[p]
- if ok {
- // Found the pin, now find the ADC name.
- for _, ss := range strings.Split(s, "/") {
- if strings.HasPrefix(ss, "ADC") && len(ss) > 3 {
- c.okay = append(c.okay, "adc0")
- return fmt.Sprintf("%s", ss[3:])
- }
- }
- return ""
- } else {
- return ""
- }
-}
-
-// Gpio returns the configuration of this pin as a
-// GPIO controller name and a pin number.
-func (c *It81302) Gpio(p string) (string, int) {
- s, ok := it81302_pins[p]
- if ok {
- // Found the pin, now find the GP name.
- for _, ss := range strings.Split(s, "/") {
- if strings.HasPrefix(ss, "GP") && len(ss) == 4 {
- lc := strings.ToLower(ss)
- pin := int(lc[3] - '0')
- if pin < 0 || pin > 9 {
- return "", 0
- }
- return fmt.Sprintf("gpio%c", lc[2]), pin
- }
- }
- return "", 0
- } else {
- return "", 0
- }
-}
-
-// I2c returns the configuration of this pin as an I2C bus.
-func (c *It81302) I2c(p string) string {
- s, ok := it81302_pins[p]
- if ok {
- // Found the pin, now find the I2C name.
- for _, ss := range strings.Split(s, "/") {
- if strings.HasPrefix(ss, "SMCLK") && len(ss) > 5 {
- i2c := fmt.Sprintf("i2c%s", ss[5:])
- c.okay = append(c.okay, i2c)
- return i2c
- }
- }
- return ""
- } else {
- return ""
- }
-}
diff --git a/util/pinmap/chips/npcx993.go b/util/pinmap/chips/npcx993.go
deleted file mode 100644
index 720cd99fb6..0000000000
--- a/util/pinmap/chips/npcx993.go
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package chips
-
-import (
- "fmt"
- "strings"
-)
-
-// As provided by Nuvoton.
-var npcx993_pins map[string]string = map[string]string{
- "E7": "PSL_IN2#&GPI00,GPIO00",
- "E6": "GPIO01,PSL_IN3#&GPI01",
- "F7": "GPIO02,PSL_IN4#&GPI02",
- "D9": "KSO16,GPIO03",
- "D11": "KSO13,GPIO04",
- "C11": "KSO12,GPIO05",
- "B10": "KSO11&P80_DAT,GPIO06",
- "B11": "KSO10&P80_CLK,GPIO07",
- "C10": "KSO09,GPIO10,CR_SIN1",
- "C9": "KSO08,GPIO11,CR_SOUT1",
- "B9": "KSO07,GPO12,JEN#",
- "C8": "KSO06,GPO13,GP_SEL#",
- "C6": "KSO05,GPIO14",
- "C7": "KSO04,GPIO15,XNOR",
- "B8": "KSO03,GPIO16,JTAG_TDO0_SWO0",
- "B7": "KSO02,GPIO17,JTAG_TDI0",
- "B6": "KSO01,GPIO20,JTAG_TMS0_SWIO0",
- "B5": "KSO00,GPIO21,JTAG_TCK0_SWCLK0",
- "C5": "KSI7,GPIO22,S_SBUA",
- "C4": "KSI6,GPIO23,S_SBUB",
- "C3": "KSI5,GPIO24,,GP_MISO",
- "B4": "KSI4,GPIO25,TRACECLK,GP_SCLK",
- "B3": "KSI3,GPIO26,TRACEDATA0",
- "A4": "KSI2,GPIO27,TRACEDATA1",
- "A3": "KSI1,GPIO30,TRACEDATA2,GP_CS#",
- "A2": "KSI0,GPIO31,TRACEDATA3,GP_MOSI",
- "E4": "GPO32,TRIS#",
- "D5": "GPIO33,CTS#,I2C5_SCL0",
- "B2": "GPIO34,PS2_DAT2,ADC6",
- "K2": "GPO35,CR_SOUT4,TEST#",
- "D4": "GPIO36,RTS#,I2C5_SDA0",
- "C1": "GPIO37,PS2_CLK2,ADC5",
- "E5": "GPIO40,TA1",
- "F4": "GPIOE0,ADC10",
- "C2": "GPIO41,ADC4",
- "D2": "GPIOF0,ADC9",
- "D1": "AVCC",
- "D3": "GPIO42,ADC3,RI#",
- "E2": "GPIO43,ADC2",
- "E3": "GPIO44,ADC1",
- "F2": "GPIO45,ADC0",
- "E1": "AVSS",
- "F3": "GPIOE1,ADC7",
- "G3": "GPIOF1,ADC8",
- "H1": "LAD0,GPIO46",
- "J1": "LAD1,GPIO47",
- "G10": "GPIO50",
- "K1": "LAD2,GPIO51",
- "L1": "LAD3,GPIO52",
- "L2": "LFRAME#,GPIO53",
- "K3": "LRESET#,GPIO54",
- "M1": "PCI_CLK,GPIO55",
- "M2": "GPIO56,CLKRUN#",
- "L3": "SER_IRQ,GPIO57",
- "F1": "VHIF",
- "L7": "GPIOE3,I2C6_SDA1,I3C_SDA",
- "L6": "GPIOE4,I2C6_SCL1,I3C_SCL",
- "G6": "GPIO60,PWM7",
- "K4": "GPIO61,PWROFF#",
- "H2": "GPIO62,PS2_CLK1",
- "J2": "GPIO63,PS2_DAT1",
- "G4": "GPIO64,CR_SIN1",
- "H4": "GPO65,CR_SOUT1,FLPRG1#",
- "G2": "GPIO66",
- "J3": "GPIO67,PS2_CLK0",
- "J4": "GPIO70,PS2_DAT0",
- "L4": "VBAT",
- "M4": "PWRGD,GPIO72",
- "M5": "32KXOUT",
- "L5": "32KXIN&32KCLKIN",
- "G5": "GPIO73,TA2",
- "H5": "GPIO74",
- "J6": "GPIO75,32KHZ_OUT,RXD,CR_SIN2",
- "J5": "GPIO76,EC_SCI#",
- "K6": "VCC1_RST#,GPO77",
- "K5": "GPIO80,PWM3",
- "M6": "VREF_PECI",
- "M7": "PECI_DATA,GPIO81",
- "M10": "VSBY",
- "J8": "PSL_OUT&GPIO85,GPO85",
- "H6": "PSL_GPO,GPOD7",
- "D6": "KSO14,GPIO82",
- "D7": "KSO15,GPIO83",
- "J9": "GPO86,TXD,CR_SOUT2,FLPRG2#",
- "K7": "GPIO87,I2C1_SDA0",
- "K8": "GPIO90,I2C1_SCL0",
- "K9": "GPIO91,I2C2_SDA0",
- "L8": "GPIO92,I2C2_SCL0",
- "E11": "GPIO93,TA1,F_DIO2",
- "M11": "GPIO94",
- "M12": ",SPIP_MISO,GPIO95",
- "G12": "F_DIO1,GPIO96",
- "L10": ",GPIO97",
- "G11": "F_CS0#,GPIOA0",
- "L12": ",SPIP_SCLK,GPIOA1",
- "F12": "F_SCLK,GPIOA2",
- "K12": ",SPIP_MOSI,GPIOA3",
- "H11": "F_DIO0,GPIOA4,TB1",
- "K11": "GPIOA5",
- "F11": "GPIOA6,PS2_CLK3,TA2,F_CS1#",
- "J11": "GPIOA7,PS2_DAT3,TB2,F_DIO3",
- "H12": "VSPI",
- "L11": "GPIOB0",
- "D8": "KSO17,GPIOB1,CR_SIN4",
- "K10": "GPIOB2,I2C7_SDA0,DSR#",
- "J10": "GPIOB3,I2C7_SCL0,DCD#",
- "B12": "GPIOB4,I2C0_SDA0",
- "C12": "GPIOB5,I2C0_SCL0",
- "L9": "GPIOB6,PWM4",
- "J7": "GPIOB7,PWM5",
- "H8": "GPIOC0,PWM6",
- "H9": "GPIOC1,I2C6_SDA0",
- "H10": "GPIOC2,PWM1,I2C6_SCL0",
- "G9": "GPIOC3,PWM0",
- "G8": "GPIOC4,PWM2",
- "H7": "GPIOC5,KBRST#",
- "D10": "GPIOC6,SMI#",
- "F10": "GPIOC7,DTR#_BOUT,ADC11",
- "F9": "GPIOD0,I2C3_SDA0",
- "F8": "GPIOD1,I2C3_SCL0",
- "G7": "PSL_IN1#&GPID2,GPIOD2",
- "E10": "GPIOD3,TB1",
- "A9": "GPIOD4,CR_SIN3",
- "A10": "GPIOD5,INTRUDER#",
- "H3": "GPOD6,CR_SOUT3,SHDF_ESPI#",
- "A11": "GPIOE2",
- "A12": "GPIOE5",
- "F6": "GPIOF2,I2C4_SDA1",
- "F5": "GPIOF3,I2C4_SCL1",
- "E9": "GPIOF4,I2C5_SDA1",
- "E8": "GPIOF5,I2C5_SCL1",
-}
-
-type Npcx993 struct {
- okay []string // Nodes to enable.
-}
-
-// Name returns the name of the chip.
-func (c *Npcx993) Name() string {
- return "NPCX993"
-}
-
-// EnabledNodes returns the list of node names that are to
-// enabled in DTS.
-func (c *Npcx993) EnabledNodes() []string {
- return c.okay
-}
-
-// Adc returns the ADC config associated with this pin.
-func (c *Npcx993) Adc(p string) string {
- s, ok := npcx993_pins[p]
- if ok {
- // Found the pin, now find the ADC name.
- for _, ss := range strings.Split(s, ",") {
- if strings.HasPrefix(ss, "ADC") && len(ss) > 3 {
- c.okay = append(c.okay, "adc0") // Enable ADC
- return ss[3:]
- }
- }
- return ""
- } else {
- return ""
- }
-}
-
-// Gpio returns the GPIO config for this pin, as
-// a GPIO controller name and a pin number.
-func (c *Npcx993) Gpio(p string) (string, int) {
- s, ok := npcx993_pins[p]
- if ok {
- // Found the pin, now find the GP name.
- for _, ss := range strings.Split(s, ",") {
- var offs int
- if strings.HasPrefix(ss, "GPO") && len(ss) == 5 {
- offs = 3
- } else if strings.HasPrefix(ss, "GPIO") && len(ss) == 6 {
- offs = 4
- } else {
- continue
- }
- lc := strings.ToLower(ss)
- pin := int(lc[offs+1] - '0')
- if pin < 0 || pin > 9 {
- fmt.Printf("Pin value is %d\n", pin)
- return "", 0
- }
- return fmt.Sprintf("gpio%c", lc[offs]), pin
- }
- return "", 0
- } else {
- return "", 0
- }
-}
-
-// I2c returns the I2C config for this pin.
-// Searches for the pattern I2Cx_SCLy.
-func (c *Npcx993) I2c(p string) string {
- s, ok := npcx993_pins[p]
- if ok {
- // Found the pin, now find the I2C port.
- for _, ss := range strings.Split(s, ",") {
- if len(ss) != 9 {
- continue
- }
- if strings.HasPrefix(ss, "I2C") &&
- ss[4:8] == "_SCL" {
- i2c := fmt.Sprintf("i2c%c_%c", ss[3], ss[8])
- c.okay = append(c.okay, i2c)
- c.okay = append(c.okay, fmt.Sprintf("i2c_ctrl%c", ss[3]))
- return i2c
- }
- }
- return ""
- } else {
- return ""
- }
-}
diff --git a/util/pinmap/chips/npcx993_test.go b/util/pinmap/chips/npcx993_test.go
deleted file mode 100644
index a3910416a2..0000000000
--- a/util/pinmap/chips/npcx993_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package chips_test
-
-import (
- "testing"
-
- "reflect"
- "sort"
-
- "pinmap/chips"
-)
-
-func TestName(t *testing.T) {
- expName := "NPCX993"
- var n chips.Npcx993
- name := n.Name()
- if name != expName {
- t.Errorf("Expected %s, got %s for Name()", expName, name)
- }
-}
-
-func TestMissing(t *testing.T) {
- var n chips.Npcx993
-
- none := "None"
- if n.Adc(none) != "" {
- t.Errorf("Expected empty string, got %s for Adc()", n.Adc(none))
- }
- gc, gp := n.Gpio(none)
- if gc != "" {
- t.Errorf("Expected empty string, got %s %d for Gpio()", gc, gp)
- }
- if n.I2c(none) != "" {
- t.Errorf("Expected empty string, got %s for I2c()", n.I2c(none))
- }
-}
-
-func TestMulti(t *testing.T) {
- var n chips.Npcx993
-
- pin := "F4"
- if n.Adc(pin) != "10" {
- t.Errorf("Expected \"10\", got %s for Adc()", n.Adc(pin))
- }
- gc, gp := n.Gpio(pin)
- if gc != "gpioe" || gp != 0 {
- t.Errorf("Expected \"gpioe 0\", got %s %d for Gpio()", gc, gp)
- }
- if n.I2c(pin) != "" {
- t.Errorf("Expected empty string, got %s for I2c()", n.I2c(pin))
- }
- pin = "F8"
- if n.I2c(pin) != "i2c3_0" {
- t.Errorf("Expected \"i2c3_0\", got %s for I2c()", n.I2c(pin))
- }
-}
-
-func TestAdcEnable(t *testing.T) {
- var n chips.Npcx993
-
- pin := "F4"
- if n.Adc(pin) != "10" {
- t.Errorf("Expected \"10\", got %s for Adc()", n.Adc(pin))
- }
- exp := []string{"adc0"}
- if !reflect.DeepEqual(n.EnabledNodes(), exp) {
- t.Errorf("Expected %v, got %v for EnabledNodes()", exp, n.EnabledNodes())
- }
-}
-
-func TestI2cEnable(t *testing.T) {
- var n chips.Npcx993
-
- n.I2c("F5") // i2c4_1
- n.I2c("C12") // i2c0_0
- exp := []string{"i2c0_0", "i2c4_1", "i2c_ctrl0", "i2c_ctrl4"}
- nodes := n.EnabledNodes()
- sort.Strings(nodes)
- if !reflect.DeepEqual(nodes, exp) {
- t.Errorf("Expected %v, got %v for EnabledNodes()", exp, n.EnabledNodes())
- }
-}
diff --git a/util/pinmap/chips/register.go b/util/pinmap/chips/register.go
deleted file mode 100644
index ff6d047140..0000000000
--- a/util/pinmap/chips/register.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package chips
-
-import (
- "pinmap/pm"
-)
-
-// init registers the chips.
-func init() {
- pm.RegisterChip(&It81302{})
- pm.RegisterChip(&Npcx993{})
-}
diff --git a/util/pinmap/go.mod b/util/pinmap/go.mod
deleted file mode 100644
index 7abf2b9886..0000000000
--- a/util/pinmap/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module pinmap
-
-go 1.15
diff --git a/util/pinmap/pinmap/main.go b/util/pinmap/pinmap/main.go
deleted file mode 100644
index 1576bac0dd..0000000000
--- a/util/pinmap/pinmap/main.go
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package main
-
-import (
- "flag"
- "fmt"
- "os"
-
- _ "pinmap/chips"
- "pinmap/pm"
- _ "pinmap/readers/csv"
-)
-
-var chipFlag = flag.String("chip", "", "Chip to use for pinmap")
-var output = flag.String("output", "gpio.dts", "Output file")
-var reader = flag.String("reader", "csv", "Input source type")
-var names = flag.Bool("names", false, "Generate gpio-line-names")
-var force = flag.Bool("force", false, "Overwrite output file")
-var column = flag.String("column", "", "Spreadsheet column index (A-Z) to use for chip pins")
-
-func main() {
- flag.Usage = Usage
- flag.Parse()
- if len(flag.Args()) == 0 {
- Error("No input arguments")
- }
- chip := pm.FindChip(*chipFlag)
- if chip == nil {
- Error(fmt.Sprintf("No matching chip for '%s'", *chipFlag))
- }
- pins, err := pm.ReadPins(*reader, *column, flag.Arg(0))
- if err != nil {
- Error(fmt.Sprintf("%s - %s: %v", *reader, flag.Arg(0), err))
- }
- if !*force && fileExists(*output) {
- Error(fmt.Sprintf("%s already exists - use --force to overwrite", *output))
- }
- out, err := os.Create(*output)
- defer out.Close()
- if err != nil {
- Error(fmt.Sprintf("Failed to create %s: %v", *output, err))
- }
- pm.Generate(out, pins, chip, *names)
-}
-
-// fileExists returns true if the file currently exists.
-func fileExists(name string) bool {
- _, err := os.Stat(name)
- return err == nil
-}
-
-// Error prints an error message to stderr and prints the usage.
-func Error(msg string) {
- fmt.Fprintf(os.Stderr, "%s\n", msg)
- Usage()
-}
-
-// Usage prints the usage of the command.
-func Usage() {
- fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
- fmt.Fprintf(os.Stderr, "%s [ flags ] input-argument\n", os.Args[0])
- flag.PrintDefaults()
- fmt.Fprintf(os.Stderr, "Available chips are:\n")
- for _, c := range pm.Chips() {
- fmt.Fprintf(os.Stderr, "%s\n", c)
- }
- fmt.Fprintf(os.Stderr, "Available readers are:\n")
- for _, r := range pm.Readers() {
- fmt.Fprintf(os.Stderr, "%s\n", r)
- }
- os.Exit(1)
-}
diff --git a/util/pinmap/pm/chip.go b/util/pinmap/pm/chip.go
deleted file mode 100644
index 9175647c9c..0000000000
--- a/util/pinmap/pm/chip.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm
-
-/*
- * Chip represents an Embedded Controller IC, where
- * pin names can be used to lookup various types of
- * pin usages such as I2C buses, GPIOs etc.
- * The pins are referenced as physical pin names such as "A4" etc.
- */
-type Chip interface {
- /*
- * Name returns the name of the chip
- */
- Name() string
- /*
- * EnabledNodes returns a list of names of DTS nodes that
- * require enabling i.e adding 'status = "okay"' on the nodes.
- */
- EnabledNodes() []string
- /*
- * Adc will return a DTS reference to the appropriate ADC
- * that is connected to this pin.
- */
- Adc(pin string) string
- /*
- * Gpio will return a gpio controller and a pin number for
- * the appropriate GPIO that is connected to this pin.
- */
- Gpio(pin string) (string, int)
- /*
- * I2C will return a DTS reference to the appropriate I2C
- * bus that is connected to this pin. The pin is assumed to be
- * the I2C clock pin of the 2 wire bus.
- */
- I2c(pin string) string
-}
-
-// chipList contains a list of registered chips.
-// Each chip has a unique name that is used to match it.
-var chipList []Chip
-
-// RegisterChip adds this chip into the list of registered chips.
-func RegisterChip(chip Chip) {
- chipList = append(chipList, chip)
-}
-
-// FindChip returns the registered chip matching this name, or nil
-// if none are found.
-func FindChip(name string) Chip {
- for _, c := range chipList {
- if c.Name() == name {
- return c
- }
- }
- return nil
-}
-
-// Chips returns the list of names of the registered chips.
-func Chips() []string {
- var l []string
- for _, c := range chipList {
- l = append(l, c.Name())
- }
- return l
-}
diff --git a/util/pinmap/pm/chip_test.go b/util/pinmap/pm/chip_test.go
deleted file mode 100644
index 1606646588..0000000000
--- a/util/pinmap/pm/chip_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm_test
-
-import (
- "testing"
-
- "reflect"
- "sort"
-
- "pinmap/pm"
-)
-
-type testChip struct {
- name string
- nodes []string
- adc string
- gc string
- gp int
- i2c string
-}
-
-func (c *testChip) Name() string {
- return c.name
-}
-
-func (c *testChip) EnabledNodes() []string {
- return c.nodes
-}
-
-func (c *testChip) Adc(pin string) string {
- return c.adc
-}
-
-func (c *testChip) Gpio(pin string) (string, int) {
- return c.gc, c.gp
-}
-
-func (c *testChip) I2c(pin string) string {
- return c.i2c
-}
-
-func TestName(t *testing.T) {
- n1 := "Test1"
- n2 := "Test2"
- tc1 := &testChip{name: n1}
- tc2 := &testChip{name: n2}
- pm.RegisterChip(tc1)
- pm.RegisterChip(tc2)
- if pm.FindChip(n1) != tc1 {
- t.Errorf("Did not match tc1")
- }
- if pm.FindChip(n2) != tc2 {
- t.Errorf("Did not match tc2")
- }
- chips := pm.Chips()
- sort.Strings(chips)
- exp := []string{n1, n2}
- if !reflect.DeepEqual(exp, chips) {
- t.Errorf("Expected %v, got %v", exp, chips)
- }
-}
diff --git a/util/pinmap/pm/generate.go b/util/pinmap/pm/generate.go
deleted file mode 100644
index 629aeaee15..0000000000
--- a/util/pinmap/pm/generate.go
+++ /dev/null
@@ -1,222 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm
-
-import (
- "fmt"
- "io"
- "sort"
- "strings"
- "time"
-)
-
-type lineName struct {
- pin int // Pin number
- name string // Pin name
-}
-
-const header = `/* Copyright %d The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * This file is auto-generated - do not edit!
- */
-
-/ {
-`
-
-// Generate creates the DTS configuration from the pins using the chip as a
-// reference and writes the DTS to the output.
-func Generate(out io.Writer, pins *Pins, chip Chip, names bool) {
- lineNameMap := make(map[string][]lineName)
- // Write header with date.
- fmt.Fprintf(out, header, time.Now().Year())
- // Default sort function (by Signal)
- sortSignal := func(iPin, jPin *Pin) bool {
- return jPin.Signal > iPin.Signal
- }
- // Sort function for I2C (by port).
- sortI2c := func(iPin, jPin *Pin) bool {
- return chip.I2c(jPin.Pin) > chip.I2c(iPin.Pin)
- }
- pinConfig(out, "named-adc-channels", pins.Adc, chip, sortSignal, adcConfig)
- pinConfig(out, "named-gpios", pins.Gpio, chip, sortSignal, func(out io.Writer, pin *Pin, chip Chip) {
- gpioConfig(out, pin, chip, lineNameMap)
- })
- pinConfig(out, "named-i2c-ports", pins.I2c, chip, sortI2c, i2cConfig)
- fmt.Fprintf(out, "};\n")
- // Retrieve the enabled nodes, sort, de-dup and
- // generate overlays.
- generateEnabledNodes(out, chip.EnabledNodes())
- // If gpio line names are required, generate them.
- if names {
- generateLineNames(out, lineNameMap)
- }
-}
-
-// pinConfig creates the DTS for a single pin.
-func pinConfig(out io.Writer, block string, pins []*Pin, chip Chip, sortFun func(*Pin, *Pin) bool, cfunc func(io.Writer, *Pin, Chip)) {
- if len(pins) == 0 {
- return
- }
- // Sort the pins.
- sort.Slice(pins, func(i, j int) bool {
- return sortFun(pins[i], pins[j])
- })
- // Generate start of block.
- fmt.Fprintf(out, "\n\t%s {\n", block)
- fmt.Fprintf(out, "\t\tcompatible = \"%s\";\n\n", block)
- for _, p := range pins {
- cfunc(out, p, chip)
- }
- fmt.Fprintf(out, "\t};\n")
-}
-
-// adcConfig is the handler for ADC pins.
-func adcConfig(out io.Writer, pin *Pin, chip Chip) {
- if pin.PinType != ADC {
- fmt.Printf("Unknown ADC type (%d) for pin %s, ignored\n", pin.PinType, pin.Pin)
- return
- }
- c := chip.Adc(pin.Pin)
- if len(c) == 0 {
- fmt.Printf("No matching ADC for pin %s, ignored\n", pin.Pin)
- return
- }
- lc := strings.ToLower(pin.Signal)
- fmt.Fprintf(out, "\t\tadc_%s: %s {\n", lc, lc)
- if len(pin.Enum) > 0 {
- fmt.Fprintf(out, "\t\t\tenum-name = \"%s\";\n", pin.Enum)
- }
- fmt.Fprintf(out, "\t\t\tio-channels = <&adc0 %s>;\n", c)
- fmt.Fprintf(out, "\t\t};\n")
-}
-
-// gpioConfig is the handler for GPIO pins. It also stores
-// the line name into the map.
-func gpioConfig(out io.Writer, pin *Pin, chip Chip, lineNameMap map[string][]lineName) {
- gc, gp := chip.Gpio(pin.Pin)
- if len(gc) == 0 {
- fmt.Printf("No matching GPIO for pin %s, ignored\n", pin.Pin)
- return
- }
- var gtype string
- switch pin.PinType {
- default:
- fmt.Printf("Unknown GPIO type (%d) for pin %s, ignored\n", pin.PinType, pin.Pin)
- return
- case Input:
- gtype = "GPIO_INPUT"
- case InputL:
- gtype = "(GPIO_INPUT | GPIO_ACTIVE_LOW)"
- case InputPU:
- gtype = "GPIO_INPUT_PULL_UP"
- case InputPUL:
- gtype = "(GPIO_INPUT_PULL_UP | GPIO_ACTIVE_LOW)"
- case InputPD:
- gtype = "GPIO_INPUT_PULL_DOWN"
- case Output:
- gtype = "GPIO_OUTPUT"
- case OutputL:
- gtype = "(GPIO_OUTPUT | GPIO_ACTIVE_LOW)"
- case OutputOD:
- gtype = "GPIO_ODR_HIGH"
- case OutputODL:
- gtype = "GPIO_ODR_LOW"
- }
- lc := strings.ToLower(pin.Signal)
- fmt.Fprintf(out, "\t\tgpio_%s: %s {\n", lc, lc)
- fmt.Fprintf(out, "\t\t\tgpios = <&%s %d %s>;\n", gc, gp, gtype)
- if len(pin.Enum) > 0 {
- fmt.Fprintf(out, "\t\t\tenum-name = \"%s\";\n", pin.Enum)
- }
- fmt.Fprintf(out, "\t\t};\n")
- lineNameMap[gc] = append(lineNameMap[gc], lineName{gp, lc})
-}
-
-// i2cConfig is the handler for I2C pins.
-func i2cConfig(out io.Writer, pin *Pin, chip Chip) {
- if pin.PinType != I2C {
- fmt.Printf("Unknown I2C type (%d) for pin %s, ignored\n", pin.PinType, pin.Pin)
- return
- }
- c := chip.I2c(pin.Pin)
- if len(c) == 0 {
- fmt.Printf("No matching I2C for pin %s, ignored\n", pin.Pin)
- return
- }
- // Trim off trailing clock name (if any)
- lc := strings.TrimRight(strings.ToLower(pin.Signal), "_scl")
- fmt.Fprintf(out, "\t\ti2c_%s: %s {\n", lc, lc)
- fmt.Fprintf(out, "\t\t\ti2c-port = <&%s>;\n", c)
- if len(pin.Enum) > 0 {
- fmt.Fprintf(out, "\t\t\tenum-names = \"%s\";\n", pin.Enum)
- }
- fmt.Fprintf(out, "\t\t};\n")
-}
-
-// generateEnabledNodes generates a "status = okay"
-// property for the list of nodes passed.
-func generateEnabledNodes(out io.Writer, nodes []string) {
- if len(nodes) != 0 {
- sort.Strings(nodes)
- var prev string
- for _, s := range nodes {
- if s == prev {
- continue
- }
- fmt.Fprintf(out, "\n&%s {\n", s)
- fmt.Fprintf(out, "\tstatus = \"okay\";\n")
- fmt.Fprintf(out, "};\n")
- prev = s
- }
- }
-}
-
-// generateLineNames generates GPIO line names
-// for the GPIO controller map passed.
-// Empty strings are added for missing pins.
-// The format generated is:
-//
-// &gpioX {
-// gpio-line-names =
-// "",
-// "gpio_name_1",
-// "",
-// "",
-// "gpio_name_2";
-// };
-//
-func generateLineNames(out io.Writer, gpios map[string][]lineName) {
- // Sort the GPIO controller names.
- var gcList []string
- for gc := range gpios {
- gcList = append(gcList, gc)
- }
- sort.Strings(gcList)
- for _, gc := range gcList {
- ln := gpios[gc]
- // Sort names into pin order.
- sort.Slice(ln, func(i, j int) bool {
- return ln[j].pin > ln[i].pin
- })
- fmt.Fprintf(out, "\n&%s {\n", gc)
- fmt.Fprintf(out, "\tgpio-line-names =\n")
- fmt.Fprintf(out, "\t\t")
- for i, v := range ln {
- // If not the first, add comma and step to next line
- if i != 0 {
- fmt.Fprintf(out, ",\n\t\t")
- }
- // Add filler empty strings
- for sk := i; sk < v.pin; sk++ {
- fmt.Fprintf(out, "\"\",\n\t\t")
- }
- fmt.Fprintf(out, "\"%s\"", v.name)
- }
- fmt.Fprintf(out, ";\n")
- fmt.Fprintf(out, "};\n")
- }
-}
diff --git a/util/pinmap/pm/generate_test.go b/util/pinmap/pm/generate_test.go
deleted file mode 100644
index 3ecdb7d1c2..0000000000
--- a/util/pinmap/pm/generate_test.go
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm_test
-
-import (
- "testing"
-
- "bytes"
- "fmt"
- "strings"
- "time"
-
- "pinmap/pm"
-)
-
-type genChip struct {
-}
-
-func (c *genChip) Name() string {
- return "Test"
-}
-
-func (c *genChip) EnabledNodes() []string {
- return []string{"adc0", "i2c0", "i2c1", "i2c2"}
-}
-
-func (c *genChip) Adc(pin string) string {
- return pin
-}
-
-func (c *genChip) Gpio(pin string) (string, int) {
-
- return fmt.Sprintf("gpio%c", pin[0]), int(pin[1] - '0')
-}
-
-func (c *genChip) I2c(pin string) string {
- switch pin {
- case "B2":
- return "i2c2"
- case "B3":
- return "i2c1"
- case "B4":
- return "i2c0"
- }
- panic(fmt.Sprintf("Unknown I2C: %s", pin))
-}
-
-func TestGenerate(t *testing.T) {
- pins := &pm.Pins{
- Adc: []*pm.Pin{
- &pm.Pin{pm.ADC, "A1", "EC_ADC_1", "ENUM_ADC_1"},
- },
- I2c: []*pm.Pin{
- &pm.Pin{pm.I2C, "B4", "EC_C_I2C_CLK", "ENUM_I2C_0"},
- &pm.Pin{pm.I2C, "B3", "EC_B_I2C_CLK", "ENUM_I2C_1"},
- &pm.Pin{pm.I2C, "B2", "EC_A_I2C_CLK", "ENUM_I2C_2"},
- },
- Gpio: []*pm.Pin{
- &pm.Pin{pm.Input, "C3", "EC_IN_1", "ENUM_IN_1"},
- &pm.Pin{pm.Output, "D4", "EC_OUT_2", "ENUM_OUT_2"},
- &pm.Pin{pm.InputPU, "G7", "EC_IN_3", "ENUM_IN_3"},
- &pm.Pin{pm.InputPD, "H8", "EC_IN_4", "ENUM_IN_4"},
- },
- }
- var out bytes.Buffer
- pm.Generate(&out, pins, &genChip{}, true)
- /*
- * Rather than doing a golden output text compare, it would be better
- * to parse the device tree directly and ensuing it is correct.
- * However this would considerably complicate this test.
- */
- expFmt :=
- `/* Copyright %d The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * This file is auto-generated - do not edit!
- */
-
-/ {
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_ec_adc_1: ec_adc_1 {
- enum-name = "ENUM_ADC_1";
- io-channels = <&adc0 A1>;
- };
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_ec_in_1: ec_in_1 {
- gpios = <&gpioC 3 GPIO_INPUT>;
- enum-name = "ENUM_IN_1";
- };
- gpio_ec_in_3: ec_in_3 {
- gpios = <&gpioG 7 GPIO_INPUT_PULL_UP>;
- enum-name = "ENUM_IN_3";
- };
- gpio_ec_in_4: ec_in_4 {
- gpios = <&gpioH 8 GPIO_INPUT_PULL_DOWN>;
- enum-name = "ENUM_IN_4";
- };
- gpio_ec_out_2: ec_out_2 {
- gpios = <&gpioD 4 GPIO_OUTPUT>;
- enum-name = "ENUM_OUT_2";
- };
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_ec_c_i2c_clk: ec_c_i2c_clk {
- i2c-port = <&i2c0>;
- enum-names = "ENUM_I2C_0";
- };
- i2c_ec_b_i2c_clk: ec_b_i2c_clk {
- i2c-port = <&i2c1>;
- enum-names = "ENUM_I2C_1";
- };
- i2c_ec_a_i2c_clk: ec_a_i2c_clk {
- i2c-port = <&i2c2>;
- enum-names = "ENUM_I2C_2";
- };
- };
-};
-
-&adc0 {
- status = "okay";
-};
-
-&i2c0 {
- status = "okay";
-};
-
-&i2c1 {
- status = "okay";
-};
-
-&i2c2 {
- status = "okay";
-};
-
-&gpioC {
- gpio-line-names =
- "",
- "",
- "",
- "ec_in_1";
-};
-
-&gpioD {
- gpio-line-names =
- "",
- "",
- "",
- "",
- "ec_out_2";
-};
-
-&gpioG {
- gpio-line-names =
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "ec_in_3";
-};
-
-&gpioH {
- gpio-line-names =
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "ec_in_4";
-};
-`
- exp := fmt.Sprintf(expFmt, time.Now().Year())
- got := out.String()
- if exp != got {
- // Split each string into lines and compare the lines.
- expLines := strings.Split(exp, "\n")
- gotLines := strings.Split(got, "\n")
- if len(expLines) != len(gotLines) {
- t.Errorf("Expected %d lines, got %d lines", len(expLines), len(gotLines))
- }
- for i := range expLines {
- if i < len(gotLines) && expLines[i] != gotLines[i] {
- t.Errorf("%d: exp %s, got %s", i+1, expLines[i], gotLines[i])
- }
- }
- }
-}
diff --git a/util/pinmap/pm/pins.go b/util/pinmap/pm/pins.go
deleted file mode 100644
index 61cd7cc043..0000000000
--- a/util/pinmap/pm/pins.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm
-
-// Pin types enum constants
-const (
- ADC = iota
- I2C
- Input
- InputL
- InputPU
- InputPUL
- InputPD
- Output
- OutputL
- OutputOD
- OutputODL
-)
-
-// Pin represents one EC pin.
-type Pin struct {
- PinType int // Type of pin (from above)
- Pin string // The reference of the physical pin.
- Signal string // The net (circuit) name of the pin
- Enum string // If set, the internal s/w name of the pin
-}
-
-// The accumulated pins of the EC.
-type Pins struct {
- Adc []*Pin // Analogue to digital converters
- I2c []*Pin // I2C busses
- Gpio []*Pin // GPIO pins
-}
diff --git a/util/pinmap/pm/reader.go b/util/pinmap/pm/reader.go
deleted file mode 100644
index 4af8e29ed9..0000000000
--- a/util/pinmap/pm/reader.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm
-
-import (
- "fmt"
-)
-
-// Reader reads the pin configuration from a source.
-type Reader interface {
- Name() string
- Read(key string, arg string) (*Pins, error)
-}
-
-// readerlist is registered list of readers.
-var readerList []Reader
-
-// ReadPins will use the selected reader and the key to
-// read the EC pin data.
-func ReadPins(reader, key, arg string) (*Pins, error) {
- for _, r := range readerList {
- if r.Name() == reader {
- return r.Read(key, arg)
- }
- }
- return nil, fmt.Errorf("%s: unknown reader", reader)
-}
-
-// Readers returns a list of the reader names.
-func Readers() []string {
- var l []string
- for _, r := range readerList {
- l = append(l, r.Name())
- }
- return l
-}
-
-// RegisterReader will add this reader to the registered list of readers.
-func RegisterReader(reader Reader) {
- readerList = append(readerList, reader)
-}
diff --git a/util/pinmap/pm/reader_test.go b/util/pinmap/pm/reader_test.go
deleted file mode 100644
index ca004eab6a..0000000000
--- a/util/pinmap/pm/reader_test.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package pm_test
-
-import (
- "testing"
-
- "reflect"
-
- "pinmap/pm"
-)
-
-type testReader struct {
- name string
- key string
- arg string
- pins pm.Pins
-}
-
-func (r *testReader) Name() string {
- return r.name
-}
-
-func (r *testReader) Read(key, arg string) (*pm.Pins, error) {
- r.key = key
- r.arg = arg
- return &r.pins, nil
-}
-
-func TestReader(t *testing.T) {
- n := "Test1"
- tr1 := &testReader{name: n}
- pm.RegisterReader(tr1)
- p, err := pm.ReadPins(n, "key", "arg1")
- if err != nil {
- t.Errorf("Error %v on reading pins", err)
- }
- if p != &tr1.pins {
- t.Errorf("Did not match Pins")
- }
- p, err = pm.ReadPins("notMine", "key", "arg1")
- if err == nil {
- t.Errorf("Should heve returned error")
- }
- readers := pm.Readers()
- exp := []string{n}
- if !reflect.DeepEqual(exp, readers) {
- t.Errorf("Expected %v, got %v", exp, readers)
- }
-}
diff --git a/util/pinmap/readers/csv/csv.go b/util/pinmap/readers/csv/csv.go
deleted file mode 100644
index df763561bb..0000000000
--- a/util/pinmap/readers/csv/csv.go
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package csv
-
-import (
- "bufio"
- "encoding/csv"
- "fmt"
- "os"
- "strings"
-
- "pinmap/pm"
-)
-
-// CSVReader reads the EC pin references from a comma separated
-// values file.
-type CSVReader struct {
-}
-
-// Name returns the name of this reader.
-func (r *CSVReader) Name() string {
- return "csv"
-}
-
-// Read reads the CSV file (provided as an argument) and extracts
-// the pin reference data. The first line is expected to be column
-// titles that are used to identify the columns.
-// columnKey identifies the column to use for the pin allocations,
-// such as "A", "B" etc.
-func (r *CSVReader) Read(columnKey, filepath string) (*pm.Pins, error) {
- if len(columnKey) != 1 {
- return nil, fmt.Errorf("illegal column name: '%s'", columnKey)
- }
- column := int(strings.ToLower(columnKey)[0] - 'a')
- if column < 0 || column > 'Z'-'A' {
- return nil, fmt.Errorf("illegal column name (should be 'A' - 'Z')")
- }
- f, err := os.Open(filepath)
- if err != nil {
- return nil, err
- }
- defer f.Close()
- rdr := csv.NewReader(bufio.NewReader(f))
- data, err := rdr.ReadAll()
- if err != nil {
- return nil, err
- }
- if len(data) < 2 {
- return nil, fmt.Errorf("no data in file")
- }
- if len(data[0]) < column {
- return nil, fmt.Errorf("Column '%s' is out of range", columnKey)
- }
- // Put the CSV headers into a map.
- cmap := make(map[string]int)
- for c, s := range data[0] {
- cmap[s] = c
- }
- // Find the matching columns that are needed.
- signal, ok := cmap["Signal Name"]
- if !ok {
- return nil, fmt.Errorf("missing 'Signal Name' column")
- }
- chipKey := data[0][column]
- chip, ok := cmap[chipKey]
- if !ok {
- return nil, fmt.Errorf("missing '%s' chip column", chipKey)
- }
- ptype, ok := cmap["Type"]
- if !ok {
- return nil, fmt.Errorf("missing 'Type' column")
- }
- enum, ok := cmap["Enum"]
- if !ok {
- return nil, fmt.Errorf("missing 'Enum' column")
- }
- var pins pm.Pins
- // Read the rest of the rows.
- for i, row := range data[1:] {
- p := new(pm.Pin)
- switch row[ptype] {
- default:
- fmt.Printf("%s:%d: Unknown signal type (%s) - ignored\n", filepath, i+1, row[ptype])
- continue
- case "OTHER":
- case "PWM":
- case "PWM_INVERT":
- // Skipped
- continue
- case "ADC":
- p.PinType = pm.ADC
- pins.Adc = append(pins.Adc, p)
- case "I2C_DATA":
- // Only the clock pin is used for the config
- continue
- case "I2C_CLOCK":
- p.PinType = pm.I2C
- pins.I2c = append(pins.I2c, p)
- case "INPUT":
- p.PinType = pm.Input
- pins.Gpio = append(pins.Gpio, p)
- case "INPUT_L":
- p.PinType = pm.InputL
- pins.Gpio = append(pins.Gpio, p)
- case "INPUT_PU":
- p.PinType = pm.InputPU
- pins.Gpio = append(pins.Gpio, p)
- case "INPUT_PU_L":
- p.PinType = pm.InputPUL
- pins.Gpio = append(pins.Gpio, p)
- case "INPUT_PD":
- p.PinType = pm.InputPD
- pins.Gpio = append(pins.Gpio, p)
- case "OUTPUT":
- p.PinType = pm.Output
- pins.Gpio = append(pins.Gpio, p)
- case "OUTPUT_L":
- p.PinType = pm.OutputL
- pins.Gpio = append(pins.Gpio, p)
- case "OUTPUT_ODL":
- p.PinType = pm.OutputODL
- pins.Gpio = append(pins.Gpio, p)
- case "OUTPUT_ODR":
- p.PinType = pm.OutputOD
- pins.Gpio = append(pins.Gpio, p)
- }
- p.Signal = row[signal]
- p.Pin = row[chip]
- p.Enum = row[enum]
- }
-
- return &pins, nil
-}
diff --git a/util/pinmap/readers/csv/csv_test.go b/util/pinmap/readers/csv/csv_test.go
deleted file mode 100644
index e1140ccb75..0000000000
--- a/util/pinmap/readers/csv/csv_test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package csv_test
-
-import (
- "testing"
-
- "path/filepath"
- "reflect"
-
- "pinmap/pm"
- "pinmap/readers/csv"
-)
-
-const column = "B"
-
-func TestName(t *testing.T) {
- var r csv.CSVReader
- if r.Name() != "csv" {
- t.Errorf("expected %s, got %s", "csv", r.Name())
- }
- pins, err := r.Read(column, filepath.Join("testdata", "data.csv"))
- if err != nil {
- t.Fatalf("data.csv: %v", err)
- }
- exp := &pm.Pins{
- Adc: []*pm.Pin{
- &pm.Pin{pm.ADC, "A1", "EC_ADC_1", "ENUM_ADC_1"},
- },
- I2c: []*pm.Pin{
- &pm.Pin{pm.I2C, "G7", "EC_I2C_CLK_0", "SENSOR"},
- },
- Gpio: []*pm.Pin{
- &pm.Pin{pm.Input, "D4", "EC_GPIO_1", "GPIO1"},
- &pm.Pin{pm.Output, "E5", "EC_GPIO_2", "GPIO2"},
- &pm.Pin{pm.OutputODL, "F6", "EC_GPIO_3", ""},
- &pm.Pin{pm.InputPU, "K10", "EC_GPIO_4", ""},
- },
- }
- check(t, "ADc", exp.Adc, pins.Adc)
- check(t, "I2c", exp.I2c, pins.I2c)
- check(t, "Gpio", exp.Gpio, pins.Gpio)
-}
-
-func check(t *testing.T, name string, exp, got []*pm.Pin) {
- if !reflect.DeepEqual(exp, got) {
- t.Errorf("%s - expected:", name)
- for _, p := range exp {
- t.Errorf("%v", *p)
- }
- t.Errorf("got:")
- for _, p := range got {
- t.Errorf("%v", *p)
- }
- }
-}
diff --git a/util/pinmap/readers/csv/register.go b/util/pinmap/readers/csv/register.go
deleted file mode 100644
index 7ccb18e78a..0000000000
--- a/util/pinmap/readers/csv/register.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2021 The ChromiumOS Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package csv
-
-import (
- "pinmap/pm"
-)
-
-func init() {
- pm.RegisterReader(&CSVReader{})
-}
diff --git a/util/pinmap/readers/csv/testdata/data.csv b/util/pinmap/readers/csv/testdata/data.csv
deleted file mode 100644
index 8f1be84801..0000000000
--- a/util/pinmap/readers/csv/testdata/data.csv
+++ /dev/null
@@ -1,9 +0,0 @@
-Signal Name,MyCHIP,Type,Enum
-EC_ADC_1,A1,ADC,ENUM_ADC_1
-EC_IGNORED_1,B2,OTHER,
-EC_GPIO_1,D4,INPUT,GPIO1
-EC_GPIO_2,E5,OUTPUT,GPIO2
-EC_GPIO_3,F6,OUTPUT_ODL,
-EC_I2C_CLK_0,G7,I2C_CLOCK,SENSOR
-EC_I2C_DATA_0,H8,I2C_DATA,
-EC_GPIO_4,K10,INPUT_PU,