Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH -mm 2/4] MIPS: BCM947xx support
@ 2007-08-06 15:09 Aurelien Jarno
  2007-08-06 18:05 ` Michael Buesch
  0 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-06 15:09 UTC (permalink / raw)
  To: Andrew Morton, linux-mips
  Cc: Michael Buesch, Waldemar Brodkorb, Felix Fietkau,
	Florian Schirmer

The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
It originally comes from the OpenWrt patches.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Waldemar Brodkorb <wbx@openwrt.org>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/bcm947xx/irq.c
+++ b/arch/mips/bcm947xx/irq.c
@@ -0,0 +1,63 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/smp.h>
+#include <linux/types.h>
+
+#include <asm/cpu.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/irq_cpu.h>
+
+void plat_irq_dispatch(void)
+{
+	u32 cause;
+
+	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
+
+	clear_c0_status(cause);
+
+	if (cause & CAUSEF_IP7)
+		do_IRQ(7);
+	if (cause & CAUSEF_IP2)
+		do_IRQ(2);
+	if (cause & CAUSEF_IP3)
+		do_IRQ(3);
+	if (cause & CAUSEF_IP4)
+		do_IRQ(4);
+	if (cause & CAUSEF_IP5)
+		do_IRQ(5);
+	if (cause & CAUSEF_IP6)
+		do_IRQ(6);
+}
+
+void __init arch_init_irq(void)
+{
+	mips_cpu_irq_init();
+}
--- a/arch/mips/bcm947xx/prom.c
+++ b/arch/mips/bcm947xx/prom.c
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <asm/pmon.h>
+
+const char *get_system_type(void)
+{
+	return "Broadcom BCM947xx";
+}
+
+void __init prom_init(void)
+{
+	unsigned long mem;
+
+	mips_machgroup = MACH_GROUP_BRCM;
+	mips_machtype = MACH_BCM947XX;
+
+	/* Figure out memory size by finding aliases */
+	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
+		if (*(unsigned long *)((unsigned long)(prom_init) + mem) == 
+		    *(unsigned long *)(prom_init))
+			break;
+	}
+
+	add_memory_region(0, mem, BOOT_MEM_RAM);
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
--- a/arch/mips/bcm947xx/setup.c	
+++ b/arch/mips/bcm947xx/setup.c
@@ -0,0 +1,106 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
+ *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/serial_reg.h>
+#include <linux/serial_8250.h>
+#include <asm/bootinfo.h>
+#include <asm/time.h>
+#include <asm/reboot.h>
+#include <linux/pm.h>
+#include <linux/ssb/ssb.h>
+
+extern void bcm947xx_pci_init(void);
+extern void bcm947xx_time_init(void);
+
+struct ssb_bus ssb;
+
+static void bcm947xx_machine_restart(char *command)
+{
+	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
+	local_irq_disable();
+	/* Set the watchdog timer to reset immediately */
+	ssb_chipco_watchdog_timer_set(&ssb.chipco, 1);
+	while (1)
+		cpu_relax();
+}
+
+static void bcm947xx_machine_halt(void)
+{
+	/* Disable interrupts and watchdog and spin forever */
+	local_irq_disable();
+	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
+	while (1)
+		cpu_relax();
+}
+
+static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
+{
+	return 0;
+}
+
+void __init plat_mem_setup(void)
+{
+	int i, err;
+	struct ssb_mipscore *mcore;
+
+	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
+	if (err) {
+		const char *msg = "Failed to initialize SSB bus (err %d)\n";
+		panic(msg, err);
+	}
+	mcore = &ssb.mipscore;
+
+#ifdef CONFIG_SERIAL_8250
+	for (i = 0; i < mcore->nr_serial_ports; i++) {
+		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
+		struct uart_port s;
+	
+		memset(&s, 0, sizeof(s));
+		s.line = i;
+		s.membase = port->regs;
+		s.irq = port->irq + 2;
+		s.uartclk = port->baud_base;
+		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
+		s.iotype = SERIAL_IO_MEM;
+		s.regshift = port->reg_shift;
+
+		early_serial_setup(&s);
+	}
+#endif
+
+	_machine_restart = bcm947xx_machine_restart;
+	_machine_halt = bcm947xx_machine_halt;
+	pm_power_off = bcm947xx_machine_halt;
+	board_time_init = bcm947xx_time_init;
+}
+
+EXPORT_SYMBOL(ssb);
--- a/arch/mips/bcm947xx/time.c
+++ b/arch/mips/bcm947xx/time.c
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/serial_reg.h>
+#include <linux/interrupt.h>
+#include <linux/ssb/ssb.h>
+#include <asm/addrspace.h>
+#include <asm/io.h>
+#include <asm/time.h>
+
+extern struct ssb_bus ssb;
+
+void __init
+bcm947xx_time_init(void)
+{
+	unsigned long hz;
+
+	/*
+	 * Use deterministic values for initial counter interrupt
+	 * so that calibrate delay avoids encountering a counter wrap.
+	 */
+	write_c0_count(0);
+	write_c0_compare(0xffff);
+
+	hz = ssb_cpu_clock(&ssb.mipscore) / 2;
+	if (!hz)
+		hz = 100000000;
+
+	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
+	mips_hpt_frequency = hz;
+}
+
+void __init
+plat_timer_setup(struct irqaction *irq)
+{
+	/* Enable the timer interrupt */
+	setup_irq(7, irq);
+}
--- a/arch/mips/bcm947xx/Makefile
+++ b/arch/mips/bcm947xx/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the BCM947xx specific kernel interface routines
+# under Linux.
+#
+
+obj-y := irq.o prom.o setup.o time.o

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support
  2007-08-06 15:09 [PATCH -mm 2/4] MIPS: BCM947xx support Aurelien Jarno
@ 2007-08-06 18:05 ` Michael Buesch
  2007-08-06 18:33   ` Aurelien Jarno
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Buesch @ 2007-08-06 18:05 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Andrew Morton, linux-mips, Waldemar Brodkorb, Felix Fietkau,
	Florian Schirmer

On Monday 06 August 2007, Aurelien Jarno wrote:
> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> It originally comes from the OpenWrt patches.
> 
> Cc: Michael Buesch <mb@bu3sch.de>
> Cc: Waldemar Brodkorb <wbx@openwrt.org>
> Cc: Felix Fietkau <nbd@openwrt.org>
> Cc: Florian Schirmer <jolt@tuxbox.org>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> --- a/arch/mips/bcm947xx/irq.c
> +++ b/arch/mips/bcm947xx/irq.c
> @@ -0,0 +1,63 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/module.h>
> +#include <linux/smp.h>
> +#include <linux/types.h>
> +
> +#include <asm/cpu.h>
> +#include <asm/io.h>
> +#include <asm/irq.h>
> +#include <asm/irq_cpu.h>
> +
> +void plat_irq_dispatch(void)
> +{
> +	u32 cause;
> +
> +	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
> +
> +	clear_c0_status(cause);
> +
> +	if (cause & CAUSEF_IP7)
> +		do_IRQ(7);
> +	if (cause & CAUSEF_IP2)
> +		do_IRQ(2);
> +	if (cause & CAUSEF_IP3)
> +		do_IRQ(3);
> +	if (cause & CAUSEF_IP4)
> +		do_IRQ(4);
> +	if (cause & CAUSEF_IP5)
> +		do_IRQ(5);
> +	if (cause & CAUSEF_IP6)
> +		do_IRQ(6);
> +}
> +
> +void __init arch_init_irq(void)
> +{
> +	mips_cpu_irq_init();
> +}
> --- a/arch/mips/bcm947xx/prom.c
> +++ b/arch/mips/bcm947xx/prom.c
> @@ -0,0 +1,58 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/sched.h>
> +#include <linux/bootmem.h>
> +
> +#include <asm/addrspace.h>
> +#include <asm/bootinfo.h>
> +#include <asm/pmon.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "Broadcom BCM947xx";
> +}
> +
> +void __init prom_init(void)
> +{
> +	unsigned long mem;
> +
> +	mips_machgroup = MACH_GROUP_BRCM;
> +	mips_machtype = MACH_BCM947XX;
> +
> +	/* Figure out memory size by finding aliases */
> +	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
> +		if (*(unsigned long *)((unsigned long)(prom_init) + mem) == 
> +		    *(unsigned long *)(prom_init))
> +			break;
> +	}
> +
> +	add_memory_region(0, mem, BOOT_MEM_RAM);
> +}
> +
> +void __init prom_free_prom_memory(void)
> +{
> +}
> --- a/arch/mips/bcm947xx/setup.c	
> +++ b/arch/mips/bcm947xx/setup.c
> @@ -0,0 +1,106 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
> + *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
> + *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/types.h>
> +#include <linux/tty.h>
> +#include <linux/serial.h>
> +#include <linux/serial_core.h>
> +#include <linux/serial_reg.h>
> +#include <linux/serial_8250.h>
> +#include <asm/bootinfo.h>
> +#include <asm/time.h>
> +#include <asm/reboot.h>
> +#include <linux/pm.h>
> +#include <linux/ssb/ssb.h>
> +
> +extern void bcm947xx_pci_init(void);
> +extern void bcm947xx_time_init(void);
> +
> +struct ssb_bus ssb;
> +
> +static void bcm947xx_machine_restart(char *command)
> +{
> +	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
> +	local_irq_disable();
> +	/* Set the watchdog timer to reset immediately */
> +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 1);
> +	while (1)
> +		cpu_relax();
> +}
> +
> +static void bcm947xx_machine_halt(void)
> +{
> +	/* Disable interrupts and watchdog and spin forever */
> +	local_irq_disable();
> +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
> +	while (1)
> +		cpu_relax();
> +}
> +
> +static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
> +{

No reading of NVRAM, yet?

> +	return 0;
> +}
> +
> +void __init plat_mem_setup(void)
> +{
> +	int i, err;
> +	struct ssb_mipscore *mcore;
> +
> +	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
> +	if (err) {
> +		const char *msg = "Failed to initialize SSB bus (err %d)\n";
> +		panic(msg, err);

We don't need the msg variable anymore.

> +	}
> +	mcore = &ssb.mipscore;
> +
> +#ifdef CONFIG_SERIAL_8250
> +	for (i = 0; i < mcore->nr_serial_ports; i++) {
> +		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
> +		struct uart_port s;
> +	
> +		memset(&s, 0, sizeof(s));
> +		s.line = i;
> +		s.membase = port->regs;
> +		s.irq = port->irq + 2;
> +		s.uartclk = port->baud_base;
> +		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
> +		s.iotype = SERIAL_IO_MEM;
> +		s.regshift = port->reg_shift;
> +
> +		early_serial_setup(&s);
> +	}
> +#endif
> +
> +	_machine_restart = bcm947xx_machine_restart;
> +	_machine_halt = bcm947xx_machine_halt;
> +	pm_power_off = bcm947xx_machine_halt;
> +	board_time_init = bcm947xx_time_init;
> +}
> +
> +EXPORT_SYMBOL(ssb);
> --- a/arch/mips/bcm947xx/time.c
> +++ b/arch/mips/bcm947xx/time.c
> @@ -0,0 +1,62 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/sched.h>
> +#include <linux/serial_reg.h>
> +#include <linux/interrupt.h>
> +#include <linux/ssb/ssb.h>
> +#include <asm/addrspace.h>
> +#include <asm/io.h>
> +#include <asm/time.h>
> +
> +extern struct ssb_bus ssb;
> +
> +void __init
> +bcm947xx_time_init(void)
> +{
> +	unsigned long hz;
> +
> +	/*
> +	 * Use deterministic values for initial counter interrupt
> +	 * so that calibrate delay avoids encountering a counter wrap.
> +	 */
> +	write_c0_count(0);
> +	write_c0_compare(0xffff);
> +
> +	hz = ssb_cpu_clock(&ssb.mipscore) / 2;
> +	if (!hz)
> +		hz = 100000000;
> +
> +	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
> +	mips_hpt_frequency = hz;
> +}
> +
> +void __init
> +plat_timer_setup(struct irqaction *irq)
> +{
> +	/* Enable the timer interrupt */
> +	setup_irq(7, irq);
> +}
> --- a/arch/mips/bcm947xx/Makefile
> +++ b/arch/mips/bcm947xx/Makefile
> @@ -0,0 +1,6 @@
> +#
> +# Makefile for the BCM947xx specific kernel interface routines
> +# under Linux.
> +#
> +
> +obj-y := irq.o prom.o setup.o time.o
> 

The patch, except the tiny comments above is
Acked-by: Michael Buesch <mb@bu3sch.de>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support
  2007-08-06 18:05 ` Michael Buesch
@ 2007-08-06 18:33   ` Aurelien Jarno
  2007-08-06 18:37     ` Michael Buesch
  0 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-06 18:33 UTC (permalink / raw)
  To: Michael Buesch
  Cc: Andrew Morton, linux-mips, Waldemar Brodkorb, Felix Fietkau,
	Florian Schirmer

On Mon, Aug 06, 2007 at 08:05:29PM +0200, Michael Buesch wrote:
> On Monday 06 August 2007, Aurelien Jarno wrote:
> > The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> > It originally comes from the OpenWrt patches.
> > 
> > Cc: Michael Buesch <mb@bu3sch.de>
> > Cc: Waldemar Brodkorb <wbx@openwrt.org>
> > Cc: Felix Fietkau <nbd@openwrt.org>
> > Cc: Florian Schirmer <jolt@tuxbox.org>
> > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

[snip]

> > --- a/arch/mips/bcm947xx/setup.c	
> > +++ b/arch/mips/bcm947xx/setup.c
> > @@ -0,0 +1,106 @@

[snip]

> > +static void bcm947xx_machine_halt(void)
> > +{
> > +	/* Disable interrupts and watchdog and spin forever */
> > +	local_irq_disable();
> > +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
> > +	while (1)
> > +		cpu_relax();
> > +}
> > +
> > +static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
> > +{
> 
> No reading of NVRAM, yet?

This requires CFE support, and this part is still a bit problematic now.
There are already CFE files for SiByte support, and I think it's not a
good idea to have too different implementations.

I will add a comment here;

> > +	return 0;
> > +}
> > +
> > +void __init plat_mem_setup(void)
> > +{
> > +	int i, err;
> > +	struct ssb_mipscore *mcore;
> > +
> > +	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
> > +	if (err) {
> > +		const char *msg = "Failed to initialize SSB bus (err %d)\n";
> > +		panic(msg, err);
> 
> We don't need the msg variable anymore.

I will fix that.


-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support
  2007-08-06 18:33   ` Aurelien Jarno
@ 2007-08-06 18:37     ` Michael Buesch
  2007-08-06 19:17       ` [PATCH -mm 2/4] MIPS: BCM947xx support (v2) Aurelien Jarno
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Buesch @ 2007-08-06 18:37 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Andrew Morton, linux-mips, Waldemar Brodkorb, Felix Fietkau,
	Florian Schirmer

On Monday 06 August 2007, Aurelien Jarno wrote:
> On Mon, Aug 06, 2007 at 08:05:29PM +0200, Michael Buesch wrote:
> > On Monday 06 August 2007, Aurelien Jarno wrote:
> > > The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> > > It originally comes from the OpenWrt patches.
> > > 
> > > Cc: Michael Buesch <mb@bu3sch.de>
> > > Cc: Waldemar Brodkorb <wbx@openwrt.org>
> > > Cc: Felix Fietkau <nbd@openwrt.org>
> > > Cc: Florian Schirmer <jolt@tuxbox.org>
> > > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> [snip]
> 
> > > --- a/arch/mips/bcm947xx/setup.c	
> > > +++ b/arch/mips/bcm947xx/setup.c
> > > @@ -0,0 +1,106 @@
> 
> [snip]
> 
> > > +static void bcm947xx_machine_halt(void)
> > > +{
> > > +	/* Disable interrupts and watchdog and spin forever */
> > > +	local_irq_disable();
> > > +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
> > > +	while (1)
> > > +		cpu_relax();
> > > +}
> > > +
> > > +static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
> > > +{
> > 
> > No reading of NVRAM, yet?
> 
> This requires CFE support, and this part is still a bit problematic now.
> There are already CFE files for SiByte support, and I think it's not a
> good idea to have too different implementations.

Yep, I forgot about that. My CFE stuff should probably partly get
merged into the existing CFE stuff, if neeeded.
So let's leave this out for now.

> I will add a comment here;
> 
> > > +	return 0;
> > > +}
> > > +
> > > +void __init plat_mem_setup(void)
> > > +{
> > > +	int i, err;
> > > +	struct ssb_mipscore *mcore;
> > > +
> > > +	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
> > > +	if (err) {
> > > +		const char *msg = "Failed to initialize SSB bus (err %d)\n";
> > > +		panic(msg, err);
> > 
> > We don't need the msg variable anymore.
> 
> I will fix that.
> 
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-06 18:37     ` Michael Buesch
@ 2007-08-06 19:17       ` Aurelien Jarno
  2007-08-06 19:22         ` Michael Buesch
                           ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-06 19:17 UTC (permalink / raw)
  To: Michael Buesch
  Cc: Andrew Morton, linux-mips, Waldemar Brodkorb, Felix Fietkau,
	Florian Schirmer

The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
It originally comes from the OpenWrt patches.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Waldemar Brodkorb <wbx@openwrt.org>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/bcm947xx/irq.c
+++ b/arch/mips/bcm947xx/irq.c
@@ -0,0 +1,63 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/smp.h>
+#include <linux/types.h>
+
+#include <asm/cpu.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/irq_cpu.h>
+
+void plat_irq_dispatch(void)
+{
+	u32 cause;
+
+	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
+
+	clear_c0_status(cause);
+
+	if (cause & CAUSEF_IP7)
+		do_IRQ(7);
+	if (cause & CAUSEF_IP2)
+		do_IRQ(2);
+	if (cause & CAUSEF_IP3)
+		do_IRQ(3);
+	if (cause & CAUSEF_IP4)
+		do_IRQ(4);
+	if (cause & CAUSEF_IP5)
+		do_IRQ(5);
+	if (cause & CAUSEF_IP6)
+		do_IRQ(6);
+}
+
+void __init arch_init_irq(void)
+{
+	mips_cpu_irq_init();
+}
--- a/arch/mips/bcm947xx/Makefile
+++ b/arch/mips/bcm947xx/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the BCM947xx specific kernel interface routines
+# under Linux.
+#
+
+obj-y := irq.o prom.o setup.o time.o
--- a/arch/mips/bcm947xx/prom.c
+++ b/arch/mips/bcm947xx/prom.c
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <asm/pmon.h>
+
+const char *get_system_type(void)
+{
+	return "Broadcom BCM947xx";
+}
+
+void __init prom_init(void)
+{
+	unsigned long mem;
+
+	mips_machgroup = MACH_GROUP_BRCM;
+	mips_machtype = MACH_BCM947XX;
+
+	/* Figure out memory size by finding aliases */
+	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
+		if (*(unsigned long *)((unsigned long)(prom_init) + mem) == 
+		    *(unsigned long *)(prom_init))
+			break;
+	}
+
+	add_memory_region(0, mem, BOOT_MEM_RAM);
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
--- a/arch/mips/bcm947xx/setup.c
+++ b/arch/mips/bcm947xx/setup.c
@@ -0,0 +1,108 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
+ *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/serial_reg.h>
+#include <linux/serial_8250.h>
+#include <asm/bootinfo.h>
+#include <asm/time.h>
+#include <asm/reboot.h>
+#include <linux/pm.h>
+#include <linux/ssb/ssb.h>
+
+extern void bcm947xx_pci_init(void);
+extern void bcm947xx_time_init(void);
+
+struct ssb_bus ssb;
+
+static void bcm947xx_machine_restart(char *command)
+{
+	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
+	local_irq_disable();
+	/* Set the watchdog timer to reset immediately */
+	ssb_chipco_watchdog_timer_set(&ssb.chipco, 1);
+	while (1)
+		cpu_relax();
+}
+
+static void bcm947xx_machine_halt(void)
+{
+	/* Disable interrupts and watchdog and spin forever */
+	local_irq_disable();
+	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
+	while (1)
+		cpu_relax();
+}
+
+static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
+{
+	/* TODO: fill ssb_init_invariants using boardtype/boardrev 
+	 * CFE environment variables.
+	 */
+
+	return 0;
+}
+
+void __init plat_mem_setup(void)
+{
+	int i, err;
+	struct ssb_mipscore *mcore;
+
+	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
+	if (err)
+		panic("Failed to initialize SSB bus (err %d)\n", err);
+	mcore = &ssb.mipscore;
+
+#ifdef CONFIG_SERIAL_8250
+	for (i = 0; i < mcore->nr_serial_ports; i++) {
+		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
+		struct uart_port s;
+	
+		memset(&s, 0, sizeof(s));
+		s.line = i;
+		s.membase = port->regs;
+		s.irq = port->irq + 2;
+		s.uartclk = port->baud_base;
+		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
+		s.iotype = SERIAL_IO_MEM;
+		s.regshift = port->reg_shift;
+
+		early_serial_setup(&s);
+	}
+#endif
+
+	_machine_restart = bcm947xx_machine_restart;
+	_machine_halt = bcm947xx_machine_halt;
+	pm_power_off = bcm947xx_machine_halt;
+	board_time_init = bcm947xx_time_init;
+}
+
+EXPORT_SYMBOL(ssb);
--- a/arch/mips/bcm947xx/time.c
+++ b/arch/mips/bcm947xx/time.c
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/serial_reg.h>
+#include <linux/interrupt.h>
+#include <linux/ssb/ssb.h>
+#include <asm/addrspace.h>
+#include <asm/io.h>
+#include <asm/time.h>
+
+extern struct ssb_bus ssb;
+
+void __init
+bcm947xx_time_init(void)
+{
+	unsigned long hz;
+
+	/*
+	 * Use deterministic values for initial counter interrupt
+	 * so that calibrate delay avoids encountering a counter wrap.
+	 */
+	write_c0_count(0);
+	write_c0_compare(0xffff);
+
+	hz = ssb_cpu_clock(&ssb.mipscore) / 2;
+	if (!hz)
+		hz = 100000000;
+
+	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
+	mips_hpt_frequency = hz;
+}
+
+void __init
+plat_timer_setup(struct irqaction *irq)
+{
+	/* Enable the timer interrupt */
+	setup_irq(7, irq);
+}

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-06 19:17       ` [PATCH -mm 2/4] MIPS: BCM947xx support (v2) Aurelien Jarno
@ 2007-08-06 19:22         ` Michael Buesch
  2007-08-06 20:31         ` Florian Schirmer
  2007-08-07  0:40         ` Yoichi Yuasa
  2 siblings, 0 replies; 25+ messages in thread
From: Michael Buesch @ 2007-08-06 19:22 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Andrew Morton, linux-mips, Waldemar Brodkorb, Felix Fietkau,
	Florian Schirmer

On Monday 06 August 2007, Aurelien Jarno wrote:
> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> It originally comes from the OpenWrt patches.
> 
> Cc: Michael Buesch <mb@bu3sch.de>
> Cc: Waldemar Brodkorb <wbx@openwrt.org>
> Cc: Felix Fietkau <nbd@openwrt.org>
> Cc: Florian Schirmer <jolt@tuxbox.org>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

Acked-by: Michael Buesch <mb@bu3sch.de>


> 
> --- a/arch/mips/bcm947xx/irq.c
> +++ b/arch/mips/bcm947xx/irq.c
> @@ -0,0 +1,63 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/module.h>
> +#include <linux/smp.h>
> +#include <linux/types.h>
> +
> +#include <asm/cpu.h>
> +#include <asm/io.h>
> +#include <asm/irq.h>
> +#include <asm/irq_cpu.h>
> +
> +void plat_irq_dispatch(void)
> +{
> +	u32 cause;
> +
> +	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
> +
> +	clear_c0_status(cause);
> +
> +	if (cause & CAUSEF_IP7)
> +		do_IRQ(7);
> +	if (cause & CAUSEF_IP2)
> +		do_IRQ(2);
> +	if (cause & CAUSEF_IP3)
> +		do_IRQ(3);
> +	if (cause & CAUSEF_IP4)
> +		do_IRQ(4);
> +	if (cause & CAUSEF_IP5)
> +		do_IRQ(5);
> +	if (cause & CAUSEF_IP6)
> +		do_IRQ(6);
> +}
> +
> +void __init arch_init_irq(void)
> +{
> +	mips_cpu_irq_init();
> +}
> --- a/arch/mips/bcm947xx/Makefile
> +++ b/arch/mips/bcm947xx/Makefile
> @@ -0,0 +1,6 @@
> +#
> +# Makefile for the BCM947xx specific kernel interface routines
> +# under Linux.
> +#
> +
> +obj-y := irq.o prom.o setup.o time.o
> --- a/arch/mips/bcm947xx/prom.c
> +++ b/arch/mips/bcm947xx/prom.c
> @@ -0,0 +1,58 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/sched.h>
> +#include <linux/bootmem.h>
> +
> +#include <asm/addrspace.h>
> +#include <asm/bootinfo.h>
> +#include <asm/pmon.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "Broadcom BCM947xx";
> +}
> +
> +void __init prom_init(void)
> +{
> +	unsigned long mem;
> +
> +	mips_machgroup = MACH_GROUP_BRCM;
> +	mips_machtype = MACH_BCM947XX;
> +
> +	/* Figure out memory size by finding aliases */
> +	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
> +		if (*(unsigned long *)((unsigned long)(prom_init) + mem) == 
> +		    *(unsigned long *)(prom_init))
> +			break;
> +	}
> +
> +	add_memory_region(0, mem, BOOT_MEM_RAM);
> +}
> +
> +void __init prom_free_prom_memory(void)
> +{
> +}
> --- a/arch/mips/bcm947xx/setup.c
> +++ b/arch/mips/bcm947xx/setup.c
> @@ -0,0 +1,108 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
> + *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
> + *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/types.h>
> +#include <linux/tty.h>
> +#include <linux/serial.h>
> +#include <linux/serial_core.h>
> +#include <linux/serial_reg.h>
> +#include <linux/serial_8250.h>
> +#include <asm/bootinfo.h>
> +#include <asm/time.h>
> +#include <asm/reboot.h>
> +#include <linux/pm.h>
> +#include <linux/ssb/ssb.h>
> +
> +extern void bcm947xx_pci_init(void);
> +extern void bcm947xx_time_init(void);
> +
> +struct ssb_bus ssb;
> +
> +static void bcm947xx_machine_restart(char *command)
> +{
> +	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
> +	local_irq_disable();
> +	/* Set the watchdog timer to reset immediately */
> +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 1);
> +	while (1)
> +		cpu_relax();
> +}
> +
> +static void bcm947xx_machine_halt(void)
> +{
> +	/* Disable interrupts and watchdog and spin forever */
> +	local_irq_disable();
> +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
> +	while (1)
> +		cpu_relax();
> +}
> +
> +static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
> +{
> +	/* TODO: fill ssb_init_invariants using boardtype/boardrev 
> +	 * CFE environment variables.
> +	 */
> +
> +	return 0;
> +}
> +
> +void __init plat_mem_setup(void)
> +{
> +	int i, err;
> +	struct ssb_mipscore *mcore;
> +
> +	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
> +	if (err)
> +		panic("Failed to initialize SSB bus (err %d)\n", err);
> +	mcore = &ssb.mipscore;
> +
> +#ifdef CONFIG_SERIAL_8250
> +	for (i = 0; i < mcore->nr_serial_ports; i++) {
> +		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
> +		struct uart_port s;
> +	
> +		memset(&s, 0, sizeof(s));
> +		s.line = i;
> +		s.membase = port->regs;
> +		s.irq = port->irq + 2;
> +		s.uartclk = port->baud_base;
> +		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
> +		s.iotype = SERIAL_IO_MEM;
> +		s.regshift = port->reg_shift;
> +
> +		early_serial_setup(&s);
> +	}
> +#endif
> +
> +	_machine_restart = bcm947xx_machine_restart;
> +	_machine_halt = bcm947xx_machine_halt;
> +	pm_power_off = bcm947xx_machine_halt;
> +	board_time_init = bcm947xx_time_init;
> +}
> +
> +EXPORT_SYMBOL(ssb);
> --- a/arch/mips/bcm947xx/time.c
> +++ b/arch/mips/bcm947xx/time.c
> @@ -0,0 +1,62 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/sched.h>
> +#include <linux/serial_reg.h>
> +#include <linux/interrupt.h>
> +#include <linux/ssb/ssb.h>
> +#include <asm/addrspace.h>
> +#include <asm/io.h>
> +#include <asm/time.h>
> +
> +extern struct ssb_bus ssb;
> +
> +void __init
> +bcm947xx_time_init(void)
> +{
> +	unsigned long hz;
> +
> +	/*
> +	 * Use deterministic values for initial counter interrupt
> +	 * so that calibrate delay avoids encountering a counter wrap.
> +	 */
> +	write_c0_count(0);
> +	write_c0_compare(0xffff);
> +
> +	hz = ssb_cpu_clock(&ssb.mipscore) / 2;
> +	if (!hz)
> +		hz = 100000000;
> +
> +	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
> +	mips_hpt_frequency = hz;
> +}
> +
> +void __init
> +plat_timer_setup(struct irqaction *irq)
> +{
> +	/* Enable the timer interrupt */
> +	setup_irq(7, irq);
> +}
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-06 19:17       ` [PATCH -mm 2/4] MIPS: BCM947xx support (v2) Aurelien Jarno
  2007-08-06 19:22         ` Michael Buesch
@ 2007-08-06 20:31         ` Florian Schirmer
  2007-08-07  8:05           ` Aurelien Jarno
  2007-08-07  0:40         ` Yoichi Yuasa
  2 siblings, 1 reply; 25+ messages in thread
From: Florian Schirmer @ 2007-08-06 20:31 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Michael Buesch, Andrew Morton, linux-mips, Waldemar Brodkorb,
	Felix Fietkau

Hi,

Aurelien Jarno wrote:
> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> It originally comes from the OpenWrt patches.
>
> Cc: Michael Buesch <mb@bu3sch.de>
> Cc: Waldemar Brodkorb <wbx@openwrt.org>
> Cc: Felix Fietkau <nbd@openwrt.org>
> Cc: Florian Schirmer <jolt@tuxbox.org>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>   

I'm not sure whether it's a good idea to export a symbol named "ssb". 
Maybe bcm47xx_ssb would be a better name? I've no idea what the general 
rule on exporting symbols is though. Otherwise:

Acked-by: Florian Schirmer <jolt@tuxbox.org>

Best,
  Florian


> --- a/arch/mips/bcm947xx/irq.c
> +++ b/arch/mips/bcm947xx/irq.c
> @@ -0,0 +1,63 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/module.h>
> +#include <linux/smp.h>
> +#include <linux/types.h>
> +
> +#include <asm/cpu.h>
> +#include <asm/io.h>
> +#include <asm/irq.h>
> +#include <asm/irq_cpu.h>
> +
> +void plat_irq_dispatch(void)
> +{
> +	u32 cause;
> +
> +	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
> +
> +	clear_c0_status(cause);
> +
> +	if (cause & CAUSEF_IP7)
> +		do_IRQ(7);
> +	if (cause & CAUSEF_IP2)
> +		do_IRQ(2);
> +	if (cause & CAUSEF_IP3)
> +		do_IRQ(3);
> +	if (cause & CAUSEF_IP4)
> +		do_IRQ(4);
> +	if (cause & CAUSEF_IP5)
> +		do_IRQ(5);
> +	if (cause & CAUSEF_IP6)
> +		do_IRQ(6);
> +}
> +
> +void __init arch_init_irq(void)
> +{
> +	mips_cpu_irq_init();
> +}
> --- a/arch/mips/bcm947xx/Makefile
> +++ b/arch/mips/bcm947xx/Makefile
> @@ -0,0 +1,6 @@
> +#
> +# Makefile for the BCM947xx specific kernel interface routines
> +# under Linux.
> +#
> +
> +obj-y := irq.o prom.o setup.o time.o
> --- a/arch/mips/bcm947xx/prom.c
> +++ b/arch/mips/bcm947xx/prom.c
> @@ -0,0 +1,58 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/sched.h>
> +#include <linux/bootmem.h>
> +
> +#include <asm/addrspace.h>
> +#include <asm/bootinfo.h>
> +#include <asm/pmon.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "Broadcom BCM947xx";
> +}
> +
> +void __init prom_init(void)
> +{
> +	unsigned long mem;
> +
> +	mips_machgroup = MACH_GROUP_BRCM;
> +	mips_machtype = MACH_BCM947XX;
> +
> +	/* Figure out memory size by finding aliases */
> +	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
> +		if (*(unsigned long *)((unsigned long)(prom_init) + mem) == 
> +		    *(unsigned long *)(prom_init))
> +			break;
> +	}
> +
> +	add_memory_region(0, mem, BOOT_MEM_RAM);
> +}
> +
> +void __init prom_free_prom_memory(void)
> +{
> +}
> --- a/arch/mips/bcm947xx/setup.c
> +++ b/arch/mips/bcm947xx/setup.c
> @@ -0,0 +1,108 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
> + *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
> + *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/types.h>
> +#include <linux/tty.h>
> +#include <linux/serial.h>
> +#include <linux/serial_core.h>
> +#include <linux/serial_reg.h>
> +#include <linux/serial_8250.h>
> +#include <asm/bootinfo.h>
> +#include <asm/time.h>
> +#include <asm/reboot.h>
> +#include <linux/pm.h>
> +#include <linux/ssb/ssb.h>
> +
> +extern void bcm947xx_pci_init(void);
> +extern void bcm947xx_time_init(void);
> +
> +struct ssb_bus ssb;
> +
> +static void bcm947xx_machine_restart(char *command)
> +{
> +	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
> +	local_irq_disable();
> +	/* Set the watchdog timer to reset immediately */
> +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 1);
> +	while (1)
> +		cpu_relax();
> +}
> +
> +static void bcm947xx_machine_halt(void)
> +{
> +	/* Disable interrupts and watchdog and spin forever */
> +	local_irq_disable();
> +	ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
> +	while (1)
> +		cpu_relax();
> +}
> +
> +static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
> +{
> +	/* TODO: fill ssb_init_invariants using boardtype/boardrev 
> +	 * CFE environment variables.
> +	 */
> +
> +	return 0;
> +}
> +
> +void __init plat_mem_setup(void)
> +{
> +	int i, err;
> +	struct ssb_mipscore *mcore;
> +
> +	err = ssb_bus_ssbbus_register(&ssb, SSB_ENUM_BASE, bcm947xx_get_invariants);
> +	if (err)
> +		panic("Failed to initialize SSB bus (err %d)\n", err);
> +	mcore = &ssb.mipscore;
> +
> +#ifdef CONFIG_SERIAL_8250
> +	for (i = 0; i < mcore->nr_serial_ports; i++) {
> +		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
> +		struct uart_port s;
> +	
> +		memset(&s, 0, sizeof(s));
> +		s.line = i;
> +		s.membase = port->regs;
> +		s.irq = port->irq + 2;
> +		s.uartclk = port->baud_base;
> +		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
> +		s.iotype = SERIAL_IO_MEM;
> +		s.regshift = port->reg_shift;
> +
> +		early_serial_setup(&s);
> +	}
> +#endif
> +
> +	_machine_restart = bcm947xx_machine_restart;
> +	_machine_halt = bcm947xx_machine_halt;
> +	pm_power_off = bcm947xx_machine_halt;
> +	board_time_init = bcm947xx_time_init;
> +}
> +
> +EXPORT_SYMBOL(ssb);
> --- a/arch/mips/bcm947xx/time.c
> +++ b/arch/mips/bcm947xx/time.c
> @@ -0,0 +1,62 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/sched.h>
> +#include <linux/serial_reg.h>
> +#include <linux/interrupt.h>
> +#include <linux/ssb/ssb.h>
> +#include <asm/addrspace.h>
> +#include <asm/io.h>
> +#include <asm/time.h>
> +
> +extern struct ssb_bus ssb;
> +
> +void __init
> +bcm947xx_time_init(void)
> +{
> +	unsigned long hz;
> +
> +	/*
> +	 * Use deterministic values for initial counter interrupt
> +	 * so that calibrate delay avoids encountering a counter wrap.
> +	 */
> +	write_c0_count(0);
> +	write_c0_compare(0xffff);
> +
> +	hz = ssb_cpu_clock(&ssb.mipscore) / 2;
> +	if (!hz)
> +		hz = 100000000;
> +
> +	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
> +	mips_hpt_frequency = hz;
> +}
> +
> +void __init
> +plat_timer_setup(struct irqaction *irq)
> +{
> +	/* Enable the timer interrupt */
> +	setup_irq(7, irq);
> +}
>
>   

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-06 19:17       ` [PATCH -mm 2/4] MIPS: BCM947xx support (v2) Aurelien Jarno
  2007-08-06 19:22         ` Michael Buesch
  2007-08-06 20:31         ` Florian Schirmer
@ 2007-08-07  0:40         ` Yoichi Yuasa
  2007-08-07  8:01           ` Aurelien Jarno
                             ` (3 more replies)
  2 siblings, 4 replies; 25+ messages in thread
From: Yoichi Yuasa @ 2007-08-07  0:40 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: yoichi_yuasa, mb, akpm, linux-mips, wbx, nbd, jolt

On Mon, 6 Aug 2007 21:17:12 +0200
Aurelien Jarno <aurelien@aurel32.net> wrote:

> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> It originally comes from the OpenWrt patches.
<snip>
> --- a/arch/mips/bcm947xx/prom.c
> +++ b/arch/mips/bcm947xx/prom.c
> @@ -0,0 +1,58 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/sched.h>
> +#include <linux/bootmem.h>
> +
> +#include <asm/addrspace.h>
> +#include <asm/bootinfo.h>
> +#include <asm/pmon.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "Broadcom BCM947xx";
> +}
> +
> +void __init prom_init(void)
> +{
> +	unsigned long mem;
> +
> +	mips_machgroup = MACH_GROUP_BRCM;
> +	mips_machtype = MACH_BCM947XX;

If you don't have a plan using mips_machgroup/mips_machtype,
it is not a must. 

Yoichi

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-07  0:40         ` Yoichi Yuasa
@ 2007-08-07  8:01           ` Aurelien Jarno
  2007-08-07  8:02           ` Aurelien Jarno
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-07  8:01 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: mb, akpm, linux-mips, wbx, nbd, jolt

Yoichi Yuasa a écrit :
> On Mon, 6 Aug 2007 21:17:12 +0200
> Aurelien Jarno <aurelien@aurel32.net> wrote:
> 
>> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
>> It originally comes from the OpenWrt patches.
> <snip>
>> --- a/arch/mips/bcm947xx/prom.c
>> +++ b/arch/mips/bcm947xx/prom.c
>> @@ -0,0 +1,58 @@
>> +/*
>> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
>> + *
>> + *  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.
>> + *
>> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
>> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
>> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
>> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
>> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
>> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
>> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
>> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
>> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
>> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> + *
>> + *  You should have received a copy of the  GNU General Public License along
>> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
>> + *  675 Mass Ave, Cambridge, MA 02139, USA.
>> + */
>> +
>> +#include <linux/init.h>
>> +#include <linux/mm.h>
>> +#include <linux/sched.h>
>> +#include <linux/bootmem.h>
>> +
>> +#include <asm/addrspace.h>
>> +#include <asm/bootinfo.h>
>> +#include <asm/pmon.h>
>> +
>> +const char *get_system_type(void)
>> +{
>> +	return "Broadcom BCM947xx";
>> +}
>> +
>> +void __init prom_init(void)
>> +{
>> +	unsigned long mem;
>> +
>> +	mips_machgroup = MACH_GROUP_BRCM;
>> +	mips_machtype = MACH_BCM947XX;
> 
> If you don't have a plan using mips_machgroup/mips_machtype,
> it is not a must. 

It is not used in other parts of the code, so we can remove that part. I
will update my patch.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-07  0:40         ` Yoichi Yuasa
  2007-08-07  8:01           ` Aurelien Jarno
@ 2007-08-07  8:02           ` Aurelien Jarno
  2007-08-07  8:04           ` Aurelien Jarno
  2007-08-07 12:16           ` [PATCH -mm 2/4] MIPS: BCM947xx support (v3) Aurelien Jarno
  3 siblings, 0 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-07  8:02 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: mb, akpm, linux-mips, wbx, nbd, jolt

Yoichi Yuasa a écrit :
> On Mon, 6 Aug 2007 21:17:12 +0200
> Aurelien Jarno <aurelien@aurel32.net> wrote:
> 
>> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
>> It originally comes from the OpenWrt patches.
> <snip>
>> --- a/arch/mips/bcm947xx/prom.c
>> +++ b/arch/mips/bcm947xx/prom.c
>> @@ -0,0 +1,58 @@
>> +/*
>> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
>> + *
>> + *  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.
>> + *
>> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
>> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
>> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
>> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
>> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
>> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
>> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
>> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
>> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
>> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> + *
>> + *  You should have received a copy of the  GNU General Public License along
>> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
>> + *  675 Mass Ave, Cambridge, MA 02139, USA.
>> + */
>> +
>> +#include <linux/init.h>
>> +#include <linux/mm.h>
>> +#include <linux/sched.h>
>> +#include <linux/bootmem.h>
>> +
>> +#include <asm/addrspace.h>
>> +#include <asm/bootinfo.h>
>> +#include <asm/pmon.h>
>> +
>> +const char *get_system_type(void)
>> +{
>> +	return "Broadcom BCM947xx";
>> +}
>> +
>> +void __init prom_init(void)
>> +{
>> +	unsigned long mem;
>> +
>> +	mips_machgroup = MACH_GROUP_BRCM;
>> +	mips_machtype = MACH_BCM947XX;
> 
> If you don't have a plan using mips_machgroup/mips_machtype,
> it is not a must. 

It is not used in other parts of the code, so we can remove that part. I
will update my patch.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-07  0:40         ` Yoichi Yuasa
  2007-08-07  8:01           ` Aurelien Jarno
  2007-08-07  8:02           ` Aurelien Jarno
@ 2007-08-07  8:04           ` Aurelien Jarno
  2007-08-07 12:16           ` [PATCH -mm 2/4] MIPS: BCM947xx support (v3) Aurelien Jarno
  3 siblings, 0 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-07  8:04 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: mb, akpm, linux-mips, wbx, nbd, jolt

Yoichi Yuasa a écrit :
> On Mon, 6 Aug 2007 21:17:12 +0200
> Aurelien Jarno <aurelien@aurel32.net> wrote:
> 
>> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
>> It originally comes from the OpenWrt patches.
> <snip>
>> --- a/arch/mips/bcm947xx/prom.c
>> +++ b/arch/mips/bcm947xx/prom.c
>> @@ -0,0 +1,58 @@
>> +/*
>> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
>> + *
>> + *  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.
>> + *
>> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
>> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
>> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
>> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
>> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
>> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
>> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
>> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
>> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
>> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> + *
>> + *  You should have received a copy of the  GNU General Public License along
>> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
>> + *  675 Mass Ave, Cambridge, MA 02139, USA.
>> + */
>> +
>> +#include <linux/init.h>
>> +#include <linux/mm.h>
>> +#include <linux/sched.h>
>> +#include <linux/bootmem.h>
>> +
>> +#include <asm/addrspace.h>
>> +#include <asm/bootinfo.h>
>> +#include <asm/pmon.h>
>> +
>> +const char *get_system_type(void)
>> +{
>> +	return "Broadcom BCM947xx";
>> +}
>> +
>> +void __init prom_init(void)
>> +{
>> +	unsigned long mem;
>> +
>> +	mips_machgroup = MACH_GROUP_BRCM;
>> +	mips_machtype = MACH_BCM947XX;
> 
> If you don't have a plan using mips_machgroup/mips_machtype,
> it is not a must. 

It is not used in other parts of the code, so we can remove that part. I
will update my patch.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v2)
  2007-08-06 20:31         ` Florian Schirmer
@ 2007-08-07  8:05           ` Aurelien Jarno
  0 siblings, 0 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-07  8:05 UTC (permalink / raw)
  To: Florian Schirmer
  Cc: Michael Buesch, Andrew Morton, linux-mips, Waldemar Brodkorb,
	Felix Fietkau

Florian Schirmer a écrit :
> Hi,
> 
> Aurelien Jarno wrote:
>> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
>> It originally comes from the OpenWrt patches.
>>
>> Cc: Michael Buesch <mb@bu3sch.de>
>> Cc: Waldemar Brodkorb <wbx@openwrt.org>
>> Cc: Felix Fietkau <nbd@openwrt.org>
>> Cc: Florian Schirmer <jolt@tuxbox.org>
>> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>>   
> 
> I'm not sure whether it's a good idea to export a symbol named "ssb". 
> Maybe bcm47xx_ssb would be a better name? I've no idea what the general 
> rule on exporting symbols is though. Otherwise:

I don't not either, but looking in other parts of the kernel it seems it
is done the other way, ie ssb_bcm947xx would be the correct name.

I will send an updated patch.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH -mm 2/4] MIPS: BCM947xx support (v3)
  2007-08-07  0:40         ` Yoichi Yuasa
                             ` (2 preceding siblings ...)
  2007-08-07  8:04           ` Aurelien Jarno
@ 2007-08-07 12:16           ` Aurelien Jarno
  2007-08-08  1:33             ` Andrew Morton
  3 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-07 12:16 UTC (permalink / raw)
  To: Yoichi Yuasa; +Cc: mb, akpm, linux-mips, nbd, jolt

The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
It originally comes from the OpenWrt patches.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/bcm947xx/irq.c
+++ b/arch/mips/bcm947xx/irq.c
@@ -0,0 +1,63 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/smp.h>
+#include <linux/types.h>
+
+#include <asm/cpu.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/irq_cpu.h>
+
+void plat_irq_dispatch(void)
+{
+	u32 cause;
+
+	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
+
+	clear_c0_status(cause);
+
+	if (cause & CAUSEF_IP7)
+		do_IRQ(7);
+	if (cause & CAUSEF_IP2)
+		do_IRQ(2);
+	if (cause & CAUSEF_IP3)
+		do_IRQ(3);
+	if (cause & CAUSEF_IP4)
+		do_IRQ(4);
+	if (cause & CAUSEF_IP5)
+		do_IRQ(5);
+	if (cause & CAUSEF_IP6)
+		do_IRQ(6);
+}
+
+void __init arch_init_irq(void)
+{
+	mips_cpu_irq_init();
+}
--- a/arch/mips/bcm947xx/Makefile
+++ b/arch/mips/bcm947xx/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the BCM947xx specific kernel interface routines
+# under Linux.
+#
+
+obj-y := irq.o prom.o setup.o time.o
--- a/arch/mips/bcm947xx/prom.c
+++ b/arch/mips/bcm947xx/prom.c
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/bootmem.h>
+
+#include <asm/addrspace.h>
+#include <asm/bootinfo.h>
+#include <asm/pmon.h>
+
+const char *get_system_type(void)
+{
+	return "Broadcom BCM947xx";
+}
+
+void __init prom_init(void)
+{
+	unsigned long mem;
+
+	/* Figure out memory size by finding aliases */
+	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
+		if (*(unsigned long *)((unsigned long)(prom_init) + mem) == 
+		    *(unsigned long *)(prom_init))
+			break;
+	}
+
+	add_memory_region(0, mem, BOOT_MEM_RAM);
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
--- a/arch/mips/bcm947xx/setup.c
+++ b/arch/mips/bcm947xx/setup.c
@@ -0,0 +1,108 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
+ *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/serial_reg.h>
+#include <linux/serial_8250.h>
+#include <asm/bootinfo.h>
+#include <asm/time.h>
+#include <asm/reboot.h>
+#include <linux/pm.h>
+#include <linux/ssb/ssb.h>
+
+extern void bcm947xx_pci_init(void);
+extern void bcm947xx_time_init(void);
+
+struct ssb_bus ssb_bcm947xx;
+
+static void bcm947xx_machine_restart(char *command)
+{
+	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
+	local_irq_disable();
+	/* Set the watchdog timer to reset immediately */
+	ssb_chipco_watchdog_timer_set(&ssb_bcm947xx.chipco, 1);
+	while (1)
+		cpu_relax();
+}
+
+static void bcm947xx_machine_halt(void)
+{
+	/* Disable interrupts and watchdog and spin forever */
+	local_irq_disable();
+	ssb_chipco_watchdog_timer_set(&ssb_bcm947xx.chipco, 0);
+	while (1)
+		cpu_relax();
+}
+
+static int bcm947xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
+{
+	/* TODO: fill ssb_init_invariants using boardtype/boardrev 
+	 * CFE environment variables.
+	 */
+
+	return 0;
+}
+
+void __init plat_mem_setup(void)
+{
+	int i, err;
+	struct ssb_mipscore *mcore;
+
+	err = ssb_bus_ssbbus_register(&ssb_bcm947xx, SSB_ENUM_BASE, bcm947xx_get_invariants);
+	if (err)
+		panic("Failed to initialize SSB bus (err %d)\n", err);
+	mcore = &ssb_bcm947xx.mipscore;
+
+#ifdef CONFIG_SERIAL_8250
+	for (i = 0; i < mcore->nr_serial_ports; i++) {
+		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
+		struct uart_port s;
+	
+		memset(&s, 0, sizeof(s));
+		s.line = i;
+		s.membase = port->regs;
+		s.irq = port->irq + 2;
+		s.uartclk = port->baud_base;
+		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
+		s.iotype = SERIAL_IO_MEM;
+		s.regshift = port->reg_shift;
+
+		early_serial_setup(&s);
+	}
+#endif
+
+	_machine_restart = bcm947xx_machine_restart;
+	_machine_halt = bcm947xx_machine_halt;
+	pm_power_off = bcm947xx_machine_halt;
+	board_time_init = bcm947xx_time_init;
+}
+
+EXPORT_SYMBOL(ssb_bcm947xx);
--- a/arch/mips/bcm947xx/time.c
+++ b/arch/mips/bcm947xx/time.c
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/serial_reg.h>
+#include <linux/interrupt.h>
+#include <linux/ssb/ssb.h>
+#include <asm/addrspace.h>
+#include <asm/io.h>
+#include <asm/time.h>
+
+extern struct ssb_bus ssb_bcm947xx;
+
+void __init
+bcm947xx_time_init(void)
+{
+	unsigned long hz;
+
+	/*
+	 * Use deterministic values for initial counter interrupt
+	 * so that calibrate delay avoids encountering a counter wrap.
+	 */
+	write_c0_count(0);
+	write_c0_compare(0xffff);
+
+	hz = ssb_cpu_clock(&ssb_bcm947xx.mipscore) / 2;
+	if (!hz)
+		hz = 100000000;
+
+	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
+	mips_hpt_frequency = hz;
+}
+
+void __init
+plat_timer_setup(struct irqaction *irq)
+{
+	/* Enable the timer interrupt */
+	setup_irq(7, irq);
+}

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH -mm 2/4] MIPS: BCM947xx support (v3)
  2007-08-07 12:16           ` [PATCH -mm 2/4] MIPS: BCM947xx support (v3) Aurelien Jarno
@ 2007-08-08  1:33             ` Andrew Morton
  2007-08-09  0:41               ` [PATCH 0/4][RFC] MIPS BCM947xx CPUs support Aurelien Jarno
  0 siblings, 1 reply; 25+ messages in thread
From: Andrew Morton @ 2007-08-08  1:33 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: Yoichi Yuasa, mb, linux-mips, nbd, jolt

On Tue, 7 Aug 2007 14:16:38 +0200
Aurelien Jarno <aurelien@aurel32.net> wrote:

> The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
> It originally comes from the OpenWrt patches.
> 
> Cc: Michael Buesch <mb@bu3sch.de>
> Cc: Felix Fietkau <nbd@openwrt.org>
> Cc: Florian Schirmer <jolt@tuxbox.org>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> --- a/arch/mips/bcm947xx/irq.c
> +++ b/arch/mips/bcm947xx/irq.c

It's a MIPS patch.  I can merge it, I guess, if Ralf is OK with that.

> ...
>
> +void __init plat_mem_setup(void)
> +{
> +	int i, err;
> +	struct ssb_mipscore *mcore;
> +
> +	err = ssb_bus_ssbbus_register(&ssb_bcm947xx, SSB_ENUM_BASE, bcm947xx_get_invariants);
> +	if (err)
> +		panic("Failed to initialize SSB bus (err %d)\n", err);
> +	mcore = &ssb_bcm947xx.mipscore;
> +
> +#ifdef CONFIG_SERIAL_8250
> +	for (i = 0; i < mcore->nr_serial_ports; i++) {
> +		struct ssb_serial_port *port = &(mcore->serial_ports[i]);
> +		struct uart_port s;
> +	
> +		memset(&s, 0, sizeof(s));
> +		s.line = i;
> +		s.membase = port->regs;
> +		s.irq = port->irq + 2;
> +		s.uartclk = port->baud_base;
> +		s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
> +		s.iotype = SERIAL_IO_MEM;
> +		s.regshift = port->reg_shift;
> +
> +		early_serial_setup(&s);
> +	}
> +#endif
> +
> +	_machine_restart = bcm947xx_machine_restart;
> +	_machine_halt = bcm947xx_machine_halt;
> +	pm_power_off = bcm947xx_machine_halt;
> +	board_time_init = bcm947xx_time_init;
> +}

Won't this break if CONFIG_SERIAL_8250=m?

> +EXPORT_SYMBOL(ssb_bcm947xx);
> --- a/arch/mips/bcm947xx/time.c
> +++ b/arch/mips/bcm947xx/time.c
> @@ -0,0 +1,62 @@
> +/*
> + *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
> + *
> + *  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.
> + *
> + *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
> + *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
> + *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
> + *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
> + *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
> + *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
> + *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + *  You should have received a copy of the  GNU General Public License along
> + *  with this program; if not, write  to the Free Software Foundation, Inc.,
> + *  675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/sched.h>
> +#include <linux/serial_reg.h>
> +#include <linux/interrupt.h>
> +#include <linux/ssb/ssb.h>
> +#include <asm/addrspace.h>
> +#include <asm/io.h>
> +#include <asm/time.h>
> +
> +extern struct ssb_bus ssb_bcm947xx;

No.  Please, never ever put extern declarations in C files.  Find a
suitable header file for it.

We have scripts/checkpatch.pl which will tell you this (and a lot of other
stuff too).  Please incorporate checkpatch into your workflow.

> +void __init
> +bcm947xx_time_init(void)
> +{
> +	unsigned long hz;
> +
> +	/*
> +	 * Use deterministic values for initial counter interrupt
> +	 * so that calibrate delay avoids encountering a counter wrap.
> +	 */
> +	write_c0_count(0);
> +	write_c0_compare(0xffff);
> +
> +	hz = ssb_cpu_clock(&ssb_bcm947xx.mipscore) / 2;
> +	if (!hz)
> +		hz = 100000000;
> +
> +	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
> +	mips_hpt_frequency = hz;
> +}
> +
> +void __init
> +plat_timer_setup(struct irqaction *irq)
> +{
> +	/* Enable the timer interrupt */
> +	setup_irq(7, irq);
> +}

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 0/4][RFC] MIPS BCM947xx CPUs support
  2007-08-08  1:33             ` Andrew Morton
@ 2007-08-09  0:41               ` Aurelien Jarno
  2007-08-09  0:43                 ` [PATCH 1/4][RFC] MIPS: Detect BCM947xx CPUs Aurelien Jarno
                                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09  0:41 UTC (permalink / raw)
  To: linux-mips; +Cc: Andrew Morton, mb, nbd, jolt

Hi,

Thanks a lot for all your comments. You will find in the next mails a
new version of the BCM947xx patches which include fixes for your
comments. The big changes concerns the serial driver which now uses a
platform driver for the configuration. This fixes the case where
CONFIG_SERIAL_8250=m.

Given the current mess wrt SSB patches, I don't ask them to be merged
now, but if would be nice if you can review them. Thanks.

Regards,
Aurelien


The following series of patches add basic support for the BCM947xx 
CPUs. CFE support still needs work and thus is not included in those 
patches, so the command line has to be included in the kernel. 
Everything else is fully functional and the resulting kernel works
fine on a Netgear WGT634U.

Patch #1: MIPS: Detect BCM947xx CPUs
Patch #2: MIPS: BCM947xx support
Patch #3: MIPS: Add BCM947XX to Kconfig
Patch #4: MIPS: Add BCM947xx to Makefile

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 1/4][RFC] MIPS: Detect BCM947xx CPUs
  2007-08-09  0:41               ` [PATCH 0/4][RFC] MIPS BCM947xx CPUs support Aurelien Jarno
@ 2007-08-09  0:43                 ` Aurelien Jarno
  2007-08-09  0:44                 ` [PATCH 2/4][RFC] MIPS: BCM947xx support Aurelien Jarno
                                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09  0:43 UTC (permalink / raw)
  To: linux-mips; +Cc: Andrew Morton, mb, nbd, jolt

The patch below against 2.6.23-rc1-mm2 adds a few constants for BCM947xx
CPUs and detect them in cpu-probe.c and tlbex.c. Note that the BCM4710 
does not support the wait instruction, this is not a mistake in the 
code.

This part is not dependent of other patches (though useless without 
them), and could already be merged in the current linux-mips git tree.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -159,6 +159,7 @@
 	case CPU_5KC:
 	case CPU_25KF:
 	case CPU_PR4450:
+	case CPU_BCM3302:
 		cpu_wait = r4k_wait;
 		break;
 
@@ -786,6 +787,22 @@
 }
 
 
+static inline void cpu_probe_broadcom(struct cpuinfo_mips *c)
+{
+	decode_configs(c);
+	switch (c->processor_id & 0xff00) {
+	case PRID_IMP_BCM3302:
+		c->cputype = CPU_BCM3302;
+		break;
+	case PRID_IMP_BCM4710:
+		c->cputype = CPU_BCM4710;
+		break;
+	default:
+		c->cputype = CPU_UNKNOWN;
+		break;
+	}
+}
+
 __init void cpu_probe(void)
 {
 	struct cpuinfo_mips *c = &current_cpu_data;
@@ -808,6 +825,9 @@
 	case PRID_COMP_SIBYTE:
 		cpu_probe_sibyte(c);
 		break;
+	case PRID_COMP_BROADCOM:
+		cpu_probe_broadcom(c);
+		break;
 	case PRID_COMP_SANDCRAFT:
 		cpu_probe_sandcraft(c);
 		break;
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -82,6 +82,8 @@
 	[CPU_VR4181]	= "NEC VR4181",
 	[CPU_VR4181A]	= "NEC VR4181A",
 	[CPU_SR71000]	= "Sandcraft SR71000",
+	[CPU_BCM3302]	= "Broadcom BCM3302",
+	[CPU_BCM4710]	= "Broadcom BCM4710",
 	[CPU_PR4450]	= "Philips PR4450",
 	[CPU_LOONGSON2]	= "ICT Loongson-2",
 };
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -893,6 +893,8 @@
 	case CPU_4KSC:
 	case CPU_20KC:
 	case CPU_25KF:
+	case CPU_BCM3302:
+	case CPU_BCM4710:
 	case CPU_LOONGSON2:
 		tlbw(p);
 		break;
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -221,6 +221,12 @@
 #define MACH_GROUP_WINDRIVER   28	/* Windriver boards */
 #define MACH_WRPPMC             1
 
+/*
+ * Valid machtype for group Broadcom
+ */
+#define MACH_GROUP_BRCM		23	/* Broadcom			*/
+#define  MACH_BCM947XX		1	/* Broadcom BCM947xx		*/
+
 #define CL_SIZE			COMMAND_LINE_SIZE
 
 const char *get_system_type(void);
--- a/include/asm-mips/cpu.h
+++ b/include/asm-mips/cpu.h
@@ -106,6 +106,13 @@
 #define PRID_IMP_SR71000        0x0400
 
 /*
+ * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
+ */
+
+#define PRID_IMP_BCM4710	0x4000
+#define PRID_IMP_BCM3302	0x9000
+
+/*
  * Definitions for 7:0 on legacy processors
  */
 
@@ -217,8 +224,9 @@
 #define CPU_R14000		64
 #define CPU_LOONGSON1           65
 #define CPU_LOONGSON2           66
-
-#define CPU_LAST		66
+#define CPU_BCM3302		67
+#define CPU_BCM4710		68
+#define CPU_LAST		68
 
 /*
  * ISA Level encodings

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 2/4][RFC] MIPS: BCM947xx support
  2007-08-09  0:41               ` [PATCH 0/4][RFC] MIPS BCM947xx CPUs support Aurelien Jarno
  2007-08-09  0:43                 ` [PATCH 1/4][RFC] MIPS: Detect BCM947xx CPUs Aurelien Jarno
@ 2007-08-09  0:44                 ` Aurelien Jarno
  2007-08-09 10:00                   ` Michael Buesch
  2007-08-09  0:45                 ` [PATCH 3/4] RFC: Add BCM947XX to Kconfig Aurelien Jarno
  2007-08-09  0:45                 ` [PATCH 4/4][RFC] MIPS: Add BCM947xx to Makefile Aurelien Jarno
  3 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09  0:44 UTC (permalink / raw)
  To: linux-mips; +Cc: Andrew Morton, mb, nbd, jolt

The patch below against 2.6.23-rc1-mm2 adds support for BCM947xx CPUs.
It originally comes from the OpenWrt patches.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/bcm947xx/irq.c
+++ b/arch/mips/bcm947xx/irq.c
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <asm/irq_cpu.h>
+
+void plat_irq_dispatch(void)
+{
+	u32 cause;
+
+	cause = read_c0_cause() & read_c0_status() & CAUSEF_IP;
+
+	clear_c0_status(cause);
+
+	if (cause & CAUSEF_IP7)
+		do_IRQ(7);
+	if (cause & CAUSEF_IP2)
+		do_IRQ(2);
+	if (cause & CAUSEF_IP3)
+		do_IRQ(3);
+	if (cause & CAUSEF_IP4)
+		do_IRQ(4);
+	if (cause & CAUSEF_IP5)
+		do_IRQ(5);
+	if (cause & CAUSEF_IP6)
+		do_IRQ(6);
+}
+
+void __init arch_init_irq(void)
+{
+	mips_cpu_irq_init();
+}
--- a/arch/mips/bcm947xx/Makefile
+++ b/arch/mips/bcm947xx/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the BCM947xx specific kernel interface routines
+# under Linux.
+#
+
+obj-y := irq.o prom.o serial.o setup.o time.o
--- a/arch/mips/bcm947xx/prom.c
+++ b/arch/mips/bcm947xx/prom.c
@@ -0,0 +1,49 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <asm/bootinfo.h>
+
+const char *get_system_type(void)
+{
+	return "Broadcom BCM947xx";
+}
+
+void __init prom_init(void)
+{
+	unsigned long mem;
+
+	/* Figure out memory size by finding aliases */
+	for (mem = (1 << 20); mem < (128 << 20); mem += (1 << 20)) {
+		if (*(unsigned long *)((unsigned long)(prom_init) + mem) ==
+		    *(unsigned long *)(prom_init))
+			break;
+	}
+
+	add_memory_region(0, mem, BOOT_MEM_RAM);
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
--- a/arch/mips/bcm947xx/serial.c	
+++ b/arch/mips/bcm947xx/serial.c	
@@ -0,0 +1,52 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/serial.h>
+#include <linux/serial_8250.h>
+#include <linux/ssb/ssb.h>
+#include <bcm947xx.h>
+
+static struct plat_serial8250_port uart8250_data[5];
+
+static struct platform_device uart8250_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_PLATFORM,
+	.dev			= {
+		.platform_data	= uart8250_data,
+	},
+};
+
+static int __init uart8250_init(void)
+{
+	int i;
+	struct ssb_mipscore *mcore = &(ssb_bcm947xx.mipscore);
+
+	memset(&uart8250_data, 0,  sizeof(uart8250_data));
+
+	for (i = 0; i < mcore->nr_serial_ports; i++) {
+		struct plat_serial8250_port *p = &(uart8250_data[i]);
+		struct ssb_serial_port *ssb_port = &(mcore->serial_ports[i]);
+
+		p->mapbase = (unsigned int) ssb_port->regs;
+		p->membase = (void *) ssb_port->regs;
+		p->irq = ssb_port->irq + 2;
+		p->uartclk = ssb_port->baud_base;
+		p->regshift = ssb_port->reg_shift;
+		p->iotype = UPIO_MEM;
+		p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
+	}
+	return platform_device_register(&uart8250_device);
+}
+
+module_init(uart8250_init);
+
+MODULE_AUTHOR("Aurelien Jarno <aurelien@aurel32.net>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("8250 UART probe driver for the BCM947xx platforms");
--- a/arch/mips/bcm947xx/setup.c
+++ b/arch/mips/bcm947xx/setup.c
@@ -0,0 +1,79 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
+ *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/types.h>
+#include <linux/ssb/ssb.h>
+#include <asm/reboot.h>
+#include <asm/time.h>
+#include <bcm947xx.h>
+
+struct ssb_bus ssb_bcm947xx;
+EXPORT_SYMBOL(ssb_bcm947xx);
+
+static void bcm947xx_machine_restart(char *command)
+{
+	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
+	local_irq_disable();
+	/* Set the watchdog timer to reset immediately */
+	ssb_chipco_watchdog_timer_set(&ssb_bcm947xx.chipco, 1);
+	while (1)
+		cpu_relax();
+}
+
+static void bcm947xx_machine_halt(void)
+{
+	/* Disable interrupts and watchdog and spin forever */
+	local_irq_disable();
+	ssb_chipco_watchdog_timer_set(&ssb_bcm947xx.chipco, 0);
+	while (1)
+		cpu_relax();
+}
+
+static int bcm947xx_get_invariants(struct ssb_bus *bus,
+				   struct ssb_init_invariants *iv)
+{
+	/* TODO: fill ssb_init_invariants using boardtype/boardrev
+	 * CFE environment variables.
+	 */
+	return 0;
+}
+
+void __init plat_mem_setup(void)
+{
+	int err;
+
+	err = ssb_bus_ssbbus_register(&ssb_bcm947xx, SSB_ENUM_BASE,
+				      bcm947xx_get_invariants);
+	if (err)
+		panic("Failed to initialize SSB bus (err %d)\n", err);
+
+	_machine_restart = bcm947xx_machine_restart;
+	_machine_halt = bcm947xx_machine_halt;
+	pm_power_off = bcm947xx_machine_halt;
+	board_time_init = bcm947xx_time_init;
+}
+
--- a/arch/mips/bcm947xx/time.c
+++ b/arch/mips/bcm947xx/time.c
@@ -0,0 +1,56 @@
+/*
+ *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
+ *
+ *  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.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include <linux/init.h>
+#include <linux/ssb/ssb.h>
+#include <asm/time.h>
+#include <bcm947xx.h>
+
+void __init
+bcm947xx_time_init(void)
+{
+	unsigned long hz;
+
+	/*
+	 * Use deterministic values for initial counter interrupt
+	 * so that calibrate delay avoids encountering a counter wrap.
+	 */
+	write_c0_count(0);
+	write_c0_compare(0xffff);
+
+	hz = ssb_cpu_clock(&ssb_bcm947xx.mipscore) / 2;
+	if (!hz)
+		hz = 100000000;
+
+	/* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
+	mips_hpt_frequency = hz;
+}
+
+void __init
+plat_timer_setup(struct irqaction *irq)
+{
+	/* Enable the timer interrupt */
+	setup_irq(7, irq);
+}
--- a/include/asm-mips/mach-bcm947xx/bcm947xx.h
+++ b/include/asm-mips/mach-bcm947xx/bcm947xx.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#ifndef __ASM_BCM947XX_H
+#define __ASM_BCM947XX_H
+
+/* SSB bus */
+extern struct ssb_bus ssb_bcm947xx;
+
+extern void bcm947xx_time_init(void);
+
+#endif /* __ASM_BCM947XX_H */

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 3/4] RFC: Add BCM947XX to Kconfig
  2007-08-09  0:41               ` [PATCH 0/4][RFC] MIPS BCM947xx CPUs support Aurelien Jarno
  2007-08-09  0:43                 ` [PATCH 1/4][RFC] MIPS: Detect BCM947xx CPUs Aurelien Jarno
  2007-08-09  0:44                 ` [PATCH 2/4][RFC] MIPS: BCM947xx support Aurelien Jarno
@ 2007-08-09  0:45                 ` Aurelien Jarno
  2007-08-09 20:40                   ` Andrew Morton
  2007-08-09  0:45                 ` [PATCH 4/4][RFC] MIPS: Add BCM947xx to Makefile Aurelien Jarno
  3 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09  0:45 UTC (permalink / raw)
  To: linux-mips; +Cc: Andrew Morton, mb, nbd, jolt

The patch below against 2.6.23-rc1-mm2 adds a BCM947XX option to 
Kconfig.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -67,6 +67,20 @@
 	  note that a kernel built with this option selected will not be
 	  able to run on normal units.
 
+config BCM947XX
+	bool "BCM947xx based boards"
+	select DMA_NONCOHERENT
+	select HW_HAS_PCI
+	select IRQ_CPU
+	select SYS_HAS_CPU_MIPS32_R1
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select SSB
+	select SSB_DRIVER_MIPS
+	select GENERIC_GPIO
+	help
+	 Support for BCM947xx based boards
+
 config MIPS_COBALT
 	bool "Cobalt Server"
 	select DMA_NONCOHERENT
--- a/drivers/ssb/Kconfig
+++ b/drivers/ssb/Kconfig
@@ -67,6 +67,7 @@
 config SSB_PCICORE_HOSTMODE
 	bool "Hostmode support for SSB PCI core"
 	depends on SSB_DRIVER_PCICORE && SSB_DRIVER_MIPS
+	default y if BCM947XX
 	help
 	  PCIcore hostmode operation (external PCI bus).
 
-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 4/4][RFC] MIPS: Add BCM947xx to Makefile
  2007-08-09  0:41               ` [PATCH 0/4][RFC] MIPS BCM947xx CPUs support Aurelien Jarno
                                   ` (2 preceding siblings ...)
  2007-08-09  0:45                 ` [PATCH 3/4] RFC: Add BCM947XX to Kconfig Aurelien Jarno
@ 2007-08-09  0:45                 ` Aurelien Jarno
  3 siblings, 0 replies; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09  0:45 UTC (permalink / raw)
  To: linux-mips; +Cc: Andrew Morton, mb, nbd, jolt

The patch below against 2.6.23-rc1-mm2 adds BCM947xx to 
arch/mips/Makefile.

Cc: Michael Buesch <mb@bu3sch.de>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: Florian Schirmer <jolt@tuxbox.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -549,6 +549,13 @@
 load-$(CONFIG_SIBYTE_BIGSUR)	:= 0xffffffff80100000
 
 #
+# Broadcom BCM947XX boards
+#
+core-$(CONFIG_BCM947XX)		+= arch/mips/bcm947xx/
+cflags-$(CONFIG_BCM947XX)	+= -Iinclude/asm-mips/mach-bcm947xx
+load-$(CONFIG_BCM947XX)		:= 0xffffffff80001000
+
+#
 # SNI RM
 #
 core-$(CONFIG_SNI_RM)		+= arch/mips/sni/

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 2/4][RFC] MIPS: BCM947xx support
  2007-08-09  0:44                 ` [PATCH 2/4][RFC] MIPS: BCM947xx support Aurelien Jarno
@ 2007-08-09 10:00                   ` Michael Buesch
  2007-08-09 10:38                     ` Aurelien Jarno
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Buesch @ 2007-08-09 10:00 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: linux-mips, Andrew Morton, nbd, jolt

On Thursday 09 August 2007 02:44:30 Aurelien Jarno wrote:
> +struct ssb_bus ssb_bcm947xx;
> +EXPORT_SYMBOL(ssb_bcm947xx);

Huh, which module does need this internal structure?

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 2/4][RFC] MIPS: BCM947xx support
  2007-08-09 10:00                   ` Michael Buesch
@ 2007-08-09 10:38                     ` Aurelien Jarno
  2007-08-09 10:51                       ` Michael Buesch
  0 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09 10:38 UTC (permalink / raw)
  To: Michael Buesch; +Cc: linux-mips, Andrew Morton, nbd, jolt

Michael Buesch a écrit :
> On Thursday 09 August 2007 02:44:30 Aurelien Jarno wrote:
>> +struct ssb_bus ssb_bcm947xx;
>> +EXPORT_SYMBOL(ssb_bcm947xx);
> 
> Huh, which module does need this internal structure?
> 

This is needed for mtd mappings. The size and the location of the flash
is taken from this structure.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 2/4][RFC] MIPS: BCM947xx support
  2007-08-09 10:38                     ` Aurelien Jarno
@ 2007-08-09 10:51                       ` Michael Buesch
  2007-08-09 11:26                         ` Aurelien Jarno
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Buesch @ 2007-08-09 10:51 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: linux-mips, Andrew Morton, nbd, jolt

On Thursday 09 August 2007 12:38:43 Aurelien Jarno wrote:
> Michael Buesch a écrit :
> > On Thursday 09 August 2007 02:44:30 Aurelien Jarno wrote:
> >> +struct ssb_bus ssb_bcm947xx;
> >> +EXPORT_SYMBOL(ssb_bcm947xx);
> > 
> > Huh, which module does need this internal structure?
> > 
> 
> This is needed for mtd mappings. The size and the location of the flash
> is taken from this structure.
> 

So mtd is compiled as a module? Really? From where is it loaded,
if not from flash?

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 2/4][RFC] MIPS: BCM947xx support
  2007-08-09 10:51                       ` Michael Buesch
@ 2007-08-09 11:26                         ` Aurelien Jarno
  2007-08-09 12:12                           ` Michael Buesch
  0 siblings, 1 reply; 25+ messages in thread
From: Aurelien Jarno @ 2007-08-09 11:26 UTC (permalink / raw)
  To: Michael Buesch; +Cc: linux-mips, Andrew Morton, nbd, jolt

Michael Buesch a écrit :
> On Thursday 09 August 2007 12:38:43 Aurelien Jarno wrote:
>> Michael Buesch a écrit :
>>> On Thursday 09 August 2007 02:44:30 Aurelien Jarno wrote:
>>>> +struct ssb_bus ssb_bcm947xx;
>>>> +EXPORT_SYMBOL(ssb_bcm947xx);
>>> Huh, which module does need this internal structure?
>>>
>> This is needed for mtd mappings. The size and the location of the flash
>> is taken from this structure.
>>
> 
> So mtd is compiled as a module? Really? From where is it loaded,
> if not from flash?
> 

Well you don't have to compile it as a module, but you can. Then you can
load it from the hard drive.

-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 2/4][RFC] MIPS: BCM947xx support
  2007-08-09 11:26                         ` Aurelien Jarno
@ 2007-08-09 12:12                           ` Michael Buesch
  0 siblings, 0 replies; 25+ messages in thread
From: Michael Buesch @ 2007-08-09 12:12 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: linux-mips, Andrew Morton, nbd, jolt

On Thursday 09 August 2007 13:26:40 Aurelien Jarno wrote:
> Michael Buesch a écrit :
> > On Thursday 09 August 2007 12:38:43 Aurelien Jarno wrote:
> >> Michael Buesch a écrit :
> >>> On Thursday 09 August 2007 02:44:30 Aurelien Jarno wrote:
> >>>> +struct ssb_bus ssb_bcm947xx;
> >>>> +EXPORT_SYMBOL(ssb_bcm947xx);
> >>> Huh, which module does need this internal structure?
> >>>
> >> This is needed for mtd mappings. The size and the location of the flash
> >> is taken from this structure.
> >>
> > 
> > So mtd is compiled as a module? Really? From where is it loaded,
> > if not from flash?
> > 
> 
> Well you don't have to compile it as a module, but you can. Then you can
> load it from the hard drive.

Ah, ok. I see. Acked.

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 3/4] RFC: Add BCM947XX to Kconfig
  2007-08-09  0:45                 ` [PATCH 3/4] RFC: Add BCM947XX to Kconfig Aurelien Jarno
@ 2007-08-09 20:40                   ` Andrew Morton
  0 siblings, 0 replies; 25+ messages in thread
From: Andrew Morton @ 2007-08-09 20:40 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: linux-mips, mb, nbd, jolt

On Thu, 9 Aug 2007 02:45:14 +0200
Aurelien Jarno <aurelien@aurel32.net> wrote:

> The patch below against 2.6.23-rc1-mm2 adds a BCM947XX option to 
> Kconfig.
> 
> Cc: Michael Buesch <mb@bu3sch.de>
> Cc: Felix Fietkau <nbd@openwrt.org>
> Cc: Florian Schirmer <jolt@tuxbox.org>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -67,6 +67,20 @@
>  	  note that a kernel built with this option selected will not be
>  	  able to run on normal units.
>  
> +config BCM947XX
> +	bool "BCM947xx based boards"
> +	select DMA_NONCOHERENT
> +	select HW_HAS_PCI
> +	select IRQ_CPU
> +	select SYS_HAS_CPU_MIPS32_R1
> +	select SYS_SUPPORTS_32BIT_KERNEL
> +	select SYS_SUPPORTS_LITTLE_ENDIAN
> +	select SSB
> +	select SSB_DRIVER_MIPS
> +	select GENERIC_GPIO
> +	help
> +	 Support for BCM947xx based boards
> +
>  config MIPS_COBALT
>  	bool "Cobalt Server"
>  	select DMA_NONCOHERENT
> --- a/drivers/ssb/Kconfig
> +++ b/drivers/ssb/Kconfig
> @@ -67,6 +67,7 @@
>  config SSB_PCICORE_HOSTMODE
>  	bool "Hostmode support for SSB PCI core"
>  	depends on SSB_DRIVER_PCICORE && SSB_DRIVER_MIPS
> +	default y if BCM947XX
>  	help
>  	  PCIcore hostmode operation (external PCI bus).

I'll consider these to be MIPS patches, so I'll spam Ralf with them.

I dropped the second hunk here, as Ralf has no drivers/ssb.  This will
need to be wired up in some later patch, once these various trees all end
up in the same place, presumably Linus's tree.

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2007-08-09 20:41 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06 15:09 [PATCH -mm 2/4] MIPS: BCM947xx support Aurelien Jarno
2007-08-06 18:05 ` Michael Buesch
2007-08-06 18:33   ` Aurelien Jarno
2007-08-06 18:37     ` Michael Buesch
2007-08-06 19:17       ` [PATCH -mm 2/4] MIPS: BCM947xx support (v2) Aurelien Jarno
2007-08-06 19:22         ` Michael Buesch
2007-08-06 20:31         ` Florian Schirmer
2007-08-07  8:05           ` Aurelien Jarno
2007-08-07  0:40         ` Yoichi Yuasa
2007-08-07  8:01           ` Aurelien Jarno
2007-08-07  8:02           ` Aurelien Jarno
2007-08-07  8:04           ` Aurelien Jarno
2007-08-07 12:16           ` [PATCH -mm 2/4] MIPS: BCM947xx support (v3) Aurelien Jarno
2007-08-08  1:33             ` Andrew Morton
2007-08-09  0:41               ` [PATCH 0/4][RFC] MIPS BCM947xx CPUs support Aurelien Jarno
2007-08-09  0:43                 ` [PATCH 1/4][RFC] MIPS: Detect BCM947xx CPUs Aurelien Jarno
2007-08-09  0:44                 ` [PATCH 2/4][RFC] MIPS: BCM947xx support Aurelien Jarno
2007-08-09 10:00                   ` Michael Buesch
2007-08-09 10:38                     ` Aurelien Jarno
2007-08-09 10:51                       ` Michael Buesch
2007-08-09 11:26                         ` Aurelien Jarno
2007-08-09 12:12                           ` Michael Buesch
2007-08-09  0:45                 ` [PATCH 3/4] RFC: Add BCM947XX to Kconfig Aurelien Jarno
2007-08-09 20:40                   ` Andrew Morton
2007-08-09  0:45                 ` [PATCH 4/4][RFC] MIPS: Add BCM947xx to Makefile Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox