Commit Graph

4284 Commits

Author SHA1 Message Date
Warner Losh
a94a63f0a6 An MMC/SD/SDIO stack using CAM
Implement the MMC/SD/SDIO protocol within a CAM framework. CAM's
flexible queueing will make it easier to write non-storage drivers
than the legacy stack. SDIO drivers from both the kernel and as
userland daemons are possible, though much of that functionality will
come later.

Some of the CAM integration isn't complete (there are sleeps in the
device probe state machine, for example), but those minor issues can
be improved in-tree more easily than out of tree and shouldn't gate
progress on other fronts. Appologies to reviews if specific items
have been overlooked.

Submitted by: Ilya Bakulin
Reviewed by: emaste, imp, mav, adrian, ian
Differential Review: https://reviews.freebsd.org/D4761

merge with first commit, various compile hacks.
2017-07-09 16:57:24 +00:00
Emmanuel Vadot
50bb2d50e8 if_awg: Add "allwinner,sun50i-a64-emac" compatible string.
This enable ethernet on Pine64 with latest DTS.
2017-07-09 12:35:19 +00:00
Andrew Turner
9ce763a0db Remove the MULTIDELAY option from arm. It's now enabled when PLATFORM is
enabled.
2017-07-07 13:55:11 +00:00
Andrew Turner
83ad38643c Make MULTIDELAY a requirement in the MPCore Timer driver when using
PLATFORM. This will help with removing the MULTIDELAY option, enabling
it when PLATFORM is enabled.
2017-07-05 10:29:05 +00:00
Andrew Turner
88fd0c95a3 Require the ARM Generic Timer driver is built for MULTIDELAY on 32bit arm.
As this driver is also used for DELAY on arm64 we need to keep the existing
DELAY code for it to use.
2017-07-05 09:27:18 +00:00
Ian Lepore
3a28d1b6e3 Add a driver for the imx6 on-chip realtime clock.
This driver is standard rather than optional because it can always provide
time after a reboot, but it will only provide time after a power cycle if
battery power is supplied to the chip's SNVS power domain.
2017-07-04 18:38:34 +00:00
Andrew Turner
89ea89de85 Move the simple armv6 only timer drivers to require MULTIDELAY to help
move all armv6 configs it.
2017-07-04 18:07:09 +00:00
Andrew Turner
57521c21b1 Add a delay count to the last few places. This will help make MULTIDELAY
a requirement on armv6 with PLATFORM.
2017-07-04 17:15:23 +00:00
Andrew Turner
3d814b4cf9 Remove PLATFORM_SMP. It's unneeded as all configs with both PLATFORM and
SMP use it so we can switch to the combination of these as the check.
2017-07-04 16:52:55 +00:00
Andrew Turner
c20963ad19 Add PLATFORM and PLATFORM_SMP support to the ALPINE kernel configuration.
This will help move it to be part of GENERIC.
2017-07-04 12:26:47 +00:00
Andrew Turner
b77a75e4a6 Teach VERSATILEPB about PLATFORM. This will help move it into the GENERIC
kernel configuration.
2017-07-04 12:17:49 +00:00
Emmanuel Vadot
31a8b4896f allwinner: Add A64 ccung support
Upstream DTS for A64 SoC doesn't provide a /clocks node as Linux switched
to ccu-ng
This commit adds the necessary bits to boot on pine64 with latest DTS from
upstream.
USB is not working for now and some node aren't present in the DTS (like the
PMU, Power Management Unit).

Tested on: Pine64
2017-07-03 19:30:03 +00:00
Emmanuel Vadot
c33f3f1e31 arm: gic: Change GIC_DEBUG_SPURIOUS to TUNABLE
On armv6 default to 1 if INVARIANTS is set
On arm64 always default to 0

Discussed with: andrew, ian, mmel
2017-07-03 18:01:58 +00:00
Jason A. Harmening
eb36b1d0bc Clean up MD pollution of bus_dma.h:
--Remove special-case handling of sparc64 bus_dmamap* functions.
  Replace with a more generic mechanism that allows MD busdma
  implementations to generate inline mapping functions by
  defining WANT_INLINE_DMAMAP in <machine/bus_dma.h>.  This
  is currently useful for sparc64, x86, and arm64, which all
  implement non-load dmamap operations as simple wrappers
  around map objects which may be bus- or device-specific.

--Remove NULL-checked bus_dmamap macros.  Implement the
  equivalent NULL checks in the inlined x86 implementation.
  For non-x86 platforms, these checks are a minor pessimization
  as those platforms do not currently allow NULL maps.  NULL
  maps were originally allowed on arm64, which appears to have
  been the motivation behind adding arm[64]-specific barriers
  to bus_dma.h, but that support was removed in r299463.

--Simplify the internal interface used by the bus_dmamap_load*
  variants and move it to bus_dma_internal.h

--Fix some drivers that directly include sys/bus_dma.h
  despite the recommendations of bus_dma(9)

Reviewed by:	kib (previous revision), marius
Differential Revision:	https://reviews.freebsd.org/D10729
2017-07-01 05:35:29 +00:00
Ian Lepore
8928c2e4f5 Add bus recovery handling to the imx5/imx6 i2c driver. 2017-06-29 01:59:39 +00:00
Ian Lepore
c592231080 Implement gpio input by reading the pad state register, not the data register.
When a pin is set for input the value in the DR will be the same as the PSR.

When a pin is set for output the value in the DR is the value output to the
pad, and the value in the PSR is the actual electrical level sensed on the
pad, and they can be different if the pad is configured for open-drain mode
and some other entity on the board is driving the line low.
2017-06-28 20:28:47 +00:00
Oleksandr Tymoshenko
7db267b3f6 [arm] Use correct index value when checking range validity
Reviewed by:	andrew
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D9145
2017-06-26 21:45:33 +00:00
Emmanuel Vadot
ac485d3178 Remove ALLWINNER kernel config file, all release image for SMP Allwinner
board uses GENERIC and it's not updated for newer SoC.
2017-06-25 11:31:39 +00:00
Emmanuel Vadot
7f61394200 Allwinner: Add support for H2 Plus SoC
H2+ SoC is a stripped down version of H3 without gigabit ethernet and 4K HDMI.
Also add sun8i-h2-plus-orangepi-zero.dts to the build as we run on this board.
2017-06-24 16:41:26 +00:00
Zbigniew Bodek
3361fdc431 Create root DMA tag and fix MBUS windows on DMA coherent platforms
Armada 38x SoCs, in order to work properly in IO-coherent mode,
requires an update of the MBUS windows attributesd.

This patch also configures nexus coherent dma tag, because all
busses and children devices have to inherit this setting in runtime.
The latter has to be executed as a sysinit (SI_SUB_DRIVERS type),
so that bus_dma_tag_create() can be executed properly.

Submitted by: Michal Mazur <mkm@semihalf.com>
 	      Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: ian
Differential revision: https://reviews.freebsd.org/D11203
2017-06-21 18:27:05 +00:00
Zbigniew Bodek
474612c372 Enable setting the dma tag at the nexus level
Allow to set the dma tag for nexus in the platform init code,
so that all busses and devices would be able to inherit it.
This change is useful e.g. for setting coherent dma tag for
the platforms with hardware IO cache coherency.

Submitted by: ian
      	      Michal Mazur <mkm@semihalf.com>
Reviewed by: ian
Differential revision: https://reviews.freebsd.org/D11202
2017-06-21 18:25:35 +00:00
Zbigniew Bodek
990b485c6f Introduce support for DMA coherent ARM platforms
- Inherit BUS_DMA_COHERENT flag from parent buses
- Use cacheable memory attributes on dma coherent platform
- Disable cache synchronization on coherent platform

Changes are based on ARMv8 busdma code and commit r299683.

Submitted by: Michal Mazur <mkm@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: ian
Differential revision: https://reviews.freebsd.org/D11201
2017-06-21 18:23:28 +00:00
Zbigniew Bodek
8cbc8d3dd1 Disable PL310 outer cache sync for IO coherent platforms
When a PL310 cache is used on a system that provides hardware
coherency, the outer cache sync operation is useless, and can be
skipped. Moreover, on some systems, it is harmful as it causes
deadlocks between the Marvell coherency mechanism, the Marvell PCIe
or Crypto controllers and the Cortex-A9.

To avoid this, this commit introduces a new Device Tree property
'arm,io-coherent' for the L2 cache controller node, valid only for the
PL310 cache. It identifies the usage of the PL310 cache in an I/O
coherent configuration. Internally, it makes the driver disable the
outer cache sync operation.

Note, that other outer-cache operations are not removed, as they may
be needed for certain situations, such as booting secondary CPUs.
Moreover, in order to enable IO coherent operation, the decision
whether to use L2 cache maintenance callbacks is done in busdma
layer, which was enabled in one of the previous commits.

Submitted by: Michal Mazur <mkm@semihalf.com>
	      Marcin Wojtas <mw@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Differential revision: https://reviews.freebsd.org/D11245
2017-06-20 11:11:42 +00:00
Zbigniew Bodek
b50f666958 Implement workaround for Armada 38X family HW issue between CPU and devices
There is a hardware problem between Cortex-A9 CPUs and on-chip devices
in Armada 38X SoCs that may cause hang on heavy load. This can be
however worked around by mapping all registers and PCI IO
as strongly ordered instead of device memory.

Submitted by: Zbigniew Bodek <zbb@semihalf.com>
Reviewed by: mmel
Tested by: mw_semihalf.com
Obtained from: Semihalf
Differential revision: https://reviews.freebsd.org/D10218
2017-06-20 11:09:38 +00:00
Emmanuel Vadot
acd690d524 allwinner: Configure pins for DTS >= Linux 4.11
Starting with DTS from Linux 4.11, the pins list, function, drive and pull
are no longer prefixed with "allwinner,".
Allow the pinctrl driver to handle both case.
2017-06-19 06:30:04 +00:00
Warner Losh
4558167c59 Put ARM_USE_V6_BUSDMA into the SAM9G20EK reference kernel to try to
track down the unaligned I/O issues we have with at least USB on that
platform.
2017-06-18 21:03:53 +00:00
Warner Losh
b2dc7525d5 Include the generic cpu.h instead of the v4/v6 specific cpu.h. This
one change allows it to be compiled either for v4 or v6.
2017-06-18 21:03:43 +00:00
Warner Losh
9cbc5bd323 Load the transmit dma buffer at attach time as well. We don't need to
load and unload it all the time since the buffer never changes. In
addition, we were loading it with a hardware spin lock held, which
makes the sleepable lock in busdma (for the bounce pages) trigger a
witness warning, as well as ipend being called with it held by uart,
which made it impossible to unload.

These differences don't matter with the v4 busdma implementation, but
they do with the v6 implementation since the latter likes to bounce
transactions more, and will always do so for Atmel's driver.

It's more efficient as well as being more correct.
2017-06-18 21:03:35 +00:00
Ian Lepore
fc0dd0d307 Add a driver for the imx6 EPIT timer that can be used as the system
timecounter instead of the GPT timer, freeing up the more flexible GPT
hardware for other uses.  The EPIT driver is a standard (always in the
kernel) driver, and the existing GPT driver is now optional and included
only if you ask for device imx_gpt.
2017-06-18 18:22:52 +00:00
Ian Lepore
cb058296ca Only register as the platform DELAY() implementation if the setup of the
global timer was successful, since the implementation tries to read it.

Notably, if the platform has a variable-frequency global timer (because
of dynamic frequency scaling), it doesn't set up the global timer for use
as a system timecounter, and in that case it also can't use it for DELAY.
Such platforms use different timer hardware for both timecounter and DELAY.
2017-06-18 17:26:54 +00:00
Ed Maste
ea2f16965e arm: set appropriate section flags for .init_pagetable
The arm kernel linker scripts place the .init_pagetable section in .bss,
but .init_pagetable had no section flags set, and so did not match the
expected flags for .bss.

GNU ld silently ignores this case, but lld reports an error:

ld: error: incompatible section flags for .bss
>>> locore.o:(.init_pagetable): 0x0
>>> output section .bss: 0x3

PR:		220055
Submitted by:	mmel, Rafael Espíndola
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
2017-06-17 14:46:14 +00:00
Michal Meloun
c40a5f8a40 Manually load tunable CPU quirks.
These are needed too early, far before SYSINIT is processed.

Reported by:	zbb
Pointy hat to:	mmel
MFC after:	3 weeks
MFC with: 	r319896
2017-06-17 14:36:25 +00:00
Zbigniew Bodek
2d80caa28a Revert change to description introduced in r320002
Currently some ARM platforms implement their own platform_probe_and_attach()
function and other use common routine that calls platform's PLATFORM_ATTACH
method.
Keep the old description to match the preferred way of naming things.

Pointed out by: andrew
2017-06-16 17:31:56 +00:00
Zbigniew Bodek
11a6a330c8 Enhance Armada 38x SoC identification string
Add hw_clockrate and CPU frequency, basing on sample-at-reset
configuration.

Submitted by:	Arnaud Ysmal <arnaud.ysmal@stormshield.eu>
		Marcin Wojtas <mw@semihalf.com>
Obtained from: Stormshield, Semihalf
Sponsored by: Stormshield
Reviewed by: andrew
Differential revision: https://reviews.freebsd.org/D10899
2017-06-16 17:18:29 +00:00
Zbigniew Bodek
9aa2805d01 Minor style improvements to pmap_remap_vm_attr()
Use correct platform_ function name in the comment and remove
redundant tabs.
2017-06-16 13:53:02 +00:00
Zbigniew Bodek
131b07cdcf Fix typo in "Marvell" string
Change Marwell to Marvell

Pointed out by: Ravi Pokala <rpokala@mac.com>
2017-06-16 10:16:24 +00:00
Zbigniew Bodek
08d94c6eab Enable HWPMC overflow IRQ on both CPUs in MPIC
This commit enables usage of HWPMC interrupts for the
Marvell SoCs, which use MPIC (Armada38x and ArmadaXP).
Those interrupts require extra unmasking, comparing to
others. Also, in order to process counters per-CPU,
they are masked/unmasked using separate registers' sets
for each core.

Submitted by: Michal Mazur <mkm@semihalf.com>
    	      Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield, Netgate
Differential revision: https://reviews.freebsd.org/D10913
2017-06-13 18:55:21 +00:00
Zbigniew Bodek
9b035ae174 Add detection of CPU class for ARMv6/v7
Submitted by: Michal Mazur <mkm@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: andrew
Differential revision: https://reviews.freebsd.org/D10909
2017-06-13 18:50:08 +00:00
Zbigniew Bodek
824e6d6bc4 Enable neta controller support in ARMADA38X
Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10707
2017-06-13 18:47:42 +00:00
Zbigniew Bodek
a8d7fc4ac1 Introduce Armada 38x/XP network controller support
This patch contains a new driver for the network unit of Marvell
Armada 38x/XP SoCs, called NETA. This support was thoroughly tested
and optimised in terms of stability and performance. Additional
hardware features, like Buffer Management (BM) or Parser and Classifier
(PnC) will be progressively supported as needed.

Submitted by: Fabien Thomas <fabien.thomas@stormshield.eu>
	      Arnaud Ysmal <arnaud.ysmal@stormshield.eu>
	      Zbigniew Bodek <zbb@semihalf.com>
	      Michal Mazur <mkm@semihalf.com>
	      Bartosz Szczepanek <bsz@semihalf.com>
	      Marcin Wojtas <mw@semihalf.com>

Obtained from:	Semihalf
Sponsored by:	Stormshield (main development)
		Netgate (cleanup and upstreaming)
Differential revision: https://reviews.freebsd.org/D10706
2017-06-13 18:46:29 +00:00
Michal Meloun
7bf5720a3f Implement tunable CPU quirks.
These quirks are intended for optimizing CPU performance, not for
applying errata workarounds. Nobody can expect that CPU with unfixed
errata is stable enough to execute the kernel until quirks are applied.

MFC after: 3 weeks
2017-06-13 12:07:18 +00:00
Konstantin Belousov
2d88da2f06 Move struct syscall_args syscall arguments parameters container into
struct thread.

For all architectures, the syscall trap handlers have to allocate the
structure on the stack.  The structure takes 88 bytes on 64bit arches
which is not negligible.  Also, it cannot be easily found by other
code, which e.g. caused duplication of some members of the structure
to struct thread already.  The change removes td_dbg_sc_code and
td_dbg_sc_nargs which were directly copied from syscall_args.

The structure is put into the copied on fork part of the struct thread
to make the syscall arguments information correct in the child after
fork.

This move will also allow several more uses shortly.

Reviewed by:	jhb (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
X-Differential revision:	https://reviews.freebsd.org/D11080
2017-06-12 21:03:23 +00:00
Zbigniew Bodek
5d83a7b631 Add function to dump PCIE MBUS decoding windows and bars
This commit allows to dump PCIE MBUS and bars configuration
for Marvell platforms.

Submitted by:   Michal Mazur <mkm@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Netgate
Differential revision: https://reviews.freebsd.org/D10908
2017-06-08 16:57:06 +00:00
Zbigniew Bodek
8595864992 Support multi-port PCIe hierarchy in Marvell boards DTS
This commit is another part of preparation for PCIe multi-port
support for Marvell SoCs. Some device trees include pcie-controller
node as a bus-parent of pcie nodes. This patch adds support for
new bus, collects and configures device informations and finally
adds PCIB devices as a childs of pcie-controller in Newbus hierarchy.

Submitted by:	Marcin Mazurek <mma@semihalf.com>
Obtained form:	Semihalf
Sponsored by:	Stormshield
Reviewed by:    https://reviews.freebsd.org/D10906
2017-06-08 16:54:02 +00:00
Zbigniew Bodek
73e48bc6d6 Fix PCIe window decoding on Armada 38x
Original PCIe nodes for Marvell SoCs consists of ports' nodes
under main controller node. In order to properly parse
this kind of representation in DT a mechanism for traversing
through the tree required an update. Moreover, processing FDT
data consisting of more than 2 cells had to be fixed,
because the 'reg' property of mrvl,pcie node have additional
parameter in front of 64-bit address. It should be skipped
by default. This commit works properly with old mrvl,pcie
representation for Kirkwood and ArmadaXP SoCs.

Submitted by:	Wojciech Macek <wma@semihalf.com>
		Michal Mazur <mkm@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield, Netgate
Differential revision: https://reviews.freebsd.org/D10905
2017-06-08 16:51:46 +00:00
Zbigniew Bodek
dc3b75aeef Enable MBUS bridge configuration in mv_rtc driver
This patch fixes sporadic problems with updating time
with mv_rtc driver by configuring access to it via MBUS.
For this purpose already existing second set of resources
in rtc@3800 node of Armada 38x DT is used.

Submitted by: Dominik Ermel <der@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10901
2017-06-08 16:48:09 +00:00
Zbigniew Bodek
054beaac09 Add reset capability to mv_rtc driver
This commit enables optional reset of the RTC, in case
its registers' contents did not sustain the reboot or power-off/on
sequence. Without it, further usage of RTC is impossible
(e.g. writing values to RTC_TIME register will not succeed).

The reset is performed only if Clock Correction register
does not comprise RTC_NOMINAL_TIMING, what helps to distinguish,
whether the software configured RTC before or it comprises
the default value.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10900
2017-06-08 16:46:38 +00:00
Andrew Turner
a29b35dd5e Start to rename files with common or generic names to be SoC specific. The
build system doesn't handle two files with the same name.
2017-06-04 09:11:14 +00:00
Andrew Turner
d9f504454a Port the Vybrid code to PLATFORM to help move it into GENERIC. 2017-06-03 20:14:46 +00:00
Andrew Turner
6f5db7909a Port the Samsung ARM code to use PLATFORM and PLATFORM_SMP. This will help
move it into the GENERIC kernel config.
2017-06-03 20:02:12 +00:00