summaryrefslogtreecommitdiff
path: root/sys/arch/loongson
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-02-12 19:37:32 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-02-12 19:37:32 +0000
commitb59df871cd300552147e6cc6593a56c47104dda4 (patch)
treeee3de1579345651c36f701591d604b614f731b2d /sys/arch/loongson
parent633324f938e62a75580861213516015a2b46954c (diff)
Allow for two more per-platform function pointers, one for extra setup work
while pmon is still available, and one for reset (in addition to the already existing powerdown routine). Add reset and powerdown code to the fuloong 2f platform; this also fixes reset on yeeloong. Tested by otto@
Diffstat (limited to 'sys/arch/loongson')
-rw-r--r--sys/arch/loongson/dev/glxreg.h98
-rw-r--r--sys/arch/loongson/include/autoconf.h4
-rw-r--r--sys/arch/loongson/loongson/gdium_machdep.c6
-rw-r--r--sys/arch/loongson/loongson/machdep.c13
-rw-r--r--sys/arch/loongson/loongson/yeeloong_machdep.c31
5 files changed, 142 insertions, 10 deletions
diff --git a/sys/arch/loongson/dev/glxreg.h b/sys/arch/loongson/dev/glxreg.h
index 3297afe0829..870ba6030e9 100644
--- a/sys/arch/loongson/dev/glxreg.h
+++ b/sys/arch/loongson/dev/glxreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: glxreg.h,v 1.1 2009/12/25 21:04:27 miod Exp $ */
+/* $OpenBSD: glxreg.h,v 1.2 2010/02/12 19:37:29 miod Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
@@ -290,3 +290,99 @@
#define GLCP_SYS_RST (GLCP_MSR_BASE + 0x14)
#define GLCP_DBGCLKCTRL (GLCP_MSR_BASE + 0x16)
#define GLCP_CHIP_REV_ID (GLCP_MSR_BASE + 0x17)
+
+/*
+ * GPIO registers
+ */
+
+#define GPIOL_OUT_VAL 0x0000
+#define GPIOL_OUT_EN 0x0004
+#define GPIOL_OUT_OD_EN 0x0008
+#define GPIOL_OUT_INVRT_EN 0x000c
+#define GPIOL_OUT_AUX1_SEL 0x0010
+#define GPIOL_OUT_AUX2_SEL 0x0014
+#define GPIOL_PU_EN 0x0018
+#define GPIOL_PD_EN 0x001c
+#define GPIOL_IN_EN 0x0020
+#define GPIOL_IN_INV_EN 0x0024
+#define GPIOL_IN_FLTR_EN 0x0028
+#define GPIOL_IN_EVNTCNT_EN 0x002c
+#define GPIOL_READ_BACK 0x0030
+#define GPIOL_IN_AUX1_SEL 0x0034
+#define GPIOL_EVNT_EN 0x0038
+#define GPIOL_LOCK_EN 0x003c
+#define GPIOL_POSEDGE_EN 0x0040
+#define GPIOL_NEGEDGE_EN 0x0044
+#define GPIOL_POSEDGE_STS 0x0048
+#define GPIOL_NEGEDGE_STS 0x004c
+#define GPIO_FLTR0_AMNT 0x0050
+#define GPIO_FLTR0_CNT 0x0052
+#define GPIO_EVNTCNT0 0x0054
+#define GPIO_EVNTCNT0_COMP 0x0056
+#define GPIO_FLTR1_AMNT 0x0058
+#define GPIO_FLTR1_CNT 0x005a
+#define GPIO_EVNTCNT1 0x005c
+#define GPIO_EVNTCNT1_COMP 0x005e
+#define GPIO_FLTR2_AMNT 0x0060
+#define GPIO_FLTR2_CNT 0x0062
+#define GPIO_EVNTCNT2 0x0064
+#define GPIO_EVNTCNT2_COMP 0x0066
+#define GPIO_FLTR3_AMNT 0x0068
+#define GPIO_FLTR3_CNT 0x006a
+#define GPIO_EVNTCNT3 0x006c
+#define GPIO_EVNTCNT3_COMP 0x006e
+#define GPIO_FLTR4_AMNT 0x0070
+#define GPIO_FLTR4_CNT 0x0072
+#define GPIO_EVNTCNT4 0x0074
+#define GPIO_EVNTCNT4_COMP 0x0076
+#define GPIO_FLTR5_AMNT 0x0078
+#define GPIO_FLTR5_CNT 0x007a
+#define GPIO_EVNTCNT5 0x007c
+#define GPIO_EVNTCNT5_COMP 0x007e
+#define GPIOH_OUT_VAL 0x0080
+#define GPIOH_OUT_EN 0x0084
+#define GPIOH_OUT_OD_EN 0x0088
+#define GPIOH_OUT_INVRT_EN 0x008c
+#define GPIOH_OUT_AUX1_SEL 0x0090
+#define GPIOH_OUT_AUX2_SEL 0x0094
+#define GPIOH_PU_EN 0x0098
+#define GPIOH_PD_EN 0x009c
+#define GPIOH_IN_EN 0x00a0
+#define GPIOH_IN_INV_EN 0x00a4
+#define GPIOH_IN_FLTR_EN 0x00a8
+#define GPIOH_IN_EVNTCNT_EN 0x00ac
+#define GPIOH_READ_BACK 0x00b0
+#define GPIOH_IN_AUX1_SEL 0x00b4
+#define GPIOH_EVNT_EN 0x00b8
+#define GPIOH_LOCK_EN 0x00bc
+#define GPIOH_POSEDGE_EN 0x00c0
+#define GPIOH_NEGEDGE_EN 0x00c4
+#define GPIOH_POSEDGE_STS 0x00c8
+#define GPIOH_NEGEDGE_STS 0x00cc
+#define GPIO_FLTR6_AMNT 0x00d0
+#define GPIO_FLTR6_CNT 0x00d2
+#define GPIO_EVNTCNT6 0x00d4
+#define GPIO_EVNTCNT6_COMP 0x00d6
+#define GPIO_FLTR7_AMNT 0x00d8
+#define GPIO_FLTR7_CNT 0x00da
+#define GPIO_EVNTCNT7 0x00dc
+#define GPIO_EVNTCNT7_COMP 0x00de
+#define GPIO_MAP_X 0x00e0
+#define GPIO_MAP_Y 0x00e4
+#define GPIO_MAP_Z 0x00e8
+#define GPIO_MAP_W 0x00ec
+#define GPIO_FE0_SEL 0x00f0
+#define GPIO_FE1_SEL 0x00f1
+#define GPIO_FE2_SEL 0x00f2
+#define GPIO_FE3_SEL 0x00f3
+#define GPIO_FE4_SEL 0x00f4
+#define GPIO_FE5_SEL 0x00f5
+#define GPIO_FE6_SEL 0x00f6
+#define GPIO_FE7_SEL 0x00f7
+#define GPIOL_EVNTCNT_DEC 0x00f8
+#define GPIOH_EVNTCNT_DEC 0x00fc
+
+#define GPIO_ATOMIC_VALUE(pin,feature) \
+ ((feature) ? \
+ ((0 << (16 + (pin))) | (1 << (pin))) : \
+ ((1 << (16 + (pin))) | (0 << (pin))))
diff --git a/sys/arch/loongson/include/autoconf.h b/sys/arch/loongson/include/autoconf.h
index 93a91e7d303..83d2c4ad6b7 100644
--- a/sys/arch/loongson/include/autoconf.h
+++ b/sys/arch/loongson/include/autoconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.h,v 1.4 2010/02/12 08:14:02 miod Exp $ */
+/* $OpenBSD: autoconf.h,v 1.5 2010/02/12 19:37:31 miod Exp $ */
/*
* Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -56,7 +56,9 @@ struct platform {
const struct bonito_config *bonito_config;
const struct legacy_io_range *legacy_io_ranges;
+ void (*setup)(void);
void (*powerdown)(void);
+ void (*reset)(void);
};
extern const struct platform *sys_platform;
diff --git a/sys/arch/loongson/loongson/gdium_machdep.c b/sys/arch/loongson/loongson/gdium_machdep.c
index 84a5fdd4245..7f1dbed57ba 100644
--- a/sys/arch/loongson/loongson/gdium_machdep.c
+++ b/sys/arch/loongson/loongson/gdium_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gdium_machdep.c,v 1.3 2010/02/12 08:14:02 miod Exp $ */
+/* $OpenBSD: gdium_machdep.c,v 1.4 2010/02/12 19:37:31 miod Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -64,7 +64,9 @@ const struct platform gdium_platform = {
.bonito_config = &gdium_bonito,
.legacy_io_ranges = NULL,
- .powerdown = gdium_powerdown
+ .setup = NULL,
+ .powerdown = gdium_powerdown,
+ .reset = NULL
};
void
diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c
index 892a64aca88..d8c2531715d 100644
--- a/sys/arch/loongson/loongson/machdep.c
+++ b/sys/arch/loongson/loongson/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.12 2010/02/12 08:14:02 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.13 2010/02/12 19:37:31 miod Exp $ */
/*
* Copyright (c) 2009, 2010 Miodrag Vallat.
@@ -354,9 +354,11 @@ mips_init(int32_t argc, int32_t argv, int32_t envp, int32_t cv)
break;
}
+ if (sys_platform->setup != NULL)
+ (*(sys_platform->setup))();
+
/*
- * The above call might have altered address mappings,
- * so pmon_printf() should no longer be used from now on.
+ * PMON functions should no longer be used from now on.
*/
/*
@@ -826,6 +828,11 @@ haltsys:
} else {
void (*__reset)(void) = (void (*)(void))RESET_EXC_VEC;
printf("System restart.\n");
+ if (sys_platform->reset != NULL)
+ (*(sys_platform->reset))();
+ (void)disableintr();
+ tlb_set_wired(0);
+ tlb_flush(bootcpu_hwinfo.tlbsize);
__reset();
}
diff --git a/sys/arch/loongson/loongson/yeeloong_machdep.c b/sys/arch/loongson/loongson/yeeloong_machdep.c
index 786eb58593d..a648ecc844e 100644
--- a/sys/arch/loongson/loongson/yeeloong_machdep.c
+++ b/sys/arch/loongson/loongson/yeeloong_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yeeloong_machdep.c,v 1.3 2010/02/12 08:14:02 miod Exp $ */
+/* $OpenBSD: yeeloong_machdep.c,v 1.4 2010/02/12 19:37:31 miod Exp $ */
/*
* Copyright (c) 2009, 2010 Miodrag Vallat.
@@ -35,12 +35,15 @@
#include <loongson/dev/bonitoreg.h>
#include <loongson/dev/bonitovar.h>
#include <loongson/dev/bonito_irq.h>
+#include <loongson/dev/glxreg.h>
#include <loongson/dev/glxvar.h>
void yeeloong_attach_hook(pci_chipset_tag_t);
int yeeloong_intr_map(int, int, int);
+void fuloong_powerdown(void);
void yeeloong_powerdown(void);
+void yeeloong_reset(void);
const struct bonito_config yeeloong_bonito = {
.bc_adbase = 11,
@@ -100,7 +103,9 @@ const struct platform fuloong_platform = {
.bonito_config = &yeeloong_bonito,
.legacy_io_ranges = fuloong_legacy_ranges,
- .powerdown = NULL /* XXX TBD */
+ .setup = NULL,
+ .powerdown = fuloong_powerdown,
+ .reset = yeeloong_reset
};
const struct platform yeeloong_platform = {
@@ -111,7 +116,9 @@ const struct platform yeeloong_platform = {
.bonito_config = &yeeloong_bonito,
.legacy_io_ranges = yeeloong_legacy_ranges,
- .powerdown = yeeloong_powerdown
+ .setup = NULL,
+ .powerdown = yeeloong_powerdown,
+ .reset = yeeloong_reset
};
void
@@ -174,8 +181,26 @@ yeeloong_intr_map(int dev, int fn, int pin)
}
void
+fuloong_powerdown()
+{
+ vaddr_t gpiobase;
+
+ gpiobase = BONITO_PCIIO_BASE + (rdmsr(DIVIL_LBAR_GPIO) & 0xff00);
+ /* enable GPIO 13 */
+ REGVAL(gpiobase + GPIOL_OUT_EN) = GPIO_ATOMIC_VALUE(13, 1);
+ /* set GPIO13 value to zero */
+ REGVAL(gpiobase + GPIOL_OUT_VAL) = GPIO_ATOMIC_VALUE(13, 0);
+}
+
+void
yeeloong_powerdown()
{
REGVAL(BONITO_GPIODATA) &= ~0x00000001;
REGVAL(BONITO_GPIOIE) &= ~0x00000001;
}
+
+void
+yeeloong_reset()
+{
+ wrmsr(GLCP_SYS_RST, rdmsr(GLCP_SYS_RST) | 1);
+}