diff --git a/arch/arm/boards/nvidia-beaver/board.c b/arch/arm/boards/nvidia-beaver/board.c index d270301..bab0238 100644 --- a/arch/arm/boards/nvidia-beaver/board.c +++ b/arch/arm/boards/nvidia-beaver/board.c @@ -19,6 +19,7 @@ #include #include #include +#include static int nvidia_beaver_fs_init(void) { @@ -53,6 +54,9 @@ barebox_set_hostname("beaver"); + tegra_bbu_register_emmc_handler("eMMC", "/dev/mmc3.boot0", + BBU_HANDLER_FLAG_DEFAULT); + return 0; } device_initcall(nvidia_beaver_device_init); diff --git a/arch/arm/boards/nvidia-jetson-tk1/board.c b/arch/arm/boards/nvidia-jetson-tk1/board.c index 564e6a0..939d184 100644 --- a/arch/arm/boards/nvidia-jetson-tk1/board.c +++ b/arch/arm/boards/nvidia-jetson-tk1/board.c @@ -19,6 +19,7 @@ #include #include #include +#include #define AS3722_SD_VOLTAGE(n) (0x00 + (n)) #define AS3722_GPIO_CONTROL(n) (0x08 + (n)) @@ -56,6 +57,9 @@ barebox_set_hostname("jetson-tk1"); + tegra_bbu_register_emmc_handler("eMMC", "/dev/mmc3.boot0", + BBU_HANDLER_FLAG_DEFAULT); + return 0; } device_initcall(nvidia_jetson_tk1_device_init); diff --git a/arch/arm/configs/tegra_v7_defconfig b/arch/arm/configs/tegra_v7_defconfig index 47e594b..c7b59ac 100644 --- a/arch/arm/configs/tegra_v7_defconfig +++ b/arch/arm/configs/tegra_v7_defconfig @@ -36,6 +36,7 @@ CONFIG_CMD_CLK=y CONFIG_CMD_DETECT=y CONFIG_CMD_GPIO=y +CONFIG_CMD_BAREBOX_UPDATE=y CONFIG_CMD_OFTREE=y CONFIG_NET=y CONFIG_OF_BAREBOX_DRIVERS=y diff --git a/arch/arm/dts/tegra124.dtsi b/arch/arm/dts/tegra124.dtsi index c795811..cd515a2 100644 --- a/arch/arm/dts/tegra124.dtsi +++ b/arch/arm/dts/tegra124.dtsi @@ -4,5 +4,9 @@ serial1 = "/serial@0,70006040/"; serial2 = "/serial@0,70006200/"; serial3 = "/serial@0,70006300/"; + mmc0 = "/sdhci@0,700b0000/"; + mmc1 = "/sdhci@0,700b0200/"; + mmc2 = "/sdhci@0,700b0400/"; + mmc3 = "/sdhci@0,700b0600/"; }; }; diff --git a/arch/arm/dts/tegra20-colibri.dtsi b/arch/arm/dts/tegra20-colibri.dtsi index 96da8a4..e931c07 100644 --- a/arch/arm/dts/tegra20-colibri.dtsi +++ b/arch/arm/dts/tegra20-colibri.dtsi @@ -1 +1,2 @@ #include +#include "tegra20.dtsi" diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi index ce7d322..995eee4 100644 --- a/arch/arm/dts/tegra20.dtsi +++ b/arch/arm/dts/tegra20.dtsi @@ -1 +1,8 @@ -#include +/ { + aliases { + mmc0 = "/sdhci@c8000000/"; + mmc1 = "/sdhci@c8000200/"; + mmc2 = "/sdhci@c8000400/"; + mmc3 = "/sdhci@c8000600/"; + }; +}; diff --git a/arch/arm/dts/tegra30-beaver.dts b/arch/arm/dts/tegra30-beaver.dts index 5879353..91e1354 100644 --- a/arch/arm/dts/tegra30-beaver.dts +++ b/arch/arm/dts/tegra30-beaver.dts @@ -1,6 +1,7 @@ /dts-v1/; #include +#include "tegra30.dtsi" / { model = "NVIDIA Tegra30 Beaver evaluation board"; diff --git a/arch/arm/dts/tegra30.dtsi b/arch/arm/dts/tegra30.dtsi new file mode 100644 index 0000000..90bd08b --- /dev/null +++ b/arch/arm/dts/tegra30.dtsi @@ -0,0 +1,8 @@ +/ { + aliases { + mmc0 = "/sdhci@78000000/"; + mmc1 = "/sdhci@78000200/"; + mmc2 = "/sdhci@78000400/"; + mmc3 = "/sdhci@78000600/"; + }; +}; diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index e68156a..7c4c1fd 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile @@ -13,3 +13,4 @@ obj-y += tegra20.o obj-y += tegra20-pmc.o obj-y += tegra20-timer.o +obj-$(CONFIG_BAREBOX_UPDATE) += tegra-bbu.o diff --git a/arch/arm/mach-tegra/include/mach/tegra-bbu.h b/arch/arm/mach-tegra/include/mach/tegra-bbu.h new file mode 100644 index 0000000..32e2861 --- /dev/null +++ b/arch/arm/mach-tegra/include/mach/tegra-bbu.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2015 Lucas Stach + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#ifdef CONFIG_BAREBOX_UPDATE +int tegra_bbu_register_emmc_handler(const char *name, char *devicefile, + unsigned long flags); +#else +static int tegra_bbu_register_emmc_handler(const char *name, char *devicefile, + unsigned long flags) +{ + return 0; +}; +#endif diff --git a/arch/arm/mach-tegra/tegra-bbu.c b/arch/arm/mach-tegra/tegra-bbu.c new file mode 100644 index 0000000..089e6c7 --- /dev/null +++ b/arch/arm/mach-tegra/tegra-bbu.c @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2015 Lucas Stach + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +static int tegra_bbu_emmc_handler(struct bbu_handler *handler, + struct bbu_data *data) +{ + + int fd, ret; + + if (file_detect_type(data->image + 0x4000, data->len) != + filetype_arm_barebox && + !bbu_force(data, "Not an ARM barebox image")) + return -EINVAL; + + ret = bbu_confirm(data); + if (ret) + return ret; + + fd = open(data->devicefile, O_WRONLY); + if (fd < 0) + return fd; + + ret = write(fd, data->image, data->len); + if (ret < 0) { + pr_err("writing update to %s failed with %s\n", + data->devicefile, strerror(-ret)); + goto err_close; + } + + ret = 0; + +err_close: + close(fd); + + return ret; +} + +int tegra_bbu_register_emmc_handler(const char *name, char *devicefile, + unsigned long flags) +{ + struct bbu_handler *handler; + int ret = 0; + + handler = xzalloc(sizeof(*handler)); + handler->name = name; + handler->devicefile = devicefile; + handler->flags = flags; + handler->handler = tegra_bbu_emmc_handler; + + ret = bbu_register_handler(handler); + if (ret) + free(handler); + + return ret; +} diff --git a/common/bbu.c b/common/bbu.c index e31f645..7fb154a 100644 --- a/common/bbu.c +++ b/common/bbu.c @@ -65,8 +65,10 @@ key = read_key(); - if (key == 'y') + if (key == 'y') { + printf("updating barebox...\n"); return 0; + } return -EINTR; } diff --git a/drivers/mci/tegra-sdmmc.c b/drivers/mci/tegra-sdmmc.c index 670c280..14c2304 100644 --- a/drivers/mci/tegra-sdmmc.c +++ b/drivers/mci/tegra-sdmmc.c @@ -411,7 +411,10 @@ static void tegra_sdmmc_parse_dt(struct tegra_sdmmc_host *host) { struct device_node *np = host->mci.hw_dev->device_node; + const char *alias = of_alias_get(np); + if (alias) + host->mci.devname = xstrdup(alias); host->gpio_cd = of_get_named_gpio(np, "cd-gpios", 0); host->gpio_pwr = of_get_named_gpio(np, "power-gpios", 0); mci_of_parse(&host->mci); diff --git a/drivers/of/base.c b/drivers/of/base.c index d45d394..3e40a48 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -227,11 +227,11 @@ const char *of_alias_get(struct device_node *np) { - struct property *pp; + struct alias_prop *app; - list_for_each_entry(pp, &of_aliases->properties, list) { - if (!of_node_cmp(np->full_name, pp->value)) - return pp->name; + list_for_each_entry(app, &aliases_lookup, link) { + if (np == app->np) + return app->alias; } return NULL; diff --git a/include/bbu.h b/include/bbu.h index adb52b0..4a3d35e 100644 --- a/include/bbu.h +++ b/include/bbu.h @@ -2,6 +2,8 @@ #define __INCLUDE_BBU_H #include +#include +#include struct bbu_data { #define BBU_FLAG_FORCE (1 << 0)