Commit Graph

2980 Commits

Author SHA1 Message Date
Ian Lepore
97665af981 Enable the snoop control unit during MP startup, rather than relying on
the bootloader to have done so.

Submitted by:	Thomas Skibo <thomasskibo@sbcglobal.net>
2015-01-16 19:49:10 +00:00
Navdeep Parhar
ca7fe84a61 Plug cxgbe(4) back into !powerpc && !arm builds, instead of building it
on amd64 only.
2015-01-16 01:39:24 +00:00
Bjoern A. Zeeb
6333a401ff Fix cpsw(4) after r277203 which folded 'struct m_hdr' into 'struct mbuf'.
While in theory this should have been a transparent change (and was for all
other drivers), cpsw(4) never used the proper accessor macros in a few
places but spelt the indirect m_hdr.mh_* out itself.  Convert those to
use m_len and m_data and unbreak the driver build.
2015-01-15 02:22:52 +00:00
Luiz Otavio O Souza
e4b6eaf73a Fix the C -> K temperature conversion for the dev.cpu.0.temperature sysctl.
Previous code was discarding the last digit.

Remove the unused temperature conversion macros.
2015-01-15 01:05:05 +00:00
Luiz Otavio O Souza
02a42e683f Catch a few cases where we need to release memory resources on errors.
Place parentheses around variables in macros.

MFC after:	3 days
2015-01-15 00:48:53 +00:00
Ganbold Tsagaankhuu
d84d6e7716 Correct cpu type, it was rather Cortex A12 R0.
Approved by:    stas (mentor)
2015-01-14 01:23:50 +00:00
Ruslan Bukin
eff43c7467 Rename Exynos UART driver. No functional change.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2015-01-13 15:04:28 +00:00
Ganbold Tsagaankhuu
cebf67b056 Add CPU ID for ARM Cortex A17.
Approved by:    stas (mentor)
2015-01-13 07:49:07 +00:00
Luiz Otavio O Souza
2566c5264a Add support to turn off Beaglebone with poweroff(8) or shutdown(8) -p.
To cut off the power we need to start the shutdown sequence by writing
the OFF bit on PMIC.

Once the PMIC is programmed the SoC needs to toggle the PMIC_PWR_ENABLE
pin when it is ready for the PMIC to cut off the power.  This is done by
triggering the ALARM2 interrupt on SoC RTC.

The RTC driver only works in power management mode which means it won't
provide any kind of time keeping functionality.  It only implements a way
to trigger the ALARM2 interrupt when requested.

Differential Revision:	https://reviews.freebsd.org/D1489
Reviewed by:	rpaulo
MFC after:	2 weeks
2015-01-12 03:23:16 +00:00
Ian Lepore
244fe94f3b Handle dma mappings with more than one segment for rpi sdhci.
The driver inherently does dma in 512 byte chunks, but it's possible that
such a buffer can span two physically discontiguous pages (such as when
a userland program does IO on the raw /dev/mmcsdN devices).  Now the driver
can handle a buffer that's split across two pages.

It could in theory handle any number of segments now, but as long as IO is
being done in 512 byte blocks it will never need more than two.
2015-01-12 02:42:33 +00:00
Ian Lepore
740a7a7597 Enable ALT_BREAK_TO_DEBUGGER for rpi. 2015-01-12 02:29:23 +00:00
Ian Lepore
bf160401a9 Check for and handle failures of bus_dmamap_load(). The driver currently
requires that each 512 byte IO be in a single contiguous buffer, but if a
buffer crosses a page boundary and the physical pages aren't contiguous
you can get an EFBIG failure (too many segments).

The driver really should handle multiple segment IO, but before adding that
I wanted to make sure that it's handling failure properly while the failure
is easily recreatable.
2015-01-11 21:27:46 +00:00
Ian Lepore
bffed0e9c8 Store the shadow command/mode register in the softc, not a local static var.
Submitted by:	Michal Meloun
2015-01-11 17:00:24 +00:00
Andrew Turner
3f53a2d612 Rename gic_init_secondary to arm_init_secondary_ic to help with the merge
of the arm_intrng project branch.
2015-01-11 16:46:43 +00:00
Andrew Turner
c9ac548c01 Rework the GIC driver to ease the import of the arm_intrng branch. The
common code has been pulled out to static functions.
2015-01-11 10:26:49 +00:00
Warner Losh
c4765af73f Add infrastructure to build dtb files from dts files. 2015-01-08 18:28:06 +00:00
Ian Lepore
9326d90f0e Move the inclusion of cpu-v6.h inside the #ifdef _KERNEL block, so that
userland programs (which probably don't actually need machine/cpu.h) compile.
2015-01-08 03:59:03 +00:00
Ian Lepore
8a474d01ee Add accessors for the ARM CP15 performance monitor registers. Also ensure
that some #ifdef SMP code is also conditional on __ARM_ARCH >= 7; we don't
support SMP on armv6, but some drivers and modules are compiled with it
forced on via the compiler command line.
2015-01-08 01:28:46 +00:00
Luiz Otavio O Souza
60245f5103 Fix the handling of pull-up and pull-down for RK3188.
For this to work the driver needs to know the bank it has attached to since
the registers for the first 12 pins are at a different location.

Move the lock initialization to simplify the code.
2015-01-07 19:15:11 +00:00
Luiz Otavio O Souza
1c15a29600 Reduce the maximum number of pins for the Rockchip RK3188, this driver
isn't supposed to manage all the GPIO pins in the system from a single
instance, instead it will attach to each one of the four available GPIO
controllers and only deal with one bank at time (32 pins per bank).

Rework part of the driver to take advantage of that, this simplify the
code a lot.

Also fix a bug in rk30_gpio_get_function() which wouldn't return the
correct values.

While here fix a typo in register name.
2015-01-07 16:55:55 +00:00
Mark Johnston
bdb9ab0dd9 Factor out duplicated code from dumpsys() on each architecture into generic
code in sys/kern/kern_dump.c. Most dumpsys() implementations are nearly
identical and simply redefine a number of constants and helper subroutines;
a generic implementation will make it easier to implement features around
kernel core dumps. This change does not alter any minidump code and should
have no functional impact.

PR:		193873
Differential Revision:	https://reviews.freebsd.org/D904
Submitted by:	Conrad Meyer <conrad.meyer@isilon.com>
Reviewed by:	jhibbits (earlier version)
Sponsored by:	EMC / Isilon Storage Division
2015-01-07 01:01:39 +00:00
John Baldwin
3e32dff52c Remove "New" label from NFSCL/NFSD now that they are the only NFS
client/server.  While here, remove duplicate NFSCL from sys/conf/NOTES.

Approved by:	rmacklem
2015-01-06 16:15:57 +00:00
Hans Petter Selasky
b217d18412 Add 64-bit DMA support in the XHCI controller driver.
- Fix some comments and whitespace while at it.

MFC after:	1 month
Submitted by:	marius@
2015-01-05 20:22:18 +00:00
Ian Lepore
fbf1ef4849 Switch all arm kernels with option SMP to use SCHED_ULE instead of 4BSD. 2015-01-03 23:57:03 +00:00
Ian Lepore
dad0c32719 Remove commented-out options SMP and APIC_IO from old arm boards that will
never be able to support smp.
2015-01-03 23:30:29 +00:00
Ian Lepore
7e55f8c198 Add a new trap-v6.c which has support for all armv7 exceptions. This
mostly paves the way for the new pmap code, and shouldn't result in any
noticible behavior differences.

Submitted by: Svatopluk Kraus <onwahe@gmail.com>,
              Michal Meloun <meloun@miracle.cz
2015-01-03 22:33:18 +00:00
Ian Lepore
301e1601ad Fix alignment directives in arm asm code after clang 3.5 import.
The ancient gas we've been using interprets .align 0 as align to the
minimum required alignment for the current section.  Clang's integrated
assembler interprets it as align to a byte boundary.  Fortunately both
assemblers interpret a non-zero value as align to 2^N so just make sure
we have appropriate non-zero values everywhere.
2015-01-02 23:46:26 +00:00
Ed Maste
942c32333e Update ELF headers to include additional defines
The elftoolchain project includes these additional defines for various
userland programs. Given that arch-specific defines are still interesting
in the context of userland programs reading or writing ELF metadata, they
should be included in top-level ELF headers.

Remove duplicate defines from ARM and MIPS elf headers.

Submitted by:	will (initial version)
Reviewed by:	imp, will
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D844
2015-01-02 15:36:29 +00:00
Ruslan Bukin
e5df85ca42 Add driver for general-purpose I/O (GPIO).
Sponsored by:	DARPA, AFRL
2015-01-02 13:15:36 +00:00
Ian Lepore
67009184e3 Remove -Wa,-march=armv7a from arm kernel configs, it makes clang 3.5 sad
and apparently isn't needed now that we're using the integrated assembler.
2015-01-01 23:21:46 +00:00
Ian Lepore
54f9ec883d Define a WFI macro that expands to the right form of wait-for-interrupt
depending on the architecture.
2015-01-01 23:18:37 +00:00
Ian Lepore
bd96d0895e Rework the vpf support code so that it compiles with clang 3.4, 3.5, and gcc.
Michal Meloun did most of the hard work in figuring out what would work with
which compiler, I just reformated things a bit before committing.
2015-01-01 23:15:52 +00:00
Warner Losh
7ed11c5e5a Fix module builds on arm (and maybe others) by turning off a whole
raft of new warnings that appear to be on by default in clang 3.5.0.
Fix RPI-B build issues with new clang not liking the ability to pass
arbitrary flags to as, since some flags are more arbitrary (and thus
verboten) than others.

These warnings should be actually fixed in the code, but this is a
band-aide to get things (almost) building again.
2015-01-01 02:00:04 +00:00
Ian Lepore
490341147e A couple small fixes to make clang 3.5 happy... Move END(sigcode) to the
end of the actual instruction sequence for the function but before some
misc data in the text segment.  This eliminates a strange "size must be
constant" error from the integrated assembler.  Also, the build_pagetables
function was missing an END(), but really the problem is that it shouldn't
have an ASENTRY() because it's not a function that needs to be a global
symbol with unwind info and all, it's just a little private subroutine
used in very early kernel init.
2014-12-31 16:15:43 +00:00
Ian Lepore
9cb25d2d4c Change the order of operations for the initial cache setup. Turning off
the cache before clean/invalidate ensured that no new lines can come into
the cache or migrate between levels during the operation, but may not be
safe on some chips.  Instead, if the cache was enabled on entry, do the
wbinv while it's still enabled, and then disable it and do a separate
invalidate pass.  After the intitial writeback we know there are no
dirty lines left and no new dirty lines can be created as long as we
carefully avoid touching memory before turning the cache off.  Add a
comment about that so no new code gets inserted between those points.
2014-12-31 02:38:23 +00:00
Ian Lepore
3ed72a94a4 Fix a paste-o.
Submitted by:		Michal Meloun <meloun@miracle.cz>
2014-12-31 02:33:12 +00:00
Ian Lepore
952fc99936 Add a new locore.S that #includes the right (v4 or v6) implementation.
The kernel build machinery really wants the entry point to be in a file
named locore.S so doing this avoids a bunch of changes to the build system
for relatively little benefit.
2014-12-30 03:19:46 +00:00
Ian Lepore
dc15bc80b7 Rename locore.S to locore-v4.S and add a new locore-v6.S for starting up
armv6/7 systems.  We need to use some new armv6/7 features at startup
and splitting the implemenations to separate files will be more maintainable
than adding even more #ifdef sections to locore.S.

Because of the standardized interfaces to cache and MMU operations in armv7,
we can tolerate the kernel being entered with caches enabled.  This allows
running u-boot and loader(8) with caches enabled, and the performance
improvement can be dramatic (boot times can be cut from over a minute
to under 30 seconds).  The new implementation also has more robust cache
and mmu sequences for launching AP cores, and it paves the way for
upcoming changes to the pmap code which will use the TEX remap feature.

Changes in mp_machdep.c work with the new behavior in locore-v6 mp_entry,
and also reuse the original boot-time page tables to get transitioned
from physical to virtual addressing before installing the normal tables.

Submitted by Svatopluk Kraus and Michal Meloun with some changes by me.
2014-12-30 03:17:53 +00:00
Ian Lepore
10fe3ac09b Export MAXCPU to the assembler code, needing by upcoming changes to locore.S. 2014-12-30 02:58:34 +00:00
Ian Lepore
aaf2d0987e Add armv6 implementations of these cache operations to avoid duplicating
the #ifdef stuff at multiple points the functions are called from.  Also
rework the armv7 implementations so that the invalidate operations work
from outermost to innermost cache level, and the writeback works from
inner to outer levels.
2014-12-30 02:56:31 +00:00
Ian Lepore
782feef3f3 Update comments (r4 is not used anywhere), use non-profiling entry macros. 2014-12-28 21:33:41 +00:00
Ian Lepore
874d48dc8f Fix a "decl is not a prototype" error noticed by gcc (but not clang). 2014-12-28 19:05:32 +00:00
Ian Lepore
6c1d9637b7 Add cache maintenance functions which will be used by startup code to
initially set up the MMU.  Some day they may also be useful as part of
suspend/resume handling, when we get better at power management.

Submitted by: Svatopluk Kraus <onwahe@gmail.com>,
              Michal Meloun <meloun@miracle.cz
2014-12-28 18:38:25 +00:00
Ian Lepore
8d59f6c4da Eliminate an unused macro whose name clashes now with a function in the
new cpu-v6.h.  This should have been part of r276334.
2014-12-28 18:26:15 +00:00
Ian Lepore
518c6ac777 Add new TLB and cache maintainence functions for armv6 and armv7. These
are inline functions that handle all the routine maintenance operations
except the flush-all and invalidate-all routines which are required only
during early kernel init.

These inline functions should be very much faster than the old mechanism
that involved jumping through the big cpufuncs table, especially for
common operations such as invalidating a single TLB entry.  Note that
nothing is calling these yet, this just is just required infrastructure
for upcoming changes to the pmap-v6 code.
2014-12-28 18:19:05 +00:00
Ian Lepore
2b71562fd8 Add new code to read and parse cpu identification data using the new CPUID
mechanism defined for armv7 (and also present on some armv6 chips including
the arm1176 used on rpi).  The information is parsed into a global cpuinfo
structure, which will be used by (upcoming) new cache and tlb maintenance
code to handle cpu-specific variations of the maintence sequences.

Submitted by: Svatopluk Kraus <onwahe@gmail.com>,
              Michal Meloun <meloun@miracle.cz
2014-12-28 18:12:56 +00:00
Luiz Otavio O Souza
bb0a868b54 Remove unnecessary code and, instead, use the provided iicbus_null_callback
callback.
2014-12-27 20:06:16 +00:00
Luiz Otavio O Souza
f7f772808b Fix a off-by-one bug.
Pointy hat to:	loos
2014-12-27 19:56:04 +00:00
Luiz Otavio O Souza
9e93dfcf25 Convert the BSC (i2c) driver to use the new iicbus_get_frequency().
Tested on:	Raspberry pi
2014-12-27 18:54:39 +00:00
Luiz Otavio O Souza
09df4bfd8d Removes unused and duplicate headers.
Bring the wait limit on mailbox write to a more sane value.

Fix a off-by-one bug on wait time limit.

Remove extra blank line.
2014-12-27 15:13:25 +00:00
Luiz Otavio O Souza
abba73f295 Remove the '#undef DEBUG' that should not be committed. 2014-12-27 14:06:05 +00:00
Luiz Otavio O Souza
1432fa20f3 On interrupt handler, save the actual data read from mbox. The previous
macro wasn't needed and was being used with swapped arguments which always
give the same result (0) defeating the overflow check.

On initialization, do not use bcm_mbox_intr() to read the pending messages,
with the new semaphore based implementation this will lead to semaphore
being incremented on the channels that contain pending data and will make
the first read for that channel return stale data.

This fixes the hang that happens on boot while initializing the cpufreq on
Raspberry Pi.
2014-12-27 13:52:33 +00:00
Luiz Otavio O Souza
e9faba9d70 Make consistent use of the correct debug macros across the file. 2014-12-27 13:17:27 +00:00
Luiz Otavio O Souza
f2e44b6029 Fix the musb initialization sequence on AM335x.
According to http://e2e.ti.com/support/arm/sitara_arm/f/791/t/210729 the
USB reset pulse has an undocumented duration of 200ns and during this
period the module must not be acessed.

We wait for 100us to take into account for some imprecision of the early
DELAY() loop.

This fixes the eventual 'External Non-Linefetch Abort (S)' that happens at
boot while resetting the musb subsystem.

While here, enable the USB subsystem clock before the first access.

Discussed with: 	ian, adrian
MFC after:		2 weeks
2014-12-26 17:45:49 +00:00
Ian Lepore
efa8bab713 Include acle-compat.h directly (we use its symbols) rather than getting
it via sysreg.h.
2014-12-26 14:29:27 +00:00
Ian Lepore
2ed434b4bf Squelch a (bogus) gcc use-before-init warning. 2014-12-26 13:44:41 +00:00
Ian Lepore
c93be3714d Define only the CP15 register operations that are valid for the architecture.
Submitted by: Svatopluk Kraus <onwahe@gmail.com>,
              Michal Meloun <meloun@miracle.cz
2014-12-25 19:22:02 +00:00
Ian Lepore
eb4585bcc6 Add macros for asm barrier instructions with arch-specific implementations. 2014-12-25 19:08:39 +00:00
Luiz Otavio O Souza
3681c8d718 Add interrupt support for GPIO pins on OMAP4 and AM335x.
This enables the use of GPIO pins as interrupt sources for kernel devices
directly attached to gpiobus (userland notification will be added soon).

The use of gpio interrupts for other kernel devices will be possible when
intrng is complete.

All GPIO pins can be set to trigger on:

- active-low;
- active-high;
- rising edge;
- falling edge.

Tested on:	Beaglebone-black
2014-12-25 17:28:26 +00:00
Ian Lepore
26659812e2 For data and instruction prefetch aborts, call the same handler in the C
code, passing a 0/1 flag that indicates which type of abort it was.  This
sets the stage for unifying the handling of page faults in a single routine.

Submitted by: Svatopluk Kraus <onwahe@gmail.com>,
	      Michal Meloun <meloun@miracle.cz
2014-12-25 17:06:58 +00:00
Ian Lepore
b05d247e35 Create 'L' variants of all the ENTRY macros for file-static/local symbols.
If it seems like this is getting out of hand, I quite agree.  I wonder if
it's safe, here in the 21st century, to lose the distinction between C and
ASM symbols?
2014-12-25 16:49:33 +00:00
Ian Lepore
714429358f Fix the GLOBAL macro so it works (upper vs lowercase X), use it in _EENTRY. 2014-12-25 16:43:15 +00:00
Ian Lepore
de064ce459 Stylish changes... put tabs where they need to be in macros, move lines
around so that related things are more grouped together, rewrite comments.

No functional changes, this is all so that the functional changes in the
next commit will stand out.
2014-12-25 16:36:02 +00:00
Ian Lepore
be483be81d Remove _PROF_PROLOGUE from the EENTRY() macros. These macros define
'extra' entry points which are nested within or provide a synonym name
for another function.  It's most likely not safe to be messing with the
IP and LR registers at anything other than the primary entry point to a
function.  Anywhere beyond initial function entry, those registers may
be in use as scratch or variable registers.
2014-12-25 04:41:43 +00:00
Ian Lepore
d1962184e0 Oops, I fumbled a semicolon on the style changes; recover it. 2014-12-25 04:18:31 +00:00
Ian Lepore
7624957bc6 Change the style of the DO_AST macro to match the others in this file --
semicolons between the code and comments instead of after the comments,
and line continuations in the arbitrary but now consistant column 76.

No functional changes.
2014-12-25 03:41:56 +00:00
Ian Lepore
1af5f5366c Display the correct value for cache Level of Coherency. Like the other
levels being displayed here, its value needs a +1 adjustment.
2014-12-24 19:47:50 +00:00
Ian Lepore
c4c27bc97f Cleanup up ARM *frame structures...
- Eliminate unused irqframe
 - Eliminate unused saframe
 - Instead of splitting r4-sp storage between the stack and switchframe,
   just put all the registers in switchframe and eliminate the un_32 struct.

Submitted by:	Svatopluk Kraus <onwahe@gmail.com>,
		Michal Meloun <meloun@miracle.cz>
2014-12-24 18:54:31 +00:00
Ian Lepore
baa4417f37 Eliminate unnecessary references to pte.h internals by using the standard
pmap_kenter_temporary() to map pages while dumping.

Submitted by:	Svatopluk Kraus <onwahe@gmail.com>,
		Michal Meloun <meloun@miracle.cz>
2014-12-24 17:12:51 +00:00
Andrew Turner
ed600fa777 Rename pic_ipi_get to pic_ipi_read for intrng. 2014-12-24 15:25:18 +00:00
Andrew Turner
ef7eac4353 Switch i.MX to use the platform code to help with a single Freescale kernel.
Differential Revision:	https://reviews.freebsd.org/D1349
Reviewed by:	ian, rpaulo
2014-12-24 12:26:43 +00:00
Luiz Otavio O Souza
e350f76c66 Bring in the last round of updates before adding the interrupt support.
Fix the following issues:

- Removed revision from device softc, it isn't used anywhere else out of
  device attach routine;

- Move the duplicated code for verification of valid banks (and pins) to
  a single function;

- Use some macros to simplify the handling of some constants;

- Update some stale comments.
2014-12-24 04:24:08 +00:00
Ian Lepore
0236b3314f Revert a glitched mismerge that got caught up in the prior commit.
The PJ4B family is still armv7, not armv6.
2014-12-24 03:09:55 +00:00
Ian Lepore
6783238b2d Define the old-school arm arch constants we still use internally based on
the somewhat newer constants predefined by the compiler.  This will allow
userland apps to use various machine/foo.h headers without CPUTYPE defined.
2014-12-24 03:02:12 +00:00
Luiz Otavio O Souza
3b9e64af65 Do not return the total number of available pins but the maximum pin number
we can cope.

Previously the returned value could prevent access to some of the pins.
2014-12-23 19:31:56 +00:00
Rick Macklem
c15882f091 Remove the old NFS client and server from head,
which means that the NFSCLIENT and NFSSERVER
kernel options will no longer work. This commit
only removes the kernel components. Removal of
unused code in the user utilities will be done
later. This commit does not include an addition
to UPDATING, but that will be committed in a
few minutes.

Discussed on: freebsd-fs
2014-12-23 00:47:46 +00:00
Luiz Otavio O Souza
a59806b252 Remove some leftovers from OMAP3 support. 2014-12-22 16:29:15 +00:00
Luiz Otavio O Souza
f9de33d497 Simplify the use of locks where possible, remove the locking when it is not
required.

Simplify the code a little bit.

Reviewed by:	andrew (previous version)
2014-12-22 16:12:55 +00:00
Ian Lepore
a0041e6d2f Replace the clock divisor terms with values that also result in a 1 MHz
clock, but actually work on real hardware, unlike the original set of
values I chose.

PR:		195009
Submitted by:	Scott Ellis <jumpnowtek@gmail.com>
2014-12-22 00:50:01 +00:00
Ian Lepore
88b80af731 Add -march=armv7a to the kernel compile for all ARM systems which are v7a.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-12-21 23:48:32 +00:00
Andrew Turner
c18b81e54b Fix the unwinder to get past functions with no stack but may cause an
exception. In this case no registers will be updated but the link register
will be copied to the program counter to be used to find the calling
function. In this case the program counter may be updated and we should
continue with the trace.
2014-12-21 21:38:12 +00:00
Andrew Turner
ec7d251e09 Pull out the fdt mapping code into intr.c. The arm_intrng branch also
defines this function allowing the mapping method to change when we move
to it.
2014-12-21 21:27:12 +00:00
Ian Lepore
f55abc7e4b Eliminate a redundant declaration. 2014-12-21 21:23:53 +00:00
Ian Lepore
9d87c6c8fb Remove a volatile qualifier on return type that is ignored and results in
a -Wreturn-type warning when compiled with gcc.
2014-12-21 21:11:54 +00:00
Andrew Turner
d0e17309d7 Further reduce the diff between the arm_intrng gic driver and the version
in head.
2014-12-21 17:25:21 +00:00
Andrew Turner
27ad9746c0 Reduce the diff between the lpc interrupt controller in head and arm_intrng 2014-12-21 16:59:41 +00:00
Andrew Turner
3d6451aef8 Reduce the diff in the Ti aintc between head and arm_intrng 2014-12-21 16:48:57 +00:00
Andrew Turner
171af33c53 Reduce the diff between head and arm_intrng with the bcm2835 interrupt
controller.
2014-12-21 16:35:42 +00:00
Andrew Turner
2fe8c9e132 Reduce the diff to the arm_intrng project branch by having the read/write
macros take the softc they are accessing.
2014-12-21 16:21:56 +00:00
Andrew Turner
afa6f59cca Fix the indentation to simplify comparing the ARM config files. 2014-12-21 11:55:40 +00:00
Andrew Turner
0c08f78521 tart to clean up the armv6 kernel configs by reducing the diff between
them in the first sections and the later FDT support.

Differential Revision:	https://reviews.freebsd.org/D1346
Reviewed by:	rpaulo (earlier version)
2014-12-21 11:37:00 +00:00
Rui Paulo
b9450e431d Driver for CPU frequency/voltage control on the Raspberry Pi.
Differential Revision:	https://reviews.freebsd.org/D1025
Submitted by:	Daisuke Aoyama aoyama@peach.ne.jp
Reviewed by:	ian (earlier version), rpaulo
MFC after:	1 month
Relnotes:	yes
2014-12-20 19:15:10 +00:00
Andrew Turner
9b2655e094 Clean up the style of the CUBIEBOARD2 config file 2014-12-20 18:42:20 +00:00
Andrew Turner
d943b9a337 Clean up to use the standard style of "options \t" and "device\t\t" 2014-12-20 18:15:23 +00:00
Ian Lepore
61bc42f782 Add a new sdhci quirk, SDHCI_QUIRK_WAITFOR_RESET_ASSERTED, to work around
TI OMAP controllers which will return the reset-in-progress bit as zero if
you read the status register too fast after setting the reset bit.

The zero is apparently from a stale snapshot of the internal state presented
in the interface register, and leads to a false indication that the reset
is complete when it either hasn't started yet or is in-progress.  The
workaround is to first loop until the bit is seen as asserted, then do the
normal loop waiting to see it de-asserted.

Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-12-20 01:13:13 +00:00
Ian Lepore
a5d3a7fba9 Rewrap long lines; no functional changes.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-12-19 23:24:54 +00:00
Ian Lepore
7a8f993664 Add code to set and reset open-drain mode on the bus when requested.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-12-19 23:13:46 +00:00
Ruslan Bukin
dd279f7aaa Fix typo. 2014-12-15 12:15:18 +00:00
Ruslan Bukin
1f7f3314d1 Follow r275792 eliminating fdt_data_verify(). 2014-12-15 11:57:39 +00:00
Ian Lepore
7f353dddc8 Fix the watchdog timeout calculation to prevent wrap. The RPi hardware
can't do a timeout bigger than 15 seconds.  The code wasn't checking for
this and because bitmasking was involved the requested timeout was
basically adjusted modulo-16.  That led to things like a 128 second
timeout actually being a 9 second timeout, which accidentally worked fine
until watchdogd was changed to only pet the dog once every 10 seconds.
2014-12-10 04:54:43 +00:00
Ruslan Bukin
a8098016f1 o Add BERI Virtio Networking Frontend (if_vtbe)
o Move similar block/networking methods to common file
o Follow r275640 and correct MMIO registers width
o Pass value to MMIO platform_note method.

Sponsored by:	DARPA, AFRL
2014-12-09 16:39:21 +00:00
Andrew Turner
95d7f8aa40 Include sys/kernel.h to pick up the definition of hz. subr_syscall.c uses
it after r275616.

X-MFC with:	r275616
2014-12-09 10:21:31 +00:00
Zbigniew Bodek
8948956770 Fix buffer overflow in Marvell PCI/PCIe driver
Buffer overflow occured when more than one MSI was allocated.

Submitted by:    Wojciech Macek <wma@semihalf.com>
Obtained from:   Semihalf
2014-12-07 21:02:45 +00:00
Andrew Turner
17fea8f6b7 Use the unified syntax when generating assembly for clang. The clang 3.5
integrated assembler only accepts it.

MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-06 11:59:35 +00:00
Andrew Turner
0395da4366 Switch to a .cpu directive. These will work when clang 3.5 is imported
where the .arch directive is a nop.

MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-05 19:23:51 +00:00
Andrew Turner
eff4f0ceee Switch to an armv6k cpu, without this clang 3.5 complains "bx lr" is
unsupported as it needs a newer cpu.

MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-05 19:19:17 +00:00
Andrew Turner
ef477cd70b Place the literal pool after a RET otherwise clang 3.5 tries to put it too
far away from a ldr psuedo instruction. With this clang will place the
literal value here where it's close enough to be loaded.

MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-05 19:14:05 +00:00
Andrew Turner
89636bddf6 Set the alignment to 4-bytes after a string as clang 3.5 can switch to
thumb mode if this is incorrect.

MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-05 19:11:25 +00:00
Andrew Turner
524bca9008 Use the unified syntax in a few more assembly files
MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-05 19:08:36 +00:00
Andrew Turner
ff9dd44ead Add missing END macros to some of the xscale functions.
MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-05 19:04:08 +00:00
Andrew Turner
c258e1cc69 Switch to unified syntax so these can be built with clang 3.5.
MFC after:	1 week
Sponsored by:	ABT Systems Ltd
2014-12-02 18:37:04 +00:00
Andrew Turner
4373d2f370 Use the APSR_nzcv format of mrc. The clang integrated assembler doesn't
support the old usage of r15.

Sponsored by:	ABT Systems Ltd
2014-12-02 18:35:34 +00:00
Andrew Turner
d9e2150b36 Fix the name of the coprocessor to include the "p" prefix, the clang
integrated assembler expects this.

MFC after:	1 Week
Sponsored by:	ABT Systems Ltd
2014-12-02 18:20:53 +00:00
Andrew Turner
7f9b314ff2 Pull in the NetBSD global offset table handling code. Clang 3.5 creates
relocations the linker complains about.

Obtained from:	NetBSD
MFC after:	1 Week
2014-12-01 21:04:26 +00:00
Rui Paulo
afe2c75694 Allow multiple devices to mmap. It's impossible to prevent this with
checks on the open/close functions.

MFC after:	1 week
2014-12-01 19:48:23 +00:00
Andrew Turner
4c1720fd9a Correctly a few incorrect uses of ENTRY/EENTRY and END/EEND
Sponsored by:	ABT Systems Ltd
2014-11-30 12:25:04 +00:00
Andrew Turner
13fb42aabe Remove extra labels, ENTRY_NP already provides them.
Sponsored by:	ABT Systems Ltd
2014-11-30 12:20:24 +00:00
Andrew Turner
b643b9341c Update _ENTRY to use _EENTRY to reduce the common code. 2014-11-29 19:31:23 +00:00
Andrew Turner
15eb3a7427 Some device tree configurations place the generic timer under the root
of the tree and not under simplebus. Update the driver to handle this.

Submitted by:	Julien Grall <julien.grall AT linaro.org>
MFC after:	1 week
2014-11-28 11:49:26 +00:00
Andrew Turner
56f0c37e9f We don't use the hypervisor interrupt, make it optional in the device tree.
Submitted by:	Julien Grall <julien.grall AT linaro.org>
MFC after:	1 week
2014-11-28 11:45:53 +00:00
Ruslan Bukin
b4db959ac5 Add new devices to the config. 2014-11-25 16:24:31 +00:00
Ruslan Bukin
e8cf387c51 o Add PIO and vtblk mmio device info to the tree
o Add FPGA memory window to static dev mappings
o Fix whitespace
2014-11-25 16:06:19 +00:00
Ed Maste
294246bb7d Revert r274772: it is not valid on MIPS
Reported by:	sbruno
2014-11-25 03:50:31 +00:00
Ian Lepore
3787815761 The arm PJ4B cpu is armv7 architecture, not v6.
If this feels like deja vu... the last time this was fixed in this file
only ARM_MMU_V6 was fixed, this time it's ARM_ARCH_V6 (and this time I
searched for other occurrances of pj4b in here).
2014-11-24 01:13:58 +00:00
Ian Lepore
0beab155a6 When doing a PREREAD sync of an mbuf-type dma buffer, do a writeback of
the first cacheline if the buffer start address is not on a cacheline
boundary.  Normally a buffer which is not cacheline-aligned is bounced,
but a special rule applies for mbufs, which are always misaligned due to
the header.  We know the cpu will not write to the header while dma is in
progress (so we've been told anyway), but it may have written to the
header shortly before starting a read, so we need to flush that write out
to memory before invalidating the whole buffer.

In collaboration with Mical Meloun and Svata Kraus.
2014-11-22 03:03:11 +00:00
Ed Maste
688fd61ae8 Use canonical __PIC__ flag
It is automatically set when -fPIC is passed to the compiler.

Reviewed by:	dim, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1179
2014-11-21 02:05:48 +00:00
Luiz Otavio O Souza
667357dc9b Moves all the duplicate code to a single function.
Verify for invalid modes and unwanted flags before pass the new flags to
driver.
2014-11-18 17:22:08 +00:00
Warner Losh
61c009a1a8 These delays aren't needed. Elimate them. They should be on the order
of a few cycles at most, not 10us. They make it impossible to
implement half-duplex protocols that are faster than about 1KHz.

Sponsored by: Netflix
2014-11-18 17:07:02 +00:00
Warner Losh
40e6bdaf1e opt_global.h is included automatically in the build. No need to
explicitly include it in these places.

Sponsored by: Netflix
2014-11-18 17:06:56 +00:00
Ian Lepore
e93af0f1b9 Fix the i2c bus speed divisors for TI OMAP4 and AM335x.
For OMAP4, the old values for 1MHz gave a bus frequency of about 890KHz.
The new numbers hit 1MHz exactly.

For AM335x the prescaler values are adjusted to give a 24MHz clock for
all 3 standard speeds, as the manual recommends (as near as we can tell,
there are errors and typos apparent in the document).  Also, 1MHz speed
is added, and has been tested successfully on a BeagleboneWhite board.

PR:		195009
2014-11-18 03:26:52 +00:00
Ian Lepore
844aff82a6 Allow i2c bus speed to be configured via hints, FDT data, and sysctl.
The current support for controlling i2c bus speed is an inconsistant mess.
There are 4 symbolic speed values defined, UNKNOWN, SLOW, FAST, FASTEST.
It seems to be universally assumed that SLOW means the standard 100KHz
rate from the original spec.  Nothing ever calls iicbus_reset() with a
speed of FAST, although some drivers would treat it as the 400KHz standard
speed.  Mostly iicbus_reset() is called with the speed set to UNKNOWN or
FASTEST, and there's really no telling what any individual driver will do
with those.

The speed of an i2c bus is limited by the speed of the slowest device on
the bus.  This means that generally the bus speed needs to be configured
based on the board/system and the components within it.  Historically for
i2c we've configured with device hints.  Newer systems use FDT data and it
documents a clock-frequency property for i2c busses.  Hobbyists and
developers are likely to want on the fly changes.  These changes provide
all 3 methods, but do not require any existing drivers to change to use
the new facilities.

This adds an iicbus method, iicbus_get_frequency(dev, speed) that gets the
frequency for the requested symbolic speed.  If the symbolic speed is SLOW
or if there is no speed configured for the bus, the returned value is
100KHz, always.  Otherwise, if bus speed is configured by hints, fdt,
tunable, or sysctl, that speed is returned.  It also adds a helper
function, iicbus_init_frequency() that any bus driver subclassed from
iicbus can initialize the frequency from some other source of info.

Initial driver implementations are provided for Freescale and TI.

Differential Revision:        https://reviews.freebsd.org/D1174
PR:		195009
2014-11-18 01:54:31 +00:00
Ian Lepore
a178f1f70a No functional changes. Remove a couple outdated or inane comments and
add new comment blocks describing why the cache maintenance sequences are
done in the order they are for each case.
2014-11-16 21:39:56 +00:00
Ian Lepore
0c4f0ef9ae Correct the sequence of busdma sync ops involved with PRE/POSTREAD syncs.
We used to invalidate the cache for PREREAD alone, or writeback+invalidate
for PREREAD with PREWRITE, then treat POSTREAD as a no-op.  Prefetching on
modern systems can lead to parts of a DMA buffer getting pulled into the
caches while DMA is in progress (due to access of "nearby" data), so it's
mandatory to invalidate during the POSTREAD sync even if a PREREAD
invalidate also happened.

In the PREREAD case the invalidate is done to ensure that there are no
dirty cache lines that might get automatically evicted during the DMA,
corrupting the buffer.  In a PREREAD+PREWRITE case the writeback which is
required for PREWRITE handling is suffficient to avoid corruption caused
by eviction and no invalidate need be done until POSTREAD time.

Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-11-16 21:22:42 +00:00
Ian Lepore
1c716437d5 Do the cache invalidate sequence from the outermost to innermost, required
for correct operation.

Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-11-16 20:59:27 +00:00
Ian Lepore
f5b11228ad Do not do a cache invalidate on a PREREAD sync that is also a PREWRITE sync.
The PREWRITE handling does a writeback of any dirty cachelines, so there's
no danger of an eviction during the DMA corrupting the buffer.  There will
be an invalidate done during POSTREAD, so doing it before the read too is
wasted time.
2014-11-16 20:55:51 +00:00
Ian Lepore
a57275b601 Indent a couple lines properly and expand a comment. No functional changes. 2014-11-16 20:34:14 +00:00
Ian Lepore
e7a8895c57 Whitespace and comment tweaks, no functional changes. 2014-11-15 05:40:20 +00:00
Ian Lepore
df826e78d4 When doing busdma sync ops for BUSDMA_COHERENT memory, there is no need
for cache maintenance operations, but ensure that all prior writes have
reached memory when doing a PREWRITE sync.

Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-11-15 03:39:58 +00:00
Ian Lepore
3aa1219d0c Use the standard powerof2() macro from param.h instead of a local one.
Pointed out by:	 jhb@
2014-11-15 02:58:17 +00:00
Zbigniew Bodek
8971dd564e Fix typo in ARM GIC device_printf()
Obtained from:   Semihalf
Sponsored by:    The FreeBSD Foundation
2014-11-13 21:37:53 +00:00
Luiz Otavio O Souza
0a39cc71f8 Fix the error checking, broken on r273337, to _not_ ignore controller
errors.

Without this fix you can't even scan the bus (all operations will always
succeed).

MFC with:	r273337
Pointy hat to:	loos
2014-11-12 03:07:46 +00:00
Ian Lepore
6eef1a334d Fix the reversed sense of the PADCONF_NONE test. 2014-11-12 02:44:27 +00:00
Ian Lepore
3a8af166a2 Bugfixes for the imx5/imx6 iomux fdt_pinctrl driver.
I originally overlooked a couple flag bits defined in the fdt binding docs.
One flag suppresses the pad configuration (pullup/pulldown/etc).  The other
one requires that the SION (set input on) flag be set in the mux register.

Also, it appears from the data involved that if the input register
address in the config tuple is zero, there is no input configuration.  The
old code was writing to register zero, which contains a collection of misc
control bits (having nothing to do with input configuration) that probably
shouldn't get overwritten arbitrarily.  The bindings doc doesn't explictly
mention this.
2014-11-12 02:37:27 +00:00
Luiz Otavio O Souza
bea71143ed Since r273264 the SD card detection on Raspberry Pi is reliably working and
that expose new bugs with HS mode.

When the old code could not do the proper card detection it would boot with
lower defaults (and no HS mode) and this makes some HS cards boots.

Now, with the card always identified as HS capable, the sdhci controller
tries to run the card at HS speeds and makes the boot always fail.

Disable the HS mode for now (which still can be enabled with the tunable)
until it is properly fixed.

MFC with:	r273264
Requested by:	many
2014-11-11 23:55:37 +00:00
Alexander V. Chernikov
603eaf792b Renove faith(4) and faithd(8) from base. It looks like industry
have chosen different (and more traditional) stateless/statuful
NAT64 as translation mechanism. Last non-trivial commits to both
faith(4) and faithd(8) happened more than 12 years ago, so I assume
it is time to drop RFC3142 in FreeBSD.

No objections from:	net@
2014-11-09 21:33:01 +00:00
Ian Lepore
77f4973eec Strengthen the sanity checking of busdma tag parameters.
It turns out an alignment of zero can lead to an endless loop in the
vm reservations code, so specifically disallow that.  The manpage says
hardware which can do dma at any address should use a value of one, which
hints at the forbiddeness of zero without exactly saying it.  Several
other conditions which could lead to insanity in working with the tag are
also checked now.

Every existing call to bus_dma_tag_create() (about 680 of them) was
eyeballed for violations of these things, and two alignment=0 glitches
were fixed.  It's possible something was missed, but overall this
shouldn't lead to any arm users suddenly experiencing failures.
2014-11-06 19:14:58 +00:00
Kevin Lo
cde04bfa59 Fix usage of kern_getenv(). 2014-10-31 15:07:51 +00:00
Luiz Otavio O Souza
8839e0e9f3 Make the GPIO children attach to the first unit available and not only to
unit 0.

It seems that this 'simplification' was copied to all GPIO drivers in tree.

This fix a bug where a GPIO controller could fail to attach its children
(gpioc and gpiobus) if another GPIO driver attach first.
2014-10-28 18:33:59 +00:00
Konstantin Belousov
4f3dc90023 Add fueword(9) and casueword(9) functions. They are like fuword(9)
and casuword(9), but do not mix value read and indication of fault.

I know (or remember) enough assembly to handle x86 and powerpc.  For
arm, mips and sparc64, implement fueword() and casueword() as wrappers
around fuword() and casuword(), which means that the functions cannot
distinguish between -1 and fault.

On architectures where fueword() and casueword() are native, implement
fuword() and casuword() using fueword() and casuword(), to reduce
assembly code duplication.

Sponsored by:	The FreeBSD Foundation
Tested by:	pho
MFC after:	2 weeks (ia64 needs treating)
2014-10-28 15:22:13 +00:00
Ian Lepore
81d54b79fc Remove the ARM_DEVICE_MULTIPASS option and make its effect be the default.
Multipass device attachment was tested on many arm platforms by users and
only success was reported on the arm@ mailing list.  This is just the
long-delayed followup of making it the default.

Multipass attachment is necessary when using vendor-supplied FDT data,
because our devices may need to be attached in a different order than they
are described in the FDT data.
2014-10-26 18:30:35 +00:00