From: kettenis Date: Sat, 9 Jul 2016 18:14:18 +0000 (+0000) Subject: Simplify the i.MX6 platform code. The list of board devices is now X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b522e10e8e7c9e419a69df792dbea127b755ded5;p=openbsd Simplify the i.MX6 platform code. The list of board devices is now (essentially) the same for all boards, so we can use a single list and match based on the compatible property of the root node in the device tree. ok jsg@ --- diff --git a/sys/arch/armv7/imx/imx.c b/sys/arch/armv7/imx/imx.c index 59b57a6d2a6..935279464fd 100644 --- a/sys/arch/armv7/imx/imx.c +++ b/sys/arch/armv7/imx/imx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx.c,v 1.21 2016/07/09 12:32:50 kettenis Exp $ */ +/* $OpenBSD: imx.c,v 1.22 2016/07/09 18:14:18 kettenis Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn * Copyright (c) 2012-2013 Patrick Wildt @@ -24,51 +24,23 @@ #include #include +#include + int imx_match(struct device *, void *, void *); void imx6_init(); struct cfattach imx_ca = { - sizeof(struct armv7_softc), imx_match, armv7_attach, NULL, - config_activate_children + sizeof(struct armv7_softc), imx_match, armv7_attach }; struct cfdriver imx_cd = { NULL, "imx", DV_DULL }; -struct board_dev hummingboard_devs[] = { - { "imxocotp", 0 }, +struct board_dev imx_devs[] = { { "imxccm", 0 }, { "imxiomuxc", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { NULL, 0 } -}; - -struct board_dev sabrelite_devs[] = { - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxocotp", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { NULL, 0 } -}; - -struct board_dev sabresd_devs[] = { { "imxocotp", 0 }, - { "imxccm", 0 }, - { "imxtemp", 0 }, - { "imxiomuxc", 0 }, { "imxgpio", 0 }, { "imxgpio", 1 }, { "imxgpio", 2 }, @@ -79,129 +51,35 @@ struct board_dev sabresd_devs[] = { { NULL, 0 } }; -struct board_dev udoo_devs[] = { - { "imxocotp", 0 }, - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { NULL, 0 } -}; - -struct board_dev utilite_devs[] = { - { "imxocotp", 0 }, - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { NULL, 0 } -}; - -struct board_dev novena_devs[] = { - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxocotp", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { NULL, 0 } -}; - -struct board_dev wandboard_devs[] = { - { "imxccm", 0 }, - { "imxiomuxc", 0 }, - { "imxocotp", 0 }, - { "imxgpio", 0 }, - { "imxgpio", 1 }, - { "imxgpio", 2 }, - { "imxgpio", 3 }, - { "imxgpio", 4 }, - { "imxgpio", 5 }, - { "imxgpio", 6 }, - { NULL, 0 } -}; - -struct armv7_board imx_boards[] = { - { - BOARD_ID_IMX6_CUBOXI, - hummingboard_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_HUMMINGBOARD, - hummingboard_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_SABRELITE, - sabrelite_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_SABRESD, - sabresd_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_UDOO, - udoo_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_UTILITE, - utilite_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_NOVENA, - novena_devs, - imx6_init, - }, - { - BOARD_ID_IMX6_WANDBOARD, - wandboard_devs, - imx6_init, - }, - { 0, NULL, NULL }, +const char *imx_compatible[] = { + "fsl,imx6sl", + "fsl,imx6sx", + "fsl,imx6dl", + "fsl,imx6q", + NULL }; struct board_dev * imx_board_devs(void) { + void *node; int i; - for (i = 0; imx_boards[i].board_id != 0; i++) { - if (imx_boards[i].board_id == board_id) - return (imx_boards[i].devs); + node = fdt_find_node("/"); + if (node == NULL) + return NULL; + + for (i = 0; imx_compatible[i] != NULL; i++) { + if (fdt_is_compatible(node, imx_compatible[i])) + return imx_devs; } - return (NULL); + return NULL; } void imx_board_init(void) { - int i; - - for (i = 0; imx_boards[i].board_id != 0; i++) { - if (imx_boards[i].board_id == board_id) { - imx_boards[i].init(); - break; - } - } + imx6_init(); } int diff --git a/sys/arch/armv7/imx/imx6.c b/sys/arch/armv7/imx/imx6.c index fdfc49880e1..eeb78d2e874 100644 --- a/sys/arch/armv7/imx/imx6.c +++ b/sys/arch/armv7/imx/imx6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imx6.c,v 1.4 2016/06/03 01:36:46 jsg Exp $ */ +/* $OpenBSD: imx6.c,v 1.5 2016/07/09 18:14:18 kettenis Exp $ */ /* * Copyright (c) 2011 Uwe Stuehler * Copyright (c) 2012 Patrick Wildt @@ -32,54 +32,12 @@ #define CCM_IRQ1 87 #define CCM_IRQ2 88 -#define ANALOG_ADDR 0x020c8000 -#define ANALOG_SIZE 0x1000 - #define IOMUXC_ADDR 0x020e0000 #define IOMUXC_SIZE 0x4000 -#define WD1_ADDR 0x020bc000 -#define WD1_SIZE 0x400 -#define WD2_ADDR 0x020c0000 -#define WD2_SIZE 0x400 - #define OCOTP_ADDR 0x021bc000 #define OCOTP_SIZE 0x4000 -#define UARTx_SIZE 0x4000 -#define UART1_ADDR 0x02020000 -#define UART2_ADDR 0x021e8000 -#define UART3_ADDR 0x021ec000 -#define UART4_ADDR 0x021f0000 -#define UART5_ADDR 0x021f4000 - -#define UART1_IRQ 26 -#define UART2_IRQ 27 -#define UART3_IRQ 28 -#define UART4_IRQ 29 -#define UART5_IRQ 30 - -#define USBPHYx_SIZE 0x1000 -#define USBPHY1_ADDR 0x020c9000 -#define USBPHY2_ADDR 0x020ca000 -#define USBOTG_ADDR 0x02184000 -#define USBOTG_EHCI_ADDR 0x02184100 -#define USBUH1_ADDR 0x02184200 -#define USBUH1_EHCI_ADDR 0x02184300 -#define USBUH2_ADDR 0x02184400 -#define USBUH2_EHCI_ADDR 0x02184500 -#define USBUH3_ADDR 0x02184600 -#define USBUH3_EHCI_ADDR 0x02184700 -#define USBNC_ADDR 0x02184800 -#define USBx_SIZE 0x100 - -#define USBH1_IRQ 40 -#define USBH2_IRQ 41 -#define USBH3_IRQ 42 -#define USBOTG_IRQ 43 -#define USBPHY0_IRQ 44 -#define USBPHY1_IRQ 45 - #define GPIOx_SIZE 0x4000 #define GPIO1_ADDR 0x0209c000 #define GPIO2_ADDR 0x020a0000 @@ -112,47 +70,6 @@ #define GPIO7_IRQ16 78 #define GPIO7_IRQ32 79 -#define I2Cx_SIZE 0x4000 -#define I2C1_ADDR 0x021a0000 -#define I2C2_ADDR 0x021a4000 -#define I2C3_ADDR 0x021a8000 - -#define I2C1_IRQ 36 -#define I2C2_IRQ 37 -#define I2C3_IRQ 38 - -#define ESDHCx_SIZE 0x4000 -#define ESDHC1_ADDR 0x02190000 -#define ESDHC2_ADDR 0x02194000 -#define ESDHC3_ADDR 0x02198000 -#define ESDHC4_ADDR 0x0219c000 - -#define ESDHC1_IRQ 22 -#define ESDHC2_IRQ 23 -#define ESDHC3_IRQ 24 -#define ESDHC4_IRQ 25 - -#define ENET_ADDR 0x02188000 -#define ENET_SIZE 0x4000 - -#define ENET_IRQ0 118 -#define ENET_IRQ1 119 - -#define SATA_ADDR 0x02200000 -#define SATA_SIZE 0x4000 - -#define SATA_IRQ 39 - -#define PCIE_REG_ADDR 0x01ffc000 -#define PCIE_REG_SIZE 0x4000 -#define PCIE_MAP_ADDR 0x01000000 -#define PCIE_MAP_SIZE 0xffc000 - -#define PCIE_IRQ0 120 -#define PCIE_IRQ1 121 -#define PCIE_IRQ2 122 -#define PCIE_IRQ3 123 - struct armv7_dev imx6_devs[] = { /* @@ -171,17 +88,6 @@ struct armv7_dev imx6_devs[] = { .mem = { { IOMUXC_ADDR, IOMUXC_SIZE } }, }, - /* - * Watchdog Timer - */ - { .name = "imxdog", - .unit = 0, - .mem = { - { WD1_ADDR, WD1_SIZE }, - { WD2_ADDR, WD2_SIZE }, - }, - }, - /* * On-Chip OTP Controller */ @@ -190,35 +96,6 @@ struct armv7_dev imx6_devs[] = { .mem = { { OCOTP_ADDR, OCOTP_SIZE } }, }, - /* - * UART - */ - { .name = "imxuart", - .unit = 0, - .mem = { { UART1_ADDR, UARTx_SIZE } }, - .irq = { UART1_IRQ } - }, - { .name = "imxuart", - .unit = 1, - .mem = { { UART2_ADDR, UARTx_SIZE } }, - .irq = { UART2_IRQ } - }, - { .name = "imxuart", - .unit = 2, - .mem = { { UART3_ADDR, UARTx_SIZE } }, - .irq = { UART3_IRQ } - }, - { .name = "imxuart", - .unit = 3, - .mem = { { UART4_ADDR, UARTx_SIZE } }, - .irq = { UART4_IRQ } - }, - { .name = "imxuart", - .unit = 4, - .mem = { { UART5_ADDR, UARTx_SIZE } }, - .irq = { UART5_IRQ } - }, - /* * GPIO */ @@ -256,97 +133,6 @@ struct armv7_dev imx6_devs[] = { .unit = 6, .mem = { { GPIO7_ADDR, GPIOx_SIZE } }, }, - - /* - * I2C - */ - { .name = "imxiic", - .unit = 0, - .mem = { { I2C1_ADDR, I2Cx_SIZE } }, - .irq = { I2C1_IRQ }, - }, - - { .name = "imxiic", - .unit = 1, - .mem = { { I2C2_ADDR, I2Cx_SIZE } }, - .irq = { I2C2_IRQ }, - }, - - { .name = "imxiic", - .unit = 2, - .mem = { { I2C3_ADDR, I2Cx_SIZE } }, - .irq = { I2C3_IRQ }, - }, - - /* - * ESDHC - */ - { .name = "imxesdhc", - .unit = 0, - .mem = { { ESDHC1_ADDR, ESDHCx_SIZE } }, - .irq = { ESDHC1_IRQ }, - }, - - { .name = "imxesdhc", - .unit = 1, - .mem = { { ESDHC2_ADDR, ESDHCx_SIZE } }, - .irq = { ESDHC2_IRQ }, - }, - - { .name = "imxesdhc", - .unit = 2, - .mem = { { ESDHC3_ADDR, ESDHCx_SIZE } }, - .irq = { ESDHC3_IRQ }, - }, - - { .name = "imxesdhc", - .unit = 3, - .mem = { { ESDHC4_ADDR, ESDHCx_SIZE } }, - .irq = { ESDHC4_IRQ }, - }, - - /* - * USB - */ - { .name = "ehci", - .unit = 0, - .mem = { - { USBUH1_EHCI_ADDR, USBx_SIZE }, - { USBUH1_ADDR, USBx_SIZE }, - { USBPHY2_ADDR, USBPHYx_SIZE }, - { USBNC_ADDR, USBx_SIZE }, - }, - .irq = { USBH1_IRQ } - }, - - { .name = "ehci", - .unit = 1, - .mem = { - { USBOTG_EHCI_ADDR, USBx_SIZE }, - { USBOTG_ADDR, USBx_SIZE }, - { USBPHY1_ADDR, USBPHYx_SIZE }, - { USBNC_ADDR, USBx_SIZE }, - }, - .irq = { USBOTG_IRQ } - }, - - /* - * Ethernet - */ - { .name = "fec", - .unit = 0, - .mem = { { ENET_ADDR, ENET_SIZE } }, - .irq = { ENET_IRQ0, ENET_IRQ1 } - }, - - /* - * AHCI compatible SATA controller - */ - { .name = "ahci", - .unit = 0, - .mem = { { SATA_ADDR, SATA_SIZE } }, - .irq = { SATA_IRQ } - }, }; void