Skip to content

Commit

Permalink
sh: Consolidated SH7751/SH7780 PCI support.
Browse files Browse the repository at this point in the history
This cleans up quite a lot of the PCI mess that we
currently have, and attempts to consolidate the
duplication in the SH7780 and SH7751 PCI controllers.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Paul Mundt committed Sep 27, 2006
1 parent e108b2c commit 959f85f
Show file tree
Hide file tree
Showing 37 changed files with 984 additions and 1,520 deletions.
2 changes: 0 additions & 2 deletions arch/sh/boards/landisk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
#

obj-y := setup.o io.o irq.o rtc.o landisk_pwb.o

obj-$(CONFIG_PCI) += pci.o
100 changes: 33 additions & 67 deletions arch/sh/boards/landisk/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,16 @@
* modifed by kogiidena
* 2005.03.03
*/

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <asm/landisk/iodata_landisk.h>
#include <asm/addrspace.h>
#include <asm/io.h>

#include <linux/module.h>
#include <linux/pci.h>
#include "../../drivers/pci/pci-sh7751.h"

extern void *area5_io_base; /* Area 5 I/O Base address */
extern void *area6_io_base; /* Area 6 I/O Base address */

/*
* The 7751R LANDISK uses the built-in PCI controller (PCIC)
* of the 7751R processor, and has a SuperIO accessible via the PCI.
* The board also includes a PCMCIA controller on its memory bus,
* like the other Solution Engine boards.
*/

#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
#define PCI_IO_AREA SH7751_PCI_IO_BASE
#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE

#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))

static inline void delay(void)
{
ctrl_inw(0xa0000000);
}

static inline unsigned long port2adr(unsigned int port)
{
if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
Expand All @@ -67,17 +44,6 @@ static inline unsigned long port2adr(unsigned int port)
return port;
}

/* In case someone configures the kernel w/o PCI support: in that */
/* scenario, don't ever bother to check for PCI-window addresses */

/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
#if defined(CONFIG_PCI)
#define CHECK_SH7751_PCIIO(port) \
((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
#else
#define CHECK_SH_7751_PCIIO(port) (0)
#endif

/*
* General outline: remap really low stuff [eventually] to SuperIO,
* stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
Expand All @@ -89,8 +55,8 @@ u8 landisk_inb(unsigned long port)
{
if (PXSEG(port))
return ctrl_inb(port);
else if (CHECK_SH7751_PCIIO(port))
return ctrl_inb(PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
return ctrl_inb(pci_ioaddr(port));

return ctrl_inw(port2adr(port)) & 0xff;
}
Expand All @@ -101,12 +67,12 @@ u8 landisk_inb_p(unsigned long port)

if (PXSEG(port))
v = ctrl_inb(port);
else if (CHECK_SH7751_PCIIO(port))
v = ctrl_inb(PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
v = ctrl_inb(pci_ioaddr(port));
else
v = ctrl_inw(port2adr(port)) & 0xff;

delay();
ctrl_delay();

return v;
}
Expand All @@ -115,8 +81,8 @@ u16 landisk_inw(unsigned long port)
{
if (PXSEG(port))
return ctrl_inw(port);
else if (CHECK_SH7751_PCIIO(port))
return ctrl_inw(PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
return ctrl_inw(pci_ioaddr(port));
else
maybebadio(port);

Expand All @@ -127,8 +93,8 @@ u32 landisk_inl(unsigned long port)
{
if (PXSEG(port))
return ctrl_inl(port);
else if (CHECK_SH7751_PCIIO(port))
return ctrl_inl(PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
return ctrl_inl(pci_ioaddr(port));
else
maybebadio(port);

Expand All @@ -139,8 +105,8 @@ void landisk_outb(u8 value, unsigned long port)
{
if (PXSEG(port))
ctrl_outb(value, port);
else if (CHECK_SH7751_PCIIO(port))
ctrl_outb(value, PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
ctrl_outb(value, pci_ioaddr(port));
else
ctrl_outw(value, port2adr(port));
}
Expand All @@ -149,19 +115,19 @@ void landisk_outb_p(u8 value, unsigned long port)
{
if (PXSEG(port))
ctrl_outb(value, port);
else if (CHECK_SH7751_PCIIO(port))
ctrl_outb(value, PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
ctrl_outb(value, pci_ioaddr(port));
else
ctrl_outw(value, port2adr(port));
delay();
ctrl_delay();
}

void landisk_outw(u16 value, unsigned long port)
{
if (PXSEG(port))
ctrl_outw(value, port);
else if (CHECK_SH7751_PCIIO(port))
ctrl_outw(value, PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
ctrl_outw(value, pci_ioaddr(port));
else
maybebadio(port);
}
Expand All @@ -170,8 +136,8 @@ void landisk_outl(u32 value, unsigned long port)
{
if (PXSEG(port))
ctrl_outl(value, port);
else if (CHECK_SH7751_PCIIO(port))
ctrl_outl(value, PCI_IOMAP(port));
else if (is_pci_ioaddr(port))
ctrl_outl(value, pci_ioaddr(port));
else
maybebadio(port);
}
Expand All @@ -184,8 +150,8 @@ void landisk_insb(unsigned long port, void *dst, unsigned long count)
if (PXSEG(port)) {
while (count--)
*buf++ = *(volatile u8 *)port;
} else if (CHECK_SH7751_PCIIO(port)) {
volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port);
} else if (is_pci_ioaddr(port)) {
volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);

while (count--)
*buf++ = *bp;
Expand All @@ -203,8 +169,8 @@ void landisk_insw(unsigned long port, void *dst, unsigned long count)

if (PXSEG(port))
p = (volatile u16 *)port;
else if (CHECK_SH7751_PCIIO(port))
p = (volatile u16 *)PCI_IOMAP(port);
else if (is_pci_ioaddr(port))
p = (volatile u16 *)pci_ioaddr(port);
else
p = (volatile u16 *)port2adr(port);
while (count--)
Expand All @@ -215,8 +181,8 @@ void landisk_insl(unsigned long port, void *dst, unsigned long count)
{
u32 *buf = dst;

if (CHECK_SH7751_PCIIO(port)) {
volatile u32 *p = (volatile u32 *)PCI_IOMAP(port);
if (is_pci_ioaddr(port)) {
volatile u32 *p = (volatile u32 *)pci_ioaddr(port);

while (count--)
*buf++ = *p;
Expand All @@ -232,8 +198,8 @@ void landisk_outsb(unsigned long port, const void *src, unsigned long count)
if (PXSEG(port))
while (count--)
ctrl_outb(*buf++, port);
else if (CHECK_SH7751_PCIIO(port)) {
volatile u8 *bp = (volatile u8 *)PCI_IOMAP(port);
else if (is_pci_ioaddr(port)) {
volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);

while (count--)
*bp = *buf++;
Expand All @@ -251,8 +217,8 @@ void landisk_outsw(unsigned long port, const void *src, unsigned long count)

if (PXSEG(port))
p = (volatile u16 *)port;
else if (CHECK_SH7751_PCIIO(port))
p = (volatile u16 *)PCI_IOMAP(port);
else if (is_pci_ioaddr(port))
p = (volatile u16 *)pci_ioaddr(port);
else
p = (volatile u16 *)port2adr(port);

Expand All @@ -264,8 +230,8 @@ void landisk_outsl(unsigned long port, const void *src, unsigned long count)
{
const u32 *buf = src;

if (CHECK_SH7751_PCIIO(port)) {
volatile u32 *p = (volatile u32 *)PCI_IOMAP(port);
if (is_pci_ioaddr(port)) {
volatile u32 *p = (volatile u32 *)pci_ioaddr(port);

while (count--)
*p = *buf++;
Expand All @@ -277,8 +243,8 @@ void __iomem *landisk_ioport_map(unsigned long port, unsigned int size)
{
if (PXSEG(port))
return (void __iomem *)port;
else if (CHECK_SH7751_PCIIO(port))
return (void __iomem *)PCI_IOMAP(port);
else if (is_pci_ioaddr(port))
return (void __iomem *)pci_ioaddr(port);

return (void __iomem *)port2adr(port);
}
15 changes: 2 additions & 13 deletions arch/sh/boards/mpc1211/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,12 @@ void __init init_mpc1211_IRQ(void)
}
}

/*
Initialize the board
*/


static void delay (void)
{
volatile unsigned short tmp;
tmp = *(volatile unsigned short *) 0xa0000000;
}

static void delay1000 (void)
static void delay1000(void)
{
int i;

for (i=0; i<1000; i++)
delay ();
ctrl_delay();
}

static int put_smb_blk(unsigned char *p, int address, int command, int no)
Expand Down
Loading

0 comments on commit 959f85f

Please sign in to comment.