summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig9
-rw-r--r--common/bootm.c45
-rw-r--r--common/cmd_bootm.c4
-rw-r--r--common/cmd_ide.c6
-rw-r--r--common/cmd_mem.c2
-rw-r--r--common/cmd_pxe.c2
-rw-r--r--common/env_mmc.c40
-rw-r--r--common/fdt_support.c25
-rw-r--r--common/image-fdt.c4
-rw-r--r--common/image-fit.c27
-rw-r--r--common/image.c73
-rw-r--r--common/menu.c3
-rw-r--r--common/spl/spl_mmc.c33
-rw-r--r--common/usb.c2
-rw-r--r--common/usb_kbd.c26
15 files changed, 234 insertions, 67 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 5b8b0c3fe7..a2167f01f7 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -252,12 +252,21 @@ config CMD_SOURCE
help
Run script from memory
+config CMD_SETEXPR
+ bool "setexpr"
+ help
+ Evaluate boolean and math expressions and store the result in an env
+ variable.
+ Also supports loading the value at a memory location into a variable.
+ If CONFIG_REGEX is enabled, setexpr also supports a gsub function.
+
endmenu
menu "Network commands"
config CMD_NET
bool "bootp, tftpboot"
+ select NET
help
Network commands.
bootp - boot image via network using BOOTP/TFTP protocol
diff --git a/common/bootm.c b/common/bootm.c
index 6842029dfb..667c93471b 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -206,7 +206,23 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
}
-static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
+/**
+ * bootm_find_images - wrapper to find and locate various images
+ * @flag: Ignored Argument
+ * @argc: command argument count
+ * @argv: command argument list
+ *
+ * boot_find_images() will attempt to load an available ramdisk,
+ * flattened device tree, as well as specifically marked
+ * "loadable" images (loadables are FIT only)
+ *
+ * Note: bootm_find_images will skip an image if it is not found
+ *
+ * @return:
+ * 0, if all existing images were loaded correctly
+ * 1, if an image is found but corrupted, or invalid
+ */
+int bootm_find_images(int flag, int argc, char * const argv[])
{
int ret;
@@ -218,14 +234,7 @@ static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
return 1;
}
- return 0;
-}
-
#if defined(CONFIG_OF_LIBFDT)
-static int bootm_find_fdt(int flag, int argc, char * const argv[])
-{
- int ret;
-
/* find flattened device tree */
ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
&images.ft_addr, &images.ft_len);
@@ -233,21 +242,17 @@ static int bootm_find_fdt(int flag, int argc, char * const argv[])
puts("Could not find a valid device tree\n");
return 1;
}
-
set_working_fdt_addr((ulong)images.ft_addr);
-
- return 0;
-}
#endif
-int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[])
-{
- if (bootm_find_ramdisk(flag, argc, argv))
- return 1;
-
-#if defined(CONFIG_OF_LIBFDT)
- if (bootm_find_fdt(flag, argc, argv))
+#if defined(CONFIG_FIT)
+ /* find all of the loadables */
+ ret = boot_get_loadable(argc, argv, &images, IH_ARCH_DEFAULT,
+ NULL, NULL);
+ if (ret) {
+ printf("Loadable(s) is corrupt or invalid\n");
return 1;
+ }
#endif
return 0;
@@ -261,7 +266,7 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
(images.os.type == IH_TYPE_MULTI)) &&
(images.os.os == IH_OS_LINUX ||
images.os.os == IH_OS_VXWORKS))
- return bootm_find_ramdisk_fdt(flag, argc, argv);
+ return bootm_find_images(flag, argc, argv);
return 0;
}
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 6b6aca66fd..48738ac605 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -580,7 +580,7 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
* have a header that provide this informaiton.
*/
- if (bootm_find_ramdisk_fdt(flag, argc, argv))
+ if (bootm_find_images(flag, argc, argv))
return 1;
return 0;
@@ -721,7 +721,7 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
* have a header that provide this informaiton.
*/
- if (bootm_find_ramdisk_fdt(flag, argc, argv))
+ if (bootm_find_images(flag, argc, argv))
return 1;
return 0;
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 04a6d9b398..ecd3e9d64f 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -79,7 +79,7 @@ static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len
#ifdef CONFIG_ATAPI
static void atapi_inquiry(block_dev_desc_t *dev_desc);
-static ulong atapi_read(int device, ulong blknr, lbaint_t blkcnt,
+static ulong atapi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
void *buffer);
#endif
@@ -1388,13 +1388,13 @@ static void atapi_inquiry(block_dev_desc_t *dev_desc)
#define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */
#define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
-ulong atapi_read(int device, ulong blknr, lbaint_t blkcnt, void *buffer)
+ulong atapi_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer)
{
ulong n = 0;
unsigned char ccb[12]; /* Command descriptor block */
ulong cnt;
- debug("atapi_read dev %d start %lX, blocks " LBAF " buffer at %lX\n",
+ debug("atapi_read dev %d start " LBAF " blocks " LBAF " buffer at %lX\n",
device, blknr, blkcnt, (ulong) buffer);
do {
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 2e85d53dd2..43c3fb62bf 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -1325,7 +1325,7 @@ U_BOOT_CMD(
#endif
#ifdef CONFIG_CMD_MEMINFO
-__weak void board_show_dram(ulong size)
+__weak void board_show_dram(phys_size_t size)
{
puts("DRAM: ");
print_size(size, "\n");
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 4cbb2b1173..abf0941b57 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -1648,7 +1648,7 @@ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
is_pxe = false;
- if (strstr(argv[1], "-p")) {
+ if (argc > 1 && strstr(argv[1], "-p")) {
prompt = 1;
argc--;
argv++;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 14648e37bd..6c4ce2f05d 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -90,19 +90,18 @@ static int mmc_set_env_part(struct mmc *mmc)
static inline int mmc_set_env_part(struct mmc *mmc) {return 0; };
#endif
-static int init_mmc_for_env(struct mmc *mmc)
+static const char *init_mmc_for_env(struct mmc *mmc)
{
- if (!mmc) {
- puts("No MMC card found\n");
- return -1;
- }
+ if (!mmc)
+ return "No MMC card found";
- if (mmc_init(mmc)) {
- puts("MMC init failed\n");
- return -1;
- }
+ if (mmc_init(mmc))
+ return "MMC init failed";
+
+ if (mmc_set_env_part(mmc))
+ return "MMC partition switch failed";
- return mmc_set_env_part(mmc);
+ return NULL;
}
static void fini_mmc_for_env(struct mmc *mmc)
@@ -143,9 +142,13 @@ int saveenv(void)
struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
u32 offset;
int ret, copy = 0;
+ const char *errmsg;
- if (init_mmc_for_env(mmc))
+ errmsg = init_mmc_for_env(mmc);
+ if (errmsg) {
+ printf("%s\n", errmsg);
return 1;
+ }
ret = env_export(env_new);
if (ret)
@@ -213,6 +216,7 @@ void env_relocate_spec(void)
env_t *ep;
int ret;
int dev = CONFIG_SYS_MMC_ENV_DEV;
+ const char *errmsg = NULL;
ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1);
@@ -223,7 +227,8 @@ void env_relocate_spec(void)
mmc = find_mmc_device(dev);
- if (init_mmc_for_env(mmc)) {
+ errmsg = init_mmc_for_env(mmc);
+ if (errmsg) {
ret = 1;
goto err;
}
@@ -249,6 +254,7 @@ void env_relocate_spec(void)
(crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc);
if (!crc1_ok && !crc2_ok) {
+ errmsg = "!bad CRC";
ret = 1;
goto fini;
} else if (crc1_ok && !crc2_ok) {
@@ -284,8 +290,7 @@ fini:
fini_mmc_for_env(mmc);
err:
if (ret)
- set_default_env(NULL);
-
+ set_default_env(errmsg);
#endif
}
#else /* ! CONFIG_ENV_OFFSET_REDUND */
@@ -297,6 +302,7 @@ void env_relocate_spec(void)
u32 offset;
int ret;
int dev = CONFIG_SYS_MMC_ENV_DEV;
+ const char *errmsg;
#ifdef CONFIG_SPL_BUILD
dev = 0;
@@ -304,7 +310,8 @@ void env_relocate_spec(void)
mmc = find_mmc_device(dev);
- if (init_mmc_for_env(mmc)) {
+ errmsg = init_mmc_for_env(mmc);
+ if (errmsg) {
ret = 1;
goto err;
}
@@ -315,6 +322,7 @@ void env_relocate_spec(void)
}
if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
+ errmsg = "!read failed";
ret = 1;
goto fini;
}
@@ -326,7 +334,7 @@ fini:
fini_mmc_for_env(mmc);
err:
if (ret)
- set_default_env(NULL);
+ set_default_env(errmsg);
#endif
}
#endif /* CONFIG_ENV_OFFSET_REDUND */
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 9e50148462..10648b5a4a 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -194,6 +194,31 @@ static inline int fdt_setprop_uxx(void *fdt, int nodeoffset, const char *name,
return fdt_setprop_u32(fdt, nodeoffset, name, (uint32_t)val);
}
+int fdt_root(void *fdt)
+{
+ char *serial;
+ int err;
+
+ err = fdt_check_header(fdt);
+ if (err < 0) {
+ printf("fdt_root: %s\n", fdt_strerror(err));
+ return err;
+ }
+
+ serial = getenv("serial#");
+ if (serial) {
+ err = fdt_setprop(fdt, 0, "serial-number", serial,
+ strlen(serial) + 1);
+
+ if (err < 0) {
+ printf("WARNING: could not set serial-number %s.\n",
+ fdt_strerror(err));
+ return err;
+ }
+ }
+
+ return 0;
+}
int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end)
{
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 7e2da7b3b7..80e3e63805 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -471,6 +471,10 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
int ret = -EPERM;
int fdt_ret;
+ if (fdt_root(blob) < 0) {
+ printf("ERROR: root node setup failed\n");
+ goto err;
+ }
if (fdt_chosen(blob) < 0) {
printf("ERROR: /chosen node create failed\n");
goto err;
diff --git a/common/image-fit.c b/common/image-fit.c
index 4eb4d42655..28f7aa83ba 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1436,6 +1436,7 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
char *desc;
char *uname;
int ret;
+ int loadables_index;
/* Mandatory properties */
ret = fit_get_desc(fit, noffset, &desc);
@@ -1460,6 +1461,22 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
uname = (char *)fdt_getprop(fit, noffset, FIT_FDT_PROP, NULL);
if (uname)
printf("%s FDT: %s\n", p, uname);
+
+ /* Print out all of the specified loadables */
+ for (loadables_index = 0;
+ fdt_get_string_index(fit, noffset,
+ FIT_LOADABLE_PROP,
+ loadables_index,
+ (const char **)&uname) == 0;
+ loadables_index++)
+ {
+ if (loadables_index == 0) {
+ printf("%s Loadables: ", p);
+ } else {
+ printf("%s ", p);
+ }
+ printf("%s\n", uname);
+ }
}
static int fit_image_select(const void *fit, int rd_noffset, int verify)
@@ -1527,6 +1544,8 @@ static const char *fit_get_image_type_property(int type)
return FIT_RAMDISK_PROP;
case IH_TYPE_X86_SETUP:
return FIT_SETUP_PROP;
+ case IH_TYPE_LOADABLE:
+ return FIT_LOADABLE_PROP;
}
return "unknown";
@@ -1644,7 +1663,13 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
os_ok = image_type == IH_TYPE_FLATDT ||
fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
fit_image_check_os(fit, noffset, IH_OS_OPENRTOS);
- if (!type_ok || !os_ok) {
+
+ /*
+ * If either of the checks fail, we should report an error, but
+ * if the image type is coming from the "loadables" field, we
+ * don't care what it is
+ */
+ if ((!type_ok || !os_ok) && image_type != IH_TYPE_LOADABLE) {
fit_image_get_os(fit, noffset, &os);
printf("No %s %s %s Image\n",
genimg_get_os_name(os),
diff --git a/common/image.c b/common/image.c
index fdec496c4b..f0f01351fe 100644
--- a/common/image.c
+++ b/common/image.c
@@ -462,7 +462,7 @@ phys_size_t getenv_bootm_size(void)
tmp = 0;
-#if defined(CONFIG_ARM)
+#if defined(CONFIG_ARM) && defined(CONFIG_NR_DRAM_BANKS)
return gd->bd->bi_dram[0].size - tmp;
#else
return gd->bd->bi_memsize - tmp;
@@ -1165,6 +1165,77 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch,
#endif
}
+#if defined(CONFIG_FIT)
+int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
+ uint8_t arch, const ulong *ld_start, ulong * const ld_len)
+{
+ /*
+ * These variables are used to hold the current image location
+ * in system memory.
+ */
+ ulong tmp_img_addr;
+ /*
+ * These two variables are requirements for fit_image_load, but
+ * their values are not used
+ */
+ ulong img_data, img_len;
+ void *buf;
+ int loadables_index;
+ int conf_noffset;
+ int fit_img_result;
+ char *uname;
+
+ /* Check to see if the images struct has a FIT configuration */
+ if (!genimg_has_config(images)) {
+ debug("## FIT configuration was not specified\n");
+ return 0;
+ }
+
+ /*
+ * Obtain the os FIT header from the images struct
+ * copy from dataflash if needed
+ */
+ tmp_img_addr = map_to_sysmem(images->fit_hdr_os);
+ tmp_img_addr = genimg_get_image(tmp_img_addr);
+ buf = map_sysmem(tmp_img_addr, 0);
+ /*
+ * Check image type. For FIT images get FIT node
+ * and attempt to locate a generic binary.
+ */
+ switch (genimg_get_format(buf)) {
+ case IMAGE_FORMAT_FIT:
+ conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
+
+ for (loadables_index = 0;
+ !fdt_get_string_index(buf, conf_noffset,
+ FIT_LOADABLE_PROP,
+ loadables_index,
+ (const char **)&uname) > 0;
+ loadables_index++)
+ {
+ fit_img_result = fit_image_load(images,
+ tmp_img_addr,
+ (const char **)&uname,
+ &(images->fit_uname_cfg), arch,
+ IH_TYPE_LOADABLE,
+ BOOTSTAGE_ID_FIT_LOADABLE_START,
+ FIT_LOAD_OPTIONAL_NON_ZERO,
+ &img_data, &img_len);
+ if (fit_img_result < 0) {
+ /* Something went wrong! */
+ return fit_img_result;
+ }
+ }
+ break;
+ default:
+ printf("The given image format is not supported (corrupt?)\n");
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
#ifdef CONFIG_SYS_BOOT_GET_CMDLINE
/**
* boot_get_cmdline - allocate and initialize kernel cmdline
diff --git a/common/menu.c b/common/menu.c
index e81c074f36..eda96d68bc 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -202,6 +202,9 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
choice_item = menu_item_by_key(m, cbuf);
if (!choice_item)
printf("%s not found\n", cbuf);
+ } else if (readret == -1) {
+ printf("<INTERRUPT>\n");
+ return -EINTR;
} else {
return menu_default_choice(m, choice);
}
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index c96345eff2..de495c0dc4 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
{
- unsigned long err;
+ unsigned long count;
u32 image_size_sectors;
struct image_header *header;
@@ -25,8 +25,8 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
sizeof(struct image_header));
/* read image header to find the image size & load address */
- err = mmc->block_dev.block_read(0, sector, 1, header);
- if (err == 0)
+ count = mmc->block_dev.block_read(0, sector, 1, header);
+ if (count == 0)
goto end;
if (image_get_magic(header) != IH_MAGIC)
@@ -39,24 +39,29 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
mmc->read_bl_len;
/* Read the header too to avoid extra memcpy */
- err = mmc->block_dev.block_read(0, sector, image_size_sectors,
- (void *)spl_image.load_addr);
+ count = mmc->block_dev.block_read(0, sector, image_size_sectors,
+ (void *) spl_image.load_addr);
end:
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
- if (err == 0)
+ if (count == 0)
printf("spl: mmc block read error\n");
#endif
- return (err == 0);
+ if (count == 0)
+ return -1;
+
+ return 0;
}
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
{
disk_partition_t info;
+ int err;
- if (get_partition_info(&mmc->block_dev, partition, &info)) {
+ err = get_partition_info(&mmc->block_dev, partition, &info);
+ if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: partition error\n");
#endif
@@ -70,13 +75,13 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
#ifdef CONFIG_SPL_OS_BOOT
static int mmc_load_image_raw_os(struct mmc *mmc)
{
- unsigned long err;
+ unsigned long count;
- err = mmc->block_dev.block_read(0,
- CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
- CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
- (void *)CONFIG_SYS_SPL_ARGS_ADDR);
- if (err == 0) {
+ count = mmc->block_dev.block_read(0,
+ CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
+ CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
+ (void *) CONFIG_SYS_SPL_ARGS_ADDR);
+ if (count == 0) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: mmc block read error\n");
#endif
diff --git a/common/usb.c b/common/usb.c
index 6283f3992c..7ff8ac5df3 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -959,8 +959,6 @@ static int get_descriptor_len(struct usb_device *dev, int len, int expect_len)
static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
{
- __maybe_unused struct usb_device_descriptor *desc;
-
/*
* This is a Windows scheme of initialization sequence, with double
* reset of the device (Linux uses the same sequence)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 24a1a56141..49bfc096e4 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -31,7 +31,7 @@ int overwrite_console(void)
#endif
/* Keyboard sampling rate */
-#define REPEAT_RATE (40 / 4) /* 40msec -> 25cps */
+#define REPEAT_RATE 40 /* 40msec -> 25cps */
#define REPEAT_DELAY 10 /* 10 x REPEAT_RATE = 400msec */
#define NUM_LOCK 0x53
@@ -103,6 +103,7 @@ struct usb_kbd_pdata {
unsigned long intpipe;
int intpktsize;
int intinterval;
+ unsigned long last_report;
struct int_queue *intq;
uint32_t repeat_delay;
@@ -310,7 +311,7 @@ static int usb_kbd_irq(struct usb_device *dev)
/* Interrupt polling */
static inline void usb_kbd_poll_for_event(struct usb_device *dev)
{
-#if defined(CONFIG_SYS_USB_EVENT_POLL)
+#if defined(CONFIG_SYS_USB_EVENT_POLL)
struct usb_kbd_pdata *data = dev->privptr;
/* Submit a interrupt transfer request */
@@ -318,15 +319,17 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
data->intinterval);
usb_kbd_irq_worker(dev);
-#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
+#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) || \
+ defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
+#if defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
struct usb_interface *iface;
struct usb_kbd_pdata *data = dev->privptr;
iface = &dev->config.if_desc[0];
usb_get_report(dev, iface->desc.bInterfaceNumber,
1, 0, data->new, USB_KBD_BOOT_REPORT_SIZE);
- if (memcmp(data->old, data->new, USB_KBD_BOOT_REPORT_SIZE))
+ if (memcmp(data->old, data->new, USB_KBD_BOOT_REPORT_SIZE)) {
usb_kbd_irq_worker(dev);
-#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
+#else
struct usb_kbd_pdata *data = dev->privptr;
if (poll_int_queue(dev, data->intq)) {
usb_kbd_irq_worker(dev);
@@ -335,6 +338,13 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
data->intq = create_int_queue(dev, data->intpipe, 1,
USB_KBD_BOOT_REPORT_SIZE, data->new,
data->intinterval);
+#endif
+ data->last_report = get_timer(0);
+ /* Repeat last usb hid report every REPEAT_RATE ms for keyrepeat */
+ } else if (data->last_report != -1 &&
+ get_timer(data->last_report) > REPEAT_RATE) {
+ usb_kbd_irq_worker(dev);
+ data->last_report = get_timer(0);
}
#endif
}
@@ -445,12 +455,16 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
data->intpktsize = min(usb_maxpacket(dev, data->intpipe),
USB_KBD_BOOT_REPORT_SIZE);
data->intinterval = ep->bInterval;
+ data->last_report = -1;
/* We found a USB Keyboard, install it. */
usb_set_protocol(dev, iface->desc.bInterfaceNumber, 0);
+#if !defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) && \
+ !defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE)
debug("USB KBD: found set idle...\n");
- usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE, 0);
+ usb_set_idle(dev, iface->desc.bInterfaceNumber, REPEAT_RATE / 4, 0);
+#endif
debug("USB KBD: enable interrupt pipe...\n");
#ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE