From da8e8fe3d6ad5eb9589c8e77e7716e4f7e1a7499 Mon Sep 17 00:00:00 2001
From: Kurt Mahan <kmahan@freescale.com>
Date: Mon, 10 Dec 2007 03:36:05 -0700
Subject: [PATCH] Coldfire M5445x PCI Bits.

LTIBName: m5445x-pci
Signed-off-by: Kurt Mahan <kmahan@freescale.com>
---
 arch/m68k/Kconfig                     |   12 ++++++++++--
 arch/m68k/Makefile                    |    4 ++++
 arch/m68k/coldfire/config.c           |    2 +-
 arch/m68k/coldfire/iomap.c            |    2 ++
 arch/m68k/coldfire/mcf5445x-devices.c |    9 +++++++++
 arch/m68k/coldfire/mcf5445x-pci.c     |    5 +++--
 arch/m68k/coldfire/pci.c              |    6 +++---
 arch/m68k/kernel/Makefile             |    2 +-
 drivers/macintosh/Kconfig             |    1 -
 drivers/pci/Makefile                  |    1 +
 include/asm-m68k/io.h                 |   13 ++++++++++++-
 include/asm-m68k/pci.h                |    2 ++
 12 files changed, 48 insertions(+), 11 deletions(-)

--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -11,6 +11,14 @@ config MMU
 	bool
 	default y
 
+config GENERIC_TIME
+        bool
+        default n
+
+config GENERIC_CLOCKEVENTS
+        bool
+        default n
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
@@ -48,7 +56,7 @@ config ARCH_MAY_HAVE_PC_FDC
 	default y
 
 config NO_IOPORT
-	def_bool y
+	def_bool !M54455
 
 config NO_DMA
 	def_bool SUN3
@@ -159,7 +167,7 @@ config HADES
 
 config PCI
 	bool
-	depends on HADES
+	depends on HADES || M54455
 	default y
 	help
 	  Find out whether you have a PCI motherboard. PCI is the name of a
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -32,6 +32,10 @@ ifdef CONFIG_SUN3
 LDFLAGS_vmlinux = -N
 endif
 
+ifdef CONFIG_COLDFIRE
+# LDFLAGS_vmlinux = --verbose
+endif
+
 CHECKFLAGS += -D__mc68000__
 
 # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
--- a/arch/m68k/coldfire/config.c
+++ b/arch/m68k/coldfire/config.c
@@ -252,7 +252,7 @@ void __init coldfire_sched_init(irq_hand
 		     MCF_DTIM_DTMR_FRR	| MCF_DTIM_DTMR_RST_EN, \
 		     MCF_DTIM0_DTMR);
 
-	request_irq(mcf_timervector, handler, SA_INTERRUPT, \
+	request_irq(mcf_timervector, handler, IRQF_DISABLED, \
 		    "timer", (void *)MCF_DTIM0_DTMR);
 
 	settimericr(1, mcf_timerlevel);
--- a/arch/m68k/coldfire/iomap.c
+++ b/arch/m68k/coldfire/iomap.c
@@ -12,6 +12,7 @@
 #include <linux/pci.h>
 #include <asm/io.h>
 
+#if 0
 void __iomem *__attribute__ ((weak))
 ioport_map(unsigned long port, unsigned int len)
 {
@@ -52,3 +53,4 @@ void pci_iounmap(struct pci_dev *dev, vo
 	/* Nothing .. */
 }
 EXPORT_SYMBOL(ioport_unmap);
+#endif
--- a/arch/m68k/coldfire/mcf5445x-devices.c
+++ b/arch/m68k/coldfire/mcf5445x-devices.c
@@ -75,10 +75,19 @@ static int ata_get_clk_rate(void)
 	return MCF_BUSCLK;
 }
 
+/* JKM -- move these to a header file */
+#define MCF_IDE_DMA_WATERMARK	32	/* DMA watermark level in bytes */
+#define MCF_IDE_DMA_BD_NR	(512/3/4) /* number of BDs per channel */
+
 static struct fsl_ata_platform_data ata_data = {
 	.init             = ata_init,
 	.exit             = ata_exit,
 	.get_clk_rate     = ata_get_clk_rate,
+#ifdef CONFIG_PATA_FSL_USE_DMA
+        .udma_mask        = 0x0F, /* the board handles up to UDMA3 */
+        .fifo_alarm       = MCF_IDE_DMA_WATERMARK / 2,
+        .max_sg           = MCF_IDE_DMA_BD_NR,
+#endif
 };
 
 static struct resource pata_fsl_resources[] = {
--- a/arch/m68k/coldfire/mcf5445x-pci.c
+++ b/arch/m68k/coldfire/mcf5445x-pci.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/interrupt.h>
 #include <linux/pci.h>
 
 #include <asm/mcfsim.h>
@@ -76,7 +77,7 @@ void mcf5445x_pci_dumpregs(void);
 #endif
 
 /*
- * static void mcf5445x_conf_device(struct pci_dev *dev)
+ * mcf5445x_conf_device(struct pci_dev *dev)
  *
  * Machine dependent Configure the given device.
  *
@@ -84,7 +85,7 @@ void mcf5445x_pci_dumpregs(void);
  *
  * dev		- the pci device.
  */
-void __init
+void
 mcf5445x_conf_device(struct pci_dev *dev)
 {
 	set_fpga(FPGA_PCI_IRQ_ENABLE, 0x0f);
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -56,7 +56,7 @@ struct pci_ops pci_root_ops = {
  *
  * Initialize the pcibios based on cmd line params.
  */
-char * __init
+char *
 pcibios_setup(char *str)
 {
 	if (!strcmp(str, "debug")) {
@@ -124,7 +124,7 @@ pcibios_map_irq(struct pci_dev *dev, u8 
  *
  * Update a PCI interrupt.
  */
-void __init
+void
 pcibios_update_irq(struct pci_dev *dev, int irq)
 {
 	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
@@ -171,7 +171,7 @@ pcibios_enable_device(struct pci_dev *de
 /*
  * pcibios_fixup_bus(struct pci_bus *bus)
  */
-void __init
+void
 pcibios_fixup_bus(struct pci_bus *bus)
 {
 	struct pci_dev *dev = bus->self;
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -9,6 +9,7 @@ else
 ifndef CONFIG_COLDFIRE
   extra-y := head.o vmlinux.lds
   obj-y := entry.o signal.o traps.o ints.o
+  obj-$(CONFIG_PCI) += bios32.o
 else   # CONFIG_COLDFIRE
   extra-y := ../coldfire/head.o vmlinux.lds
 endif
@@ -19,7 +20,6 @@ obj-y	+= process.o ptrace.o module.o \
 
 devres-y = ../../../kernel/irq/devres.o
 
-obj-$(CONFIG_PCI)	+= bios32.o
 obj-y$(CONFIG_MMU_SUN3) += dma.o	# no, it's not a typo
 
 EXTRA_AFLAGS := -traditional
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -118,7 +118,6 @@ config PMAC_SMU
 
 config PMAC_APM_EMU
 	tristate "APM emulation"
-	select APM_EMULATION
 	depends on ADB_PMU && PM && PPC32
 
 config PMAC_MEDIABAY
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_PPC) += setup-bus.o
 obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o
 obj-$(CONFIG_X86_VISWS) += setup-irq.o
 obj-$(CONFIG_MN10300) += setup-bus.o
+obj-$(CONFIG_M54455) += setup-bus.o setup-irq.o
 
 #
 # ACPI Related PCI FW Functions
--- a/include/asm-m68k/io.h
+++ b/include/asm-m68k/io.h
@@ -306,7 +306,18 @@ static inline void isa_delay(void)
 #define outw(val,port) out_le16((port),(val))
 #define inl(port)      in_le32(port)
 #define outl(val,port) out_le32((port),(val))
-
+#define insb(port, buf, nr)	\
+		raw_insb((u8 *)(port), (u8 *)(buf), (nr))
+#define outsb(port, buf, nr)	\
+		raw_outsb((u8 *)(port), (u8 *)(buf), (nr))
+#define insw(port, buf, nr)	\
+		raw_insw_swapw((u16 *)(port), (u16 *)(buf), (nr))
+#define outsw(port, buf, nr)	\
+		raw_outsw_swapw((u16 *)(port), (u16 *)(buf), (nr))
+#define insl(port, buf, nr)	\
+		raw_insw_swapw((u16 *)(port), (u16 *)(buf), (nr)<<1)
+#define outsl(port, buf, nr)	\
+		raw_outsw_swapw((u16 *)(port), (u16 *)(buf), (nr)<<1)
 #else
 /*
  * kernel with both ISA and PCI compiled in, those have
--- a/include/asm-m68k/pci.h
+++ b/include/asm-m68k/pci.h
@@ -42,11 +42,13 @@ pcibios_penalize_isa_irq(int irq, int ac
 	/* no dynamic PCI IRQ allocation */
 }
 
+#if 0
 static inline void
 pcibios_add_platform_entries(struct pci_dev *dev)
 {
 	/* no special handling */
 }
+#endif
 
 static inline void
 pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
