mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: "Eric Bénard" <eric@eukrea.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 3/4] serial gadget: enable/disable on request
Date: Wed, 4 Jan 2012 09:00:43 +0100	[thread overview]
Message-ID: <20120104080043.GL945@game.jcrosoft.org> (raw)
In-Reply-To: <1325623931-28780-1-git-send-email-eric@eukrea.com>

On 21:52 Tue 03 Jan     , Eric Bénard wrote:
> - add a usbserial command to enable/disable the serial gadget
> - allow dfu and usbserial to cohexist in the same barebox
> - add a timeout in u_serial so that we don't get locked if the user
> enable usbserial from a UART console but doesn't consume the data
> on the usbserial port created on the PC
> - remove debug or verbose printf
> - tested on i.MX25 & i.MX35
> 
> Signed-off-by: Eric Bénard <eric@eukrea.com>
> ---
> v2 : always recompile after fixing checkpatch notes ...
> 
>  commands/Makefile             |    1 +
>  commands/usbserial.c          |  102 +++++++++++++++++++++++++++++++++++++++++
>  drivers/usb/gadget/Kconfig    |    5 +--
>  drivers/usb/gadget/f_acm.c    |    4 +-
>  drivers/usb/gadget/serial.c   |   40 +++++++++++++---
>  drivers/usb/gadget/u_serial.c |   22 ++++++---
>  6 files changed, 152 insertions(+), 22 deletions(-)
>  create mode 100644 commands/usbserial.c
> 
> diff --git a/commands/Makefile b/commands/Makefile
> index 24753be..43630e1 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -47,6 +47,7 @@ obj-$(CONFIG_CMD_LSMOD)		+= lsmod.o
>  obj-$(CONFIG_CMD_INSMOD)	+= insmod.o
>  obj-$(CONFIG_CMD_BMP)		+= bmp.o
>  obj-$(CONFIG_USB_GADGET_DFU)	+= dfu.o
> +obj-$(CONFIG_USB_GADGET_SERIAL)	+= usbserial.o
>  obj-$(CONFIG_CMD_GPIO)		+= gpio.o
>  obj-$(CONFIG_CMD_UNCOMPRESS)	+= uncompress.o
>  obj-$(CONFIG_CMD_I2C)		+= i2c.o
> diff --git a/commands/usbserial.c b/commands/usbserial.c
> new file mode 100644
> index 0000000..7dfc102
> --- /dev/null
> +++ b/commands/usbserial.c
> @@ -0,0 +1,102 @@
> +/*
> + * dfu.c - device firmware update command
please fix
> + *
> + * Copyright (c) 2009 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * 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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +#include <common.h>
> +#include <command.h>
> +#include <errno.h>
> +#include <malloc.h>
> +#include <getopt.h>
> +#include <fs.h>
> +#include <xfuncs.h>
> +#include <usb/usbserial.h>
> +
> +static int do_usbserial(struct command *cmdtp, int argc, char *argv[])
> +{
> +	int opt;
> +	struct usb_serial_pdata pdata;
> +	char *argstr;
> +	char *manufacturer = "barebox";
> +	char *productname = CONFIG_BOARDINFO;
> +	u16 idVendor = 0, idProduct = 0;
> +	int mode = 0;
> +
> +	while ((opt = getopt(argc, argv, "m:p:V:P:asd")) > 0) {
> +		switch (opt) {
> +		case 'm':
> +			manufacturer = optarg;
> +			break;
> +		case 'p':
> +			productname = optarg;
> +			break;
> +		case 'V':
> +			idVendor = simple_strtoul(optarg, NULL, 0);
> +			break;
> +		case 'P':
> +			idProduct = simple_strtoul(optarg, NULL, 0);
> +			break;
> +		case 'a':
> +			mode = 0;
> +			break;
> +/*		case 'o':
> +			mode = 1;
> +			break;*/
ditto
> +		case 's':
> +			mode = 2;
> +			break;
> +		case 'd':
> +			usb_serial_unregister();
> +			return 0;
> +		}
> +	}
> +
> +	argstr = argv[optind];
> +
> +	pdata.manufacturer = manufacturer;
> +	pdata.productname = productname;
> +	pdata.idVendor = idVendor;
> +	pdata.idProduct = idProduct;
> +	pdata.mode = mode;
> +
> +	return usb_serial_register(&pdata);
> +}
> +
> +BAREBOX_CMD_HELP_START(usbserial)
> +BAREBOX_CMD_HELP_USAGE("usbserial [OPTIONS] <description>\n")
> +BAREBOX_CMD_HELP_SHORT("Enable/disable a serial gadget on the USB device interface.\n")
> +BAREBOX_CMD_HELP_OPT  ("-m <str>",  "Manufacturer string (barebox)\n")
> +BAREBOX_CMD_HELP_OPT  ("-p <str>",  "product string (" CONFIG_BOARDINFO ")\n")
> +BAREBOX_CMD_HELP_OPT  ("-V <id>",   "vendor id\n")
> +BAREBOX_CMD_HELP_OPT  ("-P <id>",   "product id\n")
> +BAREBOX_CMD_HELP_OPT  ("-a",   "CDC ACM (default)\n")
> +/*BAREBOX_CMD_HELP_OPT  ("-o",   "CDC OBEX\n")*/
ditto
> +BAREBOX_CMD_HELP_OPT  ("-s",   "Generic Serial\n")
> +BAREBOX_CMD_HELP_OPT  ("-d",   "Disable the serial gadget\n")
> +BAREBOX_CMD_HELP_END
> +
> +/**
> + * @page usbserial_command
> + */
> +
> +BAREBOX_CMD_START(usbserial)
> +	.cmd		= do_usbserial,
> +	.usage		= "Serial gadget enable/disable",
> +	BAREBOX_CMD_HELP(cmd_usbserial_help)
> +BAREBOX_CMD_END
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index fd471c0..797d19f 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -30,8 +30,7 @@ config USB_GADGET_DRIVER_PXA27X
>  	select POLLER
>  endchoice
>  
> -choice
> -	prompt "USB Gadget drivers"
> +comment "USB Gadget drivers"
>  
>  config USB_GADGET_DFU
>  	bool
> @@ -42,7 +41,5 @@ config USB_GADGET_SERIAL
>  	depends on EXPERIMENTAL
>  	prompt "Serial Gadget"
>  
> -endchoice
> -
>  endif
Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-01-04  8:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-03 16:59 [PATCH 1/4] fsl_udc: update and fix Eric Bénard
2012-01-03 16:59 ` [PATCH 2/4] dfu: fill bwPollTimeout and better handle detach Eric Bénard
2012-01-04  9:05   ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-03 16:59 ` [PATCH 3/4] serial gadget: enable/disable on request Eric Bénard
2012-01-03 20:52   ` [PATCH v2 " Eric Bénard
2012-01-04  8:00     ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-01-04  8:11       ` Eric Bénard
2012-01-04  8:57         ` Sascha Hauer
2012-01-04  8:17     ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04  8:31       ` [PATCH v3 " Eric Bénard
2012-01-04  9:03         ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-03 16:59 ` [PATCH 4/4] eukrea_cpuimx35: fix compilation when CONFIG_USB_GADGET is enabled Eric Bénard
2012-01-04  9:03 ` [PATCH 1/4] fsl_udc: update and fix Sascha Hauer
2012-01-04  9:19   ` Eric Bénard

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=20120104080043.GL945@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=eric@eukrea.com \
    /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