From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 3/5] spl: dfu: adding dfu support functions for SPL-DFU
Date: Mon, 30 May 2016 14:04:15 +0200 [thread overview]
Message-ID: <20160530140415.175524ff@amdc2363> (raw)
In-Reply-To: <1464356373-8375-4-git-send-email-ravibabu@ti.com>
Hi Ravi,
> Adding support functions to run dfu commands
> with support for eMMC/MMC/SD memory device.
>
> Signed-off-by: Ravi Babu <ravibabu@ti.com>
> ---
> drivers/dfu/dfu.c | 28 ++++++++++++++++++++++++++++
> drivers/dfu/dfu_mmc.c | 28 ++++++++++++++++++++++++++++
> include/dfu.h | 8 ++++++++
> 3 files changed, 64 insertions(+)
>
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index 20dfcbb..1d4690b 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -16,6 +16,7 @@
> #include <hash.h>
> #include <linux/list.h>
> #include <linux/compiler.h>
> +#include <environment.h>
>
> static LIST_HEAD(dfu_list);
> static int dfu_alt_num;
> @@ -596,3 +597,30 @@ int dfu_write_from_mem_addr(struct dfu_entity
> *dfu, void *buf, int size)
> return ret;
> }
> +
> +int dfu_run_cmd(char *dfu_alt_info, char *dfu_cmd_str)
> +{
> + char *str_env;
> + int ret;
> +
> + /* set default environment */
> + set_default_env(0);
> + str_env = getenv(dfu_alt_info);
> + if (!str_env) {
> + error("\"dfu_alt_info\" env variable not
> defined!\n");
> + return -EINVAL;
> + }
> +
> + ret = setenv("dfu_alt_info", str_env);
> + if (ret) {
> + error("unable to set env variable
> \"dfu_alt_info\"!\n");
> + return -EINVAL;
> + }
> +
> + /* invoke dfu command */
> + ret = run_command(dfu_cmd_str, 0);
> + if (ret)
> + error("dfu: error = %d\n", ret);
> +
> + return ret;
> +}
> diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
> index faece88..28517e8 100644
> --- a/drivers/dfu/dfu_mmc.c
> +++ b/drivers/dfu/dfu_mmc.c
> @@ -15,6 +15,7 @@
> #include <ext4fs.h>
> #include <fat.h>
> #include <mmc.h>
> +#include <environment.h>
>
> static unsigned char *dfu_file_buf;
> static long dfu_file_buf_len;
> @@ -401,3 +402,30 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu,
> char *devstr, char *s)
> return 0;
> }
> +
> +int dfu_run_mmc(int usb_index, int mmc_dev, char *dfu_alt_info)
> +{
> + char cmd_buf[DFU_CMD_BUF_SIZE];
> + struct mmc *mmcdev;
> + struct mmc **mmc = &mmcdev;
> + int device = mmc_dev;
> + int ret;
> +
> + /* initialize the mmc module */
> + mmc_initialize(0);
> +
> + *mmc = find_mmc_device(device);
> + if (!*mmc) {
> + error("failed to find mmc device %d\n", device);
> + return -ENODEV;
> + }
> +
> + ret = mmc_init(*mmc);
> + if (ret) {
> + error("spl: mmc init failed with error: %d\n", ret);
> + return ret;
> + }
> +
> + sprintf(cmd_buf, "dfu %d mmc %d", usb_index, device);
> + return dfu_run_cmd(dfu_alt_info, cmd_buf);
> +}
> diff --git a/include/dfu.h b/include/dfu.h
> index f39d3f1..0bc75bc 100644
> --- a/include/dfu.h
> +++ b/include/dfu.h
> @@ -274,4 +274,12 @@ static inline int dfu_tftp_write(char
> *dfu_entity_name, unsigned int addr, #endif
>
> int dfu_add(struct usb_configuration *c);
> +/* dfu_run_umc - run dfu command with chosen mmc device interface
> + * @param usb_index - usb controller number
> + * @param mmc_dev - mmc device nubmer
> + *
> + * @return 0 on success, otherwise error code
> + */
> +int dfu_run_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
> +int dfu_run_cmd(char *dfu_alt_info, char *dfu_cmd_str);
> #endif /* __DFU_ENTITY_H_ */
I would like to avoid mixing SPL and non SPL code as much as possible:
I can propose two options here:
1. In the ./drivers/dfu/ create dfu_spl.c file and put the needed
functionality there.
2. Or better, move all dfu related code to ./common/spl/spl_dfu.c
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2016-05-30 12:04 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-27 13:39 [U-Boot] [RFC PATCH 0/5] SPL: DFU Support in SPL Ravi Babu
2016-05-27 13:39 ` [U-Boot] [RFC PATCH 1/5] spl: dfu: add dfu support " Ravi Babu
2016-05-30 11:54 ` Lukasz Majewski
2016-05-30 13:43 ` B, Ravi
2016-05-30 14:59 ` Lukasz Majewski
2016-05-31 6:39 ` B, Ravi
2016-05-31 8:39 ` Lukasz Majewski
2016-05-31 9:04 ` B, Ravi
2016-05-31 9:55 ` Lukasz Majewski
2016-05-31 10:34 ` B, Ravi
2016-05-31 12:47 ` Lukasz Majewski
2016-05-31 13:31 ` B, Ravi
2016-05-31 15:13 ` Lukasz Majewski
2016-06-02 12:39 ` B, Ravi
2016-06-02 14:14 ` Lukasz Majewski
2016-06-02 14:22 ` B, Ravi
2016-06-03 9:27 ` Lukasz Majewski
2016-06-03 11:35 ` B, Ravi
2016-06-03 11:45 ` Lukasz Majewski
2016-05-27 13:39 ` [U-Boot] [RFC PATCH 2/5] spl: dfu: fs: adding ext4/fat filesystem support for SPL-DFU Ravi Babu
2016-05-30 11:59 ` Lukasz Majewski
2016-05-30 12:52 ` B, Ravi
2016-05-30 13:20 ` Lukasz Majewski
2016-05-30 13:52 ` B, Ravi
2016-05-27 13:39 ` [U-Boot] [RFC PATCH 3/5] spl: dfu: adding dfu support functions " Ravi Babu
2016-05-30 5:27 ` Heiko Schocher
2016-05-30 12:04 ` Lukasz Majewski [this message]
2016-05-30 12:49 ` B, Ravi
2016-05-27 13:39 ` [U-Boot] [RFC PATCH 4/5] dfu: spl: add generic spl-dfu function in common-spl Ravi Babu
2016-05-30 12:07 ` Lukasz Majewski
2016-05-27 13:39 ` [U-Boot] [RFC PATCH 5/5] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform Ravi Babu
2016-05-30 12:19 ` Lukasz Majewski
2016-05-27 13:42 ` [U-Boot] [RFC PATCH 0/5] SPL: DFU Support in SPL Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160530140415.175524ff@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox