On 11/19/2012 10:33 AM, Peter Chen wrote: > Implement struct usb_otg, In that way, calling otg_set_peripheral > will not be failed at udc.c. > > Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx> > --- > drivers/usb/chipidea/Makefile | 2 +- > drivers/usb/chipidea/otg.c | 60 +++++++++++++++++++++++++++++++++++++++++ > drivers/usb/chipidea/otg.h | 6 ++++ > 3 files changed, 67 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile > index d92ca32..11f513c 100644 > --- a/drivers/usb/chipidea/Makefile > +++ b/drivers/usb/chipidea/Makefile > @@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG > > obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o > > -ci_hdrc-y := core.o > +ci_hdrc-y := core.o otg.o > ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o > ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o > ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o > diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c > new file mode 100644 > index 0000000..7dea3b3 > --- /dev/null > +++ b/drivers/usb/chipidea/otg.c > @@ -0,0 +1,60 @@ > +/* > + * otg.c - ChipIdea USB IP core OTG driver > + * > + * Copyright (C) 2012 Freescale Semiconductor, Inc. > + * > + * Author: Peter Chen > + * > + * 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. > + */ > + > +#include <linux/platform_device.h> > +#include <linux/module.h> > +#include <linux/io.h> > +#include <linux/irq.h> > +#include <linux/kernel.h> > +#include <linux/slab.h> > +#include <linux/usb/gadget.h> > +#include <linux/usb/otg.h> > +#include <linux/usb/chipidea.h> > + > +#include "ci.h" > +#include "udc.h" > +#include "bits.h" > +#include "host.h" > +#include "debug.h" > + > +static int ci_otg_set_peripheral(struct usb_otg *otg, > + struct usb_gadget *periph) > +{ > + otg->gadget = periph; > + > + return 0; > +} > + > +static int ci_otg_set_host(struct usb_otg *otg, struct usb_bus *host) > +{ > + otg->host = host; > + > + return 0; > +} > + > +/** > + * ci_hdrc_otg_init - initialize device related bits > + * ci: the controller > + * > + * This function create otg struct, if the device can switch between > + * device and host. > + */ > +int ci_hdrc_otg_init(struct ci13xxx *ci) > +{ > + /* Useless at current */ > + ci->otg.set_peripheral = ci_otg_set_peripheral; > + ci->otg.set_host = ci_otg_set_host; > + if (!IS_ERR_OR_NULL(ci->transceiver)) ^^^^^^^^^^^^^^ Is considered harmful by some people. Can we test against NULL here? Marc > + ci->transceiver->otg = &ci->otg; > + > + return 0; > +} > diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h > new file mode 100644 > index 0000000..b4c6b3e > --- /dev/null > +++ b/drivers/usb/chipidea/otg.h > @@ -0,0 +1,6 @@ > +#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H > +#define __DRIVERS_USB_CHIPIDEA_OTG_H > + > +int ci_hdrc_otg_init(struct ci13xxx *ci); > + > +#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */ > -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Attachment:
signature.asc
Description: OpenPGP digital signature