summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2014-03-27 22:16:04 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2014-03-27 22:16:04 +0000
commit3cce96723e1cf425ea1e8075d5d5fa46bb656fa4 (patch)
tree660799b148f253b2e588e5444cc91e47f63e1ea0 /sys/arch
parent9b1b20636dc73cfdd48b3c7a823889be75e67da5 (diff)
Remove dependency from wscons_machdep upon bonito. Instead of hardcoding bonito
as the northbridge, have the per-platform early setup code register functions providing access to the PCI configuration space, for the wscons code to walk the PCI space in search of a graphics board. No functional change yet.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/loongson/dev/bonito.c19
-rw-r--r--sys/arch/loongson/dev/bonitovar.h4
-rw-r--r--sys/arch/loongson/include/autoconf.h5
-rw-r--r--sys/arch/loongson/include/pci_machdep.h6
-rw-r--r--sys/arch/loongson/loongson/gdium_machdep.c11
-rw-r--r--sys/arch/loongson/loongson/generic2e_machdep.c4
-rw-r--r--sys/arch/loongson/loongson/machdep.c7
-rw-r--r--sys/arch/loongson/loongson/wscons_machdep.c29
-rw-r--r--sys/arch/loongson/loongson/yeeloong_machdep.c16
9 files changed, 71 insertions, 30 deletions
diff --git a/sys/arch/loongson/dev/bonito.c b/sys/arch/loongson/dev/bonito.c
index 655eed2ad0a..57c902c460f 100644
--- a/sys/arch/loongson/dev/bonito.c
+++ b/sys/arch/loongson/dev/bonito.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bonito.c,v 1.24 2013/08/25 08:18:05 miod Exp $ */
+/* $OpenBSD: bonito.c,v 1.25 2014/03/27 22:16:03 miod Exp $ */
/* $NetBSD: bonito_mainbus.c,v 1.11 2008/04/28 20:23:10 martin Exp $ */
/* $NetBSD: bonito_pci.c,v 1.5 2008/04/28 20:23:28 martin Exp $ */
@@ -1208,14 +1208,27 @@ out:
* Functions used during early system configuration (before bonito attaches).
*/
+pcitag_t bonito_make_tag_early(int, int, int);
+pcireg_t bonito_conf_read_early(pcitag_t, int);
+
pcitag_t
-pci_make_tag_early(int b, int d, int f)
+bonito_make_tag_early(int b, int d, int f)
{
return bonito_make_tag(NULL, b, d, f);
}
pcireg_t
-pci_conf_read_early(pcitag_t tag, int reg)
+bonito_conf_read_early(pcitag_t tag, int reg)
{
return bonito_conf_read_internal(sys_platform->bonito_config, tag, reg);
}
+
+void
+bonito_early_setup()
+{
+ pci_make_tag_early = bonito_make_tag_early;
+ pci_conf_read_early = bonito_conf_read_early;
+
+ early_mem_t = &bonito_pci_mem_space_tag;
+ early_io_t = &bonito_pci_io_space_tag;
+}
diff --git a/sys/arch/loongson/dev/bonitovar.h b/sys/arch/loongson/dev/bonitovar.h
index 82147f180ac..043b488dd73 100644
--- a/sys/arch/loongson/dev/bonitovar.h
+++ b/sys/arch/loongson/dev/bonitovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bonitovar.h,v 1.5 2010/05/08 21:59:56 miod Exp $ */
+/* $OpenBSD: bonitovar.h,v 1.6 2014/03/27 22:16:03 miod Exp $ */
/* $NetBSD: bonitovar.h,v 1.4 2008/04/28 20:23:28 martin Exp $ */
/*-
@@ -73,6 +73,8 @@ int bonito_print(void *, const char *);
struct extent
*bonito_get_resource_extent(pci_chipset_tag_t, int);
void bonito_setintrmask(int);
+
+void bonito_early_setup(void);
#endif /* _KERNEL */
#endif /* _LOONGSON_DEV_BONITOVAR_H_ */
diff --git a/sys/arch/loongson/include/autoconf.h b/sys/arch/loongson/include/autoconf.h
index 4b32941f59b..200b47fc672 100644
--- a/sys/arch/loongson/include/autoconf.h
+++ b/sys/arch/loongson/include/autoconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.h,v 1.9 2012/10/03 21:44:51 miod Exp $ */
+/* $OpenBSD: autoconf.h,v 1.10 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -86,6 +86,9 @@ extern struct device *bootdv;
extern char bootdev[];
extern enum devclass bootdev_class;
+extern bus_space_tag_t early_mem_t;
+extern bus_space_tag_t early_io_t;
+
#include <mips64/autoconf.h>
#endif /* _MACHINE_AUTOCONF_H_ */
diff --git a/sys/arch/loongson/include/pci_machdep.h b/sys/arch/loongson/include/pci_machdep.h
index f4ae48f0137..10b97a58e48 100644
--- a/sys/arch/loongson/include/pci_machdep.h
+++ b/sys/arch/loongson/include/pci_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.h,v 1.8 2013/11/05 10:12:35 mpi Exp $ */
+/* $OpenBSD: pci_machdep.h,v 1.9 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -94,7 +94,7 @@ extern paddr_t loongson_dma_base;
* Functions used during early system configuration.
*/
-pcitag_t pci_make_tag_early(int, int, int);
-pcireg_t pci_conf_read_early(pcitag_t, int);
+extern pcitag_t (*pci_make_tag_early)(int, int, int);
+extern pcireg_t (*pci_conf_read_early)(pcitag_t, int);
#define pci_dev_postattach(a, b)
diff --git a/sys/arch/loongson/loongson/gdium_machdep.c b/sys/arch/loongson/loongson/gdium_machdep.c
index 7f823468f66..f0386b81b96 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.7 2012/10/03 21:44:51 miod Exp $ */
+/* $OpenBSD: gdium_machdep.c,v 1.8 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -41,6 +41,7 @@ void gdium_device_register(struct device *, void *);
int gdium_intr_map(int, int, int);
void gdium_powerdown(void);
void gdium_reset(void);
+void gdium_setup(void);
const struct bonito_config gdium_bonito = {
.bc_adbase = 11,
@@ -65,7 +66,7 @@ const struct platform gdium_platform = {
.isa_chipset = NULL,
.legacy_io_ranges = NULL,
- .setup = NULL,
+ .setup = gdium_setup,
.device_register = gdium_device_register,
.powerdown = gdium_powerdown,
@@ -274,3 +275,9 @@ gdium_reset()
REGVAL(BONITO_GPIODATA) &= ~0x00000002;
REGVAL(BONITO_GPIOIE) &= ~0x00000002;
}
+
+void
+gdium_setup()
+{
+ bonito_early_setup();
+}
diff --git a/sys/arch/loongson/loongson/generic2e_machdep.c b/sys/arch/loongson/loongson/generic2e_machdep.c
index 6133e615702..3077542195c 100644
--- a/sys/arch/loongson/loongson/generic2e_machdep.c
+++ b/sys/arch/loongson/loongson/generic2e_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: generic2e_machdep.c,v 1.5 2012/10/03 21:44:51 miod Exp $ */
+/* $OpenBSD: generic2e_machdep.c,v 1.6 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -353,6 +353,8 @@ generic2e_setup(void)
comconsrate = 115200; /* default PMON console speed */
}
#endif
+
+ bonito_early_setup();
}
void
diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c
index 05412107ff6..c57f650e5da 100644
--- a/sys/arch/loongson/loongson/machdep.c
+++ b/sys/arch/loongson/loongson/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.44 2014/03/13 03:52:55 dlg Exp $ */
+/* $OpenBSD: machdep.c,v 1.45 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2009, 2010 Miodrag Vallat.
@@ -126,6 +126,11 @@ caddr_t ekern;
struct phys_mem_desc mem_layout[MAXMEMSEGS];
+pcitag_t (*pci_make_tag_early)(int, int, int);
+pcireg_t (*pci_conf_read_early)(pcitag_t, int);
+bus_space_tag_t early_mem_t;
+bus_space_tag_t early_io_t;
+
static u_long atoi(const char *, uint);
static void dobootopts(int);
diff --git a/sys/arch/loongson/loongson/wscons_machdep.c b/sys/arch/loongson/loongson/wscons_machdep.c
index 9d9711d19a3..232082e4080 100644
--- a/sys/arch/loongson/loongson/wscons_machdep.c
+++ b/sys/arch/loongson/loongson/wscons_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wscons_machdep.c,v 1.10 2012/10/03 21:44:51 miod Exp $ */
+/* $OpenBSD: wscons_machdep.c,v 1.11 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -134,8 +134,6 @@ static int initted;
pcitag_t tag;
pcireg_t id, class;
int dev, rc;
- extern struct mips_bus_space bonito_pci_io_space_tag;
- extern struct mips_bus_space bonito_pci_mem_space_tag;
extern struct consdev pmoncons;
if (initted)
@@ -170,21 +168,21 @@ static int initted;
/* bitmapped frame buffer won't be of PREHISTORIC class */
if (PCI_CLASS(class) == PCI_CLASS_DISPLAY) {
#if NSISFB > 0
- if (rc != 0)
- rc = sisfb_cnattach(&bonito_pci_mem_space_tag,
- &bonito_pci_io_space_tag, tag, id);
+ if (rc != 0 && early_io_t != NULL)
+ rc = sisfb_cnattach(early_mem_t,
+ early_io_t, tag, id);
#endif
#if NSMFB > 0
- if (rc != 0)
- rc = smfb_cnattach(&bonito_pci_mem_space_tag,
- &bonito_pci_io_space_tag, tag, id);
+ if (rc != 0 && early_io_t != NULL)
+ rc = smfb_cnattach(early_mem_t,
+ early_io_t, tag, id);
#endif
- }
+ }
#if NVGA > 0
- if (rc != 0) {
+ if (rc != 0 && early_io_t != NULL) {
/* thanks $DEITY the pci_chipset_tag_t arg is ignored */
- rc = vga_pci_cnattach(&bonito_pci_io_space_tag,
- &bonito_pci_mem_space_tag, NULL, 0, dev, 0);
+ rc = vga_pci_cnattach(early_io_t,
+ early_mem_t, NULL, 0, dev, 0);
}
#endif
if (rc == 0)
@@ -205,9 +203,8 @@ setup_kbd:
rc = ENXIO;
#if NPCKBC > 0
- if (rc != 0)
- rc = pckbc_cnattach(&bonito_pci_io_space_tag, IO_KBD,
- KBCMDP, 0);
+ if (rc != 0 && early_io_t != NULL)
+ rc = pckbc_cnattach(early_io_t, IO_KBD, KBCMDP, 0);
#endif
#if NUKBD > 0
if (rc != 0)
diff --git a/sys/arch/loongson/loongson/yeeloong_machdep.c b/sys/arch/loongson/loongson/yeeloong_machdep.c
index 5b31d53a381..ad52a4fddc0 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.23 2013/01/16 20:28:06 miod Exp $ */
+/* $OpenBSD: yeeloong_machdep.c,v 1.24 2014/03/27 22:16:03 miod Exp $ */
/*
* Copyright (c) 2009, 2010 Miodrag Vallat.
@@ -59,6 +59,8 @@ extern struct mips_bus_space bonito_pci_io_space_tag;
void lemote_device_register(struct device *, void *);
void lemote_reset(void);
+void ebenton_setup(void);
+
void fuloong_powerdown(void);
void fuloong_setup(void);
@@ -218,7 +220,7 @@ const struct platform ebenton_platform = {
.isa_chipset = &lemote_isa_chipset,
.legacy_io_ranges = yeeloong_legacy_ranges,
- .setup = NULL,
+ .setup = ebenton_setup,
.device_register = lemote_device_register,
.powerdown = yeeloong_powerdown,
@@ -510,12 +512,22 @@ fuloong_setup(void)
#endif
cpu_setperf = loongson2f_setperf;
+
+ bonito_early_setup();
}
void
yeeloong_setup(void)
{
cpu_setperf = loongson2f_setperf;
+
+ bonito_early_setup();
+}
+
+void
+ebenton_setup(void)
+{
+ bonito_early_setup();
}
void