allwinner

package
v3.6.4+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package allwinner exposes the GPIO functionality that is common to all AllWinner processors.

This driver implements memory-mapped GPIO pin manipulation and leverages sysfs-gpio for edge detection.

If you are looking at the actual implementation, open doc.go for further implementation details.

Datasheets

A64: http://files.pine64.org/doc/datasheet/pine64/Allwinner_A64_User_Manual_V1.0.pdf

H3: http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdf

R8: https://github.com/NextThingCo/CHIP-Hardware/raw/master/CHIP%5Bv1_0%5D/CHIPv1_0-BOM-Datasheets/Allwinner%20R8%20User%20Manual%20V1.1.pdf

Physical overview: http://files.pine64.org/doc/datasheet/pine64/A64_Datasheet_V1.1.pdf

Index

Constants

This section is empty.

Variables

View Source
var (
	X32KFOUT *pin.BasicPin // Clock output of 32Khz crystal
	KEY_ADC  *pin.BasicPin // 6 bits resolution ADC for key application; can work up to 250Hz conversion rate; reference voltage is 2.0V
	EAROUTP  *pin.BasicPin // Earpiece amplifier negative differential output
	EAROUTN  *pin.BasicPin // Earpiece amplifier positive differential output
)

A64 specific pins.

View Source
var (
	FEL            *pin.BasicPin // Boot mode selection
	MIC_IN         *pin.BasicPin // Microphone in
	MIC_GND        *pin.BasicPin // Microphone ground
	HP_LEFT        *pin.BasicPin // Left speaker out
	HP_RIGHT       *pin.BasicPin // Right speaker out
	HP_COM         *pin.BasicPin // Speaker common
	X1, X2, Y1, Y2 *pin.BasicPin // Touch screen pins
)

R8 specific pins.

Functions

func IsA20

func IsA20() bool

IsA20 detects whether the host CPU is an Allwinner A20 CPU.

It first looks for the string "sun71-a20" in /proc/device-tree/compatible, and if that fails it checks for "Hardware : sun7i" in /proc/cpuinfo.

func IsA64

func IsA64() bool

IsA64 detects whether the host CPU is an Allwinner A64 CPU.

It looks for the string "sun50iw1p1" in /proc/device-tree/compatible.

func IsR8

func IsR8() bool

IsR8 detects whether the host CPU is an Allwinner R8 CPU.

It looks for the string "sun5i-r8" in /proc/device-tree/compatible.

func Nanospin

func Nanospin(t time.Duration)

Nanospin spins the CPU without calling into the kernel code if possible.

func Present

func Present() bool

Present detects whether the host CPU is an Allwinner CPU.

https://en.wikipedia.org/wiki/Allwinner_Technology

func ReadTime

func ReadTime() time.Duration

ReadTime returns the time on a monotonic timer.

It only works if allwinner-dma successfully loaded. Otherwise it returns 0.

Types

type Pin

type Pin struct {
	// contains filtered or unexported fields
}

Pin implements the gpio.PinIO interface for generic Allwinner CPU pins using memory mapping for gpio in/out functionality.

var (
	PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15, PA16, PA17                                                             *Pin
	PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13, PB14, PB15, PB16, PB17, PB18, PB19, PB20, PB21, PB22, PB23                         *Pin
	PC0, PC1, PC2, PC3, PC4, PC5, PC6, PC7, PC8, PC9, PC10, PC11, PC12, PC13, PC14, PC15, PC16, PC17, PC18, PC19, PC20, PC21, PC22, PC23, PC24                   *Pin
	PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PD8, PD9, PD10, PD11, PD12, PD13, PD14, PD15, PD16, PD17, PD18, PD19, PD20, PD21, PD22, PD23, PD24, PD25, PD26, PD27 *Pin
	PE0, PE1, PE2, PE3, PE4, PE5, PE6, PE7, PE8, PE9, PE10, PE11, PE12, PE13, PE14, PE15, PE16, PE17                                                             *Pin
	PF0, PF1, PF2, PF3, PF4, PF5, PF6                                                                                                                            *Pin
	PG0, PG1, PG2, PG3, PG4, PG5, PG6, PG7, PG8, PG9, PG10, PG11, PG12, PG13                                                                                     *Pin
	PH0, PH1, PH2, PH3, PH4, PH5, PH6, PH7, PH8, PH9, PH10, PH11, PH12, PH13, PH14, PH15, PH16, PH17, PH18, PH19, PH20, PH21, PH22, PH23, PH24, PH25, PH26, PH27 *Pin
	PI0, PI1, PI2, PI3, PI4, PI5, PI6, PI7, PI8, PI9, PI10, PI11, PI12, PI13, PI14, PI15, PI16, PI17, PI18, PI19, PI20, PI21                                     *Pin
)

List of all known pins. These global variables can be used directly.

The supported functionality of each gpio differs between CPUs. For example the R8 has the LCD-DE signal on gpio PD25 but the A64 has it on PD19.

The availability of each gpio differs between CPUs. For example the R8 has 19 pins in the group PB but the A64 only has 10.

So make sure to read the datasheet for the exact right CPU.

func (*Pin) DefaultPull

func (p *Pin) DefaultPull() gpio.Pull

DefaultPull implements gpio.PinIn.

func (*Pin) FastOut

func (p *Pin) FastOut(l gpio.Level)

FastOut sets a pin output level with Absolutely No error checking.

Out() Must be called once first before calling FastOut(), otherwise the behavior is undefined. Then FastOut() can be used for minimal CPU overhead to reach Mhz scale bit banging.

func (*Pin) FastRead

func (p *Pin) FastRead() gpio.Level

FastRead return the current pin level without any error checking.

This function is very fast.

func (*Pin) Func

func (p *Pin) Func() pin.Func

Func implements pin.PinFunc.

func (*Pin) Function

func (p *Pin) Function() string

Function implements pin.Pin.

func (*Pin) Halt

func (p *Pin) Halt() error

Halt implements conn.Resource.

It stops edge detection if enabled.

func (*Pin) In

func (p *Pin) In(pull gpio.Pull, edge gpio.Edge) error

In implements gpio.PinIn.

It sets the pin direction to input and optionally enables a pull-up/down resistor as well as edge detection.

Not all pins support edge detection on Allwinner processors!

Edge detection requires opening a gpio sysfs file handle. The pin will be exported at /sys/class/gpio/gpio*/. Note that the pin will not be unexported at shutdown.

func (*Pin) Name

func (p *Pin) Name() string

Name implements pin.Pin.

It returns the pin name, ex: "PB5".

func (*Pin) Number

func (p *Pin) Number() int

Number implements pin.Pin.

It returns the GPIO pin number as represented by gpio sysfs.

func (*Pin) Out

func (p *Pin) Out(l gpio.Level) error

Out implements gpio.PinOut.

func (*Pin) PWM

func (p *Pin) PWM(gpio.Duty, physic.Frequency) error

PWM implements gpio.PinOut.

func (*Pin) Pull

func (p *Pin) Pull() gpio.Pull

Pull implements gpio.PinIn.

func (*Pin) Read

func (p *Pin) Read() gpio.Level

Read implements gpio.PinIn.

It returns the current pin level. This function is fast.

func (*Pin) SetFunc

func (p *Pin) SetFunc(f pin.Func) error

SetFunc implements pin.PinFunc.

func (*Pin) String

func (p *Pin) String() string

String implements conn.Resource.

It returns the pin name and number, ex: "PB5(37)".

func (*Pin) SupportedFuncs

func (p *Pin) SupportedFuncs() []pin.Func

SupportedFuncs implements pin.PinFunc.

func (*Pin) WaitForEdge

func (p *Pin) WaitForEdge(timeout time.Duration) bool

WaitForEdge implements gpio.PinIn.

It waits for an edge as previously set using In() or the expiration of a timeout.

type PinPL

type PinPL struct {
	// contains filtered or unexported fields
}

PinPL defines one CPU supported pin in the PL group.

PinPL implements gpio.PinIO.

var PL0, PL1, PL2, PL3, PL4, PL5, PL6, PL7, PL8, PL9, PL10, PL11, PL12 *PinPL

All the pins in the PL group.

func (*PinPL) DefaultPull

func (p *PinPL) DefaultPull() gpio.Pull

DefaultPull implements gpio.PinIn.

func (*PinPL) FastOut

func (p *PinPL) FastOut(l gpio.Level)

FastOut sets a pin output level with Absolutely No error checking.

See Pin.FastOut for more information.

func (*PinPL) FastRead

func (p *PinPL) FastRead() gpio.Level

FastRead reads without verification.

func (*PinPL) Func

func (p *PinPL) Func() pin.Func

Func implements pin.PinFunc.

func (*PinPL) Function

func (p *PinPL) Function() string

Function implements pin.Pin.

func (*PinPL) Halt

func (p *PinPL) Halt() error

Halt implements conn.Resource.

It stops edge detection if enabled.

func (*PinPL) In

func (p *PinPL) In(pull gpio.Pull, edge gpio.Edge) error

In implements gpio.PinIn.

func (*PinPL) Name

func (p *PinPL) Name() string

Name implements pin.Pin.

It returns the pin name, ex: "PL5".

func (*PinPL) Number

func (p *PinPL) Number() int

Number implements pin.Pin.

It returns the GPIO pin number as represented by gpio sysfs.

func (*PinPL) Out

func (p *PinPL) Out(l gpio.Level) error

Out implements gpio.PinOut.

func (*PinPL) PWM

func (p *PinPL) PWM(gpio.Duty, physic.Frequency) error

PWM implements gpio.PinOut.

func (*PinPL) Pull

func (p *PinPL) Pull() gpio.Pull

Pull implements gpio.PinIn.

func (*PinPL) Read

func (p *PinPL) Read() gpio.Level

Read implements gpio.PinIn.

func (*PinPL) SetFunc

func (p *PinPL) SetFunc(f pin.Func) error

SetFunc implements pin.PinFunc.

func (*PinPL) String

func (p *PinPL) String() string

String implements conn.Resource.

It returns the pin name and number, ex: "PL5(352)".

func (*PinPL) SupportedFuncs

func (p *PinPL) SupportedFuncs() []pin.Func

SupportedFuncs implements pin.PinFunc.

func (*PinPL) WaitForEdge

func (p *PinPL) WaitForEdge(timeout time.Duration) bool

WaitForEdge implements gpio.PinIn.

Notes

Bugs

  • These need to be converted to an analog.PinIO implementation once analog support is implemented.

  • H3 supports group PL too.

  • Implement using AVS_CNT0_REG on A64.

  • Assumes that counterCtrl & timerPLL6 is not set.

Directories

Path Synopsis
Package allwinnersmoketest verifies that allwinner specific functionality work.
Package allwinnersmoketest verifies that allwinner specific functionality work.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL