Commit Graph

125 Commits

Author SHA1 Message Date
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
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
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
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
Luiz Otavio O Souza
e50c624155 Add an iicbus_reset() method to bcm2835_bsc. While it is generally not
used for kernel devices it is used by i2c(8).

This fix the 'error: Device not configured' when i2c(8) tries to reset the
controller, as an example:

# i2c -r
Resetting I2C controller on /dev/iic0: error: Device not configured

For now use conservative settings for default i2c speeds.

MFC after:	1 week
2014-10-24 22:06:21 +00:00
Luiz Otavio O Souza
71b37cb9ae Fix the mtx_sleep() error checking, catch all errors and not only
EWOULDBLOCK.

Do not print any message at errors.  The errors are properly sent to upper
layers which should be able to deal with it, including printing the errors
when they need to.

The error message was quite annoying while scanning the i2c bus.

MFC after:	1 week
2014-10-20 18:04:20 +00:00
Luiz Otavio O Souza
a141b6722c Add another wakeup() after actually set the bus as free.
This fix a race where the threads waiting for the bus would wake up early
and still see bus as busy.

While here, give a better description to wmesg for the two use cases we
have (bus and io waiting).

MFC after:	1 week
2014-10-20 13:36:52 +00:00
Luiz Otavio O Souza
7c26b0a7c8 Add a workaround needed to fix a bug of Arasan Host Controller where it may
lose the contents of consecutive writes (that happens within two SD card
clock cycles).

This fixes the causes of instability during the SD card detection and
identification on Raspberry Pi (which happens at 400 kHz and so was much
more vulnerable to this issue).

Remove the previous workaround which clearly can't provide the same effect.

MFC after:	1 week
Relnotes:	yes
2014-10-18 19:01:07 +00:00
Ian Lepore
8c8f31e7b2 sdhci.h has grown a dependency on sysctl.h, include the latter where needed. 2014-09-01 19:20:34 +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
Hans Petter Selasky
ad76ab4299 Factor out kernel configuration for DWC OTG FDT attach code. 2014-05-29 11:13:40 +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
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
Aleksandr Rybalko
279204f2e0 Remove extra newlines.
No functional changes.

Sponsored by:	The FreeBSD Foundation
2014-05-14 11:15:48 +00:00