From c9a3fbfa7a7ec54be976c5c1942f247fd65760c5 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sun, 17 Jul 2016 17:45:14 +0000 Subject: [PATCH] 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@ --- sys/arch/armv7/sunxi/sunxi.c | 62 +++++++++++++++++++++++++++++------- 1 file 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 * @@ -25,6 +25,8 @@ #include #include +#include + 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; } -- 2.20.1