Re: [U-Boot] [PATCH] eth: asix88179: Reset device during probe with DM_ETH enabled

2016-09-06 Thread Alban Bedel
On Mon, 5 Sep 2016 19:04:49 -0600
Simon Glass  wrote:

> Hi,
> 
> On 30 August 2016 at 08:01, Nikolaus Schulz
>  wrote:
> > With the ethernet driver model enabled, reset the device before reading
> > the MAC address, just like it's done for the non-device-model code path.
> > This avoids a timeout when the interface is first used.
> >
> > Signed-off-by: Nikolaus Schulz 
> > ---
> >  drivers/usb/eth/asix88179.c | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
> > index 7548269..0725940 100644
> > --- a/drivers/usb/eth/asix88179.c
> > +++ b/drivers/usb/eth/asix88179.c
> > @@ -878,6 +878,10 @@ static int ax88179_eth_probe(struct udevice *dev)
> > usb_dev = priv->ueth.pusb_dev;
> > priv->maxpacketsize = usb_dev->epmaxpacketout[AX_ENDPOINT_OUT];
> >
> > +   ret = asix_basic_reset(&priv->ueth, priv);
> > +   if (ret)
> > +   return ret;
> > +
> > /* Get the MAC address */
> > ret = asix_read_mac(&priv->ueth, pdata->enetaddr);
> > if (ret)  
> 
> How come this doesn't happen in ax88179_eth_start()?

It happen in ax88179_eth_get_info() in the non DM case, that's why it
was overseen when adding DM support.

Alban


pgpKXGkzQOvaS.pgp
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[PATCH v2 0/2] usb: dwc3: Add support for standalone DWC3 nodes

2022-06-16 Thread Alban Bedel
Hi all,

Sometimes ago I submitted a patch to fix the support for the DWC3
controller on the imx8mq which, unlike most DWC3 implementation, doesn't
use a top glue node with child DWC3 nodes. Instead it has the DWC3 node
directly on the main bus.

Angus Ainslie then asked why this patch was needed as he had submitted
the original support for the imx8mq. Looking into the issue it turned out
that Angus patch basically let the driver use the `port` subnodes, which
are there to define the connection to a type C connector, as DWC3 nodes.
As the board I'm working on has no type C connecor, hence no `port`
subnodes the driver just did nothing in my case.

This new series replace my previous patch (usb: dwc3-generic: Fix the
iMX8MQ support). It starts by reverting Angus patch as it was not
following the DT binding and then add support for generic DWC3 without
glue node. This fix the imx8mq case and might add support for a few
other SoC at the same time.

Alban

--
v2: - Rebased onto current master
- Fixed a typo the log message

Alban Bedel (2):
  Revert "usb: dwc3: dwc3-generic: check the parent nodes"
  usb: dwc3: Add support for standalone DWC3 nodes

 drivers/usb/dwc3/dwc3-generic.c | 124 +---
 1 file changed, 68 insertions(+), 56 deletions(-)

--
2.34.1


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 1/2] usb: dwc3: core: fix warnings when building without driver model

2022-04-19 Thread Alban Bedel
Commit f150b8d28b4e ("usb: dwc3: Enable undefined length INCR burst
type") introduced code that assign the content of dwc->dev to a
variable. But in u-boot the type of this field changes if building
with driver model enabled or not. As this variable is then only used
once just remove it and use the struct field directly.

Another issued was also introduced in commit fb146fbc1ae5 ("usb: dwc3:
core: stop the core when it's removed") which define a static function
which is only used when the driver model is enabled. Add ifdef around
this function to suppress the warning when building without driver
model.

Signed-off-by: Alban Bedel 
---
 drivers/usb/dwc3/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b592a487e001..fdd8c5db2460 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -465,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 /* set global incr burst type configuration registers */
 static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
 {
-   struct udevice *dev = dwc->dev;
u32 cfg;

if (!dwc->incrx_size)
@@ -502,7 +501,7 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
case 1:
break;
default:
-   dev_err(dev, "Invalid property\n");
+   dev_err(dwc->dev, "Invalid property\n");
break;
}

@@ -706,6 +705,7 @@ static void dwc3_gadget_run(struct dwc3 *dwc)
mdelay(100);
 }

+#if CONFIG_IS_ENABLED(DM_USB)
 static void dwc3_core_stop(struct dwc3 *dwc)
 {
u32 reg;
@@ -713,6 +713,7 @@ static void dwc3_core_stop(struct dwc3 *dwc)
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
dwc3_writel(dwc->regs, DWC3_DCTL, reg & ~(DWC3_DCTL_RUN_STOP));
 }
+#endif

 static void dwc3_core_exit_mode(struct dwc3 *dwc)
 {
--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 1/2] usb: dwc3: core: Fix warnings when building without driver model

2022-04-19 Thread Alban Bedel
Commit f150b8d28b4e ("usb: dwc3: Enable undefined length INCR burst
type") introduced code that assign the content of dwc->dev to a
variable. But in u-boot the type of this field changes if building
with driver model enabled or not. As this variable is then only used
once just remove it and use the struct field directly.

Another issued was also introduced in commit fb146fbc1ae5 ("usb: dwc3:
core: stop the core when it's removed") which define a static function
which is only used when the driver model is enabled. Add ifdef around
this function to suppress the warning when building without driver
model.

Signed-off-by: Alban Bedel 
---
 drivers/usb/dwc3/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b592a487e001..fdd8c5db2460 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -465,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 /* set global incr burst type configuration registers */
 static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
 {
-   struct udevice *dev = dwc->dev;
u32 cfg;

if (!dwc->incrx_size)
@@ -502,7 +501,7 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
case 1:
break;
default:
-   dev_err(dev, "Invalid property\n");
+   dev_err(dwc->dev, "Invalid property\n");
break;
}

@@ -706,6 +705,7 @@ static void dwc3_gadget_run(struct dwc3 *dwc)
mdelay(100);
 }

+#if CONFIG_IS_ENABLED(DM_USB)
 static void dwc3_core_stop(struct dwc3 *dwc)
 {
u32 reg;
@@ -713,6 +713,7 @@ static void dwc3_core_stop(struct dwc3 *dwc)
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
dwc3_writel(dwc->regs, DWC3_DCTL, reg & ~(DWC3_DCTL_RUN_STOP));
 }
+#endif

 static void dwc3_core_exit_mode(struct dwc3 *dwc)
 {
--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH] usb: dwc3-generic: Fix the iMX8MQ support

2022-04-19 Thread Alban Bedel
The binding of iMX8MQ USB controller doesn't use child nodes like the
other devices supported in this driver. To support it split the child
nodes parsing to its own function and add a field to the platform data
to indicate that we should just use the top node.

Signed-off-by: Alban Bedel 
---
 drivers/usb/dwc3/dwc3-generic.c | 95 +++--
 1 file changed, 56 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 01bd0ca190e3..defef43ff503 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -221,6 +221,7 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 struct dwc3_glue_ops {
void (*select_dr_mode)(struct udevice *dev, int index,
   enum usb_dr_mode mode);
+   int single_node;
 };

 void dwc3_ti_select_dr_mode(struct udevice *dev, int index,
@@ -307,54 +308,66 @@ struct dwc3_glue_ops ti_ops = {
.select_dr_mode = dwc3_ti_select_dr_mode,
 };

+static int dwc3_glue_bind_node(struct udevice *parent, ofnode node,
+  enum usb_dr_mode dr_mode)
+{
+   const char *name = ofnode_get_name(node);
+   const char *driver = NULL;
+   struct udevice *dev;
+   int ret;
+
+   debug("%s: subnode name: %s\n", __func__, name);
+
+   /* if the parent node doesn't have a mode check the leaf */
+   if (!dr_mode)
+   dr_mode = usb_get_dr_mode(node);
+
+   switch (dr_mode) {
+   case USB_DR_MODE_PERIPHERAL:
+   case USB_DR_MODE_OTG:
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+   debug("%s: dr_mode: OTG or Peripheral\n", __func__);
+   driver = "dwc3-generic-peripheral";
+#endif
+   break;
+#if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD)
+   case USB_DR_MODE_HOST:
+   debug("%s: dr_mode: HOST\n", __func__);
+   driver = "dwc3-generic-host";
+   break;
+#endif
+   default:
+   debug("%s: unsupported dr_mode\n", __func__);
+   return -ENODEV;
+   };
+
+   if (!driver)
+   return 0;
+
+   ret = device_bind_driver_to_node(parent, driver, name,
+node, &dev);
+   if (ret)
+   debug("%s: not able to bind usb device mode\n",
+ __func__);
+   return ret;
+}
+
 static int dwc3_glue_bind(struct udevice *parent)
 {
+   struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(parent);
ofnode node;
int ret;
enum usb_dr_mode dr_mode;

+   if (ops->single_node)
+   return dwc3_glue_bind_node(parent, dev_ofnode(parent), 0);
+
dr_mode = usb_get_dr_mode(dev_ofnode(parent));

ofnode_for_each_subnode(node, dev_ofnode(parent)) {
-   const char *name = ofnode_get_name(node);
-   struct udevice *dev;
-   const char *driver = NULL;
-
-   debug("%s: subnode name: %s\n", __func__, name);
-
-   /* if the parent node doesn't have a mode check the leaf */
-   if (!dr_mode)
-   dr_mode = usb_get_dr_mode(node);
-
-   switch (dr_mode) {
-   case USB_DR_MODE_PERIPHERAL:
-   case USB_DR_MODE_OTG:
-#if CONFIG_IS_ENABLED(DM_USB_GADGET)
-   debug("%s: dr_mode: OTG or Peripheral\n", __func__);
-   driver = "dwc3-generic-peripheral";
-#endif
-   break;
-#if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD)
-   case USB_DR_MODE_HOST:
-   debug("%s: dr_mode: HOST\n", __func__);
-   driver = "dwc3-generic-host";
-   break;
-#endif
-   default:
-   debug("%s: unsupported dr_mode\n", __func__);
-   return -ENODEV;
-   };
-
-   if (!driver)
-   continue;
-
-   ret = device_bind_driver_to_node(parent, driver, name,
-node, &dev);
-   if (ret) {
-   debug("%s: not able to bind usb device mode\n",
- __func__);
+   ret = dwc3_glue_bind_node(parent, node, dr_mode);
+   if (ret)
return ret;
-   }
}

return 0;
@@ -454,6 +467,10 @@ static int dwc3_glue_remove(struct udevice *dev)
return 0;
 }

+struct dwc3_glue_ops single_node_ops = {
+   .single_node = 1,
+};
+
 static const struct udevice_id dwc3_glue_ids[] = {
{ .compatible = "xlnx,zynqmp-dwc3" },
{ .compatible = "xlnx,versal-dwc3" },
@@ -464,7 +481

[PATCH] devres: Use the correct devres implementation in SPL builds

2022-04-19 Thread Alban Bedel
When CONFIG_DEVRES is set, but CONFIG_SPL_DM is not set devres code is
not included in the SPL. But dm/devres.h only check for CONFIG_DEVRES
to select if the full implementation should be used. So if any devres
function is used in the SPL with this config the link fails.

Fix the ifdef in the dm/devres.h to also check for CONFIG_SPL_DM in
SPL builds.

Signed-off-by: Alban Bedel 
---
 include/dm/devres.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/dm/devres.h b/include/dm/devres.h
index 0ab277ec38e9..8765b73d5e90 100644
--- a/include/dm/devres.h
+++ b/include/dm/devres.h
@@ -30,7 +30,8 @@ struct devres_stats {
int total_size;
 };

-#ifdef CONFIG_DEVRES
+/* devres is not available in SPL unless DM is enabled there */
+#if defined(CONFIG_DEVRES) && CONFIG_IS_ENABLED(DM)

 #ifdef CONFIG_DEBUG_DEVRES
 void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 1/2] usb: gadget: Add a config option to set the SPL product ID

2022-04-19 Thread Alban Bedel
It might be desirable to have a different product ID for the SPL
gadget. Several boards use dubious hack to achieve this like adding an
hardcoded offset to the configurable main product ID.

Add a new config option to set the product ID to use in the SPL and
use it in the ethernet and download gadgets.

Signed-off-by: Alban Bedel 
---
 common/spl/Kconfig | 6 ++
 drivers/usb/gadget/ether.c | 2 +-
 drivers/usb/gadget/g_dnl.c | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ac61b25a0660..196f3cfc5558 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1182,6 +1182,12 @@ config SPL_USB_GADGET

 if SPL_USB_GADGET

+config SPL_USB_GADGET_PRODUCT_NUM
+   hex "Product ID of the SPL USB device"
+   default 0x0
+   help
+ Product ID of the USB device emulated in SPL, reported to the host 
device.
+
 config SPL_USB_ETHER
bool "Support USB Ethernet drivers"
depends on SPL_NET
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 430732865723..18195d3ee19b 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2078,7 +2078,7 @@ static int eth_bind(struct usb_gadget *gadget)
device_desc.idVendor
__constant_cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM);
device_desc.idProduct - 
__constant_cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM);
+   
__constant_cpu_to_le16(CONFIG_VAL(USB_GADGET_PRODUCT_NUM));
 #else
device_desc.idVendor
__constant_cpu_to_le16(RNDIS_VENDOR_NUM);
diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index afb7b74f3057..85297cc0e501 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -63,7 +63,7 @@ static struct usb_device_descriptor device_desc = {
.bDeviceSubClass = 0, /*0x02:CDC-modem , 0x00:CDC-serial*/

.idVendor = __constant_cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM),
-   .idProduct = __constant_cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM),
+   .idProduct = __constant_cpu_to_le16(CONFIG_VAL(USB_GADGET_PRODUCT_NUM)),
/* .iProduct = DYNAMIC */
/* .iSerialNumber = DYNAMIC */
.bNumConfigurations = 1,
--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 2/2] mach-imx: Use CONFIG_SPL_USB_GADGET_PRODUCT_NUM

2022-04-19 Thread Alban Bedel
Remove the hardcoded USB product ID offset for the SPL as it doesn't
work anymore for the product ID needed for iMX8 with current flashing
tools. Update all the defconfig of iMX boards that have
CONFIG_SPL_USB_GADGET enabled to still return the same product ID.

Signed-off-by: Alban Bedel 
---
 arch/arm/mach-imx/spl.c  | 7 ---
 configs/apalis_imx6_defconfig| 1 +
 configs/colibri_imx6_defconfig   | 1 +
 configs/display5_factory_defconfig   | 1 +
 configs/ge_b1x5v2_defconfig  | 1 +
 configs/imx6q_logic_defconfig| 1 +
 configs/imx7_cm_defconfig| 1 +
 configs/kontron-sl-mx6ul_defconfig   | 1 +
 configs/mx6sabreauto_defconfig   | 1 +
 configs/mx6sabresd_defconfig | 1 +
 configs/mx6ul_14x14_evk_defconfig| 1 +
 configs/pico-dwarf-imx6ul_defconfig  | 1 +
 configs/pico-dwarf-imx7d_defconfig   | 1 +
 configs/pico-hobbit-imx6ul_defconfig | 1 +
 configs/pico-hobbit-imx7d_defconfig  | 1 +
 configs/pico-imx6_defconfig  | 1 +
 configs/pico-imx6ul_defconfig| 1 +
 configs/pico-imx7d_bl33_defconfig| 1 +
 configs/pico-imx7d_defconfig | 1 +
 configs/pico-nymph-imx7d_defconfig   | 1 +
 configs/pico-pi-imx6ul_defconfig | 1 +
 configs/vining_2000_defconfig| 1 +
 22 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 64ca29677212..27a2650a0ba5 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -185,13 +185,6 @@ u32 spl_boot_device(void)
 #endif /* CONFIG_MX7 || CONFIG_IMX8M || CONFIG_IMX8 */

 #ifdef CONFIG_SPL_USB_GADGET
-int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
-{
-   put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM + 0xfff, &dev->idProduct);
-
-   return 0;
-}
-
 #define SDPV_BCD_DEVICE 0x500
 int g_dnl_get_board_bcd_device_number(int gcnum)
 {
diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 3fa1bb58a434..5b641343cd9c 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -37,6 +37,7 @@ CONFIG_SPL_DMA=y
 CONFIG_SPL_I2C=y
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0x4fff
 CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_SYS_PROMPT="Apalis iMX6 # "
 # CONFIG_CMD_ELF is not set
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 04b73a8b9cb1..a946a772bccb 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -36,6 +36,7 @@ CONFIG_SPL_DMA=y
 CONFIG_SPL_I2C=y
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0x4fff
 CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_SYS_PROMPT="Colibri iMX6 # "
 # CONFIG_CMD_ELF is not set
diff --git a/configs/display5_factory_defconfig 
b/configs/display5_factory_defconfig
index 45b6b9644918..8339a7c6a09f 100644
--- a/configs/display5_factory_defconfig
+++ b/configs/display5_factory_defconfig
@@ -44,6 +44,7 @@ CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x2
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4
 CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="display5 factory > "
diff --git a/configs/ge_b1x5v2_defconfig b/configs/ge_b1x5v2_defconfig
index a1cf676f3f57..bf52e0541198 100644
--- a/configs/ge_b1x5v2_defconfig
+++ b/configs/ge_b1x5v2_defconfig
@@ -41,6 +41,7 @@ CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x11400
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4
 CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
diff --git a/configs/imx6q_logic_defconfig b/configs/imx6q_logic_defconfig
index 0a8ac8f50ab2..34b506e72c32 100644
--- a/configs/imx6q_logic_defconfig
+++ b/configs/imx6q_logic_defconfig
@@ -37,6 +37,7 @@ CONFIG_SPL_FALCON_BOOT_MMCSD=y
 CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR=0x1000
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4
 CONFIG_SPL_USB_SDP_SUPPORT=y
 CONFIG_SPL_WATCHDOG=y
 CONFIG_SYS_PROMPT="i.MX6 Logic # "
diff --git a/configs/imx7_cm_defconfig b/configs/imx7_cm_defconfig
index c22c4d570d40..18a7054b2e5d 100644
--- a/configs/imx7_cm_defconfig
+++ b/configs/imx7_cm_defconfig
@@ -27,6 +27,7 @@ CONFIG_DEFAULT_FDT_FILE="ask"
 CONFIG_SPL_I2C=y
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4
 CONFIG_SPL_USB_SDP_SUPPORT=y
 # CONFIG_CMD_BOOTD is not set
 CONFIG_CMD_BOOTMENU=y
diff --git a/configs/kontron-sl-mx6ul_defconfig 
b/configs/kontron-sl-mx6ul_defconfig
index c4f8fdb4f5fc..65cecff52f2c 100644
--- a/configs/kontron-sl-mx6ul_defconfig
+++ b/configs/kontron-sl-mx6ul_defconfig
@@ -31,6 +31,7 @@ CONFIG_SPL_LEGACY_IMAGE_CRC_CHECK=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_USB_HOST=y
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_GADGET_PRODUCT_NUM=0xb4a4
 CONFIG_SPL_WATCHDOG=y
 CONFIG_CMD_MEMTEST=y
 CONFIG

[PATCH] imx: spl: Default to SPD when booting from USB serial download

2022-04-19 Thread Alban Bedel
On the iMX platforms the USB boot is in fact boot from USB serial
download and not from a USB mass storage. So returning BOOT_DEVICE_USB
typically doesn't make sense as USB SPD is then used to continue
booting, for this we need to return BOOT_DEVICE_BOARD.

Still return BOOT_DEVICE_USB when USB mass storage support has been
built in the SPL. With USB-C on both side, the programmer could switch
back to device mode and use the exposed mass storage device after the
serial download finished.

Signed-off-by: Alban Bedel 
---
 arch/arm/mach-imx/spl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 64ca29677212..2c2b2b126ad7 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -177,7 +177,8 @@ u32 spl_boot_device(void)
case QSPI_BOOT:
return BOOT_DEVICE_NOR;
case USB_BOOT:
-   return BOOT_DEVICE_USB;
+   return IS_ENABLED(CONFIG_SPL_USB_STORAGE) ?
+   BOOT_DEVICE_USB : BOOT_DEVICE_BOARD;
default:
return BOOT_DEVICE_NONE;
}
--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 0/2] usb: dwc3: Add support for standalone DWC3 nodes

2022-04-20 Thread Alban Bedel
Hi all,

I recently submitted a patch to fix the support for the DWC3 controller
on the imx8mq which, unlike most DWC3 implementation, doesn't use a top
glue node with child DWC3 nodes. Instead it has the DWC3 node directly
on the main bus.

Angus Ainslie then asked why this patch was needed as he had submitted
the original support for the imx8mq. Looking into the issue it turned out
that Angus patch basically let the driver use the `port` subnodes, which
are there to define the connection to a type C connector, as DWC3 nodes.
As the board I'm working on has no type C connecor, hence no `port`
subnodes the driver just did nothing in my case.

This new series replace my previous patch (usb: dwc3-generic: Fix the
iMX8MQ support). It starts by reverting Angus patch as it was not
following the DT binding and then add support for generic DWC3 without
glue node. This fix the imx8mq case and might add support for a few
other SoC at the same time.

Alban

Alban Bedel (2):
  Revert "usb: dwc3: dwc3-generic: check the parent nodes"
  usb: dwc3: Add support for standalone DWC3 nodes

 drivers/usb/dwc3/dwc3-generic.c | 124 +---
 1 file changed, 68 insertions(+), 56 deletions(-)

--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH v2 1/2] usb: dwc3: core: fix warnings when building without driver model

2022-04-20 Thread Alban Bedel
Commit f150b8d28b4e (usb: dwc3: Enable undefined length INCR burst
type) introduced code that assign the content of dwc->dev to a
variable. But in u-boot the type of this field changes if building
with driver model enabled or not. As this variable is then only used
once just remove it and use the struct field directly.

Another issued was also introduced in fb146fbc1ae5 (usb: dwc3: core:
stop the core when it's removed) which define a static function which
is only used when the driver model is enabled. Mark this function with
__maybe_unused to supress the warning when building without driver
model.

Signed-off-by: Alban Bedel 
---
v2: Use __maybe_unused instead of an #ifdef
---
 drivers/usb/dwc3/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b592a487e001..2107a2993309 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -465,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 /* set global incr burst type configuration registers */
 static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
 {
-   struct udevice *dev = dwc->dev;
u32 cfg;

if (!dwc->incrx_size)
@@ -502,7 +501,7 @@ static void dwc3_set_incr_burst_type(struct dwc3 *dwc)
case 1:
break;
default:
-   dev_err(dev, "Invalid property\n");
+   dev_err(dwc->dev, "Invalid property\n");
break;
}

@@ -706,7 +705,7 @@ static void dwc3_gadget_run(struct dwc3 *dwc)
mdelay(100);
 }

-static void dwc3_core_stop(struct dwc3 *dwc)
+static void __maybe_unused dwc3_core_stop(struct dwc3 *dwc)
 {
u32 reg;

--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH v2 2/2] usb: dwc3: Don't build DM drivers in SPL unless DM USB is available

2022-04-20 Thread Alban Bedel
Most platform glue drivers need DM USB, if one of these driver is
enabled along with SPL without DM the build break. As the SPL might
still want to use the core DWC3 put the DM glue drivers under
ifdef CONFIG_$(SPL_)DM_USB.

Signed-off-by: Alban Bedel 
---
 drivers/usb/dwc3/Makefile | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 0dd1ba87cd94..34355048b7af 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -7,10 +7,13 @@ dwc3-y:= core.o
 obj-$(CONFIG_USB_DWC3_GADGET)  += gadget.o ep0.o

 obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
+obj-$(CONFIG_USB_DWC3_UNIPHIER)+= dwc3-uniphier.o
+obj-$(CONFIG_USB_DWC3_PHY_OMAP)+= ti_usb_phy.o
+obj-$(CONFIG_USB_DWC3_PHY_SAMSUNG) += samsung_usb_phy.o
+
+ifdef CONFIG_$(SPL_)DM_USB
 obj-$(CONFIG_USB_DWC3_MESON_G12A)  += dwc3-meson-g12a.o
 obj-$(CONFIG_USB_DWC3_MESON_GXL)   += dwc3-meson-gxl.o
 obj-$(CONFIG_USB_DWC3_GENERIC) += dwc3-generic.o
-obj-$(CONFIG_USB_DWC3_UNIPHIER)+= dwc3-uniphier.o
 obj-$(CONFIG_USB_DWC3_LAYERSCAPE)  += dwc3-layerscape.o
-obj-$(CONFIG_USB_DWC3_PHY_OMAP)+= ti_usb_phy.o
-obj-$(CONFIG_USB_DWC3_PHY_SAMSUNG) += samsung_usb_phy.o
+endif
--
2.32.0


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 2/3] imx8m: Automatically add the optee firmware node to the FDT

2022-05-16 Thread Alban Bedel
If optee is running add the firmware node to the FDT to allow the
kernel to use a more generic device tree.

Signed-off-by: Alban Bedel 
---
 arch/arm/mach-imx/imx8m/soc.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 8e23e6da326f..2a78cb6a0952 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 

 DECLARE_GLOBAL_DATA_PTR;

@@ -1347,6 +1348,14 @@ usb_modify_speed:
 #endif

cleanup_nodes_for_efi(blob);
+
+   if (rom_pointer[1]) {
+   int err = optee_add_firmware_node(blob, "linaro,optee-tz",
+ "smc");
+   if (err)
+   return err;
+   }
+
return 0;
 }
 #endif
--
2.34.1


smime.p7s
Description: S/MIME cryptographic signature


[PATCH 1/3] optee: Add an helper to add the optee firmware node in the FDT

2022-05-16 Thread Alban Bedel
Some platforms can detect if an optee firmware is running and then
manually add the firmware node to the FDT. Provide a common helper to
avoid code duplication in the board code.

Signed-off-by: Alban Bedel 
---
 include/tee/optee.h | 11 +
 lib/optee/optee.c   | 60 +
 2 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/include/tee/optee.h b/include/tee/optee.h
index 5412bc7386ec..d9a316150522 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -58,11 +58,22 @@ static inline int optee_verify_bootm_image(unsigned long 
image_addr,

 #if defined(CONFIG_OPTEE_LIB) && defined(CONFIG_OF_LIBFDT)
 int optee_copy_fdt_nodes(void *new_blob);
+
+int optee_add_firmware_node(void *fdt_blob,
+   const char *compatible,
+   const char *method);
 #else
 static inline int optee_copy_fdt_nodes(void *new_blob)
 {
return 0;
 }
+
+static inline int optee_add_firmware_node(void *fdt_blob,
+ const char *compatible,
+ const char *method)
+{
+   return 0;
+}
 #endif

 #endif /* _OPTEE_H */
diff --git a/lib/optee/optee.c b/lib/optee/optee.c
index b03622404469..8d4e110dfd04 100644
--- a/lib/optee/optee.c
+++ b/lib/optee/optee.c
@@ -65,10 +65,10 @@ error:
 #endif

 #if defined(CONFIG_OF_LIBFDT)
-static int optee_copy_firmware_node(ofnode node, void *fdt_blob)
+static int optee_set_firmware_node(void *fdt_blob, const char *compatible,
+  const char *method)
 {
-   int offs, ret, len;
-   const void *prop;
+   int offs, ret;

offs = fdt_path_offset(fdt_blob, "/firmware");
if (offs < 0) {
@@ -85,29 +85,32 @@ static int optee_copy_firmware_node(ofnode node, void 
*fdt_blob)
if (offs < 0)
return offs;

+   ret = fdt_setprop_string(fdt_blob, offs, "compatible", compatible);
+   if (ret < 0)
+   return ret;
+
+   return fdt_setprop_string(fdt_blob, offs, "method", method);
+}
+
+static int optee_copy_firmware_node(ofnode node, void *fdt_blob)
+{
+   const char *compatible, *method;
+
/* copy the compatible property */
-   prop = ofnode_get_property(node, "compatible", &len);
-   if (!prop) {
+   compatible = ofnode_read_string(node, "compatible");
+   if (!compatible) {
debug("missing OP-TEE compatible property");
return -EINVAL;
}

-   ret = fdt_setprop(fdt_blob, offs, "compatible", prop, len);
-   if (ret < 0)
-   return ret;
-
/* copy the method property */
-   prop = ofnode_get_property(node, "method", &len);
-   if (!prop) {
+   method = ofnode_read_string(node, "method");
+   if (!method) {
debug("missing OP-TEE method property");
return -EINVAL;
}

-   ret = fdt_setprop(fdt_blob, offs, "method", prop, len);
-   if (ret < 0)
-   return ret;
-
-   return 0;
+   return optee_set_firmware_node(fdt_blob, compatible, method);
 }

 int optee_copy_fdt_nodes(void *new_blob)
@@ -190,4 +193,29 @@ int optee_copy_fdt_nodes(void *new_blob)

return 0;
 }
+
+int optee_add_firmware_node(void *fdt_blob, const char *compatible,
+   const char *method)
+{
+   int ret;
+
+   /*
+* Do not proceed if the target dt already has an OP-TEE node.
+* In this case assume that the system knows better somehow,
+* so do not interfere.
+*/
+   if (fdt_check_header(fdt_blob))
+   return -EINVAL;
+
+   if (fdt_path_offset(fdt_blob, "/firmware/optee") >= 0) {
+   debug("OP-TEE Device Tree node already exists in target");
+   return 0;
+   }
+
+   ret = fdt_increase_size(fdt_blob, 512);
+   if (ret)
+   return ret;
+
+   return optee_set_firmware_node(fdt_blob, compatible, method);
+}
 #endif
--
2.34.1


smime.p7s
Description: S/MIME cryptographic signature


[PATCH] armv8: fsl-layerscape: Erratum A010315 needs PCIE support

2021-09-06 Thread Alban Bedel
Disabling PCIE support currently lead to a crash because the code for
erratum A010315 is still run. Add a conditional to only select
CONFIG_SYS_FSL_ERRATUM_A010315 when CONFIG_PCIE_LAYERSCAPE is enabled.

Signed-off-by: Alban Bedel 
---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 9cef363fbaab..65ddff8ddb2f 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -8,7 +8,7 @@ config ARCH_LS1012A
select SYS_HAS_SERDES
select SYS_FSL_DDR_BE
select SYS_FSL_MMDC
-   select SYS_FSL_ERRATUM_A010315
+   select SYS_FSL_ERRATUM_A010315 if PCIE_LAYERSCAPE
select SYS_FSL_ERRATUM_A009798
select SYS_FSL_ERRATUM_A008997
select SYS_FSL_ERRATUM_A009007
@@ -72,7 +72,7 @@ config ARCH_LS1043A
select SYS_FSL_ERRATUM_A009663 if !TFABOOT
select SYS_FSL_ERRATUM_A009798
select SYS_FSL_ERRATUM_A009942 if !TFABOOT
-   select SYS_FSL_ERRATUM_A010315
+   select SYS_FSL_ERRATUM_A010315 if PCIE_LAYERSCAPE
select SYS_FSL_ERRATUM_A010539
select SYS_FSL_HAS_DDR3
select SYS_FSL_HAS_DDR4
-- 
2.30.2



[PATCH] armv8: fsl-layerscape: Fix automatic setting of bootmcd with TF-A

2020-11-17 Thread Alban Bedel
When booting from TF-A there is a logic that attempt to detect if the
default environment is used, if this is the case it then set the
`bootcmd` and `mcinitcmd` depending of the device we booted from.
This detection logic is dubious as it access internals of the env
implementation and it doesn't always work correctly.

First of all it detect any valid environment as not being the
default, so after running `env default -a && saveenv` the board
doesn't boot anymore as `bootcmd` is then empty.
But it also fails in some other ways, for example it always detect a
default environment when redundant env is enabled on MMC, so in that
case `bootcmd` is overwritten on every boot.

Instead of increasing the complexity of the detection just check if
`bootcmd` and `mcinitcmd` are set in the environment and set them if
they are not.

Signed-off-by: Alban Bedel 
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 -
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 96b2775f3f..af9399278f 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -33,13 +33,10 @@
 #include 
 #endif
 #include 
-#ifdef CONFIG_TFABOOT
-#include 
-#endif
 #include 
 #include 
 #include 
-#if defined(CONFIG_TFABOOT) || defined(CONFIG_GIC_V3_ITS)
+#ifdef CONFIG_GIC_V3_ITS
 DECLARE_GLOBAL_DATA_PTR;
 #endif
 
@@ -954,28 +951,12 @@ int board_late_init(void)
 #endif
 #ifdef CONFIG_TFABOOT
/*
-* check if gd->env_addr is default_environment; then setenv bootcmd
-* and mcinitcmd.
-*/
-#ifdef CONFIG_SYS_RELOC_GD_ENV_ADDR
-   if (gd->env_addr == (ulong)&default_environment[0]) {
-#else
-   if (gd->env_addr + gd->reloc_off == (ulong)&default_environment[0]) {
-#endif
-   fsl_setenv_bootcmd();
-   fsl_setenv_mcinitcmd();
-   }
-
-   /*
-* If the boot mode is secure, default environment is not present then
-* setenv command needs to be run by default
+* Set bootcmd and mcinitcmd if they don't exist in the environment.
 */
-#ifdef CONFIG_CHAIN_OF_TRUST
-   if ((fsl_check_boot_mode_secure() == 1)) {
+   if (!env_get("bootcmd"))
fsl_setenv_bootcmd();
+   if (!env_get("mcinitcmd"))
fsl_setenv_mcinitcmd();
-   }
-#endif
 #endif
 #ifdef CONFIG_QSPI_AHB_INIT
qspi_ahb_init();
-- 
2.25.1



[U-Boot] [PATCH 2/2] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-09-04 Thread Alban Bedel
Add support for the new Tamonten™ NG platform from Avionic Design.
Currently only I2C, MMC, USB and ethernet have been tested.

Signed-off-by: Alban Bedel 
---
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  | 129 +++
 board/avionic-design/dts/tegra30-tamonten.dtsi |  74 
 board/avionic-design/dts/tegra30-tec-ng.dts|   8 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 7 files changed, 713 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

diff --git a/board/avionic-design/common/pinmux-config-tamonten-ng.h 
b/board/avionic-design/common/pinmux-config-tamonten-ng.h
new file mode 100644
index 000..39df731
--- /dev/null
+++ b/board/avionic-design/common/pinmux-config-tamonten-ng.h
@@ -0,0 +1,385 @@
+/*
+ * (C) Copyright 2013
+ * Avionic Design GmbH 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _PINMUX_CONFIG_TAMONTEN_NG_H_
+#define _PINMUX_CONFIG_TAMONTEN_NG_H_
+
+#define DEFAULT_PINMUX(_pingroup, _mux, _pull, _tri, _io)  \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_DEFAULT,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define I2C_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _od) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_##_od,\
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define LV_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _ioreset) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_##_ioreset  \
+   }
+
+#define DEFAULT_PADCFG(_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, 
_hsm) \
+   {   \
+   .padgrp = PDRIVE_PINGROUP_##_padgrp,\
+   .slwf   = _slwf,\
+   .slwr   = _slwr,\
+   .drvup  = _drvup,   \
+   .drvdn  = _drvdn,   \
+   .lpmd   = PGRP_LPMD_##_lpmd,\
+   .schmt  = PGRP_SCHMT_##_schmt,  \
+   .hsm= PGRP_HSM_##_hsm,  \
+   }
+
+static struct pingroup_config tamonten_ng_pinmux_common[] = {
+   /* SDMMC1 pinmux */
+   DEFAULT_PINMUX(SDMMC1_CLK,  SDMMC1, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_CMD,  SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT0, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT1, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT2, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT3, SDMMC1, UP, NORMAL, INPUT),
+
+   /* SDMMC3 pinmux */
+   DEFAULT_PINMUX(SDMMC3_CLK,  SDMMC3, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_CMD,  SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT0, SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT1, SDMMC3, UP, NORMAL, INPUT

[U-Boot] [PATCH 1/2] ARM: tegra: support SKU b1 of Tegra30

2013-09-04 Thread Alban Bedel
Add the Tegra30 SKU b1 and treat it like other Tegra30 chips.

Signed-off-by: Alban Bedel 
Reviewed-by: Julian Scheel 
---
 arch/arm/cpu/tegra-common/ap.c  | 1 +
 arch/arm/include/asm/arch-tegra/tegra.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/cpu/tegra-common/ap.c b/arch/arm/cpu/tegra-common/ap.c
index 6fb11cb..9e4085c 100644
--- a/arch/arm/cpu/tegra-common/ap.c
+++ b/arch/arm/cpu/tegra-common/ap.c
@@ -71,6 +71,7 @@ int tegra_get_chip_sku(void)
switch (sku_id) {
case SKU_ID_T33:
case SKU_ID_T30:
+   case SKU_ID_T30MQS:
return TEGRA_SOC_T30;
}
break;
diff --git a/arch/arm/include/asm/arch-tegra/tegra.h 
b/arch/arm/include/asm/arch-tegra/tegra.h
index 25d1fc4..6b6ce85 100644
--- a/arch/arm/include/asm/arch-tegra/tegra.h
+++ b/arch/arm/include/asm/arch-tegra/tegra.h
@@ -65,6 +65,7 @@ enum {
SKU_ID_T25E = 0x1c,
SKU_ID_T33  = 0x80,
SKU_ID_T30  = 0x81, /* Cardhu value */
+   SKU_ID_T30MQS   = 0xb1,
SKU_ID_T114_ENG = 0x00, /* Dalmore value, unfused */
SKU_ID_T114_1   = 0x01,
 };
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-09-05 Thread Alban Bedel
On Wed, 04 Sep 2013 12:05:00 -0600
Stephen Warren  wrote:

> On 09/04/2013 07:00 AM, Alban Bedel wrote:
> > Add support for the new Tamonten™ NG platform from Avionic Design. 
> > Currently only I2C, MMC, USB and ethernet have been tested.
> 
> (Also CC'ing the Tegra maintainer here)

Ok, I'll add him in the next patch round.

> > diff --git a/board/avionic-design/common/tamonten-ng.c
> > b/board/avionic-design/common/tamonten-ng.c
> >
> > +void pmu_write(uchar reg, uchar data)
> > +{
> > +   int i;
> > +   i2c_set_bus_num(0); /* PMU is on bus 0 */
> > +   for (i = 0; i < MAX_I2C_RETRY; ++i) {
> > +   if (i2c_write(PMU_I2C_ADDRESS, reg, 1, &data, 1))
> > +   udelay(100);
> > +   else
> > +   break;
> > +   }
> > +}
> 
> Is there really a need to retry the I2C transactions? If so, why do
> they fail? I assume this was just copy/pasted from some other board
> file, and there's no need for any retries?

Yes, that was adapted from the cardhu code and the retry are most
probably useless. I just made a bit more generic function because
we have to set several outputs, on cardhu only one is set.

> It'd be nice if there was a proper PMU subsystem, so we could have a
> specific driver for each PMU chip, rather than having
> open-coded/custom writes to the PMU registers in each board file, but
> I guess that's not an issue with this patch specfically.

A PMU subsystem would be nice, although something that would be
compatible with the Linux regulator and their representation in DT
would be even better.

Otherwise a first step could be to at least create a driver for this
PMU, similar to one for tps6586x. That would at least prevent too much
code duplication between the T30 boards.

> > diff --git a/include/configs/tec-ng.h b/include/configs/tec-ng.h
> >
> > +/* support the new (FDT-based) image format */
> > +#define CONFIG_FIT
> 
> Hmmm. Do the standard Tegra boot scripts in tegra-common-post.h deal
> well with FIT? I've tried to avoid FIT usage as much as possible.

AFAIU it doesn't change anything if you use old images, it just allow
you to also use FIT image. As the build system we use for our platform
produce FIT image we do need support for it. Or should such things,
which are not related to the HW config, be configured in another place?

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] ARM: tegra: support SKU b1 of Tegra30

2013-09-23 Thread Alban Bedel
On Fri, 20 Sep 2013 10:57:42 -0700
Tom Warren  wrote:

> Alban,
> 
> Were you going to do a V2 of this patchset? 

I expected to, but up to now there was no concrete change request.
Should I split the PMU stuff to its own mini driver, or is it
acceptable as is for now?

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: tegra: Use the IRAM for the early stack

2013-12-09 Thread Alban Bedel
On Mon, 09 Dec 2013 10:09:49 -0700
Stephen Warren  wrote:

> On 12/09/2013 10:06 AM, Alban Bedel wrote:
> > Unlike many other platforms the tegra platform has the luxury of
> > already having the SDRAM running during the early init, and it is used
> > for the early stack. However the memory test of the POST subsystem is
> > expecting the SDRAM to be unused, and on tegra platforms the test fail
> > to run as it destroy the stack.
> > 
> > To fix the problem simply use the IRAM for the initial stack.
> 
> Can't the POST code simply touch an unused RAM address?

The memtest is run pre-relocation to in fact avoid having to take care
about some special memory regions, beside the u-boot image and
pre-relocation code.

> There is IRAM content that needs to be preserved, so we need to make
> sure we don't stomp on that. Examples are:
> 
> * BIT (Boot Information Table)
> * BCT that was used to boot the system
> * Perhaps the whole IRAM is filled with code/data in the LP0
> suspend/resume case.

BIC and BCT shouldn't be problem if enough IRAM is left for the
relocation. After relocation the stack move to the SDRAM anyway.

But for LP0 I don't really understand what the problem would be. Do the
u-boot loading+relocation needs to be run when comming out of LP0?

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] board: tec-ng: Do not make directories in a board Makefile

2014-01-14 Thread Alban Bedel
On Tue, 14 Jan 2014 10:55:02 +0900
Masahiro Yamada  wrote:

> Commit e5c5301f refactored the build system not to make
> directories in board makefiles.
> But commit 8f380381 create directories again in
> board/avionic-design/tec-ng/Makefile.
> 
> Signed-off-by: Masahiro Yamada 
> Cc: Alban Bedel 

Acked-by: Alban Bedel 

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ARM: tegra20: Add a missing entry in the pullid enum

2014-01-15 Thread Alban Bedel
It seems two entries were merged in one when this file has been
created. The GPSLXAU entries is obviously a mix of GPU and SLXA which
are next to each other according to the datasheet. Moreover it can be
noticed because the APB_MISC_PP_PULLUPDOWN_REG_B_0 register only have
15 entries instead of 16.

Also fix the pin group descriptions that were using these buggy
entries. In particular SLXA that needed to used CRTP to actually
write the SLXA register.

Signed-off-by: Alban Bedel 
---
 arch/arm/cpu/tegra20-common/pinmux.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/tegra20-common/pinmux.c 
b/arch/arm/cpu/tegra20-common/pinmux.c
index a65e991..5c80ed9 100644
--- a/arch/arm/cpu/tegra20-common/pinmux.c
+++ b/arch/arm/cpu/tegra20-common/pinmux.c
@@ -190,7 +190,8 @@ enum pmux_pullid {
 
PUCTL_SPDI,
PUCTL_SPDO,
-   PUCTL_GPSLXAU,
+   PUCTL_GPU,
+   PUCTL_SLXA,
PUCTL_CRTP,
PUCTL_SLXC,
PUCTL_SLXD,
@@ -333,8 +334,7 @@ const struct tegra_pingroup_desc 
tegra_soc_pingroups[PINGRP_COUNT] = {
PIN(DTD,  VI,RSVD,   SDIO2,  VI,RSVD,RSVD1),
PIN(DTE,  VI,RSVD,   RSVD,   VI,SPI1,RSVD1),
 
-   PINP(GPU, UART,  PWM,UARTA,  GMI,   RSVD,RSVD4,
-   GPSLXAU),
+   PIN(GPU,  UART,  PWM,UARTA,  GMI,   RSVD,RSVD4),
PIN(GPV,  SD,PCIE,   RSVD,   RSVD,  RSVD,PCIE),
PIN(I2CP, SYS,   I2C,RSVD,   RSVD,  RSVD,RSVD4),
PIN(IRTX, UART,  UARTA,  UARTB,  GMI,   SPI4,UARTB),
@@ -356,7 +356,7 @@ const struct tegra_pingroup_desc 
tegra_soc_pingroups[PINGRP_COUNT] = {
PIN(SDC,  SD,PWM,TWC,SDIO3, SPI3,TWC),
PIN(SDD,  SD,UARTA,  PWM,SDIO3, SPI3,PWM),
PIN_RESERVED,
-   PINP(SLXA, SD,   PCIE,   SPI4,   SDIO3, SPI2,PCIE, CRTP),
+   PIN(SLXA, SD,PCIE,   SPI4,   SDIO3, SPI2,PCIE),
PIN(SLXC, SD,SPDIF,  SPI4,   SDIO3, SPI2,SPI4),
PIN(SLXD, SD,SPDIF,  SPI4,   SDIO3, SPI2,SPI4),
PIN(SLXK, SD,PCIE,   SPI4,   SDIO3, SPI2,PCIE),
-- 
1.8.5.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: tegra20: Add a missing entry in the pullid enum

2014-01-20 Thread Alban Bedel
On Wed, 15 Jan 2014 11:36:03 -0700
Stephen Warren  wrote:

> On 01/15/2014 07:55 AM, Alban Bedel wrote:
> > It seems two entries were merged in one when this file has been
> > created. The GPSLXAU entries is obviously a mix of GPU and SLXA which
> > are next to each other according to the datasheet. Moreover it can be
> > noticed because the APB_MISC_PP_PULLUPDOWN_REG_B_0 register only have
> > 15 entries instead of 16.
> > 
> > Also fix the pin group descriptions that were using these buggy
> > entries. In particular SLXA that needed to used CRTP to actually
> > write the SLXA register.
> 
> This does appear to match the kernel's pinctrl driver, so,
> Acked-by: Stephen Warren 
> 
> I wonder how many more similar issues there are. Did you check the whole
> file for this kind of issue, or just debug a problem with one particular
> pin/group?

I found this while trying to get the internal pull up enabled on UARTD.
Afterwards I checked the whole enum and the table but everything else
seems to be correct.

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] ARM: tegra: support SKU b1 of Tegra30

2013-10-17 Thread Alban Bedel
On Mon, 23 Sep 2013 17:23:12 -0700
Tom Warren  wrote:

> It's fine as-is for now. Send a V2 with any changes Stephen, et al requested
> (if any), and I'll get it into tegra-next when I return from vacation
> next Monday (assuming it's been Acked).

What is the status with this patch serie? I'd really like to get it
merged during this window if possible.

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-10-17 Thread Alban Bedel
Add support for the new Tamonten™ NG platform from Avionic Design.
Currently only I2C, MMC, USB and ethernet have been tested.

Signed-off-by: Alban Bedel 
---
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  | 129 +++
 board/avionic-design/dts/tegra30-tamonten.dtsi |  74 
 board/avionic-design/dts/tegra30-tec-ng.dts|   8 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 7 files changed, 713 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

diff --git a/board/avionic-design/common/pinmux-config-tamonten-ng.h 
b/board/avionic-design/common/pinmux-config-tamonten-ng.h
new file mode 100644
index 000..39df731
--- /dev/null
+++ b/board/avionic-design/common/pinmux-config-tamonten-ng.h
@@ -0,0 +1,385 @@
+/*
+ * (C) Copyright 2013
+ * Avionic Design GmbH 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _PINMUX_CONFIG_TAMONTEN_NG_H_
+#define _PINMUX_CONFIG_TAMONTEN_NG_H_
+
+#define DEFAULT_PINMUX(_pingroup, _mux, _pull, _tri, _io)  \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_DEFAULT,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define I2C_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _od) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_##_od,\
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define LV_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _ioreset) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_##_ioreset  \
+   }
+
+#define DEFAULT_PADCFG(_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, 
_hsm) \
+   {   \
+   .padgrp = PDRIVE_PINGROUP_##_padgrp,\
+   .slwf   = _slwf,\
+   .slwr   = _slwr,\
+   .drvup  = _drvup,   \
+   .drvdn  = _drvdn,   \
+   .lpmd   = PGRP_LPMD_##_lpmd,\
+   .schmt  = PGRP_SCHMT_##_schmt,  \
+   .hsm= PGRP_HSM_##_hsm,  \
+   }
+
+static struct pingroup_config tamonten_ng_pinmux_common[] = {
+   /* SDMMC1 pinmux */
+   DEFAULT_PINMUX(SDMMC1_CLK,  SDMMC1, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_CMD,  SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT0, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT1, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT2, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT3, SDMMC1, UP, NORMAL, INPUT),
+
+   /* SDMMC3 pinmux */
+   DEFAULT_PINMUX(SDMMC3_CLK,  SDMMC3, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_CMD,  SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT0, SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT1, SDMMC3, UP, NORMAL, INPUT

[U-Boot] [PATCH v2 0/2] ARM: tegra: Add the Tamonten-NG Evaluation carrier boards

2013-10-17 Thread Alban Bedel
Hi all,

This new serie has been rebased on the current master from denx and the SKU
0xb1 names has been changed to SKU_ID_TM30MQS_A3 to better reflect nvidia's
internal namming.

Alban Bedel (2):
  ARM: tegra: support SKU b1 of Tegra30
  ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

 arch/arm/cpu/tegra-common/ap.c |   1 +
 arch/arm/include/asm/arch-tegra/tegra.h|   1 +
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  | 129 +++
 board/avionic-design/dts/tegra30-tamonten.dtsi |  74 
 board/avionic-design/dts/tegra30-tec-ng.dts|   8 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 9 files changed, 715 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/2] ARM: tegra: support SKU b1 of Tegra30

2013-10-17 Thread Alban Bedel
Add the Tegra30 SKU b1 and treat it like other Tegra30 chips.

Signed-off-by: Alban Bedel 
Reviewed-by: Julian Scheel 
---
 arch/arm/cpu/tegra-common/ap.c  | 1 +
 arch/arm/include/asm/arch-tegra/tegra.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/cpu/tegra-common/ap.c b/arch/arm/cpu/tegra-common/ap.c
index 6fb11cb..6b050fb 100644
--- a/arch/arm/cpu/tegra-common/ap.c
+++ b/arch/arm/cpu/tegra-common/ap.c
@@ -71,6 +71,7 @@ int tegra_get_chip_sku(void)
switch (sku_id) {
case SKU_ID_T33:
case SKU_ID_T30:
+   case SKU_ID_TM30MQS_A3:
return TEGRA_SOC_T30;
}
break;
diff --git a/arch/arm/include/asm/arch-tegra/tegra.h 
b/arch/arm/include/asm/arch-tegra/tegra.h
index 25d1fc4..49d9465 100644
--- a/arch/arm/include/asm/arch-tegra/tegra.h
+++ b/arch/arm/include/asm/arch-tegra/tegra.h
@@ -65,6 +65,7 @@ enum {
SKU_ID_T25E = 0x1c,
SKU_ID_T33  = 0x80,
SKU_ID_T30  = 0x81, /* Cardhu value */
+   SKU_ID_TM30MQS_A3   = 0xb1,
SKU_ID_T114_ENG = 0x00, /* Dalmore value, unfused */
SKU_ID_T114_1   = 0x01,
 };
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-10-21 Thread Alban Bedel
Add support for the new Tamonten™ NG platform from Avionic Design.
Currently only I2C, MMC, USB and ethernet have been tested.

Signed-off-by: Alban Bedel 
---
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  | 110 ++
 board/avionic-design/dts/tegra30-tamonten.dtsi |  74 
 board/avionic-design/dts/tegra30-tec-ng.dts|   8 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 7 files changed, 694 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

diff --git a/board/avionic-design/common/pinmux-config-tamonten-ng.h 
b/board/avionic-design/common/pinmux-config-tamonten-ng.h
new file mode 100644
index 000..39df731
--- /dev/null
+++ b/board/avionic-design/common/pinmux-config-tamonten-ng.h
@@ -0,0 +1,385 @@
+/*
+ * (C) Copyright 2013
+ * Avionic Design GmbH 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _PINMUX_CONFIG_TAMONTEN_NG_H_
+#define _PINMUX_CONFIG_TAMONTEN_NG_H_
+
+#define DEFAULT_PINMUX(_pingroup, _mux, _pull, _tri, _io)  \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_DEFAULT,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define I2C_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _od) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_##_od,\
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define LV_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _ioreset) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_##_ioreset  \
+   }
+
+#define DEFAULT_PADCFG(_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, 
_hsm) \
+   {   \
+   .padgrp = PDRIVE_PINGROUP_##_padgrp,\
+   .slwf   = _slwf,\
+   .slwr   = _slwr,\
+   .drvup  = _drvup,   \
+   .drvdn  = _drvdn,   \
+   .lpmd   = PGRP_LPMD_##_lpmd,\
+   .schmt  = PGRP_SCHMT_##_schmt,  \
+   .hsm= PGRP_HSM_##_hsm,  \
+   }
+
+static struct pingroup_config tamonten_ng_pinmux_common[] = {
+   /* SDMMC1 pinmux */
+   DEFAULT_PINMUX(SDMMC1_CLK,  SDMMC1, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_CMD,  SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT0, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT1, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT2, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT3, SDMMC1, UP, NORMAL, INPUT),
+
+   /* SDMMC3 pinmux */
+   DEFAULT_PINMUX(SDMMC3_CLK,  SDMMC3, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_CMD,  SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT0, SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT1, SDMMC3, UP, NORMAL, INPUT

Re: [U-Boot] [PATCH v3] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-10-30 Thread Alban Bedel
On Mon, 28 Oct 2013 16:00:06 -0600
Stephen Warren  wrote:

> On 10/21/2013 08:28 AM, Alban Bedel wrote:
> > Add support for the new Tamonten™ NG platform from Avionic Design.
> > Currently only I2C, MMC, USB and ethernet have been tested.
> 
> What changed in v3? There's no changelog here, so I don't know where to
> concentrate my re-review of this patch...

I'll add one. It was unclear to me how these should be done, and it
took me quiet some times to find out about this 3 dashes hidden
feature.

> > diff --git a/board/avionic-design/common/tamonten-ng.c 
> > b/board/avionic-design/common/tamonten-ng.c
> 
> > +#define MAX_I2C_RETRY  3
> 
> I don't think that's used any more.

I'll remove it.

> Most of the PMU #defines aren't used either.

I'll remove them too, althought I hate having hardcoded values in the
code instead of a human readable definition of the registers.

> > +#ifdef CONFIG_BOARD_EARLY_INIT_F
> 
> I don't think any of these ifdefs are required, since the config file
> hard-codes all those values. Same for #if defined(CONFIG_TEGRA_MMC)
> below, and perhaps more?

Will do.

> > +void gpio_early_init(void)
> > +{
> > +   /* Turn on the alive signal */
> > +   gpio_request(GPIO_PV2, "ALIVE");
> > +   gpio_direction_output(GPIO_PV2, 1);
> > +
> > +   /* Remove the reset on the reset on the external periph */
> 
> "reset on the reset on the" ?
> 
> > diff --git a/board/avionic-design/dts/tegra30-tamonten.dtsi 
> > b/board/avionic-design/dts/tegra30-tamonten.dtsi
> 
> > +   i2c@7000c000 {
> > +   status = "okay";
> > +   clock-frequency = <10>;
> > +   };
> > +
> > +   i2c@7000c400 {
> > +   status = "okay";
> > +   clock-frequency = <10>;
> > +   };
> ...
> 
> Do all the carrier boards guarantee that all those I2C and SPI, and even
> SDHCI busses are routed somewhere? It may be best to defer adding
> status="okay" to the leaf board files, so you know there's actually
> something hooked up there.

Most of these are on the COM module, but you are right, a few of them
shouldn't have status="okay" in this dtsi.

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 2/3] i2c: tegra: Add the fifth bus on SoC with more than 4 buses

2013-11-13 Thread Alban Bedel
Create the i2c adapter object for the fifth bus on SoC with more than
4 buses. This allow using all the bus available on T30.

Signed-off-by: Alban Bedel 
---
 drivers/i2c/tegra_i2c.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 9847cf1..594e5dd 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -629,3 +629,8 @@ U_BOOT_I2C_ADAP_COMPLETE(tegra2, tegra_i2c_init, 
tegra_i2c_probe,
 U_BOOT_I2C_ADAP_COMPLETE(tegra3, tegra_i2c_init, tegra_i2c_probe,
 tegra_i2c_read, tegra_i2c_write,
 tegra_i2c_set_bus_speed, 10, 0, 3)
+#if TEGRA_I2C_NUM_CONTROLLERS > 4
+U_BOOT_I2C_ADAP_COMPLETE(tegra4, tegra_i2c_init, tegra_i2c_probe,
+tegra_i2c_read, tegra_i2c_write,
+tegra_i2c_set_bus_speed, 10, 0, 4)
+#endif
-- 
1.8.4.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 1/3] ARM: tegra: support SKU b1 of Tegra30

2013-11-13 Thread Alban Bedel
Add the Tegra30 SKU b1 and treat it like other Tegra30 chips.

Signed-off-by: Alban Bedel 
Reviewed-by: Julian Scheel 
---
V4: Renamed SKU_ID_TM30MQS_A3 to SKU_ID_TM30MQS_P_A3, according to
Thierry Reding this ID should be better suited as there is another
TM30MQS variant with another SKU.

Signed-off-by: Alban Bedel 
---
 arch/arm/cpu/tegra-common/ap.c  | 1 +
 arch/arm/include/asm/arch-tegra/tegra.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/cpu/tegra-common/ap.c b/arch/arm/cpu/tegra-common/ap.c
index 6fb11cb..60d71a6 100644
--- a/arch/arm/cpu/tegra-common/ap.c
+++ b/arch/arm/cpu/tegra-common/ap.c
@@ -71,6 +71,7 @@ int tegra_get_chip_sku(void)
switch (sku_id) {
case SKU_ID_T33:
case SKU_ID_T30:
+   case SKU_ID_TM30MQS_P_A3:
return TEGRA_SOC_T30;
}
break;
diff --git a/arch/arm/include/asm/arch-tegra/tegra.h 
b/arch/arm/include/asm/arch-tegra/tegra.h
index 25d1fc4..e99f681 100644
--- a/arch/arm/include/asm/arch-tegra/tegra.h
+++ b/arch/arm/include/asm/arch-tegra/tegra.h
@@ -65,6 +65,7 @@ enum {
SKU_ID_T25E = 0x1c,
SKU_ID_T33  = 0x80,
SKU_ID_T30  = 0x81, /* Cardhu value */
+   SKU_ID_TM30MQS_P_A3 = 0xb1,
SKU_ID_T114_ENG = 0x00, /* Dalmore value, unfused */
SKU_ID_T114_1   = 0x01,
 };
-- 
1.8.4.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 3/3] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-11-13 Thread Alban Bedel
Add support for the new Tamonten™ NG platform from Avionic Design.
Currently only I2C, MMC, USB and ethernet have been tested.

Signed-off-by: Alban Bedel 
---
V3: * Removed the retries from pmu_write()
* Removed the not strictly needed power init
V4: * Removed the unused PMU defines
* Removed the useless #ifdef
* Reworked the DTS to enable the device at the proper level
* Re-numbered the i2c bus to match the kernel numbering

Signed-off-by: Alban Bedel 
---
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  |  85 +
 board/avionic-design/dts/tegra30-tamonten.dtsi |  69 
 board/avionic-design/dts/tegra30-tec-ng.dts|  18 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 7 files changed, 674 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

diff --git a/board/avionic-design/common/pinmux-config-tamonten-ng.h 
b/board/avionic-design/common/pinmux-config-tamonten-ng.h
new file mode 100644
index 000..39df731
--- /dev/null
+++ b/board/avionic-design/common/pinmux-config-tamonten-ng.h
@@ -0,0 +1,385 @@
+/*
+ * (C) Copyright 2013
+ * Avionic Design GmbH 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _PINMUX_CONFIG_TAMONTEN_NG_H_
+#define _PINMUX_CONFIG_TAMONTEN_NG_H_
+
+#define DEFAULT_PINMUX(_pingroup, _mux, _pull, _tri, _io)  \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_DEFAULT,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define I2C_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _od) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_##_od,\
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define LV_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _ioreset) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_##_ioreset  \
+   }
+
+#define DEFAULT_PADCFG(_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, 
_hsm) \
+   {   \
+   .padgrp = PDRIVE_PINGROUP_##_padgrp,\
+   .slwf   = _slwf,\
+   .slwr   = _slwr,\
+   .drvup  = _drvup,   \
+   .drvdn  = _drvdn,   \
+   .lpmd   = PGRP_LPMD_##_lpmd,\
+   .schmt  = PGRP_SCHMT_##_schmt,  \
+   .hsm= PGRP_HSM_##_hsm,  \
+   }
+
+static struct pingroup_config tamonten_ng_pinmux_common[] = {
+   /* SDMMC1 pinmux */
+   DEFAULT_PINMUX(SDMMC1_CLK,  SDMMC1, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_CMD,  SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT0, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT1, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT2, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT3, SDMMC1, UP, NORMAL

[U-Boot] [PATCH v4 0/3] ARM: tegra: Add the Tamonten-NG Evaluation carrier boards

2013-11-13 Thread Alban Bedel
Hi everyone,

I hope everything requiered is there this time:

* The SKU ID has been changed to SKU_ID_T30MQS_P_A3 as suggested by
  Thierry
* A new patch has been added to enable the 5th i2c bus on T30, this is
  now needed because:
* The i2c buses have been re-numbered to match the numbering used in
  the kernel
* The DTS has been re-worked to better reflect the split between COM
  and base board. For the i2c buses the split was done according to
  where the pull-ups are. So buses enabled in the COM dts have their
  pull-ups on the COM module.
* All the "useless" defines have now been removed.

Alban Bedel (3):
  ARM: tegra: support SKU b1 of Tegra30
  i2c: tegra: Add the fifth bus on SoC with more than 4 buses
  ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

 arch/arm/cpu/tegra-common/ap.c |   1 +
 arch/arm/include/asm/arch-tegra/tegra.h|   1 +
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  |  85 +
 board/avionic-design/dts/tegra30-tamonten.dtsi |  69 
 board/avionic-design/dts/tegra30-tec-ng.dts|  18 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 drivers/i2c/tegra_i2c.c|   5 +
 include/configs/tec-ng.h   |  84 +
 10 files changed, 681 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

-- 
1.8.4.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-11-14 Thread Alban Bedel
Add support for the new Tamonten™ NG platform from Avionic Design.
Currently only I2C, MMC, USB and ethernet have been tested.

Signed-off-by: Alban Bedel 
---
V3: * Removed the retries from pmu_write()
* Removed the not strictly needed power init
V4: * Removed the unused PMU defines
* Removed the useless #ifdef
* Reworked the DTS to enable the device at the proper level
* Re-numbered the i2c bus to match the numbering we use in kernel
V5: * Updated the board Makefile to use the new style
---
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  |  85 +
 board/avionic-design/dts/tegra30-tamonten.dtsi |  69 
 board/avionic-design/dts/tegra30-tec-ng.dts|  18 +
 board/avionic-design/tec-ng/Makefile   |  12 +
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 7 files changed, 654 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

diff --git a/board/avionic-design/common/pinmux-config-tamonten-ng.h 
b/board/avionic-design/common/pinmux-config-tamonten-ng.h
new file mode 100644
index 000..39df731
--- /dev/null
+++ b/board/avionic-design/common/pinmux-config-tamonten-ng.h
@@ -0,0 +1,385 @@
+/*
+ * (C) Copyright 2013
+ * Avionic Design GmbH 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _PINMUX_CONFIG_TAMONTEN_NG_H_
+#define _PINMUX_CONFIG_TAMONTEN_NG_H_
+
+#define DEFAULT_PINMUX(_pingroup, _mux, _pull, _tri, _io)  \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_DEFAULT,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define I2C_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _od) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_##_od,\
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define LV_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _ioreset) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_##_ioreset  \
+   }
+
+#define DEFAULT_PADCFG(_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, 
_hsm) \
+   {   \
+   .padgrp = PDRIVE_PINGROUP_##_padgrp,\
+   .slwf   = _slwf,\
+   .slwr   = _slwr,\
+   .drvup  = _drvup,   \
+   .drvdn  = _drvdn,   \
+   .lpmd   = PGRP_LPMD_##_lpmd,\
+   .schmt  = PGRP_SCHMT_##_schmt,  \
+   .hsm= PGRP_HSM_##_hsm,  \
+   }
+
+static struct pingroup_config tamonten_ng_pinmux_common[] = {
+   /* SDMMC1 pinmux */
+   DEFAULT_PINMUX(SDMMC1_CLK,  SDMMC1, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_CMD,  SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT0, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT1, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT2, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX

[U-Boot] [PATCH] arm: tegra: Fix the CPU complex reset masks

2013-11-20 Thread Alban Bedel
The CPU complex reset masks are not matching with the datasheet for
the CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET/CLR_0 registers. For both T20
and T30 the register consist of groups of 4 bits, with one bit for
each CPU core. On T20 the 2 high bits of each group are always stubbed
as there is only 2 cores.

Signed-off-by: Alban Bedel 
---
 arch/arm/include/asm/arch-tegra/clock.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra/clock.h 
b/arch/arm/include/asm/arch-tegra/clock.h
index c3174bd..e7d0fd4 100644
--- a/arch/arm/include/asm/arch-tegra/clock.h
+++ b/arch/arm/include/asm/arch-tegra/clock.h
@@ -113,9 +113,9 @@ void reset_set_enable(enum periph_id periph_id, int enable);
 enum crc_reset_id {
/* Things we can hold in reset for each CPU */
crc_rst_cpu = 1,
-   crc_rst_de = 1 << 2,/* What is de? */
-   crc_rst_watchdog = 1 << 3,
-   crc_rst_debug = 1 << 4,
+   crc_rst_de = 1 << 4,/* What is de? */
+   crc_rst_watchdog = 1 << 8,
+   crc_rst_debug = 1 << 12,
 };
 
 /**
-- 
1.8.4.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: tegra: Fix the CPU complex reset masks

2013-11-25 Thread Alban Bedel
On Thu, 21 Nov 2013 13:26:07 -0700
Stephen Warren  wrote:

> On 11/20/2013 09:42 AM, Alban Bedel wrote:
> > The CPU complex reset masks are not matching with the datasheet for
> > the CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET/CLR_0 registers. For both T20
> > and T30 the register consist of groups of 4 bits, with one bit for
> > each CPU core. On T20 the 2 high bits of each group are always stubbed
> > as there is only 2 cores.
> 
> This looks correct to me. Given this problem, it's surprising that
> reset_A9_cpu() was operating correctly, and that secondary CPUs were
> coming out of reset OK later. What testing has this had (which SoCs and
> boards)?

I only tested it on T30 using our Tamonten NG board.

Alban
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ARM: tegra: Use the IRAM for the early stack

2013-12-09 Thread Alban Bedel
Unlike many other platforms the tegra platform has the luxury of
already having the SDRAM running during the early init, and it is used
for the early stack. However the memory test of the POST subsystem is
expecting the SDRAM to be unused, and on tegra platforms the test fail
to run as it destroy the stack.

To fix the problem simply use the IRAM for the initial stack.

Signed-off-by: Alban Bedel 
---
 include/configs/tegra-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h
index 522cd41..340f5aa 100644
--- a/include/configs/tegra-common.h
+++ b/include/configs/tegra-common.h
@@ -124,7 +124,7 @@
 
 #define CONFIG_SYS_BOOTMAPSZ   (256 << 20) /* 256M */
 
-#define CONFIG_SYS_INIT_RAM_ADDR   CONFIG_STACKBASE
+#define CONFIG_SYS_INIT_RAM_ADDR   EARLY_CPU_STACK
 #define CONFIG_SYS_INIT_RAM_SIZE   CONFIG_SYS_MALLOC_LEN
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_INIT_RAM_ADDR + \
CONFIG_SYS_INIT_RAM_SIZE - \
-- 
1.8.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] tegra20: tamonten: Fix the early gpio init

2014-10-02 Thread Alban Bedel
To set gpio during the early init we now need to use
tegra_spl_gpio_direction_output(), copied from seaboard.

Change-Id: Id0aadb17a71b78e75e8c3f8de374102b3eab767b
Signed-off-by: Alban Bedel 
---
 board/avionic-design/common/tamonten.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/avionic-design/common/tamonten.c 
b/board/avionic-design/common/tamonten.c
index 9c86779..ea2425a 100644
--- a/board/avionic-design/common/tamonten.c
+++ b/board/avionic-design/common/tamonten.c
@@ -23,8 +23,10 @@
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 void gpio_early_init(void)
 {
+#ifndef CONFIG_SPL_BUILD
gpio_request(GPIO_PI4, NULL);
-   gpio_direction_output(GPIO_PI4, 1);
+#endif
+   tegra_spl_gpio_direction_output(GPIO_PI4, 1);
 }
 #endif
 
-- 
2.1.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] tegra20: display: Add support for flipped panels

2014-10-02 Thread Alban Bedel
Add support for two new panel properties, flip-vertical and
flip-horizontal. If set the display controller will be setup to
correctly flip the image.

Change-Id: I324b5d2b0b7ebbde7e08e5f32509cf101c057c84
Signed-off-by: Alban Bedel 
---
 arch/arm/cpu/armv7/tegra20/display.c| 20 ++--
 arch/arm/include/asm/arch-tegra20/display.h |  4 
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra20/display.c 
b/arch/arm/cpu/armv7/tegra20/display.c
index fd77f3f..b332dd4 100644
--- a/arch/arm/cpu/armv7/tegra20/display.c
+++ b/arch/arm/cpu/armv7/tegra20/display.c
@@ -20,6 +20,7 @@ static void update_window(struct dc_ctlr *dc, struct 
disp_ctl_win *win)
 {
unsigned h_dda, v_dda;
unsigned long val;
+   unsigned x, y;
 
val = readl(&dc->cmd.disp_win_header);
val |= WINDOW_A_SELECT;
@@ -58,11 +59,22 @@ static void update_window(struct dc_ctlr *dc, struct 
disp_ctl_win *win)
val = WIN_ENABLE;
if (win->bpp < 24)
val |= COLOR_EXPAND;
+   if (win->flip_h)
+   val |= H_DIRECTION;
+   if (win->flip_v)
+   val |= V_DIRECTION;
writel(val, &dc->win.win_opt);
 
+   x = win->x;
+   if (win->flip_h)
+   x += (win->w - 1) * (win->bpp / 8);
+   y = win->y;
+   if (win->flip_v)
+   y += win->h - 1;
+
writel((unsigned long)win->phys_addr, &dc->winbuf.start_addr);
-   writel(win->x, &dc->winbuf.addr_h_offset);
-   writel(win->y, &dc->winbuf.addr_v_offset);
+   writel(x, &dc->winbuf.addr_h_offset);
+   writel(y, &dc->winbuf.addr_v_offset);
 
writel(0xff00, &dc->win.blend_nokey);
writel(0xff00, &dc->win.blend_1win);
@@ -204,6 +216,8 @@ int setup_window(struct disp_ctl_win *win, struct 
fdt_disp_config *config)
win->out_y = 0;
win->out_w = config->width;
win->out_h = config->height;
+   win->flip_h = config->flip_h;
+   win->flip_v = config->flip_v;
win->phys_addr = config->frame_buffer;
win->stride = config->width * (1 << config->log2_bpp) / 8;
debug("%s: depth = %d\n", __func__, config->log2_bpp);
@@ -258,6 +272,8 @@ static int tegra_decode_panel(const void *blob, int node,
 
config->width = fdtdec_get_int(blob, node, "xres", -1);
config->height = fdtdec_get_int(blob, node, "yres", -1);
+   config->flip_h = fdtdec_get_bool(blob, node, "flip-horizontal");
+   config->flip_v = fdtdec_get_bool(blob, node, "flip-vertical");
config->pixel_clock = fdtdec_get_int(blob, node, "clock", 0);
if (!config->pixel_clock || config->width == -1 ||
config->height == -1) {
diff --git a/arch/arm/include/asm/arch-tegra20/display.h 
b/arch/arm/include/asm/arch-tegra20/display.h
index a04c84e..05c7bd5 100644
--- a/arch/arm/include/asm/arch-tegra20/display.h
+++ b/arch/arm/include/asm/arch-tegra20/display.h
@@ -25,6 +25,8 @@ struct disp_ctl_win {
unsignedout_y;  /* Top edge of output window (row) */
unsignedout_w;  /* Width of output window in pixels */
unsignedout_h;  /* Height of output window in pixels */
+   unsignedflip_h; /* Horizontally flip the image */
+   unsignedflip_v; /* Vertically flip the image */
 };
 
 #define FDT_LCD_TIMINGS4
@@ -53,6 +55,8 @@ struct fdt_disp_config {
int width;  /* width in pixels */
int height; /* height in pixels */
int bpp;/* number of bits per pixel */
+   unsigned flip_h;/* Horizontally flip the image */
+   unsigned flip_v;/* Vertically flip the image */
 
/*
 * log2 of number of bpp, in general, unless it bpp is 24 in which
-- 
2.1.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] tegra20: tamonten: Fix the early gpio init

2014-10-02 Thread Alban Bedel
On Thu, 02 Oct 2014 09:42:18 -0600
Stephen Warren  wrote:

> On 10/02/2014 09:14 AM, Alban Bedel wrote:
> > To set gpio during the early init we now need to use
> > tegra_spl_gpio_direction_output(), copied from seaboard.
> >
> > Change-Id: Id0aadb17a71b78e75e8c3f8de374102b3eab767b
> 
> That shouldn't be present on upstream patches.

Sorry about this.

> > Signed-off-by: Alban Bedel 
> > ---
> >   board/avionic-design/common/tamonten.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/board/avionic-design/common/tamonten.c 
> > b/board/avionic-design/common/tamonten.c
> > index 9c86779..ea2425a 100644
> > --- a/board/avionic-design/common/tamonten.c
> > +++ b/board/avionic-design/common/tamonten.c
> > @@ -23,8 +23,10 @@
> >   #ifdef CONFIG_BOARD_EARLY_INIT_F
> >   void gpio_early_init(void)
> >   {
> > +#ifndef CONFIG_SPL_BUILD
> > gpio_request(GPIO_PI4, NULL);
> > -   gpio_direction_output(GPIO_PI4, 1);
> > +#endif
> > +   tegra_spl_gpio_direction_output(GPIO_PI4, 1);
> >   }
> 
> Surely you only want to call tegra_spl_*() from SPL, and not from 
> non-SPL code? In other words, don't you need something more like:
> 
> #ifdef CONFIG_SPL_BUILD
>   tegra_spl_gpio_direction_output(GPIO_PI4, 1);
> #else
>   gpio_request(GPIO_PI4, NULL);
>   gpio_direction_output(GPIO_PI4, 1);
> #endif

Sadly not, at this point the gpio driver isn't available yet, that's
why one need to use tegra_spl_gpio_direction_output(). As mentioned in
the commit log I copied this from seaboard, assuming it would be
correct.

AFAICT the gpio_request() could be removed too, it doesn't work at this
point anyway.

> ... although perhaps the SPL and non-SPL code should simply be separated 
> into separate files, so that there's no need for ifdefs, and it's 
> obvious if SPL and non-SPL code are duplicating the same work?

Actually none of the code from tamonten.c is needed for the SPL, a
build with both function under #ifndef CONFIG_SPL_BUILD works just fine.
Any pointer on how I can get tamonten.c out of the SPL build?

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/2] net: Add a command to access the EEPROM from ethernet devices

2014-10-07 Thread Alban Bedel
Many ethernet devices use an EEPROM to store various settings, most
commonly the device MAC address. But on some devices it can contains
a lot more, for example USB device might also have many USB related
parameters.

This commit add a set of commands to read/write this EEPROM, write a
default configuration and read/write the device MAC address. The
defaults command allow priming the EEPROM for devices that need more
than just a MAC address in the EEPROM.

Change-Id: I9f2d15f84b772dc680349c65c89e772780823745
Signed-off-by: Alban Bedel 
---
 common/cmd_net.c | 134 +++
 include/net.h|  28 
 net/eth.c|  46 +++
 3 files changed, 208 insertions(+)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 09489d4..f4952d5 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -445,3 +445,137 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
+
+#if defined(CONFIG_CMD_ETH_EEPROM)
+static int do_eth_eeprom_rw(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   ulong addr, offset, length = 1;
+
+   if (argc < 4)
+   return CMD_RET_USAGE;
+
+   addr = simple_strtoul(argv[2], NULL, 16);
+   offset = simple_strtoul(argv[3], NULL, 16);
+   if (argc > 4)
+   length = simple_strtoul(argv[4], NULL, 16);
+
+   if (!strcmp(argv[0], "write")) {
+   if (eth_eeprom_write(dev, offset, length, (void *)addr)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+   return CMD_RET_SUCCESS;
+   } else if (!strcmp(argv[0], "read")) {
+   if (eth_eeprom_read(dev, offset, length, (void *)addr)) {
+   printf("EEPROM read failed\n");
+   return CMD_RET_FAILURE;
+   }
+   return CMD_RET_SUCCESS;
+   }
+
+   return CMD_RET_USAGE;
+}
+
+static int do_eth_eeprom_defaults(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   if (eth_eeprom_defaults(dev)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom_set_mac(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   u8 mac[6];
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   eth_parse_enetaddr(argv[2], mac);
+   if (!is_valid_ether_addr(mac)) {
+   printf("Invalid mac address given\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("Writing MAC to EEPROM \n");
+   if (eth_eeprom_write_mac(dev, mac)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom_show_mac(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   u8 data[6];
+
+   if (eth_eeprom_read_mac(dev, data)) {
+   printf("EEPROM read failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%pM\n", data);
+   if (!is_valid_ether_addr(data))
+   printf("Warning: MAC address is not valid!\n");
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   struct eth_device *dev;
+   char *endp = NULL;
+   int index;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   /* Get the ethernet device, by ID or by name */
+   index = (int) simple_strtoul(argv[2], &endp, 16);
+   if (endp > argv[2])
+   dev = eth_get_dev_by_index(index);
+   else
+   dev = eth_get_dev_by_name(argv[2]);
+
+   if (!dev) {
+   printf("Ethernet device not found\n");
+   return CMD_RET_FAILURE;
+   }
+
+   if (!strcmp(argv[1], "read") || !strcmp(argv[1], "write"))
+   return do_eth_eeprom_rw(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "defaults"))
+   return do_eth_eeprom_defaults(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "set_mac"))
+   return do_eth_eeprom_set_mac(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "show_mac"))
+   return do_eth_eeprom_show_mac(dev, argc - 1, argv + 1);
+
+   printf("Unknown sub command: %s\n", argv[1]);
+
+   return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+   eth_eeprom, 6,  0,  do_eth_eeprom,
+   "access the EEPROM of ethernet devices",
+   "read dev addr off [size]\n"
+  

[U-Boot] [PATCH 2/2] usb: eth: smsc95xx: Add EEPROM access support

2014-10-07 Thread Alban Bedel
Use the new ethernet eeprom API to allow the user to read/write the
EEPROM.

Change-Id: I21233b6ee805a75bd8a03ca12e22c41421b7629c
Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/smsc95xx.c | 199 +++--
 1 file changed, 192 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
index 6bca34d..eb29565 100644
--- a/drivers/usb/eth/smsc95xx.c
+++ b/drivers/usb/eth/smsc95xx.c
@@ -59,6 +59,8 @@
 
 #define E2P_CMD0x30
 #define E2P_CMD_BUSY_  0x8000
+#define E2P_CMD_EWEN_  0x2000
+#define E2P_CMD_WRITE_ 0x3000
 #define E2P_CMD_READ_  0x
 #define E2P_CMD_TIMEOUT_   0x0400
 #define E2P_CMD_LOADED_0x0200
@@ -146,6 +148,131 @@ struct smsc95xx_private {
int have_hwaddr;  /* 1 if we have a hardware MAC address */
 };
 
+#ifdef CONFIG_CMD_ETH_EEPROM
+static u8 eeprom_defaults[] = {
+   /* 0x00 */
+   0xA5,   /* Signature */
+   0xFF, 0xFF, /* MAC bytes 0-1 */
+   0xFF, 0xFF, /* MAC bytes 2-3 */
+   0xFF, 0xFF, /* MAC bytes 4-5 */
+   0x01,   /* FS Polling Interval for Interrupt Endpoint */
+   0x01,   /* HS Polling Interval for Interrupt Endpoint */
+   0x01,   /* Configuration Flags */
+   0x09, 0x04, /* Language ID */
+   0x0a,   /* Manufacturer ID String Descriptor Length (bytes) */
+   0x2f,   /* Manufacturer ID String Descriptor EEPROM Word Offset 
*/
+   0x10,   /* Product Name String Descriptor Length (bytes) */
+   0x34,   /* Product Name String Descriptor EEPROM Word Offset */
+   /* 0x10 */
+   0x12,   /* Serial Number String Descriptor Length (bytes) */
+   0x3c,   /* Serial Number String Descriptor EEPROM Word Offset */
+   0x08,   /* Configuration String Descriptor Length (bytes) */
+   0x45,   /* Configuration String Descriptor Word Offset */
+   0x08,   /* Interface String Descriptor Length (bytes) */
+   0x49,   /* Interface String Descriptor Word Offset */
+   0x12,   /* Hi-Speed Device Descriptor Length (bytes) */
+   0x1d,   /* Hi-Speed Device Descriptor Word Offset */
+   0x12,   /* Hi-Speed Configuration and Interface Descriptor 
Length (bytes) */
+   0x26,   /* Hi-Speed Configuration and Interface Descriptor Word 
Offset */
+   0x12,   /* Full-Speed Device Descriptor Length (bytes) */
+   0x1d,   /* Full-Speed Device Descriptor Word Offset */
+   0x12,   /* Full-Speed Configuration and Interface Descriptor 
Length (bytes) */
+   0x26,   /* Full-Speed Configuration and Interface Descriptor 
Word Offset */
+   0x00, 0x00, /* RESERVED */
+   /* 0x20 */
+   0x24, 0x04, /* Vendor ID */
+   0x14, 0x95, /* Product ID */
+   0x00, 0x01, /* Device ID */
+   0x9b,   /* Config Data Byte 1 Register (CFG1) */
+   0x18,   /* Config Data Byte 2 Register (CFG2) */
+   0x00,   /* Config Data Byte 3 Register (CFG3) */
+   0x32,   /* Non-Removable Devices Register (NRD) */
+   0x00,   /* Port Disable (Self) Register (PDS) */
+   0x00,   /* Port Disable (Bus) Register (PDB) */
+   0x01,   /* Max Power (Self) Register (MAXPS) */
+   0x00,   /* Max Power (Bus) Register (MAXPB) */
+   0x01,   /* Hub Controller Max Current (Self) Register (HCMCS) */
+   0x00,   /* Hub Controller Max Current (Bus) Register (HCMCB) */
+   /* 0x30 */
+   0x32,   /* Power-on Time Register (PWRT) */
+   0x00,   /* Boost_Up Register (BOOSTUP) */
+   0x00,   /* Boost_5 Register (BOOST5) */
+   0x00,   /* Boost_4:2 Register (BOOST42) */
+   0x00,   /* RESERVED */
+   0x00,   /* Port Swap Register (PRTSP) */
+   0x21,   /* Port Remap 12 Register (PRTR12) */
+   0x43,   /* Port Remap 34 Register (PRTR34) */
+   0x05,   /* Port Remap 5 Register (PRTR5) */
+   0x01,   /* Status/Command Register (STCD) */
+   /* 0x3A  - Device Descriptor */
+   0x12, 0x01,
+   0x00, 0x02,
+   0xff, 0x00,
+   /* 0x40 */
+   0xff, 0x40,
+   0x24, 0x04,
+   0x00, 0xec,
+   0x00, 0x01,
+   0x01, 0x02,
+   0x03, 0x01,
+   /* 0x4C  - Configuration and Interface Descriptor */
+   0x09, 0x02,
+   0x27, 0x00,
+   /* 0x50 */
+   0x01, 0x01,
+   0x04, 0xc0,
+   0x00, 0x09,
+   0x04, 0x00,
+   0x00, 0x03,
+   0xff, 0x00,
+   0xff, 0x05,
+   /* 0x5E  - Manufacturer ID String Descriptor */
+   0x0a, 0x03,
+   /* 0x60 */
+   0x53, 0x00

[U-Boot] [PATCH] checkpatch: Add a check for forbidden tags in the git log

2014-10-07 Thread Alban Bedel
After doing this error too many times myself add a check for left
over tags from gerrit and co.

Signed-off-by: Alban Bedel 
---
 scripts/checkpatch.pl | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 74db2e2..3f1dedf 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -351,6 +351,15 @@ our $signature_tags = qr{(?xi:
Cc:
 )};
 
+our $forbidden_tags = qr{(?xi:
+   Bug[=:]|
+   Test[=:]|
+   Issue:|
+   Change-Id:|
+   Review URL:|
+   Reviewed-On:
+)};
+
 our @typeList = (
qr{void},
qr{(?:unsigned\s+)?char},
@@ -1894,6 +1903,12 @@ sub process {
}
}
 
+# Check for left over tags
+   if ($line =~ /^\s*$forbidden_tags/i) {
+   WARN("FORBIDDEN_TAGS",
+"Do not leave extra tags (internal review marker, 
etc)\n" . $herecurr)
+   }
+
 # Check for wrappage within a valid hunk of the file
if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
ERROR("CORRUPTED_PATCH",
-- 
2.1.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] usb: eth: smsc95xx: Add EEPROM access support

2014-10-07 Thread Alban Bedel
On Tue, 7 Oct 2014 14:22:09 +0200
Pavel Machek  wrote:

> On Tue 2014-10-07 11:19:37, Alban Bedel wrote:
> > Use the new ethernet eeprom API to allow the user to read/write the
> > EEPROM.
> > 
> > Change-Id: I21233b6ee805a75bd8a03ca12e22c41421b7629c
> > Signed-off-by: Alban Bedel 
> > ---
> >  drivers/usb/eth/smsc95xx.c | 199 
> > +++--
> >  1 file changed, 192 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
> > index 6bca34d..eb29565 100644
> > --- a/drivers/usb/eth/smsc95xx.c
> > +++ b/drivers/usb/eth/smsc95xx.c
> > @@ -59,6 +59,8 @@
> >  
> >  #define E2P_CMD0x30
> >  #define E2P_CMD_BUSY_  0x8000
> > +#define E2P_CMD_EWEN_  0x2000
> > +#define E2P_CMD_WRITE_ 0x3000
> >  #define E2P_CMD_READ_  0x
> >  #define E2P_CMD_TIMEOUT_   0x0400
> >  #define E2P_CMD_LOADED_0x0200
> > @@ -146,6 +148,131 @@ struct smsc95xx_private {
> > int have_hwaddr;  /* 1 if we have a hardware MAC address */
> >  };
> >  
> > +#ifdef CONFIG_CMD_ETH_EEPROM
> 
> Is this layout common for all machines using this driver? If not, is
> it worth comment which machine is it?

These are supposed to be the same values as would be used by the
controller when the eeprom is not programmed. So they are not machine
specific, however it is specific to the LAN9514, looking at the
datasheet for the LAN9500 the eeprom layout is different.

Then I'll submit a new version that use per chip defaults, as well
as allowing the board file to override the default data.

> > +static u8 eeprom_defaults[] = {
> > +   /* 0x00 */
> > +   0xA5,   /* Signature */
> > +   0xFF, 0xFF, /* MAC bytes 0-1 */
> > +   0xFF, 0xFF, /* MAC bytes 2-3 */
> > +   0xFF, 0xFF, /* MAC bytes 4-5 */
> 
> Normally, we use all zeros for unset...?

That's what the controller use when the EEPROM hasn't been programmed,
but I'll change it to all 0.

Alban



signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/2] net: Add a command to access the EEPROM from ethernet devices

2014-10-09 Thread Alban Bedel
Many ethernet devices use an EEPROM to store various settings, most
commonly the device MAC address. But on some devices it can contains
a lot more, for example USB device might also have many USB related
parameters.

This commit add a set of commands to read/write this EEPROM, write a
default configuration and read/write the device MAC address. The
defaults command allow priming the EEPROM for devices that need more
than just a MAC address in the EEPROM.

Signed-off-by: Alban Bedel 
---
v2: * No changes since v1
---
 common/cmd_net.c | 134 +++
 include/net.h|  28 
 net/eth.c|  46 +++
 3 files changed, 208 insertions(+)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 09489d4..f4952d5 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -445,3 +445,137 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
+
+#if defined(CONFIG_CMD_ETH_EEPROM)
+static int do_eth_eeprom_rw(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   ulong addr, offset, length = 1;
+
+   if (argc < 4)
+   return CMD_RET_USAGE;
+
+   addr = simple_strtoul(argv[2], NULL, 16);
+   offset = simple_strtoul(argv[3], NULL, 16);
+   if (argc > 4)
+   length = simple_strtoul(argv[4], NULL, 16);
+
+   if (!strcmp(argv[0], "write")) {
+   if (eth_eeprom_write(dev, offset, length, (void *)addr)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+   return CMD_RET_SUCCESS;
+   } else if (!strcmp(argv[0], "read")) {
+   if (eth_eeprom_read(dev, offset, length, (void *)addr)) {
+   printf("EEPROM read failed\n");
+   return CMD_RET_FAILURE;
+   }
+   return CMD_RET_SUCCESS;
+   }
+
+   return CMD_RET_USAGE;
+}
+
+static int do_eth_eeprom_defaults(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   if (eth_eeprom_defaults(dev)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom_set_mac(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   u8 mac[6];
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   eth_parse_enetaddr(argv[2], mac);
+   if (!is_valid_ether_addr(mac)) {
+   printf("Invalid mac address given\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("Writing MAC to EEPROM \n");
+   if (eth_eeprom_write_mac(dev, mac)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom_show_mac(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   u8 data[6];
+
+   if (eth_eeprom_read_mac(dev, data)) {
+   printf("EEPROM read failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%pM\n", data);
+   if (!is_valid_ether_addr(data))
+   printf("Warning: MAC address is not valid!\n");
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   struct eth_device *dev;
+   char *endp = NULL;
+   int index;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   /* Get the ethernet device, by ID or by name */
+   index = (int) simple_strtoul(argv[2], &endp, 16);
+   if (endp > argv[2])
+   dev = eth_get_dev_by_index(index);
+   else
+   dev = eth_get_dev_by_name(argv[2]);
+
+   if (!dev) {
+   printf("Ethernet device not found\n");
+   return CMD_RET_FAILURE;
+   }
+
+   if (!strcmp(argv[1], "read") || !strcmp(argv[1], "write"))
+   return do_eth_eeprom_rw(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "defaults"))
+   return do_eth_eeprom_defaults(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "set_mac"))
+   return do_eth_eeprom_set_mac(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "show_mac"))
+   return do_eth_eeprom_show_mac(dev, argc - 1, argv + 1);
+
+   printf("Unknown sub command: %s\n", argv[1]);
+
+   return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+   eth_eeprom, 6,  0,  do_eth_eeprom,
+   "access the EEPROM of ethernet devices",
+   "read dev addr off [size]\n"
+   "- read 'size' b

[U-Boot] [PATCH v2 2/2] usb: eth: smsc95xx: Add EEPROM access support for LAN9514

2014-10-09 Thread Alban Bedel
Use the new ethernet eeprom API to allow the user to read/write the
EEPROM.

Signed-off-by: Alban Bedel 
---
v2: * Rework the defaults implementation to use the proper config
  depending on the device type.
* Allow the board to override the defaults data.
* Use the proper defaults instead of the Tamonten config.
* Fix style error in usb_ether.h
* Add a comment to explain why the default MAC has all bits set

This patch is based on earlier work from Thierry Reding, I assumed
that the default config was derived from the datasheet. However it
turned out that this config had been customized for the Tamonten
boards. I restored the config according to the defaults found in the
datasheet. Sadly the datasheet doesn't properly document all the
fields from the EEPROM, so it may still have a few bugs as I don't
have the default values for all fields.
---
 drivers/usb/eth/smsc95xx.c | 246 +++--
 include/usb_ether.h|   8 ++
 2 files changed, 247 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
index 6bca34d..4e06be7 100644
--- a/drivers/usb/eth/smsc95xx.c
+++ b/drivers/usb/eth/smsc95xx.c
@@ -59,6 +59,8 @@
 
 #define E2P_CMD0x30
 #define E2P_CMD_BUSY_  0x8000
+#define E2P_CMD_EWEN_  0x2000
+#define E2P_CMD_WRITE_ 0x3000
 #define E2P_CMD_READ_  0x
 #define E2P_CMD_TIMEOUT_   0x0400
 #define E2P_CMD_LOADED_0x0200
@@ -146,6 +148,155 @@ struct smsc95xx_private {
int have_hwaddr;  /* 1 if we have a hardware MAC address */
 };
 
+#ifdef CONFIG_CMD_ETH_EEPROM
+struct smsc95xx_eeprom_device {
+   unsigned short vendor;
+   unsigned short product;
+   struct smsc95xx_eeprom_defaults *defaults;
+};
+
+/* Default values as used by the controller when the EEPROM hasn't
+ * been programmed yet. Note that when unset the MAC address has
+ * all bits set instead of all bits cleared as is usual in u-boot. */
+static u8 smsc9514_eeprom_defaults_data[] = {
+   /* 0x00 */
+   0xA5,   /* Signature */
+   0xFF, 0xFF, /* MAC bytes 0-1 */
+   0xFF, 0xFF, /* MAC bytes 2-3 */
+   0xFF, 0xFF, /* MAC bytes 4-5 */
+   0x01,   /* FS Polling Interval for Interrupt Endpoint */
+   0x04,   /* HS Polling Interval for Interrupt Endpoint */
+   0x05,   /* Configuration Flags */
+   0x09, 0x04, /* Language ID */
+   0x0a,   /* Manufacturer ID String Descriptor Length (bytes) */
+   0x2f,   /* Manufacturer ID String Descriptor EEPROM Word Offset 
*/
+   0x10,   /* Product Name String Descriptor Length (bytes) */
+   0x34,   /* Product Name String Descriptor EEPROM Word Offset */
+   /* 0x10 */
+   0x12,   /* Serial Number String Descriptor Length (bytes) */
+   0x3c,   /* Serial Number String Descriptor EEPROM Word Offset */
+   0x08,   /* Configuration String Descriptor Length (bytes) */
+   0x45,   /* Configuration String Descriptor Word Offset */
+   0x08,   /* Interface String Descriptor Length (bytes) */
+   0x49,   /* Interface String Descriptor Word Offset */
+   0x12,   /* Hi-Speed Device Descriptor Length (bytes) */
+   0x1d,   /* Hi-Speed Device Descriptor Word Offset */
+   0x12,   /* Hi-Speed Configuration and Interface Descriptor 
Length (bytes) */
+   0x26,   /* Hi-Speed Configuration and Interface Descriptor Word 
Offset */
+   0x12,   /* Full-Speed Device Descriptor Length (bytes) */
+   0x1d,   /* Full-Speed Device Descriptor Word Offset */
+   0x12,   /* Full-Speed Configuration and Interface Descriptor 
Length (bytes) */
+   0x26,   /* Full-Speed Configuration and Interface Descriptor 
Word Offset */
+   0x00, 0x00, /* RESERVED */
+   /* 0x20 */
+   0x24, 0x04, /* Vendor ID */
+   0x14, 0x95, /* Product ID */
+   0x00, 0x01, /* Device ID */
+   0x9b,   /* Config Data Byte 1 Register (CFG1) */
+   0x18,   /* Config Data Byte 2 Register (CFG2) */
+   0x00,   /* Config Data Byte 3 Register (CFG3) */
+   0x02,   /* Non-Removable Devices Register (NRD) */
+   0x00,   /* Port Disable (Self) Register (PDS) */
+   0x00,   /* Port Disable (Bus) Register (PDB) */
+   0x01,   /* Max Power (Self) Register (MAXPS) */
+   0x00,   /* Max Power (Bus) Register (MAXPB) */
+   0x01,   /* Hub Controller Max Current (Self) Register (HCMCS) */
+   0x00,   /* Hub Controller Max Current (Bus) Register (HCMCB) */
+   /* 0x30 */
+   0x32,   /* Power-on Time Register (PWRT) 

Re: [U-Boot] [PATCH v2 1/2] net: Add a command to access the EEPROM from ethernet devices

2014-10-13 Thread Alban Bedel
On Thu, 9 Oct 2014 17:17:00 +0200
Marek Vasut  wrote:

> On Thursday, October 09, 2014 at 01:42:49 PM, Alban Bedel wrote:
> > Many ethernet devices use an EEPROM to store various settings, most
> > commonly the device MAC address. But on some devices it can contains
> > a lot more, for example USB device might also have many USB related
> > parameters.
> > 
> > This commit add a set of commands to read/write this EEPROM, write a
> > default configuration and read/write the device MAC address. The
> > defaults command allow priming the EEPROM for devices that need more
> > than just a MAC address in the EEPROM.
> > 
> > Signed-off-by: Alban Bedel 
> 
> I will not comment on the code yet, but would like to discuss the concept
> instead. I wonder, can we not have a more generic command here? One which
> can manage the ethernet device altogether, not just adjust it's eeprom?
> Something like 'ethtool' in Linux ...
> 
> What do you think please ?

Currently this is all I need for the boards I'm working on. However I
have no problem with splitting the command from 'eth_eeprom' to
'eth eeprom' to leave room for other stuff.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 2/3] net: Add a command to access the EEPROM from ethernet devices

2014-10-14 Thread Alban Bedel
Many ethernet devices use an EEPROM to store various settings, most
commonly the device MAC address. But on some devices it can contains
a lot more, for example USB device might also have many USB related
parameters.

This commit add a set of commands to read/write this EEPROM, write a
default configuration and read/write the device MAC address. The
defaults command allow priming the EEPROM for devices that need more
than just a MAC address in the EEPROM.

Signed-off-by: Alban Bedel 
---
v2: * No changes since v1
v3: * Replace the dedicated 'eth_eeprom' command with a subcommand
  to the newly introduced 'eth' command
---
 common/cmd_net.c | 121 +++
 include/net.h|  28 +
 net/eth.c|  46 +
 3 files changed, 195 insertions(+)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 9cc0bdf..1c2e254 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -446,6 +446,109 @@ U_BOOT_CMD(
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
 
+#if defined(CONFIG_CMD_ETH_EEPROM)
+static int do_eth_eeprom_rw(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   ulong addr, offset, length = 1;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   addr = simple_strtoul(argv[1], NULL, 16);
+   offset = simple_strtoul(argv[2], NULL, 16);
+   if (argc > 3)
+   length = simple_strtoul(argv[3], NULL, 16);
+
+   if (!strcmp(argv[0], "write")) {
+   if (eth_eeprom_write(dev, offset, length, (void *)addr)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+   return CMD_RET_SUCCESS;
+   } else if (!strcmp(argv[0], "read")) {
+   if (eth_eeprom_read(dev, offset, length, (void *)addr)) {
+   printf("EEPROM read failed\n");
+   return CMD_RET_FAILURE;
+   }
+   return CMD_RET_SUCCESS;
+   }
+
+   return CMD_RET_USAGE;
+}
+
+static int do_eth_eeprom_defaults(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   if (eth_eeprom_defaults(dev)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom_set_mac(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   u8 mac[6];
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   eth_parse_enetaddr(argv[1], mac);
+   if (!is_valid_ether_addr(mac)) {
+   printf("Invalid mac address given\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("Writing MAC to EEPROM \n");
+   if (eth_eeprom_write_mac(dev, mac)) {
+   printf("EEPROM write failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom_show_mac(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   u8 data[6];
+
+   if (eth_eeprom_read_mac(dev, data)) {
+   printf("EEPROM read failed\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%pM\n", data);
+   if (!is_valid_ether_addr(data))
+   printf("Warning: MAC address is not valid!\n");
+
+   return CMD_RET_SUCCESS;
+}
+
+static int do_eth_eeprom(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   if (!strcmp(argv[1], "read") || !strcmp(argv[1], "write"))
+   return do_eth_eeprom_rw(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "defaults"))
+   return do_eth_eeprom_defaults(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "set_mac"))
+   return do_eth_eeprom_set_mac(dev, argc - 1, argv + 1);
+   if (!strcmp(argv[1], "show_mac"))
+   return do_eth_eeprom_show_mac(dev, argc - 1, argv + 1);
+
+   printf("Unknown eeprom sub command: %s\n", argv[1]);
+
+   return CMD_RET_USAGE;
+}
+#endif
+
 static int do_eth_show(struct eth_device *dev,
int argc, char * const argv[])
 {
@@ -478,6 +581,10 @@ static int do_eth(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
if (!strcmp(argv[2], "show"))
return do_eth_show(dev, argc - 2, argv + 2);
+#if defined(CONFIG_CMD_ETH_EEPROM)
+   if (!strcmp(argv[2], "eeprom"))
+   return do_eth_eeprom(dev, argc - 2, argv + 2);
+#endif
 
printf("Unknown eth sub command: %s\n", argv[2]);
 
@@ -492,4 +599,18 

[U-Boot] [PATCH v3 1/3] net: Add a command to manipulate ethernet devices

2014-10-14 Thread Alban Bedel
Add the 'eth' command for operations on ethernet devices.
This first version only contains a command to show a device
properties, currently only name, index and MAC address.

Signed-off-by: Alban Bedel 
---
v1: * Patch didn't exists
v2: * Patch didn't exists
v3: * Replace the dedicated 'eth_eeprom' command with a subcommand
  to the 'eth' command
---
 common/cmd_net.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 09489d4..9cc0bdf 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -445,3 +445,51 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
+
+static int do_eth_show(struct eth_device *dev,
+   int argc, char * const argv[])
+{
+   printf("Name : %s\n", dev->name);
+   printf("Index: %d\n", dev->index);
+   printf("MAC  : %pM\n", dev->enetaddr);
+   return 0;
+}
+
+static int do_eth(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   struct eth_device *dev;
+   char *endp = NULL;
+   int index;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   /* Get the ethernet device, by ID or by name */
+   index = (int) simple_strtoul(argv[1], &endp, 16);
+   if (endp > argv[1])
+   dev = eth_get_dev_by_index(index);
+   else
+   dev = eth_get_dev_by_name(argv[2]);
+
+   if (!dev) {
+   printf("Ethernet device not found\n");
+   return CMD_RET_FAILURE;
+   }
+
+   if (!strcmp(argv[2], "show"))
+   return do_eth_show(dev, argc - 2, argv + 2);
+
+   printf("Unknown eth sub command: %s\n", argv[2]);
+
+   return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+   eth,7,  0,  do_eth,
+   "extended ops for ethernet devices",
+   "  [...]\n"
+   "- run command on a device, device may be a name or id.\n"
+   "\n"
+   "eth  show\n"
+   "- show basic information about the ethernet device\n"
+);
-- 
2.1.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 3/3] usb: eth: smsc95xx: Add EEPROM access support for LAN9514

2014-10-14 Thread Alban Bedel
Use the new ethernet eeprom API to allow the user to read/write the
EEPROM.

Signed-off-by: Alban Bedel 
---
v2: * Rework the defaults implementation to use the proper config
  depending on the device type.
* Allow the board to override the defaults data.
* Use the proper defaults instead of the Tamonten config.
* Fix style error in usb_ether.h
* Add a comment to explain why the default MAC has all bits set

v3: * No changes since v2

This patch is based on earlier work from Thierry Reding, I assumed
that the default config was derived from the datasheet. However it
turned out that this config had been customized for the Tamonten
boards. I restored the config according to the defaults found in the
datasheet. Sadly the datasheet doesn't properly document all the
fields from the EEPROM, so it may still have a few bugs as I don't
have the default values for all fields.
---
 drivers/usb/eth/smsc95xx.c | 246 +++--
 include/usb_ether.h|   8 ++
 2 files changed, 247 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/eth/smsc95xx.c b/drivers/usb/eth/smsc95xx.c
index 6bca34d..4e06be7 100644
--- a/drivers/usb/eth/smsc95xx.c
+++ b/drivers/usb/eth/smsc95xx.c
@@ -59,6 +59,8 @@
 
 #define E2P_CMD0x30
 #define E2P_CMD_BUSY_  0x8000
+#define E2P_CMD_EWEN_  0x2000
+#define E2P_CMD_WRITE_ 0x3000
 #define E2P_CMD_READ_  0x
 #define E2P_CMD_TIMEOUT_   0x0400
 #define E2P_CMD_LOADED_0x0200
@@ -146,6 +148,155 @@ struct smsc95xx_private {
int have_hwaddr;  /* 1 if we have a hardware MAC address */
 };
 
+#ifdef CONFIG_CMD_ETH_EEPROM
+struct smsc95xx_eeprom_device {
+   unsigned short vendor;
+   unsigned short product;
+   struct smsc95xx_eeprom_defaults *defaults;
+};
+
+/* Default values as used by the controller when the EEPROM hasn't
+ * been programmed yet. Note that when unset the MAC address has
+ * all bits set instead of all bits cleared as is usual in u-boot. */
+static u8 smsc9514_eeprom_defaults_data[] = {
+   /* 0x00 */
+   0xA5,   /* Signature */
+   0xFF, 0xFF, /* MAC bytes 0-1 */
+   0xFF, 0xFF, /* MAC bytes 2-3 */
+   0xFF, 0xFF, /* MAC bytes 4-5 */
+   0x01,   /* FS Polling Interval for Interrupt Endpoint */
+   0x04,   /* HS Polling Interval for Interrupt Endpoint */
+   0x05,   /* Configuration Flags */
+   0x09, 0x04, /* Language ID */
+   0x0a,   /* Manufacturer ID String Descriptor Length (bytes) */
+   0x2f,   /* Manufacturer ID String Descriptor EEPROM Word Offset 
*/
+   0x10,   /* Product Name String Descriptor Length (bytes) */
+   0x34,   /* Product Name String Descriptor EEPROM Word Offset */
+   /* 0x10 */
+   0x12,   /* Serial Number String Descriptor Length (bytes) */
+   0x3c,   /* Serial Number String Descriptor EEPROM Word Offset */
+   0x08,   /* Configuration String Descriptor Length (bytes) */
+   0x45,   /* Configuration String Descriptor Word Offset */
+   0x08,   /* Interface String Descriptor Length (bytes) */
+   0x49,   /* Interface String Descriptor Word Offset */
+   0x12,   /* Hi-Speed Device Descriptor Length (bytes) */
+   0x1d,   /* Hi-Speed Device Descriptor Word Offset */
+   0x12,   /* Hi-Speed Configuration and Interface Descriptor 
Length (bytes) */
+   0x26,   /* Hi-Speed Configuration and Interface Descriptor Word 
Offset */
+   0x12,   /* Full-Speed Device Descriptor Length (bytes) */
+   0x1d,   /* Full-Speed Device Descriptor Word Offset */
+   0x12,   /* Full-Speed Configuration and Interface Descriptor 
Length (bytes) */
+   0x26,   /* Full-Speed Configuration and Interface Descriptor 
Word Offset */
+   0x00, 0x00, /* RESERVED */
+   /* 0x20 */
+   0x24, 0x04, /* Vendor ID */
+   0x14, 0x95, /* Product ID */
+   0x00, 0x01, /* Device ID */
+   0x9b,   /* Config Data Byte 1 Register (CFG1) */
+   0x18,   /* Config Data Byte 2 Register (CFG2) */
+   0x00,   /* Config Data Byte 3 Register (CFG3) */
+   0x02,   /* Non-Removable Devices Register (NRD) */
+   0x00,   /* Port Disable (Self) Register (PDS) */
+   0x00,   /* Port Disable (Bus) Register (PDB) */
+   0x01,   /* Max Power (Self) Register (MAXPS) */
+   0x00,   /* Max Power (Bus) Register (MAXPB) */
+   0x01,   /* Hub Controller Max Current (Self) Register (HCMCS) */
+   0x00,   /* Hub Controller Max Current (Bus) Register (HCMCB) */
+   /* 0x30 */
+   0x32,   /* Power-on Time

Re: [U-Boot] [PATCH v3 2/3] net: Add a command to access the EEPROM from ethernet devices

2014-10-15 Thread Alban Bedel
On Tue, 14 Oct 2014 21:18:37 +0200
Simon Glass  wrote:

> Hi Joe,
> 
> On 14 October 2014 21:14, Joe Hershberger  wrote:
> >
> > On Tue, Oct 14, 2014 at 12:21 PM, Simon Glass  wrote:
> > >
> > > Hi,
> > >
> > > On 14 October 2014 18:26, Alban Bedel  
> > > wrote:
> > > > Many ethernet devices use an EEPROM to store various settings, most
> > > > commonly the device MAC address. But on some devices it can contains
> > > > a lot more, for example USB device might also have many USB related
> > > > parameters.
> > > >
> > > > This commit add a set of commands to read/write this EEPROM, write a
> > > > default configuration and read/write the device MAC address. The
> > > > defaults command allow priming the EEPROM for devices that need more
> > > > than just a MAC address in the EEPROM.
> > > >
> > > > Signed-off-by: Alban Bedel 
> > > > ---
> > > > v2: * No changes since v1
> > > > v3: * Replace the dedicated 'eth_eeprom' command with a subcommand
> > > >   to the newly introduced 'eth' command
> > >
> > > I see a few EEPROM implementations in the code base. It feels to me
> > > like we need an EEPROM interface. In driver model terms this could be
> > > a uclass. I started something here:
> > >
> > > http://patchwork.ozlabs.org/patch/399039/
> > >
> > > Of course we don't have DM for Ethernet yet - when we do I think a
> > > child EEPROM device below the Ethernet would make sense. It could be
> > > created by the Ethernet driver when it knows that this information
> > > exists. But even without that I feel that the EEPROM should be
> > > logically separated from Ethernet.
> > >
> > > So I suggest that instead of an #ifdef to adjust the Ethernet API, add
> > > a pointer to another struct containing the EEPROM API and put it in
> > > its own header. I also feel that there should ultimately be an eeprom
> > > command which operates on these. Then the only Ethernet API call would
> > > be to find the EEPROM pointer, if there is one.
> > >
> > > If someone feels like taking it on, driver model support for Ethernet
> > > should be pretty easy. Or even EEPROM could be done now and this might
> > > avoid churn. But I would be happy for this series to be applied as is
> > > while working on a driver model version. I just don't feel we should
> > > be adding new subsystems that don't use driver model.
> >
> > I agree that we shouldn't add new subsystems that don't use DM.  I think
> > this (adding eeprom access to Ethernet) is a decent compromise until
> > we have driver model for Ethernet.  I do like your idea of having an
> > eeprom class / subsystem / command that can operate on this type of
> > thing the same way no matter where it's connected, but it probably
> > isn't a good idea to add an "eeprom" command for that without using DM
> > first.
> >
> > So your idea sounds good, but it leaves me with one question... if we want
> > to accept this now as it is, then do we want to introduce a new
> > command (eth eeprom) when we already know we want to change its
> > behavior or delete it once we add a uclass for eeproms?
> 
> Good question, in general I suppose we want to avoid changing the
> commands, although if you get to Ethernet in this merge window then it
> might not matter much. One option is to indicate in the help that it
> is a temporary command and the syntax may change.
>

A generic EEPROM driver / command sounds good, however we would still
need a few ethernet driver specific commands like the ones to
manipulate the MAC address.

If possible I would really like to settle the command syntax, so I
would suggest using the following scheme for the future eeprom command:

  eeprom   [...]

If this command is also available internally with an interface such as:

  int eeprom_cmd(struct eeprom_device *dev,
 int argc, char * const argv[]);

the 'eth eeprom' implementation could easily provides its own commands
on the eeprom while falling back on eeprom_cmd() for the generic ones.
That would avoid any code duplication while keeping the 'eth eeprom'
functionality.

I'm unsure about the 'defaults' commands, I would tend to see it at
the eeprom level as it might be needed in various situations. However
it must be provided by the device, not the eeprom driver itself.
It might also make sense to drop the callback in favour of a simple
data array as it would allow setting it from device tree.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 2/3] net: Add a command to access the EEPROM from ethernet devices

2014-10-21 Thread Alban Bedel
On Fri, 17 Oct 2014 14:12:18 -0600
Simon Glass  wrote:

> >
> > I'm unsure about the 'defaults' commands, I would tend to see it at
> > the eeprom level as it might be needed in various situations. However
> > it must be provided by the device, not the eeprom driver itself.
> > It might also make sense to drop the callback in favour of a simple
> > data array as it would allow setting it from device tree.  
> 
> I'm not sure what this refers to sorry.

It refer to the 'eth eeprom defaults' command from this patch. The USB
device I wrote that for need a lot more in the EEPROM than just the MAC
address. This command allow writing the "factory defaults" in the
EEPROM. Somehow I have a feeling that such a command would make sense
for a few other use-case than just USB ethernet devices.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/3] usb: ci_udc: Fix set address to work with older controllers

2015-02-24 Thread Alban Bedel
Older controllers don't implement "Device Address Advance" which allow
to pass the device address to the controller when it is received.
To support such controller we need to store the requested address and
only apply it after the next IN transfer completed on EP0.

Signed-off-by: Alban Bedel 
---
 drivers/usb/gadget/ci_udc.c | 18 +-
 drivers/usb/gadget/ci_udc.h |  1 +
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index b0ef35e..694745f 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -523,6 +523,13 @@ static void handle_ep_complete(struct ci_ep *ci_ep)
 
DBG("ept%d %s req %p, complete %x\n",
num, in ? "in" : "out", ci_req, len);
+   /* The device address must be applied after the next IN transfer
+* completed on ep0. */
+   if (num == 0 && in && controller.set_address) {
+   struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
+   writel(controller.set_address << 25, &udc->devaddr);
+   controller.set_address = 0;
+   }
if (num != 0 || controller.ep0_data_phase)
ci_req->req.complete(&ci_ep->ep, &ci_req->req);
if (num == 0 && controller.ep0_data_phase) {
@@ -614,11 +621,9 @@ static void handle_setup(void)
return;
 
case SETUP(USB_RECIP_DEVICE, USB_REQ_SET_ADDRESS):
-   /*
-* write address delayed (will take effect
-* after the next IN txn)
-*/
-   writel((r.wValue << 25) | (1 << 24), &udc->devaddr);
+   /* The device address must be updated after the next IN
+* request completed */
+   controller.set_address = r.wValue;
req->length = 0;
usb_ep_queue(controller.gadget.ep0, req, 0);
return;
@@ -670,6 +675,9 @@ static void stop_activity(void)
ci_flush_qh(num);
}
}
+
+   /* clear any pending set address */
+   controller.set_address = 0;
 }
 
 void udc_irq(void)
diff --git a/drivers/usb/gadget/ci_udc.h b/drivers/usb/gadget/ci_udc.h
index 346164a..44e70b1 100644
--- a/drivers/usb/gadget/ci_udc.h
+++ b/drivers/usb/gadget/ci_udc.h
@@ -99,6 +99,7 @@ struct ci_drv {
struct usb_gadget   gadget;
struct ci_req   *ep0_req;
boolep0_data_phase;
+   uint8_t set_address;
struct usb_gadget_driver*driver;
struct ehci_ctrl*ctrl;
struct ept_queue_head   *epts;
-- 
2.3.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/3] ARM: tegra: Fix the USB gadget configuration for T20

2015-02-24 Thread Alban Bedel
The USB controller on T20 doesn't have the HOSTPC feature.

As there is not define for the SoC type at this level we use the
address of the first USB controller as match. Not very nice but it
should do for now.

Signed-off-by: Alban Bedel 
---
 include/configs/tegra-common-usb-gadget.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/tegra-common-usb-gadget.h 
b/include/configs/tegra-common-usb-gadget.h
index 287460c..894b531 100644
--- a/include/configs/tegra-common-usb-gadget.h
+++ b/include/configs/tegra-common-usb-gadget.h
@@ -13,7 +13,9 @@
 #define CONFIG_USB_GADGET
 #define CONFIG_USB_GADGET_VBUS_DRAW2
 #define CONFIG_CI_UDC
+#if TEGRA_USB1_BASE != 0xC500
 #define CONFIG_CI_UDC_HAS_HOSTPC
+#endif
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_G_DNL_VENDOR_NUM 0x0955
 #define CONFIG_G_DNL_PRODUCT_NUM 0x701A
-- 
2.3.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/3] ARM: tegra: usb gadgets: Allow accessing the NAND via DFU

2015-02-24 Thread Alban Bedel
Many T20 boards use NAND instead of MMC, allow accessing it via DFU.

Signed-off-by: Alban Bedel 
---
 include/configs/tegra-common-usb-gadget.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/configs/tegra-common-usb-gadget.h 
b/include/configs/tegra-common-usb-gadget.h
index 894b531..3fd8ab4 100644
--- a/include/configs/tegra-common-usb-gadget.h
+++ b/include/configs/tegra-common-usb-gadget.h
@@ -34,6 +34,9 @@
 #ifdef CONFIG_SPI_FLASH
 #define CONFIG_DFU_SF
 #endif
+#ifdef CONFIG_CMD_NAND
+#define CONFIG_DFU_NAND
+#endif
 #endif
 
 #endif /* _TEGRA_COMMON_USB_GADGET_H_ */
-- 
2.3.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] tegra20: tamonten: Fix the early gpio init

2015-02-24 Thread Alban Bedel
To set gpio during the early init we now need to use
tegra_spl_gpio_direction_output(), copied from seaboard.

Signed-off-by: Alban Bedel 
---
 board/avionic-design/common/tamonten.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/avionic-design/common/tamonten.c 
b/board/avionic-design/common/tamonten.c
index 9c86779..ea2425a 100644
--- a/board/avionic-design/common/tamonten.c
+++ b/board/avionic-design/common/tamonten.c
@@ -23,8 +23,10 @@
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 void gpio_early_init(void)
 {
+#ifndef CONFIG_SPL_BUILD
gpio_request(GPIO_PI4, NULL);
-   gpio_direction_output(GPIO_PI4, 1);
+#endif
+   tegra_spl_gpio_direction_output(GPIO_PI4, 1);
 }
 #endif
 
-- 
2.3.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] tegra20: tamonten: Fix the early gpio init

2015-02-24 Thread Alban Bedel
On Tue, 24 Feb 2015 10:02:04 -0700
Stephen Warren  wrote:

> On 02/24/2015 09:58 AM, Alban Bedel wrote:
> > To set gpio during the early init we now need to use
> > tegra_spl_gpio_direction_output(), copied from seaboard.
> 
> Can you explain "now" a bit more. Did some previous commit change the 
> behaviour of the GPIO API? If so, if you could reference the commit hash 
> and subject that'd be useful.

This a repost, see [1] for the details. In short this is needed because
the GPIO driver isn't available at this point. In October I have been
told this will be fixed soon. Now the GPIO driver is still not fixed
and all tamonten boards are still broken.

Without this fix all board peripherals are unusable on all Tamonten
board, it would be really nice to have this integrated.

Alban

[1] http://lists.denx.de/pipermail/u-boot/2014-October/190464.html


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] tegra20: tamonten: Fix the early gpio init

2015-02-24 Thread Alban Bedel
On Tue, 24 Feb 2015 10:22:52 -0700
Stephen Warren  wrote:

> On 02/24/2015 10:18 AM, Alban Bedel wrote:
> > On Tue, 24 Feb 2015 10:02:04 -0700
> > Stephen Warren  wrote:
> >
> >> On 02/24/2015 09:58 AM, Alban Bedel wrote:
> >>> To set gpio during the early init we now need to use
> >>> tegra_spl_gpio_direction_output(), copied from seaboard.
> >>
> >> Can you explain "now" a bit more. Did some previous commit change the
> >> behaviour of the GPIO API? If so, if you could reference the commit hash
> >> and subject that'd be useful.
> >
> > This a repost, see [1] for the details. In short this is needed because
> > the GPIO driver isn't available at this point. In October I have been
> > told this will be fixed soon. Now the GPIO driver is still not fixed
> > and all tamonten boards are still broken.
> >
> > Without this fix all board peripherals are unusable on all Tamonten
> > board, it would be really nice to have this integrated.
> >
> > Alban
> >
> > [1] http://lists.denx.de/pipermail/u-boot/2014-October/190464.html
> 
> OK. My point was that the commit description should describe the source 
> of the problem so that anyone looking through git history understands 
> the issues without having to search email lists too.

Right, I'll post a V2 tomorrow with a better log.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] ARM: tegra: usb gadgets: Allow accessing the NAND via DFU

2015-02-24 Thread Alban Bedel
On Tue, 24 Feb 2015 09:56:50 -0700
Stephen Warren  wrote:

> On 02/24/2015 09:44 AM, Alban Bedel wrote:
> > Many T20 boards use NAND instead of MMC, allow accessing it via DFU.
> 
> I have no particular objection to this, but I wonder how extensively 
> you've tested this? IIRC I had to make quite a few fixes to the DFU and 
> DFU-MMU code when enabling them on Tegra. I'd expect to have to make a 
> bunch of changes to the DFU-NAND code to make it work, unless I happened 
> to fix it up blindly without issue before:-)

I only did a few test with DFU, writing u-boot image and that worked
fine.

> Does test/dfu/dfu_gadget_test.sh work without issue on NAND on Tegra?

However this test fails :( So, yes it might a bit early to enable it.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] ARM: tegra: Fix the USB gadget configuration for T20

2015-02-24 Thread Alban Bedel
On Tue, 24 Feb 2015 09:54:31 -0700
Stephen Warren  wrote:

> On 02/24/2015 09:44 AM, Alban Bedel wrote:
> > The USB controller on T20 doesn't have the HOSTPC feature.
> >
> > As there is not define for the SoC type at this level we use the
> > address of the first USB controller as match. Not very nice but it
> > should do for now.
> 
> CONFIG_TEGRA20 ought to work fine here?

Right, that was a left over of my early debug, I'll fix it in V2.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] usb: ci_udc: Fix set address to work with older controllers

2015-02-24 Thread Alban Bedel
On Tue, 24 Feb 2015 10:00:43 -0700
Stephen Warren  wrote:

> On 02/24/2015 09:44 AM, Alban Bedel wrote:
> > Older controllers don't implement "Device Address Advance" which allow
> > to pass the device address to the controller when it is received.
> > To support such controller we need to store the requested address and
> > only apply it after the next IN transfer completed on EP0.
> 
> > diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
> 
> > case SETUP(USB_RECIP_DEVICE, USB_REQ_SET_ADDRESS):
> > -   /*
> > -* write address delayed (will take effect
> > -* after the next IN txn)
> > -*/
> > -   writel((r.wValue << 25) | (1 << 24), &udc->devaddr);
> > +   /* The device address must be updated after the next IN
> > +* request completed */
> > +   controller.set_address = r.wValue;
> 
> Presumably, bit 24 is the "device address advance" feature?

Yes, bit 24 is the "device address advance" feature

> I'd prefer it if new controllers used the existing code, but we deferred 
> the write only for older controllers that don't support "device address 
> advance". That reduces the possibility of regressions on controller HW 
> that's already working. Presumably, there is some advantage using the 
> new feature, rather than deferring the address change manually, e.g. it 
> solves some race condition?

I'm no USB expert, but AFAIU it is only a convenience to make the
driver code simpler. I though that having less code path and ifdef
would make the whole thing easier to maintain. However if that is
preferred I can implement it as you suggested.

Alban

PS: Sorry for the double mail Stephen, I accidentally used the wrong
reply button.


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] tegra20: tamonten: Fix the early gpio init

2015-02-24 Thread Alban Bedel
As the GPIO driver isn't ready when gpio_early_init() is called the
normal GPIO API can't be used. Fix this like on seaboard by using the
lower level function tegra_spl_gpio_direction_output().

Signed-off-by: Alban Bedel 
---
v2: Updated the log message to better describe the problem
---
 board/avionic-design/common/tamonten.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/avionic-design/common/tamonten.c 
b/board/avionic-design/common/tamonten.c
index 9c86779..ea2425a 100644
--- a/board/avionic-design/common/tamonten.c
+++ b/board/avionic-design/common/tamonten.c
@@ -23,8 +23,10 @@
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 void gpio_early_init(void)
 {
+#ifndef CONFIG_SPL_BUILD
gpio_request(GPIO_PI4, NULL);
-   gpio_direction_output(GPIO_PI4, 1);
+#endif
+   tegra_spl_gpio_direction_output(GPIO_PI4, 1);
 }
 #endif
 
-- 
2.3.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] usb: ci_udc: Fix set address to work with older controllers

2015-02-26 Thread Alban Bedel
On Tue, 24 Feb 2015 12:25:50 -0700
Stephen Warren  wrote:

> On 02/24/2015 10:41 AM, Alban Bedel wrote:
> > On Tue, 24 Feb 2015 10:00:43 -0700
> > Stephen Warren  wrote:
> >
> >> On 02/24/2015 09:44 AM, Alban Bedel wrote:
> >>> Older controllers don't implement "Device Address Advance" which allow
> >>> to pass the device address to the controller when it is received.
> >>> To support such controller we need to store the requested address and
> >>> only apply it after the next IN transfer completed on EP0.
> >>
> >>> diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
> >>
> >>>   case SETUP(USB_RECIP_DEVICE, USB_REQ_SET_ADDRESS):
> >>> - /*
> >>> -  * write address delayed (will take effect
> >>> -  * after the next IN txn)
> >>> -  */
> >>> - writel((r.wValue << 25) | (1 << 24), &udc->devaddr);
> >>> + /* The device address must be updated after the next IN
> >>> +  * request completed */
> >>> + controller.set_address = r.wValue;
> >>
> >> Presumably, bit 24 is the "device address advance" feature?
> >
> > Yes, bit 24 is the "device address advance" feature
> >
> >> I'd prefer it if new controllers used the existing code, but we deferred
> >> the write only for older controllers that don't support "device address
> >> advance". That reduces the possibility of regressions on controller HW
> >> that's already working. Presumably, there is some advantage using the
> >> new feature, rather than deferring the address change manually, e.g. it
> >> solves some race condition?
> >
> > I'm no USB expert, but AFAIU it is only a convenience to make the
> > driver code simpler. I though that having less code path and ifdef
> > would make the whole thing easier to maintain. However if that is
> > preferred I can implement it as you suggested.
> 
> Is there not a race condition?
> 
> 1) USB device controller completes the set address's IN transaction 
> (which I assume is the status stage of a control transaction)
> 
> 2) USB device re-programs address register according to the address that 
> was set
> 
> 3) USB host controller sends a USB transaction to the new address.
> 
> (1) must always happen first, but are (2) and (3) always guaranteed to 
> happen in the desired order? I would have assumed the "auto advance" 
> feature was so that the HW could atomically switch to responding to the 
> new address while it completes the set address transaction, to avoid any 
> window where it doesn't respond to the new address.

There is such a small window, however it is handled by the standard
as the host must wait at least 2 ms after set address, so that shouldn't
be a problem. However I saw that it should also be possible to unset the
address, this is not possible any more with my patch but should be easy
to fix.

> Of course, this is just pure conjecture.

The HW solution is a bit better, but it shouldn't make a difference
with compliant hosts. I would leave it to the maintainer to choose if we
should support both mode or spare some ifdef.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] net: asix: Fix ASIX 88772B with driver model

2016-08-02 Thread Alban Bedel
Commit 147271209a9d ("net: asix: fix operation without eeprom")
added a special handling for ASIX 88772B that enable another
type of header. This break the driver in DM mode as the extra handling
needed in the receive path is missing.

However this new header mode is not required and only seems to
increase the code complexity, so this patch revert this part of
commit 147271209a9d.

Change-Id: I7edc89f5714ead60e5204340ba05caf21b155593
Fixes: 147271209a9d ("net: asix: fix operation without eeprom")
Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c
index ad083cf8ae4a..1c6e967db1a0 100644
--- a/drivers/usb/eth/asix.c
+++ b/drivers/usb/eth/asix.c
@@ -67,11 +67,8 @@
 AX_MEDIUM_AC | AX_MEDIUM_RE)
 
 /* AX88772 & AX88178 RX_CTL values */
-#define AX_RX_CTL_RH2M 0x0200  /* 32-bit aligned RX IP header */
-#define AX_RX_CTL_RH1M 0x0100  /* Enable RX header format type 1 */
-#define AX_RX_CTL_SO   0x0080
-#define AX_RX_CTL_AB   0x0008
-#define AX_RX_HEADER_DEFAULT   (AX_RX_CTL_RH1M | AX_RX_CTL_RH2M)
+#define AX_RX_CTL_SO   0x0080
+#define AX_RX_CTL_AB   0x0008
 
 #define AX_DEFAULT_RX_CTL  \
(AX_RX_CTL_SO | AX_RX_CTL_AB)
@@ -98,8 +95,6 @@
 #define FLAG_TYPE_AX88772B (1U << 2)
 #define FLAG_EEPROM_MAC(1U << 3) /* initial mac address in 
eeprom */
 
-#define ASIX_USB_VENDOR_ID 0x0b95
-#define AX88772B_USB_PRODUCT_ID0x772b
 
 /* driver private */
 struct asix_private {
@@ -431,15 +426,10 @@ static int asix_init_common(struct ueth_data *dev, 
uint8_t *enetaddr)
int timeout = 0;
 #define TIMEOUT_RESOLUTION 50  /* ms */
int link_detected;
-   u32 ctl = AX_DEFAULT_RX_CTL;
 
debug("** %s()\n", __func__);
 
-   if ((dev->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) &&
-   (dev->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID))
-   ctl |= AX_RX_HEADER_DEFAULT;
-
-   if (asix_write_rx_ctl(dev, ctl) < 0)
+   if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0)
goto out_err;
 
if (asix_write_hwaddr_common(dev, enetaddr) < 0)
@@ -572,12 +562,6 @@ static int asix_recv(struct eth_device *eth)
return -1;
}
 
-   if ((dev->pusb_dev->descriptor.idVendor ==
-ASIX_USB_VENDOR_ID) &&
-   (dev->pusb_dev->descriptor.idProduct ==
-AX88772B_USB_PRODUCT_ID))
-   buf_ptr += 2;
-
/* Notify net stack */
net_process_received_packet(buf_ptr + sizeof(packet_len),
packet_len);
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/4] eth: asix88179: Prepare supporting the driver model

2016-08-02 Thread Alban Bedel
Change the prototype of a few functions to allow resuing the code for
the driver model.

Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix88179.c | 71 -
 1 file changed, 44 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 81eae04e3402..45106ce5ef59 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -259,36 +259,32 @@ static int asix_read_cmd(struct ueth_data *dev, u8 cmd, 
u16 value, u16 index,
return len == size ? 0 : ECOMM;
 }
 
-static int asix_read_mac(struct eth_device *eth)
+static int asix_read_mac(struct ueth_data *dev, uint8_t *enetaddr)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
-   u8 buf[ETH_ALEN];
+   int ret;
 
-   asix_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, 6, 6, buf);
-   debug("asix_read_mac() returning %02x:%02x:%02x:%02x:%02x:%02x\n",
- buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+   ret = asix_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, 6, 6, enetaddr);
+   if (ret < 0)
+   debug("Failed to read MAC address: %02x\n", ret);
 
-   memcpy(eth->enetaddr, buf, ETH_ALEN);
-
-   return 0;
+   return ret;
 }
 
-static int asix_write_mac(struct eth_device *eth)
+static int asix_write_mac(struct ueth_data *dev, uint8_t *enetaddr)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
int ret;
 
ret = asix_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-ETH_ALEN, eth->enetaddr);
+ETH_ALEN, enetaddr);
if (ret < 0)
debug("Failed to set MAC address: %02x\n", ret);
 
return ret;
 }
 
-static int asix_basic_reset(struct ueth_data *dev)
+static int asix_basic_reset(struct ueth_data *dev,
+   struct asix_private *dev_priv)
 {
-   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
u8 buf[5];
u16 *tmp16;
u8 *tmp;
@@ -387,13 +383,9 @@ static int asix_wait_link(struct ueth_data *dev)
}
 }
 
-/*
- * Asix callbacks
- */
-static int asix_init(struct eth_device *eth, bd_t *bd)
+static int asix_init_common(struct ueth_data *dev,
+   struct asix_private *dev_priv)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
-   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
u8 buf[2], tmp[5], link_sts;
u16 *tmp16, mode;
 
@@ -411,7 +403,7 @@ static int asix_init(struct eth_device *eth, bd_t *bd)
if (asix_wait_link(dev) != 0) {
/*reset device and try again*/
printf("Reset Ethernet Device\n");
-   asix_basic_reset(dev);
+   asix_basic_reset(dev, dev_priv);
if (asix_wait_link(dev) != 0)
goto out_err;
}
@@ -463,11 +455,10 @@ out_err:
return -1;
 }
 
-static int asix_send(struct eth_device *eth, void *packet, int length)
+static int asix_send_common(struct ueth_data *dev,
+   struct asix_private *dev_priv,
+   void *packet, int length)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
-   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
-
int err;
u32 packet_len, tx_hdr2;
int actual_len, framesize;
@@ -504,6 +495,32 @@ static int asix_send(struct eth_device *eth, void *packet, 
int length)
return err;
 }
 
+/*
+ * Asix callbacks
+ */
+static int asix_init(struct eth_device *eth, bd_t *bd)
+{
+   struct ueth_data *dev = (struct ueth_data *)eth->priv;
+   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
+
+   return asix_init_common(dev, dev_priv);
+}
+
+static int asix_write_hwaddr(struct eth_device *eth)
+{
+   struct ueth_data *dev = (struct ueth_data *)eth->priv;
+
+   return asix_write_mac(dev, eth->enetaddr);
+}
+
+static int asix_send(struct eth_device *eth, void *packet, int length)
+{
+   struct ueth_data *dev = (struct ueth_data *)eth->priv;
+   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
+
+   return asix_send_common(dev, dev_priv, packet, length);
+}
+
 static int asix_recv(struct eth_device *eth)
 {
struct ueth_data *dev = (struct ueth_data *)eth->priv;
@@ -702,14 +719,14 @@ int ax88179_eth_get_info(struct usb_device *dev, struct 
ueth_data *ss,
eth->send = asix_send;
eth->recv = asix_recv;
eth->halt = asix_halt;
-   eth->write_hwaddr = asix_write_mac;
+   eth->write_hwaddr = asix_write_hwaddr;
eth->priv = ss;
 
if (asix_basic_reset(ss))
return 0;
 
/* Get the MAC address */
-   if (asix_read_mac(eth))
+   if (as

[U-Boot] [PATCH 2/4] eth: asix88179: Fix receiving on big endian system

2016-08-02 Thread Alban Bedel
In asix_recv() the call to convert the endianess of the receive header
was applied on the wrong variable. Instead of converting rx_hdr it
converted pkt_hdr which is a pointer, and not yet initialiazed at this
point.

Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix88179.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 9e04c7c5c658..81eae04e3402 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -543,7 +543,7 @@ static int asix_recv(struct eth_device *eth)
 
 
rx_hdr = *(u32 *)(recv_buf + actual_len - 4);
-   le32_to_cpus(&pkt_hdr);
+   le32_to_cpus(&rx_hdr);
 
pkt_cnt = (u16)rx_hdr;
hdr_off = (u16)(rx_hdr >> 16);
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/4] eth: asix88179: Add VID:DID for Cypress GX3 USB Ethernet Adapter

2016-08-02 Thread Alban Bedel
Added support for the Cypress GX3 SuperSpeed to Gigabit Ethernet
Bridge Controller (VID_04b4/PID_3610).

Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix88179.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 5e1ea8693b0b..9e04c7c5c658 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -185,6 +185,7 @@
 #define FLAG_TYPE_SITECOM  (1U << 3)
 #define FLAG_TYPE_SAMSUNG  (1U << 4)
 #define FLAG_TYPE_LENOVO   (1U << 5)
+#define FLAG_TYPE_GX3  (1U << 6)
 
 /* local vars */
 static const struct {
@@ -596,6 +597,7 @@ static const struct asix_dongle asix_dongles[] = {
{ 0x0df6, 0x0072, FLAG_TYPE_SITECOM },
{ 0x04e8, 0xa100, FLAG_TYPE_SAMSUNG },
{ 0x17ef, 0x304b, FLAG_TYPE_LENOVO },
+   { 0x04b4, 0x3610, FLAG_TYPE_GX3 },
{ 0x, 0x, FLAG_NONE }   /* END - Do not remove */
 };
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 4/4] eth: asix88179: Add support for the driver model

2016-08-02 Thread Alban Bedel
Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix88179.c | 184 
 1 file changed, 184 insertions(+)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 45106ce5ef59..cc4ae3c17f16 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -197,10 +198,18 @@ static const struct {
{7, 0xcc, 0x4c, 0x04, 8},
 };
 
+#ifndef CONFIG_DM_ETH
 static int curr_eth_dev; /* index for name of next device detected */
+#endif
 
 /* driver private */
 struct asix_private {
+#ifdef CONFIG_DM_ETH
+   struct ueth_data ueth;
+   unsigned pkt_cnt;
+   uint8_t *pkt_data;
+   uint32_t *pkt_hdr;
+#endif
int flags;
int rx_urb_size;
int maxpacketsize;
@@ -495,6 +504,7 @@ static int asix_send_common(struct ueth_data *dev,
return err;
 }
 
+#ifndef CONFIG_DM_ETH
 /*
  * Asix callbacks
  */
@@ -732,3 +742,177 @@ int ax88179_eth_get_info(struct usb_device *dev, struct 
ueth_data *ss,
 
return 1;
 }
+
+#else /* !CONFIG_DM_ETH */
+
+static int ax88179_eth_start(struct udevice *dev)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+
+   return asix_init_common(&priv->ueth, priv);
+}
+
+void ax88179_eth_stop(struct udevice *dev)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   debug("** %s()\n", __func__);
+
+   usb_ether_advance_rxbuf(ueth, -1);
+   priv->pkt_cnt = 0;
+   priv->pkt_data = NULL;
+   priv->pkt_hdr = NULL;
+}
+
+int ax88179_eth_send(struct udevice *dev, void *packet, int length)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+
+   return asix_send_common(&priv->ueth, priv, packet, length);
+}
+
+int ax88179_eth_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+   int ret, len;
+   u16 pkt_len;
+
+   /* No packet left, get a new one */
+   if (priv->pkt_cnt == 0) {
+   uint8_t *ptr;
+   u16 pkt_cnt;
+   u16 hdr_off;
+   u32 rx_hdr;
+
+   len = usb_ether_get_rx_bytes(ueth, &ptr);
+   debug("%s: first try, len=%d\n", __func__, len);
+   if (!len) {
+   if (!(flags & ETH_RECV_CHECK_DEVICE))
+   return -EAGAIN;
+
+   ret = usb_ether_receive(ueth, priv->rx_urb_size);
+   if (ret < 0)
+   return ret;
+
+   len = usb_ether_get_rx_bytes(ueth, &ptr);
+   debug("%s: second try, len=%d\n", __func__, len);
+   }
+
+   if (len < 4) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return -EMSGSIZE;
+   }
+
+   rx_hdr = *(u32 *)(ptr + len - 4);
+   le32_to_cpus(&rx_hdr);
+
+   pkt_cnt = (u16)rx_hdr;
+   if (pkt_cnt == 0) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return 0;
+   }
+
+   hdr_off = (u16)(rx_hdr >> 16);
+   if (hdr_off > len - 4) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return -EIO;
+   }
+
+   priv->pkt_cnt = pkt_cnt;
+   priv->pkt_data = ptr;
+   priv->pkt_hdr = (u32 *)(ptr + hdr_off);
+   debug("%s: %d packets received, pkt header at %d\n",
+ __func__, (int)priv->pkt_cnt, (int)hdr_off);
+   }
+
+   le32_to_cpus(priv->pkt_hdr);
+   pkt_len = (*priv->pkt_hdr >> 16) & 0x1fff;
+
+   *packetp = priv->pkt_data + 2;
+
+   priv->pkt_data += (pkt_len + 7) & 0xFFF8;
+   priv->pkt_cnt--;
+   priv->pkt_hdr++;
+
+   debug("%s: return packet of %d bytes (%d packets left)\n",
+ __func__, (int)pkt_len, priv->pkt_cnt);
+   return pkt_len;
+}
+
+static int ax88179_free_pkt(struct udevice *dev, uchar *packet, int packet_len)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   if (priv->pkt_cnt == 0)
+   usb_ether_advance_rxbuf(ueth, -1);
+
+   return 0;
+}
+
+int ax88179_write_hwaddr(struct udevice *dev)
+{
+   struct eth_pdata *pdata = dev_get_platdata(dev);
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   return asix_write_mac(ueth, pdata->enetaddr);
+}
+
+static int ax88179_eth_probe(struct udevice *dev)
+{
+   struct eth_pdata *pdata = dev_get_platda

[U-Boot] [PATCH] net: e1000: Fix the build with driver model and SPI EEPROM

2016-08-03 Thread Alban Bedel
When adding support for the driver model the SPI EEPROM feature had
been ignored. Fix the build with both CONFIG_DM_ETH and
CONFIG_E1000_SPI enabled.

Signed-off-by: Alban Bedel 
---
 drivers/net/e1000.c |  6 +-
 drivers/net/e1000_spi.c | 57 +
 2 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 196989b3864f..3332ad95d467 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5513,7 +5513,8 @@ static int do_e1000(cmd_tbl_t *cmdtp, int flag,
struct udevice *dev;
char name[30];
int ret;
-#else
+#endif
+#if !defined(CONFIG_DM_ETH) || defined(CONFIG_E1000_SPI)
struct e1000_hw *hw;
 #endif
int cardnum;
@@ -5549,6 +5550,9 @@ static int do_e1000(cmd_tbl_t *cmdtp, int flag,
}
 
 #ifdef CONFIG_E1000_SPI
+#ifdef CONFIG_DM_ETH
+   hw = dev_get_priv(dev);
+#endif
/* Handle the "SPI" subcommand */
if (!strcmp(argv[2], "spi"))
return do_e1000_spi(cmdtp, hw, argc - 3, argv + 3);
diff --git a/drivers/net/e1000_spi.c b/drivers/net/e1000_spi.c
index 576ddb8b2429..6ec3120a2d15 100644
--- a/drivers/net/e1000_spi.c
+++ b/drivers/net/e1000_spi.c
@@ -94,17 +94,17 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
 
/* Make sure it has an SPI chip */
if (hw->eeprom.type != e1000_eeprom_spi) {
-   E1000_ERR(hw->nic, "No attached SPI EEPROM found!\n");
+   E1000_ERR(hw, "No attached SPI EEPROM found!\n");
return NULL;
}
 
/* Argument sanity checks */
if (cs != 0) {
-   E1000_ERR(hw->nic, "No such SPI chip: %u\n", cs);
+   E1000_ERR(hw, "No such SPI chip: %u\n", cs);
return NULL;
}
if (mode != SPI_MODE_0) {
-   E1000_ERR(hw->nic, "Only SPI MODE-0 is supported!\n");
+   E1000_ERR(hw, "Only SPI MODE-0 is supported!\n");
return NULL;
}
 
@@ -124,7 +124,7 @@ int spi_claim_bus(struct spi_slave *spi)
struct e1000_hw *hw = e1000_hw_from_spi(spi);
 
if (e1000_acquire_eeprom(hw)) {
-   E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n");
+   E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n");
return -1;
}
 
@@ -342,41 +342,41 @@ static int do_e1000_spi_show(cmd_tbl_t *cmdtp, struct 
e1000_hw *hw,
 
/* Extra sanity checks */
if (!length) {
-   E1000_ERR(hw->nic, "Requested zero-sized dump!\n");
+   E1000_ERR(hw, "Requested zero-sized dump!\n");
return 1;
}
if ((0x1 < length) || (0x1 - length < offset)) {
-   E1000_ERR(hw->nic, "Can't dump past 0x!\n");
+   E1000_ERR(hw, "Can't dump past 0x!\n");
return 1;
}
 
/* Allocate a buffer to hold stuff */
buffer = malloc(length);
if (!buffer) {
-   E1000_ERR(hw->nic, "Out of Memory!\n");
+   E1000_ERR(hw, "Out of Memory!\n");
return 1;
}
 
/* Acquire the EEPROM and perform the dump */
if (e1000_acquire_eeprom(hw)) {
-   E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n");
+   E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n");
free(buffer);
return 1;
}
err = e1000_spi_eeprom_dump(hw, buffer, offset, length, true);
e1000_release_eeprom(hw);
if (err) {
-   E1000_ERR(hw->nic, "Interrupted!\n");
+   E1000_ERR(hw, "Interrupted!\n");
free(buffer);
return 1;
}
 
/* Now hexdump the result */
printf("%s: = Intel e1000 EEPROM (0x%04hX - 0x%04hX) =",
-   hw->nic->name, offset, offset + length - 1);
+   hw->name, offset, offset + length - 1);
for (i = 0; i < length; i++) {
if ((i & 0xF) == 0)
-   printf("\n%s: %04hX: ", hw->nic->name, offset + i);
+   printf("\n%s: %04hX: ", hw->name, offset + i);
else if ((i & 0xF) == 0x8)
printf(" ");
printf(" %02hx", buffer[i]);
@@ -407,29 +407,29 @@ static int do_e1000_spi_dump(cmd_tbl_t *cmdtp, struct 
e1000_hw *hw,
 
/* Extra sanity checks */
if (!length) {
-   E1000_ERR(hw->nic, "Requested zero-sized dump!\n");
+   E1000_ERR(hw, "Requested zero-sized 

[U-Boot] [PATCH] tegra: config: Add 'pci enum' to preboot when PCI is enabled

2016-08-03 Thread Alban Bedel
For simplicity and backward compatibility automatically run 'pci enum'
via preboot when PCI is enabled. As preboot is already used for the
USB keyboard support this rework how CONFIG_PREBOOT is set to allow
combining several commands.

Signed-off-by: Alban Bedel 
---
 include/configs/tegra-common-post.h | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/configs/tegra-common-post.h 
b/include/configs/tegra-common-post.h
index b206ce4bf93c..eff4c760797d 100644
--- a/include/configs/tegra-common-post.h
+++ b/include/configs/tegra-common-post.h
@@ -42,9 +42,10 @@
 #ifdef CONFIG_USB_KEYBOARD
 #define STDIN_KBD_USB ",usbkbd"
 #define CONFIG_SYS_USB_EVENT_POLL
-#define CONFIG_PREBOOT "usb start"
+#define PREBOOT_USB "usb start;"
 #else
 #define STDIN_KBD_USB ""
+#define PREBOOT_USB ""
 #endif
 
 #ifdef CONFIG_LCD
@@ -89,6 +90,12 @@
 #define INITRD_HIGH ""
 #endif
 
+#ifdef CONFIG_PCI
+#define PREBOOT_PCI "pci enum;"
+#else
+#define PREBOOT_PCI ""
+#endif
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
TEGRA_DEVICE_SETTINGS \
MEM_LAYOUT_ENV_SETTINGS \
@@ -102,6 +109,10 @@
 #define CONFIG_TEGRA_SPI
 #endif
 
+#if defined(CONFIG_USB_KEYBOARD) || defined(CONFIG_PCI)
+#define CONFIG_PREBOOT PREBOOT_USB PREBOOT_PCI
+#endif
+
 /* overrides for SPL build here */
 #ifdef CONFIG_SPL_BUILD
 
-- 
2.9.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] net: asix: Fix ASIX 88772B with driver model

2016-08-03 Thread Alban Bedel
On Wed, 3 Aug 2016 09:00:42 +0200
Marek Vasut  wrote:

> On 08/03/2016 07:32 AM, Alban Bedel wrote:
> > Commit 147271209a9d ("net: asix: fix operation without eeprom")
> > added a special handling for ASIX 88772B that enable another
> > type of header. This break the driver in DM mode as the extra handling
> > needed in the receive path is missing.
> 
> So add the extra handling ?

I can do that too, but I though u-boot preferred to avoid useless code.

> > However this new header mode is not required and only seems to
> > increase the code complexity, so this patch revert this part of
> > commit 147271209a9d.
> 
> Why is it not required ?

It works fine without, since 2012. In fact this change is not even
mentioned in the log of commit 147271209a9d, so I really don't know why
it was added in the first place. As can be seen in the revert all it
does is adding 2 bytes to the USB packets that are then just skipped.
Seems pretty useless to me.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2] eth: asix88179: Add support for the driver model

2016-08-03 Thread Alban Bedel
Adjust this driver to support driver model for Ethernet.

Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix88179.c | 184 
 1 file changed, 184 insertions(+)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 45106ce5ef59..cc4ae3c17f16 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -197,10 +198,18 @@ static const struct {
{7, 0xcc, 0x4c, 0x04, 8},
 };
 
+#ifndef CONFIG_DM_ETH
 static int curr_eth_dev; /* index for name of next device detected */
+#endif
 
 /* driver private */
 struct asix_private {
+#ifdef CONFIG_DM_ETH
+   struct ueth_data ueth;
+   unsigned pkt_cnt;
+   uint8_t *pkt_data;
+   uint32_t *pkt_hdr;
+#endif
int flags;
int rx_urb_size;
int maxpacketsize;
@@ -495,6 +504,7 @@ static int asix_send_common(struct ueth_data *dev,
return err;
 }
 
+#ifndef CONFIG_DM_ETH
 /*
  * Asix callbacks
  */
@@ -732,3 +742,177 @@ int ax88179_eth_get_info(struct usb_device *dev, struct 
ueth_data *ss,
 
return 1;
 }
+
+#else /* !CONFIG_DM_ETH */
+
+static int ax88179_eth_start(struct udevice *dev)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+
+   return asix_init_common(&priv->ueth, priv);
+}
+
+void ax88179_eth_stop(struct udevice *dev)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   debug("** %s()\n", __func__);
+
+   usb_ether_advance_rxbuf(ueth, -1);
+   priv->pkt_cnt = 0;
+   priv->pkt_data = NULL;
+   priv->pkt_hdr = NULL;
+}
+
+int ax88179_eth_send(struct udevice *dev, void *packet, int length)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+
+   return asix_send_common(&priv->ueth, priv, packet, length);
+}
+
+int ax88179_eth_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+   int ret, len;
+   u16 pkt_len;
+
+   /* No packet left, get a new one */
+   if (priv->pkt_cnt == 0) {
+   uint8_t *ptr;
+   u16 pkt_cnt;
+   u16 hdr_off;
+   u32 rx_hdr;
+
+   len = usb_ether_get_rx_bytes(ueth, &ptr);
+   debug("%s: first try, len=%d\n", __func__, len);
+   if (!len) {
+   if (!(flags & ETH_RECV_CHECK_DEVICE))
+   return -EAGAIN;
+
+   ret = usb_ether_receive(ueth, priv->rx_urb_size);
+   if (ret < 0)
+   return ret;
+
+   len = usb_ether_get_rx_bytes(ueth, &ptr);
+   debug("%s: second try, len=%d\n", __func__, len);
+   }
+
+   if (len < 4) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return -EMSGSIZE;
+   }
+
+   rx_hdr = *(u32 *)(ptr + len - 4);
+   le32_to_cpus(&rx_hdr);
+
+   pkt_cnt = (u16)rx_hdr;
+   if (pkt_cnt == 0) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return 0;
+   }
+
+   hdr_off = (u16)(rx_hdr >> 16);
+   if (hdr_off > len - 4) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return -EIO;
+   }
+
+   priv->pkt_cnt = pkt_cnt;
+   priv->pkt_data = ptr;
+   priv->pkt_hdr = (u32 *)(ptr + hdr_off);
+   debug("%s: %d packets received, pkt header at %d\n",
+ __func__, (int)priv->pkt_cnt, (int)hdr_off);
+   }
+
+   le32_to_cpus(priv->pkt_hdr);
+   pkt_len = (*priv->pkt_hdr >> 16) & 0x1fff;
+
+   *packetp = priv->pkt_data + 2;
+
+   priv->pkt_data += (pkt_len + 7) & 0xFFF8;
+   priv->pkt_cnt--;
+   priv->pkt_hdr++;
+
+   debug("%s: return packet of %d bytes (%d packets left)\n",
+ __func__, (int)pkt_len, priv->pkt_cnt);
+   return pkt_len;
+}
+
+static int ax88179_free_pkt(struct udevice *dev, uchar *packet, int packet_len)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   if (priv->pkt_cnt == 0)
+   usb_ether_advance_rxbuf(ueth, -1);
+
+   return 0;
+}
+
+int ax88179_write_hwaddr(struct udevice *dev)
+{
+   struct eth_pdata *pdata = dev_get_platdata(dev);
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   return asix_write_mac(ueth, pdata->enetaddr);
+}
+
+static int ax88179_eth_probe(struct udevi

Re: [U-Boot] [PATCH] tegra: config: Add 'pci enum' to preboot when PCI is enabled

2016-08-04 Thread Alban Bedel
On Wed, 3 Aug 2016 19:16:57 -0600
Simon Glass  wrote:

> Hi,
> 
> On 3 August 2016 at 09:37, Stephen Warren  wrote:
> > On 08/03/2016 03:35 AM, Alban Bedel wrote:
> >>
> >> For simplicity and backward compatibility automatically run 'pci enum'
> >> via preboot when PCI is enabled. As preboot is already used for the
> >> USB keyboard support this rework how CONFIG_PREBOOT is set to allow
> >> combining several commands.
> >
> >
> > For better or worse, this was a deliberate change, so I don't think this
> > patch will be accepted.
> >
> > If it is, then you should apply it to all boards, not just Tegra boards, and
> > adjust include/config_distro_bootcmd.h since it will no longer need to run
> > "pci enum", and also test/py/tests/test_net.py won't need to either.
> 
> The boards which need PCI to boot are still few... we've talked about
> this before. It would be great if we could find a way to detect or be
> told that boot devices are on PCI and probe it accordingly. Perhaps we
> should have a driver flag?

In my case I needed this for network boot. However I just found out
that with a properly reseted environment this is already handled, so
this is not needed. Sorry for the noise.

Alban



signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] net: asix: Fix ASIX 88772B with driver model

2016-08-04 Thread Alban Bedel
On Wed, 3 Aug 2016 15:23:30 +
Marcel Ziswiler  wrote:

> On Wed, 2016-08-03 at 15:51 +0200, Marek Vasut wrote:
> > On 08/03/2016 11:46 AM, Alban Bedel wrote:
> > > 
> > > On Wed, 3 Aug 2016 09:00:42 +0200
> > > Marek Vasut  wrote:
> > > 
> > > > 
> > > > On 08/03/2016 07:32 AM, Alban Bedel wrote:
> > > > > 
> > > > > Commit 147271209a9d ("net: asix: fix operation without eeprom")
> > > > > added a special handling for ASIX 88772B that enable another
> > > > > type of header. This break the driver in DM mode as the extra
> > > > > handling
> > > > > needed in the receive path is missing.
> > > > So add the extra handling ?
> > > I can do that too, but I though u-boot preferred to avoid useless
> > > code.
> > Yes, if it is useless.
> > 
> > > 
> > > > 
> > > > > 
> > > > > However this new header mode is not required and only seems to
> > > > > increase the code complexity, so this patch revert this part of
> > > > > commit 147271209a9d.
> > > > Why is it not required ?
> > > It works fine without, since 2012. In fact this change is not even
> > > mentioned in the log of commit 147271209a9d, so I really don't know
> > > why
> > > it was added in the first place. As can be seen in the revert all
> > > it
> > > does is adding 2 bytes to the USB packets that are then just
> > > skipped.
> > > Seems pretty useless to me.
> > I would like to get some feedback on this from Marcel, since he added
> > this stuff.
> 
> Yes, sorry. I just came back from vacation and started looking into it
> now. As far as I remember on our hardware without this Ethernet did not
> quite work reliably. This also means that with driver model so far it
> does not work for us which I fed back to Simon once but so far this has
> not been resolved. That fix came from some early U-Boot work done by
> Antmicro way back and I am missing some of the history.

Then I'll do a new patch that just fix the driver model receive path.

Alban



signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] net: e1000: Allow to use e1000 SPI command with DM

2016-08-08 Thread Alban Bedel
On Thu, 4 Aug 2016 11:39:49 -0500
Joe Hershberger  wrote:

> On Tue, Aug 2, 2016 at 9:42 PM, Yaroslav K.  wrote:
> > Fix compile errors when enabling CONFIG_DM_ETH,
> > CONFIG_CMD_E1000 and CONFIG_E1000_SPI.
> >
> > Signed-off-by: Yaroslav K. 
> 
> Something about this patch email is malformed and not parsed by
> patchwork properly.
> 
> Another patch with the same intent was also sent just after this one:
> https://patchwork.ozlabs.org/patch/655311/
> 
> With permission of you and Alban Bedel I'll add both of your SOB to
> Alban's patch.

Please do.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 2/2] eth: asix88179: Add support for the driver model

2016-08-09 Thread Alban Bedel
Adjust this driver to support driver model for Ethernet.

Signed-off-by: Alban Bedel 
---
 drivers/usb/eth/asix88179.c | 184 
 1 file changed, 184 insertions(+)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index f3179bcf1e2e..7548269f958a 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -197,10 +198,18 @@ static const struct {
{7, 0xcc, 0x4c, 0x04, 8},
 };
 
+#ifndef CONFIG_DM_ETH
 static int curr_eth_dev; /* index for name of next device detected */
+#endif
 
 /* driver private */
 struct asix_private {
+#ifdef CONFIG_DM_ETH
+   struct ueth_data ueth;
+   unsigned pkt_cnt;
+   uint8_t *pkt_data;
+   uint32_t *pkt_hdr;
+#endif
int flags;
int rx_urb_size;
int maxpacketsize;
@@ -495,6 +504,7 @@ static int asix_send_common(struct ueth_data *dev,
return err;
 }
 
+#ifndef CONFIG_DM_ETH
 /*
  * Asix callbacks
  */
@@ -734,3 +744,177 @@ int ax88179_eth_get_info(struct usb_device *dev, struct 
ueth_data *ss,
 
return 1;
 }
+
+#else /* !CONFIG_DM_ETH */
+
+static int ax88179_eth_start(struct udevice *dev)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+
+   return asix_init_common(&priv->ueth, priv);
+}
+
+void ax88179_eth_stop(struct udevice *dev)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   debug("** %s()\n", __func__);
+
+   usb_ether_advance_rxbuf(ueth, -1);
+   priv->pkt_cnt = 0;
+   priv->pkt_data = NULL;
+   priv->pkt_hdr = NULL;
+}
+
+int ax88179_eth_send(struct udevice *dev, void *packet, int length)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+
+   return asix_send_common(&priv->ueth, priv, packet, length);
+}
+
+int ax88179_eth_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+   int ret, len;
+   u16 pkt_len;
+
+   /* No packet left, get a new one */
+   if (priv->pkt_cnt == 0) {
+   uint8_t *ptr;
+   u16 pkt_cnt;
+   u16 hdr_off;
+   u32 rx_hdr;
+
+   len = usb_ether_get_rx_bytes(ueth, &ptr);
+   debug("%s: first try, len=%d\n", __func__, len);
+   if (!len) {
+   if (!(flags & ETH_RECV_CHECK_DEVICE))
+   return -EAGAIN;
+
+   ret = usb_ether_receive(ueth, priv->rx_urb_size);
+   if (ret < 0)
+   return ret;
+
+   len = usb_ether_get_rx_bytes(ueth, &ptr);
+   debug("%s: second try, len=%d\n", __func__, len);
+   }
+
+   if (len < 4) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return -EMSGSIZE;
+   }
+
+   rx_hdr = *(u32 *)(ptr + len - 4);
+   le32_to_cpus(&rx_hdr);
+
+   pkt_cnt = (u16)rx_hdr;
+   if (pkt_cnt == 0) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return 0;
+   }
+
+   hdr_off = (u16)(rx_hdr >> 16);
+   if (hdr_off > len - 4) {
+   usb_ether_advance_rxbuf(ueth, -1);
+   return -EIO;
+   }
+
+   priv->pkt_cnt = pkt_cnt;
+   priv->pkt_data = ptr;
+   priv->pkt_hdr = (u32 *)(ptr + hdr_off);
+   debug("%s: %d packets received, pkt header at %d\n",
+ __func__, (int)priv->pkt_cnt, (int)hdr_off);
+   }
+
+   le32_to_cpus(priv->pkt_hdr);
+   pkt_len = (*priv->pkt_hdr >> 16) & 0x1fff;
+
+   *packetp = priv->pkt_data + 2;
+
+   priv->pkt_data += (pkt_len + 7) & 0xFFF8;
+   priv->pkt_cnt--;
+   priv->pkt_hdr++;
+
+   debug("%s: return packet of %d bytes (%d packets left)\n",
+ __func__, (int)pkt_len, priv->pkt_cnt);
+   return pkt_len;
+}
+
+static int ax88179_free_pkt(struct udevice *dev, uchar *packet, int packet_len)
+{
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   if (priv->pkt_cnt == 0)
+   usb_ether_advance_rxbuf(ueth, -1);
+
+   return 0;
+}
+
+int ax88179_write_hwaddr(struct udevice *dev)
+{
+   struct eth_pdata *pdata = dev_get_platdata(dev);
+   struct asix_private *priv = dev_get_priv(dev);
+   struct ueth_data *ueth = &priv->ueth;
+
+   return asix_write_mac(ueth, pdata->enetaddr);
+}
+
+static int ax88179_eth_probe(struct udevi

[U-Boot] [PATCH v3 1/2] eth: asix88179: Prepare supporting the driver model

2016-08-09 Thread Alban Bedel
Change the prototype of a few functions to allow resuing the code for
the driver model.

Signed-off-by: Alban Bedel 
---
Changelog:
v3: * Don't break the build without driver model
---
 drivers/usb/eth/asix88179.c | 75 -
 1 file changed, 47 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/eth/asix88179.c b/drivers/usb/eth/asix88179.c
index 81eae04e3402..f3179bcf1e2e 100644
--- a/drivers/usb/eth/asix88179.c
+++ b/drivers/usb/eth/asix88179.c
@@ -259,36 +259,32 @@ static int asix_read_cmd(struct ueth_data *dev, u8 cmd, 
u16 value, u16 index,
return len == size ? 0 : ECOMM;
 }
 
-static int asix_read_mac(struct eth_device *eth)
+static int asix_read_mac(struct ueth_data *dev, uint8_t *enetaddr)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
-   u8 buf[ETH_ALEN];
+   int ret;
 
-   asix_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, 6, 6, buf);
-   debug("asix_read_mac() returning %02x:%02x:%02x:%02x:%02x:%02x\n",
- buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+   ret = asix_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, 6, 6, enetaddr);
+   if (ret < 0)
+   debug("Failed to read MAC address: %02x\n", ret);
 
-   memcpy(eth->enetaddr, buf, ETH_ALEN);
-
-   return 0;
+   return ret;
 }
 
-static int asix_write_mac(struct eth_device *eth)
+static int asix_write_mac(struct ueth_data *dev, uint8_t *enetaddr)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
int ret;
 
ret = asix_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
-ETH_ALEN, eth->enetaddr);
+ETH_ALEN, enetaddr);
if (ret < 0)
debug("Failed to set MAC address: %02x\n", ret);
 
return ret;
 }
 
-static int asix_basic_reset(struct ueth_data *dev)
+static int asix_basic_reset(struct ueth_data *dev,
+   struct asix_private *dev_priv)
 {
-   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
u8 buf[5];
u16 *tmp16;
u8 *tmp;
@@ -387,13 +383,9 @@ static int asix_wait_link(struct ueth_data *dev)
}
 }
 
-/*
- * Asix callbacks
- */
-static int asix_init(struct eth_device *eth, bd_t *bd)
+static int asix_init_common(struct ueth_data *dev,
+   struct asix_private *dev_priv)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
-   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
u8 buf[2], tmp[5], link_sts;
u16 *tmp16, mode;
 
@@ -411,7 +403,7 @@ static int asix_init(struct eth_device *eth, bd_t *bd)
if (asix_wait_link(dev) != 0) {
/*reset device and try again*/
printf("Reset Ethernet Device\n");
-   asix_basic_reset(dev);
+   asix_basic_reset(dev, dev_priv);
if (asix_wait_link(dev) != 0)
goto out_err;
}
@@ -463,11 +455,10 @@ out_err:
return -1;
 }
 
-static int asix_send(struct eth_device *eth, void *packet, int length)
+static int asix_send_common(struct ueth_data *dev,
+   struct asix_private *dev_priv,
+   void *packet, int length)
 {
-   struct ueth_data *dev = (struct ueth_data *)eth->priv;
-   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
-
int err;
u32 packet_len, tx_hdr2;
int actual_len, framesize;
@@ -504,6 +495,32 @@ static int asix_send(struct eth_device *eth, void *packet, 
int length)
return err;
 }
 
+/*
+ * Asix callbacks
+ */
+static int asix_init(struct eth_device *eth, bd_t *bd)
+{
+   struct ueth_data *dev = (struct ueth_data *)eth->priv;
+   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
+
+   return asix_init_common(dev, dev_priv);
+}
+
+static int asix_write_hwaddr(struct eth_device *eth)
+{
+   struct ueth_data *dev = (struct ueth_data *)eth->priv;
+
+   return asix_write_mac(dev, eth->enetaddr);
+}
+
+static int asix_send(struct eth_device *eth, void *packet, int length)
+{
+   struct ueth_data *dev = (struct ueth_data *)eth->priv;
+   struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
+
+   return asix_send_common(dev, dev_priv, packet, length);
+}
+
 static int asix_recv(struct eth_device *eth)
 {
struct ueth_data *dev = (struct ueth_data *)eth->priv;
@@ -693,6 +710,8 @@ int ax88179_eth_probe(struct usb_device *dev, unsigned int 
ifnum,
 int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
struct eth_device *eth)
 {
+   struct asix_private *dev_priv = (struct asix_private *)ss->dev_priv;
+
if (!eth) {
debug("%s: missing parameter.\n", __func__);
  

Re: [U-Boot] [PATCH] net: asix: Fix ASIX 88772B with driver model

2016-08-11 Thread Alban Bedel
On Thu, 11 Aug 2016 11:26:23 +0200
Marek Vasut  wrote:

> On 08/11/2016 10:52 AM, Alban Bedel wrote:
> > On Tue, 9 Aug 2016 14:32:14 +0200
> > Marek Vasut  wrote:
> > 
> >> On 08/09/2016 02:14 PM, Marcel Ziswiler wrote:
> >>> On Thu, 2016-08-04 at 11:12 +0200, Marek Vasut wrote:
> >>>> On 08/04/2016 11:07 AM, Alban Bedel wrote:
> >>>>>
> >>>>> On Wed, 3 Aug 2016 15:23:30 +
> >>>>> Marcel Ziswiler  wrote:
> >>>>>
> >>>>>>
> >>>>>> On Wed, 2016-08-03 at 15:51 +0200, Marek Vasut wrote:
> >>>>>>>
> >>>>>>> On 08/03/2016 11:46 AM, Alban Bedel wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> On Wed, 3 Aug 2016 09:00:42 +0200
> >>>>>>>> Marek Vasut  wrote:
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On 08/03/2016 07:32 AM, Alban Bedel wrote:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Commit 147271209a9d ("net: asix: fix operation without
> >>>>>>>>>> eeprom")
> >>>>>>>>>> added a special handling for ASIX 88772B that enable
> >>>>>>>>>> another
> >>>>>>>>>> type of header. This break the driver in DM mode as the
> >>>>>>>>>> extra
> >>>>>>>>>> handling
> >>>>>>>>>> needed in the receive path is missing.
> >>>>>>>>> So add the extra handling ?
> >>>>>>>> I can do that too, but I though u-boot preferred to avoid
> >>>>>>>> useless
> >>>>>>>> code.
> >>>>>>> Yes, if it is useless.
> >>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> However this new header mode is not required and only
> >>>>>>>>>> seems to
> >>>>>>>>>> increase the code complexity, so this patch revert this
> >>>>>>>>>> part of
> >>>>>>>>>> commit 147271209a9d.
> >>>>>>>>> Why is it not required ?
> >>>>>>>> It works fine without, since 2012. In fact this change is not
> >>>>>>>> even
> >>>>>>>> mentioned in the log of commit 147271209a9d, so I really
> >>>>>>>> don't know
> >>>>>>>> why
> >>>>>>>> it was added in the first place. As can be seen in the revert
> >>>>>>>> all
> >>>>>>>> it
> >>>>>>>> does is adding 2 bytes to the USB packets that are then just
> >>>>>>>> skipped.
> >>>>>>>> Seems pretty useless to me.
> >>>>>>> I would like to get some feedback on this from Marcel, since he
> >>>>>>> added
> >>>>>>> this stuff.
> >>>>>> Yes, sorry. I just came back from vacation and started looking
> >>>>>> into it
> >>>>>> now. As far as I remember on our hardware without this Ethernet
> >>>>>> did not
> >>>>>> quite work reliably. This also means that with driver model so
> >>>>>> far it
> >>>>>> does not work for us which I fed back to Simon once but so far
> >>>>>> this has
> >>>>>> not been resolved. That fix came from some early U-Boot work done
> >>>>>> by
> >>>>>> Antmicro way back and I am missing some of the history.
> >>>>> Then I'll do a new patch that just fix the driver model receive
> >>>>> path.
> >>>> Hold on. Marcel, can you maybe test if removing this code has any
> >>>> impact
> >>>> on the behavior now ?
> >>>
> >>> Sorry for the delay. I tested Alban's patch now both on Toradex Colibri
> >>> T20 as well as T30 and its on-module ASIX USB-to-Ethernet chip actually
> >>> works perfectly aside from the occasional EHCI timed out on TD -
> >>> token=0x88008d80 Rx: failed to receive: -5 message which last I checked
> >>> with Simon is still unresolved but was already there long before any of
> >>> the driver model work started.
> >>>
> >>> Tested-by: Marcel Ziswiler 
> >>> Tested-on: Colibri T20/T30 on Colibri Evaluation Board
> >>>
> > 
> > Will this be applied for the upcoming release?
> 
> Yeah. Why the hurry though ?

I was just wondering because all the other patches I submitted have
been applied but this one still seems to be on hold.

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] net: asix: Fix ASIX 88772B with driver model

2016-08-11 Thread Alban Bedel
On Tue, 9 Aug 2016 14:32:14 +0200
Marek Vasut  wrote:

> On 08/09/2016 02:14 PM, Marcel Ziswiler wrote:
> > On Thu, 2016-08-04 at 11:12 +0200, Marek Vasut wrote:
> >> On 08/04/2016 11:07 AM, Alban Bedel wrote:
> >>>
> >>> On Wed, 3 Aug 2016 15:23:30 +
> >>> Marcel Ziswiler  wrote:
> >>>
> >>>>
> >>>> On Wed, 2016-08-03 at 15:51 +0200, Marek Vasut wrote:
> >>>>>
> >>>>> On 08/03/2016 11:46 AM, Alban Bedel wrote:
> >>>>>>
> >>>>>>
> >>>>>> On Wed, 3 Aug 2016 09:00:42 +0200
> >>>>>> Marek Vasut  wrote:
> >>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> On 08/03/2016 07:32 AM, Alban Bedel wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Commit 147271209a9d ("net: asix: fix operation without
> >>>>>>>> eeprom")
> >>>>>>>> added a special handling for ASIX 88772B that enable
> >>>>>>>> another
> >>>>>>>> type of header. This break the driver in DM mode as the
> >>>>>>>> extra
> >>>>>>>> handling
> >>>>>>>> needed in the receive path is missing.
> >>>>>>> So add the extra handling ?
> >>>>>> I can do that too, but I though u-boot preferred to avoid
> >>>>>> useless
> >>>>>> code.
> >>>>> Yes, if it is useless.
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> However this new header mode is not required and only
> >>>>>>>> seems to
> >>>>>>>> increase the code complexity, so this patch revert this
> >>>>>>>> part of
> >>>>>>>> commit 147271209a9d.
> >>>>>>> Why is it not required ?
> >>>>>> It works fine without, since 2012. In fact this change is not
> >>>>>> even
> >>>>>> mentioned in the log of commit 147271209a9d, so I really
> >>>>>> don't know
> >>>>>> why
> >>>>>> it was added in the first place. As can be seen in the revert
> >>>>>> all
> >>>>>> it
> >>>>>> does is adding 2 bytes to the USB packets that are then just
> >>>>>> skipped.
> >>>>>> Seems pretty useless to me.
> >>>>> I would like to get some feedback on this from Marcel, since he
> >>>>> added
> >>>>> this stuff.
> >>>> Yes, sorry. I just came back from vacation and started looking
> >>>> into it
> >>>> now. As far as I remember on our hardware without this Ethernet
> >>>> did not
> >>>> quite work reliably. This also means that with driver model so
> >>>> far it
> >>>> does not work for us which I fed back to Simon once but so far
> >>>> this has
> >>>> not been resolved. That fix came from some early U-Boot work done
> >>>> by
> >>>> Antmicro way back and I am missing some of the history.
> >>> Then I'll do a new patch that just fix the driver model receive
> >>> path.
> >> Hold on. Marcel, can you maybe test if removing this code has any
> >> impact
> >> on the behavior now ?
> > 
> > Sorry for the delay. I tested Alban's patch now both on Toradex Colibri
> > T20 as well as T30 and its on-module ASIX USB-to-Ethernet chip actually
> > works perfectly aside from the occasional EHCI timed out on TD -
> > token=0x88008d80 Rx: failed to receive: -5 message which last I checked
> > with Simon is still unresolved but was already there long before any of
> > the driver model work started.
> > 
> > Tested-by: Marcel Ziswiler 
> > Tested-on: Colibri T20/T30 on Colibri Evaluation Board
> > 

Will this be applied for the upcoming release?

Alban


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot