updated dependencies
This commit is contained in:
1 parent
2729a727dc
commit
fb5f6a0d85
9 files changed
+52
-95
No files matched your search
+41
-28
@@ -8,14 +8,14 @@
|
||||
package allwinner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"periph.io/x/conn/v3/pin"
|
||||
"periph.io/x/host/v3/sysfs"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// mappingH6 describes the mapping of the H5 processor gpios to their
|
||||
// mappingH6 describes the mapping of the H6 processor gpios to their
|
||||
// alternate functions.
|
||||
// According to https://linux-sunxi.org/H616 H616 and H618 are the same.
|
||||
// allwinner marketing team seems to disagree.
|
||||
@@ -31,25 +31,36 @@ import (
|
||||
// - SDC means SDCard?
|
||||
// - NAND connects to a NAND flash controller.
|
||||
// - CSI and CCI are for video capture.
|
||||
var mappingH6 = map[string][5]pin.Func{
|
||||
"PC0": {"NAND_WE", "SDC2_DS", "SPI0_CLK", "", "PA_EINT0"},
|
||||
"PC1": {"NAND_ALE", "SDC2_RST", "", "", "PA_EINT1"},
|
||||
"PC2": {"NAND_CLE", "", "SPI0_MOSI", "", "PA_EINT2"},
|
||||
"PC3": {"NAND_CE1", "", "SPI0_CS0", "BOOT_SEL1", "PA_EINT3"},
|
||||
"PC4": {"NAND_CE0", "", "SPI0_MIS0", "BOOT_SEL2", "PA_EINT4"},
|
||||
"PC5": {"NAND_RE", "SDC2_CLK", "", "BOOT_SEL3", "PA_EINT5"},
|
||||
"PC6": {"NAND_RB0", "SDC2_CMD", "", "BOOT_SEL4", "PA_EINT6"},
|
||||
"PC7": {"NAND_RB1", "", "SPI0_CS1", "", "PA_EINT7"},
|
||||
"PC8": {"NAND_DQ7", "SDC2_D3", "", "", "PA_EINT8"},
|
||||
//
|
||||
// The data itself has been extracted from the pdf using
|
||||
// https://ronnywang.github.io/pdf-table-extractor/ and some
|
||||
// scripting. The data has been validated manually.
|
||||
//
|
||||
//go:embed H6_pins.json
|
||||
var h6PinsSpec []byte
|
||||
|
||||
"PC9": {"NAND_DQ6", "SDC2_D4", "", "", "PA_EINT9"},
|
||||
"PC10": {"NAND_DQ5", "SDC2_D0", "", "", "PA_EINT10"},
|
||||
"PC11": {"NAND_DQ4", "SDC2_D5", "", "", "PA_EINT11"},
|
||||
"PC12": {"NAND_DQS", "", "", "", "PA_EINT12"},
|
||||
"PC13": {"NAND_DQ3", "SDC2_D1", "", "", "PA_EINT13"},
|
||||
"PC14": {"NAND_DQ2", "SDC2_D6", "", "", "PA_EINT14"},
|
||||
"PC15": {"NAND_DQ1", "SDC2_D1", "SPI0_WP", "", "PA_EINT15"},
|
||||
"PC16": {"NAND_DQ0", "SDC2_D7", "SPI0_HOLD", "", "PA_EINT16"},
|
||||
type serializedPinSpec struct {
|
||||
Name string
|
||||
Function2 pin.Func
|
||||
Function3 pin.Func
|
||||
Function4 pin.Func
|
||||
Function5 pin.Func
|
||||
Function6 pin.Func
|
||||
}
|
||||
|
||||
func getH6SerializedPinSpecs() ([]serializedPinSpec, error) {
|
||||
var serializedPins []serializedPinSpec
|
||||
err := json.Unmarshal(h6PinsSpec, &serializedPins)
|
||||
return serializedPins, err
|
||||
}
|
||||
|
||||
func getAltFunc(pinSpec serializedPinSpec) [5]pin.Func {
|
||||
return [5]pin.Func{
|
||||
pinSpec.Function2,
|
||||
pinSpec.Function3,
|
||||
pinSpec.Function4,
|
||||
pinSpec.Function5,
|
||||
pinSpec.Function6}
|
||||
}
|
||||
|
||||
// mapH6Pins uses mappingH6 to actually set the altFunc fields of all gpio
|
||||
@@ -57,15 +68,17 @@ var mappingH6 = map[string][5]pin.Func{
|
||||
//
|
||||
// It is called by the generic allwinner processor code if an H6 is detected.
|
||||
func mapH6Pins() error {
|
||||
fmt.Println("Initializing H6 pins.")
|
||||
for name, altFuncs := range mappingH6 {
|
||||
pin := cpupins[name]
|
||||
pin.altFunc = altFuncs
|
||||
serializedPinSpecs, err := getH6SerializedPinSpecs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, pinSpec := range serializedPinSpecs {
|
||||
pin := cpupins[pinSpec.Name]
|
||||
pin.altFunc = getAltFunc(pinSpec)
|
||||
pin.available = true
|
||||
if strings.Contains(string(altFuncs[4]), "_EINT") {
|
||||
if strings.Contains(string(pinSpec.Function6), "_EINT") {
|
||||
pin.supportEdge = true
|
||||
}
|
||||
|
||||
// Initializes the sysfs corresponding pin right away.
|
||||
pin.sysfsPin = sysfs.Pins[pin.Number()]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user