summaryrefslogtreecommitdiff
path: root/common/usb_kbd.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: s/CONFIG_DM_USB/CONFIG_IS_ENABLED(DM_USB)/Sven Schwermer2018-11-261-2/+2
| | | | | | | | 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>
* usb_kdb: Get stdio_dev directly from sdev pointerMichal Simek2018-07-191-2/+2
| | | | | | | Driver supports only one instance of usb keyboard. Remove the first dependency on generic usbkbd DEVNAME. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
* usb_kbd: Add support for watchdogMichal Simek2018-07-191-1/+4
| | | | | | | There is need to service watchdog in while loop or system will be restarted when idlying. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-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>
* env: Rename getenv/_f() to env_get()Simon Glass2017-08-161-3/+3
| | | | | | | | | | | 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>
* console: Don't enable CONFIG-CONSOLE_MUX, etc. in SPLSimon Glass2017-02-061-3/+3
| | | | | | | | | CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV are not applicable for SPL. Update the console code to use CONFIG_IS_ENABLED(), so that these options will be inactive in SPL. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* Convert CONFIG_SYS_STDIO_DEREGISTER to KconfigSimon Glass2016-10-231-1/+1
| | | | | | | | | | | | This converts the following to Kconfig: CONFIG_SYS_STDIO_DEREGISTER This option should never be enabled in SPL, so use CONFIG_IS_ENABLED(SYS_STDIO_DEREGISTER) when checking the option. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Re-sync] Signed-off-by: Tom Rini <trini@konsulko.com>
* usb: squash lines for immediate returnMasahiro Yamada2016-09-231-4/+1
| | | | | | This makes functions much simpler. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* usb: kbd: Do not deregister usbkbd twice when using dmHans de Goede2016-04-101-1/+2
| | | | | | | | | | | | | | The dm usb_kbd_remove function() will deregister the usb keyboard for us on a "usb reset" / "usb stop" so there is no need to manually call usb_kbd_deregister() in the dm case. This commit removes usb_kbd_deregister() in the dm case fixing the following "usb reset" errors: usb_kbd_remove: warning, ret=-6 device_remove: Device 'usb_kbd' failed to remove, but children are gone Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Prevent out of bound accessMarek Vasut2016-01-251-1/+1
| | | | | | | | Scan code 0x39 is CapsLock, which is not a printable character and thus is not covered by either usb_kbd_numkey_shifted[] or usb_kbd_numkey[]. Fix the scan code check to avoid looking it up in either of the arrays. Signed-off-by: Marek Vasut <marex@denx.de>
* dm: usb: Add a remove() method for USB keyboardsSimon Glass2016-01-071-0/+36
| | | | | | | | At present USB keyboards are not properly removed with driver model. Add the code to handle this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* usb: kbd: don't use int xfers when polling via ctrl xfersStephen Warren2015-12-171-0/+3
| | | | | | | | | | | | When CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP is enabled, use a GET_REPORT control transfer to retrieve the initial state of the keyboard. This matches the technique used to poll the keyboard state. This is useful since it eliminates the remaining use of interrupt transfers from the USB keyboard driver, which allows it to work with USB HCD that don't support interrupt transfers. Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
* usb: Avoid open-coded USB constants in usb_kbd.cSimon Glass2015-11-191-5/+5
| | | | | | | Replace the open-coded values with constants to make it clearer what they mean. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: Drop unused code in usb_kbd.cSimon Glass2015-11-191-30/+0
| | | | | | This was missed in the conversion to driver model. Signed-off-by: Simon Glass <sjg@chromium.org>
* Move console definitions into a new console.h fileSimon Glass2015-11-191-0/+1
| | | | | | | | The console includes a global variable and several functions that are only used by a small subset of U-Boot files. Before adding more functions, move the definitions into their own header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: input: Create a keyboard uclassSimon Glass2015-11-191-6/+0
| | | | | | | | | Add a uclass for keyboard input, mirroring the existing stdio methods. This is enabled by a new CONFIG_DM_KEYBOARD option. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* dm: usb: Add support for USB keyboards with driver modelSimon Glass2015-11-191-2/+50
| | | | | | | | Switch USB keyboards over to use driver model instead of scanning with the horrible usb_get_dev_index() function. This involves creating a new uclass for keyboards, although so far there is no API. Signed-off-by: Simon Glass <sjg@chromium.org>
* video: Drop DEV_FLAGS_SYSTEM flagBin Meng2015-11-051-1/+1
| | | | | | DEV_FLAGS_SYSTEM does not have any actual meaning, hence drop it. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
* Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass2015-09-111-0/+1
| | | | | | | Now that we have a new header file for cache-aligned allocation, we should move the stack-based allocation macro there also. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: usb: Adjust the USB_DEVICE() macro namingSimon Glass2015-07-211-2/+2
| | | | | | | | | In Linux USB_DEVICE() is used to declare a USB device by vendor/device ID. We should follow the same convention in U-Boot. Rename the existing USB_DEVICE() macro to U_BOOT_USB_DEVICE() and bring in the USB_DEVICE() macro from Linux for use in U-Boot. Signed-off-by: Simon Glass <sjg@chromium.org>
* usb: kbd: Disable idle input reports when we do not need themHans de Goede2015-06-191-1/+3
| | | | | | | | When we're polling and thus handling key-repeat in software, make sure to disable idle reports, some keyboards may have these enabled by default messing up our software keyrepeat. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Fix key repeat not always workingHans de Goede2015-05-291-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | The usb-kbd key repeat code assumes that reports get repeated every 40 ms, this is never true when using CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP, and does not always works for CONFIG_SYS_USB_EVENT_POLL and CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE since not all usb keyboards honor the usb_set_idle() command. For CONFIG_SYS_USB_EVENT_POLL we must use usb_set_idle() since we do a blocking wait for the hid report, so if we do not tell the keyboard to send a hid report every 40ms even if nothing changes then we will block u-boot for 1s (the default u-boot usb interrupt packet timeout). Note that in this case on keyboards which do not support usb_set_idle() we loose and we actually get 1s latencies on other u-boot activities. For the other poll-methods this commit stops using usb_set_idle() and instead repeats the last received hid-report every 40 ms as long as no new hid-report is received. This fixes key-repeat not working at all with CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP and fixes it not working with keyboards which do not implement usb_set_idle() when using CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* dm: usb: Support driver model with USB keyboardsSimon Glass2015-04-181-1/+33
| | | | | | | | | Allow USB keyboards to work with driver model. The main difference is that we can have multiple buses (each with its own device numbering) and each bus must be scanned. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* dm: usb: Split out the keyboard probe into its own functionSimon Glass2015-04-181-38/+51
| | | | | | | | Before adding driver model support, split out code from this over-long function. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
* usb: Fix usb_kbd_deregister when console-muxing is usedHans de Goede2015-01-181-0/+4
| | | | | | | | | | | | | When iomuxing is used we must not only deregister the device with stdio.c, but also remove the reference to the device in the console_devices array used by console-muxing. Add a call to iomux_doenv to usb_kbd_deregister to update console_devices, which will drop the reference. This fixes the console filling with "Failed to enqueue URB to controller" messages after a "usb stop force", or when the USB keyboard is gone after a "usb reset". Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: Add an interval parameter to create_int_queueHans de Goede2015-01-181-2/+4
| | | | | | | | Currently create_int_queue is only implemented by the ehci code, and that does not honor interrupt intervals, but other drivers which might also want to implement create_int_queue may honor intervals, so add an interval param. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Add (optional) support for using an interrupt queue for pollingHans de Goede2014-11-041-0/+19
| | | | | | | | | | | | | | | Waiting an interrupt packet to complete in usb_kbd_poll_for_event, causes a 40 ms latency for each call to usb_kbd_testc, which is undesirable. Using control messages leads to lower (but still not 0) latency, but some devices do not work well with control messages (e.g. my kvm behaves funny with them). This commit adds support for using the int_queue mechanism which at least the ehci-hcd driver supports. This allows polling with 0 latency, while using interrupt packets. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Cache pipe, interval and packetsizeHans de Goede2014-11-041-21/+13
| | | | | | Instead of looking them up every time we need them. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Fix memleak on usb_kbd_deregister()Hans de Goede2014-11-041-3/+13
| | | | | | Free the keyboard hid-report buffer and private data on deregister. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Remove unused usb_kbd_generic_poll functionHans de Goede2014-11-041-26/+0
| | | | | | This is not used anywhere, so lets remove it. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Allow "usb reset" to continue when an usb kbd is usedHans de Goede2014-10-061-2/+2
| | | | | | | | Use the new force parameter to make the stdio_deregister succeed, replacing stdin with a nulldev, and assume that the usb keyboard will come back after the reset. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* stdio: Add force parameter to stdio_deregisterHans de Goede2014-10-061-1/+1
| | | | | | | In some cases we really want to move forward with a deregister, add a force parameter to allow this, and replace the dev with a nulldev in this case. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Remove check for already being registeredHans de Goede2014-10-061-11/+1
| | | | | | | We now always properly deregister the keyboard before calling drv_usb_kbd_init(), so we can drop the check for already being registered. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Do not treat -ENODEV as an error for usb_kbd_deregisterHans de Goede2014-10-061-1/+6
| | | | | | | ENODEV menas no usb keyboard was registered, threat this as a successful usb_kbd_deregister. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: kbd: Fix unaligned buffer usage in usb_kbd_setled()Hans de Goede2014-10-061-2/+3
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* stdio: Pass device pointer to stdio methodsSimon Glass2014-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | At present stdio device functions do not get any clue as to which stdio device is being acted on. Some implementations go to great lengths to work around this, such as defining a whole separate set of functions for each possible device. For driver model we need to associate a stdio_dev with a device. It doesn't seem possible to continue with this work-around approach. Instead, add a stdio_dev pointer to each of the stdio member functions. Note: The serial drivers have the same problem, but it is not strictly necessary to fix that to get driver model running. Also, if we convert serial over to driver model the problem will go away. Code size increases by 244 bytes for Thumb2 and 428 for PowerPC. 22: stdio: Pass device pointer to stdio methods arm: (for 2/2 boards) all +244.0 bss -4.0 text +248.0 powerpc: (for 1/1 boards) all +428.0 text +428.0 Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Marek Vasut <marex@denx.de> Reviewed-by: Marek Vasut <marex@denx.de>
* stdio: Remove redundant code around stdio_register() callsSimon Glass2014-07-231-2/+0
| | | | | | | | | | | | | There is no point in setting a structure's memory to NULL when it has already been zeroed with memset(). Also, there is no need to create a stub function for stdio to call - if the function is NULL it will not be called. This is a clean-up, with no change in functionality. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Marek Vasut <marex@denx.de>
* usb: Fix USB keyboard polling via control endpointAdrian Cox2014-04-301-11/+25
| | | | | | | | | | USB keyboard polling failed for some keyboards on PowerPC 5020. This was caused by requesting only 4 bytes of data from keyboards that produce an 8 byte HID report. Signed-off-by: Adrian Cox <adrian@humboldt.co.uk> Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Marek Vasut <marex@denx.de>
* console: usb: kbd: To fix slow TFTP bootingJim Lin2013-08-261-10/+10
| | | | | | | | | | | | TFTP booting is slow when a USB keyboard is installed and stdin has usbkbd added. This fix is to change Ctrl-C polling for USB keyboard to every second when NET transfer is running. My previous patch is expected to be put into usb_kbd_testc(). But it went into usb_kbd_getc() after applied. This patch is to put change in correct place. Signed-off-by: Jim Lin <jilin@nvidia.com>
* console: usb: kbd: To improve TFTP booting performanceJim Lin2013-08-261-0/+15
| | | | | | | | | TFTP booting is slow when a USB keyboard is installed and stdin has usbkbd added. This fix is to change Ctrl-C polling for USB keyboard to every second when NET transfer is running. Signed-off-by: Jim Lin <jilin@nvidia.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-18/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* usb: workaround non-working keyboards.Vincent Palatin2013-06-121-2/+7
| | | | | | | | | | | | | | | | If the USB keyboard is not answering properly the first request on its interrupt endpoint, just skip it and try the next one. This workarounds an issue with a wireless mouse dongle which presents itself both as a keyboard and a mouse but has a non-functional keyboard interface. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 012bbf0ce0301be2482857e3f03b481dd15c2340) Rebased to upstream/master: Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* usb: properly re-initialize the USB keyboard.Vincent Palatin2013-06-121-0/+1
| | | | | | | | | | | Allow to reconfigure properly the USB keyboard driver when we enumerate several times the USB devices and its position in the device tree has changes. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* usb: common: Weed out USB_**_PRINTFs from usb frameworkVivek Gautam2013-05-051-15/+9
| | | | | | | | USB_PRINTF, USB_HUB_PRINTF, USB_STOR_PRINTF, USB_KBD_PRINTF are nothing but conditional debug prints, depending on DEBUG. So better remove them and use debug() simply. Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
* USB: add arrow key support to usb_kbdAllen Martin2012-11-201-0/+13
| | | | | | | | | | | Check for scancodes for arrow keys and map them to ^F/^B, ^N/^P. Control characters are used instead of ANSI sequence because the queueing code in usb_kbd doesn't handle the data increase when one keypress generates 3 keycodes. The real fix is to convert this driver to use the input subsystem and queue, but this allows arrow keys to work until this driver is converted. Signed-off-by: Allen Martin <amartin@nvidia.com>
* USB: make usb_kbd obey USB DMA alignment requirementsAllen Martin2012-11-201-1/+4
| | | | | | | | | | Change usb_kbd driver to obey alignment requirements for USB DMA on the buffer used for data transfer. This is necessary for architectures that enable dcache and enable USB DMA. Signed-off-by: Allen Martin <amartin@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* USB: move keyboard polling into kbd driveramartin@nvidia.com2012-03-031-1/+17
| | | | | | | | | This moves keyboard polling logic from USB HCD drivers into USB keyboard driver. Remove usb_event_poll() as keyboard polling was the only user of this API. With this patch USB keyboard works with EHCI controllers again. Tested on a tegra2 seaboard. Signed-off-by: Allen Martin <amartin@nvidia.com>
* USB: reevaluate iomux stdin on USB kbd detectamartin@nvidia.com2012-03-031-0/+6
| | | | | | | If CONSOLE_MUX is enabled, reevaluate console stdin when USB keyboard device is detected. Signed-off-by: Allen Martin <amartin@nvidia.com>
* usb: add numeric keypad support to HID driverVincent Palatin2012-03-031-0/+10
| | | | | | | When keys are pressed on the numeric keypad, emit key codes for the numbers, operators, dot and enter. Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
* USB: fix USB keyboard polling parameterVincent Palatin2012-03-031-1/+1
| | | | | | | | When doing a "GET_REPORT" request on the keyboard control endpoint, the report ID should 0 (ie report ID not used) rather than 1 as reports are not used in boot mode. Signed-off-by: Vincent Palatin <vpalatin@chromium.org>