Commit Graph

138 Commits

Author SHA1 Message Date
Andrew Turner
087af50ab8 Include vm/pmap.h for pmap_kextract. 2015-04-04 23:03:11 +00:00
Andrew Turner
ff3b52bb19 Stop using machine/fdt.h in the arm kernel code when we don't need it. 2015-04-04 21:34:26 +00:00
Andrew Turner
0ebebb1260 Build the cpufunc_asm_* files based on the cpu type, not which config file
we happen to be building.
2015-03-29 22:43:39 +00:00
Andrew Turner
760b9ede07 We only need cpufunc_asm_arm11.S on bcm2835, not bcm2836 2015-03-29 20:21:59 +00:00
Andrew Turner
745202c280 We don't use cpufunc_asm_armv5.S in any of these configs, remove it. 2015-03-29 18:41:43 +00:00
Andrew Turner
33a00de2dd Remove a debug #error from the bcm2835 sdhci driver. 2015-03-25 11:53:52 +00:00
Andrew Turner
4e46a66e4a Add support for the Raspberry Pi 2. As the chip is based on the bcm2835 in
the Raspberry Pi B we support most of the devices are already supported,
however the base address has changed.

A few items are not working, or missing. The main ones are:
 * DMA doesn't work in the sdhci driver.
 * Enabling vchiq halts the boot, may be interrupt related.
 * There is no U-Boot port yet so the DTB is embedded in the kernel.

The last point will make it difficult to boot FreeBSD, however there is
support for the Raspberry Pi 2 in the U-Boot git repo. As I have not tested
this it is left as an open task to create a port to build.

X-MFC:		When the above issues are fixed
Sponsored by:	ABT Systems Ltd
2015-03-25 10:59:42 +00:00
Andrew Turner
c375a72167 Move including std.bcm2835 to the RPI-B kernel config. The std.rpi file
will be shared between the existing Raspberry Pi config, and the new
Raspberry Pi 2 config.

MFC after:	1 week
2015-03-24 19:01:42 +00:00
Andrew Turner
e68fcb030d Add the SOC_BCM2835 and SOC_BCM2836 options for the arm kernel and add the
former to std.bcm2835. These will be used to enable support for the
Raspberry Pi 2.

MFC after:	1 week
2015-03-24 18:46:01 +00:00
Andrew Turner
27eb3304cd Add a helper function to read clock frequencies from videocore and use this
to get the default frequency of the sdhci device.

While here use a u_int to hold the frequency as it may be too large to fit
in a 32-bit signed integer. This is the case when we have a 250MHz clock.
2015-03-20 16:54:21 +00:00
Andrew Turner
e5e85011ae Split out the common bcm283x fixes from the bcm2835 specific files. 2015-03-20 14:25:51 +00:00
Andrew Turner
df0968e45e Remove now unneeded headers from the Broadcom DWC driver 2015-03-20 14:23:40 +00:00
Andrew Turner
b812d0ad85 Move the code to set the device power to the bcm2835 mailbox driver so it
can be reused by other drivers.
2015-03-20 14:16:39 +00:00
Andrew Turner
686513878d Call config_intrhook_disestablish on failure of the bcm2835 fb and fbd intr
hooks. With this we can get through the boot even if these functions fail.

Sponsored by:	ABT Systems Ltd
2015-03-08 14:15:57 +00:00
Andrew Turner
8f3ad0f84e Add support for enabling the USB on the Raspberry Pi boards when it hasn't
been done by U-Boot. This allows the USB to work when we load the kernel
directly.

No dma sync is performed after these operations as the data we read/write
is not used by the cpu after the calls to the maimbox driver.

Differential Revision:	https://reviews.freebsd.org/D1940
Reviewed by:	imp, Michal Meloun (meloun AT miracle.cz)
MFC after:	1 Week
Sponsored by:	ABT Systems Ltd
2015-03-08 13:52:07 +00:00
Andrew Turner
d792cd9231 Add support to the bcm2835 mailbox driver to work before interrupts are
enabled. This will be needed to enable the power on devices early on in the
boot process.
2015-02-22 11:11:05 +00:00
Luiz Otavio O Souza
5508fc88ba Make use of the newly introduced macros.
Update the copyright.
2015-02-17 20:37:21 +00:00
Luiz Otavio O Souza
b4ae2f3c55 Add a mask to match only the relative base address of BSC controllers.
This should fix the attach of BSC on RPI2 (based on andrew@ dmesg).
2015-02-16 19:06:31 +00:00
Andrew Turner
88cb7e2852 Add the structures needed to get/set the power state. These can be used
when, for example, we boot without U-Boot and wish to enable USB, or to
suspend an unneeded device.

MFC after:	1 week
2015-02-15 11:23:27 +00:00
Oleksandr Tymoshenko
2f99b597e0 Add VideoCore audio driver for Rasperry Pi (BCM2835) 2015-02-08 01:12:40 +00:00
Oleksandr Tymoshenko
939099221b Make VCHI driver optional and add "device vchiq" to default RPI-B config 2015-02-07 01:03:45 +00:00
Oleksandr Tymoshenko
262f27b29e Import VCHI driver for Broadcom's VideoCore IV GPU
Differential Revision:	D1753
2015-02-05 19:54:03 +00:00
Luiz Otavio O Souza
12471cec7c Add GPIO interrupt support for BCM2835 (Raspberry pi).
With this commit any of the GPIO pins can now be programmed to act as an
interrupt source for GPIO devices (i.e. limited to devices directly
attached to gpiobus - at least for now).

Differential Revision:	https://reviews.freebsd.org/D1000
2015-02-04 18:15:28 +00:00
Luiz Otavio O Souza
e74d6e2a12 Sort and remove unnecessary includes. 2015-02-04 17:23:02 +00:00
Luiz Otavio O Souza
d86f31b96b Remove stale comments about the issues with HS mode.
Remove a previous workaround to limit the minimum sdhci frequency that
isn't needed anymore.
2015-02-04 16:36:51 +00:00
Luiz Otavio O Souza
07c7a520f1 Remove some duplicate calls to bus_release_resource() and destroy the mutex
on error cases.

While here remove unnecessary includes.
2015-02-04 16:21:45 +00:00
Luiz Otavio O Souza
7836352b50 Implement GPIO_GET_BUS() method for all GPIO drivers.
Add helper routines to deal with attach and detach of gpiobus and gpioc
devices that are common to all drivers.
2015-01-31 19:32:14 +00:00
Luiz Otavio O Souza
c213658943 The BCM2835 GPIO controller uses has interrupt lines and not only one.
Allocate all four, we will use them soon.

Simplificate the allocation of memory and interrupt resources with a single
bus_alloc_resources() call instead of doing them separately.

Destroy the mutex in case of errors.
2015-01-30 18:18:09 +00:00
Luiz Otavio O Souza
99a2011188 Allow the retrieving of the reserved pins state.
With this change, it is now possible to verify the pin function and level
of reserved pins (but not set them).

The use of reserved pins on Raspberry pi can lead to short circuits and
real damage to the SoC.

While here, remove duplicated code, make use of OF_getencprop_alloc()
instead of using fixed sized variables and reduce the dmesg spam by
printing reserved pin ranges (when possible) instead of printing each pin
in the range.
2015-01-30 14:35:04 +00:00
Ian Lepore
eb8711ce16 Rename bus_space-v6.c to bus_space_base.c, because it's not v6-specific
and now some v5 Marvell systems are using it.  Only define fdt_bus_tag
if option FDT is defined.
2015-01-21 03:44:29 +00:00
Ian Lepore
86ee58d992 Save the command-and-flags value into the shadow register when it is written.
This doesn't actually change any behavior, because it just allows a 16-bit
read of the command register to return the correct value, and nothing
actually does a 16-bit read of that register.
2015-01-18 20:47:21 +00:00
Ian Lepore
bba987dc50 Add a new SDHCI quirk, SDHCI_QUIRK_DONT_SET_HISPD_BIT. Apparently some
sdhci controllers, such as the one on a Raspberry Pi, mishandle the signal
timing in high speed signaling mode, but run just fine in standard mode
with the bus running at frequencies between 25-50MHz (which shouldn't work).

This is the solution adopted by U-Boot and other OSes (linux and *BSD)
for the timeouts on Raspberry Pi boards with certain SD cards.  Some
research shows that this quirk is also used on a few other boards, so the
fix is a generic quirk instead of being in the RPi-specific driver code.

This change is based on information discovered by Michal Meloun.
2015-01-17 19:57:03 +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
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
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
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
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
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
171af33c53 Reduce the diff between head and arm_intrng with the bcm2835 interrupt
controller.
2014-12-21 16:35:42 +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
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
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