updated dependencies
This commit is contained in:
1 parent
2729a727dc
commit
fb5f6a0d85
9 files changed
+52
-95
No files matched your search
@@ -2,7 +2,7 @@ module go-orange
|
|||||||
|
|
||||||
go 1.22
|
go 1.22
|
||||||
|
|
||||||
replace periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.3-0.20240731020403-7fe82b3432d5
|
replace periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.3-0.20240804011140-a6ce90fa3ccf
|
||||||
|
|
||||||
require (
|
require (
|
||||||
periph.io/x/conn/v3 v3.7.0
|
periph.io/x/conn/v3 v3.7.0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
github.com/didiercrunch/host/v3 v3.8.3-0.20240731020403-7fe82b3432d5 h1:sH6pH2bxUcJuJuPjAT4cfYQoT3F9OZfCC5x+Z1USgrw=
|
github.com/didiercrunch/host/v3 v3.8.3-0.20240804011140-a6ce90fa3ccf h1:66BDi2FDDzhPPu79j+HyKgrk7nO19Wa4tTOjZat3ITc=
|
||||||
github.com/didiercrunch/host/v3 v3.8.3-0.20240731020403-7fe82b3432d5/go.mod h1:yFL76AesNHR68PboofSWYaQTKmvPXsQH2Apvp/ls/K4=
|
github.com/didiercrunch/host/v3 v3.8.3-0.20240804011140-a6ce90fa3ccf/go.mod h1:yFL76AesNHR68PboofSWYaQTKmvPXsQH2Apvp/ls/K4=
|
||||||
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
|
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
|
||||||
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||||
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
|
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ func Present() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
boardZero string = "Orange Pi Zero" // + LTS (H2/H3 have identical pinouts)
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
PC1_5 gpio.PinIO = allwinner.PC5
|
PC1_5 gpio.PinIO = allwinner.PC5
|
||||||
PC1_6 gpio.PinIO = allwinner.PC6
|
PC1_6 gpio.PinIO = allwinner.PC6
|
||||||
|
|||||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ periph.io/x/conn/v3/pin
|
|||||||
periph.io/x/conn/v3/pin/pinreg
|
periph.io/x/conn/v3/pin/pinreg
|
||||||
periph.io/x/conn/v3/spi
|
periph.io/x/conn/v3/spi
|
||||||
periph.io/x/conn/v3/spi/spireg
|
periph.io/x/conn/v3/spi/spireg
|
||||||
# periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.3-0.20240731020403-7fe82b3432d5
|
# periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.3-0.20240804011140-a6ce90fa3ccf
|
||||||
## explicit; go 1.20
|
## explicit; go 1.20
|
||||||
periph.io/x/host/v3
|
periph.io/x/host/v3
|
||||||
periph.io/x/host/v3/allwinner
|
periph.io/x/host/v3/allwinner
|
||||||
|
|||||||
-4
@@ -5,7 +5,6 @@
|
|||||||
package allwinner
|
package allwinner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -42,7 +41,6 @@ func IsA20() bool {
|
|||||||
// It looks for the string "sun50iw1p1" in /proc/device-tree/compatible.
|
// It looks for the string "sun50iw1p1" in /proc/device-tree/compatible.
|
||||||
func IsA64() bool {
|
func IsA64() bool {
|
||||||
detection.do()
|
detection.do()
|
||||||
fmt.Printf("IsA64? %t\n", detection.isA64)
|
|
||||||
return detection.isA64
|
return detection.isA64
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +96,6 @@ func (d *detectionS) do() {
|
|||||||
d.done = true
|
d.done = true
|
||||||
if isArm {
|
if isArm {
|
||||||
for _, c := range distro.DTCompatible() {
|
for _, c := range distro.DTCompatible() {
|
||||||
fmt.Println("distro >>> " + c)
|
|
||||||
if strings.Contains(c, "sun50iw1p1") {
|
if strings.Contains(c, "sun50iw1p1") {
|
||||||
d.isA64 = true
|
d.isA64 = true
|
||||||
}
|
}
|
||||||
@@ -117,7 +114,6 @@ func (d *detectionS) do() {
|
|||||||
d.isH5 = true
|
d.isH5 = true
|
||||||
}
|
}
|
||||||
if strings.Contains(c, "sun50i-h6") {
|
if strings.Contains(c, "sun50i-h6") {
|
||||||
fmt.Println("isH6 detected")
|
|
||||||
d.isH6 = true
|
d.isH6 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-46
@@ -11,7 +11,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -309,10 +308,8 @@ func (p *Pin) Read() gpio.Level {
|
|||||||
//
|
//
|
||||||
// This function is very fast.
|
// This function is very fast.
|
||||||
func (p *Pin) FastRead() gpio.Level {
|
func (p *Pin) FastRead() gpio.Level {
|
||||||
|
status := drvGPIO.gpioMemory.groups[p.group].data
|
||||||
foo := drvGPIO.gpioMemory.groups[p.group].data
|
return status&(1<<p.offset) != 0
|
||||||
fmt.Printf("Group value is: %d", foo)
|
|
||||||
return gpio.Level(foo&(1<<p.offset) != 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForEdge implements gpio.PinIn.
|
// WaitForEdge implements gpio.PinIn.
|
||||||
@@ -483,17 +480,9 @@ func (p *Pin) setFunction(f function) {
|
|||||||
mask := uint32(disabled) << shift
|
mask := uint32(disabled) << shift
|
||||||
v := (uint32(f) << shift) ^ mask
|
v := (uint32(f) << shift) ^ mask
|
||||||
// First disable, then setup. This is concurrent safe.
|
// First disable, then setup. This is concurrent safe.
|
||||||
original := drvGPIO.gpioMemory.groups[p.group].cfg[off]
|
|
||||||
drvGPIO.gpioMemory.groups[p.group].cfg[off] |= mask
|
drvGPIO.gpioMemory.groups[p.group].cfg[off] |= mask
|
||||||
drvGPIO.gpioMemory.groups[p.group].cfg[off] &^= v
|
drvGPIO.gpioMemory.groups[p.group].cfg[off] &^= v
|
||||||
|
|
||||||
modified := original | mask
|
|
||||||
modified &^= v
|
|
||||||
fmt.Printf("Original: %d\n", original)
|
|
||||||
fmt.Printf("Modified: %d\n", modified)
|
|
||||||
fmt.Printf("Memory mapped value: %d\n", drvGPIO.gpioMemory.groups[p.group].cfg[off])
|
|
||||||
if p.function() != f {
|
if p.function() != f {
|
||||||
fmt.Printf("Pin number %d. Pin name %s.\n Expected %d to equals %d \n", p.Number(), p.Name(), p.function(), f)
|
|
||||||
panic(f)
|
panic(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1018,7 +1007,6 @@ func (d *driverGPIO) Init() (bool, error) {
|
|||||||
|
|
||||||
// Mark the right pins as available even if the memory map fails so they can
|
// Mark the right pins as available even if the memory map fails so they can
|
||||||
// callback to sysfs.Pins.
|
// callback to sysfs.Pins.
|
||||||
fmt.Println("Didier initiating allwinner gpio")
|
|
||||||
switch {
|
switch {
|
||||||
case IsA64():
|
case IsA64():
|
||||||
if err := mapA64Pins(); err != nil {
|
if err := mapA64Pins(); err != nil {
|
||||||
@@ -1041,18 +1029,19 @@ func (d *driverGPIO) Init() (bool, error) {
|
|||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
case IsH6():
|
case IsH6():
|
||||||
fmt.Println("Is H6 CPU!!!")
|
|
||||||
if err := mapH6Pins(); err != nil {
|
if err := mapH6Pins(); err != nil {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Println("error: unknown Allwinner CPU model")
|
|
||||||
return false, errors.New("unknown Allwinner CPU model")
|
return false, errors.New("unknown Allwinner CPU model")
|
||||||
}
|
}
|
||||||
|
|
||||||
// gpioBaseAddr is the physical base address of the GPIO registers.
|
// gpioBaseAddr is the physical base address of the GPIO registers.
|
||||||
gpioBaseAddr := uint32(getBaseAddressDidier())
|
gpioBaseAddr, err := getBaseAddress()
|
||||||
if err := pmem.MapAsPOD(uint64(gpioBaseAddr), &d.gpioMemory); err != nil {
|
if err != nil {
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
if err := pmem.MapAsPOD(gpioBaseAddr, &d.gpioMemory); err != nil {
|
||||||
if os.IsPermission(err) {
|
if os.IsPermission(err) {
|
||||||
return true, fmt.Errorf("need more access, try as root: %v", err)
|
return true, fmt.Errorf("need more access, try as root: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1064,38 +1053,10 @@ func (d *driverGPIO) Init() (bool, error) {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if isArm {
|
if isArm {
|
||||||
fmt.Println("Stating to initiate allwinner")
|
|
||||||
driverreg.MustRegister(&drvGPIO)
|
driverreg.MustRegister(&drvGPIO)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getBaseAddress queries the virtual file system to retrieve the base address
|
|
||||||
// of the GPIO registers for GPIO pins in groups PA to PI.
|
|
||||||
//
|
|
||||||
// Defaults to 0x01C20800 as per datasheet if it could not query the file
|
|
||||||
// system.
|
|
||||||
func getBaseAddress() uint64 {
|
|
||||||
base := uint64(0x01C20800)
|
|
||||||
link, err := os.Readlink("/sys/bus/platform/drivers/sun50i-pinctrl/driver")
|
|
||||||
if err != nil {
|
|
||||||
return base
|
|
||||||
}
|
|
||||||
parts := strings.SplitN(path.Base(link), ".", 2)
|
|
||||||
if len(parts) != 2 {
|
|
||||||
return base
|
|
||||||
}
|
|
||||||
base2, err := strconv.ParseUint(parts[0], 16, 64)
|
|
||||||
if err != nil {
|
|
||||||
return base
|
|
||||||
}
|
|
||||||
return base2
|
|
||||||
}
|
|
||||||
|
|
||||||
func getBaseAddressDidier() uint64 {
|
|
||||||
fmt.Println("OK did is insane shit.")
|
|
||||||
return uint64(0x300b000)
|
|
||||||
}
|
|
||||||
|
|
||||||
var drvGPIO driverGPIO
|
var drvGPIO driverGPIO
|
||||||
|
|
||||||
// Ensure that the various structs implement the interfaces they're supposed to.
|
// Ensure that the various structs implement the interfaces they're supposed to.
|
||||||
|
|||||||
+41
-28
@@ -8,14 +8,14 @@
|
|||||||
package allwinner
|
package allwinner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
_ "embed"
|
||||||
"strings"
|
"encoding/json"
|
||||||
|
|
||||||
"periph.io/x/conn/v3/pin"
|
"periph.io/x/conn/v3/pin"
|
||||||
"periph.io/x/host/v3/sysfs"
|
"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.
|
// alternate functions.
|
||||||
// According to https://linux-sunxi.org/H616 H616 and H618 are the same.
|
// According to https://linux-sunxi.org/H616 H616 and H618 are the same.
|
||||||
// allwinner marketing team seems to disagree.
|
// allwinner marketing team seems to disagree.
|
||||||
@@ -31,25 +31,36 @@ import (
|
|||||||
// - SDC means SDCard?
|
// - SDC means SDCard?
|
||||||
// - NAND connects to a NAND flash controller.
|
// - NAND connects to a NAND flash controller.
|
||||||
// - CSI and CCI are for video capture.
|
// - CSI and CCI are for video capture.
|
||||||
var mappingH6 = map[string][5]pin.Func{
|
//
|
||||||
"PC0": {"NAND_WE", "SDC2_DS", "SPI0_CLK", "", "PA_EINT0"},
|
// The data itself has been extracted from the pdf using
|
||||||
"PC1": {"NAND_ALE", "SDC2_RST", "", "", "PA_EINT1"},
|
// https://ronnywang.github.io/pdf-table-extractor/ and some
|
||||||
"PC2": {"NAND_CLE", "", "SPI0_MOSI", "", "PA_EINT2"},
|
// scripting. The data has been validated manually.
|
||||||
"PC3": {"NAND_CE1", "", "SPI0_CS0", "BOOT_SEL1", "PA_EINT3"},
|
//
|
||||||
"PC4": {"NAND_CE0", "", "SPI0_MIS0", "BOOT_SEL2", "PA_EINT4"},
|
//go:embed H6_pins.json
|
||||||
"PC5": {"NAND_RE", "SDC2_CLK", "", "BOOT_SEL3", "PA_EINT5"},
|
var h6PinsSpec []byte
|
||||||
"PC6": {"NAND_RB0", "SDC2_CMD", "", "BOOT_SEL4", "PA_EINT6"},
|
|
||||||
"PC7": {"NAND_RB1", "", "SPI0_CS1", "", "PA_EINT7"},
|
|
||||||
"PC8": {"NAND_DQ7", "SDC2_D3", "", "", "PA_EINT8"},
|
|
||||||
|
|
||||||
"PC9": {"NAND_DQ6", "SDC2_D4", "", "", "PA_EINT9"},
|
type serializedPinSpec struct {
|
||||||
"PC10": {"NAND_DQ5", "SDC2_D0", "", "", "PA_EINT10"},
|
Name string
|
||||||
"PC11": {"NAND_DQ4", "SDC2_D5", "", "", "PA_EINT11"},
|
Function2 pin.Func
|
||||||
"PC12": {"NAND_DQS", "", "", "", "PA_EINT12"},
|
Function3 pin.Func
|
||||||
"PC13": {"NAND_DQ3", "SDC2_D1", "", "", "PA_EINT13"},
|
Function4 pin.Func
|
||||||
"PC14": {"NAND_DQ2", "SDC2_D6", "", "", "PA_EINT14"},
|
Function5 pin.Func
|
||||||
"PC15": {"NAND_DQ1", "SDC2_D1", "SPI0_WP", "", "PA_EINT15"},
|
Function6 pin.Func
|
||||||
"PC16": {"NAND_DQ0", "SDC2_D7", "SPI0_HOLD", "", "PA_EINT16"},
|
}
|
||||||
|
|
||||||
|
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
|
// 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.
|
// It is called by the generic allwinner processor code if an H6 is detected.
|
||||||
func mapH6Pins() error {
|
func mapH6Pins() error {
|
||||||
fmt.Println("Initializing H6 pins.")
|
serializedPinSpecs, err := getH6SerializedPinSpecs()
|
||||||
for name, altFuncs := range mappingH6 {
|
if err != nil {
|
||||||
pin := cpupins[name]
|
return err
|
||||||
pin.altFunc = altFuncs
|
}
|
||||||
|
for _, pinSpec := range serializedPinSpecs {
|
||||||
|
pin := cpupins[pinSpec.Name]
|
||||||
|
pin.altFunc = getAltFunc(pinSpec)
|
||||||
pin.available = true
|
pin.available = true
|
||||||
if strings.Contains(string(altFuncs[4]), "_EINT") {
|
if strings.Contains(string(pinSpec.Function6), "_EINT") {
|
||||||
pin.supportEdge = true
|
pin.supportEdge = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes the sysfs corresponding pin right away.
|
// Initializes the sysfs corresponding pin right away.
|
||||||
pin.sysfsPin = sysfs.Pins[pin.Number()]
|
pin.sysfsPin = sysfs.Pins[pin.Number()]
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -6,7 +6,6 @@ package distro
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,7 +30,6 @@ func DTModel() string {
|
|||||||
func DTCompatible() []string {
|
func DTCompatible() []string {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
fmt.Println("\n\n\n\n\tdidier: Deep in the dependencies...")
|
|
||||||
|
|
||||||
if dtCompatible == nil {
|
if dtCompatible == nil {
|
||||||
dtCompatible = []string{}
|
dtCompatible = []string{}
|
||||||
|
|||||||
-7
@@ -60,13 +60,6 @@ func IsRaspbian() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNixos returns true if running on a NixOs distribution.
|
|
||||||
//
|
|
||||||
// https://nixos.org/
|
|
||||||
func IsNixos() bool {
|
|
||||||
return isLinux && OSRelease()["ID"] == "nixos"
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsUbuntu returns true if running on an Ubuntu derived distribution.
|
// IsUbuntu returns true if running on an Ubuntu derived distribution.
|
||||||
//
|
//
|
||||||
// https://ubuntu.com/
|
// https://ubuntu.com/
|
||||||
|
|||||||
Reference in new issue
Block a user