Commit Graph

2690 Commits

Author SHA1 Message Date
Ruslan Bukin
d440ef2d73 Rename files: keep codename only to make it shorter. 2014-08-01 15:10:55 +00:00
Ruslan Bukin
835b36e211 Add support for Chromebook2 -- next-generation 8-core
(4 in operation), 4GB ram (3.5 usable) ARM machine.

Support covers device drivers for:
- Serial Peripheral Interface (SPI)
- Chrome Embedded Controller (EC) - SPI-based version
- XHCI and USB 3.0 dual-role device PHY

Also:
- Add support for Exynos5420 in Pad module
- Move power-related functions to separate driver --
  Power Management Unit (PMU)
- Enable XHCI for Chromebook1

Special thanks to grehan@ for hardware, and to
hselasky@ for r269139.
2014-08-01 06:20:25 +00:00
Ian Lepore
e58f02735f Switch to using counter(9) for the new 64-bit stats kept by armv6 busdma. 2014-07-31 03:59:00 +00:00
Ruslan Bukin
d6fb2fd561 Remove unused option. 2014-07-29 12:44:19 +00:00
Aleksandr Rybalko
d5a20b9777 Remove SC_DFLT_FONT option. vt(4) don't use it.
Suggested by:	emaste
Sponsored by:	The FreeBSD Foundation
2014-07-29 12:04:11 +00:00
Ian Lepore
15fc287383 Export some new busdma stats via sysctl for armv6. Added:
hw.busdma.tags_total: 46
 hw.busdma.maps_total: 1302
 hw.busdma.maps_dmamem: 851
 hw.busdma.maps_coherent: 849
 hw.busdma.maploads_total: 1568812
 hw.busdma.maploads_bounced: 16750
 hw.busdma.maploads_coherent: 920
 hw.busdma.maploads_dmamem: 920
 hw.busdma.maploads_mbuf: 1542766
 hw.busdma.maploads_physmem: 0
2014-07-29 02:38:02 +00:00
Ian Lepore
b92672d0cb A while back, the array of segments used for a load/mapping operation was
moved from the stack into the tag structure.  In retrospect that was a bad
idea, because nothing protects that array from concurrent access by
multiple threads.

This change moves the array to the map structure (actually it's allocated
following the structure, but all in a single malloc() call).

This also establishes a "sane" limit of 4096 segments per map.  This is
mostly to prevent trying to allocate all of memory if someone accidentally
uses a tag with nsegments set to BUS_SPACE_UNRESTRICTED.  If there's ever
a genuine need for more than 4096, don't hesitate to increase this (or
maybe make it tunable).

Reviewed by:	cognet
2014-07-29 02:37:48 +00:00
Ian Lepore
0e58c32732 We never need bounce pages for memory we allocate. We cleverly allocate
memory the matches all the constraints of the dma tag so that bouncing
will never be required.

Reviewed by:	cognet
2014-07-29 02:37:31 +00:00
Ian Lepore
409b23f7a7 Replace a bunch of double-indirection with a local pointer var (that is,
(*mapp)->something becomes map->something).  No functional changes.

Reviewed by:	cognet
2014-07-29 02:37:24 +00:00
Ian Lepore
2746b8c41f Don't clear the DMAMAP_DMAMEM_ALLOC flag set a few lines earlier. Doh!
Reviewed by:	cognet
2014-07-29 02:36:50 +00:00
Ian Lepore
1da97d052e Memory belonging to an mbuf, or allocated by bus_dmamem_alloc(), never
triggers a need to bounce due to cacheline alignment.  These buffers
are always aligned to cacheline boundaries, and even when the DMA operation
starts at an offset within the buffer or doesn't extend to the end of the
buffer, it's safe to flush the complete cachelines that were only partially
involved in the DMA.  This is because there's a very strict rule on these
types of buffers that there will not be concurrent access by the CPU and
one or more DMA transfers within the buffer.

Reviewed by:	cognet
2014-07-29 02:36:41 +00:00
Ian Lepore
688e9d85f4 The run_filter() function doesn't just run dma tag exclusion filter
functions, it has evolved to make a variety of decisions about whether
the DMA needs to bounce, so rename it to must_bounce().  Rewrite it to
perform checks outside of the ancestor loop if they're based on information
that's wholly contained within the original tag.  Now the loop only checks
exclusion zones in ancestor tags.

Also, add a new function, might_bounce() which does a fast inline check
of flags within the tag and map to quickly eliminate the need to call
the more expensive must_bounce() for each page in the DMA operation.

Within the mapping loops, use map->pagesneeded != 0 as a proxy for all
the various checks on whether bouncing might be required.  If no pages
were reserved for bouncing during the checks before the mapping loop,
then there's no need to re-check any of the conditions that can lead
to bouncing -- all those checks already decided there would be no bouncing.

Reviewed by:	cognet
2014-07-29 02:36:27 +00:00
Ian Lepore
befb477022 Propagate any alignment restriction from the parent tag to a new tag,
keeping the more restrictive of the two values.

Reviewed by:	cognet
2014-07-29 02:36:09 +00:00
Ian Lepore
3de4bbe357 Reformat some continuation lines. No functional changes.
Reviewed by:	cognet
2014-07-29 02:36:02 +00:00
Ian Lepore
7b1ee35189 Correct the comparison logic when looking for intersections between
exclusion zones and phsyical memory.  The phys_avail[i] entries are the
address of the first byte of ram in the region, and phys_avail[i+1]
entries are the address of the first byte of ram in the next region
(i.e., they're not included in the region that starts at phys_avail[i]).

Reviewed by:	cognet
2014-07-29 02:35:44 +00:00
Ian Lepore
7c54a52475 The exclusion_bounce() routine compares unchanging values in the tag with
unchanging values in the phys_avail array, so do the comparisons just once
at tag creation time and set a flag to remember the result.

Reviewed by:	cognet
2014-07-29 02:34:32 +00:00
Ian Lepore
751428ce88 Rename _bus_dma_can_bounce(), add new inline routines.
DMA on arm can bounce for several reasons, and _bus_dma_can_bounce() only
checks for the lowaddr/highaddr exclusion ranges in the dma tag, so now
it's named exclusion_bounce().  The other reasons for bouncing are checked
by the new functions alignment_bounce() and cacheline_bounce().

Reviewed by:	cognet
2014-07-29 02:31:29 +00:00
Ruslan Bukin
4d3ff0c3e6 Add the rest of combined interrupt groups. 2014-07-28 05:37:10 +00:00
Ian Lepore
510b2cb75c Pull in the armv4 "fast out" code for checking whether busdma can bounce
due to an excluded region of physical memory.
2014-07-26 18:19:43 +00:00
Ian Lepore
9ec89d355f Remove completely bogus alignment check -- it's the physical address that
needs to be aligned, not the virtual, and it doesn't seem worth the cost
of a vtophys() call just to see if kmem_alloc_contig() works properly.
2014-07-26 18:14:16 +00:00
Gavin Atkinson
f6b4f5ca21 Add error return to dumpsys(), and use it in doadump().
This commit does not add error returns to minidumpsys() or
textdump_dumpsys(); those can also be added later.

Submitted by:	Conrad Meyer (EMC / Isilon storage division)
2014-07-25 23:52:53 +00:00
Ruslan Bukin
40d7d6323b Enable Freescale i.MX I2C driver for i.MX6. 2014-07-22 04:39:32 +00:00
Ruslan Bukin
484b4fd46c Rename i.MX I2C driver file. 2014-07-22 03:59:14 +00:00
Ian Lepore
677a88cec2 Add dl_unwind_find_exidx() for ARM EABI, required for C++ exception
handling.  For statically linked apps this uses the __exidx_start/end
symbols set up by the linker.  For dynamically linked apps it finds the
shared object that contains the given address and returns the location and
size of the exidx section in that shared object.

The dl_unwind_find_exidx() name is used by other BSD projects and Android,
and is mentioned in clang 3.5 comments as "the BSD interface" for finding
exidx data.  GCC (in libgcc_s) expects the exact same API and functionality
to be provided by a function named __gnu_Unwind_Find_exidx(), so we provide
that with an alias ("strong reference").

Reviewed by:	kib@
MFC after:	1 week
2014-07-19 22:13:27 +00:00
Ruslan Bukin
f040f3b317 Add support for Toradex Apalis i.MX6 development board.
Sponsored by:	Toradex AG
2014-07-18 08:23:53 +00:00
Ruslan Bukin
0495dcef49 Rename gpio driver file. 2014-07-18 07:52:35 +00:00
Ruslan Bukin
e18aa9229a o Enable GPIO device driver for i.MX6.
It was originally written for i.MX5 and compatible with newer chip.
o Extend device tree information
o style(9) fixes

Discussed with:	ian
2014-07-18 07:47:50 +00:00
Alan Cox
526ed91414 Implement pmap_unwire(). See r268327 for the motivation behind this change. 2014-07-16 21:06:43 +00:00
Alan Cox
87dd8ef960 Actually set the "no execute" bit on 1 MB page mappings in pmap_protect().
Previously, the "no execute" bit was being set directly in the PTE, instead
of the local variable in which the new PTE value is being constructed.  So,
when the local variable was finally assigned to the PTE, the "no execute"
bit setting was lost.
2014-07-15 17:16:06 +00:00
Alan Cox
c3c820296f Eliminate repeated calculation of next_bucket in pmap_protect() and
pmap_remove().  Eliminate an unnecessary variable from pmap_remove() and
pmap_advise().
2014-07-15 05:34:27 +00:00
Ian Lepore
0f822edead Fix the Zedboard/Zynq ethernet driver to handle media speed changes so
that it can connect to switches at speeds other than 1gb.

This requires changing the reference clock speed.  Since we still don't
have a general clock API that lets a SoC-independant driver manipulate its
own clocks, this change includes a weak reference to a routine named
cgem_set_ref_clk().  The default implementation is a no-op; SoC-specific
code can provide an implementation that actually changes the speed.

Submitted by:	Thomas Skibo <ThomasSkibo@sbcglobal.net>
2014-07-14 20:58:57 +00:00
Alan Cox
db3ddfd672 Eliminate dead code. There is no direct map. This code was cut-and-pasted
from amd64.
2014-07-14 17:16:09 +00:00
Ian Lepore
8d99c2a062 Pending interrupt status is cleared by writing to the ISR, not the data reg.
MFC after:	1 week
2014-07-10 14:06:18 +00:00
Ian Lepore
1e3d53c687 Use named constant rather than '0' to access the reset controller register. 2014-07-08 14:35:09 +00:00
Hans Petter Selasky
af3b2549c4 Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
Glen Barber
37a107a407 Revert r267961, r267973:
These changes prevent sysctl(8) from returning proper output,
such as:

 1) no output from sysctl(8)
 2) erroneously returning ENOMEM with tools like truss(1)
    or uname(1)
 truss: can not get etype: Cannot allocate memory
2014-06-27 22:05:21 +00:00
Hans Petter Selasky
3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2014-06-27 16:33:43 +00:00
Andrew Turner
8b04766b28 Remove the incomplete Tegra 2 code, nobody was maintaining it. The AC100
never booted to single user mode.

It can be brought back if someone is willing to get it into a stable state
and maintain it.
2014-06-22 15:15:52 +00:00
Michael Tuexen
2ff25a8b1c Different versions of the ARM processor use different registers.
Fix the code used on a Raspberry Pi.

Reviewed by: markm@
2014-06-17 21:48:04 +00:00
John Baldwin
a2677ff239 Don't bother clearing maps for static DMA allocations to NULL. Instead,
leave them as purely opaque values that are only set by bus_dmamem_alloc().
2014-06-17 18:10:06 +00:00
Attilio Rao
3ae10f7477 - Modify vm_page_unwire() and vm_page_enqueue() to directly accept
the queue where to enqueue pages that are going to be unwired.
- Add stronger checks to the enqueue/dequeue for the pagequeues when
  adding and removing pages to them.

Of course, for unmanaged pages the queue parameter of vm_page_unwire() will
be ignored, just as the active parameter today.
This makes adding new pagequeues quicker.

This change effectively modifies the KPI.  __FreeBSD_version will be,
however, bumped just when the full cache of free pages will be
evicted.

Sponsored by:	EMC / Isilon storage division
Reviewed by:	alc
Tested by:	pho
2014-06-16 18:15:27 +00:00
Ruslan Bukin
b9402e3d56 Add very basic driver for 12-bit Analog to Digital Converter (ADC). 2014-06-15 12:08:33 +00:00
John-Mark Gurney
4f4bd09dd1 clear the write bit... This allows my AVILA board to survive a
portsnap extract, where previously it would panic..  clearly someone
who knows pmap should optimize this code per alc's comment...

Submitted by:	alc
MFC after:	probably
2014-06-12 16:31:15 +00:00
Ruslan Bukin
d17024dfd7 Enable SMP for both Exynos5 models we support. 2014-06-12 11:44:26 +00:00
Ruslan Bukin
f0687d366a Activate IRQ 30 (non-secure private timer IRQ) for case we are running
in non-secure state.
2014-06-12 11:41:04 +00:00
Ruslan Bukin
f098889377 Add machine-dependent SMP part for Exynos5420 2014-06-12 11:37:38 +00:00
John Baldwin
068d8643ad Fix various NIC drivers to properly cleanup static DMA resources.
In particular, don't check the value of the bus_dma map against NULL
to determine if either bus_dmamem_alloc() or bus_dmamap_load() succeeded.
Instead, assume that bus_dmamap_load() succeeeded (and thus that
bus_dmamap_unload() should be called) if the bus address for a resource
is non-zero, and assume that bus_dmamem_alloc() succeeded (and thus
that bus_dmamem_free() should be called) if the virtual address for a
resource is not NULL.

In many cases these bugs could result in leaks when a driver was detached.

Reviewed by:	yongari
MFC after:	2 weeks
2014-06-11 14:53:58 +00:00
Ruslan Bukin
2aaaabd4c1 Add a driver for Serial Peripheral Interface (SPI). 2014-06-11 10:03:06 +00:00
John Baldwin
f07894dbde Don't destroy bus_dma maps created by bus_dmamem_alloc(). In some cases,
don't create a map before calling bus_dmamem_alloc() (such maps were
leaked).  It is believed that the extra destroy of the map was generally
harmless since bus_dmamem_alloc() often uses special maps for which
bus_dmamap_destroy() is a no-op (e.g. on x86).

Reviewed by:	scottl
2014-06-10 20:25:45 +00:00
Alan Cox
dd05fa1945 Add a page size field to struct vm_page. Increase the page size field when
a partially populated reservation becomes fully populated, and decrease this
field when a fully populated reservation becomes partially populated.

Use this field to simplify the implementation of pmap_enter_object() on
amd64, arm, and i386.

On all architectures where we support superpages, the cost of creating a
superpage mapping is roughly the same as creating a base page mapping.  For
example, both kinds of mappings entail the creation of a single PTE and PV
entry.  With this in mind, use the page size field to make the
implementation of vm_map_pmap_enter(..., MAP_PREFAULT_PARTIAL) a little
smarter.  Previously, if MAP_PREFAULT_PARTIAL was specified to
vm_map_pmap_enter(), that function would only map base pages.  Now, it will
create up to 96 base page or superpage mappings.

Reviewed by:	kib
Sponsored by:	EMC / Isilon Storage Division
2014-06-07 17:12:26 +00:00
Kevin Lo
6ed1354934 Remove extra semicolons. 2014-06-06 16:37:42 +00:00
Warner Losh
3f1afabf09 Restore comments accidentally removed.
MFC after: 3 days
2014-06-06 04:08:55 +00:00
Zbigniew Bodek
47fdf913c1 Avoid using hard-coded SoC's register address in mptramp code for Armada XP
SoC's registers base address may differ between boards
(0xf1000000 or 0xd0000000). Therefore, in order to use
the proper CPU Boot Address Redirect register during SMP
initialization in mptramp the real, physical address has
to be passed to mptramp based on the value from DT.

Reviewed by: gber
2014-06-05 21:37:04 +00:00
Zbigniew Bodek
d0307444ed Fix broken SMP startup on Armada XP after r265694
During Armada's platform_mp_start_ap(), mptramp code
is being copied to the specific physical location (0xffff0000).
Before r265694 the address to which the code should be copied
was equal to the address of mpentry routine that followed the
mptramp in locore.S. Now the mptramp end address should be
exported and used as a copy limit.

Reviewed by: gber
2014-06-05 21:35:10 +00:00
Luiz Otavio O Souza
d6cf3c637e FreeBSD, historically, has always used 8-bit addresses for i2c devices
(7-bit device address << 1), always leaving the room for the read/write bit.

This commit convert ti_i2c and revert r259127 on bcm2835_bsc to make them
compatible with 8-bit addresses.  Previous to this commit an i2c device
would have different addresses depending on the controller it was attached
to (by example, when compared to any iicbb(4) based i2c controller), which
was a pretty annoying behavior.

Also, update the PMIC i2c address on beaglebone* DTS files to match the new
address scheme.

Now the userland utilities need to do the correct slave address shifting
(but it is going to work with any i2c controller on the system).

Discussed with:	ian
MFC after:	2 weeks
2014-06-03 19:24:53 +00:00
Luiz Otavio O Souza
a673123f8c Remove the unnecessary i2c slave address assignment.
The ti_i2c controller only works in the master mode and the i2c address
passed on iicbus_reset() is used to set the controller slave address when
operating as an i2c slave (which isn't currently supported).

When talking to a slave, the slave address is correctly provided to
ti_i2c_tranfer().
2014-06-03 14:46:50 +00:00
Luiz Otavio O Souza
f7eebb7730 Configure the analog input 7 which, on BBB, is connected to the 3V3B rail
through a voltage divisor (R163 and R164 on page 4 of BBB schematic).

Add a note about this on ti_adc(4) man page.  The ti_adc(4) man page will
first appear on 10.1-RELEASE.

MFC after:	1 week
Suggested by:	Sulev-Madis Silber (ketas)
Manual page reviewed by:	brueffer (D127)
2014-06-02 02:00:17 +00:00
Ruslan Bukin
0cd354a070 Add ident value. This fixes universe build.
Pointed out by:	andrew
2014-06-01 17:09:02 +00:00
Ruslan Bukin
53dc9d3d9c Fix i2c communication interface to be compatible with
vendor tools, e.g. embedded controller tool

Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-06-01 08:45:27 +00:00
Ruslan Bukin
08ae4ac990 Rename exynos uart driver filenames. 2014-06-01 08:34:45 +00:00
Ruslan Bukin
1e57235626 Add support for Exynos 5420 Octa - 8-core
heterogeneous (big.LITTLE) ARM machine
(4 x Cortex-A15 @ 1.8Ghz, 4 x Cortex-A7 @ 1Ghz)

Add configuration for Arndale Octa development board
2014-06-01 08:15:34 +00:00
Ruslan Bukin
058a928e4c Do only receive chars if there are some data in the buffer.
This fixes operation on newer Exynos boards.
2014-06-01 07:34:54 +00:00
Ganbold Tsagaankhuu
80ce0850f4 Silence tinderbox build.
Approved by:    stas (mentor)
2014-06-01 05:02:48 +00:00
Luiz Otavio O Souza
b1b4b37f4d Export two new settings for the AM335x PWM, the clock prescaler (clkdiv)
and the actual PWM frequency.

Enforce the maximum value for the period sysctl.

The frequency systcl now allows the direct setting of the PWM frequency (it
will try to find the better clkdiv and period for a given frequency, i.e.
the ones that will give the better PWM resolution).

This allows the use lower frequencies on the PWM.  Without changing the
clock prescaler the minimum PWM frequency was 1.52kHz.

PWM frequencies checked with an osciloscope.

PWM output tested with some R/C servos at 50Hz.
2014-06-01 03:57:57 +00:00
Ganbold Tsagaankhuu
75dc1c319b Add #NO_UNIVERSE to RADXA and RADXA-LITE kernel configs
since there aren't any new devices in those files so unhook them
from universe build.

Approved by:    stas (mentor)
2014-05-31 06:17:34 +00:00
Ruslan Bukin
45d909c6dc Reset HSIC hub during EHCI initialization. This makes devices connected
to external USB ports available to the system.

Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-05-30 07:48:55 +00:00
Ruslan Bukin
46eac58237 Fix off-by-one error that makes 0-th pins of each bank unreachable.
Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-05-30 07:43:55 +00:00
Ruslan Bukin
17f65b3a8d o Make keyboard-related properties to be compatible with vendor standard
o Allow setting keymap in FDT, use hardcoded one by default
o Represent fallback keymap as a list rather than directly usable M*N array

Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-05-30 06:45:50 +00:00
Ganbold Tsagaankhuu
1a31ec5e51 Add common kernel config file for Rockchip RK3188 systems by splitting
current RADXA config. Radxa Rock (RR) boards have few types such as
RR (full version), RR Lite and some variants of RR engineering samples.
Add kernel config and FDT file for RR Lite board.

Approved by:	stas (mentor)
2014-05-30 06:37:06 +00:00
Rui Paulo
38235b4177 Cleanup the RADXA kernel config file a bit and enable modules. 2014-05-30 05:17:14 +00:00
Olivier Houchard
d489d1f51f Do not hand the VM the memory used for stacks/page tables/etc. 2014-05-29 16:56:39 +00:00
Olivier Houchard
cb07f5b377 For old CPUs, map the 64 first MB of RAM as it used to be. Some ports
(XScale mainly) expects the memory located before the kernel to be mapped,
and use it to allocate the page tables, the various stacks, etc.
A better fix would probably be to rewrite the various bla_machdep.c to stop
using that RAM, but I'm not so inclined to do it, especially since I don't
have hardware for all of them.
2014-05-29 16:54:15 +00:00
Hans Petter Selasky
ad76ab4299 Factor out kernel configuration for DWC OTG FDT attach code. 2014-05-29 11:13:40 +00:00
Ruslan Bukin
3863e61d2e Add simple polling mechanism that works for KDB.
Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-05-28 06:15:45 +00:00
Ruslan Bukin
ff4590bed7 Describe I2C arbitrator device in DTS and use it for Chromebook Snow only.
Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-05-28 06:11:12 +00:00
Ruslan Bukin
0cd10310ad o Add kernel configuration for HP Chromebook 11
o Use machine codename in filenames
o Add GEOM_PART_GPT kernel option

Submitted by:	Maxim Ignatenko <gelraen.ua@gmail.com>
2014-05-28 06:00:55 +00:00
Andrew Turner
4eb12144c0 Rework the Ti GPIO driver to work on multiple SoCs. At the moment it could
work with OMAP4 and AM335x without needing to recompile.

Reviewed by:	loos
2014-05-26 18:02:36 +00:00
Zbigniew Bodek
1e17cf74b6 Delete obsolete and unused PJ4B CPU functions
Since PJ4Bv7 uses armv7_ CPU functions only pj4b_config
function is necessary. Remove obsolete routines.
2014-05-25 19:19:41 +00:00
Zbigniew Bodek
fd31d8bb75 Fix context switch on PJ4Bv7 and remove obsolete pj4b_/arm11 functions
Use armv7_setttb that sets proper PT attributes.
Get rid of unused CPU functions, put nullop instead.
Exchange obsolete pj4b_/arm11_ functions to the appropriate armv7_ ones.
2014-05-25 18:47:24 +00:00
Ian Lepore
cd21da8083 Fix whitespace glitches.
Pointed out by:	jhb
2014-05-25 14:01:30 +00:00
Andrew Turner
77a732bda5 Make ti_padconf_devmap static in both places it is defined. 2014-05-25 10:56:45 +00:00
Andrew Turner
0a8c1fdf5a Allow the OMAP4 and AM335x prcm drivers to be compiled in the same kernel
by renaming the structures used.
2014-05-25 10:49:07 +00:00
Andrew Turner
8166c218e6 Reduce the diff between the PandaBoard and BeableBone kernel configs to
help with the creation of a more generic Ti kernel config.
2014-05-25 10:17:26 +00:00
Zbigniew Bodek
94831f6d21 Enable automatic superpages promotion by default on ARMv6/v7
From now on superpages are enabled by default on ARM.
One can still disable superpages utilization by adding:

vm.pmap.sp_enabled=0

to loader.conf
2014-05-24 22:46:00 +00:00
Ian Lepore
11d47032ee Eliminate one of the causes of spurious interrupts on armv6. The arm weak
memory ordering model allows writes to different devices to complete out
of order, leading to a situation where the write that clears an interrupt
source at a device can complete after a write that unmasks and EOIs the
interrupt at the interrupt controller, leading to a spurious re-interrupt.

This adds a generic barrier function specific to the needs of interrupt
controllers, and calls that function from the GIC and TI AINTC controllers.
There may still be other soc-specific controllers that need to make the call.

Reviewed by:	cognet, Svatopluk Kraus <onwahe@gmail.com>
MFC after:	3 days
2014-05-24 16:21:16 +00:00
Warner Losh
32d5c97723 Remove NetBSD implementation details not relevant to FreeBSD. 2014-05-23 00:21:02 +00:00
Ian Lepore
97bbab9993 Map device memory using PTE_DEVICE attributes, and also ensure that the
shared flag is set on normal-memory mappings made via pmap_kenter() for SMP.

The "shared flag" part of this change isn't obvious from the diff, here's
the deal... by using the array of preformatted page table entry templates
instead of constructing the PTE from scratch, we automatically get the
right attribute bits set for both caching and shared.

MFC after:	1 week
2014-05-22 23:38:17 +00:00
Hans Petter Selasky
5c657683bb Optimise reading of pending interrupt registers. If there are no
pending interrupt bits, skip the bit iteration loop.

Reviewed by:	ian @
2014-05-20 15:03:23 +00:00
Andrew Turner
101355bc67 Allow us to compile the Ti iic driver for both OMAP4 and AM335x.
MFC after:	1 week
2014-05-17 18:52:20 +00:00
Andrew Turner
f37128c048 Move the Ti SoCs to use the ARM platform. This should help allowing a
single kernel to work on both PandaBoard and BeagleBone.
2014-05-17 18:35:22 +00:00
Andrew Turner
87ff982083 Add FDT_PLATFORM_DEF2 for when there are multiple platforms needing to use
the same platform methods.
2014-05-17 18:02:46 +00:00
Andrew Turner
92e7f50a4e Fix a comment s/initarm_/platform_/ 2014-05-17 11:29:44 +00:00
Andrew Turner
27521ff8e4 Add the start of the ARM platform code. This is based on the PowerPC
platform code, it is expected these will be merged in the future when the
ARM code is more complete.

Until more boards can be tested only use this with the Raspberry Pi and
rrename the functions on the other SoCs.

Reviewed by:	ian@
2014-05-17 11:27:36 +00:00
Gavin Atkinson
015280f64c Fix spelling mistake in comment.
Spotted during:	http://www.bsdcan.org/2014/schedule/events/484.en.html
2014-05-16 21:20:13 +00:00
Ruslan Bukin
3d0bf6b1d0 Fix return value. Should be logic one or zero. 2014-05-15 10:06:59 +00:00
Mark Murray
7ff2eaaad3 Give suitably-endowed ARMs a register similar to the x86 TSC register.
Here, "suitably endowed" means that the System Control Coprocessor
(#15) has Performance Monitoring Registers, including a CCNT (Cycle
Count) register.

The CCNT register is used in a way similar to the TSC register in
x86 processors by the get_cyclecount(9) function. The entropy-harvesting
thread is a heavy user of this function, and will benefit from not
having to call binuptime(9) instead.

One problem with the CCNT register is that it is 32-bit only, so
the upper 32-bits of the returned number are always 0. The entropy
harvester does not care, but in case any one else does, follow-up
work may include an interrup trap to increment an upper-32-bit
counter on CCNT overflow.

Another problem is that the CCNT register is not readable in user-mode
code; in can be made readable by userland, but then it is also
writable, and so is a good chunk of the PMU system. For that reason,
the CCNT is not enabled for user-mode access in this commit.

Like the x86, there is one CCNT per core, so they don't all run in
perfect sync.

Reviewed by:	ian@ (an earlier version)
Tested by:	ian@ (same earlier version)
Committed from:	WANDBOARD-QUAD
2014-05-14 19:11:15 +00:00
Ruslan Bukin
876ac29ddc Fix typo. 2014-05-14 14:19:57 +00:00
Aleksandr Rybalko
279204f2e0 Remove extra newlines.
No functional changes.

Sponsored by:	The FreeBSD Foundation
2014-05-14 11:15:48 +00:00
Ian Lepore
ad622f7078 Cleanup some style nits. 2014-05-12 13:08:37 +00:00
Ian Lepore
02bb9ba1cc Interrupts need to be disabled on entry to cpu_sleep() for ARM. Given
that and the need to be in a critical section when switching to idleclock
mode for event timers, use spinlock_enter()/exit() to achieve both needs.

The ARM WFI (wait for interrupt) instruction blocks until an interrupt is
asserted, and it will unblock even if interrupts are masked, and it will
unblock immediately if an interrupt is already pending.  It is necessary
to execute it with interrupts disabled, otherwise the interrupt that
should unblock it may occur and be serviced just prior to executing the
instruction.  At that point the system is inappropriately asleep until
the next timer tick or some other random interrupt happens.

In general, interrupts need to be disabled continuously from the time the
decision is made that there is no work to be done and sleeping is needed
until actually going to sleep, to avoid a race where handling a new
interrupt changes the basis for deciding there is no work to be done.

Submitted by:	hps@ (in slightly different form)
2014-05-12 13:05:03 +00:00
Ian Lepore
b07d0cbce3 Add cpu_l2cache_drain_writebuf(), use it to implement generic_bs_barrier().
On modern ARM SoCs the L2 cache controller sits between the CPU and the
AXI bus, and most on-chip memory-mapped devices are on the AXI bus.  We
map the device registers using the 'Device' memory attribute, which means
the memory is not cached, but writes to it are buffered.  Ensuring that a
write has made it all the way to a device may require that the L2
controller take some action.

There is currently only one implementation of the new function, for the
PL310 cache controller.  It invokes a function that the controller
manual calls "cache sync" but it actually has nothing to do with cache at
all, it triggers a drain of all pending store buffer writes and it blocks
until they complete.

The sheeva and xscale L2 controllers (which predate the concept of Device
memory) don't seem to have a corresponding function.  It appears that the
standard armv5 drain_writebuf function includes draining all the way
through the L2 controller.
2014-05-11 04:24:57 +00:00
Peter Grehan
ffd328487a Enable SMP for Exynos-based platforms (i.e. Chromebook)
Reviewed by:	br
2014-05-11 04:18:51 +00:00
Ian Lepore
6af0d51bce Make the hardware memory and instruction barrier functions work on armv4
and armv5 as well.
2014-05-11 00:43:06 +00:00
Andrew Turner
b36b897e51 Rename platform_gpio_init to be SoC specific 2014-05-10 21:30:19 +00:00
Andrew Turner
87ef4d1f85 Rename platform_gpio_init to be platform specific, and make it static as
it's only used from this file.
2014-05-10 20:31:05 +00:00
Andrew Turner
3664cbc0f0 Rename platform_gpio_init to be SoC specific, and make it static as it's
only called from this file.
2014-05-10 20:26:49 +00:00
Ian Lepore
b8821f8415 When mapping device memory, use PTE_DEVICE rather than PTE_NOCACHE.
On armv4 these are defined as synonyms right now, but it's a bit ambiguous
what NOCACHE means (is buffering/write-combining also enabled or not?); this
is a first step towards replacing PTE_NOCACHE with a less ambiguous name.
2014-05-10 20:03:03 +00:00
Ian Lepore
dfd03689d7 Call idcache_inv_all from the AP core entry code before turning on the MMU.
Also, enable instruction and branch caches, which should be safe now that
they're properly initialized/invalidated first.
2014-05-09 19:14:34 +00:00
Ganbold Tsagaankhuu
08d56ebf0a Add the codes for enabling CPU cores of Rockchip RK3188 SoC.
Enable SMP for Radxa Rock board.

Approved by:	stas (mentor)
2014-05-09 05:39:57 +00:00
Ian Lepore
9f8e153645 Consolitate all the AP core startup stuff under a single #ifdef SMP block.
Remove some other ifdefs that came in with a copy/paste that mean basically
"if this processor supports multicore stuff", because if you're starting up
an AP core... it does.
2014-05-08 20:02:38 +00:00
Ian Lepore
f296249f58 Move the mptramp code which is specific to the Marvell ArmadaXP SoC out of
the common locore.S file and into the mv/armadaxp directory.
2014-05-08 18:36:42 +00:00
Ian Lepore
0bd55d38ec Use edge-triggered interrupts rather than polling loops to avoid missing
transitions of the INIT_B line.  Also, release the mutex during uiomove().

Submitted by:	Thomas Skibo <ThomasSkibo@sbcglobal.net>
2014-05-08 17:20:45 +00:00
Ian Lepore
95da66135d Enable PL310 power-saving modes and tune the cache ram latencies for imx6. 2014-05-06 14:26:24 +00:00
Ian Lepore
334b9c79c3 Add a public routine to set the L2 cache ram latencies. This can be
called by platform init routines to fine-tune cache performance.
2014-05-06 14:19:54 +00:00
Ian Lepore
7b41388248 Add defines for the bits in the PL310 debug control register.
This should have been part of r265444.
2014-05-06 14:08:42 +00:00
Ian Lepore
b450e1090d Call platform_pl310_init() before enabling the controller, and handle the
case where the controller is already enabled.

Some of the pl310 configuration registers cannot be changed while the
controller is active, so if there is any platform-specific init to be done
it must happen before enabling the controller.

The controller should not be enabled upon entry to the kernel, but u-boot
has recently developed the bad habit of leaving caches enabled when
launching the kernel, and since we have no control over that source code
we have to do our best to cope with it.  The PL310 manual doesn't document
a safe sequence for disabling the controller, but the sequence used here
(force write-through mode and disable linefill allocations, then clean and
invalidate the current contents before disabling the hardware) appears to
be sound both by analysis and empirical testing.

These changes were developed and tested in collaboration with
Svatopluk Kraus <onwahe@gmail.com>.

Reviewed by:	cognet@
2014-05-06 14:03:35 +00:00
Ian Lepore
9925f09b81 Break out the code that figures out the L2 cache geometry to its own
routine, so that it can be called from multiple places in upcoming changes.
2014-05-06 13:46:36 +00:00
Ian Lepore
a787d4c699 Move the pl310.enabled tunable to hw.pl310.enabled. Clean up a few minor
style(9) nits.  Use DEVMETHOD_END.
2014-05-06 13:38:34 +00:00
Luiz Otavio O Souza
1deba728cd Fix the tinderbox armv6/arm build failure.
VYBRID code depends on FDT.
2014-05-03 03:40:36 +00:00
Ganbold Tsagaankhuu
b4ce42b4b8 Switch to use arm_devmap_add_entry() to setup static device mapping.
Approved by:	stas (mentor)
2014-05-02 01:20:13 +00:00
Warner Losh
9f06808398 This was copied to IMX6, which has since evolved further. Remove this
as it is no longer needed.
2014-04-30 18:02:19 +00:00
Warner Losh
7621eebbb1 Omit from the universe build all config files tagged with
#NO_UNIVERSE. Many of these config files are important examples, but
add little to no regresive value to the intended purpose of
UNIVERSE. We now build over 120 kernels during universe. There's
really little to no value to this over building say 60 or even 30 of
them (either is still a way too big number). This is especially true
for kernels that are nothing more than including a common base and
adding a static DTB file. Start by pruning 1/3 of the arm kernels that
add little regresion value.
2014-04-30 18:02:10 +00:00
Ian Lepore
4c05359867 Convert the Zynq SoC support to the new routines for static device mapping. 2014-04-30 14:38:13 +00:00
Ian Lepore
457e64a02f Make this declaration into a proper function prototype. 2014-04-29 23:29:28 +00:00
Ian Lepore
06177e52c9 Add SMP support for Zedboard.
Submitted by:	Thomas Skibo <ThomasSkibo@sbcglobal.net>
2014-04-29 17:48:57 +00:00
Ian Lepore
440fe55df6 Don't use multiprocessing-extensions instruction on processors that don't
support SMP.

Submitted by:	loos@
Pointy hat to:	me
2014-04-28 02:35:28 +00:00
Ian Lepore
88b3694bd9 Move duplicated code to print l2 cache config into the common code. 2014-04-27 23:47:38 +00:00
Ian Lepore
f62cbe0e49 Explain why wbinv_all is SMP-safe in this case, and add a missing l2 cache
flush.  (Either it was missing here, or it isn't needed in the minidump
case.  Adding it here seems like the safer path to consistancy.)
2014-04-27 20:26:15 +00:00
Ian Lepore
fa046341af Flush and invalidate caches on each CPU as part of handling IPI_STOP.
Flushing the caches is required before doing a panic dump, but ARM
doesn't provide a flavor of flush that gets broadcast to other cores.
However, all cores except one are stopped before doing a dump, so this
works around the lack of a global flush/invalidate by doing it locally
on each CPU as part of stopping.

Discussed with:	cognet@
2014-04-27 20:16:51 +00:00
Ian Lepore
824e4131a0 There is no difference between IPI_STOP and IPI_STOP_HARD on ARM, so
map them both to the same interrupt number like other arches do.
2014-04-27 20:01:59 +00:00
Ian Lepore
edecf7f6c1 Remove cpu_idcache_wbinv_all() from kdb_cpu_trap(), it's no longer needed.
This was added ca. 2004 for the purpose of ensuring the caches were in the
right state after the debugger set a breakpoint.  kdb_cpu_sync_icache()
was added in 2007 to handle that situation, and now the wbinv_all is
actually harmful because the operation isn't broadcast to other cores.
2014-04-27 18:12:55 +00:00
Ian Lepore
91c650065a Provide a proper armv7 implementation of icache_sync_all rather than
using armv7_idcache_wbinv_all, because wbinv_all doesn't broadcast the
operation to other cores.  In elf_cpu_load_file() use icache_sync_all()
and explain why it's needed (and why other sync operations aren't).

As part of doing this, all callers of cpu_icache_sync_all() were
inspected to ensure they weren't relying on the old side effect of
doing a wbinv_all along with the icache work.
2014-04-27 00:46:01 +00:00
Ian Lepore
75c95895f5 Call cpu_icache_sync_range() rather than sync_all since we know the range
and flushing the entire icache is needlessly expensive.
2014-04-26 23:09:01 +00:00
Scott Long
60ad8150c7 Retire smp_active. It was racey and caused demonstrated problems with
the cpufreq code.  Replace its use with smp_started.  There's at least
one userland tool that still looks at the kern.smp.active sysctl, so
preserve it but point it to smp_started as well.

Discussed with: peter, jhb
MFC after: 3 days
Obtained from: Netflix
2014-04-26 20:27:54 +00:00
Ian Lepore
a7fa939bb3 Stop calling imx51_ccm_foo() clock functions from imx6 code. Instead
define a few imx_ccm_foo() functions that are implemented by the imx51 or
imx6 ccm code.  Of course, the imx6 ccm code is still more a wish than
reality, so for now its implementations just return hard-coded numbers.
2014-04-26 16:48:09 +00:00
Ian Lepore
49f85c3edb Remove uncessary cache and TLB maintenance ops.
- These were needed on armv4/5 (VIVT cache), not needed on armv6.
 - The wbinv_all call can't be used on SMP systems; cache operations by
   set/way are not broadcast to other cores.
 - The TLB maintenance operations needed for pmap_growkernel() happen in
   pmap_grow_l2_bucket(), so there's no need to flush all TLB entries at
   the end.
 - There may not be any need for the TLB flush at the beginning of
   pmap_release(), but it's left in for now pending more investigation.

Pointed out by:	   Svatopluk Kraus <onwahe@gmail.com>
Discussed with:	   cognet@
2014-04-20 18:21:05 +00:00
Rui Paulo
9e63671c57 Updates to i.MX53:
* Define support for the SDHCI driver, although it doesn't work yet
* Fix the memory mappings for IPU [1]

Reviewed by:	ray [1]
2014-04-08 04:05:04 +00:00
Rui Paulo
9d3cc729fb Move sys/arm/econa to sys/arm/cavium/cns11xx. 2014-04-07 05:33:30 +00:00
Ian Lepore
0b7d5b8f89 Tell VM we now have ARM platforms with physically discontiguous memory. 2014-04-06 21:40:39 +00:00
Luiz Otavio O Souza
1f1e8f1681 Partially revert r264083.
While it is the recommended initialization procedure, it hangs on the reset
of the second GPIO module on pandaboard.

Removes the module reset for now as more investigation would be needed.

Reported by:	jceel
2014-04-06 17:09:51 +00:00
Ian Lepore
2d1e88da97 Add a couple more required TLB flushes.
These should have been part of r264129, they are part of the overall set
of changes that got several weeks of testing.  I must have fumbled them
while merging various patchsets.
2014-04-06 00:17:41 +00:00
Rui Paulo
87c6502bba Follow files.imx51 and add vt support. 2014-04-05 23:16:51 +00:00
Rui Paulo
9fe6f910fd Remove code under PMAP_CACHE_VIVT that is not compiled anymore.
This is for ARMv4/ARMv5 and it doesn't belong in ARMv6 code.

Reviewed by:	ian
2014-04-05 18:13:28 +00:00
Luiz Otavio O Souza
db8a14ec74 - Fix the setup of interrupts for banks 2 and 3 on AM335x.
On AM335x each one of the four GPIO banks has two physical interrupt
    lines, so we now allocate resources and setup our interrupt handler for
    all the (8) available interrupts.

    On OMAP3 and OMAP4 there is only one interrupt for each GPIO bank (6
    banks, 6 interrupts), but there are two set of registers where the
    first one is used to setup the delivery of interrupts to the MPU and
    the second set, setup the delivery of interrupts to the DSP.

    On AM335x, each set of registers controls each one of the interrupt
    lines.

- Remove nonexistent registers for OMAP4 and AM335x, replace their use with
  the correct ones for these SoCs.

- Remove stray whitespace.

Based on OMAP3, OMAP4 and AM335x TRMs.

Tested on Beaglebone-black.
2014-04-05 17:53:59 +00:00
Ruslan Bukin
11a99c6984 Correct the end address of the video frame buffer.
This fixes problem that sometimes display suddenly
goes blank.
2014-04-05 16:38:27 +00:00
Ian Lepore
78806b5ec8 Enable SMP for Pandaboard. 2014-04-04 20:58:45 +00:00
Ian Lepore
de6a23b300 Switch wandboards over to the common IMX6 kernel config, which has SMP
enabled.  Also switch IMX6 to use SCHED_ULE.

The now-unreferenced WANDBOARD.common config will be deleted after giving
folks who may be including it a heads-up to switch to IMX6.
2014-04-04 20:42:44 +00:00
Ian Lepore
e69ba7c708 We don't support any ARM systems with an ISA bus and don't need a freelist
of memory to support ISA addressing limitations.
2014-04-04 19:35:38 +00:00
Ian Lepore
24ca71778e Allocate per-cpu resources for doing pmap_zero_page() and pmap_copy_page().
This is performance enhancement rather than bugfix.
2014-04-04 17:57:49 +00:00
Ian Lepore
a2f5bf29cd Fix TLB maintenance issues for armv6 and armv7.
- Add cpu_cpwait to comply with the convention.
  - Add missing TLB invalidations, especially in pmap_kenter & pmap_kremove
    with distinguishing between D and ID pages.
  - Modify pmap init/bootstrap invalidations to ID, just to be safe.
  - Fix TLB-inv and PTE_SYNC ordering.

This combines changes submitted by ian@, cognet@, and Wojciech Macek,
which have all been tested together as a unit.
2014-04-04 17:45:39 +00:00