Commit Graph

3765 Commits

Author SHA1 Message Date
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
Emmanuel Vadot
356c50adff Add support for Allwinner A13.
Reviewed by:	jmcneill
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6809
2016-07-08 23:38:25 +00:00
Emmanuel Vadot
f8f34e91da Check that the pin function exists before setting it.
This is needed for Allwinner A13 which has gpio pins with only "out" function.
2016-07-08 23:08:59 +00:00
Luiz Otavio O Souza
cde7231a7f Fix a lockup in tx path for cspw.
Sometimes the software loses the race when appending more descriptors to
the tx ring and the tx queue stops.

This commit detects this condition and restart the tx queue whenever it stall.

Tested by:	sobomax@, Keith White <kwhite@site.uottawa.ca>,
	Paul Mather <paul@gromit.dlib.vt.edu>
Sponsored by:	Rubicon Communications (Netgate)
Approved by:	re (kib)
2016-07-07 20:01:03 +00:00
Ian Lepore
45cd4c8cef Revert the recent armv6 changes to ALIGNED_POINTER(), restoring the
fully-pessimized implementation that requires a type to be aligned to
its natural size.

On armv6+ the compiler might generate load-/store-multiple instructions
which require 4-byte alignment even though the source code is only
accessing individual uint32_t values in a way that doesn't require any
particular alignment at all.  The compiler apparently feels free to
combine multiple accesses into a single instruction that requires a
more-strict alignment, and no set of compiler flags seems to disable
this behavior (at least in clang 3.8).

This fixes alignment faults on arm systems using wifi adapters.  The
wifi code uses ALIGNED_POINTER(p, uint32_t) to decide whether it needs
to copy-align tcp headers.  Because clang is combining several uint32_t
accesses into a single ldm instruction, we need to say that accessing a
uint32_t requires 4-byte alignment.

Approved by:	re(gjb)
2016-06-21 17:53:42 +00:00
Konstantin Belousov
5c2cf81845 Update comments for the MD functions managing contexts for new
threads, to make it less confusing and using modern kernel terms.

Rename the functions to reflect current use of the functions, instead
of the historic KSE conventions:
  cpu_set_fork_handler -> cpu_fork_kthread_handler (for kthreads)
  cpu_set_upcall -> cpu_copy_thread (for forks)
  cpu_set_upcall_kse -> cpu_set_upcall (for new threads creation)

Reviewed by:	jhb (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Approved by:	re (hrs)
Differential revision:	https://reviews.freebsd.org/D6731
2016-06-16 12:05:44 +00:00
Andrew Turner
c3ab415cb2 Move the arm call to intr_pic_init_secondary earlier in the secondary CPU
initialisation. This ensures it will complete before signalling to the boot
CPU it has booted. This fixes a race with the GIC where the arm_gic_map may
not be populated before it is used to bind interrupts leading to some
interrupts becoming bound to no CPUs.

Approved by:	re (kib)
Sponsored by:	ABT Systems Ltd
2016-06-14 16:41:39 +00:00
Ian Lepore
e2a03c1fe5 Do not define __NO_STRICT_ALIGNMENT for armv6. While the requirements
are no longer natural-alignment strict, there are still some restrictions.

FreeBSD network code assumes data is naturally-aligned or is running
on a platform with no restrictions; pointers are not annotated to
indicate the data pointed to may be packed or unaligned.  The clang
optimizer can sometimes combine the load or store of a pair of adjacent
32-bit values into a single doubleword load/store, and that operation
requires at least 4-byte alignment.  __NO_STRICT_ALIGNMENT can lead
to tcp headers being only 2-byte aligned.

Note that alignment faults remain disabled on armv6, this change reverts
only the defining of the symbol which leads to some overly-agressive code
shortcuts when building common/shared drivers and network code for arm.

Approved by:	re(kib)
2016-06-13 16:48:27 +00:00
Andrew Turner
4a9fc96001 Remove the ARMv4/ARMv5 userland atomic support from struct proc on armv6.
Nothing should use this on armv6 as we use the atomic instructions added in
ARMv6k.

Sponsored by:	ABT Systems Ltd
2016-06-08 22:29:30 +00:00
Andrew Turner
8a77146289 Start to clean MIDR values using the CPUID scheme. We don't need to know
the exact CPU we are running on to set the cpu functions. Relax the check
to ignore the CPU revision. Even so this may still be too specific.

Reviewed by:	mmel
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D6504
2016-06-07 18:50:36 +00:00
Svatopluk Kraus
ad5244ece1 INTRNG - change the way how an interrupt mapping data are provided
to the framework in OFW (FDT) case.

This is a follow-up to r301451.

Differential Revision:	https://reviews.freebsd.org/D6634
2016-06-05 16:20:12 +00:00
Pedro F. Giffuni
95a9e5d682 tegra124: use roundup/rounddown macros from <sys/param.h>. 2016-06-03 21:11:34 +00:00
Zbigniew Bodek
85bf4227a0 Use nitems() macro instead of re-inventing it
Fixed after r301221.

Pointed out by:	oshogbo
Submitted by:	Michal Stanek <mst@semihalf.com>
Obtained from:	Semihalf
2016-06-03 18:52:57 +00:00
Svatopluk Kraus
477ef5caf6 Define irq variable only in the block where used. 2016-06-03 11:18:30 +00:00
Svatopluk Kraus
4d7f3703e2 Postpone allocation of IRQ resource to the time when interrupt
controller devices are attached. This has already been done for
bus_setup_intr().

There was no doubt that if someone wants to setup an interrupt,
corresponding interrupt controller device must already be attached.
However, the same must be valid for allocation of an interrupt resource
unless the allocation is done blindly, without any information that
such interrupt even exists. While it was done this blind way before,
it won't be possible after next INTRNG change.
2016-06-03 11:05:55 +00:00
Zbigniew Bodek
c247b3ca67 Add support for CESA on Armada38x
Changes:
- added new SoC ID in CESA attach
- allowed crypto driver IDs other than 0
- added CESA nodes to Armada38x .dts files
- enabled required devices in kernconf

Submitted by:	Michal Stanek <mst@semihalf.com>
Obtained from:	Semihalf
Sponsored by:	Stormshield
Differential revision:	https://reviews.freebsd.org/D6220
2016-06-02 18:41:33 +00:00
Zbigniew Bodek
5d7cb9a803 Configure CPU window to second CESA SRAM
Check if there is a second CESA SRAM node in FDT and add a CPU window
for it. Define A38X specific macro for setting device attribute for
each node.

Submitted by:	Michal Stanek <mst@semihalf.com>
Obtained from:	Semihalf
Sponsored by:	Stormshield
Differential revision:	https://reviews.freebsd.org/D6216
2016-06-02 18:33:26 +00:00
Zbigniew Bodek
5188e3cca6 Map CESA SRAM memory in driver attach for Armada38x
On other platforms with CESA accelerator the SRAM memory is mapped in
early init before driver is attached. This method only works correctly
with mappings no smaller than L1 section size (1MB). There may be more
SRAM blocks and they may have smaller sizes than 1MB as is the case
for Armada38x. Instead, map SRAM memory with bus_space_map() in CESA
driver attach. Note that we can no longer assume that VA == PA for the
SRAM.

Submitted by:	Michal Stanek <mst@semihalf.com
Obtained from:	Semihalf
Sponsored by:	Stormshield
Differential revision:	https://reviews.freebsd.org/D6215
2016-06-02 18:31:36 +00:00
Jared McNeill
b8f34c287a Fix a crash while iterating compat strings when no match is found.
Spotted by:	ian
2016-05-31 21:58:09 +00:00
Andrew Turner
02a1932d1c arm_gic_map is a mask not the CPUs ID, there is no need to shift it.
Pointy-hat to:	andrew
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-05-31 18:05:17 +00:00
Andrew Turner
9a53d57e54 Bin interrupts to the correct CPU when we boot on a non-zero CPU.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-05-31 17:49:47 +00:00
Zbigniew Bodek
01ed3219b9 Improve ARM debug_monitor for SMP machines
- Reset debug architecture and enable monitor for secondary
  CPUs in init_secondary() rather than when configuring watchpoint, etc.
- Disable HW debugging capabilities when one of the CPU cores fails
  to set up.
- Use dbg_capable() in a more atomic manner to avoid any mismatch
  between CPUs.

Differential Revision: https://reviews.freebsd.org/D6009
2016-05-29 17:35:38 +00:00
Zbigniew Bodek
9ae1207bcf Fix debug_monitor code for older ARMs (ARM11)
- Enable monitor mode prior to accessing watchpoint
  registers for v6, v6.1 architectures.
- Fix configuration scheme for v6, v6.1 and v7 Debug Archs
- Enable monitor unconditionally and for good instead
  of enabling and disabling it (needed for single stepping
  on on v6/v6.1)

Tested on RPI-B and Arndale

Differential Revision: https://reviews.freebsd.org/D6008
2016-05-29 17:33:49 +00:00
Michal Meloun
74bf497550 ARM GIC: Allow to setup interrupt without configuration data.
In some cases, like for PCI devices, only interrupt numbers are enumerated
from HW. In this case, use INTR_foo_CONFORM as level and trigger values.
2016-05-29 07:39:56 +00:00
Ian Lepore
e3f2d7af0e Add support for triggering interrupts on both rising and falling edges.
Also, EOI a gpio interrupt in the post_ithread routine before re-enabling.
2016-05-26 22:34:25 +00:00
Emmanuel Vadot
30068a1de9 Add support for interrupts, sensors and GPIO for AXP209 PMIC.
Pressing the PEK (power enable key) will shutdown the board.
Some events are reported to devd via system "PMU" and subsystem
"Battery", "AC" and "USB" such as connected/disconnected.
Some sensors values (power source voltage/current) are reported via
sysctl (dev.axp209_pmu.X.)
It also expose a gpioc node usable in kernel and userland. Only 3 of
the 4 GPIO are exposed (The GPIO3 is different and mostly unused on
boards). Most popular boards uses GPIO1 as a sense pin for OTG power.
Add a dtsi file that adds gpio-controller capability to the device as
upstream doesn't defined it and include it in our custom DTS.

Reviewed by:	jmcneill
Approved by:	cognet (mentor)
Differential Revision:	https://reviews.freebsd.org/D6135
2016-05-26 21:09:07 +00:00
Luiz Otavio O Souza
d3dd020425 Only do the touch screen setup when the 'ti,wires' property is present.
While here fix a typo in a debug message.
2016-05-26 18:52:26 +00:00
Jared McNeill
627c360fa7 Enable USB PHY regulators when requested by the host controller driver.
Previously the USB PHY driver would enable all regulators at attach time.
This prevented boards from booting when powered by the USB OTG port, as
it didn't take VBUS presence into consideration.
2016-05-26 10:50:39 +00:00
Ian Lepore
183d468536 Another round of changes to add compatibility with the older ESHDC variety
of hardware.  Mostly this focuses on the big changes needed for setting the
bus clock, because ESDHC is SDHCI v2.0 and USDHC is 3.0, and the number,
location, and interpretation of clock divisor bits is vastly different
between the two.  This doesn't get the device all the way to functioning
on ESDHC hardware yet, but it's much closer, now getting through all the
card detection and negotiation of capabilties and speed (but it eventually
hangs on what appears to be a missing interrupt).

Another missing chunk of code for handling ESDHC's 32 bit command-and-mode
register using sdhci's pair of 16 bit writes is added.

This also does some leading whitespace cleanups and sorts some softc
struct members by size, and adds some comments (because when do I ever
touch code without adding comments?).
2016-05-26 03:55:27 +00:00
Ian Lepore
40cb6df5f3 Disable alignment faults on armv6, adjust various alignment-related macros
to match the new state of affairs.  The hardware we support has always been
able to do unaligned accesses, we've just never enabled it until now.

This brings FreeBSD into line with all the other major OSes, and should help
with the growing volume of 3rd-party software that assumes unaligned access
will just work on armv6 and armv7.
2016-05-26 00:03:23 +00:00
Ian Lepore
a66dc0c52b Include machine/acle-compat.h in cdefs.h on arm if the compiler doesn't
have ACLE support built in.  The ACLE (ARM C Language Extensions) defines
a set of standardized symbols which indicate the architecture version and
features available.  ACLE support is built in to modern compilers (both
clang and gcc), but absent from gcc prior to 4.4.

ARM (the company) provides the acle-compat.h header file to define the
right symbols for older versions of gcc.  Basically, acle-compat.h does
for arm about the same thing cdefs.h does for freebsd: defines
standardized macros that work no matter which compiler you use.  If ARM
hadn't provided this file we would have ended up with a big #ifdef __arm__
section in cdefs.h with our own compatibility shims.

Remove #include <machine/acle-compat.h> from the zillion other places (an
ever-growing list) that it appears.  Since style(9) requires sys/types.h
or sys/param.h early in the include list, and both of those lead to
including cdefs.h, only a couple special cases still need to include
acle-compat.h directly.

Loves it:     imp
2016-05-25 19:44:26 +00:00
Svatopluk Kraus
8dc78d592c Add more info about the issue fixed in r298460. Rephrase some sentences
and fix grammar.

No functional change.

Suggested by:	alc
Reviewed by:	alc
2016-05-25 10:09:23 +00:00
Ian Lepore
0d66d6d423 Spaces->tab in comment. 2016-05-23 20:13:17 +00:00
Ian Lepore
25926a4b4b Oops, fix a paste-o commited in r300533. 2016-05-23 20:12:38 +00:00