9
0
Fork 0
Commit Graph

373 Commits

Author SHA1 Message Date
Sascha Hauer e21ddc6ec0 usb: imx-us-phy: implement notify_(dis)concect
The i.MX6 USB phy does not recognize disconnects of high speed
devices when the USBPHY_CTRL_ENHOSTDISCONDETECT is not set. The
phy does not work properly though when this bit is always set, so
implement the notify_(dis)concect() callbacks to set this bit
whenever a high speed device is connected and to clear it again
when the device is disconnected.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-29 14:30:48 +02:00
Sascha Hauer a44f222e09 usb: imx-us-phy: Convert driver to generic phy support
The generic phy layer now supports USB phys, so convert
the driver over to use it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-29 14:29:16 +02:00
Sascha Hauer 4ed80f0643 usb: imx-usb-phy: Drop unnecessary read/modify/write
When writing to the USBPHY_CTRL register read/modify/write is unncessary
since we are writing to the associated bit set register anyway.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-29 13:57:37 +02:00
Sascha Hauer 7c9708a5c6 usb: ehci: forward phy given in registration data to host
Allow to pass a phy in the registration data and forward it to
the usb_host structure.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-29 13:57:14 +02:00
Sascha Hauer 0408cb01fa usb: Add usb phy to usb host
Add a struct usb_phy * member to struct usb_host. Also, call
usb_phy_notify_connect() / usb_phy_notify_disconnect() when there
are connection changes on the root hub.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-29 13:57:14 +02:00
Sascha Hauer 8ac094d346 usb: Use standard debug macro
Use standard pr_debug instead of homebrew USB_PRINTF

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-28 15:34:15 +02:00
Alexander Kurz 25be41232b ARM: i.MX drivers: enable i.MX50 where already supported
The i.MX50 SOC includes one ESDHCv3, three ESDHCv2, one cspi and
two ecspi instances which are supported by existing drivers.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-12 08:23:09 +02:00
Sascha Hauer b5952e8304 usb: i.MX chipidea: Enable VBUS regulator when needed
We should enable VBUS only in host mode, not unconditionally
during probe(). Fix that.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:52:56 +02:00
Sascha Hauer b82ae64e47 usb: chipidea i.MX: Do not return unnecessary error
We only allow to setup the host/peripheral role once, when it's already
set then we return -EBUSY.
Return 0 instead when we set the same role again and only return -EBUSY
when we actually try to change the role.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-29 17:37:41 +02:00
Sascha Hauer 4d85cb974a include: Move bulk of boot.h to bootm.h
The majority of the stuff currently in include/boot.h is about bootm
code implemented common/bootm.c. To be more consistent move it to a
new file include/bootm.h.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:31 +02:00
Lucas Stach 81a54afd22 USB: gadget: composite: avoid possible NULL ptr dereference
Check if g is valid before trying to dereference it.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:35:53 +02:00
Sascha Hauer 04f3cde151 usb: ehci: honour timeout value
usb_control_msg() and usb_bulk_msg() have a timeout parameter. Honour
this in the ehci driver instead of using a default timeout.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-06 11:15:39 +02:00
Sascha Hauer ece204a8ac usb: fastboot: Fix oem exec support
Fixes: b1374a6 usb: fastboot: drop CONFIG_COMMAND_SUPPORT dependency

The correct config option to depend on is CONFIG_COMMAND_SUPPORT,
not CONFIG_COMMAND.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 10:29:50 +02:00
Sascha Hauer 06f5a7c9ad Merge branch 'for-next/ubiformat' 2016-05-09 08:50:02 +02:00
Sascha Hauer 55aca0a48c Merge branch 'for-next/include-cleanup' 2016-05-09 08:49:42 +02:00
Sascha Hauer b1374a6d97 usb: fastboot: drop CONFIG_COMMAND_SUPPORT dependency
fastboot can run without command support. In this case we cannot
execute oem commands.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-26 09:24:53 +02:00
Sascha Hauer 8228f9e1fd usb: fastboot: Use C API for ubiformat
This makes it possible to compile the fastboot gadget without
command support. While at it bail out when ubiformat is not
compiled in.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-26 09:10:02 +02:00
Sascha Hauer cb8cf33ce8 fix erasing/protecting flashes with unspecified size
fixes: 81737c1 mtd: Fix erasing of devices >4GiB

Several places erased a complete flash partition passing ~0 as count to
erase(). With the above commit count to erase was changed from an unsigned
type to a signed type, so the (count > f->size - offset) check in
erase() no longer triggers and the ~0 count is no longer adjusted to the whole
device size. Among other things this results in saveenv failures on NOR
flashes.
This patch fixes this by introducing an explicit macro for erasing the
whole device which is tested for in erase(). All other negative values
are rejected.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Giorgio <giorgio.nicole@arcor.de>
2016-04-19 08:26:51 +02:00
Sascha Hauer 947fb5adf8 string: Fix (v)asprintf prototypes
Our asprintf and vasprintf have different prototypes than the glibc
functions. This causes trouble when we want to share barebox code
with userspace code. Change the prototypes for (v)asprintf to match
the glibc prototypes. Since the current (v)asprintf are convenient
to use change the existing functions to b(v)asprintf.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer ea5aeb986c include: move run_command prototype to command.h
run_command fits much better into command.h, move it there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer 034d4ddcb6 Merge branch 'for-next/misc' 2016-03-11 10:49:50 +01:00
Sascha Hauer 690ec1804c Merge branch 'for-next/driver' 2016-03-11 10:49:48 +01:00
Sascha Hauer 330dc0a6b7 Merge branch 'for-next/bbu' 2016-03-11 10:49:35 +01:00
Markus Pargmann 0240fd3f84 fastboot: Add a ARM Barebox filetype handler
This will automatically call barebox_update for the transfered file if
it is an ARM Barebox image and the destination file is defined by some
update handler.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-11 08:06:05 +01:00
Sascha Hauer 0ee69c9501 USB: imx-usb-phy: Fix uninitialized use of variable
ret may no be initialized in the error path when clk_get fails. Fix it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-10 10:38:52 +01:00
Aleksey Kuleshov 092479d7da ehci-hcd: preserve DTC in QH for interrupt transactions
In Linux ehci-q Data Toggle Control bit for interrupt transactions
is preserved in Queue Head (EHCI 3.6.2). So don't set 14's bit in
qh_endpt1 and don't manage toggle bit anywhere in int transactions.

This fixes an idle issue for USB keyboards, where keys
were physically changed but barebox haven't seen them in polling
until the next USB keyboard polling occurs.

Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-10 10:01:09 +01:00
Aleksey Kuleshov 9b6fd6edf1 ehci-hcd: remove useless timeout
This is just a regular iteration loop so no timeout needed

Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-10 10:00:24 +01:00
Sascha Hauer 3bd69ad077 driver: replace dev_request_mem_region with dev_request_mem_resource
dev_request_mem_region doesn't work properly one some SoCs on which
PTR_ERR() values clash with valid return values from dev_request_mem_region.
Replace them with dev_request_mem_resource where possible.

This patch has been generated with the following semantic patch:

// <smpl>
@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
-if (IS_ERR(io)) {
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores)) {
...
-	return PTR_ERR(io);
-}
+	return PTR_ERR(iores);
+}
+io = IOMEM(iores->start);
...+>
}

@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
-if (IS_ERR(io)) {
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores))
-	return PTR_ERR(io);
-}
+	return PTR_ERR(iores);
+io = IOMEM(iores->start);
...+>
}

@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
-if (IS_ERR(io)) {
-	ret = PTR_ERR(io);
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores)) {
+	ret = PTR_ERR(iores);
...
}
+io = IOMEM(iores->start);
...+>
}

@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores))
+	return PTR_ERR(iores);
+io = IOMEM(iores->start);
...+>
}

@@
identifier func;
@@
func(...) {
<+...
struct resource *iores;
-struct resource *iores;
...+>
}
// </smpl>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-07 08:57:56 +01:00
Sascha Hauer 8ee5479a28 driver: Fix return check of dev_request_mem_region
dev_request_mem_region returns an ERR_PTR, fix places which check for a
NULL pointer instead. This patch has been generated with this semantic
patch, written by me and improved by Andrey Smirnov:

// <smpl>
@@
expression e;
expression e1;
@@
e = dev_request_mem_region(...);
...
-if (!e)
-	return e1;
+if (IS_ERR(e))
+	return PTR_ERR(e);

@ rule1 @
expression e;
@@
e = dev_request_mem_region(...);

@@
expression rule1.e;
identifier ret, label;
constant errno;
@@
if (!e) {
	...
(
-	ret = -errno;
+	ret = PTR_ERR(e);
	...
	goto label;
|
-	return -errno;
+	return PTR_ERR(e);
)
}

@depends on rule1@
expression rule1.e;
@@
-	if (e == NULL)
+	if (IS_ERR(e))
{
...
}
// </smpl>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
2016-02-23 08:14:16 +01:00
Markus Pargmann 24ff0ab0fa fastboot: Fix usage of ubiformat for UBI image transfers
Currently all fastboot flash commands with UBI images are handled by a
final call to 'ubiformat'. This only makes sense for flash commands
where the target file is a mtd device. If we just want to transfer a UBI
image we would expect a simple copy to the correct location.

This patch checks if the destination file is a MTD device by opening it
and calling an ioctl MEMGETINFO. Only for MTD devices, ubiformat is
called.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-18 16:10:11 +01:00
Yegor Yefremov baa7fe1d15 Introduce include/linux/spinlock.h
Move spinlock related definitions to its original place.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-01 09:16:13 +01:00
David Jander 0295088d53 usb: chipidea-imx: check return value of regulator_get()
The VBUS regulator is optional for the chipidea-imx glue, so it must
be checked if regulator_get provided a valid regulator handle before
trying to enable the regulator.

Signed-off-by: David Jander <david@protonic.nl>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:52:02 +01:00
Uwe Kleine-König d9c2cfd534 usb: mx25: fix bit position of "Host power mask"
The bit MX25_H1_PM_BIT value is handled for port 1 as MX25_OTG_PM_BIT is
for port 0. The latter is called "OPM: OTG power mask" in the i.MX25
reference manual. Its description matches the description of "HPM: Host
power mask" for the host port which is bit 16, not 8.

The Linux kernel (as of 4.3) also has

	#define MX25_H1_PM_BIT                  BIT(16)

.

Fixes: a4076ddf65 ("USB i.MX: Add chipidea driver support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-09 07:33:34 +01:00
Sascha Hauer e65090ecc6 usb: ehci-hcd: Use regular mdelay()
The USB core will make sure we do not re-enter the ehci driver, so
we can use regular mdelay instead of mdelay_non_interruptible().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-14 15:39:26 +02:00
Sascha Hauer 8f92eb2666 Revert "usb: ehci-hcd: detect re-entrance"
Now that the USB core makes sure that we do not re-enter USB
drivers we no longer have to detect re-entrancy in the ehci driver.

This reverts commit 8426cc641d.
2015-10-14 15:38:00 +02:00
Sascha Hauer 180370774f Revert "usb: ehci-hcd: use mdelay_non_interruptible()"
Now that the USB core makes sure that we do not re-enter USB
drivers we no longer need mdelay_non_interruptible() but can use
regular mdelay() again.

This reverts commit 4cfd909412.
2015-10-14 15:35:55 +02:00
Peter Mamonov e1d67aa40f usb: core: return -EAGAIN on usb_* functions reentrance
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-14 15:35:30 +02:00
Sascha Hauer 54bf386650 Merge branch 'for-next/usb' 2015-10-07 08:23:51 +02:00
Sascha Hauer c8fa7eed66 Merge branch 'for-next/misc' 2015-10-07 08:23:45 +02:00
Antony Pavlov d0a5ea479e usb: core: drop unnecessary le16_to_cpu() conversion
In drivers/usb/core/usb.c we already have le16_to_cpus() conversion
just after usb_get_descriptor():

    390     /* correct le values */
    391     le16_to_cpus(&dev->descriptor->bcdUSB);
    392     le16_to_cpus(&dev->descriptor->idVendor);
    393     le16_to_cpus(&dev->descriptor->idProduct);
    394     le16_to_cpus(&dev->descriptor->bcdDevice);

so no additional idVendor/idProduct descriptor fields
le16_to_cpu() conversion is needed after that.

On the big-endian machines extra le16_to_cpu() conversion
leads to wrong idVendor/idProduct USB device parameters values
(e.g. see devinfo <usb-device> output), and to a much more
serious problem: idVendor/idProduct-based USB device detection
does not work.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-02 10:06:47 +02:00
Peter Mamonov 4cfd909412 usb: ehci-hcd: use mdelay_non_interruptible()
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-02 07:50:51 +02:00
Peter Mamonov 8426cc641d usb: ehci-hcd: detect re-entrance
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-02 07:50:51 +02:00
Peter Mamonov 4350744bf5 usb: ehci-hcd: port periodic transactions implementation from the u-boot
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-02 07:50:51 +02:00
Eric Bénard 39b0eb3b84 chipidea-imx: allow phymode configuration in pdata
it's currently only handled through DT and for i.MX25 OTG port (at least),
we need to configure portsc to get host mode working but it actually fails
as ci->phymode is 0 which is USBPHY_INTERFACE_MODE_UNKNOWN

Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-29 08:47:25 +02:00
Sascha Hauer 7e44c8495a introduce strerrorp
putting an error pointer into strerror can be a bit confusing since
strerror takes a positive error code but PTR_ERR returns a negative
number, so we have to do strerror(-PTR_ERR(errp)). Some places got
this wrong already, so introduce a strerrorp function which directly
takes an error pointer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-23 17:12:44 +02:00
Markus Pargmann d27cddcc3a usb: chipidea: Add udc unregister for device removal
The host may assume that the usb device is still up and running after
booting if we do not deregister the udc here. I observed issues when the
linux kernel was using a usb gadget directly where the complete USB Hub
got disconnected through this.

This patch adds a proper USB disconnect for gadget devices.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-23 10:31:33 +02:00
Antony Pavlov 4d90f44e6e usb: storage: fix warning: no previous prototype for 'usb_stor_Bulk_clear_endpt_stall'
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-14 08:29:20 +02:00
Peter Mamonov fe02d7e6c8 usb: ehci-hcd: use is_timeout_non_interruptible()
Use is_timeout_non_interruptible() intead of is_timeout()
to avoid re-entering ehci-hcd functions from pollers,
registered by usb drivers.

Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-10 09:16:42 +02:00
Peter Mamonov 790584b769 usb: ehci-hcd: add OF bindings
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-04 08:05:11 +02:00
Antony Pavlov eeab50e961 usb: ehci: fix include/usb/usb.h:'struct usb_configuration' misuse
See the commit

    commit 245069bcef
    Author: Sascha Hauer <s.hauer@pengutronix.de>
    Date:   Thu Jul 10 11:36:12 2014 +0200

        USB: introduce usb_interface/usb_configuration structs

On little endian systems like ARM the le16_to_cpus() macro
is a no op, defined as:

    #define le16_to_cpus __le16_to_cpus
    #define __le16_to_cpus(x) do {} while (0)

So struct usb_configuration field misuse was discovered
on big-endian MIPS machine.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-02 07:53:02 +02:00