Commit Graph

153 Commits

Author SHA1 Message Date
Nathan Whitehorn
67dbd33ca8 Reimplement fdt_intr_to_rl() in terms of OFW_BUS_MAP_INTR() and
OFW_BUS_CONFIG_INTR(). This function is only used by simplebus, so will
likely be moved there in the future.
2014-01-04 21:14:33 +00:00
Nathan Whitehorn
fc54707f7d Remove dead code. Most of this was in an #if 0 block; the rest is not
used and duplicates functionality in dev/ofw.
2013-12-17 14:51:47 +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
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
2bd843b4da This files should have been included in r257648. 2013-11-04 20:00:21 +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
Nathan Whitehorn
6751474523 Use common OFW root code to set up fdtbus. This is an almost purely
negative diff that should improve reliability somewhat. There should be
no differences in behavior -- please report any that crop up. This has been
tested on ARM and PPC systems.

Tested by:	ray
2013-10-25 13:29:07 +00:00
Nathan Whitehorn
238b0483a7 Do not map IRQs twice. This fixes PowerPC/FDT systems with multiple PICs,
which would try to treat the previously-mapped interrupts from
fdt_decode_intr() as interrupt line numbers on the same parent PIC.
2013-10-24 15:44:29 +00:00
Nathan Whitehorn
755c959170 Remove OF_instance_to_package() hack for FDT and replace with use of the
generic OF_xref_phandle() API universally. Also replace some related
explicit uses of fdt32_to_cpu() with OF_getencprop() calls.
2013-10-23 14:04:09 +00:00
Brooks Davis
fdd228fcd6 MFP4: 223121 (PIC portion), 225861, 227822, 229692 (PIC only), 229693,
230523, 1123614

Implement a driver for Robert Norton's PIC as an FDT interrupt
controller. Devices whose interrupt-parent property points to a beripic
device will have their interrupt allocation, activation , and setup
operations routed through the IC rather than down the traditional bus
hierarchy.

This driver largely abstracts the underlying CPU away allowing the
PIC to be implemented on CPU's other than BERI. Due to insufficient
abstractions a small amount of MIPS specific code is currently required
in fdt_mips.c and to implement counters.

MFC after:	3 days
Sponsored by:	DARPA/AFRL
2013-10-22 15:29:59 +00:00
Nathan Whitehorn
7f5392e292 Allow lots of interrupts (useful on multi-domain platforms) and do not
set device_quiet() on all devices attached under nexus(4).
2013-10-22 14:08:57 +00:00
Nathan Whitehorn
17593f8612 Standards-conformance and code deduplication:
- Use bus reference phandles in place of FDT offsets as IRQ domain keys
- Unify the identical macio/fdt/mambo OpenPIC drivers into one
- Be more forgiving (following ePAPR) about what we need from the device
  tree to identify an OpenPIC
- Correctly map all IRQs into an interrupt domain
- Set IRQ_*_CONFORM for interrupts on an unknown PIC type instead of
  failing attachment for that device.
2013-10-22 14:07:57 +00:00
Brooks Davis
1f40dbc854 MFP4: 223121 (FDT infrastructure portion)
Implement support for interrupt-parent nodes in simplebus.  The current
implementation requires that device declarations have an interrupt-parent
node and that it point to a device that has registered itself as a
interrupt controller in fdt_ic_list_head and implements the fdt_ic
interface.

Sponsored by:   DARPA/AFRL
2013-10-21 21:13:01 +00:00
Nathan Whitehorn
457639351b Some nexus devices add wildcard children. Since fdtbus_probe returned
BUS_PROBE_DEFAULT, it would attach to them all, producing both many
fdtbus instances and preventing other devices from attaching. Instead
return BUS_PROBE_NOWILDCARD, which exists for exactly this purpose.
2013-10-20 18:38:19 +00:00
Marcel Moolenaar
cb34ed4434 Add basic support for FDT to i386 & amd64. This change includes:
1.  Common headers for fdt.h and ofw_machdep.h under x86/include
    with indirections under i386/include and amd64/include.
2.  New modinfo for loader provided FDT blob.
3.  Common x86_init_fdt() called from hammer_time() on amd64 and
    init386() on i386.
4.  Split-off FDT specific low-level console functions from FDT
    bus methods for the uart(4) driver. The low-level console
    logic has been moved to uart_cpu_fdt.c and is used for arm,
    mips & powerpc only. The FDT bus methods are shared across
    all architectures.
5.  Add dev/fdt/fdt_x86.c to hold the fdt_fixup_table[] and the
    fdt_pic_table[] arrays. Both are empty right now.

FDT addresses are I/O ports on x86. Since the core FDT code does
not handle different address spaces, adding support for both I/O
ports and memory addresses requires some thought and discussion.
It may be better to use a compile-time option that controls this.

Obtained from:	Juniper Networks, Inc.
2013-05-21 03:05:49 +00:00
Aleksandr Rybalko
5ac9d9890f Return "start" and "end" to u_long world. Because rman handle addresses as
u_long too.

Discussed with:	ian@
Pointy hat to:	ray@
2013-03-19 14:15:41 +00:00
Aleksandr Rybalko
ee52bd5713 Cast "start" to u_long. Temporary fix to unbreak tinderbox.
We need here max possible storage or dynamic, depend on size of address cell.
2013-03-19 13:13:26 +00:00
Aleksandr Rybalko
36581e4785 Don't hesitate to ask parent to setup IRQ finally.
Sponsored by:	The FreeBSD Foundation
2013-03-18 23:51:39 +00:00
Aleksandr Rybalko
bf9d6206b0 Allow simplebus to attach to another simplebus.
Sponsored by:	The FreeBSD Foundation
2013-03-18 23:41:19 +00:00
Aleksandr Rybalko
089dfb09f1 Hide "no default resources for" warning under bootverbose. It's ok to use
optional resources.

Sponsored by:	The FreeBSD Foundation
2013-03-18 23:38:15 +00:00
Aleksandr Rybalko
2737a5a925 Allow simplebus to attach in less strict way, when "simple-bus" listed on not
first position of compatible property, so simplebus driver can be generic
driver for any bus listed as compatible with "simple-bus".

Sponsored by:	The FreeBSD Foundation
2013-03-18 23:35:01 +00:00
Aleksandr Rybalko
4117c1db9e o Switch to use physical addresses in rman for FDT.
o Remove vtophys used to translate virtual address to physical in case rman carry virtual.

Sponsored by:	The FreeBSD Foundation
2013-03-18 15:18:55 +00:00
Oleksandr Tymoshenko
8966173312 Bump per-device interrupt limit to more reasonable default.
Some hardware like DMA and GPIO controllers might require
more then 8 interrupts per device instance.

Submitted by:	Daisuke Aoyama <aoyama at peach.ne.jp>
Discussed with:	gber@, raj@
2013-02-23 22:58:04 +00:00
Robert Watson
2029d071db Merge Perforce changeset 219933 and portions of 219962 (omits changes to
unmerged BERI DTS files) to head:

  Use the OFW compatible string "mips,mips4k" rather than
  "mips4k,cp0" for interrupt control using MIPS4k CP0.

  Suggested by:   thompsa

  Implement a MIPS FDT PIC decode routine to use when no PIC has been
  configured, which assumes a cascade back to the nexus bus (e.g.,
  the on-board CP0 interrupt management parts on the MIPS).  If the
  soc bus in a MIPS DTS file is declared as "mips4k,cp0"-compatible,
  then this will be enabled.  This is sufficient to allow IRQs to be
  configured on BERI.

Sponsored by:	DARPA, AFRL
2013-01-12 16:09:33 +00:00
Robert Watson
ff82fb46d4 When a partially initialised FDT-based device instance can't attach,
perhaps due to an interrupt configuration problem, do not try to free
device ivars that have not yet have been allocated.

MFC after:	1 week
Reviewed by:	gonzo
Sponsored by:	DARPA, AFRL
2012-12-30 21:10:48 +00:00
Oleksandr Tymoshenko
1d1ffd9efb Add fdt_get_reserved_regions function. API is simmilar to fdt_get_mem_regions
It returns memory regions restricted from being used by kernel. These
regions are dfined in "memreserve" property of root node in the same
format as "reg" property of /memory node
2012-11-30 03:08:49 +00:00
Grzegorz Bernacki
68b7bd0469 If virtual addresses are not set use one to one mapping.
Do not map memory and IO space at address 0.

Obtained from: Semihalf
2012-09-14 09:45:13 +00:00
Grzegorz Bernacki
2c99056488 Add fdt_get_unit() function.
Obtained from:	Semihalf
2012-09-14 09:36:35 +00:00
Grzegorz Bernacki
2f0da24b47 Set busaddr and bussize to 0 when fdt_get_range() fails.
Obtained from:	Semihalf
2012-09-14 09:33:35 +00:00
Oleksandr Tymoshenko
c36ad1ffa3 Do not swap byte order if we assign default value for intr_cells 2012-08-25 20:18:12 +00:00
Oleksandr Tymoshenko
22cbf66621 Fix argument type for bus_space_map 2012-08-15 18:37:01 +00:00
Oleksandr Tymoshenko
8bb9363760 Merging of projects/armv6, part 4
r233822:
  Remove useless and wrong piece of code in fdt_get_range() which i
  overwrites passed phandle_t node. Modify debug printf in fdt_reg_to_rl()
  to be consistent (that is, print start and end *virtual* addresses).

r230560:
  Handle "ranges;"
  Make fdt_reg_to_rl() responsible for mapping the device memory, instead
  on just hoping that there's only one simplebus, and using fdt_immr_va as
  the base VA.

r230315
  Add a function to get the PA from range, instead of (ab)using
  fdt_immr_pa, and use it for the UART driver
2012-08-15 03:49:10 +00:00
Marcel Moolenaar
120c7e2eb7 Simplify simplebus_setup_intr and don't call MD code directly. We can
(and have to) trust our parent to handle interrupt configuration.
2012-07-02 23:53:08 +00:00
Marcel Moolenaar
8c4c7216e6 Properly implement bus_setup_intr so that it handles the configuration
of interrupts of direct children. Have the bus_config_intr and
bus_teardown_intr methods implemented by bus_generic_config_intr and
bus_generic_teardown_intr (resp) as we don't need to do anything
special outselves.

This removes all the ``#ifdef $arch'' code that was there because powerpc
didn't have a proper nexus and people tend to copy and paste stuff.
2012-07-02 23:49:29 +00:00
Marcel Moolenaar
695d8e87f2 Preset (clear) the ranges we're supposed to fill from the FDT. If a
particular range (either I/O memory or I/O port) is not defined in
the FDT, we're not handing uninitialized structures back to our caller.
2012-05-24 20:24:49 +00:00
Grzegorz Bernacki
4ffd4dfe17 Add a new geom class which allows to divide NAND Flash chip
into partitions.

Partitions are created based on data in dts file which are
extracted and interpreted by slicer.

Obtained from: Semihalf
Supported by:  FreeBSD Foundation, Juniper Networks
2012-05-22 08:33:14 +00:00
Rafal Jaworowski
aa15e881bb Respect phy-handle property in Ethernet nodes of the device tree.
This lets specify whereabouts of the parent PHY for a given MAC node
(and get rid of ugly kludges in mge(4) and tsec(4)).

Obtained from:	Semihalf
MFC after:	1 week
2012-03-04 19:22:52 +00:00
Marcel Moolenaar
49a5225199 DEBUG is a kernel option. Don't define it here, as it breaks LINT.
Since DEBUG was subsequently undefined, this is just debugging left-
over.
2011-12-30 04:00:31 +00:00
Jayachandran C.
07042bef45 Fix OF_finddevice error return value in case of FDT.
According to the open firmware standard, finddevice call has to return
a phandle with value of -1 in case of error.

This commit is to:
- Fix the FDT implementation of this interface (ofw_fdt_finddevice) to
  return (phandle_t)-1 in case of error, instead of 0 as it does now.
- Fix up the callers of OF_finddevice() to compare the return value with
  -1 instead of 0 to check for errors.
- Since phandle_t is unsigned, the return value of OF_finddevice should
  be checked with '== -1' rather than '<= 0' or '> 0', fix up these cases
  as well.

Reported by:	nwhitehorn

Reviewed by:	raj
Approved by:	raj, nwhitehorn
2011-12-02 15:24:39 +00:00
Jayachandran C.
29a99755a9 FDT support for MIPS.
Add architecture specific files needed to compile MIPS with
flattened device tree support.
2011-10-18 07:29:21 +00:00
John Baldwin
b67d11bbcc Change rman_manage_region() to actually honor the rm_start and rm_end
constraints on the rman and reject attempts to manage a region that is out
of range.
- Fix various places that set rm_end incorrectly (to ~0 or ~0u instead of
  ~0ul).
- To preserve existing behavior, change rman_init() to set rm_start and
  rm_end to allow managing the full range (0 to ~0ul) if they are not set by
  the caller when rman_init() is called.
2011-04-29 18:41:21 +00:00
Marcel Moolenaar
3a47c0e263 Don't operate on the parent of the PCI node. It's the PCI node itself
that represents the host controller. This makes the FDT PCI support
working an a bare-bones manner. This needs a lot more work, of which
the beginning are at the end of the file, compiled-out with #if 0.

The intend being that both the Marvell PCIE and Freescale PCI/PCIX/PCIE
duplicate the same platform-independent domain initialization, that
should be moved into an unified implementation in the FDT code. Handling
of resources requires help from the platform. A unified implementation
allows us to properly support PCI devices listed in the device tree and
configured according to the device tree specification.

Sponsored by: Juniper Networks
2011-01-29 21:14:29 +00:00
Marcel Moolenaar
ac3fe75f97 Call newbus_device_create() for PCI devices. Call pci_from_fdt_node()
for the newly created device_t, rather than the parent.
2011-01-29 21:08:03 +00:00
Marcel Moolenaar
2af3fc178e Introduce macro FDT_MAP_IRQ to map from an interrupt controller and
interrupt pin pair to a global IRQ number. When multiple PICs exist
on a board, the interrupt pin alone is not unique.
2011-01-29 20:25:20 +00:00
Rafal Jaworowski
4f124b977c Eliminate FDT_IMMR_VA define.
This removes platform dependencies from <machine>/fdt.h for the benfit of
portability.
2010-07-19 18:47:18 +00:00
Rafal Jaworowski
5710b7a9da Move MRVL FDT fixups and PIC decode routine to a platform specific area.
This allows for better encapsulation (and eliminates generic fdt_arm.c, at
least for now).
2010-07-19 18:41:50 +00:00
Rafal Jaworowski
d1d3233ebd Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:

  - MPC8555CDS
  - MPC8572DS

This overhaul covers the following major changes:

  - All integrated peripherals drivers for Freescale MPC85XX SoC, which are
    currently in the FreeBSD source tree are reworked and adjusted so they
    derive config data out of the device tree blob (instead of hard coded /
    tabelarized values).

  - This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
    QUICC, UART, CFI.

  - Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
    ocpbus(4) driver, which was based on hard-coded config data.

Note that world for these platforms has to be built WITH_FDT.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
Rafal Jaworowski
da6bc8989d Introduce PowerPC-specific helper routines for FDT.
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-07-11 20:49:36 +00:00
Rafal Jaworowski
caaa3c62d4 Save fdtbus trigger / polarity data at their correct index. 2010-07-11 20:33:39 +00:00
Rafal Jaworowski
a22cd1e668 Let simplebus(4) diagnostics be a bit more descriptive. 2010-07-11 20:30:59 +00:00
Rafal Jaworowski
dc65d002dd Initial FDT infrastructure elements for ARM.
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-06-13 13:12:52 +00:00
Rafal Jaworowski
10e8667600 Provide identify method for the fdtbus(4).
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-06-13 12:58:31 +00:00
Rafal Jaworowski
58158742f2 Import the common Flattened Device Tree infrastructure.
o fdtbus(4) - the main abstract bus driver for all FDT-compliant systems. This
  is a direct replacement for the many incompatible bus drivers grouping
  integrated peripherals on embedded platforms (like obio(4), ocpbus(4) etc.)

o simplebus(4) - bus driver representing ePAPR style 'simple-bus' node, which
  is an umbrella device for most of the integrated peripherals on a typical
  system-on-chip device.

o Other components (common routines library, PCI node processing helper
  functions)

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-06-02 17:17:45 +00:00