[PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-11-16 Thread Andrei Dolnikov
Emerson Katana Qp platform specific code

Signed-off-by: Andrei Dolnikov <[EMAIL PROTECTED]>

---
 arch/powerpc/platforms/embedded6xx/Kconfig|9 +
 arch/powerpc/platforms/embedded6xx/Makefile   |1
 arch/powerpc/platforms/embedded6xx/katanaqp.c |  180 ++
 3 files changed, 190 insertions(+)

diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig 
b/arch/powerpc/platforms/embedded6xx/Kconfig
index 8924095..33190bd 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -46,6 +46,15 @@ config PPC_PRPMC2800
help
  This option enables support for the Motorola PrPMC2800 board
 
+config PPC_KATANAQP
+   bool "Emerson-Katana Qp"
+   depends on EMBEDDED6xx
+   select MV64X60
+   select NOT_COHERENT_CACHE
+   select WANT_DEVICE_TREE
+   help
+ This option enables support for the Emerson Katana Qp board
+
 config TSI108_BRIDGE
bool
depends on MPC7448HPC2 || PPC_HOLLY
diff --git a/arch/powerpc/platforms/embedded6xx/Makefile 
b/arch/powerpc/platforms/embedded6xx/Makefile
index 844947c..c83558f 100644
--- a/arch/powerpc/platforms/embedded6xx/Makefile
+++ b/arch/powerpc/platforms/embedded6xx/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_MPC7448HPC2)   += mpc7448_hpc2.o
 obj-$(CONFIG_LINKSTATION)  += linkstation.o ls_uart.o
 obj-$(CONFIG_PPC_HOLLY)+= holly.o
 obj-$(CONFIG_PPC_PRPMC2800)+= prpmc2800.o
+obj-$(CONFIG_PPC_KATANAQP) += katanaqp.o
diff --git a/arch/powerpc/platforms/embedded6xx/katanaqp.c 
b/arch/powerpc/platforms/embedded6xx/katanaqp.c
new file mode 100644
index 000..c0a8469
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/katanaqp.c
@@ -0,0 +1,180 @@
+/*
+ * Board setup routines for the Emerson Katana Qp
+ *
+ * Authors: Vladislav Buzov <[EMAIL PROTECTED]>
+ * Andrei Dolnikov <[EMAIL PROTECTED]>
+ *
+ * Based on prpmc2800.c by Dale Farnsworth <[EMAIL PROTECTED]>
+ *
+ * 2007 (c) MontaVista, Software, Inc.  This file is licensed under
+ * the terms of the GNU General Public License version 2.  This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define PLATFORM_NAME_MAX  64
+
+/* CPLD registers definitions */
+#define KATANAQP_CPLD_RCR  0x0004  /* Reset command */
+#define KATANAQP_CPLD_RCR_CPUHR(1 << 7)
+
+#define KATANAQP_CPLD_HVR  0x0020
+
+#define KATANAQP_CPLD_PSR  0x0030  /* PCI status */
+#define KATANAQP_CPLD_PSR_PMCM (1 << 1)
+
+#define KATANAQP_CPLD_HCR  0x0044
+
+static char katanaqp_platform_name[PLATFORM_NAME_MAX];
+
+static void __iomem *cpld_base;
+
+int katanaqp_exclude_device(struct pci_controller *hose, u_char bus,
+   u_char devfn)
+{
+   if (bus == 0 && PCI_SLOT(devfn) == 0)
+   return PCIBIOS_DEVICE_NOT_FOUND;
+   else
+   return PCIBIOS_SUCCESSFUL;
+}
+
+static int __init katanaqp_is_monarch(void)
+{
+   return !(in_8((volatile char *)(cpld_base + KATANAQP_CPLD_PSR)) &
+KATANAQP_CPLD_PSR_PMCM);
+}
+
+static void __init katanaqp_setup_arch(void)
+{
+   struct device_node *cpld;
+   const unsigned int *reg;
+
+   /*
+* ioremap cpld registers in case they are later
+* needed by katanaqp_reset_board().
+*/
+   cpld = of_find_node_by_path("/[EMAIL PROTECTED]/[EMAIL PROTECTED]");
+   reg = of_get_property(cpld, "reg", NULL);
+   of_node_put(cpld);
+   cpld_base = ioremap(reg[0], reg[1]);
+
+#ifdef CONFIG_PCI
+   if (katanaqp_is_monarch()) {
+   mv64x60_pci_init();
+   ppc_md.pci_exclude_device = katanaqp_exclude_device;
+   }
+#endif
+
+   printk("Emerson Network Power %s\n", katanaqp_platform_name);
+}
+
+static void katanaqp_reset_board(void)
+{
+   local_irq_disable();
+
+   /* issue hard reset to the reset command register */
+   out_8((volatile char *)(cpld_base + KATANAQP_CPLD_RCR),
+ KATANAQP_CPLD_RCR_CPUHR);
+   for (;;) ;
+}
+
+static void katanaqp_restart(char *cmd)
+{
+   katanaqp_reset_board();
+}
+
+#ifdef CONFIG_NOT_COHERENT_CACHE
+#define KATANAQP_COHERENCY_SETTING "off"
+#else
+#define KATANAQP_COHERENCY_SETTING "on"
+#endif
+
+void katanaqp_show_cpuinfo(struct seq_file *m)
+{
+   uint memsize = total_memory;
+
+   seq_printf(m, "vendor\t\t: Emerson Network Power\n");
+
+   seq_printf(m, "hardware rev\t: %d\n",
+  in_8((volatile char *)(cpld_base + KATANAQP_CPLD_HVR)));
+
+   seq_printf(m, "hardware config\t: %d\n",
+  in_8((volatile char *)(cpld_base + KATANAQP_CPLD_HCR)));
+
+   seq_printf(m, "memory size\t: %d MB\n", memsize / (1024 * 1024));
+
+   seq_printf(m, "voherency\t: %s\n", KATANAQP_COH

[PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-11-29 Thread Andrei Dolnikov
Emerson Katana Qp platform specific code

Signed-off-by: Andrei Dolnikov <[EMAIL PROTECTED]>

---
 Kconfig|9 +++
 Makefile   |1
 katanaqp.c |  168 +
 3 files changed, 178 insertions(+)

diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig 
b/arch/powerpc/platforms/embedded6xx/Kconfig
index 8924095..33190bd 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -46,6 +46,15 @@ config PPC_PRPMC2800
help
  This option enables support for the Motorola PrPMC2800 board
 
+config PPC_KATANAQP
+   bool "Emerson-Katana Qp"
+   depends on EMBEDDED6xx
+   select MV64X60
+   select NOT_COHERENT_CACHE
+   select WANT_DEVICE_TREE
+   help
+ This option enables support for the Emerson Katana Qp board
+
 config TSI108_BRIDGE
bool
depends on MPC7448HPC2 || PPC_HOLLY
diff --git a/arch/powerpc/platforms/embedded6xx/Makefile 
b/arch/powerpc/platforms/embedded6xx/Makefile
index 844947c..c83558f 100644
--- a/arch/powerpc/platforms/embedded6xx/Makefile
+++ b/arch/powerpc/platforms/embedded6xx/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_MPC7448HPC2)   += mpc7448_hpc2.o
 obj-$(CONFIG_LINKSTATION)  += linkstation.o ls_uart.o
 obj-$(CONFIG_PPC_HOLLY)+= holly.o
 obj-$(CONFIG_PPC_PRPMC2800)+= prpmc2800.o
+obj-$(CONFIG_PPC_KATANAQP) += katanaqp.o
diff --git a/arch/powerpc/platforms/embedded6xx/katanaqp.c 
b/arch/powerpc/platforms/embedded6xx/katanaqp.c
new file mode 100644
index 000..64fb608
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/katanaqp.c
@@ -0,0 +1,168 @@
+/*
+ * Board setup routines for the Emerson Katana Qp
+ *
+ * Authors: Vladislav Buzov <[EMAIL PROTECTED]>
+ * Andrei Dolnikov <[EMAIL PROTECTED]>
+ *
+ * Based on prpmc2800.c by Dale Farnsworth <[EMAIL PROTECTED]>
+ *
+ * 2007 (c) MontaVista, Software, Inc.  This file is licensed under
+ * the terms of the GNU General Public License version 2.  This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#define PLATFORM_NAME_MAX  64
+
+/* CPLD registers definitions */
+#define KATANAQP_CPLD_RCR  0x0004  /* Reset command */
+#define KATANAQP_CPLD_RCR_CPUHR(1 << 7)
+
+#define KATANAQP_CPLD_HVR  0x0020
+
+#define KATANAQP_CPLD_PSR  0x0030  /* PCI status */
+#define KATANAQP_CPLD_PSR_PMCM (1 << 1)
+
+#define KATANAQP_CPLD_HCR  0x0044
+
+static char katanaqp_platform_name[PLATFORM_NAME_MAX];
+
+static void __iomem *cpld_base;
+
+static int katanaqp_exclude_device(struct pci_controller *hose, u_char bus,
+   u_char devfn)
+{
+   if (bus == 0 && PCI_SLOT(devfn) == 0)
+   return PCIBIOS_DEVICE_NOT_FOUND;
+   else
+   return PCIBIOS_SUCCESSFUL;
+}
+
+static int __init katanaqp_is_monarch(void)
+{
+   return !(in_8(cpld_base + KATANAQP_CPLD_PSR) &
+KATANAQP_CPLD_PSR_PMCM);
+}
+
+static void __init katanaqp_setup_arch(void)
+{
+   struct device_node *cpld;
+
+   /*
+* ioremap cpld registers in case they are later
+* needed by katanaqp_reset_board().
+*/
+   cpld = of_find_compatible_node(NULL, NULL, "altera,maxii");
+   cpld_base = of_iomap(cpld, 0);
+
+#ifdef CONFIG_PCI
+   if (katanaqp_is_monarch()) {
+   mv64x60_pci_init();
+   ppc_md.pci_exclude_device = katanaqp_exclude_device;
+   }
+#endif
+
+   printk("Emerson Network Power %s\n", katanaqp_platform_name);
+}
+
+static void katanaqp_reset_board(void)
+{
+   local_irq_disable();
+
+   /* issue hard reset to the reset command register */
+   out_8(cpld_base + KATANAQP_CPLD_RCR, KATANAQP_CPLD_RCR_CPUHR);
+   for (;;) ;
+}
+
+static void katanaqp_restart(char *cmd)
+{
+   katanaqp_reset_board();
+}
+
+static void katanaqp_show_cpuinfo(struct seq_file *m)
+{
+   uint memsize = total_memory;
+
+   seq_printf(m, "vendor\t\t: Emerson Network Power\n");
+
+   seq_printf(m, "hardware rev\t: %d\n",
+  in_8(cpld_base + KATANAQP_CPLD_HVR));
+
+   seq_printf(m, "hardware config\t: %d\n",
+  in_8(cpld_base + KATANAQP_CPLD_HCR));
+
+   seq_printf(m, "memory size\t: %d MB\n", memsize / (1024 * 1024));
+
+   seq_printf(m, "PCI\t\t: %sMonarch\n",
+  katanaqp_is_monarch() ? "" : "Non-");
+}
+
+static int __init katanaqp_of_init(void)
+{
+   struct device_node *np;
+
+   np = of_find_compatible_node(NULL, NULL, "cfi-flash");
+   if (np)
+   of_platform_device_create(np, "of-flash", NULL);
+
+   return 0;
+}
+
+device_initcall(katanaqp_of_init);
+
+/*
+ * Called very early, device-tree isn't unflattened
+ */
+s

Re: [PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-11-21 Thread Vitaly Bordug
Hi Andrei,

Looks okay in general, some notes below...

On Fri, 16 Nov 2007 19:31:16 +0300
Andrei Dolnikov wrote:

> Emerson Katana Qp platform specific code
> 
> Signed-off-by: Andrei Dolnikov <[EMAIL PROTECTED]>
> 
> ---
>  arch/powerpc/platforms/embedded6xx/Kconfig|9 +
>  arch/powerpc/platforms/embedded6xx/Makefile   |1
>  arch/powerpc/platforms/embedded6xx/katanaqp.c |  180
> ++ 3 files changed, 190 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig
> b/arch/powerpc/platforms/embedded6xx/Kconfig index 8924095..33190bd
> 100644 --- a/arch/powerpc/platforms/embedded6xx/Kconfig
> +++ b/arch/powerpc/platforms/embedded6xx/Kconfig
> @@ -46,6 +46,15 @@ config PPC_PRPMC2800
>   help
> This option enables support for the Motorola PrPMC2800
> board 
> +config PPC_KATANAQP
> + bool "Emerson-Katana Qp"
> + depends on EMBEDDED6xx
> + select MV64X60
> + select NOT_COHERENT_CACHE
> + select WANT_DEVICE_TREE
> + help
> +   This option enables support for the Emerson Katana Qp board
> +
>  config TSI108_BRIDGE
>   bool
>   depends on MPC7448HPC2 || PPC_HOLLY
> diff --git a/arch/powerpc/platforms/embedded6xx/Makefile
> b/arch/powerpc/platforms/embedded6xx/Makefile index 844947c..c83558f
> 100644 --- a/arch/powerpc/platforms/embedded6xx/Makefile
> +++ b/arch/powerpc/platforms/embedded6xx/Makefile
> @@ -5,3 +5,4 @@ obj-$(CONFIG_MPC7448HPC2) += mpc7448_hpc2.o
>  obj-$(CONFIG_LINKSTATION)+= linkstation.o ls_uart.o
>  obj-$(CONFIG_PPC_HOLLY)  += holly.o
>  obj-$(CONFIG_PPC_PRPMC2800)  += prpmc2800.o
> +obj-$(CONFIG_PPC_KATANAQP)   += katanaqp.o
> diff --git a/arch/powerpc/platforms/embedded6xx/katanaqp.c
> b/arch/powerpc/platforms/embedded6xx/katanaqp.c new file mode 100644
> index 000..c0a8469
> --- /dev/null
> +++ b/arch/powerpc/platforms/embedded6xx/katanaqp.c
> @@ -0,0 +1,180 @@
> +/*
> + * Board setup routines for the Emerson Katana Qp
> + *
> + * Authors: Vladislav Buzov <[EMAIL PROTECTED]>
> + *   Andrei Dolnikov <[EMAIL PROTECTED]>
> + *
> + * Based on prpmc2800.c by Dale Farnsworth <[EMAIL PROTECTED]>
> + *
> + * 2007 (c) MontaVista, Software, Inc.  This file is licensed under
> + * the terms of the GNU General Public License version 2.  This
> program
> + * is licensed "as is" without any warranty of any kind, whether
> express
> + * or implied.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +
> +#define PLATFORM_NAME_MAX64
> +
> +/* CPLD registers definitions */
> +#define KATANAQP_CPLD_RCR0x0004  /* Reset command */
> +#define KATANAQP_CPLD_RCR_CPUHR  (1 << 7)
> +
> +#define KATANAQP_CPLD_HVR0x0020
> +
> +#define KATANAQP_CPLD_PSR0x0030  /* PCI status */
> +#define KATANAQP_CPLD_PSR_PMCM   (1 << 1)
> +
> +#define KATANAQP_CPLD_HCR0x0044
> +
> +static char katanaqp_platform_name[PLATFORM_NAME_MAX];
> +
> +static void __iomem *cpld_base;
> +
> +int katanaqp_exclude_device(struct pci_controller *hose, u_char bus,
> + u_char devfn)
> +{
> + if (bus == 0 && PCI_SLOT(devfn) == 0)
> + return PCIBIOS_DEVICE_NOT_FOUND;
> + else
> + return PCIBIOS_SUCCESSFUL;
> +}
> +
> +static int __init katanaqp_is_monarch(void)
> +{
> + return !(in_8((volatile char *)(cpld_base +
> KATANAQP_CPLD_PSR)) &
> +  KATANAQP_CPLD_PSR_PMCM);
> +}
> +
> +static void __init katanaqp_setup_arch(void)
> +{
> + struct device_node *cpld;
> + const unsigned int *reg;
> +
> + /*
> +  * ioremap cpld registers in case they are later
> +  * needed by katanaqp_reset_board().
> +  */
> + cpld =
> of_find_node_by_path("/[EMAIL PROTECTED]/[EMAIL PROTECTED]");
> + reg = of_get_property(cpld, "reg", NULL);
> + of_node_put(cpld);
> + cpld_base = ioremap(reg[0], reg[1]);
> +
use of_iomap here?

> +#ifdef CONFIG_PCI
> + if (katanaqp_is_monarch()) {
> + mv64x60_pci_init();
> + ppc_md.pci_exclude_device = katanaqp_exclude_device;
> + }
> +#endif
> +
> + printk("Emerson Network Power %s\n", katanaqp_platform_name);
> +}
> +
> +static void katanaqp_reset_board(void)
> +{
> + local_irq_disable();
> +
> + /* issue hard reset to the reset command register */
> + out_8((volatile char *)(cpld_base + KATANAQP_CPLD_RCR),
> +   KATANAQP_CPLD_RCR_CPUHR);
> + for (;;) ;
> +}
> +
> +static void katanaqp_restart(char *cmd)
> +{
> + katanaqp_reset_board();
> +}
> +
> +#ifdef CONFIG_NOT_COHERENT_CACHE
> +#define KATANAQP_COHERENCY_SETTING "off"
> +#else
> +#define KATANAQP_COHERENCY_SETTING "on"
> +#endif
> +
Does it mean this HW supports both coherent and non-coherent case?
I don't think we need to add this just "for the future" if QP doesn't have it.

If it does, I dont' see how it's being 

Re: [PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-11-24 Thread Arnd Bergmann
On Friday 16 November 2007, Andrei Dolnikov wrote:

> +static int __init katanaqp_is_monarch(void)
> +{
> + return !(in_8((volatile char *)(cpld_base + KATANAQP_CPLD_PSR)) &
> +  KATANAQP_CPLD_PSR_PMCM);
> +}

The pointer here needs to be __iomem, not volatile. Same in other places.
Please use 'sparse' to check your code for bugs like this.

> +
> +static void __init katanaqp_setup_arch(void)
> +{
> + struct device_node *cpld;
> + const unsigned int *reg;
> +
> + /*
> +  * ioremap cpld registers in case they are later
> +  * needed by katanaqp_reset_board().
> +  */
> + cpld = of_find_node_by_path("/[EMAIL PROTECTED]/[EMAIL PROTECTED]");

It doesn't sounds good to hardcode the path for this device.
Instead, it would be much better to look for the 'compatible' property
here.

> +static int __init katanaqp_of_init(void)
> +{
> + struct device_node *np;
> +
> + np = of_find_compatible_node(NULL, NULL, "cfi-flash");
> + if (np)
> + of_platform_device_create(np, "of-flash", NULL);
> +
> + return 0;
> +}
> +
> +device_initcall(katanaqp_of_init);

This should be done automatically using of_platform_bus_probe().

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


Re: [PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-11-24 Thread Benjamin Herrenschmidt

On Sat, 2007-11-24 at 19:51 +0100, Arnd Bergmann wrote:
> 
> This should be done automatically using of_platform_bus_probe().

Not necessarily. of_platform_bus_probe() is an optional facility that is
common used by SoCs that have lots of otherwise non-probable on chip
devices, but for platforms with more classic setups, it's totally
acceptable to have the platform code explicitely register only those
devices it wants exposed.

Ben.


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


Re: [PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-12-03 Thread Benjamin Herrenschmidt

On Thu, 2007-11-29 at 18:42 +0300, Andrei Dolnikov wrote:
> +config PPC_KATANAQP
> +   bool "Emerson-Katana Qp"
> +   depends on EMBEDDED6xx
> +   select MV64X60
> +   select NOT_COHERENT_CACHE
 ^^

Just one word: ARG !

Oh and another one: WHY ?

Ben.


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


Re: [PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-12-03 Thread Mark A. Greer
On Tue, Dec 04, 2007 at 07:54:59AM +1100, Benjamin Herrenschmidt wrote:
> 
> On Thu, 2007-11-29 at 18:42 +0300, Andrei Dolnikov wrote:
> > +config PPC_KATANAQP
> > +   bool "Emerson-Katana Qp"
> > +   depends on EMBEDDED6xx
> > +   select MV64X60
> > +   select NOT_COHERENT_CACHE
>  ^^
> 
> Just one word: ARG !
> 
> Oh and another one: WHY ?

I responded to your other email regarding this.

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


Re: [PATCH 4/5] PowerPC 74xx: Katana Qp base support

2007-12-11 Thread Mark A. Greer
On Thu, Nov 29, 2007 at 06:42:00PM +0300, Andrei Dolnikov wrote:
> Emerson Katana Qp platform specific code
> 
> Signed-off-by: Andrei Dolnikov <[EMAIL PROTECTED]>

Acked-by: Mark A. Greer <[EMAIL PROTECTED]>
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev