Commit Graph

4224 Commits

Author SHA1 Message Date
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
John Baldwin
1ec22b4425 Exclude ccr(4) from arm LINT since it excludes cxgbe(4). 2017-05-19 22:54:45 +00:00
Michal Meloun
d304b9ec4a Increase maximum text segment size.
LLVM binaries are huge...

MFC after:	3 days
2017-05-19 11:45:14 +00:00
Wojciech Macek
22a752b482 Fix boot up on ARMADA38X uniprocessor variant
Marvell Armada 380 is a uni-processor variant of the 38x SoC
family. A function platform_mp_setmaxid() was setting a hardcoded
value, which caused boot fail on A380. Fix this by relying on
the CPU count obtained from device tree nodes.

Submitted by:  Marcin Wojtas <mw@semihalf.com
Obtained from: Semihalf
Sponsored by:  Netgate
Reviewed by:   loos
Differential revision: https://reviews.freebsd.org/D10783
2017-05-19 08:26:41 +00:00
Wojciech Macek
c7a65ae3fe Fix MPIC mask/unmask
Before the fix for single interrupt, both percpu and non-percpu routes
were enabled/disable at the same time.

Submitted by:  Marcin Wojtas <mw@semihalf.com
Obtained from: Semihalf
Sponsored by:  Stormshield, Netgate
Reviewed by:   loos
Differential revision: https://reviews.freebsd.org/D10716
2017-05-19 08:25:40 +00:00
Wojciech Macek
fcb93d7493 Enable proper configuration of CESA MBUS windows
For all Marvell devices, MBUS windows configuration is done
in a common place. Only CESA was an exception, so move its
related code from driver to mv_common.c. This way it uses
same proper DRAM information, same as  all other interfaces
instead of parsing DT /memory node directly.

Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: loos
Differential revision: https://reviews.freebsd.org/D10723
2017-05-19 08:19:39 +00:00
Luiz Otavio O Souza
0044ecde83 Use the MACROS to access the Global mpic registers. Makes the code
consistent and easier to read.

While here, remove two unused static functions and fix a unused function
warning when building !INTRNG.

No functional changes.

Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-05-17 21:14:27 +00:00
Zbigniew Bodek
b488f7aaa5 Fix registration of MPIC driver
Submitted by:  Michal Mazur <mkm@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Netgate
Reviewed by: loos
Differential revision: https://reviews.freebsd.org/D10717
2017-05-17 15:57:14 +00:00
Zbigniew Bodek
da081cb51d Correct MPIC order of attachment
If MPIC happens to be a slave interrupt controller (as on Armada38x),
it should be attached after primary interrupt controller.
Thus BUS_PASS_ORDER_LATE was added to default BUS_PASS_INTERRUPT.

This change doesn't affect the cases when MPIC is standalone IC.

Submitted by:  Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Stormshield, Netgate
Reviewed by: loos
Differential revision: https://reviews.freebsd.org/D10715
2017-05-17 15:56:09 +00:00
Zbigniew Bodek
49b5f55902 Enable proper parsing of nested simlpe-buses on Marvell platforms
OF_finddevice doesn't find the "simple-bus" node, which is problematic
for Marvell platforms, using nested buses in Device Tree, like
Armada 38x SoC.

Submitted by: Arnaud Ysmal <arnaud.ysmal@stormshield.eu>
Obtained from: Stormshield
Sponsored by: Stormshield
Reviewed by: loos
Differential revision: https://reviews.freebsd.org/D10719
2017-05-17 15:54:33 +00:00
Zbigniew Bodek
dbd1638a48 Parse EHCI windows on Marvell platforms
Add missing compatibility string to allow proper
window configuration for EHCI devices.

Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: loos
Differential revision: https://reviews.freebsd.org/D10722
2017-05-17 15:53:13 +00:00
Zbigniew Bodek
abafc55b96 Fix USB3.0 decoding windows on Armada38x
Set correct offset for MBUS windows configuration in
USB3.0 interface.

Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: loos
Differential revision: https://reviews.freebsd.org/D10721
2017-05-17 15:52:04 +00:00
Luiz Otavio O Souza
a564364892 Move the IO Window Control Register defines out of the ARMADA38X ifdef.
Fixes the build of Marvell kernels (other than ARMADA38X) after r318336.

Reported by:	mmel
2017-05-17 15:13:01 +00:00
Ed Maste
3e85b721d6 Remove register keyword from sys/ and ANSIfy prototypes
A long long time ago the register keyword told the compiler to store
the corresponding variable in a CPU register, but it is not relevant
for any compiler used in the FreeBSD world today.

ANSIfy related prototypes while here.

Reviewed by:	cem, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10193
2017-05-17 00:34:34 +00:00
Hans Petter Selasky
65b017b420 Avoid use of contiguous memory allocations in busdma when possible.
This patch improves the boundary checks in busdma to allow more cases
using the regular page based kernel memory allocator. Especially in
the case of having a non-zero boundary in the parent DMA tag. For
example AMD64 based platforms set the PCI DMA tag boundary to
PCI_DMA_BOUNDARY, 4GB, which before this patch caused contiguous
memory allocations to be preferred when allocating more than PAGE_SIZE
bytes. Even if the required alignment was less than PAGE_SIZE bytes.

This patch also fixes the nsegments check for using kmem_alloc_attr()
when the maximum segment size is less than PAGE_SIZE bytes.

Updated some comments describing the code in question.

Differential Revision:	https://reviews.freebsd.org/D10645
Reviewed by:		kib, jhb, gallatin, scottl
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-05-16 14:21:37 +00:00
Luiz Otavio O Souza
018101a836 Add the Marvell SDHCI controller to the list of supported devices in
sdhci_fdt.

Enable the SDHCI controller, bus and devices on ARMADA38X kernel.

Tested on:	ClearFog Pro
Reviewed by:	Marcin Wojtas <mw at semihalf.com>
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D10606
2017-05-16 05:10:15 +00:00
Luiz Otavio O Souza
98a2d78daf Add the SDHCI Address Decoder registers and routines for ARMADA 38X.
Tested on:	ClearFog Pro
Reviewed by:	Marcin Wojtas <mw at semihalf.com>
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D10601
2017-05-16 04:47:50 +00:00
Michal Meloun
f1ec210574 Clarify usage rules for pmap_remap_vm_attr().
Not a functional change.

MFC with:	r318021
MFC after:	2 weeks
2017-05-13 10:00:24 +00:00
Luiz Otavio O Souza
34238cb7b3 Disable the build of the static/embedded DTB for the ARMADA38X kernel.
Build the supported DTBs as part of modules build.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-05-09 18:12:05 +00:00
Michal Meloun
39d24078f8 Revert accidentally changed std.armv6 in r318024.
MFC with:	r318024
MFC after:	2 weeks
2017-05-09 12:32:31 +00:00
Michal Meloun
19600bd917 Fix _Unwind_Backtrace symbol version for ARM.
In real GNU libgcc, _Unwind_Backtrace is published with GCC_3.3 version
for all architectures but ARM. For ARM it's publishes with GCC_4.3.0
version.
This exception is not implement in your version of libggc, thus we
export _Unwind_Backtrace with bad version. To maintain backward
compatibility, publish _Unwind_Backtrace twice, once as compatible
symbol with GCC_3.3 version, and once as default symbol with
GCC_4.3.0 version.

While I'm in, fix typo in GCC_4.2.0 to GCC_4.3.0 inheritance declaration.

MFC after:	2 weeks
2017-05-09 12:14:00 +00:00
Michal Meloun
49aaa80401 Introduce pmap_remap_vm_attr(),
it allows to remap one VM memattr class to another.

This function is intent to be used as workaround for various SoC bugs,
mainly access ordering/sequencing related bugs in crossbar fabric.

Inspired by:	https://reviews.freebsd.org/D10218
MFC after:	2 weeks
2017-05-09 11:05:32 +00:00
Adrian Chadd
5c99cda025 [arm] [rt1310] add initial RT1310 SoC code.
This code base on lpc code. Ralink RT1310 is oem from 5V Technologies.
RT1310 is ARM926EJS(arm5t).

Tested:

* Buffalo WZR2-G300N

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Reviewed by:	mizhka
Differential Revision:	https://reviews.freebsd.org/D7238
2017-05-06 06:14:46 +00:00
Olivier Houchard
899a362907 In arm_gicv2m_alloc_msi(), if we found a suitable irq range, leave the loop
before we increase irq again, or we'd end up choosing an irq, and then
really using the next one, even if it's not available.
Also in the inner loop, correct the end check so that we check every irq,
even the last one.
This makes the msk(4) adapter able to use MSI on Softiron Overdrive 1000.
2017-04-25 23:46:53 +00:00
Ganbold Tsagaankhuu
5657848913 Use hwreset_get_by_ofw_idx() function instead, since there is
no reset-names dts property defined for IR in case of H3 SoC.
That way IR works on H3 SoC based board.
Tested on Orangepi mini 2 board.
2017-04-19 05:59:00 +00:00
Zbigniew Bodek
2fcf414549 Optimize Armada38x low-level MBUS settings
Add early init handler, which comprises various internal
bus optimisations for Armada 38x SoC's. Magic values used
due to undocumented registers.

Submitted by:	Marcin Wojtas <mw@semihalf.com>,
		Arnaud Ysmal <arnaud.ysmal@stormshield.eu>
Obtained from: Semihalf, Stormshield
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10219
2017-04-18 10:39:14 +00:00
Zbigniew Bodek
803b7f053e Fix bit assignment in PL310_POWER_CTRL
Align to ARM specification:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0246f/BEIEHICF.html

Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: meloun-miracle-cz
Differential revision: https://reviews.freebsd.org/D10223
2017-04-18 10:37:08 +00:00
Zbigniew Bodek
3d9dcb4574 Add PL310 device in ARMADA38X config
Submitted by: Arnaud Ysmal <arnaud.ysmal@stormshield.eu>
Obtained from: Stormshield
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10222
2017-04-18 10:35:30 +00:00
Zbigniew Bodek
9fdc4ca57c Execute PL310_ERRATA_727915 only for related revisions
Part of PL310 erratum 727915 in pl310_wbinv_range() was
executed uncoditionally for all possible controllers'
revisions. This patch adds appropriate condition, since
extra operations are required only for revisions between
r2p0 and r3p0.

Submitted by: Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: meloun-miracle-cz
Differential revision: https://reviews.freebsd.org/D10221
2017-04-18 10:34:10 +00:00
Zbigniew Bodek
06918748e5 Add PL310 platform initialization for Armada 38x
Introduce machine-dependent part of the arm/pl310 driver for
Armada 38x SoCs. Add prefetch and power savings configuration.

Submitted by: <arnaud.ysmal@stormshield.eu>
Obtained from: Stormshield
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10220
2017-04-18 10:32:21 +00:00
Zbigniew Bodek
2dc97081b1 Increase number of L2 tables required for kernel bootstrap
Memory space reserved for pmap_kernel_l2dtable_kva and
pmap_kernel_l2ptp_kva has not been taken into account in
original code. All the memory reserved from kernel space by
pmap_alloc_specials() function called in pmap_bootstrap()
should be mapped initially by initarm(). To create initial
mapping initarm() function reserves proper number of l2 page
tables. However the number of the l2 page tables does not take
into account memory for: pmap_kernel_l2ptp_kva,
pmap_kernel_l2dtable_kva, crashdumpmap, etc.

Submitted by: Grzegorz Bernacki <gjb@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: meloun-miracle-cz
Differential revision: https://reviews.freebsd.org/D10217
2017-04-18 10:25:59 +00:00
Zbigniew Bodek
c7df7863ae Reduce kmem_arena maximum size for Armada38x
VM_KMEM_SIZE_MAX allows to limit kmem arena size. In our case this was
necessary, as decreasing size of kmem_arena leaves more space for
kernel_arena.

kernel_arena is pool used for contigmalloc (in effect, DMA) allocations,
which failed on Armada38x. This resulted in 'no memory errors'
(e.g. USB_ERR_NOMEM errors) and failure of whole system. The need for
greater size of kernel_arena probably comes from more peripherals making
use of busdma.

Value used as upper limit is half of the default value
(0x1399a000).

Submitted by: Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D10216
2017-04-18 10:20:42 +00:00
Ganbold Tsagaankhuu
64af9561d6 Remove function declaration that doesn't exist. 2017-04-18 06:58:04 +00:00
Gleb Smirnoff
83c9dea1ba - Remove 'struct vmmeter' from 'struct pcpu', leaving only global vmmeter
in place.  To do per-cpu stats, convert all fields that previously were
  maintained in the vmmeters that sit in pcpus to counter(9).
- Since some vmmeter stats may be touched at very early stages of boot,
  before we have set up UMA and we can do counter_u64_alloc(), provide an
  early counter mechanism:
  o Leave one spare uint64_t in struct pcpu, named pc_early_dummy_counter.
  o Point counter(9) fields of vmmeter to pcpu[0].pc_early_dummy_counter,
    so that at early stages of boot, before counters are allocated we already
    point to a counter that can be safely written to.
  o For sparc64 that required a whole dummy pcpu[MAXCPU] array.

Further related changes:
- Don't include vmmeter.h into pcpu.h.
- vm.stats.vm.v_swappgsout and vm.stats.vm.v_swappgsin changed to 64-bit,
  to match kernel representation.
- struct vmmeter hidden under _KERNEL, and only vmstat(1) is an exclusion.

This is based on benno@'s 4-year old patch:
https://lists.freebsd.org/pipermail/freebsd-arch/2013-July/014471.html

Reviewed by:	kib, gallatin, marius, lidl
Differential Revision:	https://reviews.freebsd.org/D10156
2017-04-17 17:34:47 +00:00
Gleb Smirnoff
9ed01c32e0 All these files need sys/vmmeter.h, but now they got it implicitly
included via sys/pcpu.h.
2017-04-17 17:07:00 +00:00
Ian Lepore
b8255b91e7 Convert probing to use an ofw_compat_data array, and add imx6ul to the list. 2017-04-16 17:53:44 +00:00
Ian Lepore
e0427caa47 Add support for the imx6ul SoC. 2017-04-15 17:02:32 +00:00
Alexander Kabaev
11011dfc94 Use proper fields to check for interrupt trigger mode. 2017-04-13 14:23:27 +00:00
Andrew Turner
4bd9887cd5 Port the IMX6 kernel configuration to use MULTIDELAY. This will help adding
the i.MX series of SoCs to the armv6 GENERIC kernel.

This uses updated times from ian@.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
2017-04-10 12:35:58 +00:00
Ian Lepore
0c076be2c2 Add support for imx6ul soc. 2017-04-10 02:46:39 +00:00
Ian Lepore
c1411a76e5 Add code/constants for detecting imx6ul (ultralite) chips, a species of
imx6 based on a single cortex-a7 core.  Other changes to imx6 drivers
and support code are needed to fully support the imx6ul.

Also fix an indentation glitch committed in the prior change.
2017-04-09 20:59:12 +00:00
Ian Lepore
08efd2cde9 Update the code that compensates for the lack of a GPC interrupt controller
driver for imx6.  Some newer dts source puts the GIC node at the root
instead of under /soc, so look in both places.  Also, sometimes the GIC
node doesn't list itself as its own interrupt-parent, allow that too.
2017-04-09 20:41:00 +00:00
Ian Lepore
2216512fcb Remove some old interrupt handling workaround code from the pre-INTRNG days.
At this point, INTRNG is not going away (the option may go away, but the
code is not), so we no longer need code to support workarounds that handled
the lack of INTRNG functionality.
2017-04-09 18:31:33 +00:00
Patrick Kelsey
67d955aab4 Corrected misspelled versions of rendezvous.
The MFC will include a compat definition of smp_no_rendevous_barrier()
that calls smp_no_rendezvous_barrier().

Reviewed by:	gnn, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D10313
2017-04-09 02:00:03 +00:00
Gavin Atkinson
5613f78480 Fix spelling mistake, BCM2835_PASWORD -> BCM2835_PASSWORD 2017-04-03 22:36:45 +00:00