diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-09 08:30:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-09 08:30:24 +0100 |
commit | 22e42ca3fc591ddb342e43f86cf2931870bea042 (patch) | |
tree | 076200b389bc4a6dd75fc0286fd6a61e4a336ada /arch/arm/mach-samsung | |
parent | 1629b5835a9ce19ec43381afd788da8c53ba652c (diff) | |
parent | 0bdc1c5d114bb189677aa9b0f57d0e2fd24a8e6e (diff) | |
download | barebox-22e42ca3fc591ddb342e43f86cf2931870bea042.tar.gz barebox-22e42ca3fc591ddb342e43f86cf2931870bea042.tar.xz |
Merge branch 'for-next/arm'
Diffstat (limited to 'arch/arm/mach-samsung')
-rw-r--r-- | arch/arm/mach-samsung/Kconfig | 6 | ||||
-rw-r--r-- | arch/arm/mach-samsung/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-samsung/bbu-nand-s3c24x0.c | 85 | ||||
-rw-r--r-- | arch/arm/mach-samsung/include/mach/bbu.h | 16 |
4 files changed, 108 insertions, 0 deletions
diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig index 13dac29dcc..8f421bb839 100644 --- a/arch/arm/mach-samsung/Kconfig +++ b/arch/arm/mach-samsung/Kconfig @@ -166,6 +166,12 @@ config S3C_NAND_BOOT Add generic support to boot from NAND flash. Image loading will be skipped if the code is running from NOR or already from SDRAM. +config BAREBOX_UPDATE_NAND_S3C24XX + bool + depends on BAREBOX_UPDATE + depends on S3C_NAND_BOOT + default y + endmenu endif diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile index 46393e1725..284c80a2ad 100644 --- a/arch/arm/mach-samsung/Makefile +++ b/arch/arm/mach-samsung/Makefile @@ -8,4 +8,5 @@ obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o clocks-s3c24xx.o mem-s3c24x0.o obj-$(CONFIG_ARCH_S3C64xx) += gpio-s3c64xx.o clocks-s3c64xx.o mem-s3c64xx.o obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o mem-s5pcxx.o pbl-$(CONFIG_ARCH_S5PCxx) += mem-s5pcxx.o +obj-$(CONFIG_BAREBOX_UPDATE_NAND_S3C24XX) += bbu-nand-s3c24x0.o obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y) diff --git a/arch/arm/mach-samsung/bbu-nand-s3c24x0.c b/arch/arm/mach-samsung/bbu-nand-s3c24x0.c new file mode 100644 index 0000000000..0d25abfeb7 --- /dev/null +++ b/arch/arm/mach-samsung/bbu-nand-s3c24x0.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2014 Michael Olbrich, Pengutronix + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that 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, write to the Free Software + * Foundation. + * + */ + +#include <common.h> +#include <malloc.h> +#include <bbu.h> +#include <fs.h> +#include <fcntl.h> + +static int nand_update(struct bbu_handler *handler, struct bbu_data *data) +{ + int fd, ret; + + if (file_detect_type(data->image, 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; + + debug("%s: eraseing %s from 0 to 0x%08x\n", __func__, + data->devicefile, data->len); + ret = erase(fd, data->len, 0); + if (ret) { + printf("erasing %s failed with %s\n", data->devicefile, + strerror(-ret)); + goto err_close; + } + + ret = write(fd, data->image, data->len); + if (ret < 0) { + printf("writing update to %s failed with %s\n", data->devicefile, + strerror(-ret)); + goto err_close; + } + + ret = 0; + +err_close: + close(fd); + + return ret; +} + +/* + * Register a s3c24x0 update handler for NAND + */ +int s3c24x0_bbu_nand_register_handler(void) +{ + struct bbu_handler *handler; + int ret; + + handler = xzalloc(sizeof(*handler)); + handler->devicefile = "/dev/nand0.barebox"; + handler->name = "nand"; + handler->handler = nand_update; + handler->flags = BBU_HANDLER_FLAG_DEFAULT; + + ret = bbu_register_handler(handler); + if (ret) + free(handler); + + return ret; +} diff --git a/arch/arm/mach-samsung/include/mach/bbu.h b/arch/arm/mach-samsung/include/mach/bbu.h new file mode 100644 index 0000000000..7ce7052bcf --- /dev/null +++ b/arch/arm/mach-samsung/include/mach/bbu.h @@ -0,0 +1,16 @@ +#ifndef __MACH_BBU_H +#define __MACH_BBU_H + +#include <bbu.h> +#include <errno.h> + +#ifdef CONFIG_BAREBOX_UPDATE_NAND_S3C24XX +int s3c24x0_bbu_nand_register_handler(void); +#else +static inline int s3c24x0_bbu_nand_register_handler(void) +{ + return -ENOSYS; +} +#endif + +#endif |