Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/bonito Loongson2f support:
details: https://anonhg.NetBSD.org/src/rev/6828efedff51
branches: trunk
changeset: 768773:6828efedff51
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sat Aug 27 12:59:16 2011 +0000
description:
Loongson2f support:
- make the 'struct bonito_config' const, so that it can be in kernel
text instead of data.
- Add a bc_attach_hook to struct bonito_config, to be used as pc_attach_hook
if not NULL.
- Add some LS2-specific register defines (LS2f uses a modified bonito64).
diffstat:
sys/arch/mips/bonito/bonito_pci.c | 13 ++-
sys/arch/mips/bonito/bonitoreg.h | 114 +++++++++++++++++++++++++++++++++++++-
sys/arch/mips/bonito/bonitovar.h | 9 ++-
3 files changed, 128 insertions(+), 8 deletions(-)
diffs (204 lines):
diff -r cd2c6e8167a1 -r 6828efedff51 sys/arch/mips/bonito/bonito_pci.c
--- a/sys/arch/mips/bonito/bonito_pci.c Sat Aug 27 12:55:09 2011 +0000
+++ b/sys/arch/mips/bonito/bonito_pci.c Sat Aug 27 12:59:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bonito_pci.c,v 1.9 2011/07/10 23:13:22 matt Exp $ */
+/* $NetBSD: bonito_pci.c,v 1.10 2011/08/27 12:59:16 bouyer Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bonito_pci.c,v 1.9 2011/07/10 23:13:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bonito_pci.c,v 1.10 2011/08/27 12:59:16 bouyer Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -66,11 +66,14 @@
void bonito_conf_write(void *, pcitag_t, int, pcireg_t);
void
-bonito_pci_init(pci_chipset_tag_t pc, struct bonito_config *bc)
+bonito_pci_init(pci_chipset_tag_t pc, const struct bonito_config *bc)
{
- pc->pc_conf_v = bc;
- pc->pc_attach_hook = bonito_attach_hook;
+ pc->pc_conf_v = __UNCONST(bc);
+ if (bc->bc_attach_hook != NULL)
+ pc->pc_attach_hook = bc->bc_attach_hook;
+ else
+ pc->pc_attach_hook = bonito_attach_hook;
pc->pc_bus_maxdevs = bonito_bus_maxdevs;
pc->pc_make_tag = bonito_make_tag;
pc->pc_decompose_tag = bonito_decompose_tag;
diff -r cd2c6e8167a1 -r 6828efedff51 sys/arch/mips/bonito/bonitoreg.h
--- a/sys/arch/mips/bonito/bonitoreg.h Sat Aug 27 12:55:09 2011 +0000
+++ b/sys/arch/mips/bonito/bonitoreg.h Sat Aug 27 12:59:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bonitoreg.h,v 1.6 2005/12/24 20:07:19 perry Exp $ */
+/* $NetBSD: bonitoreg.h,v 1.7 2011/08/27 12:59:17 bouyer Exp $ */
/*
* Bonito Register Map
@@ -22,7 +22,14 @@
#define BONITO(x) (BONITO_REG_BASE + (x))
+
+#ifdef _LP64
+#define REGVAL(x) *((volatile u_int32_t *)MIPS_PHYS_TO_XKPHYS_UNCACHED(x))
+#define REGVAL8(x) *((volatile u_int8_t *)MIPS_PHYS_TO_XKPHYS_UNCACHED(x))
+#else
#define REGVAL(x) *((volatile u_int32_t *) MIPS_PHYS_TO_KSEG1(x))
+#define REGVAL8(x) *((volatile u_int8_t *)MIPS_PHYS_TO_KSEG1(x))
+#endif
#define BONITO_BOOT_BASE 0x1fc00000
#define BONITO_BOOT_SIZE 0x00100000
@@ -48,7 +55,11 @@
#define BONITO_PCIHI_BASE 0x20000000
#define BONITO_PCIHI_SIZE 0x20000000
#define BONITO_PCIHI_TOP (BONITO_PCIHI_BASE+BONITO_PCIHI_SIZE-1)
+#define LS2F_PCIHI_BASE 0x40000000UL
+#define LS2F_PCIHI_SIZE 0x40000000UL
+#define LS2F_PCIHI_TOP (LS2F_PCIHI_BASE+LS2F_PCIHI_SIZE-1)
#define BONITO_PCIIO_BASE 0x1fd00000
+#define BONITO_PCIIO_LEGACY 0x00004000UL
#define BONITO_PCIIO_SIZE 0x00100000
#define BONITO_PCIIO_TOP (BONITO_PCIIO_BASE+BONITO_PCIIO_SIZE-1)
#define BONITO_PCICFG_BASE 0x1fe80000
@@ -409,4 +420,105 @@
#define BONITO_TIMERCFG BONITO(BONITO_REGBASE + 0x60)
+
+/*
+ * Bonito interrupt assignments
+ */
+
+/*
+ * Loongson 2F assignments
+ */
+
+#define LOONGSON_INTR_GPIO0 0
+#define LOONGSON_INTR_GPIO1 1
+#define LOONGSON_INTR_GPIO2 2
+#define LOONGSON_INTR_GPIO3 3
+
+/* pci interrupts */
+#define LOONGSON_INTR_PCIA 4
+#define LOONGSON_INTR_PCIB 5
+#define LOONGSON_INTR_PCIC 6
+#define LOONGSON_INTR_PCID 7
+
+#define LOONGSON_INTR_PCI_PARERR 8
+#define LOONGSON_INTR_PCI_SYSERR 9
+#define LOONGSON_INTR_DRAM_PARERR 10
+
+/* non-PCI interrupts */
+#define LOONGSON_INTR_INT0 11
+#define LOONGSON_INTR_INT1 12
+#define LOONGSON_INTR_INT2 13
+#define LOONGSON_INTR_INT3 14
+
+#define LOONGSON_INTRMASK_GPIO0 0x00000001 /* can't interrupt */
+#define LOONGSON_INTRMASK_GPIO1 0x00000002
+#define LOONGSON_INTRMASK_GPIO2 0x00000004
+#define LOONGSON_INTRMASK_GPIO3 0x00000008
+
+#define LOONGSON_INTRMASK_GPIO 0x0000000f
+
+/* pci interrupts */
+#define LOONGSON_INTRMASK_PCIA 0x00000010
+#define LOONGSON_INTRMASK_PCIB 0x00000020
+#define LOONGSON_INTRMASK_PCIC 0x00000040
+#define LOONGSON_INTRMASK_PCID 0x00000080
+
+#define LOONGSON_INTRMASK_PCI_PARERR 0x00000100
+#define LOONGSON_INTRMASK_PCI_SYSERR 0x00000200
+#define LOONGSON_INTRMASK_DRAM_PARERR 0x00000400
+
+/* non-PCI interrupts */
+#define LOONGSON_INTRMASK_INT0 0x00000800
+#define LOONGSON_INTRMASK_INT1 0x00001000
+#define LOONGSON_INTRMASK_INT2 0x00002000
+#define LOONGSON_INTRMASK_INT3 0x00004000
+
+#define LOONGSON_INTRMASK_LVL0 0x00007800 /* not maskable in bonito */
+#define LOONGSON_INTRMASK_LVL4 0x000007ff
+
+/*
+ * Loongson 2E (Bonito64) assignments
+ */
+
+#define BONITO_INTRMASK_MBOX 0x0000000f
+#define BONITO_INTR_MBOX 0
+#define BONITO_INTRMASK_DMARDY 0x00000010
+#define BONITO_INTRMASK_DMAEMPTY 0x00000020
+#define BONITO_INTRMASK_COPYRDY 0x00000040
+#define BONITO_INTRMASK_COPYEMPTY 0x00000080
+#define BONITO_INTRMASK_COPYERR 0x00000100
+#define BONITO_INTRMASK_PCIIRQ 0x00000200
+#define BONITO_INTRMASK_MASTERERR 0x00000400
+#define BONITO_INTRMASK_SYSTEMERR 0x00000800
+#define BONITO_INTRMASK_DRAMPERR 0x00001000
+#define BONITO_INTRMASK_RETRYERR 0x00002000
+#define BONITO_INTRMASK_GPIO 0x01ff0000
+#define BONITO_INTR_GPIO 16
+#define BONITO_INTRMASK_GPIN 0x7e000000
+#define BONITO_INTR_GPIN 25
+
+/*
+ * Bonito interrupt handling recipes:
+ * - we have up to 32 interrupts at the Bonito level.
+ * - systems with ISA devices also have 16 (well, 15) ISA interrupts with the
+ * usual 8259 pair. Bonito and ISA interrupts happen on two different levels.
+ *
+ * These arbitrary values may be changed as long as interrupt mask variables
+ * use large enough integer types and always use the following macros to
+ * handle interrupt masks.
+ */
+
+#define INTPRI_BONITO (INTPRI_CLOCK + 1)
+#define INTPRI_ISA (INTPRI_BONITO + 1)
+
+#define BONITO_NDIRECT 32
+#define BONITO_NISA 16
+#define BONITO_NINTS (BONITO_NDIRECT + BONITO_NISA)
+#define BONITO_ISA_IRQ(i) ((i) + BONITO_NDIRECT)
+#define BONITO_DIRECT_IRQ(i) (i)
+#define BONITO_IRQ_IS_ISA(i) ((i) >= BONITO_NDIRECT)
+#define BONITO_IRQ_TO_ISA(i) ((i) - BONITO_NDIRECT)
+
+#define BONITO_DIRECT_MASK(imask) ((imask) & ((1L << BONITO_NDIRECT) - 1))
+#define BONITO_ISA_MASK(imask) ((imask) >> BONITO_NDIRECT)
#endif /* _BONITO_H_ */
diff -r cd2c6e8167a1 -r 6828efedff51 sys/arch/mips/bonito/bonitovar.h
--- a/sys/arch/mips/bonito/bonitovar.h Sat Aug 27 12:55:09 2011 +0000
+++ b/sys/arch/mips/bonito/bonitovar.h Sat Aug 27 12:59:16 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bonitovar.h,v 1.4 2008/04/28 20:23:28 martin Exp $ */
+/* $NetBSD: bonitovar.h,v 1.5 2011/08/27 12:59:17 bouyer Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -42,10 +42,15 @@
uint32_t bc_intEdge;
uint32_t bc_intSteer;
uint32_t bc_intPol;
+
+ /* PCI Attach hook , if needed */
+ void (*bc_attach_hook)(device_t, device_t,
+ struct pcibus_attach_args *);
+
};
#ifdef _KERNEL
-void bonito_pci_init(pci_chipset_tag_t, struct bonito_config *);
+void bonito_pci_init(pci_chipset_tag_t, const struct bonito_config *);
void bonito_iobc_wbinv_range(paddr_t, psize_t);
void bonito_iobc_inv_range(paddr_t, psize_t);
Home |
Main Index |
Thread Index |
Old Index