Commit Graph

70 Commits

Author SHA1 Message Date
Nathan Whitehorn
65d08437ef Move Open Firmware device root on PowerPC, ARM, and MIPS systems to
a sub-node of nexus (ofwbus) rather than direct attach under nexus. This
fixes FDT on x86 and will make coexistence with ACPI on ARM systems easier.
SPARC is unchanged.

Reviewed by:	imp, ian
2014-02-05 14:44:22 +00:00
Ian Lepore
add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
to check the status property in their probe routines.

Simplebus used to only instantiate its children whose status="okay"
but that was improper behavior, fixed in r261352.  Now that it doesn't
check anymore and probes all its children; the children all have to
do the check because really only the children know how to properly
interpret their status property strings.

Right now all existing drivers only understand "okay" versus something-
that's-not-okay, so they all use the new ofw_bus_status_okay() helper.
2014-02-02 19:17:28 +00:00
Andrew Turner
979d76c948 Remove STARTUP_PAGETABLE_ADDR from the ARM configs and replace it with
memory at the end of the kernel.

This helps reduce the SoC and board specific configuration required.

Reviewed by:	bsdimp
Tested by:	jmg (armeb), br
2014-01-28 09:12:04 +00:00
Ian Lepore
fdadb971af Switch to using arm_devmap_add_entry() to set up static device mapping.
This eliminates the hard-coded max kva and roughly doubles the available
kva space.
2014-01-06 15:48:16 +00:00
Ian Lepore
170e15fb4c Add #include <machine/fdt.h> to a few files that used to get it via
pollution from other headers.
2014-01-05 20:09:51 +00:00
Aleksandr Rybalko
86b04d42ec Fix copyright and some style(9) things.
Sponsored by:	The FreeBSD Foundation
2013-12-17 15:34:38 +00:00
Aleksandr Rybalko
0f705e869b Add vt support for RPi. (No early stage yet.)
Sponsored by:	The FreeBSD Foundation
2013-12-17 15:23:47 +00:00
Luiz Otavio O Souza
7f6897133f Bring the RPi I2C driver in line with ti_i2c. Make it treat any slave
address as a 7-bit address.

Approved by:	adrian (mentor)
2013-12-09 12:01:17 +00:00
Luiz Otavio O Souza
1fbabb4886 Make the sysctl node read-only.
Approved by:	adrian (mentor)
2013-12-06 17:45:14 +00:00
Eitan Adler
7a22215c53 Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit.  Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with:	-arch, rdivacky
Reviewed by:	cperciva
2013-11-30 22:17:27 +00:00
Luiz Otavio O Souza
21cb1342c0 As all the IIC controllers on system uses the same 'iichb' prefix we cannot
rely only on checking the device unit to indentify the BSC unit we are
attaching to.  Make use of the device base address to identify our BSC unit.

Approved by:	adrian (mentor)
2013-11-12 13:34:07 +00:00
Ian Lepore
10f52325db Switch to the new common bus_space-v6.c, remove the local one. 2013-11-07 04:02:08 +00:00
Nathan Whitehorn
5cd2b97cd0 Teach nexus(4) about Open Firmware (e.g. FDT) on ARM and MIPS, retiring
fdtbus in most cases. This brings ARM and MIPS more in line with existing
Open Firmware platforms like sparc64 and powerpc, as well as preventing
double-enumeration of the OF tree on embedded PowerPC (first through nexus,
then through fdtbus).

This change is also designed to simplify resource management on FDT platforms
by letting there exist a platform-defined root bus resource_activate() call
instead of replying on fdtbus to do the right thing through fdt_bs_tag.
The OFW_BUS_MAP_INTR() and OFW_BUS_CONFIG_INTR() kobj methods are also
available to implement for similar purposes.

Discussed on:	-arm, -mips
Tested by:	zbb, brooks, imp, and others
MFC after:	6 weeks
2013-11-05 13:48:34 +00:00
Ian Lepore
515cbe8673 Call initarm_lastaddr() later in the init sequence, after establishing
static device mappings, rather than as the first of the initializations
that a platform can hook into.  This allows a platform to allocate KVA
from the top of the address space downwards for things like static device
mapping, and return the final "last usable address" result after that and
other early init work is done.

Because some platforms were doing work in initarm_lastaddr() that needs to
be done early, add a new initarm_early_init() routine and move the early
init code to that routine on those platforms.

Rename platform_devmap_init() to initarm_devmap_init() to match all the
other init routines called from initarm() that are designed to be
implemented by platform code.

Add a comment block that explains when these routines are called and the
type of work expected to be done in each of them.
2013-11-05 02:57:34 +00:00
Ian Lepore
3110e7eed8 Move remaining code and data related to static device mapping into the
new devmap.[ch] files.  Emphasize the MD nature of these things by using
the prefix arm_devmap_ on the function and type names (already a few of
these things found their way into MI code, hopefully it will be harder to
do by accident in the future).
2013-11-04 22:45:26 +00:00
Ian Lepore
99af02e3b6 Retire arm_remap_nocache() and the data and constants associated with it.
The only remaining user was the code that allocates bounce pages for armv4
busdma.  It's not clear why bounce pages would need uncached memory, but
if that ever changes, kmem_alloc_attr() would be the way to get it.
2013-10-27 03:13:26 +00:00
Ian Lepore
6489412064 Remove #include <machine/frame.h> from all the arm code that doesn't
really need it.  That would be almost everywhere it was included.  Add
it in a couple files that really do need it and were previously getting
it by accident via another header.
2013-10-27 01:34:10 +00:00
Ian Lepore
69d75558a7 Remove all #include <machine/pmap.h> from arm code. It's already
included by vm/pmap.h, which is a prerequisite for arm/machine/pmap.h
so there's no reason to ever include it directly.

Thanks to alc@ for pointing this out.
2013-10-27 00:51:46 +00:00
Luiz Otavio O Souza
09b2544b71 Remove all the instances of '#undef DEBUG' from kernel.
Suggested by:	rpaulo
Approved by:	adrian (mentor)
2013-10-25 18:38:44 +00:00
Luiz Otavio O Souza
07897970fb Add the Raspberry Pi SPI controller driver.
Reviewed by:	rpaulo
Approved by:	adrian (mentor)
2013-10-24 16:27:33 +00:00
Luiz Otavio O Souza
be9ddf4313 Add the Raspberry Pi BSC (I2C compliant) controller driver.
Reviewed by:	rpaulo
Approved by:	adrian (mentor)
2013-10-23 12:29:39 +00:00
Oleksandr Tymoshenko
00b1705bdc - Implement watchdog function and register it with watchdog list 2013-10-22 05:19:42 +00:00
Ganbold Tsagaankhuu
8f011d4075 Move and rename dwc otg driver to more
generic one as it appears to work
for rk3188 SoC based board too.

No objections from: hselasky@
Reviewed by: ray@
2013-10-21 09:34:04 +00:00
Luiz Otavio O Souza
c58e1e485c Fix DELAY() on RPi, the wrong math was making it take twice it should.
Reported by:	Alexander <sht@ropnet.ru>
Approved by:	adrian (mentor)
Approved by:	re (gjb)
2013-09-23 14:00:18 +00:00
Luiz Otavio O Souza
44d06d8d9a Export a function to allow BCM2835's peripheral devices to enable their
altenate pin function (from GPIO pins) as needed.

Approved by:	adrian (mentor)
2013-09-07 18:48:15 +00:00
Luiz Otavio O Souza
8d900240b0 Fix an off-by-one bug in ar71xx_gpio and bcm2835_gpio which makes the last
pin unavailable.

Reported and tested by:	sbruno (ar71xx)
Approved by:	adrian (mentor)
Pointy hat to:	loos
2013-09-06 23:39:56 +00:00
Rui Paulo
9c9a49c494 Move the Raspberry Pi low level options out of the kernel config and into
std.rpi + std.bcm2835.

Reviewed by:	imp
2013-07-15 07:01:30 +00:00
Rui Paulo
279cd1010a Convert bcm2835_mbox to the new mbox interface.
Reviewed by:	gonzo
2013-07-07 21:23:58 +00:00
Rui Paulo
95506b814d The mbox driver is actually MP safe, so set the right flag in
bus_setup_intr().
2013-07-01 06:33:35 +00:00
Rui Paulo
623b72a733 Disable debugging. 2013-07-01 06:32:56 +00:00
Eitan Adler
578acad37e Correct a few sizeof()s
Submitted by:	swildner@DragonFlyBSD.org
Reviewed by:	alfred
2013-05-01 04:37:34 +00:00
Dimitry Andric
27e644a80b Fix undefined behaviour in several gpio_pin_setflags() routines (under
sys/arm and sys/mips), squelching the clang 3.3 warnings about this.

Noticed by:	tinderbox and many irate spectators
Submitted by:	Luiz Otavio O Souza <loos.br@gmail.com>
PR:		kern/177759
MFC after:	3 days
2013-04-13 21:21:13 +00:00
Alexander Motin
359b47db97 Minimal timer period of 100us introduced in r244758 is overkill. While
original 2us are indeed not enough, 3us are working quite well on my tests.
To be more safe set minimal period to 5us and to be even more safe replicate
here from HPET mechanism of rereading counter after programming comparator.

This change allows to handle 30K of short nanosleep() calls per second on
Raspberry Pi instead of just 8K before.

Discussed with:	gonzo
2013-03-21 15:42:41 +00:00
Ian Lepore
b479b38c0a Eliminate an intermediate buffer and some memcpy() operations, and do
DMA directly to/from the buffers passed in from higher layer drivers.

Reviewed by:	gonzo
2013-03-17 16:31:09 +00:00
Ian Lepore
33ff10ea55 Add a macro that gets the physical address of a memory mapped device
register from a bus space resource.

Note that this macro is just for ARM, and is intended to have a short
lifespan.  The DMA engines in some SoCs need the physical address of a
memory-mapped device register as one of the arguments for the transfer.
Several scattered ad-hoc solutions have been converted to use this macro,
which now also serves to mark the places where a more complete fix needs
to be applied (after that fix has been designed).
2013-03-17 03:04:43 +00:00
Oleksandr Tymoshenko
e9401a9e0e - Reset DMA channel if error occured
- Initialize info field in bcm_dma_reset

Submitted by:	Daisuke Aoyama <aoyama@peach.ne.jp>
2013-03-05 20:00:11 +00:00
Oleksandr Tymoshenko
adc99a8aa6 Add platform DMA support to SDHCI driver for BCM2835
Submitted by:	Daisuke Aoyama <aoyama at peach.ne.jp>
Reviewed by:	ian@
2013-02-28 19:51:30 +00:00
Oleksandr Tymoshenko
cdafe74e84 Add driver for BCM2835's DMA engine
This is a version of code submitted by Daisuke Aoyama <aoyama at peach.ne.jp>
with some architectural changes.
2013-02-28 19:48:19 +00:00
Alexander Motin
fdc5dd2d2f MFcalloutng:
Switch eventtimers(9) from using struct bintime to sbintime_t.
Even before this not a single driver really supported full dynamic range of
struct bintime even in theory, not speaking about practical inexpediency.
This change legitimates the status quo and cleans up the code.
2013-02-28 13:46:03 +00:00
Oleksandr Tymoshenko
e5b6b345cf Add macroses to properly map IO peripherals memory window from
ARM physical memory address space to VideoCore address space
2013-02-23 22:46:26 +00:00
Oleksandr Tymoshenko
8635d479c2 Spelling fixes
Spotted by:	N. J. Mann
2013-02-19 21:24:52 +00:00
Oleksandr Tymoshenko
f91360b174 Roll back change of frequency for initialization sequence since it
seems to cause more problems then previous behavior: it either breaks
initilization sequence in other places or uncovers problems with
high-speed mode timing for SDHCI 3.0
2013-02-19 20:33:55 +00:00
Oleksandr Tymoshenko
d3d7f709ce - Add hw.bcm2835.sdhci.hs tunable to enable/disable highspeed mode in
SDHCI driver
  Suggested by: Daisuke Aoyama

- Set initilization sequence frequency to 8MHz. It should fix Data CRC
    errors. Standard requires initialization sequence to be executed
    at 400KHz but on this hardware low frequncies seems to cause
    Data CRC errors.

    Value was derived from analyzing hardware signals after
    Raspberry Pi is powered up. Before any data is read though DATA line
    adapter's clock frequency is changed to 8MHz.

    Modern cards should function fine at 8MHz but for older MMC cards it
    can be overriden by setting hw.bcm2835.sdhci.min_freq tunable.
2013-02-17 00:23:42 +00:00
Aleksandr Rybalko
f101fd7fdc Enable syscons framebuffer support for bcm2835. It makes possible to run Xorg
on Raspberry Pi.
o convert mmap address to physical.
o add FBIOGTYPE ioctl handler - allow to get screen resolution by new
    xf86-video-scfb driver.
Originally designed for "Efika MX" project.

Sponsored by:	FreeBSD Foundation
2013-01-13 22:05:46 +00:00
Oleksandr Tymoshenko
0b5eb45655 Remove accidentally copypasted comment
Spotted by: gavin
2013-01-13 21:32:40 +00:00
Oleksandr Tymoshenko
fd79f4a5a4 Export board serial and board revision obtained from FDT blob 2013-01-05 23:08:58 +00:00
Oleksandr Tymoshenko
706f28ae4b Fix background color calculation
Spotted by: ray@
2013-01-05 21:05:16 +00:00
Oleksandr Tymoshenko
3ada2d599e Add makeshift implementation for framebuffer console's cursor
Basically it's replica of VersatilePB code which is replica of XBox FB
code. All of them are linear framebuffers and should have common bits
moved to reusable framework.
2012-12-28 03:18:05 +00:00
Oleksandr Tymoshenko
0c093a7055 Fix event timer on Raspberry Pi
- Disable interrupt when updating compare value in order to
   make this operation atomical

- Increase minimum period for event timer. Systimer on BCM2835
    is compare timer, so if minimum period is too small it might
    be less then fraction of time between "read current value" and
    "set compare timer" operations. It means that when timer is armed
    actual counter value is more then compare value and it will take
    whole cycle (~32sec for 1MHz timer) to fire interrupt.

Submitted by:	Daisuke Aoyama <aoyama at peach.ne.jp>
2012-12-28 01:38:43 +00:00
Oleksandr Tymoshenko
c5f8f8946c Replace generic ARM11 option with more specific
support for ARM1136 and ARM1176

Submitted by:	Daisuke Aoyama <aoyama at peach.ne.jp>
Obtained from:	NetBSD
2012-12-20 04:32:02 +00:00