All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/12] add basic gdium support
@ 2010-05-04  9:55 yajin
  2010-05-04 11:25 ` Wu Zhangjin
  0 siblings, 1 reply; 2+ messages in thread
From: yajin @ 2010-05-04  9:55 UTC (permalink / raw)
  To: linux-mips, loongson-dev, wuzhangjin, apatard

Gdium is same to most of the loongson2f based machines except that it
does NOT use the cs5536 south bridge.

Signed-off-by: yajin <yajin@vm-kernel.org>
---
 arch/mips/Makefile                            |    1 +
 arch/mips/include/asm/mach-loongson/machine.h |    7 +++
 arch/mips/loongson/Kconfig                    |   25 +++++++++
 arch/mips/loongson/Makefile                   |    6 ++
 arch/mips/loongson/gdium/Makefile             |    3 +
 arch/mips/loongson/gdium/irq.c                |   66 +++++++++++++++++++++++++
 arch/mips/loongson/gdium/reset.c              |   25 +++++++++
 7 files changed, 133 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/gdium/Makefile
 create mode 100644 arch/mips/loongson/gdium/irq.c
 create mode 100644 arch/mips/loongson/gdium/reset.c

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 0b9c01a..c1470af 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -359,6 +359,7 @@ cflags-$(CONFIG_MACH_LOONGSON) +=
-I$(srctree)/arch/mips/include/asm/mach-loongs
                     -mno-branch-likely
 load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000
 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
+load-$(CONFIG_DEXXON_GDIUM) += 0xffffffff80200000

 #
 # MIPS Malta board
diff --git a/arch/mips/include/asm/mach-loongson/machine.h
b/arch/mips/include/asm/mach-loongson/machine.h
index 4321338..fb9554c 100644
--- a/arch/mips/include/asm/mach-loongson/machine.h
+++ b/arch/mips/include/asm/mach-loongson/machine.h
@@ -24,4 +24,11 @@

 #endif

+/* use gdium as the default machine of LEMOTE_MACH2F */
+#ifdef CONFIG_DEXXON_GDIUM
+
+#define LOONGSON_MACHTYPE MACH_DEXXON_GDIUM2F10
+
+#endif
+
 #endif /* __ASM_MACH_LOONGSON_MACHINE_H */
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 3df1967..90a02b4 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -57,6 +57,31 @@ config LEMOTE_MACH2F

 	  These family machines include fuloong2f mini PC, yeeloong2f notebook,
 	  LingLoong allinone PC and so forth.
+
+config DEXXON_GDIUM
+        bool "Dexxon Gdium Netbook"
+        select ARCH_SPARSEMEM_ENABLE
+        select BOARD_SCACHE
+        select BOOT_ELF32
+        select CEVT_R4K
+        select CPU_HAS_WB
+        select CSRC_R4K
+        select DMA_NONCOHERENT
+        select GENERIC_HARDIRQS_NO__DO_IRQ
+        select GENERIC_ISA_DMA_SUPPORT_BROKEN
+        select HW_HAS_PCI
+        select I8259
+        select IRQ_CPU
+        select ISA
+        select SYS_HAS_CPU_LOONGSON2F
+        select SYS_HAS_EARLY_PRINTK
+        select SYS_SUPPORTS_32BIT_KERNEL
+        select SYS_SUPPORTS_64BIT_KERNEL
+        select SYS_SUPPORTS_HIGHMEM
+        select SYS_SUPPORTS_LITTLE_ENDIAN
+        select ARCH_REQUIRE_GPIOLIB
+        help
+          Dexxon gdium netbook based on Loongson 2F and SM502.
 endchoice

 config CS5536
diff --git a/arch/mips/loongson/Makefile b/arch/mips/loongson/Makefile
index 2b76cb0..6002109 100644
--- a/arch/mips/loongson/Makefile
+++ b/arch/mips/loongson/Makefile
@@ -15,3 +15,9 @@ obj-$(CONFIG_LEMOTE_FULOONG2E)  += fuloong-2e/
 #

 obj-$(CONFIG_LEMOTE_MACH2F)  += lemote-2f/
+
+#
+# gdium
+#
+
+obj-$(CONFIG_DEXXON_GDIUM)  += gdium/
diff --git a/arch/mips/loongson/gdium/Makefile
b/arch/mips/loongson/gdium/Makefile
new file mode 100644
index 0000000..31a8e57
--- /dev/null
+++ b/arch/mips/loongson/gdium/Makefile
@@ -0,0 +1,3 @@
+# Makefile for gdium
+
+obj-y += irq.o reset.o
diff --git a/arch/mips/loongson/gdium/irq.c b/arch/mips/loongson/gdium/irq.c
new file mode 100644
index 0000000..b0679eb
--- /dev/null
+++ b/arch/mips/loongson/gdium/irq.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2007 Lemote Inc.
+ * Author: Fuxin Zhang, zhangfx@lemote.com
+ *
+ * Copyright (c) 2010 yajin <yajin@vm-kernel.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.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+
+#include <asm/irq_cpu.h>
+#include <asm/mipsregs.h>
+
+#include <loongson.h>
+#include <machine.h>
+
+#define LOONGSON_TIMER_IRQ      (MIPS_CPU_IRQ_BASE + 7) /* cpu timer */
+#define LOONGSON_PERFCNT_IRQ    (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */
+#define LOONGSON_NORTH_BRIDGE_IRQ       (MIPS_CPU_IRQ_BASE + 6) /* bonito */
+#define LOONGSON_UART_IRQ       (MIPS_CPU_IRQ_BASE + 3) /* cpu serial port */
+
+void mach_irq_dispatch(unsigned int pending)
+{
+	if (pending & CAUSEF_IP7)
+		do_IRQ(LOONGSON_TIMER_IRQ);
+	else if (pending & CAUSEF_IP6) {        /* North Bridge, Perf counter */
+#ifdef CONFIG_OPROFILE
+		do_IRQ(LOONGSON2_PERFCNT_IRQ);
+#endif
+		bonito_irqdispatch();
+	} else if (pending & CAUSEF_IP3)        /* CPU UART */
+		do_IRQ(LOONGSON_UART_IRQ);
+	else
+		spurious_interrupt();
+}
+
+static irqreturn_t ip6_action(int cpl, void *dev_id)
+{
+	return IRQ_HANDLED;
+}
+
+struct irqaction ip6_irqaction = {
+	.handler = ip6_action,
+	.name = "cascade",
+	.flags = IRQF_SHARED,
+};
+
+void __init mach_init_irq(void)
+{
+	/* init all controller
+	*   16-23        ------> mips cpu interrupt
+	*   32-63        ------> bonito irq
+	*/
+
+	/* Sets the first-level interrupt dispatcher. */
+	mips_cpu_irq_init();
+	bonito_irq_init();
+
+	/* setup north bridge irq (bonito) */
+	setup_irq(LOONGSON_NORTH_BRIDGE_IRQ, &ip6_irqaction);
+}
diff --git a/arch/mips/loongson/gdium/reset.c b/arch/mips/loongson/gdium/reset.c
new file mode 100644
index 0000000..da7752d
--- /dev/null
+++ b/arch/mips/loongson/gdium/reset.c
@@ -0,0 +1,25 @@
+/* Board-specific reboot/shutdown routines
+ *
+ * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
+ * Author: Fuxin Zhang, zhangfx@lemote.com
+ *
+ * Copyright (C) 2010 yajin <yajin@vm-kernel.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.
+ */
+#include <loongson.h>
+
+void mach_prepare_shutdown(void)
+{
+	LOONGSON_GPIOIE &= ~(1<<1);
+	LOONGSON_GPIODATA |= (1<<1);
+}
+
+void mach_prepare_reboot(void)
+{
+	LOONGSON_GPIOIE &= ~(1<<2);
+	LOONGSON_GPIODATA &= ~(1<<2);
+}
-- 
1.5.6.5

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

* Re: [PATCH 2/12] add basic gdium support
  2010-05-04  9:55 [PATCH 2/12] add basic gdium support yajin
@ 2010-05-04 11:25 ` Wu Zhangjin
  0 siblings, 0 replies; 2+ messages in thread
From: Wu Zhangjin @ 2010-05-04 11:25 UTC (permalink / raw)
  To: yajin; +Cc: linux-mips, loongson-dev, apatard

Hi, Yajin

On Tue, 2010-05-04 at 17:55 +0800, yajin wrote:
> Gdium is same to most of the loongson2f based machines except that it
> does NOT use the cs5536 south bridge.
> 
> Signed-off-by: yajin <yajin@vm-kernel.org>
[...]
>  #
>  # MIPS Malta board
> diff --git a/arch/mips/include/asm/mach-loongson/machine.h
> b/arch/mips/include/asm/mach-loongson/machine.h
> index 4321338..fb9554c 100644
> --- a/arch/mips/include/asm/mach-loongson/machine.h
> +++ b/arch/mips/include/asm/mach-loongson/machine.h
> @@ -24,4 +24,11 @@
> 
>  #endif
> 
> +/* use gdium as the default machine of LEMOTE_MACH2F */

Several machines shared the same LEMOTE_MACH2F config, I have added the
above comment for the default one, therefore, this is not needed for
gdium, you can remove it directly.

> +#ifdef CONFIG_DEXXON_GDIUM
> +
> +#define LOONGSON_MACHTYPE MACH_DEXXON_GDIUM2F10
> +
> +#endif
> +

Suggest you remove the 'useless' blank line between the #ifdef and
#endif and also the other blank lines in the original machine.h added by
me, just found they are really useless.

>  #endif /* __ASM_MACH_LOONGSON_MACHINE_H */
> diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
> index 3df1967..90a02b4 100644
> --- a/arch/mips/loongson/Kconfig
> +++ b/arch/mips/loongson/Kconfig
> @@ -57,6 +57,31 @@ config LEMOTE_MACH2F
> 
>  	  These family machines include fuloong2f mini PC, yeeloong2f notebook,
>  	  LingLoong allinone PC and so forth.
> +
> +config DEXXON_GDIUM
> +        bool "Dexxon Gdium Netbook"
> +        select ARCH_SPARSEMEM_ENABLE
> +        select BOARD_SCACHE
> +        select BOOT_ELF32
> +        select CEVT_R4K
> +        select CPU_HAS_WB
> +        select CSRC_R4K
> +        select DMA_NONCOHERENT
> +        select GENERIC_HARDIRQS_NO__DO_IRQ
> +        select GENERIC_ISA_DMA_SUPPORT_BROKEN
> +        select HW_HAS_PCI
> +        select I8259
> +        select IRQ_CPU
> +        select ISA
> +        select SYS_HAS_CPU_LOONGSON2F
> +        select SYS_HAS_EARLY_PRINTK
> +        select SYS_SUPPORTS_32BIT_KERNEL
> +        select SYS_SUPPORTS_64BIT_KERNEL
> +        select SYS_SUPPORTS_HIGHMEM
> +        select SYS_SUPPORTS_LITTLE_ENDIAN
> +        select ARCH_REQUIRE_GPIOLIB

Perhaps you can move "select ARCH_REQUIRE_GPIOLIB" before "select
ARCH_SPARSEMEM_ENABLE" to make them in alphabetical order.

> +        help
> +          Dexxon gdium netbook based on Loongson 2F and SM502.
>  endchoice
> 
>  config CS5536
> diff --git a/arch/mips/loongson/Makefile b/arch/mips/loongson/Makefile
> index 2b76cb0..6002109 100644
> --- a/arch/mips/loongson/Makefile
> +++ b/arch/mips/loongson/Makefile
> @@ -15,3 +15,9 @@ obj-$(CONFIG_LEMOTE_FULOONG2E)  += fuloong-2e/
>  #
> 
>  obj-$(CONFIG_LEMOTE_MACH2F)  += lemote-2f/
> +
> +#
> +# gdium
> +#
> +
> +obj-$(CONFIG_DEXXON_GDIUM)  += gdium/
> diff --git a/arch/mips/loongson/gdium/Makefile
> b/arch/mips/loongson/gdium/Makefile
> new file mode 100644
> index 0000000..31a8e57
> --- /dev/null
> +++ b/arch/mips/loongson/gdium/Makefile
> @@ -0,0 +1,3 @@
> +# Makefile for gdium
> +
> +obj-y += irq.o reset.o
> diff --git a/arch/mips/loongson/gdium/irq.c b/arch/mips/loongson/gdium/irq.c
> new file mode 100644
> index 0000000..b0679eb
> --- /dev/null
> +++ b/arch/mips/loongson/gdium/irq.c
> @@ -0,0 +1,66 @@
> +/*
> + * Copyright (C) 2007 Lemote Inc.
> + * Author: Fuxin Zhang, zhangfx@lemote.com
> + *
> + * Copyright (c) 2010 yajin <yajin@vm-kernel.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.
> + */
> +
> +#include <linux/interrupt.h>
> +#include <linux/module.h>
> +
> +#include <asm/irq_cpu.h>
> +#include <asm/mipsregs.h>
> +
> +#include <loongson.h>
> +#include <machine.h>
> +
> +#define LOONGSON_TIMER_IRQ      (MIPS_CPU_IRQ_BASE + 7) /* cpu timer */
> +#define LOONGSON_PERFCNT_IRQ    (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */
> +#define LOONGSON_NORTH_BRIDGE_IRQ       (MIPS_CPU_IRQ_BASE + 6) /* bonito */
> +#define LOONGSON_UART_IRQ       (MIPS_CPU_IRQ_BASE + 3) /* cpu serial port */
> +
> +void mach_irq_dispatch(unsigned int pending)
> +{
> +	if (pending & CAUSEF_IP7)
> +		do_IRQ(LOONGSON_TIMER_IRQ);
> +	else if (pending & CAUSEF_IP6) {        /* North Bridge, Perf counter */
> +#ifdef CONFIG_OPROFILE
> +		do_IRQ(LOONGSON2_PERFCNT_IRQ);
> +#endif

Ralf just applied one patch from me for the Oprofile problem when it is
configured as module, that commit is:

"MIPS: oprofile: Fix breakage when CONFIG_OPROFILE=m"

The #ifdef condition should be changed to "#if defined(CONFIG_OPROFILE)
|| defined(CONFIG_OPROFILE_MODULE)" to ensure the do_IRQ() is called
when the Oprofile driver is configured as a module.

To reduce the duplication and make it maintainable, Perhaps we can add
an inline function to loongson.h for this specific stuff.

static inline do_perfcnt_IRQ()
{
#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
	do_IRQ(LOONGSON2_PERFCNT_IRQ);
#endif
}

Regards,
	Wu Zhangjin

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

end of thread, other threads:[~2010-05-04 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04  9:55 [PATCH 2/12] add basic gdium support yajin
2010-05-04 11:25 ` Wu Zhangjin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.