Commit Graph

125 Commits

Author SHA1 Message Date
Jared McNeill
65d6a5a446 Attach hwreset resources at the same time as clock resources. 2016-04-08 23:07:16 +00:00
Jared McNeill
ce45969226 Add function for mapping SRAM-D area to USB0 (OTG) controller. Use a lower
pass number to ensure that this driver is loaded before EMAC or OTG,
regardless of the order of nodes in the DT.
2016-04-08 10:54:59 +00:00
Jared McNeill
43b227c89f Match on compatible string "allwinner,sun4i-a10-sram-controller" instead of
"allwinner,sun4i-sramc", to match upstream DTS.
2016-04-08 00:01:19 +00:00
Jared McNeill
6a05f063ed Convert Allwinner port to extres clk/hwreset/regulator APIs.
Reviewed by:		andrew, gonzo, Emmanuel Vadot <manu@bidouilliste.com>
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5752
2016-04-06 23:11:03 +00:00
Jared McNeill
bfba653b0e Improve HDMI display detection by searching the CEA-861 extension block for
an HDMI vendor-specific data block (VSDB) containing the HDMI 24-bit IEEE
registration ID (0x000C03).

Approved by:	gonzo (mentor)
2016-04-02 16:53:12 +00:00
Andrew Turner
bdb976c4a3 Only define the platform methods for the Allwinner platforms we are
building for.

Sponsored by:	ABT Systems Ltd
2016-03-26 17:49:46 +00:00
Ian Lepore
dec4873723 Fix fallout from r292180 (Dec 2015)... ensure that every driver which has
a DRIVER_MODULE() referencing mmc_driver has a MODULE_DEPEND() on mmc.  This
is because the kernel linker only searches for symbols in dependent modules,
so loading sdhci_pci (and other bus-flavors of sdhci) would fail when mmc
was not compiled into the kernel (even if you hand-loaded mmc first).

(Thanks to jilles@ for providing the vital clue about the kernel linker.)
2016-03-21 00:52:24 +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
Jared McNeill
f7f2f3a975 Fix display output for non-HDMI display devices.
Only set the display to HDMI mode if a CEA-861 extension block was found
on the connected display.

PR:		207912
Approved by:	gonzo (mentor)
2016-03-13 01:47:42 +00:00
Andrew Turner
f4df324224 Add SMP support for the Allwinner A31 and A31s. This updated the existing
code for the A20 to use the new PLATFORM_SMP interface, and extends it to
add support for the new SoCs allowing for both to coexist within the same
kernel.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:	jmcneill
Differential Revision:	https://reviews.freebsd.org/D5342
2016-03-06 11:41:08 +00:00
Andrew Turner
c794871343 Add support to enable/disable both the EHCI and OHCI Allwinner clocks. This
adds a lock to ensure only a single device is accessing the hardware. A
reference count is added to only enable when we start to use the clock,
and to disable after we have finished needing the clock.

This was extracted from a larger review to add OHCI support to the
Allwinner SoCs.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:	jmcneill
X-Differential Revision:	https://reviews.freebsd.org/D5481
2016-03-05 13:17:53 +00:00
Jared McNeill
7bf46e12dd Add support for Allwinner A31 RTC controller.
Very similar to the A10 RTC controller with a few register offsets changed
and a different location for the LOSC switch status.

Submitted by:		Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:		jmcneill
Approved by:		adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5500
2016-03-03 22:19:39 +00:00
Jared McNeill
1b4bd0235e Add support for Allwinner A31/A31s EHCI controller and USB PHY.
Reviewed by:		andrew, Emmanuel Vadot <manu@bidouilliste.com>
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5467
2016-03-01 22:54:30 +00:00
Jared McNeill
3f3af790f9 Add Allwinner A10/A20 RTC driver.
Submitted by:		Vladimir Belian <fate10@gmail.com>
Reviewed by:		andrew, imp, jmcneill
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5414
2016-02-28 17:42:27 +00:00
Jared McNeill
ce6507d3d9 Fix PIO mode on A31 and later SoCs.
Newer Allwinner MMC implementations use a different FIFO register offset
(0x200 instead of 0x100). Since the FDT uses the same compat string for
both cases, base the decision on which FIFO offset to use on the Allwinner
SoC family.

Reviewed by:		Emmanuel Vadot <manu@bidouilliste.com>
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5468
2016-02-27 22:26:05 +00:00
Jared McNeill
81e802c14b Fix inverted test for lock status while waiting for PLL to become stable.
Reviewed by:	andrew
Approved by:	adrian (mentor)
2016-02-26 20:33:32 +00:00
Andrew Turner
7133fe0f33 Almost all copies of platform_mp_init_secondary just called
intr_pic_init_secondary. Replace them with a direct call. On BCM2836
and ARMADA XP we need to add this function, but it can be empty.

Reviewed by:	ian, imp
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5460
2016-02-26 16:04:47 +00:00
Andrew Turner
3210b87554 Remove platform_mp_probe as it's almost identical on most ARM SoCs, and
slightly wrong on the others. We should just check if mp_ncpus is set to
more than one CPU as we may wish to run on a single core even when SMP is
available.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5458
2016-02-26 15:54:34 +00:00
Andrew Turner
461a7671c7 Add the start of support for the Allwinner A31 clocks. It only adds
support for the i2c, mmc, and gmac clocks. Further clocks can be added as
needed.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:	jmcneill
Differential Revision:	https://reviews.freebsd.org/D5339
2016-02-26 13:53:09 +00:00
Andrew Turner
243b36c321 Remove platform_ipi_send, it's an unneeded as all implementations are
identical.

Sponsored by:	 ABT Systems Ltd
2016-02-25 20:48:23 +00:00
Jared McNeill
dd03610a2e Add Allwinner A20 HDMI support.
The HDMI driver will attach a framebuffer device when a display is
connected. If the EDID can be read and contains a preferred mode, it
will be used. Otherwise the framebuffer will default to 800x600.

In addition, if the EDID contains a CEA-861 extension block and the
"basic audio" flag is set, audio playback at 48kHz 16-bit stereo is
enabled on the controller.

Reviewed by:		andrew
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5383
2016-02-25 20:17:18 +00:00
Andrew Turner
7ea3f5b654 Add support for the Allwinner A31 watchdog to the existing A10 watchdog
driver. This mostly involves selecting the register offsets to use at
runtime based on the hardware we are talking to.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D5327
2016-02-25 16:50:36 +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
Jared McNeill
6da9071523 Fix dedicated DMA transfers.
For sources and destinations marked "noincr", the previous code was
incorrectly programming the dedicated DMA channel control register
using bit definitions for normal DMA channels. This code path is not
currently used, but will be used by the HDMI audio driver in review.

Reviewed by:		andrew
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5382
2016-02-25 01:24:02 +00:00
Svatopluk Kraus
7758916f44 Move ARM_L2_PIPT option to std.armv6 for all armv6 platforms.
Only L2 PIPT cache is supported for __ARM_ARCH >= 6.

In fact, this is just a pure proclamation as this option is used
only in armv4 specific files now.
2016-02-22 11:47:28 +00:00
Andrew Turner
0bd11ac8f9 Add initial support for the Allwinner A31i and A31s. This just adds the
FDT platform code to detect when we are booting on one of these SoCs. The
driver changes will be added shortly.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D5338
2016-02-19 14:15:31 +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
86914a0f9b Add a sysctl to read the internal temperature of the AXP209 Power
Management IC.

Submitted by:	Jared McNeill <jmcneill@invisible.ca>
Differential Revision:	https://reviews.freebsd.org/D5298
2016-02-16 11:51:54 +00:00
Andrew Turner
ba9b71631d Add an analog audio driver for the audio codec found on the Allwinner
A10/A20 SoC. Based loosely on the submitters NetBSD driver, tested on
Cubieboard 2. Playback and capture are supported.

Submitted by:	Jared McNeill <jmcneill@invisible.ca>
Differential Revision:	https://reviews.freebsd.org/D5202
2016-02-16 11:45:46 +00:00
Andrew Turner
276b1ac928 Only read the power state register when we will be using its value. While
here remove magic shifts, and cleanup pwr_name.

Sponsored by:	ABT Systems Ltd
2016-02-16 11:03:21 +00:00
Andrew Turner
501ce0d86b Add support for the Allwinner DMA controller. This will be used by the at
least the audio codec driver currently in review.

Submitted by:	Jared McNeill <jmcneill@invisible.ca>
Differential Revision:	https://reviews.freebsd.org/D5050
2016-02-15 19:56:35 +00:00
Andrew Turner
2ff143af3f Add support for the AXP209 Power System Management IC. This allows boards
with this and an Allwinner SoC to power off.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D4954
2016-02-15 19:31:23 +00:00
Andrew Turner
5f250b53e8 Add support for the Allwinner i2c device. This is similar to the existing
Marvell twsi part, however uses different register locations, as such split
the existing driver into Marvell and Allwinner attachments.

While here clean a few style issues.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D4846
2016-02-15 15:11:26 +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
Andrew Turner
23da15d045 Remove unneeded whitespace, and fix a license for a new file. Extracted
from a larger patch.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
X-Differential Revision:	https://reviews.freebsd.org/D4792
2016-02-09 18:19:24 +00:00
Michal Meloun
a89156f53f ARM: Use new ARMv6 naming conventions for cache and TLB functions
in all but ARMv4 specific files.
Expand ARMv6 compatibility stubs in cpu-v4.h. Use physical address
in L2 cache functions if ARM_L2_PIPT is defined.
2016-02-05 14:57:41 +00:00
Andrew Turner
c9a608ac3f Add allwinner_machdep.h, it was missed in r294698. 2016-01-25 08:19:16 +00:00
Andrew Turner
d8b624dcab Update the Allwinner kernels:
* Use the ARM PLATFORM framework
 * Use ARM_INTRNG on teh A20 as it has a GICv2
 * Add a method to find which Allwinner SoC we are running on

Differential Revision:	https://reviews.freebsd.org/D5059
2016-01-25 00:24:57 +00:00
Andrew Turner
b4733230c9 Remove an extra newline that crept in. 2016-01-24 19:12:16 +00:00
Andrew Turner
aea7d91520 Add support for controlling the clocks for the audio codec and DMA engines.
Submitted by:	Jared McNeill <jmcneill@invisible.ca>
Differential Revision:	https://reviews.freebsd.org/D5052
2016-01-24 19:10:30 +00:00
Adrian Chadd
2b3ad18853 [intrng] Migrate the intrng code from sys/arm/arm to sys/kern/subr_intr.c.
The ci20 port (by kan@) is going to reuse almost all of the intrng code
since the SoC in question looks suspiciously like someone took an ARM
SoC design and replaced the ARM core with a MIPS core.

* migrate out the code;
* rename ARM_ -> INTR_;
* rename arm_ -> intr_;
* move the interrupt flush routine from intr.c / intrng.c into
  arm/machdep_intr.c - removing the code duplication and removing
  the ARM specific bits from here.

Thanks to the Star Wars: The Force Awakens premiere line for allowing
me a couple hours of quiet time to finish the universe builds.

Tested:

* make universe

TODO:

* The structure definitions in subr_intr.c still includes machine/intr.h
  which requires one duplicates all of the intrng definitions in
  the platform code (which kan has done, and I think we don't have to.)

  Instead I should break out the generic things (function declarations,
  common intr structures, etc) into a separate header.

* Kan has requested I make the PIC based IPI stuff optional.
2015-12-18 05:43:59 +00:00
Ian Lepore
3f62727443 Move the DRIVER_MODULE() statements that declare mmc(4) to be a child of
the various bridge drivers out of dev/mmc.c and into the bridge drivers.

Requested by:	   jhb (almost two years ago; better late than never)
2015-12-14 01:09:25 +00:00
Andrew Turner
210d6af74d Move more bus_space_* files to be built by files.arm. This leaves the
definition in a file.* file under sys/arm/arm in the few cases we need it
for non-fdt platforms.

Sponsored by:	ABT Systems Ltd
2015-11-21 15:30:08 +00:00
Warner Losh
c192c5d300 Makeoption ARM_LITLE_ENDIAN does nothing. Remove it since it isn't
consistently used. It was a carry over from NetBSD that FreeBSD
doesn't use.
2015-11-20 21:49:46 +00:00
Andrew Turner
805471578e Remove bus_space_asm_generic.S from the per-SoC files.* files, it's already
in files.arm.

Sponsored by:	ABT Systems Ltd
2015-11-20 19:48:32 +00:00
Andrew Turner
aeef645f92 Stop setting {KERN,}PHYSADDR on armv6, it's unneeded.
Sponsored by:	ABT Systems Ltd
2015-11-20 16:12:22 +00:00
Ian Lepore
7ce00ee7b4 Rename arm_init_secondary_ic() -> arm_pic_init_secondary(). The latter is
the name the function will have when the new ARM_INTRNG code is integrated,
and doing this rename first will make it easier to toggle the new interrupt
handling code on/off with a config option for debugging.
2015-10-18 16:54:34 +00:00
Luiz Otavio O Souza
ea8b18848f Add the A20 glue code for if_dwc.
This code initializes the GMAC clock and sets the pin mux to rgmii.

It also override the if_dwc defaults to set the alternate descriptor type
and MII clock used on A20.

Tested on cubieboard2 and banana pi.
2015-09-21 01:51:37 +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