Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

2009-01-12 Thread Gerhard Pircher

 Original-Nachricht 
> Datum: Mon, 12 Jan 2009 16:08:07 +1100
> Von: Benjamin Herrenschmidt 
> An: Scott Wood 
> CC: Gerhard Pircher , linuxppc-dev@ozlabs.org
> Betreff: Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

> 
> > > + /* Flush and disable I/D cache. */
> > > + __asm__ __volatile__ ("mfspr3, 1008"::: "r3");
> > > + __asm__ __volatile__ ("ori  5, 5, 0xcc00"   ::: "r5");
> > > + __asm__ __volatile__ ("ori  4, 3, 0xc00"::: "r4");
> > > + __asm__ __volatile__ ("andc 5, 3, 5"::: "r5");
> > 
> > Don't do this; instead, have one multi-line asm statement (or better
> yet,
> > just use mfspr()/mtspr()/sync()/isync()).
> > 
> > GCC is perfectly free to trash your registers in between statements.
> 
> Also there's already some code around to properly flush & disable the
> caches on those processors.
Ouch! I searched through all assembler files in arch/powerpc/kernel/ for
such a function, but I have missed flush_disable_L1 in l2cr_6xx.S.
Thanks for the hint!

Gerhard

-- 
Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: 
http://www.gmx.net/de/go/multimessenger
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

2009-01-11 Thread Benjamin Herrenschmidt

> > +   /* Flush and disable I/D cache. */
> > +   __asm__ __volatile__ ("mfspr3, 1008"::: "r3");
> > +   __asm__ __volatile__ ("ori  5, 5, 0xcc00"   ::: "r5");
> > +   __asm__ __volatile__ ("ori  4, 3, 0xc00"::: "r4");
> > +   __asm__ __volatile__ ("andc 5, 3, 5"::: "r5");
> 
> Don't do this; instead, have one multi-line asm statement (or better yet,
> just use mfspr()/mtspr()/sync()/isync()).
> 
> GCC is perfectly free to trash your registers in between statements.

Also there's already some code around to properly flush & disable the
caches on those processors.

Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

2009-01-07 Thread Gerhard Pircher

 Original-Nachricht 
> Datum: Wed, 7 Jan 2009 13:07:18 -0600
> Von: Scott Wood 
> An: Gerhard Pircher 
> CC: linuxppc-dev@ozlabs.org
> Betreff: Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

> On Wed, Jan 07, 2009 at 02:54:57PM +0100, Gerhard Pircher wrote:
> > +void amigaone_show_cpuinfo(struct seq_file *m)
> > +{
> > +   struct device_node *root;
> > +   const char *model = "";
> > +
> > +   root = of_find_node_by_path("/");
> > +   if (root)
> > +   model = of_get_property(root, "model", NULL);
> > +   seq_printf(m, "machine\t\t: %s\n", model);
> > +
> > +   of_node_put(root);
> > +   return;
> 
> This is already printed by the generic cpuinfo.
I'll remove that. Is a vendor or machine entry actually required?
IIRC the debian-installer parses the machine entry.

> > +void __init amigaone_setup_arch(void)
> > +{
> > +   struct device_node *np;
> > +
> > +   /* Initialization until calibrate_delay() runs. */
> > +   loops_per_jiffy = 5000/HZ;
> 
> Is this really necessary?
Don't think so. It's a leftover from the CHRP setup code.

> > +   /* Flush and disable I/D cache. */
> > +   __asm__ __volatile__ ("mfspr3, 1008"::: "r3");
> > +   __asm__ __volatile__ ("ori  5, 5, 0xcc00"   ::: "r5");
> > +   __asm__ __volatile__ ("ori  4, 3, 0xc00"::: "r4");
> > +   __asm__ __volatile__ ("andc 5, 3, 5"::: "r5");
> 
> Don't do this; instead, have one multi-line asm statement (or better yet,
> just use mfspr()/mtspr()/sync()/isync()).
> 
> GCC is perfectly free to trash your registers in between statements.
Okay, I'll try to rewrite it with mfspr() and friends (I don't understand gcc's
assembler syntax yet).

Thanks!

Gerhard

-- 
Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: 
http://www.gmx.net/de/go/multimessenger
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

2009-01-07 Thread Scott Wood
On Wed, Jan 07, 2009 at 02:54:57PM +0100, Gerhard Pircher wrote:
> +void amigaone_show_cpuinfo(struct seq_file *m)
> +{
> + struct device_node *root;
> + const char *model = "";
> +
> + root = of_find_node_by_path("/");
> + if (root)
> + model = of_get_property(root, "model", NULL);
> + seq_printf(m, "machine\t\t: %s\n", model);
> +
> + of_node_put(root);
> + return;

This is already printed by the generic cpuinfo.

> +void __init amigaone_setup_arch(void)
> +{
> + struct device_node *np;
> +
> + /* Initialization until calibrate_delay() runs. */
> + loops_per_jiffy = 5000/HZ;

Is this really necessary?

> + /* Flush and disable I/D cache. */
> + __asm__ __volatile__ ("mfspr3, 1008"::: "r3");
> + __asm__ __volatile__ ("ori  5, 5, 0xcc00"   ::: "r5");
> + __asm__ __volatile__ ("ori  4, 3, 0xc00"::: "r4");
> + __asm__ __volatile__ ("andc 5, 3, 5"::: "r5");

Don't do this; instead, have one multi-line asm statement (or better yet,
just use mfspr()/mtspr()/sync()/isync()).

GCC is perfectly free to trash your registers in between statements.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/5] powerpc: Add platform support for AmigaOne

2009-01-07 Thread Grant Likely
On Wed, Jan 7, 2009 at 6:54 AM, Gerhard Pircher  wrote:
> +
> +void amigaone_show_cpuinfo(struct seq_file *m)
> +{
> +   struct device_node *root;
> +   const char *model = "";
> +
> +   root = of_find_node_by_path("/");
> +   if (root)
> +   model = of_get_property(root, "model", NULL);
> +   seq_printf(m, "machine\t\t: %s\n", model);
> +
> +   of_node_put(root);
> +   return;
> +}

show_cpuinfo() common code already prints the model.  You can drop this hook.

> +void __init amigaone_setup_arch(void)
> +{
> +   struct device_node *np;
> +
> +   /* Initialization until calibrate_delay() runs. */
> +   loops_per_jiffy = 5000/HZ;

If it doesn't noticeably slow down the boot then I would remove this line.

Otherwise looks okay to me.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 1/5] powerpc: Add platform support for AmigaOne

2009-01-07 Thread Gerhard Pircher
This commit adds the setup code for booting Linux on AmigaOne G3SE (G3
only), AmigaOne XE and uA1 (G3/G4) desktop computers. These boards were
sold by Eyetech and are based on MAI Logic's Teron boards and its
Articia S northbridge.
The AmigaOne uses U-boot as firmware, which doesn't support a flattened
device tree yet. The northbridge has some design flaws, which makes it
necessary to use non cacheable memory for DMA operations
(CONFIG_NOT_COHERENT_CACHE) and to avoid setting the coherence (M) flag
for memory pages.

Signed-off-by: Gerhard Pircher 
---
 arch/powerpc/platforms/Kconfig   |1 +
 arch/powerpc/platforms/Makefile  |1 +
 arch/powerpc/platforms/amigaone/Kconfig  |   18 +++
 arch/powerpc/platforms/amigaone/Makefile |1 +
 arch/powerpc/platforms/amigaone/setup.c  |  197 ++
 5 files changed, 218 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/amigaone/Kconfig
 create mode 100644 arch/powerpc/platforms/amigaone/Makefile
 create mode 100644 arch/powerpc/platforms/amigaone/setup.c

diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 47fe2be..3fce996 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -28,6 +28,7 @@ source "arch/powerpc/platforms/86xx/Kconfig"
 source "arch/powerpc/platforms/embedded6xx/Kconfig"
 source "arch/powerpc/platforms/44x/Kconfig"
 source "arch/powerpc/platforms/40x/Kconfig"
+source "arch/powerpc/platforms/amigaone/Kconfig"
 
 config PPC_NATIVE
bool
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 8079e0b..f741919 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -19,3 +19,4 @@ obj-$(CONFIG_PPC_PASEMI)  += pasemi/
 obj-$(CONFIG_PPC_CELL) += cell/
 obj-$(CONFIG_PPC_PS3)  += ps3/
 obj-$(CONFIG_EMBEDDED6xx)  += embedded6xx/
+obj-$(CONFIG_AMIGAONE) += amigaone/
diff --git a/arch/powerpc/platforms/amigaone/Kconfig 
b/arch/powerpc/platforms/amigaone/Kconfig
new file mode 100644
index 000..9276a96
--- /dev/null
+++ b/arch/powerpc/platforms/amigaone/Kconfig
@@ -0,0 +1,18 @@
+config AMIGAONE
+   bool "Eyetech AmigaOne/MAI Teron"
+   depends on PPC32 && BROKEN_ON_SMP && PPC_MULTIPLATFORM
+   select PPC_I8259
+   select PPC_INDIRECT_PCI
+   select PPC_UDBG_16550
+   select PCI
+   select NOT_COHERENT_CACHE
+   select CHECK_CACHE_COHERENCY
+   select DEFAULT_UIMAGE
+   select PCSPKR_PLATFORM
+   help
+   Select AmigaOne for the following machines:
+   - AmigaOne SE/Teron CX (G3 only)
+   - AmigaOne XE/Teron PX
+   - uA1/Teron mini
+ More information is available at:
+ .
diff --git a/arch/powerpc/platforms/amigaone/Makefile 
b/arch/powerpc/platforms/amigaone/Makefile
new file mode 100644
index 000..e6885b3
--- /dev/null
+++ b/arch/powerpc/platforms/amigaone/Makefile
@@ -0,0 +1 @@
+obj-y  += setup.o
diff --git a/arch/powerpc/platforms/amigaone/setup.c 
b/arch/powerpc/platforms/amigaone/setup.c
new file mode 100644
index 000..30c9b46
--- /dev/null
+++ b/arch/powerpc/platforms/amigaone/setup.c
@@ -0,0 +1,197 @@
+/*
+ * AmigaOne platform setup
+ *
+ * Copyright 2008 Gerhard Pircher (gerhard_pirc...@gmx.net)
+ *
+ *   Based on original amigaone_setup.c source code
+ * Copyright 2003 by Hans-Joerg Frieden and Thomas Frieden
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+void amigaone_show_cpuinfo(struct seq_file *m)
+{
+   struct device_node *root;
+   const char *model = "";
+
+   root = of_find_node_by_path("/");
+   if (root)
+   model = of_get_property(root, "model", NULL);
+   seq_printf(m, "machine\t\t: %s\n", model);
+
+   of_node_put(root);
+   return;
+}
+
+static int __init amigaone_add_bridge(struct device_node *dev)
+{
+   int len;
+   struct pci_controller *hose;
+   const int *bus_range;
+
+   printk(KERN_INFO "Adding PCI host bridge %s\n", dev->full_name);
+
+   bus_range = of_get_property(dev, "bus-range", &len);
+   if ((bus_range == NULL) || (len < 2 * sizeof(int)))
+   printk(KERN_WARNING "Can't get bus-range for %s, assume"
+  " bus 0\n", dev->full_name);
+
+   hose = pcibios_alloc_controller(dev);
+   if (hose == NULL)
+   return -ENOMEM;
+
+   hose->first_busno = bus_range ? bus_range[0] : 0;
+   hose->last_busno = bus_range ? bus_range[1] : 0xff;
+
+   setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc, 0);
+
+   /* Interpret th