Commit Graph

3707 Commits

Author SHA1 Message Date
Andrew Turner
501ce0d86b Add support for the Allwinner DMA controller. This will be used by the at
least the audio codec driver currently in review.

Submitted by:	Jared McNeill <jmcneill@invisible.ca>
Differential Revision:	https://reviews.freebsd.org/D5050
2016-02-15 19:56:35 +00:00
Andrew Turner
2ff143af3f Add support for the AXP209 Power System Management IC. This allows boards
with this and an Allwinner SoC to power off.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D4954
2016-02-15 19:31:23 +00:00
Andrew Turner
4d1defda24 Set sc->clkfreq removed in r295470
Reported by:	Jared McNeill <jmcneill@invisible.ca>
Pointy-hat to:	andrew
2016-02-15 19:14:24 +00:00
Andrew Turner
0df627dc54 Remove an unused static inline function.
Sponsored by:	ABT Systems Ltd
2016-02-15 16:55:44 +00:00
Svatopluk Kraus
c2849e3c11 Initial OMAP4 WUGEN pass-through driver. SPI interrupts are passed
through WUGEN to GIC. Hardware initialization is left in state after
reset as well as before.

This is needed after an update of Linux dts files.
2016-02-15 15:28:56 +00:00
Andrew Turner
5f250b53e8 Add support for the Allwinner i2c device. This is similar to the existing
Marvell twsi part, however uses different register locations, as such split
the existing driver into Marvell and Allwinner attachments.

While here clean a few style issues.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D4846
2016-02-15 15:11:26 +00:00
Andrew Turner
632381ed9d Move the twsi driver source to be under iicbus. It is in a separate
directory as it is expected multiple attachments will be added for the SoC
families that use this hardware.

Sponsored by:	ABT Systems Ltd
2016-02-14 23:51:13 +00:00
Andrew Turner
aa8dbafa71 Create the twsi device option in preparation to move the driver to a common
location. The device is also found in Allwinner SoCs.

Sponsored by:	ABT Systems Ltd
2016-02-14 23:42:07 +00:00
Andrew Turner
15147f076e Remove an unused include. 2016-02-14 16:38:32 +00:00
Andrew Turner
ee211e0268 Stop adding an extra null terminator to strings, OF_getprop already returns
a null terminated string.
2016-02-12 17:04:03 +00:00
Andrew Turner
77fc1120a7 Enable ARM_INTRNG on all kernel configs where we use the Generic Interrupt
Controller.

Sponsored by:	ABT Systems Ltd
2016-02-11 18:01:10 +00:00
Andrew Turner
647a3bac7e Stop defining fdt_pic_table when building for ARM_INTRNG. 2016-02-11 11:49:27 +00:00
Andrew Turner
75d36854d4 Remove unused Zedboard config files. files.zedboard was empty other than
comments, and std.zedboard just pointed to files.zedboard and std.xilinx.
2016-02-11 10:48:15 +00:00
Andrew Turner
09bcaf7acc Fix a logic inversion when checking for ARM_INTRNG
Pointy hat to:	andrew
2016-02-10 16:44:20 +00:00
Andrew Turner
c5fdd4d379 Only use fdt_pic_table when not using ARM_INTRNG 2016-02-10 16:39:02 +00:00
Andrew Turner
1e2b39a3f2 Use OF_getencprop to read a property, it already handles the endian
conversion so we don't need to pass the data through fdt32_to_cpu.
2016-02-10 15:56:52 +00:00
Andrew Turner
907fe11655 Update of the Allwinner drivers to:
* Use the Linux compat string
 * Use EARLY_DRIVER_MODULE to attach at the right time
 * Add a generic A10 kernel config file
 * A20 now use generic_timer
 * Add two new dts files for Olimex boards
 * Update our custom DTS file for A10 and A20 to use the same compatible
   property names as the vendor ones.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D4792
2016-02-10 09:19:29 +00:00
Adrian Chadd
d6233babae Break out the shared bits of the arm intrng definitions into sys/intr.h;
leave the machine dependent bits in sys/arm/.

This is in preparation for MIPS INTRNG work.

Submitted by:	Stanislav Galabov <sgalabov@gmail.com>
2016-02-10 04:43:08 +00:00
Gleb Smirnoff
b28cc462ad Include sys/_task.h into uma_int.h, so that taskqueue.h isn't a
requirement for uma_int.h.

Suggested by:	jhb
2016-02-09 20:22:35 +00:00
Andrew Turner
23da15d045 Remove unneeded whitespace, and fix a license for a new file. Extracted
from a larger patch.

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
X-Differential Revision:	https://reviews.freebsd.org/D4792
2016-02-09 18:19:24 +00:00
Michal Meloun
a89156f53f ARM: Use new ARMv6 naming conventions for cache and TLB functions
in all but ARMv4 specific files.
Expand ARMv6 compatibility stubs in cpu-v4.h. Use physical address
in L2 cache functions if ARM_L2_PIPT is defined.
2016-02-05 14:57:41 +00:00
Svatopluk Kraus
3af1c2aae2 Follow up r295257 and replace bad reference to TEX in defines,
variables and functions. This stuff is named properly now.

Thus, the VM_MEMATTR_xxx is an index to PTE2 attribute table.

Pointy hat to:	skra
2016-02-05 11:28:35 +00:00
Svatopluk Kraus
a901e7b637 Follow up r295257 and convert also pt_memattr. This did not break
anything as both VM_MEMATTR_WB_WA and PTE2_ATTR_WB_WA are zero.
Correct also type of pmap_dcache_wb_pou() last argument.
2016-02-05 10:40:01 +00:00
Michal Meloun
3025d19dfc ARM: Introduce new cpu-v4.h header and move all ARMv4 specific code
from cpu-v6.h to it.
Remove unneeded cpu-v6.h includes.
2016-02-05 09:46:24 +00:00
Michal Meloun
49475a5b47 Replace broken implementation of fuswintr() and suswintr() by functions
which return -1 as well as on tier 1 archs. Remove block_userspace_access
used only in these implementations.

(1) These functions may be called in interrupt context and pcb_onfault
can be already set in this time. Thus, prior pcb_onfault must be saved
and restored afterwards.

(2) The check that an abort came either from nested interrupt or while
in critical section or holding not sleepable lock must be avoided for
this case.

These functions are called only for profiling reason, so there will be
only small gain by making the code more complex.
2016-02-04 17:01:38 +00:00
Michal Meloun
dfa0f9c66a ARM: For ARMv6/v7, code in locore.S initializes SCTLR and ACTRL registers.
Don't duplicate this initialization in cpu_setup().
2016-02-04 14:32:48 +00:00
Svatopluk Kraus
82f313b3f0 Make VM_MEMATTR_xxx definitions independent on pmap internals
for __ARM_ARCH >= 6.

It's TEX class number now, so it still has some meaning.
2016-02-04 14:15:24 +00:00
Michal Meloun
a65bd3c84b ARM: Set UNAL_ENABLE bit in SCTLR CP15 register. This bit is RAO/SBOP
for ARMv7. For ARMv6, it controls ARMv5 compatible alignment support.
This bit have no effect until unaligned access is enabled.
2016-02-04 14:02:42 +00:00
Svatopluk Kraus
f196c10421 Small rearrangement of abort_handler().
(1) Move cnt.v_trap increment to the beginning. There is cnt.v_vm_faults
counter in vm_fault(), so a number of hardware emulation aborts may be
get roughly as difference.
(2) Move kdb_reenter() up to not be ignored if pmap_fault() has failed.
(3) Update comments.
2016-02-04 13:35:40 +00:00
Michal Meloun
f7e5efbbae ARM: RPI-B kernel was broken by r294740. Make it functional again. 2016-02-04 13:32:29 +00:00
Michal Meloun
0b5afe4aea ARM: Don't use ugly (and hidden) global variable, control register is
readable at any time.
2016-02-04 12:11:18 +00:00
Ruslan Bukin
ef9ca62c6b Fix build. 2016-02-04 12:06:06 +00:00
Michal Meloun
98d40dd063 ARM: Remove unused symbols from genassym.c. 2016-02-04 06:39:20 +00:00
Michal Meloun
d1e8cd8a88 ARM: Consistently use cpu_setttb() instead of setttb().
Remove unused #define for drain_writebuf.
2016-02-03 16:44:06 +00:00
Michal Meloun
d397c7a0af ARM: Replace only once used cpu_icache_sync_all() by ranged equivalent.
Remove it from cpu_functions table.
2016-02-03 13:47:50 +00:00
Svatopluk Kraus
b4ae00fcd7 Partly revert r295168 and define PTE_DEVICE in pmap-v6.h header again.
It turned out that devmap.c is not only file in which PTE_DEVICE
is used and simultaneously, built for both armv4 and armv6 platforms.

When I tried to build all arm kernels before r295168 commit, it was
hid by some other local changes in my tree. I hope that this is just
temporary workaround before VM_MEMATTR_DEVICE could be used instead of
PTE_DEVICE outside of pmap code for __ARM_ARCH < 6.
2016-02-03 12:11:07 +00:00
Michal Meloun
24fbfc5fd5 ARM: Remove C++ comments erroneously committed in r295200. 2016-02-03 10:39:29 +00:00
Michal Meloun
afdcfee483 ARM: Remove support for xscale i80219 and i80321 CPUs. We haven't single
supported config/board with these CPUs.
2016-02-03 09:15:44 +00:00
Michal Meloun
619552c93a ARM: The arm/xscale/i80321 directory is now orphaned, but two drivers
are shared with i8134x. In preparation for removal of i80321, copy these
drivers to i8134x.
2016-02-03 08:59:12 +00:00
Michal Meloun
8b77f22e7a ARM: acle-compat.h is arm specific header, don't include it for aarch64. This
fixes aarch64 buildkernel.
2016-02-03 08:12:21 +00:00
Svatopluk Kraus
677ba8502b Use pmap_preboot_map_attr() directly in arm_devmap_bootstrap()
instead of hiding behind pmap_map_chunk(). It's not longer needed
after old pmap-v6 code was removed.

For compatibility with __ARM_ARCH < 6, define PTE_DEVICE in devmap.c
file. Certainly, it would be nice if VM_MEMATTR_DEVICE could be used
even for __ARM_ARCH < 6.
2016-02-02 21:17:25 +00:00
Svatopluk Kraus
0a57d9e4c3 Make pmap_preboot_map_attr() vm subsystem compliant, so its arguments
do not depend on pmap internals. This is a preparation for hiding
internal pmap definitions as much as possible from the rest of system.

Simultaneously, the protection argument evaluation is fixed. Happily,
it did not effect the mappings. And it's the reason why it was not fixed
earlier.
2016-02-02 21:10:55 +00:00
Michal Meloun
e3f95afdec ARM: All remaining functions in cpufunc_asm_arm10.S are identical with
functions in cpufunc_asm_arm9.S. Use arm9 variants and remove
cpufunc_asm_arm10.S completly.
2016-02-02 14:53:34 +00:00
Michal Meloun
fc4c15c466 ARM: Remove last unused function, cpu_flush_prefetchbuf(),
from cpu_functions table.
2016-02-02 10:50:32 +00:00
Svatopluk Kraus
e81df52303 Remove all remaining references to old and not more used struct
pmap_devmap, pmap_devmap_bootstrap() and pmap_devmap[]. It was
replaced in r257660.
2016-02-02 10:32:45 +00:00
Svatopluk Kraus
6f95e9062b Fix setting of protection bits for page table entries in pmap_map(). This
function is only called from vm_page_startup() and vm_reserv_startup().
I.e. during vm subsystem initialization. As VM_PROT_WRITE is always
used in these calls, the typo did not have any effect. Likely, it's
the reason why it wasn't discovered so long.
2016-02-02 10:17:51 +00:00
Svatopluk Kraus
d713568142 Remove all stuff related to __ARM_ARCH >= 6 from pmap.h header except
for <machine/pmap-v6.h> include. It was used by old pmap-v6 code.
2016-02-01 19:43:04 +00:00
Svatopluk Kraus
231ccab8e7 Remove not needed <machine/pte.h> includes. 2016-02-01 19:36:33 +00:00
Michal Meloun
ebda969939 ARM: Rename remaining instances of cpufunc_id() to cpu_ident(),
forgotten in r295096.
Remove tlb_flushI/tlb_flushI_SE functions forgotten in r295122.
2016-02-01 14:28:58 +00:00
Michal Meloun
03fa312bb7 ARM: Remove never used cpu_tlb_flushI and cpu_tlb_flushI_SE() functions
and their implementations.
2016-02-01 13:13:53 +00:00
Michal Meloun
3fa3c8c7b5 ARM: Fix END() symbol for cpu_ident function. I forgot to rename it
in r295096.
2016-01-31 16:55:52 +00:00
Michal Meloun
bf488b9dde ARM: cpufunc_domains, cpufunc_faultstatus and cpufunc_faultaddress
functions are equal for all ARM variants. Remove them from cpu_functions
table.
2016-01-31 16:34:06 +00:00
Michal Meloun
0d87509689 ARM: Next round of cpufunc.* cleaning. Nobody uses flush_brnchtgt* functions,
delete them.
2016-01-31 15:36:13 +00:00
Michal Meloun
24338d26d4 ARM: First round of cpufunc.* cleaning. All abort_fixup functions are
not currently used or defined. Delete them.
2016-01-31 13:59:16 +00:00
Michal Meloun
83242da4a9 ARM: Rename ARM specific VM_MEMATTR_WT memory attribute to standard one. 2016-01-31 09:16:20 +00:00
Michal Meloun
74767d85c1 ARM: Convert spaces to tabs, fix formatting.
Not a functional change.
2016-01-31 08:53:53 +00:00
Michal Meloun
23c2675f0c ARM: Next round of cleanup in swtch-v*.S.
- remove now useless #if __ARM_ARCH conditional
 - use macro for accessing CP15 registers
 - remove unused PCPU_SIZE

Pointed by: kib
2016-01-31 08:06:22 +00:00
Michal Meloun
eefa6312dd ARM: Remove TLB IPI.
We don't support SMP on ARMv6. All ARMv7 multicore cpus already uses
hardware broadcast for TLB and cache operations.
2016-01-30 13:11:13 +00:00
Michal Meloun
3753ce3c75 ARM: Cleanup mp_machdep.c. SMP is supported only on ARMv6 and later. 2016-01-30 12:23:28 +00:00
Michal Meloun
4ac8a40011 ARM: Don't misuse ARM_TP_ADDRESS as ARMv4 / ARMv6 selector. 2016-01-30 10:10:29 +00:00
Michal Meloun
46c901268a ARM: Split swtch.S into common, ARMv4 and ARMv6 parts. Cleanup them. 2016-01-30 08:02:12 +00:00
Svatopluk Kraus
37b8426b33 Retire pmap_pte_init_mmu_v6() which was used by old pmap-v6. 2016-01-29 17:43:03 +00:00
Svatopluk Kraus
1fc390d1a1 Remove NPTEPG definition which is not used anywhere now after
introduction of new pmap dump interface (r294722). And do not
expose pt_entry_t type.
2016-01-29 16:42:03 +00:00
Svatopluk Kraus
480f7464c1 Use kernel_pmap directly instead of pmap_kernel(). The kernel_pmap is
already used for __ARM_ARCH >= 6 and so even for __ARM_ARCH < 6 on some
common places.
2016-01-29 16:01:37 +00:00
Michal Meloun
4f7da057cb ARM: After removal of old pmap-v6 code, rename pmap-v6-new.c to pmap-v6.c. 2016-01-29 11:00:33 +00:00
Michal Meloun
41a7c569b0 ARM: remove old pmap-v6 code. The new pmap-v6 is mature enough, and
dual implementation is showstopper for major cleanup.

This patch only removes old code from tree. Cleanups will follow asap.
2016-01-29 10:31:54 +00:00
Michal Meloun
cdf4ec6873 EHCI: Make core reset and port speed reading more generic.
Use driver settable callbacks for handling of:
- core post reset
- reading actual port speed

Typically, OTG enabled EHCI cores wants setting of USBMODE register,
but this register is not defined in EHCI specification and different
cores can have it on different offset.

Also, for cores with TT extension, actual port speed must be determinable.
But again, EHCI specification not covers this so this patch provides
function for two most common variant of speed bits layout.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D5088
2016-01-28 14:11:59 +00:00
Zbigniew Bodek
60ba692c78 SMP support for ARMv6/v7 HW watchpoints
Use per-CPU structure to store HW watchpoints registers state
for each CPU present in the system. Those registers will be restored
upon wake up from the STOP state if requested by the debug_monitor
code. The method is similar to the one introduced to AMD64.

We store all possible 16 registers for HW watchpoints
(maximum allowed by the architecture).
HW breakpoints are not maintained since they are used for single
stepping only.

Pointed out by: kib
Reviewed by:    wma
No strong objections from: kib
Submitted by:   Zbigniew Bodek <zbb@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4338
2016-01-28 12:43:58 +00:00
John Baldwin
aa949be551 Convert ss_sp in stack_t and sigstack to void *.
POSIX requires these members to be of type void * rather than the
char * inherited from 4BSD.  NetBSD and OpenBSD both changed their
fields to void * back in 1998.  No new build failures were reported
via an exp-run.

PR:		206503 (exp-run)
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D5092
2016-01-27 17:55:01 +00:00
Justin Hibbits
2dd1bdf183 Convert rman to use rman_res_t instead of u_long
Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources.  For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075
2016-01-27 02:23:54 +00:00
Svatopluk Kraus
b78e1f8a46 Make pmap_fault() return values vm subsystem compliant to
simplify their handling in abort_handler(). While here,
remove one extra initialization of pcb variable.
2016-01-26 13:50:44 +00:00
Svatopluk Kraus
267e03a45d Don't do icache sync on kernel memory and keep in line with comment
in elf_cpu_load_file(). The only time when the sync is needed is after
kernel module is loaded and the relocation info is processed. And it's
done in elf_cpu_load_file().
2016-01-26 10:24:18 +00:00
Svatopluk Kraus
24152caa00 Make code more compact and readable better in pmap_extract()
like functions. No functional change.

This is a follow up to r294722.

Suggested by:	kib
2016-01-26 09:50:23 +00:00
Andrew Turner
1e7b9e9e68 Allow us to be told about memory past the first 4GB point, but ignore it.
This allows, for example, UEFI pass a memory map with some ram in this
region, but for us to ignore it. This is the case when running under the
qemu virt machine type.

Sponsored by:	ABT Systems Ltd
2016-01-25 23:04:40 +00:00
Zbigniew Bodek
595f8a5905 Introduce support for HW watchpoints and single stepping for ARMv6/v7
Allows for using hardware watchpoints for 1, 2, 4, 8 byte long addresses.
The default configuration of watchpoint is RW but code allows to select
RO or WO and X.
Since debugging registers are per-CPU (CP14) the watchpoint is set on
the CPU that was lucky (or not) to enter DDB.

HW breakpoints are used to perform single step in KDB.
When HW breakpoint is enabled all watchpoints are temporary disabled
to avoid recursive abort on both watchpoint and breakpoint.
In case of branch, the breakpoint is set to both - next instruction
and possible branch address. This requires at least 2 breakpoints
supported in the CPU however this is a must for ARMv6/v7 CPUs.

Reviewed by:   imp
Submitted by:  Zbigniew Bodek <zbb@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4037
2016-01-25 18:02:28 +00:00
Svatopluk Kraus
d36f48ddc2 Fix an occasional undefined instruction abort during module loading.
Even if data cache maintenance was done by IO code, the relocation
fixup process creates dirty cache entries that we must write back
before doing icache sync.

Reported by:	Thiagarajan Venkatasubramanian <tvenkata at juniper.net>
Reviewed by:	ian
2016-01-25 14:09:35 +00:00
Svatopluk Kraus
a9dc686c9a Do not use blk_write_cont() and remove it. There si no need to call
blk_flush() between two writes by physical address when these are
PAGE_SIZE aligned.

Fix some style nits.
2016-01-25 12:55:24 +00:00
Svatopluk Kraus
768f645256 Make minidump more like its i386 original back as with new pmap dump
interface all used physical addresses are PAGE_SIZE aligned.
Add missing copyright.

This is a follow up to r294722.
2016-01-25 12:49:08 +00:00
Svatopluk Kraus
971962e4d9 Create new pmap dump interface for minidump and use it for existing
pmap implementations on ARM. This way minidump code can be used without
any platform specific modification.

Also, this is the last piece missing for ARM_NEW_PMAP.

Differential Revision:	https://reviews.freebsd.org/D5023
2016-01-25 12:43:07 +00:00
Andrew Turner
c9a608ac3f Add allwinner_machdep.h, it was missed in r294698. 2016-01-25 08:19:16 +00:00
Andrew Turner
d8b624dcab Update the Allwinner kernels:
* Use the ARM PLATFORM framework
 * Use ARM_INTRNG on teh A20 as it has a GICv2
 * Add a method to find which Allwinner SoC we are running on

Differential Revision:	https://reviews.freebsd.org/D5059
2016-01-25 00:24:57 +00:00
Andrew Turner
b4733230c9 Remove an extra newline that crept in. 2016-01-24 19:12:16 +00:00
Andrew Turner
aea7d91520 Add support for controlling the clocks for the audio codec and DMA engines.
Submitted by:	Jared McNeill <jmcneill@invisible.ca>
Differential Revision:	https://reviews.freebsd.org/D5052
2016-01-24 19:10:30 +00:00
Andrew Turner
654ad322b6 Stop defining fdt_pic_table with ARM_INTRNG, it's unused. 2016-01-22 12:51:12 +00:00
Andrew Turner
026ffbb8ed Remove an extra '!' found by clang 3.8. 2016-01-21 16:42:52 +00:00
Zbigniew Bodek
ec22b42afb Introduce initial driver for PMSU on Armada38x
This is a stub for PMSU driver. Note that it cannot be used to set the
secondary core boot address during attach because drivers are attached
later than SI_SUB_CPU sysinit where cores are started.
Setting the boot address should be done manually in platform_mp_start_ap().

SMP is working fine with this commit and was enabled in Armada38x kernel
configuration file.

Obtained from:	Semihalf
Sponsored by:	Stormshield
Submitted by:	Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4427
2016-01-20 14:49:16 +00:00
Zbigniew Bodek
00ad2ec864 Add initial support for SMP on Armada38x
- Add file sys/arm/mv/armada38x/armada38x_mp.c
- Set mp_maxid and mp_ncpus based on FDT unless SCU register indicates
  only one core
- Boot CPU1 in platform_mp_start_ap()
- IPI range defined

Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4426
2016-01-20 14:45:54 +00:00
Zbigniew Bodek
46c9254b05 Open window to bootROM memory on Armada38x to allow CPU1 to boot
CPU1 is halted in bootROM code while it is waiting to be released.
Memory window to bootROM must be opened before booting the core.

Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4425
2016-01-20 14:30:17 +00:00
Zbigniew Bodek
a695f1c97f Support watchdog depending on "mrvl,has-wdt" property
With this commit, watchdog is supported only in case of having
"mrvl,has-wdt" property or dedicated for watchdog compatibility field
("marvell,armada-380-wdt"). There is no need to modify dts files,
as "has-wdt" property already exists.

Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4424
2016-01-20 14:28:05 +00:00
Zbigniew Bodek
786e3fea32 Add support for watchdog on Armada38x
A38X watchdog support was implemented in sys/arm/mv/timer.c driver.
It required following modifications:
- add "marvell,armada-380-wdt" compatibility, which supports only watchdog
- correct and enhance definitions related to timer control register
- unmask reset capability in RSTOUTn_MASK register
- use dedicated watchdog timer on A38X instead of second timer

Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4423
2016-01-20 14:23:57 +00:00
Zbigniew Bodek
a4ee1a8e13 Add support for I2C on Armada38x
Extend driver's compatible strings' table
and enable I2C compilation in kernconf.

Reviewed by:    andrew, ian
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Jan Dabros <jsd@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4422
2016-01-20 14:21:06 +00:00
Zbigniew Bodek
e7a6ec97db Add a new RTC driver for Armada38x
New driver registers RTC as system clock. New RTC resolution is 1 sec.
Settime and gettime functions were implemented.

Reviewed by:    andrew, ian
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Jan Dabros <jsd@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4421
2016-01-20 14:18:49 +00:00
Zbigniew Bodek
e34c3bf23b Correct MV_DDR_CADR_BASE definiton in mvwin.h
SOC_MV_ARMADAXP ifdef was enhanced with SOC_MV_ARMADA38X,
correcting MV_DDR_CADR_BASE definition. It fixes PCIe hangs issue.

Reviewed by:    andrew
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4380
2016-01-20 14:16:13 +00:00
Zbigniew Bodek
0538eb3458 Change DTS entry of PCIe controller for Armada38x
Invalid (in FreeBSD) definition of PCI controller was
replaced with another one, working in FreeBSD environment.

PCI controller's entry had to move from its parent node
so as to be recognized properly by FBSD.

PCI was enabled in kernel configuration file.

Obtained from:	Semihalf
Sponsored by:	Stormshield
Submitted by:	Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4379
2016-01-20 14:14:30 +00:00
Zbigniew Bodek
5afccf3680 Improve definitions of CPU/PCIe windows for Armada38x
Enhance existing ARMADAXP defines and introduce new MV_WIN_PCIE_
definitions.

Reviewed by:    andrew
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4378
2016-01-20 14:10:00 +00:00
Zbigniew Bodek
1e92574faa Fix invalid root link detection in mv_pci driver
mv_pci driver omitted slot 0, which can be valid device on Armada38x.
New mechanism detects if device is root link, basing on vendor's
and device's IDs.
It is restricted to Armada38x; on other machines, behaviour remains
the same.

Reviewed by:    andrew
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4377
2016-01-20 14:05:21 +00:00
Zbigniew Bodek
515af5ce4e Enhance remap capabilities for Armada38x
Add conditions corresponding to Armada38x-based SoCs,
enhancing their remap capabilities.
This is required for PCIe to work properly.

Reviewed by:    andrew
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4376
2016-01-20 14:02:36 +00:00
Zbigniew Bodek
f4c36f2b60 Enable USB in kernconf of Armada38x
With this commit, USB 2.0 works fine on Armada38x platforms.

Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4375
2016-01-20 14:00:32 +00:00
Zbigniew Bodek
223e0cfd9a Enable SCU unit for Armada38x
Valid SCU operation is necessary for SMP interoperability.
Initialization function armada38x_enable_scu() was added.

Reviewed by:    andrew, ian
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4220
2016-01-20 13:55:51 +00:00
Zbigniew Bodek
5b683b6fc5 Set IO Sync Barrier flags for all Mbus devices on Armada38x
IO Sync Barrier setting is required for I/O coherency.

Reviewed by:   andrew, ian, imp
Obtained from: Semihalf
Sponsored by:  Stormshield
Submitted by:  Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4219
2016-01-20 13:53:33 +00:00
Zbigniew Bodek
90c1c677af Fix GIC FDT interrupts decoding
Interrupt type in FDT was interpreted incorrectly.
Patch taken from freebsd-arm thread 'GIC - interrupts interpretation in
DTS/FDT':
https://lists.freebsd.org/pipermail/freebsd-arm/2015-August/012145.html

Reviewed by:    ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4215
2016-01-20 13:45:35 +00:00
Zbigniew Bodek
81c8a263d6 Use GIC-specific decoding function in mv_common.c
Add gic_decode_fdt function to fdt_pic_table, allowing to recognize GIC
interrupts on Armada38x. SOC_MV_ARMADA38X ifdef is required because A38X
is the only Marvell's platform in FreeBSD using GIC; lack of ifdef would
lead to linking errors on other platforms.

Reviewed by:    andrew, ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4214
2016-01-20 13:42:54 +00:00
Zbigniew Bodek
b2ea73e3bb Do not require strict compatibility on simplebus
Strict compatibility requirement is a root of problems when simplebus'
node has two compatibility strings (i.e. on Armada38x). Removing this
requirement should not interfere with other platforms.

fdt_is_compatible_strict() and fdt_find_compatible() calls were changed
in fdt_common.c and mv_common.c.

Reviewed by:    ian, imp
Obtained from:	Semihalf
Sponsored by:	Stormshield
Submitted by:	Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4602
2016-01-20 13:35:06 +00:00
Zbigniew Bodek
f8742b0da3 Introduce initial support for Marvell Armada38x
This commit introduces initial support for Marvell Armada38x platform.
Changes:
- Add common DTS files for Armada38x SoCs and DTS file for A388-GP
- Add ARMADA38X kernel configuration
- Add option SOC_MV_ARMADA38X and set MV_PCI_PORTS
- Add list of files to compile
- Implement get_tclk(), get_sar_value(), cpu_reset() functions
- Add CPU ID and SoC numbers
- Correct ifdefs in arm/mv/timer.c

Reviewed by:    ian, imp
Obtained from:  Semihalf
Sponsored by:   Stormshield
Submitted by:   Michal Stanek <mst@semihalf.com>
Differential revision:  https://reviews.freebsd.org/D4210
2016-01-20 13:14:36 +00:00
Zbigniew Bodek
fa85e32f0c Mark gpio as "optional" in files.mv and edit Marvell's kernconfs
Including arm/mv/gpio.c now depends on 'gpio' device. 'device gpio' was
added to all kernconf files of Marvell boards, except ARMADAXP (dummy
mv_gpio_res definition was removed) and ARMADA38X (not supported yet).

This commit allows to use generic files.mv on A38X.

Reviewed by:    andrew
Obtained from:	Semihalf
Sponsored by:	Stormshield
Submitted by:	Bartosz Szczepanek <bsz@semihalf.com>
Differential revision:	https://reviews.freebsd.org/D4372
2016-01-20 11:57:11 +00:00
Andrew Turner
0cd387161a Add extra checks to make sure the size is valid. We may get an integer
underflow when we have small blocks of memory at the start and end of the
32-bit address range.

While here, only insert mappings pointing at a non-zero amount of memory.

Sponsored by:	ABT Systems Ltd
2016-01-18 00:07:04 +00:00
Justin Hibbits
02630b085c Quick exit after setting the clock control register.
Discussed with:	ian
2016-01-17 23:03:21 +00:00
Andrew Turner
2aa4a62da3 Use __ARM_ARCH to decide when ARM_TP_ADDRESS needs to be set. This fixes
an issue with clang 3.8.0 where none of the __ARM_ARCH_*__ macros were
defined on some ARMv6 kernel configs.

Sponsored by:	ABT Systems Ltd
2016-01-16 10:12:50 +00:00
Warner Losh
8046b4f5b5 We don't need at91_bs_tag. arm_base_bs_tag works now that we have
better dynamic device mapping that didn't exit when we started this
port. Remove it, since everything works w/o it.
2016-01-16 05:47:34 +00:00
Warner Losh
64535e84f6 Move ohci files to their proper place in the tree for atmel.
Fix when it is included (we don't have a at91rm9200 device).
From a similar patch in the PR, with tweaked names.

PR: 206229
2016-01-16 04:47:32 +00:00
Svatopluk Kraus
effb4b3c8c Add mmu format info into ARM vmcore.
Fix kvatop translation for 64K pages.

Reviewed by:	jhb
Approved by:	kib (mentor)
Differential Revision:    https://reviews.freebsd.org/D4942
2016-01-15 18:53:06 +00:00
Ian Lepore
765b890b92 Reduce diffs to upstream by adding a couple comment blocks and moving the
parse_boot_param() function to the end of the file.
2016-01-15 18:27:34 +00:00
Andrew Turner
ed5c72c308 Remove the commented out sc device from the i.MX kernels, they both use
vt(4).
2016-01-15 11:40:41 +00:00
Ian Lepore
750e48d766 Fix the handling of the "PDC write transfer length" erratum for at91. The
problem affects revision 1xx hardware as well as later versions.  Also, the
recommended workaround is to set the PDC count register for a 12-byte
transfer when the actual size is less than that, but there is no need to
extend or zero-out the data buffer, because the blklen register contains
the real transfer size and only that many bytes will be transferred.

Also add a sysctl to turn debugging printfs on or off on the fly.
2016-01-14 19:33:13 +00:00
Ian Lepore
739e2464e9 Fix the spelling of fueword* to eliminate compile warnings about mismatched
begin/end symbols when the warning level is turned up.

Submitted by:	Steve Kiernan <stevek@juniper.net>
2016-01-13 14:39:39 +00:00
Svatopluk Kraus
339d7dad7a Fix local macro for early KVA allocation.
Only crashdumpmap allocation was affected which is used for temporary
mappings during panic dump.

Approved by:	kib (mentor)
2016-01-12 15:31:32 +00:00
Dmitry Chagin
038c720553 Implement vsyscall hack. Prior to 2.13 glibc uses vsyscall
instead of vdso. An upcoming linux_base-c6 needs it.

Differential Revision:  https://reviews.freebsd.org/D1090

Reviewed by:	kib, trasz
MFC after:	1 week
2016-01-09 20:18:53 +00:00
Svatopluk Kraus
514ba65500 Print curpmap in "show pcpu" command.
Approved by:	kib (mentor)
2016-01-07 12:31:49 +00:00
Ian Lepore
7aa9d7375e Store the pointer to the bootloader-provided env data in a static var
for use in debug printing.
2016-01-03 14:42:28 +00:00
Ian Lepore
9df1d85ebb Reword the comment to better describe what I found while researching the
problem that led to this temporary workaround (and also so I can properly
cite the PR in the commit this time).

In general this is intended to be a temporary workaround until we can figure
out why including any ram from the last megabyte of the physical address
space leads to a NULL pointer deref.  Debugging that is made trickier by the
fact that I couldn't even get a backtrace in ddb.

PR:		201614
2016-01-02 23:14:52 +00:00
Ian Lepore
95181ed7ff Work around problems that happen when there is ram at the end of the
physical address space.
2016-01-02 22:31:14 +00:00
Ian Lepore
e376ad23c2 Use 64-bit math when processing the lists of physical and excluded memory
to generate the phys_avail and dump_avail arrays.

This is a partial fix for the kernel side of the problem mentioned in the
PR.  This part handles the cases where comparing start and end addresses of
a block would fail because 32-bit wrap caused the end address to come out
zero if the end of the region is the end of the address space (0xffffffff
with 32-bit vm_paddr_t, but now the code should also work right if we ever
support LPAE with 36-bit addresses).

More work is necessary to make systems with ram at the end of the physical
address space usable, but at least initially it's going to be more like a
workaround than a fix, so this non-hacky part is being committed first.

PR:		201614
2016-01-02 22:00:52 +00:00
Ian Lepore
69dcb7e771 Make the 'env' directive described in config(5) work on all architectures,
providing compiled-in static environment data that is used instead of any
data passed in from a boot loader.

Previously 'env' worked only on i386 and arm xscale systems, because it
required the MD startup code to examine the global envmode variable and
decide whether to use static_env or an environment obtained from the boot
loader, and set the global kern_envp accordingly.  Most startup code wasn't
doing so.  Making things even more complex, some mips startup code uses an
alternate scheme that involves calling init_static_kenv() to pass an empty
buffer and its size, then uses a series of kern_setenv() calls to populate
that buffer.

Now all MD startup code calls init_static_kenv(), and that routine provides
a single point where envmode is checked and the decision is made whether to
use the compiled-in static_kenv or the values provided by the MD code.

The routine also continues to serve its original purpose for mips; if a
non-zero buffer size is passed the routine installs the empty buffer ready
to accept kern_setenv() values.  Now if the size is zero, the provided buffer
full of existing env data is installed.  A NULL pointer can be passed if the
boot loader provides no env data; this allows the static env to be installed
if envmode is set to do so.

Most of the work here is a near-mechanical change to call the init function
instead of directly setting kern_envp.  A notable exception is in xen/pv.c;
that code was originally installing a buffer full of preformatted env data
along with its non-zero size (like mips code does), which would have allowed
kern_setenv() calls to wipe out the preformatted data.  Now it passes a zero
for the size so that the buffer of data it installs is treated as
non-writeable.
2016-01-02 02:53:48 +00:00
Ian Lepore
4d43e76fb2 Bring some of the recent locore-v4.S improvements into locore-V6...
- Map all 4GB as VA=PA so that args passed in from a bootloader can
   be accessed regardless of where they are.
 - Figure out the kernel load address by directly masking the PC rather
   then by doing pc-relative math on the _start symbol.
 - For EARLY_PRINTF support, map device memory as uncacheable (no-op for
   ARM_NEW_PMAP because all TEX types resolve to uncacheable).
2015-12-29 22:18:35 +00:00
Kevin Lo
ddb1359877 Fix typo (s/harware/hardware/) 2015-12-25 14:51:36 +00:00
Andrew Turner
7c570e8bb1 Remove the arm KERNPHYSADDR option as it is no longer used. The make
option is still in existance as it is used to build the trampoline code.
2015-12-22 09:08:21 +00:00
Oleksandr Tymoshenko
dfbf5e4bbf Add i.MX 6 IPU driver and enable it in IMX6 config
Current functionality is somewhat limited: driver assumes that there
is only one active IPU unit (IPU1) and that video output is DI0 and
video mode is 1024x768. For more advanced functionality driver requires
proper clock management which is work in progress. At the moment driver
assumes that pixel clock is configured by u-boot for 1026x768 mode.

Reviewed by:	andrew, ian, mmel
Differential Revision:	https://reviews.freebsd.org/D4168
2015-12-21 22:25:35 +00:00
Oleksandr Tymoshenko
a0becfc978 - Add driver for i.MX 6 HDMI framer
- Enable HDMI driver in IMX6 config

Reviewed by:	andrew, ian, mmel
Differential Revision:	https://reviews.freebsd.org/D4174
2015-12-21 21:40:15 +00:00
Oleksandr Tymoshenko
c0f3a6c2bb Add CCM functions to enable HDMI framer and IPU units (video controller)
Reviewed by:	andrew, ian
Differential Revision:	https://reviews.freebsd.org/D4168
2015-12-21 20:17:24 +00:00
Warner Losh
e581fd9e95 Configure the Atmel eval boards to boot the same way. This gives
them the same layout as other embedded systems.
2015-12-21 18:27:51 +00:00
Ian Lepore
bc7b930020 Implement OF_decode_addr() for arm. Move most of powerpc's implementation
into a new function that other platforms can share.

This creates a new ofw_reg_to_paddr() function (in a new ofw_subr.c file)
that contains most of the existing ppc implementation, mostly unchanged.
The ppc code now calls the new MI code from the MD code, then creates a
ppc-specific bus_space mapping from the results. The new arm implementation
does the same in an arm-specific way.

This also moves the declaration of OF_decode_addr() from ofw_machdep.h to
openfirm.h, except on sparc64 which uses a different function signature.

This will help all FDT platforms to set up early console access using
OF_decode_addr().
2015-12-21 18:07:32 +00:00
Ian Lepore
38b65fa05c Replace some references to KERNPHYSADDR with the equivelent value passed in
from the bootloader.
2015-12-21 01:14:54 +00:00
Ian Lepore
bfb14e93a2 Change KERNVIRTADDR to 0xc0000000 since the low-order bits no longer need to
match the physical load address.  Remove the *PHYSADDR symbols which are no
longer necessary.

Also remove a bunch of comments, most of which which have been wrong for
quite some time now, and the rest of which are mooted by these changes.  All
that's left in this file is assigning a single symbol to its cannonical
value, not much to comment on anymore.
2015-12-20 23:38:14 +00:00
Ian Lepore
6a6d0fff18 Allow armv4/5 kernels to be loaded on any 2MB boundary, like armv6/7.
This eliminates the reliance on PHYSADDR and KERNPHYSADDR compile-time
symbols (except when the rom-copy code is enabled) by using the current
PC and the assumption that the entry-point routine is in the first 1MB
section of the text segment.

Other cleanups done:

 - Reduce the initarm() stack size back to 2K.  It got increased to
   4 * 2K when this file was supporting multicore armv6, but that
   support is now in locore-v6.S.

 - When building the temporary startup page tables, map the entire
   4GB address space as VA=PA before mapping the kernel at its loaded
   location.  This allows access to boot parameters stored somewhere
   in ram by the bootloader, regardless of where that may be.

 - When building the page table entry for supporting EARLY_PRINTF, map
   the section as uncached unbuffered, since it is presumably device
   registers.

Note that this restores the ability to use loader(8)/ubldr on armv4/5
kernels.  That was broken in r283035, the point at which ubldr started
loading an arm kernel at any 2MB boundary.

Also note that after this, there is no reason to set KERNVIRTADDR to
anything other than 0xc0000000, and no need for PHYSADDR or KERNPHYSADDR
symbols at all.
2015-12-20 23:31:11 +00:00
Oleksandr Tymoshenko
25a2de5e7e Add dev.fb.X.resync sysctl to resync ARM framebuffer with VideoCore
Some applications (e.g. Kodi) use tvservice APIs to manage HDMI
modes, power state, EDID etc. directly through VideoCore. After
these manipulations VideoCore may loose its state and needs to be
resynced with ARM. Under Linux this problem is worked around using
fbset utility that recreates framebuffer. Since there is no fbset
utility in FreeBSD we provide sysctl for userland apps to get system
back into normal mode.
2015-12-20 00:58:22 +00:00
Adrian Chadd
2b3ad18853 [intrng] Migrate the intrng code from sys/arm/arm to sys/kern/subr_intr.c.
The ci20 port (by kan@) is going to reuse almost all of the intrng code
since the SoC in question looks suspiciously like someone took an ARM
SoC design and replaced the ARM core with a MIPS core.

* migrate out the code;
* rename ARM_ -> INTR_;
* rename arm_ -> intr_;
* move the interrupt flush routine from intr.c / intrng.c into
  arm/machdep_intr.c - removing the code duplication and removing
  the ARM specific bits from here.

Thanks to the Star Wars: The Force Awakens premiere line for allowing
me a couple hours of quiet time to finish the universe builds.

Tested:

* make universe

TODO:

* The structure definitions in subr_intr.c still includes machine/intr.h
  which requires one duplicates all of the intrng definitions in
  the platform code (which kan has done, and I think we don't have to.)

  Instead I should break out the generic things (function declarations,
  common intr structures, etc) into a separate header.

* Kan has requested I make the PIC based IPI stuff optional.
2015-12-18 05:43:59 +00:00
Warner Losh
31c9adb789 Create a simplebus PNP info wrapper.
Differential Review: https://reviews.freebsd.org/D4517
2015-12-18 05:29:22 +00:00
Ian Lepore
db9431acb3 Fix the clock divisor calc for imx6 sdcard bus speed.
I don't know what alternate universe I was inhabiting when I wrote it
originally, but apparently the basic workings of mathematics were different
than in this universe.  I also can't explain how it ever worked, except "by
accident", because completely bogus values were being written into the
divisor register.
2015-12-18 01:25:30 +00:00
Svatopluk Kraus
4729bd79cb Adopt assert from amd64 in pmap_remove_pages().
Suggested by:	kib
Approved by:	kib (mentor)
2015-12-16 10:55:19 +00:00
Svatopluk Kraus
b500ef0907 Local TLB flush is sufficient in pmap_remove_pages().
(1) The pmap argument passed to the function must be current pmap only.
(2) The process must be single threaded as the function is called either
when a process is exiting or from exec_new_vmspace().

Remove pmap_tlb_flush_ng() which is not used anywhere now.

Approved by:	kib (mentor)
2015-12-15 16:04:45 +00:00
Svatopluk Kraus
28dff94844 Replace all postponed TLB flushes by immediate ones except the one
in pmap_remove_pages().

Some points were considered:
(1) There is no range TLB flush cp15 function.
(2) There is no target selection for hardware TLB flush broadcasting.
(3) Some memory ranges could be mapped sparsely.
(4) Some memory ranges could be quite large.

Tested by buildworld on RPi2 and Jetson TK1, i.e. 4 core platforms.
It turned out that the buildworld time is faster. On the other hand,
when the postponed TLB flush was also removed from pmap_remove_pages(),
the result was worse. But pmap_remove_pages() is called for removing
all user mapping from a process, thus it's quite expected.

Note that the postponed TLB flushes came here from i386 pmap where
hardware TLB flush broadcasting is not available.

Approved by:	kib (mentor)
2015-12-15 15:22:33 +00:00
Svatopluk Kraus
acf4dc71d6 Flush intermediate TLB cache when L2 page table is unlinked.
This fixes an issue observed on Cortex A7 (RPi2) and on Cortex A15
(Jetson TK1) causing various memory corruptions. It turned out that
even L2 page table with no valid mapping might be a subject of such
caching.

Note that not all platforms have intermediate TLB caching implemented.
An open question is if this fix is sufficient for all platforms with
this feature.

Approved by:	kib (mentor)
2015-12-15 13:17:40 +00:00
Michal Meloun
ae47b5ecd3 ARM: Remove outdated katelib.h.
Approved by:	kib (mentor)
2015-12-15 12:52:45 +00:00
Michal Meloun
a6bd1732a4 ARM: option PPC_PROBE_CHIPSET is applicable only for x86. Don't enable it
for ARM LINT config.

Approved by:	kib (mentor)
2015-12-15 12:51:58 +00:00
Ian Lepore
3f62727443 Move the DRIVER_MODULE() statements that declare mmc(4) to be a child of
the various bridge drivers out of dev/mmc.c and into the bridge drivers.

Requested by:	   jhb (almost two years ago; better late than never)
2015-12-14 01:09:25 +00:00
Mark Johnston
711fbd17ec Add helper functions proc_readmem() and proc_writemem().
These helper functions can be used to read in or write a buffer from or to
an arbitrary process' address space. Without them, this can only be done
using proc_rwmem(), which requires the caller to fill out a uio. This is
onerous and results in code duplication; the new functions provide a simpler
interface which is sufficient for most existing callers of proc_rwmem().

This change also adds a manual page for proc_rwmem() and the new functions.

Reviewed by:	jhb, kib
Differential Revision:	https://reviews.freebsd.org/D4245
2015-12-07 21:33:15 +00:00
Konstantin Belousov
4d22d07a07 Add support for usermode (vdso-like) gettimeofday(2) and
clock_gettime(2) on ARMv7 and ARMv8 systems which have architectural
generic timer hardware. It is similar how the RDTSC timer is used in
userspace on x86.

Fix a permission problem where generic timer access from EL0 (or
userspace on v7) was not properly initialized on APs.

For ARMv7, mark the stack non-executable. The shared page is added for
all arms (including ARMv8 64bit), and the signal trampoline code is
moved to the page.

Reviewed by:	andrew
Discussed with:	emaste, mmel
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D4209
2015-12-07 12:20:26 +00:00
Andrew Turner
c218815337 Move the check to see if we are tracing a function with the DTrace Function
Boundary Trace to assembly to reduce the overhead of these checks.

Submitted by:	Howard Su <howard0su@gmail.com>
Relnotes:	Yes
Differential Revision:	https://reviews.freebsd.org/D4266
2015-12-05 09:32:36 +00:00
Ganbold Tsagaankhuu
f4459b9645 Add glue driver for Amlogic Meson Gigabit Ethernet Controller
and enable it for Odroid C1 board.
Together with r291676 change, dwc(4) can receive packets now.
2015-12-03 09:37:20 +00:00
Michal Meloun
23a4fe48f9 ARM: Define PCI_RES_BUS resource for platforms having NEW_PCIB enabled.
Approved by:	kib (mentor)
2015-12-02 14:24:14 +00:00
Michal Meloun
ab1910e8af ARM: Fix of detection of root interrupt controller.
This fixes detection of root interrupt controller for cases,
when interrupt parent is not defined at all or it's not defined directly
in controller node.

Approved by:	kib (mentor)
2015-12-02 14:22:58 +00:00
Michal Meloun
e53ea2ab77 ARM: create new memory attribute for writethrough cacheable memory.
- add new TEX class for WT cacheable memory
- export new TEX class to kernel as VM_MEMATTR_WT attribute
- add new aliases VM_MEMATTR_WRITE_COMBINING and
  VM_MEMATTR_WRITE_BACK, it's used in DRM code

Note:
 Only Cortex A8 supports WT caching in HW. On rest of Cortex CPUs,
 WT requests is treated as uncacheable.

Approved by:	kib (mentor)
2015-11-30 17:09:25 +00:00
Michal Meloun
1eb1d41a56 ARM: Implement atomic_swap_int(9). It's used in DRM2 code.
Approved by:	kib (mentor)
2015-11-28 12:12:28 +00:00
Michal Meloun
1d687ba2d1 ARM: Add support for new KRAIT 300 CPU revision.
Approved by:	kib (mentor)
2015-11-28 12:11:44 +00:00
Michal Meloun
20fc8f2bb5 ARM: Cumulative fixes for GIC
- fix detection of interrupt root controller
 - allow (but warn) unsupported configuration bits
 - dont send EOI for spurious interrupts
 - print more informations for spurious interrupts
 - use device_printf() where appropriate

Reviewed by:	ian (earlier version)
Approved by:	kib (mentor)
2015-11-28 12:09:36 +00:00
Konstantin Belousov
724f4b62b0 Remove sv_prepsyscall, sv_sigsize and sv_sigtbl members of the struct
sysent.

sv_prepsyscall is unused.

sv_sigsize and sv_sigtbl translate signal number from the FreeBSD
namespace into the ABI domain.  It is only utilized on i386 for iBCS2
binaries.  The issue with this approach is that signals for iBCS2 were
delivered with the FreeBSD signal frame layout, which does not follow
iBCS2.  The same note is true for any other potential user if
sv_sigtbl.  In other words, if ABI needs signal number translation, it
really needs custom sv_sendsig method instead.

Sponsored by:	The FreeBSD Foundation
2015-11-28 08:49:07 +00:00
Zbigniew Bodek
6a5289b068 Add support for exynos5_ehci in loader
Create new driver which initializes Arndale PHY and calls ehci_init

Reviewed by:   hselasky
Submitted by:  Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4192
2015-11-27 18:22:04 +00:00
Ian Lepore
bd6b2f9bef Rename sysctl node hw.imx6 to hw.imx. Move its definition to imx_machdep.c
so that code shared between imx5 and imx6 can work with OIDs under that node.

Add last_reset_status (integer) and last_reset_reason (string) OIDs that
provide info about the last chip reset (power-on, software reset, watchdog
timeout).
2015-11-26 17:26:52 +00:00
Svatopluk Kraus
b09e6b5c6e Flush all kernel mappings from TLB(s) in time when they are cleared.
Replace tlb_flush_local() by tlb_flush() as even not global mappings
could be fetched to TLB(s) on other cores by speculative table walk.

From OS point of view, it was not a problem as either such mappings
were not used anymore or they were flushed from TLB(s) when reused.
However, from hardware point of view, it was a problem. Not flushed
mappings could be a target for speculative reads or prefetches (which
might be quite aggresive on ARM cores). As speculative read can fill
cacheline, it can cause a real problem, when physical page is reused,
but mapped with different memory attributes.

Anyhow, it's good to have only valid mappings in TLB(s).

Approved by:	kib (mentor)
2015-11-24 13:57:41 +00:00
Andrew Turner
46e3a1113e Use #ifdef to get the file compiling without errors 2015-11-23 18:20:32 +00:00
Andrew Turner
c2c58185e5 Only enable the first interrupt for now, we don't correctly configure or
route interrupts to the needed cpu.

Sponsored by:	ABT Systems Ltd
2015-11-23 17:05:28 +00:00
Svatopluk Kraus
eae22c4430 Revert r291142.
The not quite consistent logic for bounce pages allocation is utilizited
by re(4) interface which can hang now.

Approved by:	kib (mentor)
2015-11-23 11:19:00 +00:00
Mark Johnston
7672ca059a Remove unneeded includes of opt_kdtrace.h.
As of r258541, KDTRACE_HOOKS is defined in opt_global.h, so opt_kdtrace.h
is not needed when defining SDT(9) probes.
2015-11-22 02:01:01 +00:00
Ian Lepore
e0848bbb0c Update the imx5/imx6 cpu_reset() implementation based on a new understanding
of the SRS (software reset) bit in the watchdog control register.  Despite
what the manual seems to imply, this bit DOES trigger an immediate reset, as
opposed to simply flagging the type of reset as software-triggered.
2015-11-21 23:30:47 +00:00
Svatopluk Kraus
6fa7734d6f Fix BUS_DMA_MIN_ALLOC_COMP flag logic. When bus_dmamap_t map is being
created for bus_dma_tag_t tag, bounce pages should be allocated
only if needed.

Before the fix, they were allocated always if BUS_DMA_COULD_BOUNCE flag
was set but BUS_DMA_MIN_ALLOC_COMP not. As bounce pages are never freed,
it could cause memory exhaustion when a lot of such tags together with
their maps were created.

Note that there could be more maps in one tag by current design.
However BUS_DMA_MIN_ALLOC_COMP flag is tag's flag. It's set after
bounce pages are allocated. Thus, they are allocated only for first
tag's map which needs them.

Approved by:	kib (mentor)
2015-11-21 19:55:01 +00:00
Andrew Turner
dd76e27f7a Move hdmi_if.m to files.arm so other kernel configs can use it. 2015-11-21 16:25:03 +00:00
Andrew Turner
ed18006cbf Create device options for the two common ARM timers.
Sponsored by:	ABT Systems Ltd
2015-11-21 16:23:56 +00:00
Andrew Turner
210d6af74d Move more bus_space_* files to be built by files.arm. This leaves the
definition in a file.* file under sys/arm/arm in the few cases we need it
for non-fdt platforms.

Sponsored by:	ABT Systems Ltd
2015-11-21 15:30:08 +00:00
Andrew Turner
19bec15c6f Limit arm_base_bs_tag to ARMv4 and ARMv5, we only used it in one place in
armv6 and that can use fdtbus_bs_tag.
2015-11-21 13:02:34 +00:00
Warner Losh
c192c5d300 Makeoption ARM_LITLE_ENDIAN does nothing. Remove it since it isn't
consistently used. It was a carry over from NetBSD that FreeBSD
doesn't use.
2015-11-20 21:49:46 +00:00
Andrew Turner
805471578e Remove bus_space_asm_generic.S from the per-SoC files.* files, it's already
in files.arm.

Sponsored by:	ABT Systems Ltd
2015-11-20 19:48:32 +00:00
Andrew Turner
09f449399b Remove pl310.c from the SoC std.* files, it's in files.arm
Sponsored by:	ABT Systems Ltd
2015-11-20 16:43:21 +00:00
Andrew Turner
aeef645f92 Stop setting {KERN,}PHYSADDR on armv6, it's unneeded.
Sponsored by:	ABT Systems Ltd
2015-11-20 16:12:22 +00:00
Svatopluk Kraus
3ee1f8b1b7 Add usermode variable to KTR output. Fix style.
Approved by:	kib (mentor)
2015-11-20 09:34:59 +00:00
Svatopluk Kraus
a7d84eda93 Fix style and argument count for KTR.
Approved by:	kib (mentor)
2015-11-20 09:33:22 +00:00
Michal Meloun
bb12cf0137 ARM: Fix dma_dcache_sync() for early allocated memory.
Drivers can request DMA to buffers that are not in memory represented
in the vm page arrays. Because of this, store KVA of already mapped
buffer to synclist and use it in dma_dcache_sync().

Reviewed by:	jah
Approved by:	kib (mentor)
Differential Revision: https://reviews.freebsd.org/D4120
2015-11-18 16:07:01 +00:00
Zbigniew Bodek
676420e8b1 Make PCB structure binary compatible for old and new PMAP on ARM
This structure must be binary compatible regardless of PMAP
version being used. Create reserved section for NEW_PMAP to
make other variables be placed exactly in the same memory
addresses. This fixes kgdb/gdb behavoiur, which uses pcb.h stuctures.
The NEW_PMAP is kernel flag, so it does not propagate to the buildworld,
what makes the tools using pcb.h unable to parse PCB data.

Reviewed by:   mmel, kib
Submitted by:  Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4011
2015-11-17 13:09:51 +00:00
Zbigniew Bodek
166800cd36 Fix buffer overflow in exynos5_ehci
Use proper size of exynos_ehci_softc, not the generic one.

Reviewed by:   andrew
Submitted by:  Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4189
2015-11-17 12:50:45 +00:00
Andrew Turner
f90ec37df0 Make pl310_print_config static, it's not called out of pl310.c
Sponsored by:	ABT Systems Ltd
2015-11-17 11:26:35 +00:00
Oleksandr Tymoshenko
183413c80c Replace magic numbers for CCGRx registers with more descriptive names 2015-11-14 22:46:50 +00:00
Oleksandr Tymoshenko
6f79d9e96c Somewhat improve HDMI event API
- Pass device_t for HDMI framer as an argument for event hook
- Use #define for event values, instead of opaque (and unused) 0
2015-11-14 21:01:35 +00:00
Oleksandr Tymoshenko
ca298cac31 hdmi_if.m will be reused by iMX6 IPU code so move it to arm/arm 2015-11-14 03:22:59 +00:00
Oleksandr Tymoshenko
9c42981925 Move all HDMI-related stuff to hdmi_if.m, hdmi.h is not required 2015-11-14 03:05:42 +00:00
Oleksandr Tymoshenko
83860f69f5 - Add driver for System-Reset-Controler i.MX6 module
- Add API function to reset IPU1
2015-11-13 23:47:41 +00:00
Warner Losh
fe04a9e147 Add support for the Zybo and similar boards to ZEDBOARD kernel.
Zybo needs its own DTB and has a different PHY, so add it to
the base kernel. Details on building bootable SD images at
http://www.thomasskibo.com/zedbsd/

Submitted By: Thomas Skibo
2015-11-13 15:36:40 +00:00
Oleksandr Tymoshenko
acaf20cbde Enable cloks for all USDHC interfaces, previous value was USDHC 1-3 + USBOH3 2015-11-12 21:37:58 +00:00
Gavin Atkinson
24e34f5771 Consistently capitalize "TI" as an abbreviation for Texas Instruments. 2015-11-12 20:14:25 +00:00
Warner Losh
309c88ebab Move the root to s3a given this kernel will be used with a nanobsd
build that defaults there.
2015-11-12 17:46:57 +00:00
Warner Losh
11051df0cb Revisit this old board with 64MB of RAM. Comment out usb entirely,
since it isn't used for my application. Add back the md device since
it's needed for NanoBSD support. Add in many of the small memory
footprint options from the access points.

With these changes we go from having ~8MB to having ~20MB free,
though free + inactive only goes from ~35MB to ~42MB. We can
also boot a nanobsd image mostly (I had to hand tweak what was
built to represent the final goal).

Move the FDT stuff to the top. We're almost ready to pull the trigger
to moving over to FDT, but something in the MCI driver is freaking out
when we do and that needs fixing first.
2015-11-12 00:26:47 +00:00
Oleksandr Tymoshenko
cd3903c620 Refactor bcm2835_cpufreq to use bcm2835_mbox_property API 2015-11-11 00:45:41 +00:00
Oleksandr Tymoshenko
e597fdb889 - Set have_message in interrupt to handle "response before READ" case
- Serialize access to property channel when using bcm2835_mbox_property
2015-11-11 00:41:02 +00:00
Michal Meloun
5fcbe89ac9 ARM: Refactor interrupt_enable/disable/restore.
Allow manipulation with PSR_A bit on ARMv6+.
Remove declaration of unused functions.

This effectively enables asynchronous aborts on early bootstrap stage,
which previously was not enabled due to an error in enable_interrupts().

PR:		201434
Reported by:	Gregory Soutade <soutade at gmail.com>
Approved by:	kib (mentor)
2015-11-10 13:47:28 +00:00
Svatopluk Kraus
aeef015ea1 Fix cp15 PAR definition and function. While here, add cp15 ATS1CPW
function which checks an address for privileged (PL1) write access.
The function is inlined so it does not bring any cost, but makes
function set for checking privileged access complete.

Approved by:	kib (mentor)
2015-11-10 13:20:21 +00:00
Svatopluk Kraus
765b884ede Fix pmap_fault(). It turned out that alignment abort may have higher
priority than both translation and permission ones.

Approved by:	kib (mentor)
2015-11-10 13:15:34 +00:00
Konstantin Belousov
081432a88f Implement atomic_testandset_{32,int,long,64} for ARMv6. Only
little-endian configuration for 64-bit variant is supported.

Reviewed by:	mmel
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4113
2015-11-10 12:15:13 +00:00
Michal Meloun
4dbc00835d ARM: Remove trailing whitespace from sys/arm/include
No functional changes.

Approved by:    kib (mentor)
2015-11-10 12:02:41 +00:00
Michal Meloun
89b4b66950 ARM: Improve robustness of locore_v6.S and fix errors.
- boot page table is not allocated in data section, so must be
  cleared before use
- map only one section (1 MB) for SOCDEV mapping (*)
- DSB must be used for ensuring of finishing TLB operations
- Invalidate BTB when appropriate

PR:		198360
Reported by:	Daisuke Aoyama <aoyama at peach.ne.jp> (*)
Approved by:	kib (mentor)
2015-11-10 11:45:41 +00:00
Tijl Coosemans
ad3c3dbe18 Fix typo (s/ncpus/mp_ncpus/)
Reported by:	bz
2015-11-09 22:12:29 +00:00
Bjoern A. Zeeb
eeaf6acbfd Now that the PMU implementation is independent of HWPMC
as of r288992 use it to manage the CCNT.

Use the CNNT for get_cyclecount() instead of binuptime() when device pmu
is compiled in; if it fails to attach, fall back to the former method.

Enable by default for the BeagleBoneBlack configuration.

Optained from:		Cambridge/L41
Sponsored by:		DARPA/AFRL
Reviewed by:		andrew
Differential Revision:	https://reviews.freebsd.org/D3837
2015-11-09 17:57:32 +00:00
Tijl Coosemans
27f38a8d69 Since r289279 bufinit() uses mp_ncpus, but some architectures set this
variable during mp_start() which is too late.  Move this to mp_setmaxid()
where other architectures set it and move x86 assertions to MI code.

Reviewed by:	kib (x86 part)
2015-11-08 14:26:50 +00:00
Svatopluk Kraus
bee75f52d1 Make usermode variable the bool type. It's already used that way.
Suggested by:	kib
Approved by:	kib (mentor)
2015-11-08 08:31:34 +00:00
Oleksandr Tymoshenko
ebb62474ab Fix some of WITNESS complaints and bootup lock by removing msg_avail
condvar/mutex. They're basically no-op because error is not propagated
up the call chain. We still report message failures in VC service callback
2015-11-08 04:15:52 +00:00
Oleksandr Tymoshenko
b805a8c3eb - Replace semaphore-base locking with sleep/wait synchronization:
sema_trywait/sema_timedwait can't be used while holding
    non-sleepable mutex

- Fix infinite loop if response from VideoCore never received
2015-11-08 03:34:19 +00:00
Warner Losh
971c23c9a0 Correct !FDT case with proper name. 2015-11-07 22:58:56 +00:00
Warner Losh
7535619977 Implement the phy-mode property for ate and macb. If it is set to
"rmii", use rmii mode for the MAC, otherwise use MII mode. The code is
somewhat duplicated between these drivers for this.

Also, add AT91RM9200 compatibility strings to the ate driver. In the
future, there's a good chance that ate will lose the MACB support and
only attach to the AT91RM9200 EMAC device since the macb works now
that RMII support has been added to it.
2015-11-07 22:52:06 +00:00
Warner Losh
56ea9c7b08 Add support for RMII in macb, cribbed slightly from the ate
driver. This is taken from the MAC at boot, but can be overridden with
'options AT91_MACB_USE_RMII'.

Switch to macb for HL201 and SAM9G20EK boards. It now works both
places. Also start to sneak up on FDT for the SAM9G20EK board, but
leave disabled due to issues with MMC that haven't been resolved.
Add early debug support for the SAM9G20EK since that is required
for FDT to work presently on these SoC.
2015-11-07 20:02:07 +00:00
Svatopluk Kraus
9a54871fd8 Set correct code for signal in abort_align() routine.
Remove superfluous printf() and both unnecessary and obsolete comments.

Approved by:	kib (mentor)
2015-11-06 23:17:00 +00:00
Olivier Houchard
b34e5f2e07 Include opt_platform.h to get FDT defined. 2015-11-06 20:12:31 +00:00
Svatopluk Kraus
3084b64cd9 Make interrupt dispatching MP safe. Use GPU interrupt bit in per-core
interrupt status register to process shared interrupts only if the bit
is active and only on core to which they are routed.

Reviewed by:	imp, loos
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D3723
2015-11-06 17:12:33 +00:00
Olivier Houchard
c973c8b228 Make if_macb work with FDT. 2015-11-05 22:03:42 +00:00
Olivier Houchard
a3f8e2c7fc Make at91_pmc probe any at91 pmc device we support, not just at91rm9200.
MFC after:	1 week
2015-11-05 22:03:20 +00:00
Oleksandr Tymoshenko
f4f73431bc Add /dev/vcio, userland access point to VideoCore mailbox property channel
It's required by some applications in raspberrypi-userland package
2015-11-05 04:16:03 +00:00
Oleksandr Tymoshenko
8826550b5a Refactor mailbox property API to make it usable for /dev/vcio driver:
- Add bcm2835_mbox_property for generic property request, it accepts
    pointer to prepared property chan message and its size, forwards
    it to MBOX and copies result back
- Make all bcm2835_mbox_XXX functions that use property channel go
    through bcm2835_mbox_property path. Do not accept device_t as
    an argument, it's not required: all DMA operatiosn should go
    through mbox device, and all API consumers should report errors
    on their side.
2015-11-05 03:46:54 +00:00
Svatopluk Kraus
36fb9d5fc8 Fix comment about unpriviledged instructions. Now, it matches with
current state after r289372.

While here, do some style and comment cleanups.  No functional changes.

Approved by:	kib (mentor)
2015-11-04 15:35:22 +00:00
Oleksandr Tymoshenko
23e00b90da Revert r290243, it's vaid "illegal instruction" case
DEX bit is set to 1 and exception raised whenever vectorized operation is
attempted on the VFP implementation that does not support it (i.e. on Cortex A7)
2015-11-04 04:01:59 +00:00
Ian Lepore
0c1daec859 Eliminate the last dregs of the old global arm_root_dma_tag.
In the old days, device drivers passed NULL for the parent tag when creating
a new tag, and on arm platforms that resulted in a global tag representing
overall platform constraints being substituted in the busdma code.  Now all
drivers use bus_get_dma_tag() and if there is a need to represent overall
platform constraints they will be inherited from a tag supplied by nexus or
some bus driver in the hierarchy.

The only arm platforms still relying on the old global-tag scheme were some
xscale boards with special PCI-bus constraints.  This change provides those
constraints through a tag supplied by the xscale PCI bus driver, and
eliminates the few remaining references to the old global var.

Reviewed by:	cognet
2015-11-02 22:49:39 +00:00
Zbigniew Bodek
232e189a56 Add support for branch instruction on armv7 with ptrace single step
Previous code supported only "continuous" code without any kind of
branch instructions. To change that, new function was implemented
which parses current instruction and returns an addres where
the jump might happen (alternative addr).
mdthread structure was extended to support two breakpoints
(one directly below current instruction and the second placed
at the alternative location).
One of them must trigger regardless the instruction has or has not been
executed due to condition field.
Upon cleanup, both software breakpoints are removed.

This implementation parses only the most common instructions
that are present in the code (like 99.99% of all), but there
is a chance there are some left, not covered by the parsing routine.
Parsing is done only for 32-bit instruction, no Thumb nor Thumb-2
support is provided.

Reviewed by:   kib
Submitted by:  Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4021
2015-11-02 16:56:34 +00:00
Oleksandr Tymoshenko
85645c5669 Add mailbox tag/structure for touchscreen buffer address property 2015-11-01 23:50:07 +00:00
Oleksandr Tymoshenko
0265aa0a15 Treat synchronous VFP exception just like aynchronous: as an FP exception,
not as illegal instruction
2015-11-01 21:59:56 +00:00
Oleksandr Tymoshenko
5ab55ce398 Fix framebuffer compatibility with new RPi firmware. Framebuffer driver
receives video memory address from VideoCore through property mailbox
channel. Older versions of firmware (and the one that is currently part
of sysutils/u-boot-rpi and sysutils/u-boot-rpi2) returned real physical
address, newer one returns VideoCore bus address, so we need to convert
it to actual physical address. this version works with both older and
newer interface.
2015-10-30 00:24:37 +00:00
Oleksandr Tymoshenko
5da8f2b69b Fix LEAVE_HYP macro: spsr is not guaranteed to contain valid value at this
point, e.g. on RaspberryPi 2 when control is passed from loader to kernel
it contains garbage. So we use cpsr as a base for new cpsr value: if we
have reached this point it means current value is OK

Reviewed by:	andrew
2015-10-29 22:12:03 +00:00
Jason A. Harmening
d58d7ad4a8 Retire pmap_dmap_iscurrent(). It is only a wrapper around pmap_is_current(), and is no longer called. 2015-10-28 21:17:38 +00:00
Andrew Turner
4648ee9525 Remove the s3c2xx0 code, it's no longer used. As far as I know I as the
main user of this code, however I haven't used it in over two years, and
don't expect to in the future.
2015-10-28 13:14:16 +00:00
Andrew Turner
7c07418e51 Start to remove support for the XScale i80321. As far as I can tell nobody
uses this which makes it difficult to support.
2015-10-28 13:07:56 +00:00
Andrew Turner
5635dd52eb Start to remove support for the Samsung s3c24x0 SoCs by removing the kernel
config, and support from NOTES.
2015-10-27 23:37:54 +00:00
Zbigniew Bodek
3c71b84f0a Add etherswitch support to mge
This commit introduces support for etherswitch devices that utilize SMI as
a way of accessing its registers. SMI register is located in address space
of mge -- access to it was exported through MDIO interface.

Attachment functions were enhanced so as to ensure proper initialisation
in both cases: 1) PHYs attached directly to mge, 2) PHYs attached to
switch device and switch attached to mge. Attachment of etherswitch device
depends on dts entry with compatible="mrvl,sw" property. If none is found,
typical PHY attachment procedure follows.

In case of switch attached, PHYs' status and configuration is accessible
via etherswitchcfg, and ifconfig shows always-up, non-configurable mge
interfaces.

Due to the fact that there may be simultaneous accessess to SMI
registers (e.g. from PHY attached to one of mge instances and switch
to the other), SMI access interlock was added. It is SX lock,
because sleep ability is necessary -- busy-waiting would result
in poor performance due to long delays required by hardware.
Underlying switch driver is obliged to use sleepable locks as well.

Reviewed by:    adrian
Obtained from:  Semihalf
Submitted by:   Bartosz Szczepanek <bsz@semihalf.com>
Differential revision: https://reviews.freebsd.org/D3900
2015-10-25 22:00:56 +00:00
Ian Lepore
e6bbb5d227 Define a couple macros to access cacheline size/mask in an arch-dependent
way.  This code should now work for all arm versions v4 thru v7.
2015-10-24 21:27:09 +00:00
Ian Lepore
ce6ce41cac Provide armv4/v5 implementations of several of the armv6 cache maintenance
functions.  This will make it possible to use the same busdma code for all
arm platforms v4 thru v7.
2015-10-24 21:25:53 +00:00
Ian Lepore
d818f2b6b9 Rename dcache_dma_preread() to dcache_inv_poc_dma() to make it clear that it
is a dcache invalidate to point of coherency just like dcache_inv_poc(), but
a slightly different version specific to dma operations.  Elaborate the
comment about how and why it's different.
2015-10-24 19:39:41 +00:00
Ian Lepore
872fb8b006 A few more whitespace, style, and comment cleanups. No functional changes. 2015-10-24 03:01:47 +00:00
Ian Lepore
5c738111f9 Bring in all the new(-ish) statistics code from armv6. 2015-10-24 02:44:13 +00:00
Ian Lepore
ba4e597710 Change the preallocation of a busdma segment mapping array from per-tag to
per-map.  The per-tag scheme is not safe, and a mutex can't be used to
protect it because the mapping routines can't sleep.  Code brought in
from armv6 implementation.
2015-10-24 02:18:14 +00:00
Ian Lepore
c83f1f12aa Instead of all memory allocations using M_DEVBUF, use new categories
M_BUSDMA for allocations of metadata (tags, maps, segment tracking lists),
and M_BOUNCE for bounce pages.
2015-10-23 22:52:00 +00:00
Ian Lepore
7a8c92a2c2 Instead of all memory allocations using M_DEVBUF, use new categories
M_BUSDMA for allocations of metadata (tags, maps, segment tracking lists),
and M_BOUNCE for bounce pages.
2015-10-23 22:51:48 +00:00
Ian Lepore
cce940d2f6 Catch up to r232356: change the boundary constraint type to bus_addr_t.
This code lived in the projects/armv6 branch when that change got applied
to all the other arches.
2015-10-23 21:29:37 +00:00
Ian Lepore
99bcf5e5b6 Whitespace and style nits, no functional changes.
The goal is to make these two files cosmetically alike so that the actual
implementation differences are visible.  The only changes which aren't
spaces<->tabs and rewrapping and reindenting lines are a couple fields
shuffled around in the tag and map structs so that everything is in the same
order in both versions (which should amount to no functional change).
2015-10-23 20:49:34 +00:00
Jason A. Harmening
a50730587b Remove unclear comment about address truncation in busdma. Add (hopefully much clearer) comment at declaration of PHYS_TO_VM_PAGE().
Noted by:	avg
2015-10-23 12:03:25 +00:00
Jason A. Harmening
0820c78e93 Use pmap_quick* functions in armv6 busdma, for bounce buffers and cache maintenance. This makes it safe to sync buffers that have no VA mapping associated with the busdma map, but may have other mappings, possibly on different CPUs. This also makes it safe to sync unmapped bounce buffers in non-sleepable thread contexts.
Similar to r286787 for x86, this treats userspace buffers the same as unmapped buffers and no longer borrows the UVA for sync operations.

Submitted by: 	Svatopluk Kraus <onwahe@gmail.com> (earlier revision)
Tested by:	Svatopluk Kraus
Differential Revision:	https://reviews.freebsd.org/D3869
2015-10-22 16:38:01 +00:00
Ian Lepore
9a2bb68894 Fix parsing of I2C addresses properties in fdt data. I2C address is
represented in 7-bits format in DT files, but system expect it in 8-bit
format.  Also, fix two drivers that locally hack around this bug.

Submitted by:	Michal Meloun <meloun@miracle.cz>
2015-10-21 15:41:16 +00:00
Ian Lepore
7b19ce31bb Move arm_gic_bind() out of the #ifdef SMP block to fix compile errors in
the not-SMP case.  This is safe because arm_irq_next_cpu() will return
the cpuid of the current/only core in the not-SMP case.

Submitted by:	 Bartosz Szczepanek @ semihalf
2015-10-21 13:59:00 +00:00
Jason A. Harmening
845baf1922 Use pmap_quick* for out-of-context bounce buffers and (limited) cache maintenance of unmapped buffers in armv5 busdma.
Tested by:	Mattia Rossi <mattia.rossi.mailinglists@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3522
2015-10-21 04:53:34 +00:00
Ian Lepore
d891769473 Uncomment some rather important code that was commented out for benchmarking.
Normally this routine is supposed to loop until the PIC returns a "no more
interrupts pending" indication.  I had commented that out to do just one
interrupt per invokation to do some timing tests.

Spotted by:   	Svata Kraus
Pointy Hat:	ian
2015-10-20 15:15:30 +00:00
Ganbold Tsagaankhuu
ba27fc087c Include "opt_platform.h" to fix kernel build for amlogic devices. 2015-10-20 13:47:36 +00:00
Ian Lepore
cabd1a7c40 Follow the advice of the misplaced comment and don't access the map struct
after freeing it.  Remove the comment whose uselessness has been revealed.
2015-10-20 03:27:59 +00:00
Ian Lepore
935c21a18e Set the correct values in the arm aux control register, based on chip type.
The bits in the aux control register vary based on the processor type.  In
the past we've always just set the 'smp' and "broadcast tlb/cache ops' bits,
which worked fine for the first few SoCs we supported.  Now that we support
most of the cortex-a series processors, it's important to get the right bits
set based on the processor type.

Submitted by:	Svatopluk Kraus <onwahe@gmail.com>
2015-10-19 19:18:02 +00:00
Oleksandr Tymoshenko
9d94145b96 Enable gpiobacklight in BEAGLEBONE config to support LCD capes by
4DSYSTEMS out of box
2015-10-18 23:58:05 +00:00
Ian Lepore
26b9f0eb98 Only decode fdt data which belongs to the GIC controller.
The interrupts-extended property is a list of controller-specific
interrupt tuples for more than one controller.  The decode routine of
every PIC gets called in the pre-INTRNG code (nexus doesn't know which
device instance belongs to which fdt node), so the GIC code has to
check each FDT node it is asked to decode to ensure it is the owner.

Because in the pre-INTRNG world there can only be one instance of a GIC,
it's safe to cache the results of a positive lookup in a static variable
to avoid the expensive lookups on subsequent calls.

Submitted by:	Svatopluk Kraus <onwahe@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D2345
2015-10-18 20:37:10 +00:00
Ian Lepore
302a9d3633 Include "opt_platform.h" early so that the FDT option is visible as needed. 2015-10-18 20:32:37 +00:00
Ian Lepore
e6c435106f Enable ARM_INTRNG on IMX6 platforms, and make the imx_gpio driver an
interrupt controller.

The latter is required for INTRNG, because of the hardware erratum
workaround installed by the linux folks into the imx6 FDT data, which remaps
an ethernet interrupt to the gpio device.  In the non-INTRNG world we
intercept the call to map the interrupt and map it back to the ethernet
hardware (because we don't need linux's workaround), but in the INTRNG world
we lose the hookpoint where that remapping was happening, but we gain the
ability to work the way linux does by having the gpio driver dispatch the
interrupt.
2015-10-18 19:54:11 +00:00
Ian Lepore
cf91682f07 Enable ARM_INTRNG on the pandaboard platform.
Differential Revision:	https://reviews.freebsd.org/D2048
2015-10-18 18:39:16 +00:00