diff options
Diffstat (limited to 'arch/arm/boards/udoo-neo')
-rw-r--r-- | arch/arm/boards/udoo-neo/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/boards/udoo-neo/board.c | 112 | ||||
-rw-r--r-- | arch/arm/boards/udoo-neo/flash-header-mx6sx-udoo-neo_full.imxcfg | 2 | ||||
-rw-r--r-- | arch/arm/boards/udoo-neo/lowlevel.c | 7 |
4 files changed, 115 insertions, 8 deletions
diff --git a/arch/arm/boards/udoo-neo/Makefile b/arch/arm/boards/udoo-neo/Makefile index 01c7a259e9..da63d2625f 100644 --- a/arch/arm/boards/udoo-neo/Makefile +++ b/arch/arm/boards/udoo-neo/Makefile @@ -1,2 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + obj-y += board.o lwl-y += lowlevel.o diff --git a/arch/arm/boards/udoo-neo/board.c b/arch/arm/boards/udoo-neo/board.c index 5964e92159..d9b9517fc1 100644 --- a/arch/arm/boards/udoo-neo/board.c +++ b/arch/arm/boards/udoo-neo/board.c @@ -2,16 +2,116 @@ // SPDX-FileCopyrightText: 2014 Sascha Hauer, Pengutronix #include <common.h> -#include <init.h> -#include <linux/clk.h> +#include <deep-probe.h> +#include <gpio.h> +#include <mach/imx/bbu.h> +#include <mach/imx/imx6.h> -static int imx6sx_udoneo_coredevices_init(void) +/** + * Detects the board model by checking the R184 and R185 resistors. + * A mounted resistor (0Ohm) connects the GPIO to ground, so the + * GPIO value will be 0. + * + * FULL - Eth, WiFi, motion sensors, 1GB RAM -> R184 not mounted - R185 mounted + * EXTENDED - NO Eth, WiFi, motion sensors, 1GB RAM -> R184 not mounted - R185 not mounted + * BASE - Eth, NO WiFi, NO motion sensors, 512MB RAM -> R184 mounted - R185 mounted + * BASE KS - NO Eth, WiFi, NO motion sensors, 512MB RAM -> R184 mounted - R185 not mounted + */ + +enum imx6sx_udoneo_board_type { + UDOO_NEO_BASIC = 0, + UDOO_NEO_BASIC_KS = 1, + UDOO_NEO_FULL = 2, + UDOO_NEO_EXTENDED = 3, + UDOO_NEO_UNKNOWN, +}; + +#define GPIO_R184 IMX_GPIO_NR(4, 13) +#define GPIO_R185 IMX_GPIO_NR(4, 0) + +static enum imx6sx_udoneo_board_type imx6sx_udoneo_detect(struct device *dev) { - if (!of_machine_is_compatible("fsl,imx6sx-udoo-neo")) - return 0; + struct device_node *gpio_np = NULL; + int r184, r185; + int ret; + + gpio_np = of_find_node_by_name_address(NULL, "gpio@20a8000"); + if (gpio_np) { + ret = of_device_ensure_probed(gpio_np); + if (ret) { + dev_warn(dev, "Can't probe GPIO node\n"); + goto detect_error; + } + } else { + dev_warn(dev, "Can't get GPIO node\n"); + goto detect_error; + } + + ret = gpio_request(GPIO_R184, "version r184"); + if (ret) + goto detect_error; + + ret = gpio_request(GPIO_R185, "version r185"); + if (ret) + goto detect_error; + + ret = gpio_direction_input(GPIO_R184); + if (ret) + goto detect_error; + + ret = gpio_direction_input(GPIO_R185); + if (ret) + goto detect_error; + + r184 = gpio_get_value(GPIO_R184); + r185 = gpio_get_value(GPIO_R185); + + return r184 << 1 | r185 << 0; +detect_error: + dev_warn(dev, "Board detection failed\n"); + + return UDOO_NEO_UNKNOWN; +} + +static int imx6sx_udoneo_probe(struct device *dev) +{ + enum imx6sx_udoneo_board_type type; + const char *model; + + type = imx6sx_udoneo_detect(dev); + switch (type) { + case UDOO_NEO_FULL: + model = "UDOO Neo Full"; + break; + case UDOO_NEO_EXTENDED: + model = "UDOO Neo Extended"; + break; + case UDOO_NEO_BASIC: + model = "UDOO Neo Basic"; + break; + default: + model = "UDOO Neo unknown"; + } + + barebox_set_model(model); barebox_set_hostname("mx6sx-udooneo"); + imx6_bbu_internal_mmc_register_handler("emmc", "/dev/mmc1.barebox", + BBU_HANDLER_FLAG_DEFAULT); + return 0; } -coredevice_initcall(imx6sx_udoneo_coredevices_init); + +static const struct of_device_id imx6sx_udoneo_of_match[] = { + { .compatible = "udoo,neofull" }, + { /* sentinel */ }, +}; +BAREBOX_DEEP_PROBE_ENABLE(imx6sx_udoneo_of_match); + +static struct driver imx6sx_udoneo_driver = { + .name = "board-udoo-neo", + .probe = imx6sx_udoneo_probe, + .of_compatible = imx6sx_udoneo_of_match, +}; +postcore_platform_driver(imx6sx_udoneo_driver); diff --git a/arch/arm/boards/udoo-neo/flash-header-mx6sx-udoo-neo_full.imxcfg b/arch/arm/boards/udoo-neo/flash-header-mx6sx-udoo-neo_full.imxcfg index a349b1022b..6246e17a73 100644 --- a/arch/arm/boards/udoo-neo/flash-header-mx6sx-udoo-neo_full.imxcfg +++ b/arch/arm/boards/udoo-neo/flash-header-mx6sx-udoo-neo_full.imxcfg @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + /* * These values are taken from: * repository: https://github.com/UDOOboard/uboot-imx diff --git a/arch/arm/boards/udoo-neo/lowlevel.c b/arch/arm/boards/udoo-neo/lowlevel.c index bb6b7d8332..e8712b0c72 100644 --- a/arch/arm/boards/udoo-neo/lowlevel.c +++ b/arch/arm/boards/udoo-neo/lowlevel.c @@ -1,10 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-only + #include <debug_ll.h> +#include <mach/imx/debug_ll.h> #include <common.h> #include <linux/sizes.h> -#include <mach/generic.h> +#include <mach/imx/generic.h> #include <asm/barebox-arm-head.h> #include <asm/barebox-arm.h> -#include <mach/esdctl.h> +#include <mach/imx/esdctl.h> static inline void setup_uart(void) { |