summaryrefslogtreecommitdiff
path: root/sys/arch/armv7
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-07-17 17:45:15 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-07-17 17:45:15 +0000
commit0e603d7c9e200d38e3b421af3544512d408459b1 (patch)
tree4bc15da9b1ff5263fb8b857e344805e8510cbf79 /sys/arch/armv7
parentbb8f11edb41a28f332f24c771e57d88a89786baa (diff)
Attach sunxi(4) based on the compatible property of the root node of the
device tree like we do on omap. Add preliminary support for the sun5i variant which corresponds to the A13 and A10s SoCs. ok patrick@
Diffstat (limited to 'sys/arch/armv7')
-rw-r--r--sys/arch/armv7/sunxi/sunxi.c62
1 files changed, 50 insertions, 12 deletions
diff --git a/sys/arch/armv7/sunxi/sunxi.c b/sys/arch/armv7/sunxi/sunxi.c
index 48bba6b1331..0232aae6818 100644
--- a/sys/arch/armv7/sunxi/sunxi.c
+++ b/sys/arch/armv7/sunxi/sunxi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sunxi.c,v 1.12 2016/06/11 07:07:59 jsg Exp $ */
+/* $OpenBSD: sunxi.c,v 1.13 2016/07/17 17:45:14 kettenis Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
*
@@ -25,6 +25,8 @@
#include <armv7/armv7/armv7var.h>
#include <armv7/sunxi/sunxireg.h>
+#include <dev/ofw/fdt.h>
+
int sunxi_match(struct device *, void *, void *);
void sxia1x_init();
void sxia20_init();
@@ -56,6 +58,21 @@ struct board_dev sun4i_devs[] = {
{ NULL, 0 }
};
+struct board_dev sun5i_devs[] = {
+ { "sxipio", 0 },
+ { "sxiccmu", 0 },
+ { "a1xintc", 0 },
+ { "sxitimer", 0 },
+ { "sxitimer", 1 },
+ { "sxitimer", 2 },
+ { "sxidog", 0 },
+ { "ehci", 0 },
+#if 0
+ { "ohci", 0 },
+#endif
+ { NULL, 0 }
+};
+
struct board_dev sun7i_devs[] = {
{ "sxipio", 0 },
{ "sxiccmu", 0 },
@@ -71,41 +88,62 @@ struct board_dev sun7i_devs[] = {
{ NULL, 0 }
};
-struct armv7_board sunxi_boards[] = {
+struct sunxi_soc {
+ char *compatible;
+ struct board_dev *devs;
+ void (*init)(void);
+};
+
+struct sunxi_soc sunxi_socs[] = {
{
- BOARD_ID_SUN4I_A10,
+ "allwinner,sun4i-a10",
sun4i_devs,
sxia1x_init,
},
{
- BOARD_ID_SUN7I_A20,
+ "allwinner,sun5i-a10s",
+ sun5i_devs,
+ sxia1x_init,
+ },
+ {
+ "allwinner,sun7i-a20",
sun7i_devs,
sxia20_init,
},
- { 0, NULL, NULL },
+ { NULL, NULL, NULL },
};
struct board_dev *
sunxi_board_devs(void)
{
+ void *node;
int i;
- for (i = 0; sunxi_boards[i].board_id != 0; i++) {
- if (sunxi_boards[i].board_id == board_id)
- return (sunxi_boards[i].devs);
+ node = fdt_find_node("/");
+ if (node == NULL)
+ return NULL;
+
+ for (i = 0; sunxi_socs[i].compatible != NULL; i++) {
+ if (fdt_is_compatible(node, sunxi_socs[i].compatible))
+ return sunxi_socs[i].devs;
}
- return (NULL);
+ return NULL;
}
void
sunxi_board_init(void)
{
bus_space_handle_t ioh;
+ void *node;
int i, match = 0;
- for (i = 0; sunxi_boards[i].board_id != 0; i++) {
- if (sunxi_boards[i].board_id == board_id) {
- sunxi_boards[i].init();
+ node = fdt_find_node("/");
+ if (node == NULL)
+ return;
+
+ for (i = 0; sunxi_socs[i].compatible != NULL; i++) {
+ if (fdt_is_compatible(node, sunxi_socs[i].compatible)) {
+ sunxi_socs[i].init();
match = 1;
break;
}