allwinner

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2018 License: Apache-2.0 Imports: 17 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 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 (
	PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13, PB14, PB15, PB16, PB17, PB18                                                       *Pin
	PC0, PC1, PC2, PC3, PC4, PC5, PC6, PC7, PC8, PC9, PC10, PC11, PC12, PC13, PC14, PC15, PC16, PC17, PC18, PC19                                                 *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                                                                                                 *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 returns the default pull for the pin.

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) Function

func (p *Pin) Function() string

Function returns the current function of the pin in printable form.

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 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 returns the pin name.

func (*Pin) Number

func (p *Pin) Number() int

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

func (*Pin) Out

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

Out ensures that the pin is configured as an output and outputs the value.

func (*Pin) Pull

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

Pull returns the current pull-up/down registor setting.

func (*Pin) Read

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

Read return the current pin level and implements gpio.PinIn.

This function is very fast.

func (*Pin) String

func (p *Pin) String() string

String returns the name of the pin in the processor and the GPIO pin number.

func (*Pin) WaitForEdge

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

WaitForEdge 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 returns the default pull for the pin.

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) Function

func (p *PinPL) Function() string

Function returns the current pin function, ex: "In/PullUp".

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. See Pin.In for more information.

func (*PinPL) Name

func (p *PinPL) Name() string

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

func (*PinPL) Number

func (p *PinPL) Number() int

Number 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. See Pin.Out for more information.

func (*PinPL) Pull

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

Pull implements gpio.PinIn. See Pin.Pull for more information.

func (*PinPL) Read

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

Read implements gpio.PinIn. See Pin.Read for more information.

func (*PinPL) String

func (p *PinPL) String() string

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

func (*PinPL) WaitForEdge

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

WaitForEdge implements gpio.PinIn. See Pin.WaitForEdge for more information.

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