From e7cc8d11ad41f4bed7ba0532285091e9a42a7348 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Fri, 11 Dec 2015 16:27:34 +0800 Subject: test: add sandbox timer to test.dts Add missing sandbox timer to test.dts, so that test-dm works. Signed-off-by: Thomas Chou Acked-by: Simon Glass Tested-by: Simon Glass --- arch/sandbox/dts/test.dts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index b6d9a15da4..2e0d320b1e 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -279,6 +279,11 @@ 0x38 8>; }; + timer { + compatible = "sandbox,timer"; + clock-frequency = <1000000>; + }; + uart0: serial { compatible = "sandbox,serial"; u-boot,dm-pre-reloc; -- cgit v1.2.1 From a671c4f2bea6215140b34726900d4f0aa5892e6a Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 21 Dec 2015 22:43:38 -0800 Subject: dm: eth: Test 'ethrotate' before changing current ethernet device In eth_current_changed(), the call to eth_get_dev() below has a side effect of rotating ethernet device if uc_priv->current == NULL. This is not what we want when 'ethrotate' variable is 'no'. Signed-off-by: Bin Meng Acked-by: Joe Hershberger Acked-by: Simon Glass Tested-by: Simon Glass --- net/eth.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/eth.c b/net/eth.c index 6cf3a353a3..6c490a6b93 100644 --- a/net/eth.c +++ b/net/eth.c @@ -1039,6 +1039,17 @@ int eth_receive(void *packet, int length) static void eth_current_changed(void) { char *act = getenv("ethact"); + char *ethrotate; + + /* + * The call to eth_get_dev() below has a side effect of rotating + * ethernet device if uc_priv->current == NULL. This is not what + * we want when 'ethrotate' variable is 'no'. + */ + ethrotate = getenv("ethrotate"); + if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0)) + return; + /* update current ethernet name */ if (eth_get_dev()) { if (act == NULL || strcmp(act, eth_get_name()) != 0) -- cgit v1.2.1 From 4cdc2c8cc018ba90050bee7622148032af7341ec Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 21 Dec 2015 22:43:39 -0800 Subject: dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init() When 'ethrotate' variable is set to 'no' and 'ethact' variable is already set to an ethernet device, we should stick to 'ethact'. Signed-off-by: Bin Meng Acked-by: Joe Hershberger Acked-by: Simon Glass Tested-by: Simon Glass --- net/eth.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/net/eth.c b/net/eth.c index 6c490a6b93..18c53bf58a 100644 --- a/net/eth.c +++ b/net/eth.c @@ -337,14 +337,30 @@ U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr); int eth_init(void) { - struct udevice *current; + char *ethact = getenv("ethact"); + char *ethrotate = getenv("ethrotate"); + struct udevice *current = NULL; struct udevice *old_current; int ret = -ENODEV; - current = eth_get_dev(); + /* + * When 'ethrotate' variable is set to 'no' and 'ethact' variable + * is already set to an ethernet device, we should stick to 'ethact'. + */ + if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0)) { + if (ethact) { + current = eth_get_dev_by_name(ethact); + if (!current) + return -EINVAL; + } + } + if (!current) { - printf("No ethernet found.\n"); - return -ENODEV; + current = eth_get_dev(); + if (!current) { + printf("No ethernet found.\n"); + return -ENODEV; + } } old_current = current; -- cgit v1.2.1 From b042566dcf0225f89026113ac24b9bffb9546684 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 3 Jan 2016 13:50:29 -0700 Subject: dm: Disable all SPI and SPI flash tests This subsystem has been broken since commit: 4efad20a sf: Update status reg check in spi_flash_cmd_wait_ready There has so far been no response from the maintainer, and a release is imminent. For now, let's just disable the tests. Signed-off-by: Simon Glass --- test/dm/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dm/Makefile b/test/dm/Makefile index 681c6aec71..3ff1b75e6f 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -27,8 +27,8 @@ obj-y += regmap.o obj-$(CONFIG_REMOTEPROC) += remoteproc.o obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o -obj-$(CONFIG_DM_SPI_FLASH) += sf.o -obj-$(CONFIG_DM_SPI) += spi.o +#obj-$(CONFIG_DM_SPI_FLASH) += sf.o +#obj-$(CONFIG_DM_SPI) += spi.o obj-y += syscon.o obj-$(CONFIG_DM_USB) += usb.o obj-$(CONFIG_DM_PMIC) += pmic.o -- cgit v1.2.1 From 70caa97108d790e5779b347a8530b130df9f000a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 3 Jan 2016 13:50:30 -0700 Subject: usb: Allow up to 7 storage devices The current limit of 5 is not enough for the driver model USB tests. Really we should not have a limit but the driver model code still uses the usb_dev_desc[] array, which has a limit. Increasing the limit by 2 should not bother anyone. Adjust it. Signed-off-by: Simon Glass Reviewed-by: Marek Vasut --- common/usb_storage.c | 2 +- include/usb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/usb_storage.c b/common/usb_storage.c index 4fa6538db5..e61a8c8adf 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -65,7 +65,7 @@ static const unsigned char us_direction[256/8] = { static ccb usb_ccb __attribute__((aligned(ARCH_DMA_MINALIGN))); static __u32 CBWTag; -#define USB_MAX_STOR_DEV 5 +#define USB_MAX_STOR_DEV 7 static int usb_max_devs; /* number of highest available usb device */ static block_dev_desc_t usb_dev_desc[USB_MAX_STOR_DEV]; diff --git a/include/usb.h b/include/usb.h index 2539364565..0b410b6cd1 100644 --- a/include/usb.h +++ b/include/usb.h @@ -227,7 +227,7 @@ int board_usb_cleanup(int index, enum usb_init_type init); #ifdef CONFIG_USB_STORAGE -#define USB_MAX_STOR_DEV 5 +#define USB_MAX_STOR_DEV 7 block_dev_desc_t *usb_stor_get_dev(int index); int usb_stor_scan(int mode); int usb_stor_info(void); -- cgit v1.2.1 From 8a8348703081098dcd0b3affd5ee432164d2f535 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 3 Jan 2016 13:50:31 -0700 Subject: dm: usb: Add a remove() method for USB keyboards At present USB keyboards are not properly removed with driver model. Add the code to handle this. Signed-off-by: Simon Glass Reviewed-by: Marek Vasut --- common/usb_kbd.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 9617a4848a..cbb1995de3 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -611,6 +611,41 @@ static int usb_kbd_probe(struct udevice *dev) return ret; } +static int usb_kbd_remove(struct udevice *dev) +{ + struct usb_device *udev = dev_get_parent_priv(dev); + struct usb_kbd_pdata *data; + struct stdio_dev *sdev; + int ret; + + sdev = stdio_get_by_name(DEVNAME); + if (!sdev) { + ret = -ENXIO; + goto err; + } + data = udev->privptr; + if (stdio_deregister_dev(sdev, true)) { + ret = -EPERM; + goto err; + } +#ifdef CONFIG_CONSOLE_MUX + if (iomux_doenv(stdin, getenv("stdin"))) { + ret = -ENOLINK; + goto err; + } +#endif +#ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE + destroy_int_queue(udev, data->intq); +#endif + free(data->new); + free(data); + + return 0; +err: + printf("%s: warning, ret=%d", __func__, ret); + return ret; +} + static const struct udevice_id usb_kbd_ids[] = { { .compatible = "usb-keyboard" }, { } @@ -621,6 +656,7 @@ U_BOOT_DRIVER(usb_kbd) = { .id = UCLASS_KEYBOARD, .of_match = usb_kbd_ids, .probe = usb_kbd_probe, + .remove = usb_kbd_remove, }; static const struct usb_device_id kbd_id_table[] = { -- cgit v1.2.1 From 71105f50fedddfa5b0535d102c3d5078671721ad Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 28 Oct 2015 15:37:57 +0100 Subject: fdt: fix address cell count checking in fdt_translate_address() Commit: dm: core: Enable optional use of fdt_translate_address() Enables use of this function as default, but after this it's not possible to get dev address for the case in which: '#size-cells == 0' This causes errors when getting address for some GPIOs, for which the '#size-cells' is set to 0. Example error: '__of_translate_address: Bad cell count for gpx0' Allowing for that case by modifying the macro 'OF_CHECK_COUNTS', (called from )__of_translate_address(), fixes the issue. Now, this macro doesn't check, that '#size-cells' is greater than 0. This is possible from the specification point of view, but I'm not sure that it doesn't introduce a regression for other configs. Please test and share the results. Tested-on: Odroid U3, Odroid X2, Odroid XU3, Sandbox. Signed-off-by: Przemyslaw Marczak Cc: Masahiro Yamada Cc: Lukasz Majewski Cc: Jaehoon Chung Cc: Stefan Roese Cc: Simon Glass Cc: Bin Meng Cc: Marek Vasut Tested-by: Jaehoon Chung Tested-by: Lukasz Majewski --- common/fdt_support.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 66464dbfd8..a539389a9e 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -952,8 +952,7 @@ void fdt_del_node_and_alias(void *blob, const char *alias) /* Max address size we deal with */ #define OF_MAX_ADDR_CELLS 4 #define OF_BAD_ADDR FDT_ADDR_T_NONE -#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ - (ns) > 0) +#define OF_CHECK_COUNTS(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS) /* Debug utility */ #ifdef DEBUG @@ -1121,7 +1120,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in /* Cound address cells & copy address locally */ bus->count_cells(blob, parent, &na, &ns); - if (!OF_CHECK_COUNTS(na, ns)) { + if (!OF_CHECK_COUNTS(na)) { printf("%s: Bad cell count for %s\n", __FUNCTION__, fdt_get_name(blob, node_offset, NULL)); goto bail; @@ -1148,7 +1147,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in /* Get new parent bus and counts */ pbus = &of_busses[0]; pbus->count_cells(blob, parent, &pna, &pns); - if (!OF_CHECK_COUNTS(pna, pns)) { + if (!OF_CHECK_COUNTS(pna)) { printf("%s: Bad cell count for %s\n", __FUNCTION__, fdt_get_name(blob, node_offset, NULL)); break; -- cgit v1.2.1 From c5a75339cf1595ee89a3513cd4fd84c10c0cd910 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Mon, 21 Dec 2015 16:31:35 -0600 Subject: net: Fix delay in net_retry test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced in 45b4773 (net/arp: account for ARP delay, avoid duplicate packets on timeout) Check the arp timeout and adjust the timeout start time before the call to eth_recv() so that the sandbox driver has the opportunity to adjust the sandbox timer after the new start time has been recorded. Also, change the adjustment amount by 11 seconds instead of exactly the 10 seconds that the ping timout is expecting since the timeout check is looking for the time elapsed to be greater than but not equal to the specified delay. Signed-off-by: Joe Hershberger Reviewed-by: Stefan BrĂ¼ns Acked-by: Simon Glass --- drivers/net/sandbox.c | 2 +- net/net.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 6763a248f2..d538d379bb 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -157,7 +157,7 @@ static int sb_eth_recv(struct udevice *dev, int flags, uchar **packetp) struct eth_sandbox_priv *priv = dev_get_priv(dev); if (skip_timeout) { - sandbox_timer_add_offset(10000UL); + sandbox_timer_add_offset(11000UL); skip_timeout = false; } diff --git a/net/net.c b/net/net.c index 4d5746a7b3..fba111edfb 100644 --- a/net/net.c +++ b/net/net.c @@ -542,6 +542,9 @@ restart: #ifdef CONFIG_SHOW_ACTIVITY show_activity(1); #endif + if (arp_timeout_check() > 0) + time_start = get_timer(0); + /* * Check the ethernet for a new packet. The ethernet * receive routine will process it. @@ -570,10 +573,6 @@ restart: goto done; } - if (arp_timeout_check() > 0) { - time_start = get_timer(0); - } - /* * Check for a timeout, and run the timeout handler * if we have one. -- cgit v1.2.1