NetBSD/sys/arch/sandpoint
dyoung d3e53912d2 Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args.  Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
    pci_intr_map() was a leftover from Xen 2.  Probably a bug.  I
    stopped writing it.  I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
    Probably a bug.  I use a temporary variable.  I have not tested this
    change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
    Probably a bug.  Use a local pci_attach_args.  I have not tested
    this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
    caller's pci_attach_args.  Probably a bug.  Make a local copy of the
    caller's pci_attach_args and modify the copy.  I have not tested
    this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
	HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
	KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
	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
	OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
2011-04-04 20:37:49 +00:00
..
compile
conf More networking options. 2011-03-20 17:10:46 +00:00
include Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9), 2011-04-04 20:37:49 +00:00
isa
pci Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9), 2011-04-04 20:37:49 +00:00
sandpoint Add more known I2C devices: 2011-04-04 18:01:08 +00:00
stand Make sure a frame is at least 60 bytes, as Realtek does not automatically 2011-04-04 16:41:34 +00:00
Makefile Fix target 'tags'. 2011-04-04 19:44:16 +00:00
README
README.NAS Updated information for D-Link and QNAP. 2011-03-26 22:18:06 +00:00

/*	$NetBSD: README,v 1.3 2007/10/17 19:56:54 garbled Exp $	*/

Overview

This is a port to the Motorola "SandPoint" evaluation system.  The
SandPoint is the successor to the "Yellowknife" system.  The system
can be fitted with different PMCs (Processor Mezzanine Cards).  This
port is specifically for the rev X2 motherboard system with the PPC
8240 PMC rev X4 installed.  It also works with the Altimus X2 PMC
(MPC7400 with MPC107).

All references (cf) listed here are for the MPC8240 Integrated Processor
User's Manual.

Information on the Sandpoint can be found on Motorola's web site:
http://www.mot.com/SPS/PowerPC/teksupport/refdesigns/sandpoint.html


SandPoint Hardware Configuration

This port was developed on a Sandpoint X2 motherboard with a Unity X4 PMC.

This port assumes that the jumpers are set as follows:
	S3/S4	- Mode 1: PMC w/o IDE (switches opposite, one nearest PCI
		  slot toward near edge)
	S5	- Interrupt to PMC normal (switch toward near edge)
	S6	- Local I/O shared with slot 2 (switch toward near edge)

Mode 0 (PMC w/ IDE) does not appear to work right with ISA interrupts.  The
interrupts from the Winbond chip do not appear at the PMC.

On the PPMC, we assume a 100MHz clock.
on PPMC: (C == closed, or "on")
    SW2:
	C	ROM on PCI bus (DINK32 on mainboard)
	-	Map "B": CHRP
	C	Motorola PPMC
	C	Wait for initialization (peripheral mode)
	-	Program mode: Normal mode
	-	Select normal ROM
	-	33 MHz only
	-	COP only resets local CPU/MPC107
    SW3:
	-C--C	PCI 33, Mem 66, PPC 266
	--	0.5 - 0.9 ns PCI hold time
	C	25 ohm PCI drive strength


Address Map

For this port, we choose the "Address Map B" (CHRP-compatible) for the
system (see SW2, #2, above):

 (Processor View)
0000 0000   0009 FFFF	System Memory
000A 0000   000F FFFF	Compatibility Hole (programmable to go to PCI space
			or system memory--programmed for system memory--cf 5.8)
0010 0000   3FFF FFFF	System memory
4000 0000   7FFF FFFF	Reserved (programmed to give a memory select
			error if accessed--cf 5.7.2)
8000 0000   FCFF FFFF	PCI memory space
FD00 0000   FDFF FFFF	PCI/ISA memory space (see 5.8, CPU_FD_ALIAS_EN)
FE00 0000   FE7F FFFF	PCI/ISA I/O space (Forwarded to PCI address space
			with high byte zeroed, but FE01 0000 and up are
			reserved)
FE80 0000   FEBF FFFF	PCI I/O space (Forwarded to PCI I/O space with high
			byte zeroed)
FEC0 0000   FEDF FFFF	PCI configuration address register (Each word in this
			range is aliased to the PCI CONFIG_ADDR register)
FEE0 0000   FEEF FFFF	PCI configuration data register (Each word in this
			range is aliased to the PCI CONFIG_DATA register)
FEF0 0000   FEFF FFFF	PCI interrupt acknowledge
FF00 0000   FF7F FFFF	32- or 64-bit Flash/ROM space (Can hit either local
			memory or PCI bus -- cf. 5.6)
FF80 0000   FFFF FFFF	8-, 32- or 64-bit Flash/ROM space (Can hit either
			local memory or PCI bus -- cf. 5.6)

This is a host-mode port, so the inbound and output translation windows
are unused.

The Embedded Utilities Memory Block (EUMB) is set to be 1M below the end
of the PCI memory space: FC00 0000, so EUMBBAR is FC00 0000, giving us

Message unit (I2O) base	: FC00 0000	(cf. 10.2, 10.2.3, 10.3)
DMA base		: FC00 1000	(cf. 9.2)
ATU base		: FC00 2000	(cf. 4.3.3)
I2C base		: FC00 3000	(cf. 11.3)
EPIC base		: FC04 0000	(cf. 12.2)



Boot Information

The SandPoint ships with the Motorola DINK32 ROM.  This is a rather
basic ROM with only serial-download (S-Record) capability for
loading the kernel.  Basically, the kernel is loaded to a specified
address and you jump to it.  The ROM takes care of initializing
the MICRs and MCCRs.  There is really no boot information to pass.

It would be nice to have a much more complete ROM interface, allowing
settings for, say, bootp/tftp boot, automatic boot, and persistent
settings (for console rate, auto boot, bootp, etc), and that might
be provided at some point, but that's not available as of this
writing.

So, the kernel is hard-coded to boot w/ 32MB for now.



Interrupt Configuration

The 8240 has the internal EPIC.  For the SandPoint, the EPIC is programmed
in mixed-mode (GCR) with direct interrupts (EICR).  With this configuration,
there are 13 available interrupts:
	4 global timers
	5 direct IRQs
		IRQ0 - PCI Slot #0 INTA#
		IRQ1 - PCI Slot #1 INTA# / shared with WinBond I/O
		IRQ2 - PCI Slot #2 INTA#
		IRQ3 - PCI Slot #3 INTA#
		IRQ4 - On-PPMC 16552 interrupt (Unity X2)
		IRQ4 - pulled down w/ resistor (Unity X4)
	4 internal interrupts
		I2C
		DMA Ch0
		DMA Ch1
		I2O message unit

The SandPoint can run in one of 4 interrupt modes:
  0 - PMC host with IDE (3.3v PCI slots are unavailable)
  1 - PMC host w/o IDE (all PCI slots are available)
  2 - PMC agent, Winbond providing arbitration & interrupt to INTA# on PMC
  3 - Yellowknife mode--just like #2, except drives INTA# on 4th PCI slot

We choose to run in mode 1 as Motorola recommends modes 0 or 1 for
all new development.  Unfortunately, mode 0 does not appear to
work--"ISA" interrupts are lost.  In this mode, with interrupts
routed to PCI slot 3, we have to check for both a Winbond (ISA)
interrupt, and a PCI slot interrupt.  So basically, we have a
two-level interrupt configuration for Winbond interrupts.  The ISA
bus attachment registers an interrupt for PCI slot 3 with its own
interrupt handler.  Drivers for ISA devices on the Winbond will
register interrupts with the ISA interrupt handler.  The sticky
part of this is how to deal with one global interrupt priority.



SandPoint III "SP3" Interrupt Configuration

With a help of additional logic circuit SP3 organizes external
interrupt sources as EPIC serial mode interrupts.
	16 serial IRQs
		IRQ0 - WinBond South bridge i8259 PIC, polarity inverted
		IRQ1 - reserved
		IRQ2 - PCI Slot #1, INTA#
		IRQ3 - PCI Slot #2, INTA#
		IRQ4 - PCI Slot #3, INTA#
		IRQ5 - PCI Slot #4, INTA#
		IRQ6 - WinBond INTA#
		IRQ7 - WinBond INTB#
		IRQ8 - WinBond INTC#
		IRQ9 - WinBond INTD#
		IRQ10 thru 15 - reserved
SP3 provides switch selections to emulate SP1/2 compatible EPIC
direct mode interrupt assignments.