aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/ether.c
AgeCommit message (Collapse)AuthorFilesLines
2024-07-22drivers: usb: Remove duplicate newlinesMarek Vasut1-4/+0
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-07-05usb: gadget: Drop all gadget_is_*() functionsMarek Vasut1-5/+3
The only actually used gadget_is_*() functions are the one for DWC3 used in epautoconf.c usb_ep_autoconfig() and one for MUSB in ether.c. The DWC3 one should be fixed in some separate patch. Inline the gadget_is_dwc3() and stop using ifdefs in favor of IS_ENABLED() macro. The rest of gadget_is_*() calls in usb_ep_autoconfig() can never be anything but 0, since those gadgets are not supported in U-Boot, so remove all that unused code. Remove gadget_chips.h as well. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3 Link: https://lore.kernel.org/r/20240609213449.194762-4-marek.vasut+renesas@mailbox.org Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-07-05usb: gadget: ether: Drop usb_gadget_controller_number()Marek Vasut1-14/+3
The bcdDevice field is defined as |Device release number in binary-coded decimal in the USB 2.0 specification. We use this field to distinguish the UDCs from each other. In theory this could be used on the host side to apply certain quirks if the "special" UDC in combination with this gadget is used. This hasn't been done as far as I am aware. In practice it would be better to fix the UDC driver before shipping since a later release might not need this quirk anymore. This patch converts this gadget to use the U-Boot version instead of a random 2 or 3 plus the UDC number. Linux stopped using this functionality in 2012, remove it from U-Boot as well. Matching Linux kernel commit: ed9cbda63d45 ("usb: gadget: remove usb_gadget_controller_number()") Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3 Link: https://lore.kernel.org/r/20240609213449.194762-2-marek.vasut+renesas@mailbox.org Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"WIP/20May2024-nextTom Rini1-1/+0
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini1-0/+1
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-07usb: Remove <common.h> and add needed includesTom Rini1-1/+0
Remove <common.h> from this driver directory and when needed add missing include files directly. Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2023-09-24common: Drop linux/printk.h from common headerSimon Glass1-0/+1
This old patch was marked as deferred. Bring it back to life, to continue towards the removal of common.h Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-09-15usb: gadget: ether: Use plain udevice for UDC controller interactionMarek Vasut1-9/+11
Convert to plain udevice interaction with UDC controller device, avoid the use of UDC uclass dev_array . Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-08-05usb: gadget: ether: Handle gadget driver registration in probe and removeMarek Vasut1-45/+52
Move the ethernet gadget driver registration and removal from ethernet bind and unbind callbacks into driver DM probe and remove callbacks. This way, when the driver is bound, which is triggered deliberately using 'bind' command, the USB ethernet gadget driver is instantiated and bound to the matching UDC. In reverse, when the driver is unbound, which is again triggered deliberately using 'unbind' command, the USB ethernet gadget driver instance is removed. Effectively, this now behaves like running either 'ums' or 'dfu' or any other commands utilizing USB gadget functionality. This also drops use of usb_gadget_release() and moves the use of usb_gadget_initialize() into usb_ether_init() used only by legacy platforms that do not use 'bind' command properly yet. Those have no place in drivers. Signed-off-by: Marek Vasut <marex@denx.de> Tested-by: Tom Rini <trini@konsulko.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-05usb: gadget: ether: Move probe function above driver structureMarek Vasut1-14/+14
Move the driver probe function above the driver structure, so it can be placed alongside other related functions, like upcoming remove function. No functional change. Signed-off-by: Marek Vasut <marex@denx.de> Tested-by: Tom Rini <trini@konsulko.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-05usb: gadget: ether: Inline functions used onceMarek Vasut1-39/+9
These functions here are only ever called once since drop of non-DM networking code. Inline them. No functional change. Signed-off-by: Marek Vasut <marex@denx.de> Tested-by: Tom Rini <trini@konsulko.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2022-12-07usb: gadget: Remove non-DM_ETH codeTom Rini1-97/+0
As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
2022-10-17usb: ether: Fix error handling in usb_ether_initMichal Suchanek1-6/+5
The code checks the return value from uclass_first_device as well as that the device exists but it passes on the return value which may be zero if there are no gadget devices. Just check that a device was returned and return -ENODEV otherwise. Also remove the dev variable which is not really used for anything. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-12Fix typo in CONFIG_USBNET_DEVADDRIgnacio Zamora1-1/+1
Fix typo that was caused by the same feature being split in to 2 different configuration options. Replace CONFIG_USBNET_DEVADDR with CONFIG_USBNET_DEV_ADDR Signed-off-by: Ignacio Zamora <nachopitt@gmail.com>
2022-07-08arm: Remove strongarm supportTom Rini1-15/+0
There are no platforms using this architecture anymore, remove it. Signed-off-by: Tom Rini <trini@konsulko.com>
2022-07-07arm: Remove PXA architecture supportTom Rini1-24/+1
With the last platform for this architecture removed, remove the rest of the architecture support as well. Cc: Marek Vasut <marex@denx.de> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-08-02global: Convert simple_strtoul() with decimal to dectoul()Simon Glass1-2/+1
It is a pain to have to specify the value 10 in each call. Add a new dectoul() function and update the code to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dm: Use access methods for dev/uclass private dataSimon Glass1-4/+12
Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
2020-12-13dm: treewide: Rename dev_get_platdata() to dev_get_plat()Simon Glass1-2/+2
Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass1-1/+1
We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass1-2/+2
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-14linux/compat.h: Add wait_event_timeout macroOleksandr Andrushchenko1-1/+0
Add wait_event_timeout - sleep until a condition gets true or a timeout elapses. This is a stripped version of the same from Linux kernel with the following u-boot specific modifications: - no wait queues supported - use u-boot timer to detect timeouts - check for Ctrl-C pressed during wait Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> [trini: Drop atomic_read from gadget/ether.c as this has existed for a while and now causes problems] Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-17treewide: convert bd_t to struct bd_info by coccinelleMasahiro Yamada1-2/+2
The Linux coding style guide (Documentation/process/coding-style.rst) clearly says: It's a **mistake** to use typedef for structures and pointers. Besides, using typedef for structures is annoying when you try to make headers self-contained. Let's say you have the following function declaration in a header: void foo(bd_t *bd); This is not self-contained since bd_t is not defined. To tell the compiler what 'bd_t' is, you need to include <asm/u-boot.h> #include <asm/u-boot.h> void foo(bd_t *bd); Then, the include direcective pulls in more bloat needlessly. If you use 'struct bd_info' instead, it is enough to put a forward declaration as follows: struct bd_info; void foo(struct bd_info *bd); Right, typedef'ing bd_t is a mistake. I used coccinelle to generate this commit. The semantic patch that makes this change is as follows: <smpl> @@ typedef bd_t; @@ -bd_t +struct bd_info </smpl> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2020-05-18common: Drop log.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop part.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-28usb: ether: avoid NULL check before free()Heinrich Schuchardt1-2/+1
free() checks if its argument is NULL. Do not duplicate this check. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-11env: Drop environment.h header file where not neededSimon Glass1-1/+0
This header file is now only used by files that access internal environment features. Drop it from various places where it is not needed. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-11env: Move env_set() to env.hSimon Glass1-0/+1
Move env_set() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-02-01usb: ether: call _usb_eth_halt() if initialization failsJean-Jacques Hiblot1-1/+4
If the host does not respond in time, the initialization fails. However the usb ether driver will still be registered. This will make usb_gadget_probe_driver() fail the next time the initialization is attempted because it cannot find an available UDC. Fixing this by calling _usb_eth_halt() when the init fails. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Acked-by: Lukasz Majewski <lukma@denx.de>
2019-01-24net: remove CONFIG_MCAST_TFTPChris Packham1-3/+0
No mainline board enables CONFIG_MCAST_TFTP and there have been compilation issues with the code for some time. Additionally, it has a potential buffer underrun issue (reported as a side note in CVE-2018-18439). Remove the multicast TFTP code but keep the driver API for the future addition of IPv6. Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Signed-off-by: Chris Packham <judge.packham@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2018-12-07dm: usb: create a new UCLASS ID for USB gadget devicesJean-Jacques Hiblot1-1/+1
UCLASS_USB_DEV_GENERIC was meant for USB devices connected to host controllers, not gadget devices. Adding a new UCLASS for gadget devices alone. Also move the generic DM code for USB gadgets in a separate file for clarity. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-12-07usb: gadget: Do not call board_usb_xxx() directly in USB gadget driversJean-Jacques Hiblot1-33/+5
Add 2 functions to wrap the calls to board_usb_init() and board_usb_cleanup(). This is a preparatory work for DM support for UDC drivers (DM_USB_GADGET). Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2018-11-26usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/Sven Schwermer1-4/+4
This allows to disable the USB driver model in SPL because it checks the CONFIG_SPL_DM_USB variable for SPL builds. Nothing changes for regular non-SPL builds. Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
2018-10-10net.h: Include linux/if_ether.h to avoid duplicationBin Meng1-7/+2
There are plenty of existing drivers that have macros like ETH_ALEN defined in their own source files. Now that we imported the kernel's if_ether.h to U-Boot we can reduce some duplication. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-08net: Move enetaddr env access code to env config instead of net configAlex Kiernan1-0/+1
In order that we can use eth_env_* even when CONFIG_NET isn't set, move these functions to environment code from net code. This fixes failures such as: board/ti/am335x/built-in.o: In function `board_late_init': board/ti/am335x/board.c:752: undefined reference to `eth_env_set_enetaddr' u-boot/board/ti/am335x/board.c:766: undefined reference to `eth_env_set_enetaddr' which caters for use cases such as: commit f411b5cca48f ("board: am335x: Always set eth/eth1addr environment variable") when Ethernet is required in Linux, but not U-Boot. Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
2017-10-05Merge git://git.denx.de/u-boot-sunxiTom Rini1-8/+8
2017-10-04treewide: replace with error() with pr_err()Masahiro Yamada1-21/+21
U-Boot widely uses error() as a bit noisier variant of printf(). This macro causes name conflict with the following line in include/linux/compiler-gcc.h: # define __compiletime_error(message) __attribute__((error(message))) This prevents us from using __compiletime_error(), and makes it difficult to fully sync BUILD_BUG macros with Linux. (Notice Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().) Let's convert error() into now treewide-available pr_err(). Done with the help of Coccinelle, excluing tools/ directory. The semantic patch I used is as follows: // <smpl> @@@@ -error +pr_err (...) // </smpl> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Re-run Coccinelle] Signed-off-by: Tom Rini <trini@konsulko.com>
2017-10-03usb: gadget: usb_ether: Move settings to commonMaxime Ripard1-8/+8
The usb_ether gadget duplicates the USB settings for the manufacturer, product ID and vendor ID. Make sure we use the common option so that we can expect a single VID/PID couple for a single device. Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lukasz Majewski <lukma@denx.de> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-08-16env: Rename getenv/_f() to env_get()Simon Glass1-6/+6
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename eth_setenv_enetaddr() to eth_env_set_enetaddr()Simon Glass1-1/+1
Rename this function for consistency with env_set(). Signed-off-by: Simon Glass <sjg@chromium.org>
2017-01-17drivers: usb: gadget: ether: Fix compiler warningLokesh Vutla1-0/+2
Latest gcc 6.2 compiler is throwing the below warning for am335x_baltos_defconfig drivers/usb/gadget/ether.c:501:17: warning: 'mdlm_detail_desc' defined but not used [-Wunused-const-variable=] static const u8 mdlm_detail_desc[] = { Guard mdlm_detail_desc with CONFIG_USB_ETH_SUBSET to avoid the warning Reported-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
2017-01-09drivers: usb: gadget: ether/rndis: convert driver to adopt device driver modelMugunthan V N1-9/+144
Adopt usb ether gadget and rndis driver to adopt driver model Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
2016-12-04usb: gadget: remove unused shortname variableAndre Przywara1-1/+0
The shortname variable isn't referenced anywhere in the code, so just remove it. Pointed out by a GCC 6.2 default warning option. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Marek Vasut <marex@denx.de> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
2016-12-02drivers: usb: gadget: ether: prepare driver for driver model migrationMugunthan V N1-21/+52
prepare driver for driver model migration Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2016-12-02drivers: usb: gadget: ether: use net device priv to pass usb ether privMugunthan V N1-25/+21
Use net device priv to pass usb ether priv and use it in net device ops callback. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2016-12-02drivers: usb: gadget: ether: consolidate global devices to single structMugunthan V N1-27/+26
Consolidate the net device, usb eth device and gadget device struct to single struct and a single global variable so that the same can be passed as priv of ethernet driver. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2016-12-02drivers: usb: gadget: ether: adopt to usb driver modelMugunthan V N1-0/+36
Convert usb ether gadget to adopt usb driver model Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2016-12-02drivers: usb: gadget: ether: access network_started using local variableMugunthan V N1-5/+5
network_started of struct eth_dev can be accessed using local variable dev and no reason to access it with the global struct. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2016-09-23treewide: replace #include <asm/errno.h> with <linux/errno.h>Masahiro Yamada1-1/+1
Now, arch/${ARCH}/include/asm/errno.h and include/linux/errno.h have the same content. (both just wrap <asm-generic/errno.h>) Replace all include directives for <asm/errno.h> with <linux/errno.h>. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> [trini: Fixup include/clk.] Signed-off-by: Tom Rini <trini@konsulko.com>