Commit Graph

3798 Commits

Author SHA1 Message Date
Emmanuel Vadot
f8fc698b0d allwinner: Remove a20/a20_cpu_cfg.c from the build.
This was needed when we used the SoC specific timer and not the generic-timer.
2016-08-21 16:03:44 +00:00
Emmanuel Vadot
bee987e3c8 if_emac: Before generating a random MAC address, try using the SID rootkey
to generate one. This is was U-Boot does to generate a random MAC so we end
up with the same MAC address as if U-Boot did generate it.

MFC after:	1 week
2016-08-19 23:44:07 +00:00
Emmanuel Vadot
2d6c6bf704 Keep boot parameters in ARM trampoline code
Currently boot parameters (r0 - r3) are forgotten in ARM trampoline code.
This patch save them at startup and restore them before jumping into kernel
_start() routine.
This is usefull when booting with Linux ABI and/or custom bootloader.

Submitted by:	Grégory Soutadé <soutade@gmail.com>
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D7395
2016-08-19 18:02:36 +00:00
Emmanuel Vadot
c8442223b6 Allwinner: Move a10_padconf.c into a10 subdirectory. 2016-08-19 12:48:32 +00:00
Michal Meloun
032bdb1bb4 TEGRA: Remove forgotten debug printf. 2016-08-19 11:12:59 +00:00
Michal Meloun
7709abd109 TEGRA: Implement MSI/MSIX interrupts for pcie controller. 2016-08-19 10:53:17 +00:00
Michal Meloun
895c8b1c39 INTRNG: Rework handling with resources. Partially revert r301453.
- Read interrupt properties at bus enumeration time and store
   it into global mapping table.
 - At bus_activate_resource() time, given mapping entry is resolved and
   connected to real interrupt source. A copy of mapping entry is attached
   to given resource.
 - At bus_setup_intr() time, mapping entry stored in resource is used
   for delivery of requested interrupt configuration.
 - For MSI/MSIX interrupts, mapping entry is created within
   pci_alloc_msi()/pci_alloc_msix() call.
 - For legacy PCI interrupts, mapping entry must be created within
   pcib_route_interrupt() by pcib driver itself.

Reviewed by: nwhitehorn, andrew
Differential Revision: https://reviews.freebsd.org/D7493
2016-08-19 10:52:39 +00:00
Emmanuel Vadot
d00d8ed84f Rename allwinner_machdep.{c.h} to aw_machdep.{c.h} as all allwinner source
files are name aw_*
2016-08-17 21:44:02 +00:00
Emmanuel Vadot
627ea1e104 Rename kernel config A10 into ALLWINNER_UP as it is intend to work with all
Allwinner Uniprocessor SoC.
As of now it works with A10 and A13 (and possibly R8 as it is the same as the A13).
Move files.a10 into a1o subdirectory as it should be.
Rename std.a10 into std.allwinner_up
2016-08-17 20:32:08 +00:00
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
Konstantin Belousov
1680854946 Implement userspace gettimeofday(2) with HPET timecounter.
Right now, userspace (fast) gettimeofday(2) on x86 only works for
RDTSC.  For older machines, like Core2, where RDTSC is not C2/C3
invariant, and which fall to HPET hardware, this means that the call
has both the penalty of the syscall and of the uncached hw behind the
QPI or PCIe connection to the sought bridge.  Nothing can me done
against the access latency, but the syscall overhead can be removed.
System already provides mappable /dev/hpetX devices, which gives
straight access to the HPET registers page.

Add yet another algorithm to the x86 'vdso' timehands. Libc is updated
to handle both RDTSC and HPET.  For HPET, the index of the hpet device
to mmap is passed from kernel to userspace, index might be changed and
libc invalidates its mapping as needed.

Remove cpu_fill_vdso_timehands() KPI, instead require that
timecounters which can be used from userspace, to provide
tc_fill_vdso_timehands{,32}() methods.  Merge i386 and amd64
libc/<arch>/sys/__vdso_gettc.c into one source file in the new
libc/x86/sys location.  __vdso_gettc() internal interface is changed
to move timecounter algorithm detection into the MD code.

Measurements show that RDTSC even with the syscall overhead is faster
than userspace HPET access.  But still, userspace HPET is three-four
times faster than syscall HPET on several Core2 and SandyBridge
machines.

Tested by:	Howard Su <howard0su@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D7473
2016-08-17 09:52:09 +00:00
Emmanuel Vadot
29f11c7d8b Correct the size of the softc in a10_ehci
Reported by:	andrew
MFC after:	1 week
2016-08-14 13:17:59 +00:00
Pedro F. Giffuni
a061aa46fe sys: replace comma with semicolon when pertinent.
Uses of commas instead of a semicolons can easily go undetected. The comma
can serve as a statement separator but this shouldn't be abused when
statements are meant to be standalone.

Detected with devel/coccinelle following a hint from DragonFlyBSD.

MFC after:	1 month
2016-08-09 19:42:20 +00:00
Edward Tomasz Napierala
7ee3fef85a Remove some NULL checks after M_WAITOK allocations from sys/arm/.
MFC after:	1 month
2016-08-09 16:02:35 +00:00
Emmanuel Vadot
80ab358ee4 We need aw_nmi to be attached which needs GIC so attach a bit later.
Also the GPIOC doesn't need to be attach early

Reviewed by:	andrew
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D7082
2016-08-03 18:45:56 +00:00
Ed Maste
dd2be8cb6e Move/add ARM ELF PHDR types to elf_common.h
Accidentally missed in r303674
2016-08-02 20:26:04 +00:00
Andrew Turner
727c18a84f Split out the FDT parts of the GICv2 interrupt controller driver. This will
allow us to add an ACPI attachment for arm64.

Obtained from:	ABT Systems Ltd
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7307
2016-08-01 16:29:04 +00:00
Luiz Otavio O Souza
92ee0c01d4 Enable the build of micphy as part of generic miibus build, but only for
FDT enabled systems.

Sponsored by:	Rubicon Communications (Netgate)
2016-07-28 05:59:56 +00:00
Alexander Motin
fb112f72a8 Add more UEFI/e820 memory types from latest specifications.
This is only cosmetics.

MFC after:	2 weeks
2016-07-24 09:15:11 +00:00
Luiz Otavio O Souza
285e3c3ea9 Allow the use of micphy on am335x devices.
The Micrel PHYs reads the optional external delays from DTB.

Tested and used by uBMC and uFW.

Sponsored by:	Rubicon Communications (Netgate)
2016-07-24 01:31:41 +00:00
Luiz Otavio O Souza
522f50c5a0 Remove unused USB ethernet driver from BEAGLEBONE/AM335x kernel. 2016-07-23 17:36:17 +00:00
Emmanuel Vadot
1c26086e73 PC5 doesn't have mmc2 function. 2016-07-22 14:39:55 +00:00
Emmanuel Vadot
852047d66a axp209 needs aw_nmi so attach a bit earlier
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D7081
2016-07-21 13:28:07 +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
Emmanuel Vadot
280ab2edb1 Add support for the SID (Security ID Module) on Allwinner A10 and A20.
The rootkey is burnt at production and can't be changed, thus is can be used
as a device unique ID or to generate a MAC address (This is was u-boot does).
The rootkey is exposed as a sysctl (dev.aw_sid.<unit>.rootkey).

Reviewed by:	jmcneill
Differential Revision:	https://reviews.freebsd.org/D6383
2016-07-20 11:23:06 +00:00
Mark Murray
a1acc06f4f Random bit generator (RBG) driver for RPi and RPi2.
Summary:
This driver supports the following methods to trigger gathering random bits from the hardware:
1. interrupt when the FIFO is full (default) fed into the harvest queue
2. callout (when BCM2835_RNG_USE_CALLOUT is defined) every second if hz is less than 100, otherwise hz / 100, feeding the random bits into the harvest queue

If the kernel is booted with verbose enabled, the contents of the registers will be dumped after the RBG is started during the attach routine.

Author: hackagadget_gmail.com (Stephen J. Kiernan)

Test Plan: Built RPI2 kernel and booted on board. Tested the different methods to feed the harvest queue (callout, interrupt) and the interrupt driven approach seems best. However, keeping the other method for people to be able to experiment with.

Reviewed By: adrian, delphij, markm

Differential Revision: https://reviews.freebsd.org/D6888
2016-07-19 18:07:47 +00:00
Luiz Otavio O Souza
59b67ee8f0 Fix a random memory overwrite at boot time, simplebus_init() and
simplebus_add_device() expect a simplebus_softc structure associated with
the device.

Add the simplebus_softc as first member in am335x_pwmss_softc structure.

Sponsored by:	Rubicon Communications (Netgate)
2016-07-18 06:35:40 +00:00
Michal Meloun
79cceaac0f TEGRA: Subclass Tegra PCIE driver from ofw_pci base driver.
Remove now redundant code.
2016-07-17 14:45:15 +00:00
Jared McNeill
01a469b860 Add support for Allwinner H3 EMAC.
H3 EMAC is the same as A83T/A64 except the SoC includes an (optional)
internal 10/100 PHY. Both internal and external PHYs are supported on H3
with this driver.
2016-07-16 18:06:41 +00:00
Jared McNeill
169285288c Allwinner Gigabit EMAC performance improvements.
- Support DEVICE_POLLING
 - Increase TX descriptors to 1024
 - Add support for passing a chain of mbufs to if_input, reducing the
   number of calls to mtx_unlock/mtx_lock under load.
 - Remove duplicate byteswap when setting TX_INT_CTL in TX descriptor.
 - Set undocumented "TX_NEXT_FRAME" bit in TX control 1 register.
   According to the A83T BSP, setting this bit allows the DMA engine to
   operate on a packet while receiving another.

Tested on A83T (1000Mbps PHY) and H3 (100Mbps PHY).

Reviewed by:		manu
Differential Revision:	https://reviews.freebsd.org/D7031
2016-07-13 20:46:54 +00:00
Jared McNeill
814f548cd5 H3/A83T: Use PLL_PERIPH/2 for AHB2 parent clock.
Reviewed by:	manu
2016-07-13 20:44:02 +00:00
Andrey A. Chernov
239e5577a2 Undo r302601, WCHAR_MAX may not be a valid wchar value. 2016-07-12 04:20:44 +00:00
Andrey A. Chernov
713a61670c I don't know why unsigned int is choosed for wchar_t here, but WCHAR_MAX
should be <= WINT_MAX. It is bigger, __UINT_MAX > INT32_MAX
2016-07-12 00:37:48 +00:00
Jared McNeill
9f2b8101d7 Add support for Allwinner A64.
Reviewed by:	andrew, manu
2016-07-11 20:15:46 +00:00
Jared McNeill
d1d50b7010 Return early from bus_dmamap_load callback if the error indicator is set.
Reviewed by:	andrew, manu
2016-07-11 20:14:50 +00:00
Jared McNeill
d40e52436e Add support for arm64. The allwinner_soc_family() function is not available
on arm64 and all SoCs using the old FIFO register location are 32-bit only,
so unconditionally use the new location for arm64.

Reviewed by:	andrew, manu
2016-07-11 20:13:46 +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
Jared McNeill
25cd5941be Add Allwinner A64 padconf settings.
Reviewed by:	andrew, manu
2016-07-11 20:06:21 +00:00
Jared McNeill
2274551aba Include sys/rman.h to fix build on arm64. 2016-07-11 20:03:31 +00:00
Jared McNeill
221a9d6dd6 Attach RSB early. Children of RSB may provide resources necessary for
other devices such as interrupts, GPIOs, and regulators.
2016-07-11 20:02:51 +00:00
Jared McNeill
7dd6227263 Build fix for arm64. The phy interface uses intptr_t for the "phy"
parameter, not int.
2016-07-11 20:00:57 +00:00
Jared McNeill
18c3530813 Remove unused bus_space prototypes. 2016-07-11 19:58:00 +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
Jared McNeill
22a81821b0 Align descriptors and data buffers to 32 bits. This restriction is
described in the A20 (and later) user manuals.
2016-07-10 10:38:28 +00:00
Jared McNeill
6964917c0e In the absence of a bus-width property, default to 4-bit bus width instead
of 1-bit.
2016-07-10 10:21:22 +00:00
Ian Lepore
3a86bcdd17 Remove HZ=<various> from all armv6 configs, put HZ=1000 in std.armv6.
All armv6 processors are plenty fast enough for HZ=1000.

No changes are made for older arm systems, because some chips are a bit
wimpy for 1000 while others do fine, so it has to be set on a per-config
basis.
2016-07-09 21:14:59 +00:00
Ian Lepore
7651aa600b Consolidate debugging options from all arm kernel configs to std.arm[v6]. 2016-07-09 20:42:57 +00:00
Ian Lepore
392a8e4408 Correct syntax errors that only show up when compiled with INVARIANTS. 2016-07-09 18:43:15 +00:00
Andrew Turner
04d18df9af Remove an unneeded call to fdt_get_unit, the return value is unused.
MFC after:	1 month
Sponsored by:	ABT Systems Ltd
2016-07-09 13:27:14 +00:00