Home | History | Annotate | Download | only in footbridge
History log of /src/sys/arch/arm/footbridge/footbridge.c
RevisionDateAuthorComments
 1.30  27-Sep-2022  skrll Remove unnecessary sys/malloc.h include
 1.29  13-Aug-2021  skrll Trailing whitespace
 1.28  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.27  24-Apr-2021  thorpej branches: 1.27.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.26  10-Oct-2012  skrll branches: 1.26.52;
Update comments to reflect the real function prototypes.

From chuq.
 1.25  01-Jul-2011  dyoung branches: 1.25.2; 1.25.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.24  17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.23  18-Nov-2010  skrll branches: 1.23.2;
Comment KNF.
 1.22  18-Nov-2010  skrll Remove commented out setting of SDRAM_MEMORY_ADDR - it's set later on.
 1.21  21-Jul-2009  skrll branches: 1.21.4;
device_t/softc split
CFATTACH_DECL -> CFATTACH_DECL_NEW
struct device * -> device_t
struct cfdata * -> cfdata_t
Use aprint*
 1.20  14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.19  14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18  14-Dec-2007  chris branches: 1.18.10; 1.18.18; 1.18.24;
Fix for PR cats/18026.

cats was never able to dump a kernel core dump because reading from
VGA addresses (0xb8000) was causing the system to hang.

To workaround this reprogram the footbridge to map the memory to appear on
the PCI bus at 0x20000000, rather than at 0x0. Also configure the pci bus
to have a DMA range so that data is mapped correctly.

Note that -current kernels seem to hang when unmounting the fs. This
is a seperate issue, and appears to be because interrupts need to be
enabled to unmount filesystems.

So using reboot 0x104 does work, as it does a sync without unmounting the
filesystems.

Also arm savecore doesn't do anything with the memroy dump, as on arm we
currently just dump the raw memory, there's no header block to indicate
memory sizes or other useful information.
 1.17  06-Jan-2007  christos branches: 1.17.20; 1.17.24; 1.17.26; 1.17.34; 1.17.38;
Add generic TOD support. From Bucky Katz.
 1.16  11-Dec-2005  christos branches: 1.16.20; 1.16.24;
merge ktrace-lwp.
 1.15  30-Aug-2004  drochner branches: 1.15.12;
Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.14  15-Jun-2003  fvdl branches: 1.14.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.13  23-Mar-2003  chris Add __KERNEL_RCSID tags to footbridge files.
 1.12  01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.11  03-Nov-2002  chris Checkin new interrupt handling code for the footbridge.
This is based upon Jason's work on xscale.

Most of the interrupt handling code is now written in C using an asm stub to
call into the C code.

spl* now only updates a software mask, and does not update the hardware,
this should be much faster.

The new code works well on cats, it's untested on netwinder, but should work.

The code implements generic soft interrupts.

More work is still required to bring the isa interrupt handling code upto
scratch currently all isa interrupts are handled at IPL_BIO on the footbridge.
This may cause isa interrupts to be handled later than they should be.
I plan to fix this in the near future.
 1.10  02-Oct-2002  thorpej branches: 1.10.2;
Use CFATTACH_DECL().
 1.9  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.8  27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.7  16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.6  04-May-2002  chris branches: 1.6.2;
Implement a proper delay routine for footbridge based systems. Note that
until the footbridge is attached we still have to rely on a loop. This
uses TIMER_3 running at 100Hz.
Sadly this doesn't appear to fix the tlp problems, which either means that this
delay routine is not as accurate as it should/could be or tlp is still broken.
 1.5  12-Apr-2002  thorpej Centralize ARM CPU configuration information by adding a new header
file, <arm/cpuconf.h>, which pulls in "opt_cputypes.h" and then defines
the following:
* CPU_NTYPES -- now many CPU types are configured into the kernel. What
you really want to know is "== 1" or "> 1".
* Defines ARM_ARCH_2, ARM_ARCH_3, ARM_ARCH_4, ARM_ARCH_5, depending
on which ARM architecture versions are configured (based on CPU_*
options). Also defines ARM_NARCH to determins how many architecture
versions are configured.
* Defines ARM_MMU_MEMC, ARM_MMU_GENERIC, ARM_MMU_XSCALE depending on
which classes of ARM MMUs are configured into the kernel, and ARM_NMMUS
to determine how many MMU classes are configured.

Remove the needless inclusion of "opt_cputypes.h" in several places.
Convert remaining users to <arm/cpuconf.h>.
 1.4  05-Jan-2002  chris Make some of the arm32 files build with LOOSE_PROTOTYPES not set in the makefile. Turned up a few mismatched functions. Note that this isn't all of the arm32 files. Aim will be to get arm32 kernels built with LOOSE_PROTOTYPES not set.
 1.3  23-Nov-2001  thorpej Use <arm/cpufunc.h>, not <machine/cpufunc.h>.
 1.2  05-Sep-2001  matt branches: 1.2.6;
Change <machine/irqhandler.h> to <machine/intr.h> since the latter always
includes the former and is a standard include file.
 1.1  09-Jun-2001  chris branches: 1.1.2;
Move the footbridge dir out of arm32 into arm.
 1.1.2.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.1  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.6.9  03-Jan-2003  thorpej Sync with HEAD.
 1.2.6.8  11-Nov-2002  nathanw Catch up to -current
 1.2.6.7  18-Oct-2002  nathanw Catch up to -current.
 1.2.6.6  20-Jun-2002  nathanw Catch up to -current.
 1.2.6.5  17-Apr-2002  nathanw Catch up to -current.
 1.2.6.4  28-Feb-2002  nathanw Catch up to -current.
 1.2.6.3  11-Jan-2002  nathanw More catchup.
 1.2.6.2  08-Jan-2002  nathanw Catch up to -current.
 1.2.6.1  05-Sep-2001  nathanw file footbridge.c was added on branch nathanw_sa on 2002-01-08 00:23:10 +0000
 1.6.2.1  30-May-2002  gehenna Catch up with -current.
 1.10.2.1  09-Nov-2002  bjh21 Catch up with -current.
 1.14.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1  03-Sep-2004  skrll Sync with HEAD
 1.15.12.2  21-Jan-2008  yamt sync with head
 1.15.12.1  26-Feb-2007  yamt sync with head.
 1.16.24.1  30-Apr-2007  bouyer Pull up following revision(s) (requested by rearnsha in ticket #592):
sys/arch/arm/footbridge/footbridgevar.h: revision 1.5
sys/arch/arm/ep93xx/epclk.c: revision 1.10
sys/arch/arm/ixp12x0/ixp12x0_clk.c: revision 1.11
sys/arch/arm/footbridge/footbridge.c: revision 1.17
sys/arch/arm/footbridge/isa/dsrtc.c: revision 1.10
sys/arch/arm/s3c2xx0/s3c2800_clk.c: revision 1.10
sys/arch/arm/xscale/ixp425_timer.c: revision 1.13
sys/arch/arm/xscale/becc_timer.c: revision 1.11
sys/arch/arm/xscale/i80321_timer.c: revision 1.16
sys/arch/arm/s3c2xx0/s3c24x0_clk.c: revision 1.7
Add generic TOD support. From Bucky Katz.
 1.16.20.1  12-Jan-2007  ad Sync with head.
 1.17.38.1  02-Jan-2008  bouyer Sync with HEAD
 1.17.34.1  26-Dec-2007  ad Sync with head.
 1.17.26.1  09-Jan-2008  matt sync with HEAD
 1.17.24.2  01-Jan-2008  chris Sync with HEAD.
 1.17.24.1  11-Aug-2007  chris Initial check-in of reworked arm interrupt routines.

Main things to note on this branch:
* spl routines are inlined, less complex, and small (kernel drops in size)
* interrupts are handled in priority order (for most things it doesn't
matter, but pending ipls are used to determine if there is any work to do)
* arm_irqhandler.c is derived from footbridge_irqhandler.c, which was based
on work by thorpej.
* The code tries to touch hardware as little as possible.
* spl masks are no longer tracked, as the system is based on pending ipls

The shared code uses global ipl lists to track which interrupt handlers
are attached to which ipl (arm_iplq[]).

Interrupt sources register with the common code to indicate:
* how many irq lines they have
* a function to set the hardware mask.
* call arm_intr_claim and arm_intr_disestablish to setup handlers

When an interrupt occurs the ipl is flagged as pending, in ipls_pending.
If it can be handled at the current_ipl_level the code does so.
If it can't be handled it's left until the current_ipl_level drops.

As the ipl level changes down a quick test is made of the new ipl level
against the ipls_pending value. If an ipl is pending arm_intr_splx_lifter
is called to handle the pending ipls.

It should be noted that all interrupts are left enabled at the hardware
level, interrupts are only masked when they occur. They are only
re-enabled after it's interrupt handler is called. Hardware masks are not
changed at any other time.

Soft interrupts are treated the same as hardware interrupts, they
register as a provider, and do not get treated specially. All the soft
interrupt handlers are placed onto the relevant global ipl queue, the same
as hard interrupts handlers.

At the moment only footbridge within a cats has been updated to use the new
handling.

Todo:
* change the handling of interrupts, so that the hardware doesn't register
a routine to fetch the hardware status. Instead is makes a call which
provides the mask. This removes the primary flag when registering an
interrupt provider. It also makes more sense with multiple interrupt
sources.
* Arm v5 has the clz asm, which could be used instead of the carefully
hand rolled arm_intr_fls function.
* switch cats isa support to use this framework.
* switch iomd and acorn32 to use this framework.
* switch shark to use this framework.
* port any other arm platforms that are interested
* examine overlaps between this code and ppcoea-renovation branch.
* add support for different trigger types (Edge, level, pulse, etc)

(note that iomd and shark currently touch hardware on every spl change,
hence why they're targets to port)
 1.17.20.1  26-Dec-2007  rjs Sync with HEAD.
 1.18.24.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.18.1  28-Apr-2009  skrll Sync with HEAD.
 1.18.10.2  19-Aug-2009  yamt sync with head.
 1.18.10.1  04-May-2009  yamt sync with head.
 1.21.4.2  31-May-2011  rmind sync with head
 1.21.4.1  05-Mar-2011  rmind sync with head
 1.23.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.25.12.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.25.2.1  30-Oct-2012  yamt sync with head
 1.26.52.1  02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.27.8.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed