Commit Graph

4268 Commits

Author SHA1 Message Date
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
Andrew Turner
dc59c854ca Port the Xilinx code to use PLATFORM and PLATFORM_SMP. This will help move
it to be part of the armv6 GENERIC kernel.
2017-06-03 19:11:32 +00:00
Andrew Turner
e23ce9ef7a Stop making cpu_initclocks weak when using event timers. A weak symbol
could be overridden in the SoC specific code, but this would break GENERIC
as it is likely to be incorrect.

Remove the versatile implementation of cpu_initclocks as it's unneeded.
2017-06-03 16:24:17 +00:00
Andrew Turner
95bae5e40c Add MULTIDELAY support to the mpcore timer driver. This is needed when
using this with GENERIC.

While here remove the weak symbol, it doesn't seem to be needed anymore.
2017-06-03 15:56:54 +00:00
Andrew Turner
78527f28d3 Add MULTIDELAY support to the sp804 driver. 2017-06-03 15:48:03 +00:00
Andrew Turner
35c4874e8d Add MULTIDELAY to the Beaglebone kenrel config to help moving it to GENERIC. 2017-06-03 15:40:34 +00:00
Andrew Turner
b32611238e Enable MULTIDELAY in the i.MX5 kernel configs. This will help adding them
to GENERIC.
2017-06-03 15:39:23 +00:00
Andrew Turner
62e2e02278 Remove RT1310 from universe as it fails to build. 2017-06-03 14:45:46 +00:00
Andrew Turner
08cda712b4 Make it an error to build armv6 without INTRNG enabled. Most kernel configs
have been updated for this, with the exception of the two marked as
NO_UNIVERSE in r319514.
2017-06-03 10:40:45 +00:00
Andrew Turner
5dc97550fb Mark the non-INTRNG armv6 configs with NO_UNIVERSE to prepare for INTRNG
being always enabled on armv6.
2017-06-03 10:38:41 +00:00
Wojciech Macek
e6a54e228a Enable wireless Atheros cards in ARMADA38X
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
                Dominik Ermel <der@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Stormshield
Differential revision: https://reviews.freebsd.org/D10904
2017-05-29 09:20:20 +00:00
Zbigniew Bodek
26872c13ce Unmask legacy interrupts on Marvell PCIE controller
This patch fixes a bug introduced with commit:
r294510  "Remove an extra '!' found by clang 3.8."

'!' was removed without inverting the logic, which
broke PCIe legacy interrupts operation for Marvell
controllers.

Submitted by: Michal Mazur <mkm@semihalf.com>
Obtained from: Semihalf
Sponsored by: Netgate
2017-05-25 14:34:21 +00:00
Zbigniew Bodek
fa5f501d0a Add workaround for CESA MBUS windows with 4GB DRAM
Armada 38x SoC's equipped with 4GB DRAM suffer freeze
during CESA operation, if MBUS window opened at given
DRAM CS reaches end of the address space. Apply a workaround
by setting the window size to the closest possible
value, i.e. divide it by 2 (it has to be power-of-2).

Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10724
2017-05-25 14:25:05 +00:00
Zbigniew Bodek
0c79c0b138 Fix PM recognition on recent Marvell boards
PM status is only supported on Kirkwood and Disvovery.
Cleanup the code to properly report its state on
other platforms.

Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10718
2017-05-25 14:23:49 +00:00
Zbigniew Bodek
92ce47d94e Introduce separate watchdog driver for Armada to fix phony DELAY
DELAY is a problematic routine called all over the kernel.
Armada38x using CA-9 CPUs are using mpcore timer to count events
and measure time but DELAY in the mpcore timer code is a weak
function reference and therefore will be replaced by the platform
implementation if the one is introduced. Since Armada38x uses
on-chip watchdog to which the driver is merged with the on-chip timer
driver there will be a platform DELAY implementation.
The latter however will not use any HW timers as it will not attempt
to configure any. Phony busy loop will be used instead.

To fix that we introduce a separate watchdog driver for Armada platforms,
(currently only A38X) and stop using Marvell timer driver. That
switches DELAY to the desired implementation.

Submitted by: Zbigniew Bodek <zbb@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10710
2017-05-25 14:22:00 +00:00
Zbigniew Bodek
bb98396b47 Enable SCU Speculative linefills to L2 on Armada 38x
Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10709
2017-05-25 14:19:20 +00:00
Zbigniew Bodek
70d163328d Fix memory corruption while configuring CPU windows on Marvell SoCs
Resolving CPU windows from localbus entry caused buffer overflow
and memory corruption. Fix wrong indexing and ensure the index
does not exceed table size.

Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10720
2017-05-25 14:16:43 +00:00