Commit Graph

31 Commits

Author SHA1 Message Date
Emmanuel Vadot
7dc8d93acb Only set pud settings if this is a pullup or pulldown configuration.
This removes the need to set the MMC pins with pullups in our DTS.
Thanks to jmcneill@ for spotting this.

Tested on Orange Pi One (Allwinner H3).

MFC after:	1 week
2016-08-17 13:09:31 +00:00
Emmanuel Vadot
4943ecf438 a10_gpio_get_function now returns the whole function not only
GPIO_INPUT/GPIO_OUTPUT.
a10_gpio_get_pud now returns the whole pud not only PULLDOWN/PULLUP.
Add a10_gpio_get_drv to get the current drive strenght.
During fdt pin configure, avoid setting function/drive/pud if it's already in
the correct value.

Tested on Allwinner H3 and A20

MFC after:	1 week
2016-08-17 10:20:36 +00:00
Emmanuel Vadot
be79f382c8 We need the GIC to be attached so attach later at BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE
Reviewed by:	andrew
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D7080
2016-07-21 13:26:39 +00:00
Jared McNeill
2d36de5fb7 Add support for Allwinner A64 CPUx-PORT and CPUs-PORT Port Controllers.
Reviewed by:	andrew, manu
2016-07-11 20:09:17 +00:00
Michal Meloun
dac935533b EXTRES: Add OF node as argument to all <foo>_get_by_ofw_<bar>() functions.
In some cases, the driver must handle given properties located in
specific OF subnode. Instead of creating duplicate set of function, add
'node' as argument to existing functions, defaulting it to device OF node.

MFC after: 3 weeks
2016-07-10 18:28:15 +00:00
Emmanuel Vadot
356c50adff Add support for Allwinner A13.
Reviewed by:	jmcneill
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6809
2016-07-08 23:38:25 +00:00
Emmanuel Vadot
f8f34e91da Check that the pin function exists before setting it.
This is needed for Allwinner A13 which has gpio pins with only "out" function.
2016-07-08 23:08:59 +00:00
Oleksandr Tymoshenko
39a997283f Use OF_prop_free instead of direct call to free(9)
Approved by:	jmcneill
2016-05-13 22:28:02 +00:00
Emmanuel Vadot
0aa4b81381 Add support for Allwinner H3 SoC.
For now clocks, GPIO, Pinmux, UART, MMC, EHCI is supported.
Tested on OrangePi-One

Reviewed by:	jmcneill
Approved by:	cognet (mentor)
Differential Revision:	https://reviews.freebsd.org/D6311
2016-05-13 18:20:54 +00:00
Jared McNeill
8a0fd1a7cd Add support for the Allwinner A83T (sun8iw6p1) SoC.
Clocks, GPIO, UART, SD card / eMMC, USB, watchdog, and ethernet are
supported. Note that the A83T contains two clusters of four Cortex-A7
CPUs, and only CPUs in first cluster are started for now.

Tested on a Sinovoip Banana Pi BPI-M3.
2016-05-05 09:41:57 +00:00
Jared McNeill
013cb2e961 Add support for Allwinner A31/A31S R-GPIO (CPUs-PORT) controller.
Submitted by:		Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:		jmcneill
Differential Revision:	https://reviews.freebsd.org/D5930
2016-04-23 13:59:18 +00:00
Michal Meloun
f645a5d9c7 A20: Gpiobus can be attached only after full gpio driver initialization.
While i'm in, remove now unused global variable.

Submited by:	Emmanuel Vadot <manu@bidouilliste.com>
2016-03-17 08:57:41 +00:00
Andrew Turner
ccf8caad14 Add the Allwinner A31 and A31s padconf support. It's currently unused, but
will be needed when we bring in further support for these SoCs.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D5340
2016-02-25 12:17:41 +00:00
Andrew Turner
4b68de9c1a Move the Allwinner kernels to use fdt_pinctrl. This will read the pin
configuration from the FDT data, then set the pins into the requested
state. As part of this the gpio controller now reports the correct number
of pins instead of returning the number of bank * 32.

To allow for a future consolidated kernel we add the SOC_ALLWINNER_A10 and
SOC_ALLWINNER_A20 kernel options. These need to be set as appropriate for
the SoC the kernel will boot on.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D5177
2016-02-17 18:28:03 +00:00
Andrew Turner
907fe11655 Update of the Allwinner drivers to:
* Use the Linux compat string
 * Use EARLY_DRIVER_MODULE to attach at the right time
 * Add a generic A10 kernel config file
 * A20 now use generic_timer
 * Add two new dts files for Olimex boards
 * Update our custom DTS file for A10 and A20 to use the same compatible
   property names as the vendor ones.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D4792
2016-02-10 09:19:29 +00:00
Luiz Otavio O Souza
fbb065700c The vendor's DTS for Allwinner A20 uses a different way to map the gpio
pins, they specify the bank and the pin in two separated cells.

This allow the use of vendor's DTS definitions by adding a gpio map
routine that copes with that.
2015-08-30 22:38:06 +00:00
Luiz Otavio O Souza
fb54940587 Bring a few simplifications to a10_gpio:
o Return the real hardware state in gpio_pin_getflags() instead of keep
   the last state in an internal table.  Now the driver returns the real
   state of pins (input/output and pull-up/pull-down) at all times.
 o Use a spin mutex.  This is required by interrupts and the 1-wire code.
 o Use better variable names and place parentheses around them in MACROS.
 o Do not lock the driver when returning static data.

Tested with gpioled(4) and DS1820 (1-wire) sensors on banana pi.
2015-07-13 18:19:26 +00:00
Luiz Otavio O Souza
a8921b867f Return the FDT node of the GPIO controller to gpiobus. It is used by the
children of gpiobus.
2015-07-11 21:09:43 +00:00
Luiz Otavio O Souza
9639a6c7c9 Rename a10_emac_gpio_config() to a10_gpio_ethernet_activate() to make the
change to GMAC easier on A20 SoCs.

On A10 only the EMAC controller is available (fast ethernet), but on A20
there is also GMAC a high (or better) performant controller (gigabit
ethernet).

On A20 the both controllers uses the same pins to talk to the ethernet PHY
(MII or RGMII) and they can be selected by the GPIO pin mux.

There is work in progress to bring in GMAC support.
2015-07-03 17:54:41 +00:00
Andrew Turner
ff3b52bb19 Stop using machine/fdt.h in the arm kernel code when we don't need it. 2015-04-04 21:34:26 +00:00
Luiz Otavio O Souza
7836352b50 Implement GPIO_GET_BUS() method for all GPIO drivers.
Add helper routines to deal with attach and detach of gpiobus and gpioc
devices that are common to all drivers.
2015-01-31 19:32:14 +00:00
Luiz Otavio O Souza
876c1bd8b0 Clean up and fix the device detach routine and the failure path on GPIO
drivers.

This paves the way for upcoming work.
2015-01-31 12:17:07 +00:00
Luiz Otavio O Souza
667357dc9b Moves all the duplicate code to a single function.
Verify for invalid modes and unwanted flags before pass the new flags to
driver.
2014-11-18 17:22:08 +00:00
Luiz Otavio O Souza
8839e0e9f3 Make the GPIO children attach to the first unit available and not only to
unit 0.

It seems that this 'simplification' was copied to all GPIO drivers in tree.

This fix a bug where a GPIO controller could fail to attach its children
(gpioc and gpiobus) if another GPIO driver attach first.
2014-10-28 18:33:59 +00:00
Ganbold Tsagaankhuu
fe47fb7b1c Switch to my freebsd.org emal address in copyright.
Approved by:	stas (mentor)
2014-03-25 08:31:47 +00:00
Ganbold Tsagaankhuu
79690a92d0 Add gpio and clock bits for A10/A20's EMAC ethernet controller driver, such as:
- EMAC gpio configuration
- EMAC clock activation

Approved by:	stas (mentor)
2014-03-03 11:00:52 +00:00
Ian Lepore
add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
to check the status property in their probe routines.

Simplebus used to only instantiate its children whose status="okay"
but that was improper behavior, fixed in r261352.  Now that it doesn't
check anymore and probes all its children; the children all have to
do the check because really only the children know how to properly
interpret their status property strings.

Right now all existing drivers only understand "okay" versus something-
that's-not-okay, so they all use the new ofw_bus_status_okay() helper.
2014-02-02 19:17:28 +00:00
Ian Lepore
6489412064 Remove #include <machine/frame.h> from all the arm code that doesn't
really need it.  That would be almost everywhere it was included.  Add
it in a couple files that really do need it and were previously getting
it by accident via another header.
2013-10-27 01:34:10 +00:00
Dimitry Andric
27e644a80b Fix undefined behaviour in several gpio_pin_setflags() routines (under
sys/arm and sys/mips), squelching the clang 3.3 warnings about this.

Noticed by:	tinderbox and many irate spectators
Submitted by:	Luiz Otavio O Souza <loos.br@gmail.com>
PR:		kern/177759
MFC after:	3 days
2013-04-13 21:21:13 +00:00
Ganbold Tsagaankhuu
bf4e1ed0bc Define gpio constants rather than using enum.
Fix pull-up and pull-down values of gpio.
According to A10 user manual possible pull register
values are 00 Pull-up/down disable, 01 Pull-up, 10 Pull-down.

Approved by: gonzo@
2013-02-19 02:01:35 +00:00
Ganbold Tsagaankhuu
d9a1428cab Add gpio driver and update dts and kernel config accordingly.
Approved by: gonzo@
2013-02-05 02:25:13 +00:00