Re: [U-Boot] [PATCH] arm: zynq: dts: add spi flash node to zedboard

2018-07-30 Thread Michal Simek
On 27.7.2018 10:43, Luis Araneda wrote:
> Add a flash node to fix the detection of the memory IC.
> With the changes introduced with commit 8fee8845e754
> ("enf_sf: reuse setup_flash_device instead of open coding it")
> the SPI speed is now read from device-tree or a default value
> is applied. This replaced the old behavior of setting the
> SPI speed to CONFIG_ENV_SPI_MAX_HZ.
> 
> As this board didn't have a flash node, the default value
> was applied to the SPI speed, producing an error when probing
> the flash memory (speed too slow).
> 
> Signed-off-by: Luis Araneda 
> ---
>  arch/arm/dts/zynq-zed.dts | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/dts/zynq-zed.dts b/arch/arm/dts/zynq-zed.dts
> index 24eccf1633..9c505fb7b8 100644
> --- a/arch/arm/dts/zynq-zed.dts
> +++ b/arch/arm/dts/zynq-zed.dts
> @@ -51,6 +51,13 @@
>  &qspi {
>   u-boot,dm-pre-reloc;
>   status = "okay";
> + num-cs = <1>;
> + flash@0 {
> + compatible = "spansion,s25fl256s", "spi-flash";
> + reg = <0>;
> + spi-max-frequency = <3000>;
> + m25p,fast-read;
> + };
>  };
>  
>  &sdhci0 {
> 

Applied.
M
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] common: Generic loader for file system

2018-07-30 Thread Michal Simek
On 27.7.2018 10:40, Chee, Tien Fong wrote:
> On Thu, 2018-07-26 at 11:03 +0200, Michal Simek wrote:
>> On 25.7.2018 18:03, Tom Rini wrote:
>>>
>>> On Wed, Jul 25, 2018 at 09:47:17AM -0600, Simon Glass wrote:

 Hi,

 On 25 July 2018 at 03:48, Michal Simek 
 wrote:
>
>
> On 25.7.2018 08:31, Chee, Tien Fong wrote:
>>
>> On Wed, 2018-07-18 at 16:48 +0200, Michal Simek wrote:
>>>
>>> On 6.7.2018 10:28, tien.fong.c...@intel.com wrote:


 From: Tien Fong Chee 

 [...]

>
>>
>>>
>>>
>>> Also that DT binding is quite weird and I don't think you
>>> will get
>>> ACK
>>> for this from device tree community at all. I think that
>>> calling via
>>> platdata and avoid DT nodes would be better way to go.
>> Why do you think DT binding is weird? The DT is designed
>> based on Simon
>> proposal, and i believe following the rules in DTS spec.
>> There are some DT benefits with current design, i think
>> someone may be
>> maintainer need to made the final decision on the design.
> It is software configuration in file which should mostly
> describe
> hardware and state for hardware configuration.
>
> Your fs_loader node is purely describe sw configuration which
> shouldn't
> be here.
> You have there run time configuration via variables. I think
> using only
> this way is enough. Default variables will match what you would
> want to
> add to DT.
 I think DT makes sense in the U-Boot context.

 We don't have a user space to handle policy decisions, and the
 'chosen' node is a good place to configure these common features.

 While you can argue that the partition or filesystem where an
 image
 comes from is a software config, it is something that has to be
 configured. It has impact on hardware too, since the FPGA has to
 get
 its firmware from somewhere. We use the chosen node to specify
 the
 UART to use, and this is no different. Again, we don't have user-
 space
 config files in U-Boot.

 This argument comes up from time to time and I'd really like to
 put it
 to bed for U-Boot. I understand that Linux has its own approach
 and
 rules, but in some cases they serve U-Boot poorly.
>>> I want to second this as well.  So long as we're using our prefix
>>> and
>>> we've thought through and discussed what we're trying to do here,
>>> it's
>>> OK to do things that might not be accepted for Linux.
>>>
>> I have not a problem with using chosen node with u-boot prefix
>> properties and my colleague hopefully with finish work about moving
>> u-boot,dm-pre-reloc; to chosen node where it should be (because
>> current
>> solution has also problem with ordering).
>>
>> In this loader case doc is saying that you can rewrite it with
>> variables
>> on the prompt (or via script).
>> For cases that you want to autodetect platform and pass/load correct
>> dtb
>> which setup u-boot this can be problematic and using DT is could be
>> considered as easier for use.
>>
>> In this case this is what was proposed:
>>
>> +fs_loader0: fs-loader@0 {
>> +u-boot,dm-pre-reloc;
>> +compatible = "u-boot,fs-loader";
>> +phandlepart = <&mmc 1>;
>> +};
>>
>> +fs_loader1: fs-loader@1 {
>> +u-boot,dm-pre-reloc;
>> +compatible = "u-boot,fs-loader";
>> +mtdpart = "UBI",
>> +ubivol = "ubi0";
>> +};
>>
>> u-boot,dm-pre-reloc; requires DM_FLAG_PRE_RELOC which is not setup
>> for
>> this driver - it means this should be here.
> You are right, i missed this one. The intention of design enables user
> to call any loader with default storage through the sequence number  if
> fs loader is not defined in chosen. For example, there is a case where
> system loading the file from SDMMC, NAND and QSPI.
>>
>> compatible = "u-boot,fs-loader"; - bind and probe are empty that's
>> why
>> this is only used for filling platdata but driver has no user that's
>> why
>> this is unused till someone calls that functions.
>>
>> phandlepart/mtdpart/ubivol is just for setup.
> There are some benefits with driver model:
> 1. Saving space, calling when need.
> 2. Handle memory allocation and deallocation automatically.
>>
>> For the first case you can just use in chosen node:
>> u-boot,fs-loader = <&mmc 1>;
>>
>> And for UBIfs. I have never played with that but I expect it
>> shouldn't
>> be big problem to describe it differently too (something like)
>> u-boot,fs-loader = <0 ubi0>;
> Need consider description for UBIFS, using fs-loader seems not working
> for UBIFS, since more arguments such as mtdpartition and mtd volume
> need passing into driver. In order to avoid messing, fs_loader can act
> the pointer to the chosen. 
> 
> Anyway, i have no strong opinion with driver designed via platdata or
> driver model if we 

Re: [U-Boot] [linux-sunxi] Re: [PATCH v2 05/13] sunxi: add config for SPL at 0x20000 on H6

2018-07-30 Thread Jagan Teki
On Tue, Jul 24, 2018 at 2:06 PM, Icenowy Zheng  wrote:
>
>
> 于 2018年7月24日 GMT+08:00 下午4:34:52, Maxime Ripard  
> 写到:
>>On Sat, Jul 21, 2018 at 04:20:24PM +0800, Icenowy Zheng wrote:
>>> On the new Allwinner H6 SoC, the SRAM A2 address (SPL load address)
>>is
>>> at 0x2, which is different with any old Allwinner SoCs.
>>>
>>> Add SPL position and size configuration for this.
>>>
>>> Signed-off-by: Icenowy Zheng 
>>> Reviewed-by: Andre Przywara 
>>> ---
>>> Changes in v2:
>>> - Added Andre's Reviewed-by tag.
>>>
>>>  include/configs/sunxi-common.h | 5 +
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/include/configs/sunxi-common.h
>>b/include/configs/sunxi-common.h
>>> index 1b5daa8928..4db770d69d 100644
>>> --- a/include/configs/sunxi-common.h
>>> +++ b/include/configs/sunxi-common.h
>>> @@ -199,6 +199,11 @@
>>>  #else
>>>  #define LOW_LEVEL_SRAM_STACK0x00018000
>>>  #endif /* !CONFIG_ARM64 */
>>> +#elif CONFIG_SUNXI_SRAM_ADDRESS == 0x2
>>> +#define CONFIG_SPL_TEXT_BASE0x20060 /* sram 
>>> start+header */
>>> +#define CONFIG_SPL_MAX_SIZE 0x7fa0  /* 32 KiB */
>>> +/* end of SRAM A2 on H6 for now */
>>> +#define LOW_LEVEL_SRAM_STACK0x00118000
>>
>>Can't we move those options to Kconfig, and deal with those changes
>>there instead?
>
> It's possible, but not any cleaner.
>
> It will still be a hugh set of default xxx if xxx.

It's fine. we can do it. LOW_LEVEL_SRAM_STACK doesn't seem like CONFIG
item so moving them to kconfig and assugn to SPL_STACK would be
better.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] video: sunxi: de2: fix SimpleFB node creation when DE2 not probed

2018-07-30 Thread Maxime Ripard
On Fri, Jul 27, 2018 at 11:50:53PM +0800, Icenowy Zheng wrote:
> Sometimes when a monitor without EDID information is plugged, the DE2
> won't be probed (because of lack of timing information), but the HDMI
> node is probed, thus a SimpleFB node with invalid information will be
> populated.
> 
> Also detect whether DE2 is probed when creating SimpleFB node.
> 
> Fixes: be5b96f0e411 ("sunxi: setup simplefb for Allwinner DE2")
> Signed-off-by: Icenowy Zheng 

Acked-by: Maxime Ripard 

Maxime
-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


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


[U-Boot] [PATCH v2 0/6] driver: net: fsl-mc: Add support of multiple phys for dpmac

2018-07-30 Thread Pankaj Bansal
This patch set adds support of multiple phys for one dpmac

Till now we have had cases where we had one phy device per dpmac.
Now, with the upcoming products (LX2160AQDS), we have cases, where there
are sometimes two phy devices for one dpmac. One phy for TX lanes and one
phy for RX lanes. To handle such cases, add the support for multiple phys
in ethernet driver. The ethernet link is up if all the phy devices
connected to one dpmac report link up.
also the link capabilities are limited by the weakest phy device.

i.e. say if there are two phys for one dpmac. one operates at 10G without
autoneg and other operate at 1G with autoneg. Then the ethernet interface
will operate at 1G without autoneg.

Pankaj Bansal (6):
  driver: net: fsl-mc: modify the label name
  driver: net: fsl-mc: remove unused strcture elements
  driver: net: fsl-mc: fix error handing in init_phy
  driver: net: fsl-mc: Modify the dpmac link detection method
  driver: net: fsl-mc: initialize dpmac irrespective of phy
  driver: net: fsl-mc: Add support of multiple phys for dpmac

 board/freescale/ls1088a/eth_ls1088aqds.c   |  18 +--
 board/freescale/ls1088a/eth_ls1088ardb.c   |  21 +--
 board/freescale/ls2080aqds/eth.c   |  26 ++--
 board/freescale/ls2080ardb/eth_ls2080rdb.c |  24 +--
 drivers/net/fsl-mc/mc.c|   6 +-
 drivers/net/ldpaa_eth/ldpaa_eth.c  | 171 +
 drivers/net/ldpaa_eth/ldpaa_eth.h  |   1 -
 drivers/net/ldpaa_eth/ldpaa_wriop.c|  59 ---
 include/fsl-mc/ldpaa_wriop.h   |  46 +++---
 9 files changed, 211 insertions(+), 161 deletions(-)

-- 
2.17.1

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


[U-Boot] [PATCH v2 1/6] driver: net: fsl-mc: modify the label name

2018-07-30 Thread Pankaj Bansal
The goto label name is misspelled it should be DPMAC not DPAMC

Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- No change

 drivers/net/ldpaa_eth/ldpaa_eth.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 79facb4a44..18bc05790a 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -413,7 +413,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t 
*bd)
if (err) {
printf("%s: Could not initialize\n",
   priv->phydev->dev->name);
-   goto err_dpamc_bind;
+   goto err_dpmac_bind;
}
}
 #else
@@ -441,13 +441,13 @@ static int ldpaa_eth_open(struct eth_device *net_dev, 
bd_t *bd)
if (!priv->phydev->link) {
printf("%s: No link.\n", priv->phydev->dev->name);
err = -1;
-   goto err_dpamc_bind;
+   goto err_dpmac_bind;
}
 
/* DPMAC binding DPNI */
err = ldpaa_dpmac_bind(priv);
if (err)
-   goto err_dpamc_bind;
+   goto err_dpmac_bind;
 
/* DPNI initialization */
err = ldpaa_dpni_setup(priv);
@@ -540,7 +540,7 @@ err_dpni_bind:
 err_dpbp_setup:
dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
 err_dpni_setup:
-err_dpamc_bind:
+err_dpmac_bind:
dpmac_close(dflt_mc_io, MC_CMD_NO_FLAGS, priv->dpmac_handle);
dpmac_destroy(dflt_mc_io,
  dflt_dprc_handle,
-- 
2.17.1

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


[U-Boot] [PATCH v2 3/6] driver: net: fsl-mc: fix error handing in init_phy

2018-07-30 Thread Pankaj Bansal
if an error occurs during init_phy, we should free the phydev structure
which has been allocated by phy_connect.

Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- after free phydev just pass NULL into wriop_set_phy_dev()

 drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 4dd0f3913d..4231fb6119 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)
struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;
struct phy_device *phydev = NULL;
struct mii_dev *bus;
+   int ret;
 
bus = wriop_get_mdio(priv->dpmac_id);
if (bus == NULL)
@@ -37,7 +38,14 @@ static int init_phy(struct eth_device *dev)
 
wriop_set_phy_dev(priv->dpmac_id, phydev);
 
-   return phy_config(phydev);
+   ret = phy_config(phydev);
+
+   if (ret) {
+   free(phydev);
+   wriop_set_phy_dev(priv->dpmac_id, NULL);
+   }
+
+   return ret;
 }
 #endif
 
-- 
2.17.1

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


[U-Boot] [PATCH v2 2/6] driver: net: fsl-mc: remove unused strcture elements

2018-07-30 Thread Pankaj Bansal
The phydev structure is present in both ldpaa_eth_priv and
wriop_dpmac_info. the phydev in wriop_dpmac_info is not being used

As the phydev is created based on phy_addr and bus members of
wriop_dpmac_info, it is appropriate to keep phydev in wriop_dpmac_info.

Also phy_regs is not being used, therefore remove it

Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL into wriop_set_phy_dev()

 drivers/net/ldpaa_eth/ldpaa_eth.c   | 56 +++
 drivers/net/ldpaa_eth/ldpaa_eth.h   |  1 -
 drivers/net/ldpaa_eth/ldpaa_wriop.c |  2 +
 include/fsl-mc/ldpaa_wriop.h|  1 -
 4 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 18bc05790a..4dd0f3913d 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)
return -1;
}
 
-   priv->phydev = phydev;
+   wriop_set_phy_dev(priv->dpmac_id, phydev);
 
return phy_config(phydev);
 }
@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t 
*bd)
struct mii_dev *bus;
phy_interface_t enet_if;
struct dpni_queue d_queue;
+   struct phy_device *phydev = NULL;
 
if (net_dev->state == ETH_STATE_ACTIVE)
return 0;
@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, 
bd_t *bd)
goto err_dpmac_setup;
 
 #ifdef CONFIG_PHYLIB
-   if (priv->phydev) {
-   err = phy_startup(priv->phydev);
+   phydev = wriop_get_phy_dev(priv->dpmac_id);
+   if (phydev) {
+   err = phy_startup(phydev);
if (err) {
printf("%s: Could not initialize\n",
-  priv->phydev->dev->name);
+  phydev->dev->name);
goto err_dpmac_bind;
}
}
 #else
-   priv->phydev = (struct phy_device *)malloc(sizeof(struct phy_device));
-   memset(priv->phydev, 0, sizeof(struct phy_device));
+   phydev = (struct phy_device *)malloc(sizeof(struct phy_device));
+   memset(phydev, 0, sizeof(struct phy_device));
+   wriop_set_phy_dev(priv->dpmac_id, phydev);
 
-   priv->phydev->speed = SPEED_1000;
-   priv->phydev->link = 1;
-   priv->phydev->duplex = DUPLEX_FULL;
+   phydev->speed = SPEED_1000;
+   phydev->link = 1;
+   phydev->duplex = DUPLEX_FULL;
 #endif
 
bus = wriop_get_mdio(priv->dpmac_id);
enet_if = wriop_get_enet_if(priv->dpmac_id);
if ((bus == NULL) &&
(enet_if == PHY_INTERFACE_MODE_XGMII)) {
-   priv->phydev = (struct phy_device *)
+   phydev = (struct phy_device *)
malloc(sizeof(struct phy_device));
-   memset(priv->phydev, 0, sizeof(struct phy_device));
+   memset(phydev, 0, sizeof(struct phy_device));
+   wriop_set_phy_dev(priv->dpmac_id, phydev);
 
-   priv->phydev->speed = SPEED_1;
-   priv->phydev->link = 1;
-   priv->phydev->duplex = DUPLEX_FULL;
+   phydev->speed = SPEED_1;
+   phydev->link = 1;
+   phydev->duplex = DUPLEX_FULL;
}
 
-   if (!priv->phydev->link) {
-   printf("%s: No link.\n", priv->phydev->dev->name);
+   if (!phydev->link) {
+   printf("%s: No link.\n", phydev->dev->name);
err = -1;
goto err_dpmac_bind;
}
@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, 
bd_t *bd)
return err;
}
 
-   dpmac_link_state.rate = priv->phydev->speed;
+   dpmac_link_state.rate = phydev->speed;
 
-   if (priv->phydev->autoneg == AUTONEG_DISABLE)
+   if (phydev->autoneg == AUTONEG_DISABLE)
dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG;
else
dpmac_link_state.options |= DPMAC_LINK_OPT_AUTONEG;
 
-   if (priv->phydev->duplex == DUPLEX_HALF)
+   if (phydev->duplex == DUPLEX_HALF)
dpmac_link_state.options |= DPMAC_LINK_OPT_HALF_DUPLEX;
 
-   dpmac_link_state.up = priv->phydev->link;
+   dpmac_link_state.up = phydev->link;
 
err = dpmac_set_link_state(dflt_mc_io, MC_CMD_NO_FLAGS,
  priv->dpmac_handle, &dpmac_link_state);
@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t 
*bd)
goto err_qdid;
}
 
-   return priv->phydev->link;
+   return phydev->link;
 
 err_qdid:
 err_get_queue:
@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)
 #ifdef CONFIG_PHYLIB
struct mii_dev *bus = wriop_get_mdio(priv->dpmac_id);
 #endif
+   struc

[U-Boot] [PATCH v2 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmac

2018-07-30 Thread Pankaj Bansal
Till now we have had cases where we had one phy device per dpmac.
Now, with the upcoming products (LX2160AQDS), we have cases, where there
are sometimes two phy devices for one dpmac. One phy for TX lanes and
one phy for RX lanes. to handle such cases, add the support for multiple
phys in ethernet driver. The ethernet link is up if all the phy devices
connected to one dpmac report link up. also the link capabilities are
limited by the weakest phy device.

i.e. say if there are two phys for one dpmac. one operates at 10G without
autoneg and other operate at 1G with autoneg. Then the ethernet interface
will operate at 1G without autoneg.

Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- use single-line comment format.
- use WRIOP_MAX_PHY_NUM.
- use -ENODEV or -EINVAL instead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that
  a meaningful error message can be returned

 board/freescale/ls1088a/eth_ls1088aqds.c   | 18 +++---
 board/freescale/ls1088a/eth_ls1088ardb.c   | 21 ---
 board/freescale/ls2080aqds/eth.c   | 26 
 board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++
 drivers/net/ldpaa_eth/ldpaa_eth.c  | 66 ++--
 drivers/net/ldpaa_eth/ldpaa_wriop.c| 61 +++---
 include/fsl-mc/ldpaa_wriop.h   | 45 ++---
 7 files changed, 152 insertions(+), 109 deletions(-)

diff --git a/board/freescale/ls1088a/eth_ls1088aqds.c 
b/board/freescale/ls1088a/eth_ls1088aqds.c
index 40b1a0e631..f16b78cf03 100644
--- a/board/freescale/ls1088a/eth_ls1088aqds.c
+++ b/board/freescale/ls1088a/eth_ls1088aqds.c
@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)
case 0x3A:
switch (dpmac_id) {
case 1:
-   wriop_set_phy_address(dpmac_id, riser_phy_addr[1]);
+   wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[1]);
break;
case 2:
-   wriop_set_phy_address(dpmac_id, riser_phy_addr[0]);
+   wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[0]);
break;
case 3:
-   wriop_set_phy_address(dpmac_id, riser_phy_addr[3]);
+   wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[3]);
break;
case 7:
-   wriop_set_phy_address(dpmac_id, riser_phy_addr[2]);
+   wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[2]);
break;
default:
printf("WRIOP: Wrong DPMAC%d set to SGMII", dpmac_id);
@@ -532,13 +532,13 @@ void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)
case 4:
case 5:
case 6:
-   wriop_set_phy_address(dpmac_id, dpmac_id + 9);
+   wriop_set_phy_address(dpmac_id, 0, dpmac_id + 9);
break;
case 7:
case 8:
case 9:
case 10:
-   wriop_set_phy_address(dpmac_id, dpmac_id + 1);
+   wriop_set_phy_address(dpmac_id, 0, dpmac_id + 1);
break;
}
 
@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)
case 0x15:
case 0x1D:
case 0x1E:
-   wriop_set_phy_address(i, i + 26);
+   wriop_set_phy_address(i, 0, i + 26);
ls1088a_qds_enable_SFP_TX(SFP_TX);
break;
default:
@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int 
dpmac_id)
 
switch (dpmac_id) {
case 4:
-   wriop_set_phy_address(dpmac_id, RGMII_PHY1_ADDR);
+   wriop_set_phy_address(dpmac_id, 0, RGMII_PHY1_ADDR);
dpmac_info[dpmac_id].board_mux = EMI1_RGMII1;
bus = mii_dev_for_muxval(EMI1_RGMII1);
wriop_set_mdio(dpmac_id, bus);
break;
case 5:
-   wriop_set_phy_address(dpmac_id, RGMII_PHY2_ADDR);
+   wriop_set_phy_address(dpmac_id, 0, RGMII_PHY2_ADDR);
dpmac_info[dpmac_id].board_mux = EMI1_RGMII2;
bus = mii_dev_for_muxval(EMI1_RGMII2);
wriop_set_mdio(dpmac_id, bus);
diff --git a/board/freescale/ls1088a/eth_ls1088ardb.c 
b/board/freescale/ls1088a/eth_ls1088ardb.c
index 418f362e9a..a2b52a879b 100644
--- a/board/freescale/ls1088a/eth_ls1088ardb.c
+++ b/board/freescale/ls1088a/eth_ls1088ardb.c
@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)
 * a MAC has no PHY address, we give a PHY address to XFI
 * MAC error.
 */
-   wriop_set_phy_address(WRIOP1_DPMAC1, 0x0a);
-   wriop_set_phy_address(WRIOP1_

[U-Boot] [PATCH v2 5/6] driver: net: fsl-mc: initialize dpmac irrespective of phy

2018-07-30 Thread Pankaj Bansal
The dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function.
Therefore, remove dpmac initialization dependency from phy.

Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- No Change

 drivers/net/fsl-mc/mc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 982024e31e..e2341a2e3c 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -327,8 +327,7 @@ static int mc_fixup_mac_addrs(void *blob, enum 
mc_fixup_type type)
 
for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
/* port not enabled */
-   if ((wriop_is_enabled_dpmac(i) != 1) ||
-   (wriop_get_phy_address(i) == -1))
+   if (wriop_is_enabled_dpmac(i) != 1)
continue;
 
sprintf(ethname, "DPMAC%d@%s", i,
@@ -845,8 +844,7 @@ int fsl_mc_ldpaa_init(bd_t *bis)
int i;
 
for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++)
-   if ((wriop_is_enabled_dpmac(i) == 1) &&
-   (wriop_get_phy_address(i) != -1))
+   if (wriop_is_enabled_dpmac(i) == 1)
ldpaa_eth_init(i, wriop_get_enet_if(i));
return 0;
 }
-- 
2.17.1

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


[U-Boot] [PATCH v2 4/6] driver: net: fsl-mc: Modify the dpmac link detection method

2018-07-30 Thread Pankaj Bansal
when there is no phy present for a dpmac, a dummy phy device is created.
when we move to multiple phy method, we need to create as many dummy phy
devices.

Change this method so that we don't need to create dummy phy devices.
We always report linkup if no phy is present.

Signed-off-by: Pankaj Bansal 
---

Notes:
V2:
- Change (phydev->link == 1) to (phydev->link)
- Use min macro instead of ternary operator
- return -ENOLINK instead of -1 from ldpaa_get_dpmac_state
- Change (state->up == 0) to (!state->up)

 drivers/net/ldpaa_eth/ldpaa_eth.c | 119 +---
 1 file changed, 57 insertions(+), 62 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c 
b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 4231fb6119..d2bec31dd7 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -385,6 +385,59 @@ error:
return err;
 }
 
+static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv,
+struct dpmac_link_state *state)
+{
+   struct phy_device *phydev = NULL;
+   phy_interface_t enet_if;
+   int err;
+
+   /* let's start off with maximum capabilities
+*/
+   enet_if = wriop_get_enet_if(priv->dpmac_id);
+   switch (enet_if) {
+   case PHY_INTERFACE_MODE_XGMII:
+   state->rate = SPEED_1;
+   break;
+   default:
+   state->rate = SPEED_1000;
+   break;
+   }
+   state->up = 1;
+
+#ifdef CONFIG_PHYLIB
+   state->options |= DPMAC_LINK_OPT_AUTONEG;
+
+   phydev = wriop_get_phy_dev(priv->dpmac_id);
+   if (phydev) {
+   err = phy_startup(phydev);
+   if (err) {
+   printf("%s: Could not initialize\n", phydev->dev->name);
+   state->up = 0;
+   }
+   if (phydev->link) {
+   state->rate = min(state->rate, (uint32_t)phydev->speed);
+   if (!phydev->duplex)
+   state->options |= DPMAC_LINK_OPT_HALF_DUPLEX;
+   if (!phydev->autoneg)
+   state->options &= ~DPMAC_LINK_OPT_AUTONEG;
+   } else {
+   state->up = 0;
+   }
+   }
+#endif
+   if (!phydev)
+   state->options &= ~DPMAC_LINK_OPT_AUTONEG;
+
+   if (!state->up) {
+   state->rate = 0;
+   state->options = 0;
+   return -ENOLINK;
+   }
+
+   return 0;
+}
+
 static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
 {
struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
@@ -393,10 +446,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t 
*bd)
struct dpni_link_state link_state;
 #endif
int err = 0;
-   struct mii_dev *bus;
-   phy_interface_t enet_if;
struct dpni_queue d_queue;
-   struct phy_device *phydev = NULL;
 
if (net_dev->state == ETH_STATE_ACTIVE)
return 0;
@@ -416,45 +466,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t 
*bd)
if (err < 0)
goto err_dpmac_setup;
 
-#ifdef CONFIG_PHYLIB
-   phydev = wriop_get_phy_dev(priv->dpmac_id);
-   if (phydev) {
-   err = phy_startup(phydev);
-   if (err) {
-   printf("%s: Could not initialize\n",
-  phydev->dev->name);
-   goto err_dpmac_bind;
-   }
-   }
-#else
-   phydev = (struct phy_device *)malloc(sizeof(struct phy_device));
-   memset(phydev, 0, sizeof(struct phy_device));
-   wriop_set_phy_dev(priv->dpmac_id, phydev);
-
-   phydev->speed = SPEED_1000;
-   phydev->link = 1;
-   phydev->duplex = DUPLEX_FULL;
-#endif
-
-   bus = wriop_get_mdio(priv->dpmac_id);
-   enet_if = wriop_get_enet_if(priv->dpmac_id);
-   if ((bus == NULL) &&
-   (enet_if == PHY_INTERFACE_MODE_XGMII)) {
-   phydev = (struct phy_device *)
-   malloc(sizeof(struct phy_device));
-   memset(phydev, 0, sizeof(struct phy_device));
-   wriop_set_phy_dev(priv->dpmac_id, phydev);
-
-   phydev->speed = SPEED_1;
-   phydev->link = 1;
-   phydev->duplex = DUPLEX_FULL;
-   }
-
-   if (!phydev->link) {
-   printf("%s: No link.\n", phydev->dev->name);
-   err = -1;
+   err = ldpaa_get_dpmac_state(priv, &dpmac_link_state);
+   if (err < 0)
goto err_dpmac_bind;
-   }
 
/* DPMAC binding DPNI */
err = ldpaa_dpmac_bind(priv);
@@ -488,18 +502,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t 
*bd)
return err;
}
 
-   dpmac_link_state.rate = phydev->speed;
-
-   if (phydev->autoneg == AUTONEG_DISABLE)
-   dpmac_link_

Re: [U-Boot] [RFC PATCH] gpio: zynq: Setup bank_name to dev->name

2018-07-30 Thread Michal Simek
On 27.7.2018 11:14, Stefan Herbrechtsmeier wrote:
> Am 27.07.2018 um 08:42 schrieb Michal Simek:
>> On 26.7.2018 22:04, Stefan Herbrechtsmeier wrote:
>>> Am 26.07.2018 um 10:22 schrieb Michal Simek:
 On 25.7.2018 21:17, Stefan Herbrechtsmeier wrote:
> Am 25.07.2018 um 08:07 schrieb Michal Simek:
>> On 24.7.2018 21:39, Stefan Herbrechtsmeier wrote:
>>> Am 24.07.2018 um 10:37 schrieb Michal Simek:
 On 23.7.2018 20:29, Stefan Herbrechtsmeier wrote:
> Am 23.07.2018 um 11:08 schrieb Michal Simek:
>> On 20.7.2018 21:31, Stefan Herbrechtsmeier wrote:
>>> Am 12.07.2018 um 16:04 schrieb Michal Simek:
 There should be proper bank name setup to distiguish between
 different
 gpio drivers. Use dev->name for it.

 Signed-off-by: Michal Simek 
 ---

    drivers/gpio/zynq_gpio.c | 2 ++
    1 file changed, 2 insertions(+)

 diff --git a/drivers/gpio/zynq_gpio.c
 b/drivers/gpio/zynq_gpio.c
 index 26f69b1a713f..f793ee5754a8 100644
 --- a/drivers/gpio/zynq_gpio.c
 +++ b/drivers/gpio/zynq_gpio.c
 @@ -337,6 +337,8 @@ static int zynq_gpio_probe(struct udevice
 *dev)
    struct zynq_gpio_privdata *priv = dev_get_priv(dev);
    struct gpio_dev_priv *uc_priv =
 dev_get_uclass_priv(dev);
    +    uc_priv->bank_name = dev->name;
 +
    if (priv->p_data)
    uc_priv->gpio_count = priv->p_data->ngpio;
    
>>> Does this not lead to ugly names because the gpio number is
>>> append to
>>> the bank_name? Have you check the "gpio status -a" output?
>> Yes I was checking it. Names are composed together but also just
>> numbers
>> works as before.
>>
>> gpio@ff0a0: input: 0 [ ]
>> gpio@ff0a1: input: 0 [ ]
>> gpio@ff0a2: input: 0 [ ]
>> gpio@ff0a3: input: 0 [ ]
>> gpio@ff0a4: input: 0 [ ]
>> gpio@ff0a5: input: 0 [ ]
>> gpio@ff0a6: input: 0 [ ]
>> gpio@ff0a7: input: 0 [ ]
>> gpio@ff0a8: input: 0 [ ]
>> gpio@ff0a9: input: 0 [ ]
> Do you think that this are meaningful names? It isn't possible to
> separate the device and pin number as well as it mix hex and
> decimal
> numbers.
>
>> If you know better way how to setup a bank name please let me
>> know
>> but I
>> need to distinguish ps gpio from pl one and for pl we need to
>> know
>> the
>> address.
> I know the use case.
>
> A lot of drivers use the bank_name from the device tree, some
> drivers
> append an underscore to the bank name and others add the
> req_seq of
> the
> device to an alphabetic character.
>
>>> Other drivers use the gpio-bank-name from the device tree.
>> I can't see this property inside Linux kernel. If this has been
>> reviewed
>> by dt guys please let me know.
> This property is only used by u-boot. I think it isn't needed
> by the
> Linux kernel.
 I am happy to use consistent solution but what's that?
>>> Consistent solution between what?
>> all drivers. Name should be composed consistently among all drivers.
>> It means drivers shouldn't add additional "_" in driver code for
>> example.
>>
 Mixing name with hex and int is not nice but adding "_" or
 something
 else is just a pain in driver code. If this is done in core I am
 fine
 with that but adding this code to all drivers don't look like
 generic
 solution at all.
>>> Normally the bank name is an alphabetic character or string.
>>> Maybe we
>>> could add the device name to the gpio_lookup_name function and
>>> add an
>>> additional optional device name parameter to the gpio command.
>>>
 Using additional u-boot property is not good too.

 I have mentioned in "gpio: xilinx: Convert driver to DM"
 (sha1:10441ec9224d0d269dc512819a32c0785a6338d3)
 that uc-priv->name is completely unused. Maybe this should be
 dev->name
 and bank_name should be really used for banks.
>>> Isn't the uc-priv->name used for the label of the request?
>> Last time when I looked at it and I didn't see this name listed
>> anywhere
>> in output.
>>
>>
 Then in gpio status -a can be

 Device gpio@a0001000:
 Bank:
 ...

 but not sure how gpio commands will work to address exact pin from
 prompt. Because this is nor

Re: [U-Boot] [PATCH v2 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmac

2018-07-30 Thread Pankaj Bansal
Hi Joe,

I have incorporated all your review comments except one:

"This should jut call wriop_init_dpmac_enet_if(). You can just set
dpmac_info[dpmac_id].enabled = 0 after calling
wriop_init_dpmac_enet_if()."

Actually in  wriop_init_dpmac, we assign -1 to phy_addr array and NULL to 
phydev array irrespective of enet_if.
If we call wriop_init_dpmac_enet_if from wriop_init_dpmac then this would be 
done only for dpmacs for which enet_if is not PHY_INTERFACE_MODE_NONE.

Regards,
Pankaj Bansal

> -Original Message-
> From: Pankaj Bansal
> Sent: Monday, July 30, 2018 6:45 PM
> To: u-boot@lists.denx.de; joe.hershber...@ni.com
> Cc: Prabhakar Kushwaha ; Priyanka Jain
> ; Varun Sethi ; York Sun
> ; Pankaj Bansal 
> Subject: [PATCH v2 6/6] driver: net: fsl-mc: Add support of multiple phys
> for dpmac
> 
> Till now we have had cases where we had one phy device per dpmac.
> Now, with the upcoming products (LX2160AQDS), we have cases, where
> there are sometimes two phy devices for one dpmac. One phy for TX lanes
> and one phy for RX lanes. to handle such cases, add the support for multiple
> phys in ethernet driver. The ethernet link is up if all the phy devices
> connected to one dpmac report link up. also the link capabilities are limited
> by the weakest phy device.
> 
> i.e. say if there are two phys for one dpmac. one operates at 10G without
> autoneg and other operate at 1G with autoneg. Then the ethernet interface
> will operate at 1G without autoneg.
> 
> Signed-off-by: Pankaj Bansal 
> ---
> 
> Notes:
> V2:
> - use single-line comment format.
> - use WRIOP_MAX_PHY_NUM.
> - use -ENODEV or -EINVAL instead of -1 wherever appropriate
> - include the variable names in the headers too.
> - Change the return type of some functions from void to int so that
>   a meaningful error message can be returned
> 
>  board/freescale/ls1088a/eth_ls1088aqds.c   | 18 +++---
>  board/freescale/ls1088a/eth_ls1088ardb.c   | 21 ---
>  board/freescale/ls2080aqds/eth.c   | 26 
>  board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++
>  drivers/net/ldpaa_eth/ldpaa_eth.c  | 66 ++--
>  drivers/net/ldpaa_eth/ldpaa_wriop.c| 61 +++---
>  include/fsl-mc/ldpaa_wriop.h   | 45 ++---
>  7 files changed, 152 insertions(+), 109 deletions(-)
> 
> diff --git a/board/freescale/ls1088a/eth_ls1088aqds.c
> b/board/freescale/ls1088a/eth_ls1088aqds.c
> index 40b1a0e631..f16b78cf03 100644
> --- a/board/freescale/ls1088a/eth_ls1088aqds.c
> +++ b/board/freescale/ls1088a/eth_ls1088aqds.c
> @@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int
> dpmac_id)
>   case 0x3A:
>   switch (dpmac_id) {
>   case 1:
> - wriop_set_phy_address(dpmac_id,
> riser_phy_addr[1]);
> + wriop_set_phy_address(dpmac_id, 0,
> riser_phy_addr[1]);
>   break;
>   case 2:
> - wriop_set_phy_address(dpmac_id,
> riser_phy_addr[0]);
> + wriop_set_phy_address(dpmac_id, 0,
> riser_phy_addr[0]);
>   break;
>   case 3:
> - wriop_set_phy_address(dpmac_id,
> riser_phy_addr[3]);
> + wriop_set_phy_address(dpmac_id, 0,
> riser_phy_addr[3]);
>   break;
>   case 7:
> - wriop_set_phy_address(dpmac_id,
> riser_phy_addr[2]);
> + wriop_set_phy_address(dpmac_id, 0,
> riser_phy_addr[2]);
>   break;
>   default:
>   printf("WRIOP: Wrong DPMAC%d set to SGMII",
> dpmac_id); @@ -532,13 +532,13 @@ void
> ls1088a_handle_phy_interface_qsgmii(int dpmac_id)
>   case 4:
>   case 5:
>   case 6:
> - wriop_set_phy_address(dpmac_id, dpmac_id + 9);
> + wriop_set_phy_address(dpmac_id, 0, dpmac_id +
> 9);
>   break;
>   case 7:
>   case 8:
>   case 9:
>   case 10:
> - wriop_set_phy_address(dpmac_id, dpmac_id + 1);
> + wriop_set_phy_address(dpmac_id, 0, dpmac_id +
> 1);
>   break;
>   }
> 
> @@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)
>   case 0x15:
>   case 0x1D:
>   case 0x1E:
> - wriop_set_phy_address(i, i + 26);
> + wriop_set_phy_address(i, 0, i + 26);
>   ls1088a_qds_enable_SFP_TX(SFP_TX);
>   break;
>   default:
> @@ -590,13 +590,13 @@ static void
> ls1088a_handle_phy_interface_rgmii(int dpmac_id)
> 
>   switch (dpmac_id) {
>   case 4:
> - wriop_set_phy_address(dpmac_id, RGMII_PHY1_ADDR);
> + wriop_set_phy_address(dpmac_id, 0, RGMII_PHY1_ADDR);
>   dpmac_info[dpmac_id].board_mux = EMI1_RGMII1;
>   bus =

Re: [U-Boot] [PATCH] spl: fit: Enable GZIP compression also for no kernel partitions

2018-07-30 Thread Michal Simek
On 26.7.2018 18:23, York Sun wrote:
> On 07/25/2018 11:52 PM, Michal Simek wrote:
>> On 25.7.2018 23:18, York Sun wrote:
>>> On 07/24/2018 10:58 PM, Michal Simek wrote:
 On 24.7.2018 18:26, York Sun wrote:
> On 07/24/2018 06:07 AM, Michal Simek wrote:
>> There is no reason to limit gzip usage only for OS_BOOT and kernel image
>> type.
>>
>> Signed-off-by: Michal Simek 
>> ---
>>
>>  common/spl/spl_fit.c | 5 +
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index 9eabb1c1058b..dbf5ac33a845 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -257,10 +257,7 @@ static int spl_load_fit_image(struct spl_load_info 
>> *info, ulong sector,
>>  board_fit_image_post_process(&src, &length);
>>  #endif
>>  
>> -if (IS_ENABLED(CONFIG_SPL_OS_BOOT)  &&
>> -IS_ENABLED(CONFIG_SPL_GZIP) &&
>> -image_comp == IH_COMP_GZIP  &&
>> -type == IH_TYPE_KERNEL) {
>> +if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
>>  size = length;
>>  if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
>> src, &size)) {
>>
>
> This will uncompress ramdisk unnecessarily.

 Can you please share your its fragment? Also is there any other image
 which should be exclude?
>>>
>>> I used it for falcon boot. I guess the executable image should have 
>>> "entry". In
>>> my setup, only kernel image has "entry". Here is my its file.
>>>
>>> /dts-v1/;
>>>
>>> / {
>>> description = "Image file for the LS1046A Linux Kernel";
>>> #address-cells = <1>;
>>>
>>> images {
>>> kernel@1 {
>>> description = "ARM64 Linux kernel";
>>> data = /incbin/("./arch/arm64/boot/Image.gz");
>>> type = "kernel";
>>> arch = "arm64";
>>> os = "linux";
>>> compression = "gzip";
>>> load = <0x8008>;
>>> entry = <0x8008>;
>>> };
>>> fdt@1 {
>>> description = "Flattened Device Tree blob";
>>> data = /incbin/("./fsl-ls1046ardb.dtb");
>>> type = "flat_dt";
>>> arch = "arm64";
>>> compression = "none";
>>> load = <0x9000>;
>>> };
>>> ramdisk@1 {
>>> description = "Buildroot initramfs";
>>> data = /incbin/("./rootfs.cpio.gz");
>>> type = "ramdisk";
>>> arch = "arm64";
>>> os = "linux";
>>> compression = "gzip";
>>
>> I have tested full u-boot and there is also no uncompression for ramdisk
>> when you put gzip compress there.
>> I have even tried gzip compression for fdt with expectation that u-boot
>> will uncompress it.
>>
>> Based on doc/uImage.FIT/source_file_format.txt:
>> 165  - compression : Compression used by included data. Supported
>> compressions
>> 166 are "gzip" and "bzip2". If no compression is used compression
>> property
>> 167 should be set to "none".
>>
>>
>> Based on me this means that data inside fit are compressed and you are
>> asking u-boot in boot to uncompress it. If you are not asking for that
>> you should put none there.
>> But it doesn't look like this is supported at all for fdt/ramdisk and it
>> is only handled for OS.
>> I see here two cases.
>> 1. I want u-boot to uncompress my data in fit image (whatever it is)
>> before passing control to OS that's why I putting there compression method.
>> 2. I want OS to uncompress data but I want pass this data unchanged from
>> u-boot to OS that's why I am putting compression method at "none"
>>
>> I am expecting when you put "none" there than you will boot in falcon
>> mode without any issue.
> 
> That will work. I can put "none" for the images I don't want U-Boot to
> uncompress.
> 
>>
>> I have no problem to change this patch and include only kernel and fpga
>> image but it sounds to me that we have gaps in implementation that not
>> all images inside the fit image have the same range of functionalities.
>>
>> Also I think that "load" entry is that one which matters not "entry".
>>
> 
> Not true here. The "entry" matters if you want to run it, for example
> Linux kernel. It may be different from "load".

yes - if you want to run it entry is used but if you want to uncompress
it you should say where you want to uncompress it. I am not quite sure
if we have any logic to automatically choose a place for uncompression.

Thanks,
Michal

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-

Re: [U-Boot] [PATCH] spl: fit: Enable GZIP compression also for no kernel partitions

2018-07-30 Thread Michal Simek
On 26.7.2018 19:16, Tom Rini wrote:
> On Thu, Jul 26, 2018 at 04:23:14PM +, York Sun wrote:
>> On 07/25/2018 11:52 PM, Michal Simek wrote:
>>> On 25.7.2018 23:18, York Sun wrote:
 On 07/24/2018 10:58 PM, Michal Simek wrote:
> On 24.7.2018 18:26, York Sun wrote:
>> On 07/24/2018 06:07 AM, Michal Simek wrote:
>>> There is no reason to limit gzip usage only for OS_BOOT and kernel image
>>> type.
>>>
>>> Signed-off-by: Michal Simek 
>>> ---
>>>
>>>  common/spl/spl_fit.c | 5 +
>>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>>> index 9eabb1c1058b..dbf5ac33a845 100644
>>> --- a/common/spl/spl_fit.c
>>> +++ b/common/spl/spl_fit.c
>>> @@ -257,10 +257,7 @@ static int spl_load_fit_image(struct spl_load_info 
>>> *info, ulong sector,
>>> board_fit_image_post_process(&src, &length);
>>>  #endif
>>>  
>>> -   if (IS_ENABLED(CONFIG_SPL_OS_BOOT)  &&
>>> -   IS_ENABLED(CONFIG_SPL_GZIP) &&
>>> -   image_comp == IH_COMP_GZIP  &&
>>> -   type == IH_TYPE_KERNEL) {
>>> +   if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
>>> size = length;
>>> if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
>>>src, &size)) {
>>>
>>
>> This will uncompress ramdisk unnecessarily.
>
> Can you please share your its fragment? Also is there any other image
> which should be exclude?

 I used it for falcon boot. I guess the executable image should have 
 "entry". In
 my setup, only kernel image has "entry". Here is my its file.

 /dts-v1/;

 / {
description = "Image file for the LS1046A Linux Kernel";
#address-cells = <1>;

images {
kernel@1 {
description = "ARM64 Linux kernel";
data = /incbin/("./arch/arm64/boot/Image.gz");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "gzip";
load = <0x8008>;
entry = <0x8008>;
};
fdt@1 {
description = "Flattened Device Tree blob";
data = /incbin/("./fsl-ls1046ardb.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
load = <0x9000>;
};
ramdisk@1 {
description = "Buildroot initramfs";
 data = /incbin/("./rootfs.cpio.gz");
type = "ramdisk";
arch = "arm64";
os = "linux";
compression = "gzip";
>>>
>>> I have tested full u-boot and there is also no uncompression for ramdisk
>>> when you put gzip compress there.
>>> I have even tried gzip compression for fdt with expectation that u-boot
>>> will uncompress it.
>>>
>>> Based on doc/uImage.FIT/source_file_format.txt:
>>> 165  - compression : Compression used by included data. Supported
>>> compressions
>>> 166 are "gzip" and "bzip2". If no compression is used compression
>>> property
>>> 167 should be set to "none".
>>>
>>>
>>> Based on me this means that data inside fit are compressed and you are
>>> asking u-boot in boot to uncompress it. If you are not asking for that
>>> you should put none there.
>>> But it doesn't look like this is supported at all for fdt/ramdisk and it
>>> is only handled for OS.
>>> I see here two cases.
>>> 1. I want u-boot to uncompress my data in fit image (whatever it is)
>>> before passing control to OS that's why I putting there compression method.
>>> 2. I want OS to uncompress data but I want pass this data unchanged from
>>> u-boot to OS that's why I am putting compression method at "none"
>>>
>>> I am expecting when you put "none" there than you will boot in falcon
>>> mode without any issue.
>>
>> That will work. I can put "none" for the images I don't want U-Boot to
>> uncompress.
> 
> Please also update the document to be clear that "none" for "don't touch
> my compressed data!" is expected.  The existing language isn't clear but
> I agree it makes sense (and follows the long standing practice of "-C
> none" on compressed ramdisks for legacy style images).
> 
> And per Simon Goldschmidt's suggestion, after we've made the docs
> clearer, making it so that U-Boot does decompress things would be good,
> but we may also need to make that behavior configurable as I can see
> people having put the correct compression in and not wanting it to be
> uncompressed as we have examples of both none and gzip for ramdisks
> today.  It's also p

Re: [U-Boot] [PATCH 04/20] W1-EEPROM: Add an W1-EEPROM uclass for 1 wire EEPROMs

2018-07-30 Thread Eugen Hristev



On 20.07.2018 17:28, Maxime Ripard wrote:

Hi Eugen,

Thanks for giving those patches another shot.

On Thu, Jul 19, 2018 at 12:57:52PM +0300, Eugen Hristev wrote:

From: Maxime Ripard 

We might want to access data stored onto one wire EEPROMs.
Create a framework to provide a consistent API.

Signed-off-by: Maxime Ripard 
[eugen.hris...@microchip.com: reworked patch]
Signed-off-by: Eugen Hristev 
---
  drivers/Kconfig  |  2 ++
  drivers/Makefile |  1 +
  drivers/w1-eeprom/Kconfig| 17 +++
  drivers/w1-eeprom/Makefile   |  2 ++
  drivers/w1-eeprom/w1-eeprom-uclass.c | 56 
  include/dm/uclass-id.h   |  1 +
  include/w1-eeprom.h  | 28 ++
  7 files changed, 107 insertions(+)
  create mode 04 drivers/w1-eeprom
  create mode 100644 drivers/w1-eeprom/Kconfig
  create mode 100644 drivers/w1-eeprom/Makefile
  create mode 100644 drivers/w1-eeprom/w1-eeprom-uclass.c
  create mode 100644 include/w1-eeprom.h


I believe that we shouldn't have a framework solely for 1-wire
EEPROMs, but for EEPROMs, connected to any bus.

The 1-Wire EEPROMs all behave pretty much the same, so we'll probably
only see a single driver within that framework. And at the same time,
we'll want to have a consistent interface to access all the EEPROMs,
no matter on which bus they sit on.


Hello,

I worked this series using the original implementation as a starting 
point: having the eeproms on different subsystems (i2c and onewire).


The different types of eeproms have only the name in common as I see it, 
and the way to access them is totally different: two different type of 
buses, so uniting them is just for the namesake ?


One option is to have them separately, as we have spi, i2c memories , etc;
Or, unite them under a single subsystem for eeproms, and have one driver 
for i2c eeproms and one for w1 eeproms, trying to make the same API to 
access them, and hide the bus specific differences.


Question for maintainers: which is the best direction to go, so I can 
rework the series accordingly ?


Thanks,
Eugen


Maxime


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


Re: [U-Boot] [PATCH] board: sun50i: h6: Add OrangePi One Plus initial support

2018-07-30 Thread Maxime Ripard
On Sun, Jul 29, 2018 at 12:03:31AM +0530, Jagan Teki wrote:
> OrangePi One Plus is Allwinner H6 based open-source SBC,
> which support:
> - Allwinner H6 Quad-core 64-bit ARM Cortex-A53
> - GPU Mali-T720
> - 1GB LPDDR3 RAM
> - AXP805 PMIC
> - 1Gbps GMAC via RTL8211
> - USB 2.0 Host, OTG
> - HDMI port
> - 5V/2A DC power supply
> 
> Signed-off-by: Jagan Teki 

Acked-by: Maxime Ripard 

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


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


[U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Simon Goldschmidt
Compressed images should have their compression property
set to "none" if U-Boot should leave them compressed.

This is especially the case for compressed ramdisks that
should be uncompressed by the kernel only.

Signed-off-by: Simon Goldschmidt 
---

 doc/uImage.FIT/source_file_format.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/doc/uImage.FIT/source_file_format.txt 
b/doc/uImage.FIT/source_file_format.txt
index d2793a195d..d701b9bb76 100644
--- a/doc/uImage.FIT/source_file_format.txt
+++ b/doc/uImage.FIT/source_file_format.txt
@@ -164,7 +164,9 @@ the '/images' node should have the following layout:
   - data : Path to the external file which contains this node's binary data.
   - compression : Compression used by included data. Supported compressions
 are "gzip" and "bzip2". If no compression is used compression property
-should be set to "none".
+should be set to "none". If the data is compressed but it should not be
+uncompressed by U-Boot (e.g. compressed ramdisk), this should also be set
+to "none".
 
   Conditionally mandatory property:
   - os : OS name, mandatory for types "kernel" and "ramdisk". Valid OS names
-- 
2.11.0

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


[U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Simon Goldschmidt
To prepare supporting compression for all image types, change
compression to "none" for ramdisks in all examples.

Signed-off-by: Simon Goldschmidt 
---

 arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 2 +-
 doc/README.bcm7xxx  | 2 +-
 doc/uImage.FIT/multi.its| 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon 
b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
index 7dae9f03c3..b3c6693a42 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
+++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
@@ -110,7 +110,7 @@ Example:
type = "ramdisk";
arch = "arm64";
os = "linux";
-   compression = "gzip";
+   compression = "none";
load = <0xa000>;
};
};
diff --git a/doc/README.bcm7xxx b/doc/README.bcm7xxx
index 9b5eae4741..1de2f63181 100644
--- a/doc/README.bcm7xxx
+++ b/doc/README.bcm7xxx
@@ -91,7 +91,7 @@ image.its:
type = "ramdisk";
arch = "arm";
os = "linux";
-   compression = "gzip";
+   compression = "none";
/*
 * Set the environment variable initrd_high to
 * 0x, and set "load" and "entry" here
diff --git a/doc/uImage.FIT/multi.its b/doc/uImage.FIT/multi.its
index 26c8dad6a2..814d1f73b5 100644
--- a/doc/uImage.FIT/multi.its
+++ b/doc/uImage.FIT/multi.its
@@ -60,7 +60,7 @@
type = "ramdisk";
arch = "ppc";
os = "linux";
-   compression = "gzip";
+   compression = "none";
load = <>;
entry = <>;
hash-1 {
@@ -74,7 +74,7 @@
type = "ramdisk";
arch = "ppc";
os = "linux";
-   compression = "gzip";
+   compression = "none";
load = <>;
entry = <>;
hash-1 {
-- 
2.11.0

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


Re: [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup

2018-07-30 Thread Tom Rini
On Sun, Jul 22, 2018 at 09:46:05PM +0300, Ramon Fried wrote:

> Fixup the Linux FDT with the detection of onboard DRAM as
> provided by SBL (Secondary boot loader) by reading
> the shared-memory region.
> 
> Signed-off-by: Ramon Fried 

This breaks 820c and adds a warning on 410c (this is with 2/2 applied as well):
   aarch64:  +   dragonboard820c dragonboard410c
+(dragonboard820c,dragonboard410c)   ret = fdt_fixup_memory_banks(blob, 
bank_start, bank_size, count);
+(dragonboard820c,dragonboard410c) ^~
+(dragonboard820c,dragonboard410c) msm_fixup_memory
+(dragonboard410c)   msm_fixup_memory(blob);
+(dragonboard410c)   ^~~~
+(dragonboard410c)   fdt_fixup_memory
w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c: In 
function 'msm_fixup_memory':
w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c:91:8: 
warning: implicit declaration of function 'fdt_fixup_memory_banks'; did you 
mean 'msm_fixup_memory'? [-Wimplicit-function-declaration]
w+(dragonboard410c) ../board/qualcomm/dragonboard410c/dragonboard410c.c: In 
function 'ft_board_setup':
w+(dragonboard410c) ../board/qualcomm/dragonboard410c/dragonboard410c.c:183:2: 
warning: implicit declaration of function 'msm_fixup_memory'; did you mean 
'fdt_fixup_memory'? [-Wimplicit-function-declaration]

-- 
Tom


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


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message <20180730105319.79424-1-sgoldschm...@de.pepperl-fuchs.com> you wrote:
> Compressed images should have their compression property
> set to "none" if U-Boot should leave them compressed.
> 
> This is especially the case for compressed ramdisks that
> should be uncompressed by the kernel only.

Is this not self-explaining as is?  When you use "none", U-boot wil
do nothing to the data - it passes it on unchanged as binay blob.

I donrt see the need for this additional explanation of what seems
obvious to me.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
If you're not part of the solution, then you're part of the  precipi-
tate.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] smbios: fix checkstyle error

2018-07-30 Thread Christian Gmeiner
Fixes the following chechpatch -f error:

ERROR: "(foo*)" should be "(foo *)"
+   strncpy((char*)t->uuid, serial_str, sizeof(t->uuid));

Signed-off-by: Christian Gmeiner 
---
 lib/smbios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index df3d26b071..40c921984c 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -116,7 +116,7 @@ static int smbios_write_type1(ulong *current, int handle)
t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
t->product_name = smbios_add_string(t->eos, CONFIG_SMBIOS_PRODUCT_NAME);
if (serial_str) {
-   strncpy((char*)t->uuid, serial_str, sizeof(t->uuid));
+   strncpy((char *)t->uuid, serial_str, sizeof(t->uuid));
t->serial_number = smbios_add_string(t->eos, serial_str);
}
 
-- 
2.17.1

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


[U-Boot] [PATCH 2/2] smbios: fix checkstyle warning

2018-07-30 Thread Christian Gmeiner
Fixes the following checkstyle warning:

WARNING: Missing a blank line after declarations
+   int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++);
+   max_struct_size = max(max_struct_size, tmp);

Signed-off-by: Christian Gmeiner 
---
 lib/smbios.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/smbios.c b/lib/smbios.c
index 40c921984c..326eb00230 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -278,6 +278,7 @@ ulong write_smbios_table(ulong addr)
/* populate minimum required tables */
for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {
int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++);
+
max_struct_size = max(max_struct_size, tmp);
len += tmp;
}
-- 
2.17.1

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


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Tom Rini
On Mon, Jul 30, 2018 at 01:19:16PM +0200, Wolfgang Denk wrote:

> Dear Simon,
> 
> In message <20180730105319.79424-1-sgoldschm...@de.pepperl-fuchs.com> you 
> wrote:
> > Compressed images should have their compression property
> > set to "none" if U-Boot should leave them compressed.
> > 
> > This is especially the case for compressed ramdisks that
> > should be uncompressed by the kernel only.
> 
> Is this not self-explaining as is?  When you use "none", U-boot wil
> do nothing to the data - it passes it on unchanged as binay blob.
> 
> I donrt see the need for this additional explanation of what seems
> obvious to me.

Ah, but it's not spelled out.  And also given that currently we don't
decompress say a ramdisk that spells out compression = "gzip" (is that a
regression from initial FIT behavior?) it helps to be clear that putting
none here for "don't touch the data" is valid and that the compression
property isn't just a descriptive one, U-Boot may decompress the data.

-- 
Tom


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


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Simon Goldschmidt



On 30.07.2018 13:19, Wolfgang Denk wrote:

Dear Simon,

In message <20180730105319.79424-1-sgoldschm...@de.pepperl-fuchs.com> you wrote:

Compressed images should have their compression property
set to "none" if U-Boot should leave them compressed.

This is especially the case for compressed ramdisks that
should be uncompressed by the kernel only.


Is this not self-explaining as is?  When you use "none", U-boot wil
do nothing to the data - it passes it on unchanged as binay blob.

I donrt see the need for this additional explanation of what seems
obvious to me.


This has been explicitly requested in this mail:
https://lists.denx.de/pipermail/u-boot/2018-July/336435.html

It might seem obvious to you, but given the examples had both "none" and 
"gzip" for ramdisk, it seems it has not been obvious for everybody.



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


Re: [U-Boot] [PATCH] spl: fit: Enable GZIP compression also for no kernel partitions

2018-07-30 Thread Simon Goldschmidt



On 30.07.2018 10:54, Michal Simek wrote:

On 26.7.2018 19:16, Tom Rini wrote:

On Thu, Jul 26, 2018 at 04:23:14PM +, York Sun wrote:

On 07/25/2018 11:52 PM, Michal Simek wrote:

On 25.7.2018 23:18, York Sun wrote:

On 07/24/2018 10:58 PM, Michal Simek wrote:

On 24.7.2018 18:26, York Sun wrote:

On 07/24/2018 06:07 AM, Michal Simek wrote:

There is no reason to limit gzip usage only for OS_BOOT and kernel image
type.

Signed-off-by: Michal Simek 
---

  common/spl/spl_fit.c | 5 +
  1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 9eabb1c1058b..dbf5ac33a845 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -257,10 +257,7 @@ static int spl_load_fit_image(struct spl_load_info *info, 
ulong sector,
board_fit_image_post_process(&src, &length);
  #endif
  
-	if (IS_ENABLED(CONFIG_SPL_OS_BOOT)	&&

-   IS_ENABLED(CONFIG_SPL_GZIP) &&
-   image_comp == IH_COMP_GZIP  &&
-   type == IH_TYPE_KERNEL) {
+   if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
size = length;
if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
   src, &size)) {



This will uncompress ramdisk unnecessarily.


Can you please share your its fragment? Also is there any other image
which should be exclude?


I used it for falcon boot. I guess the executable image should have "entry". In
my setup, only kernel image has "entry". Here is my its file.

/dts-v1/;

/ {
description = "Image file for the LS1046A Linux Kernel";
#address-cells = <1>;

images {
kernel@1 {
description = "ARM64 Linux kernel";
data = /incbin/("./arch/arm64/boot/Image.gz");
type = "kernel";
arch = "arm64";
os = "linux";
compression = "gzip";
load = <0x8008>;
entry = <0x8008>;
};
fdt@1 {
description = "Flattened Device Tree blob";
data = /incbin/("./fsl-ls1046ardb.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
load = <0x9000>;
};
ramdisk@1 {
description = "Buildroot initramfs";
 data = /incbin/("./rootfs.cpio.gz");
type = "ramdisk";
arch = "arm64";
os = "linux";
compression = "gzip";


I have tested full u-boot and there is also no uncompression for ramdisk
when you put gzip compress there.
I have even tried gzip compression for fdt with expectation that u-boot
will uncompress it.

Based on doc/uImage.FIT/source_file_format.txt:
165  - compression : Compression used by included data. Supported
compressions
166 are "gzip" and "bzip2". If no compression is used compression
property
167 should be set to "none".


Based on me this means that data inside fit are compressed and you are
asking u-boot in boot to uncompress it. If you are not asking for that
you should put none there.
But it doesn't look like this is supported at all for fdt/ramdisk and it
is only handled for OS.
I see here two cases.
1. I want u-boot to uncompress my data in fit image (whatever it is)
before passing control to OS that's why I putting there compression method.
2. I want OS to uncompress data but I want pass this data unchanged from
u-boot to OS that's why I am putting compression method at "none"

I am expecting when you put "none" there than you will boot in falcon
mode without any issue.


That will work. I can put "none" for the images I don't want U-Boot to
uncompress.


Please also update the document to be clear that "none" for "don't touch
my compressed data!" is expected.  The existing language isn't clear but
I agree it makes sense (and follows the long standing practice of "-C
none" on compressed ramdisks for legacy style images).

And per Simon Goldschmidt's suggestion, after we've made the docs
clearer, making it so that U-Boot does decompress things would be good,
but we may also need to make that behavior configurable as I can see
people having put the correct compression in and not wanting it to be
uncompressed as we have examples of both none and gzip for ramdisks
today.  It's also possible (and if someone wants to dig back /
experiment and confirm) that long ago it did auto-decompress the data
and now doesn't, it would be a bugfix and no we don't need to make it
configurable.


Simon Goldschmidt: Can you please update that doc?


Done here:
https://lists.denx.de/pipermail/u-boot/2018-July/336438.html

Are you planning to implement fpga uncompression in U-Boot proper? I 
do

Re: [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup

2018-07-30 Thread Ramon Fried
On July 30, 2018 2:18:17 PM GMT+03:00, Tom Rini  wrote:
>On Sun, Jul 22, 2018 at 09:46:05PM +0300, Ramon Fried wrote:
>
>> Fixup the Linux FDT with the detection of onboard DRAM as
>> provided by SBL (Secondary boot loader) by reading
>> the shared-memory region.
>> 
>> Signed-off-by: Ramon Fried 
>
>This breaks 820c and adds a warning on 410c (this is with 2/2 applied
>as well):
>   aarch64:  +   dragonboard820c dragonboard410c
>+(dragonboard820c,dragonboard410c)   ret = fdt_fixup_memory_banks(blob,
>bank_start, bank_size, count);
>+(dragonboard820c,dragonboard410c) ^~
>+(dragonboard820c,dragonboard410c) msm_fixup_memory
>+(dragonboard410c)   msm_fixup_memory(blob);
>+(dragonboard410c)   ^~~~
>+(dragonboard410c)   fdt_fixup_memory
>w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c:
>In function 'msm_fixup_memory':
>w+(dragonboard820c,dragonboard410c)
>../arch/arm/mach-snapdragon/dram.c:91:8: warning: implicit declaration
>of function 'fdt_fixup_memory_banks'; did you mean 'msm_fixup_memory'?
>[-Wimplicit-function-declaration]
>w+(dragonboard410c)
>../board/qualcomm/dragonboard410c/dragonboard410c.c: In function
>'ft_board_setup':
>w+(dragonboard410c)
>../board/qualcomm/dragonboard410c/dragonboard410c.c:183:2: warning:
>implicit declaration of function 'msm_fixup_memory'; did you mean
>'fdt_fixup_memory'? [-Wimplicit-function-declaration]

Thanks Tom.
Strange. I don't recall it introduced warning message. Will look into it in the 
evening.


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message <20180730105319.79424-2-sgoldschm...@de.pepperl-fuchs.com> you wrote:
> To prepare supporting compression for all image types, change
> compression to "none" for ramdisks in all examples.

What makes you think this is a correct thing to do?

There are different approaches to handle things.  For example,
traditionally on Power Architecture we would use a raw kernel
binray, compress this (for example with gzip) before wrapping it
with mkimage into an (uImage or FIT) U-Boot image, and then let
U-Boot uncompress the kernel image into rum and start it.  On ARM
the kernel comes traditionally with it's own wrapper that does
unompressions and such.

Same for ramdisk handling.  On some systems it may make sense to
have U-Boot handle the uncompressing, so compression = "gzip";
may be fully intentional.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"Pardon me for breathing, which I never do anyway so I don't know why
I bother to say it, oh God, I'm so depressed. Here's another of those
self-satisfied doors. Life! Don't talk to me about life."
- Marvin the Paranoid Android
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message <6009778b-1c55-d67b-26a5-7d9039c85...@de.pepperl-fuchs.com> you 
wrote:
> 
> It might seem obvious to you, but given the examples had both "none" and 
> "gzip" for ramdisk, it seems it has not been obvious for everybody.

These may be different examples, documenting different use cases
which do exactly what they say?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The shortest unit of time in the multiverse is the News York  Second,
defined  as  the  period  of  time between the traffic lights turning
green and the cab behind you honking.
- Terry Pratchett, _Lords and Ladies_
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Simon Goldschmidt

Dear Wolfgang,

On 30.07.2018 13:46, Wolfgang Denk wrote:

Dear Simon,

In message <6009778b-1c55-d67b-26a5-7d9039c85...@de.pepperl-fuchs.com> you 
wrote:


It might seem obvious to you, but given the examples had both "none" and
"gzip" for ramdisk, it seems it has not been obvious for everybody.


These may be different examples, documenting different use cases
which do exactly what they say?


That might well be, but given that compression in FIT images only works 
for kernel sub-images up to now, I strongly doubt that.


Best Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Simon Goldschmidt

Dear Wolfgang,

On 30.07.2018 13:45, Wolfgang Denk wrote:

Dear Simon,

In message <20180730105319.79424-2-sgoldschm...@de.pepperl-fuchs.com> you wrote:

To prepare supporting compression for all image types, change
compression to "none" for ramdisks in all examples.


What makes you think this is a correct thing to do?

There are different approaches to handle things.  For example,
traditionally on Power Architecture we would use a raw kernel
binray, compress this (for example with gzip) before wrapping it
with mkimage into an (uImage or FIT) U-Boot image, and then let
U-Boot uncompress the kernel image into rum and start it.  On ARM
the kernel comes traditionally with it's own wrapper that does
unompressions and such.

Same for ramdisk handling.  On some systems it may make sense to
have U-Boot handle the uncompressing, so compression = "gzip";
may be fully intentional.


That's the whole point and in the thread I mentioned 
(https://lists.denx.de/pipermail/u-boot/2018-July/336435.html) it has 
been discussed that this is the future goal.


However, uncompression currently is only implemented for kernels, not 
for other sub-images. This patch aims at updating the docs and the 
current .its examples to what they do now.


Best regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message  you 
wrote:
>
> > These may be different examples, documenting different use cases
> > which do exactly what they say?
>
> That might well be, but given that compression in FIT images only works 
> for kernel sub-images up to now, I strongly doubt that.

This might actually be a regression the image handling rework that
went unnoticed for a long time.  I'm pretty sure that the original
implementation of FIT images handled this correctly.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"Plan to throw one away. You will anyway."
  - Fred Brooks, "The Mythical Man Month"
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/4] gpio: xilinx: Find out bank before use in xilinx_gpio_get_function()

2018-07-30 Thread Michal Simek
Call xilinx_gpio_get_bank_pin() before use.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

 drivers/gpio/xilinx_gpio.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 48b52c985a55..8ce08d80f491 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -435,6 +435,10 @@ static int xilinx_gpio_get_function(struct udevice *dev, 
unsigned offset)
int val, ret;
u32 bank, pin;
 
+   ret = xilinx_gpio_get_bank_pin(offset, &bank, &pin, dev);
+   if (ret)
+   return ret;
+
/* Check if all pins are inputs */
if (platdata->bank_input[bank])
return GPIOF_INPUT;
@@ -443,10 +447,6 @@ static int xilinx_gpio_get_function(struct udevice *dev, 
unsigned offset)
if (platdata->bank_output[bank])
return GPIOF_OUTPUT;
 
-   ret = xilinx_gpio_get_bank_pin(offset, &bank, &pin, dev);
-   if (ret)
-   return ret;
-
/* FIXME test on dual */
val = readl(&platdata->regs->gpiodir + bank * 2);
val = !(val & (1 << pin));
-- 
1.9.1

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


[U-Boot] [PATCH 2/4] gpio: xilinx: Remove !DM driver

2018-07-30 Thread Michal Simek
There is no user for !DM driver that's why remove it.

Signed-off-by: Michal Simek 
---

 drivers/gpio/xilinx_gpio.c | 338 +
 1 file changed, 2 insertions(+), 336 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 8ce08d80f491..776a147cc8d7 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -10,13 +10,9 @@
 #include 
 #include 
 #include 
+#include 
 
-static LIST_HEAD(gpio_list);
-
-enum gpio_direction {
-   GPIO_DIRECTION_OUT = 0,
-   GPIO_DIRECTION_IN = 1,
-};
+#define XILINX_GPIO_MAX_BANK   2
 
 /* Gpio simple map */
 struct gpio_regs {
@@ -24,335 +20,6 @@ struct gpio_regs {
u32 gpiodir;
 };
 
-#if !defined(CONFIG_DM_GPIO)
-
-#define GPIO_NAME_SIZE 10
-
-struct gpio_names {
-   char name[GPIO_NAME_SIZE];
-};
-
-/* Initialized, rxbd_current, rx_first_buf must be 0 after init */
-struct xilinx_gpio_priv {
-   struct gpio_regs *regs;
-   u32 gpio_min;
-   u32 gpio_max;
-   u32 gpiodata_store;
-   char name[GPIO_NAME_SIZE];
-   struct list_head list;
-   struct gpio_names *gpio_name;
-};
-
-/* Store number of allocated gpio pins */
-static u32 xilinx_gpio_max;
-
-/* Get associated gpio controller */
-static struct xilinx_gpio_priv *gpio_get_controller(unsigned gpio)
-{
-   struct list_head *entry;
-   struct xilinx_gpio_priv *priv = NULL;
-
-   list_for_each(entry, &gpio_list) {
-   priv = list_entry(entry, struct xilinx_gpio_priv, list);
-   if (gpio >= priv->gpio_min && gpio <= priv->gpio_max) {
-   debug("%s: reg: %x, min-max: %d-%d\n", __func__,
- (u32)priv->regs, priv->gpio_min, priv->gpio_max);
-   return priv;
-   }
-   }
-   puts("!!!Can't get gpio controller!!!\n");
-   return NULL;
-}
-
-/* Get gpio pin name if used/setup */
-static char *get_name(unsigned gpio)
-{
-   u32 gpio_priv;
-   struct xilinx_gpio_priv *priv;
-
-   debug("%s\n", __func__);
-
-   priv = gpio_get_controller(gpio);
-   if (priv) {
-   gpio_priv = gpio - priv->gpio_min;
-
-   return *priv->gpio_name[gpio_priv].name ?
-   priv->gpio_name[gpio_priv].name : "UNKNOWN";
-   }
-   return "UNKNOWN";
-}
-
-/* Get output value */
-static int gpio_get_output_value(unsigned gpio)
-{
-   u32 val, gpio_priv;
-   struct xilinx_gpio_priv *priv = gpio_get_controller(gpio);
-
-   if (priv) {
-   gpio_priv = gpio - priv->gpio_min;
-   val = !!(priv->gpiodata_store & (1 << gpio_priv));
-   debug("%s: reg: %x, gpio_no: %d, dir: %d\n", __func__,
- (u32)priv->regs, gpio_priv, val);
-
-   return val;
-   }
-   return -1;
-}
-
-/* Get input value */
-static int gpio_get_input_value(unsigned gpio)
-{
-   u32 val, gpio_priv;
-   struct gpio_regs *regs;
-   struct xilinx_gpio_priv *priv = gpio_get_controller(gpio);
-
-   if (priv) {
-   regs = priv->regs;
-   gpio_priv = gpio - priv->gpio_min;
-   val = readl(®s->gpiodata);
-   val = !!(val & (1 << gpio_priv));
-   debug("%s: reg: %x, gpio_no: %d, dir: %d\n", __func__,
- (u32)priv->regs, gpio_priv, val);
-
-   return val;
-   }
-   return -1;
-}
-
-/* Set gpio direction */
-static int gpio_set_direction(unsigned gpio, enum gpio_direction direction)
-{
-   u32 val, gpio_priv;
-   struct gpio_regs *regs;
-   struct xilinx_gpio_priv *priv = gpio_get_controller(gpio);
-
-   if (priv) {
-   regs = priv->regs;
-   val = readl(®s->gpiodir);
-
-   gpio_priv = gpio - priv->gpio_min;
-   if (direction == GPIO_DIRECTION_OUT)
-   val &= ~(1 << gpio_priv);
-   else
-   val |= 1 << gpio_priv;
-
-   writel(val, ®s->gpiodir);
-   debug("%s: reg: %x, gpio_no: %d, dir: %d\n", __func__,
- (u32)priv->regs, gpio_priv, val);
-
-   return 0;
-   }
-
-   return -1;
-}
-
-/* Get gpio direction */
-static int gpio_get_direction(unsigned gpio)
-{
-   u32 val, gpio_priv;
-   struct gpio_regs *regs;
-   struct xilinx_gpio_priv *priv = gpio_get_controller(gpio);
-
-   if (priv) {
-   regs = priv->regs;
-   gpio_priv = gpio - priv->gpio_min;
-   val = readl(®s->gpiodir);
-   val = !!(val & (1 << gpio_priv));
-   debug("%s: reg: %x, gpio_no: %d, dir: %d\n", __func__,
- (u32)priv->regs, gpio_priv, val);
-
-   return val;
-   }
-
-   return -1;
-}
-
-/*
- * Get input value
- * for example gpio setup to output only can't get input value
- * which is breaking gpio toggle command
- */
-int gpio_get_

[U-Boot] [PATCH 3/4] gpio: xilinx: Set value before changing direction

2018-07-30 Thread Michal Simek
Set a value before changing gpio direction. This will ensure that the
old value is not propagated when direction has changed but new value is
not written yet.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

 drivers/gpio/xilinx_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 776a147cc8d7..1e5f3da8d7e8 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -139,14 +139,14 @@ static int xilinx_gpio_direction_output(struct udevice 
*dev, unsigned offset,
if (platdata->bank_input[bank])
return -EINVAL;
 
+   xilinx_gpio_set_value(dev, offset, value);
+
if (!platdata->bank_output[bank]) {
val = readl(&platdata->regs->gpiodir + bank * 2);
val = val & ~(1 << pin);
writel(val, &platdata->regs->gpiodir + bank * 2);
}
 
-   xilinx_gpio_set_value(dev, offset, value);
-
return 0;
 }
 
-- 
1.9.1

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


[U-Boot] [PATCH 4/4] gpio: xilinx: Simplify logic in xilinx_gpio_set_value

2018-07-30 Thread Michal Simek
There is no reason to do read/write for if/else separately.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

 drivers/gpio/xilinx_gpio.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 1e5f3da8d7e8..cccfa7561739 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -61,18 +61,17 @@ static int xilinx_gpio_set_value(struct udevice *dev, 
unsigned offset,
if (ret)
return ret;
 
+   val = readl(&platdata->regs->gpiodata + bank * 2);
+
debug("%s: regs: %lx, value: %x, gpio: %x, bank %x, pin %x\n",
  __func__, (ulong)platdata->regs, value, offset, bank, pin);
 
-   if (value) {
-   val = readl(&platdata->regs->gpiodata + bank * 2);
+   if (value)
val = val | (1 << pin);
-   writel(val, &platdata->regs->gpiodata + bank * 2);
-   } else {
-   val = readl(&platdata->regs->gpiodata + bank * 2);
+   else
val = val & ~(1 << pin);
-   writel(val, &platdata->regs->gpiodata + bank * 2);
-   }
+
+   writel(val, &platdata->regs->gpiodata + bank * 2);
 
return val;
 };
-- 
1.9.1

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


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Simon Goldschmidt



On 30.07.2018 14:32, Wolfgang Denk wrote:

Dear Simon,

In message  you 
wrote:



These may be different examples, documenting different use cases
which do exactly what they say?


That might well be, but given that compression in FIT images only works
for kernel sub-images up to now, I strongly doubt that.


This might actually be a regression the image handling rework that
went unnoticed for a long time.  I'm pretty sure that the original
implementation of FIT images handled this correctly.


In that case, we should ignore parts of patch 2/2, of course. I'm pretty 
sure the default examples would still leave the ramdisk compressed for 
the kernel to uncompress though.


As I'm not that long with U-Boot, can you point me to a rough date of a 
release that I could check to see if it worked at that time?


Best regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message <6bce9049-a812-d8e4-cd2a-4b86dccae...@de.pepperl-fuchs.com> you 
wrote:
>
> However, uncompression currently is only implemented for kernels, not 
> for other sub-images. This patch aims at updating the docs and the 
> current .its examples to what they do now.

Yes, but the current state should IMO not been taken as reference.
I don't have time ATM to achtually check with older versions, but
I'm pretty sure that that was handled correctly in the original FIT
implementation, and the examples made sense at the time they were
being written.  I suspect that later changes broke the code, so only
the code needs to be fixed.

In general for the image handling there should be no distinction at
all whether this is a kernel or ramdisk or FPGA or whatever image -
compression is a feature independent of the image type, and that's
how the code should handle it.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Why can you only have two doors on a chicken coop? If it had four  it
would be a chicken sedan.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message <642b8dae-f941-5255-42c7-3761e12d0...@de.pepperl-fuchs.com> you 
wrote:
> 
> As I'm not that long with U-Boot, can you point me to a rough date of a 
> release that I could check to see if it worked at that time?

I can only speculate...  The first bigger rework of the cose appears
to be this patch series:

30864 859e92b775   2013-05-14 15:37:25 -0400   image: Move timestamp #ifdefs to 
header file
30863 61a439a873   2013-05-14 15:37:25 -0400   image: Export fit_check_ramdisk()
30862 53fbb7e885   2013-05-14 15:37:25 -0400   image: Split FIT code into new 
image-fit.c
30861 604f23dde0   2013-05-14 15:37:25 -0400   image: Move HOSTCC image code to 
tools/
30860 94e5fa46a0   2013-05-14 15:37:25 -0400   image: Split hash node 
processing into its own function
30859 b7260910dc   2013-05-14 15:37:25 -0400   image: Convert 
fit_image_hash_set_value() to static, and rename
30858 b8da836650   2013-05-14 15:37:25 -0400   image: Rename 
fit_image_check_hashes() to fit_image_verify()
30857 ab9efc665a   2013-05-14 15:37:25 -0400   image: Move hash checking into 
its own function
30856 e754da2aee   2013-05-14 15:37:25 -0400   image: Move error! string to 
common place
30855 003efd7da4   2013-05-14 15:37:25 -0400   image: Export 
fit_conf_get_prop_node()
30854 bbb467dc3c   2013-05-14 15:37:25 -0400   image: Rename fit_add_hashes() 
to fit_add_verification_data()
30853 d8b75360ee   2013-05-14 15:37:25 -0400   image: Rename hash printing to 
fit_image_print_verification_dat  a()
30852 35e7b0f179   2013-05-14 15:37:25 -0400   sandbox: image: Add support for 
booting images in sandbox
30851 aa6d6db4d4   2013-05-14 15:37:25 -0400   mkimage: Put FIT loading in 
function and tidy error handling
30850 1fe7d93891   2013-05-14 15:37:25 -0400   image: Remove remaining #ifdefs 
in image-fit.c
30849 87ebee39e9   2013-05-14 15:37:25 -0400   image: Add CONFIG_FIT_SPL_PRINT 
to control FIT image printing i  n SPL
30848 44d3a3066b   2013-05-14 15:37:25 -0400   image: Split libfdt code into 
image-fdt.c
30847 13d06981a9   2013-05-14 15:37:25 -0400   image: Add device tree setup to 
image library
30846 c19d13b030   2013-05-14 15:37:25 -0400   arm: Refactor bootm to reduce 
#ifdefs
30845 6caa195614   2013-05-14 15:37:25 -0400   arm: Use image_setup_linux() 
instead of local code
30844 3e51266a4e   2013-05-14 15:37:25 -0400   powerpc: Use image_setup_linux() 
instead of local code
30843 24507cf50a   2013-05-14 15:37:26 -0400   m68k: Use image_setup_linux() 
instead of local code
30842 2a08b740e3   2013-05-14 15:37:26 -0400   sparc: Use image_setup_linux() 
instead of local code

But there have been earlier changes, and many later (heavy) reworks,
too.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Nothing ever becomes real until it is experienced.   - John Keats
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 00/10] net: fec: Code Improvement/cleanups

2018-07-30 Thread Jagan Teki
dm code in fec_mxc has some quite few issues with mdio handling
and the dm vs non-dm code in fec_mxc looks very uncomfortable 
to read and add new support.

This series is trying to fixe all necessary issues regarding fec_mxc,
along with necessary CONFIG options are moved into defconfig.

Require enough testing to get these changes to move further.

Jagan Teki (10):
  configs: Drop imx27lite-common.h
  configs: Move CONFIG_FEC_MXC
  net: fec: Use PHY_INTERFACE_MODE_ for xcv_type
  net: fec: Add default CONFIG_FEC_MXC_PHYADDR for few boards
  net: fec: Use PHY_ADDR instead of FEC_MXC_PHYADDR
  net: fec_mxc: Use udevice to retrive priv, in fec_phy_init
  dm: net: fec: Move enet init in fec_enet
  dm: net: fec: Refactor mdio_init code
  dm: net: fec: Add support for PHY reset
  net: fec: Setup common eth_ops code for dm and non-dm

 board/compulab/cl-som-imx7/cl-som-imx7.c  |   2 +-
 .../freescale/mx6sxsabreauto/mx6sxsabreauto.c |   3 +-
 .../mx6ul_14x14_evk/mx6ul_14x14_evk.c |   2 +-
 board/freescale/mx7dsabresd/mx7dsabresd.c |   3 +-
 board/samtec/vining_2000/vining_2000.c|   3 +-
 board/sks-kinkel/sksimx6/sksimx6.c|   2 +-
 board/technexion/pico-imx7d/pico-imx7d.c  |   3 +-
 board/toradex/colibri_imx7/colibri_imx7.c |   3 +-
 board/tqc/tqma6/tqma6_mba6.c  |   2 +-
 board/udoo/neo/neo.c  |   2 +-
 configs/apalis_imx6_defconfig |   2 +
 configs/apalis_imx6_nospl_com_defconfig   |   2 +
 configs/apalis_imx6_nospl_it_defconfig|   3 +
 configs/apf27_defconfig   |   3 +
 configs/apx4devkit_defconfig  |   1 +
 configs/aristainetos2_defconfig   |   1 +
 configs/aristainetos2b_defconfig  |   1 +
 configs/aristainetos_defconfig|   1 +
 configs/bg0900_defconfig  |   1 +
 configs/cgtqmx6eval_defconfig |   2 +
 configs/cl-som-imx7_defconfig |   2 +
 configs/cm_fx6_defconfig  |   1 +
 configs/colibri_imx6_defconfig|   2 +
 configs/colibri_imx6_nospl_defconfig  |   2 +
 configs/colibri_imx7_defconfig|   1 +
 configs/colibri_vf_defconfig  |   1 +
 configs/dms-ba16-1g_defconfig |   2 +
 configs/dms-ba16_defconfig|   2 +
 configs/flea3_defconfig   |   2 +
 configs/ge_bx50v3_defconfig   |   3 +
 configs/gwventana_emmc_defconfig  |   1 +
 configs/gwventana_gw5904_defconfig|   1 +
 configs/gwventana_nand_defconfig  |   1 +
 configs/imx6dl_mamoj_defconfig|   1 +
 configs/imx6qdl_icore_rqs_defconfig   |   1 +
 configs/liteboard_defconfig   |   1 +
 configs/marsboard_defconfig   |   2 +
 configs/mccmon6_nor_defconfig |   2 +
 configs/mccmon6_sd_defconfig  |   2 +
 configs/mx25pdk_defconfig |   3 +
 configs/mx28evk_auart_console_defconfig   |   1 +
 configs/mx28evk_defconfig |   1 +
 configs/mx28evk_nand_defconfig|   1 +
 configs/mx28evk_spi_defconfig |   1 +
 configs/mx35pdk_defconfig |   3 +
 configs/mx51evk_defconfig |   3 +
 configs/mx53cx9020_defconfig  |   2 +
 configs/mx53evk_defconfig |   3 +
 configs/mx53loco_defconfig|   3 +
 configs/mx53ppd_defconfig |   3 +
 configs/mx53smd_defconfig |   3 +
 configs/mx6cuboxi_defconfig   |   1 +
 configs/mx6dlarm2_defconfig   |   1 +
 configs/mx6dlarm2_lpddr2_defconfig|   1 +
 configs/mx6qarm2_defconfig|   1 +
 configs/mx6qarm2_lpddr2_defconfig |   1 +
 configs/mx6qsabrelite_defconfig   |   1 +
 configs/mx6sabreauto_defconfig|   2 +
 configs/mx6sabresd_defconfig  |   2 +
 configs/mx6slevk_defconfig|   1 +
 configs/mx6slevk_spinor_defconfig |   1 +
 configs/mx6slevk_spl_defconfig|   2 +
 configs/mx6sxsabreauto_defconfig  |   1 +
 configs/mx6sxsabresd_defconfig|   2 +
 configs/mx6sxsabresd_spl_defconfig|   2 +
 configs/mx6ul_14x14_evk_defconfig |   2 +
 configs/mx6ul_9x9_evk_defconfig   |   2 +
 configs/mx7dsabresd_defconfig |   1 +
 configs/nitrogen6dl2g_defconfig   |   2 +
 configs/nitrogen6dl_defconfig |   2 +
 configs/nitrogen6q2g_defconfig|   2 +
 configs/nitrogen6q_defconfig  |   2 +
 configs/nitrogen6s1g_defconfig|   2 +
 configs/nitrogen6s_defconfig  |   2 +
 configs/novena_defconfig  |   2 +
 configs/opos6uldev_def

[U-Boot] [PATCH 01/10] configs: Drop imx27lite-common.h

2018-07-30 Thread Jagan Teki
This file not used by any config file, hence droped.

Cc: Adam Ford 
Signed-off-by: Jagan Teki 
---
 include/configs/imx27lite-common.h | 172 -
 1 file changed, 172 deletions(-)
 delete mode 100644 include/configs/imx27lite-common.h

diff --git a/include/configs/imx27lite-common.h 
b/include/configs/imx27lite-common.h
deleted file mode 100644
index f5c5298812..00
--- a/include/configs/imx27lite-common.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2010 Heiko Schocher 
- *
- * based on:
- * Copyright (C) 2009 Ilya Yanok 
- */
-
-#ifndef __IMX27LITE_COMMON_CONFIG_H
-#define __IMX27LITE_COMMON_CONFIG_H
-
-/*
- * SoC Configuration
- */
-#define CONFIG_MX27
-#define CONFIG_MX27_CLK32  32768   /* OSC32K frequency */
-
-#define CONFIG_CMDLINE_TAG 1   /* enable passing of ATAGs */
-#define CONFIG_SETUP_MEMORY_TAGS   1
-#define CONFIG_INITRD_TAG  1
-
-/*
- * Lowlevel configuration
- */
-#define SDRAM_ESDCFG_REGISTER_VAL(cas) \
-   (ESDCFG_TRC(10) |   \
-   ESDCFG_TRCD(3) |\
-   ESDCFG_TCAS(cas) |  \
-   ESDCFG_TRRD(1) |\
-   ESDCFG_TRAS(5) |\
-   ESDCFG_TWR |\
-   ESDCFG_TMRD(2) |\
-   ESDCFG_TRP(2) | \
-   ESDCFG_TXP(3))
-
-#define SDRAM_ESDCTL_REGISTER_VAL  \
-   (ESDCTL_PRCT(0) |   \
-ESDCTL_BL |\
-ESDCTL_PWDT(0) |   \
-ESDCTL_SREFR(3) |  \
-ESDCTL_DSIZ_32 |   \
-ESDCTL_COL10 | \
-ESDCTL_ROW13 | \
-ESDCTL_SDE)
-
-#define SDRAM_ALL_VAL  0xf00
-
-#define SDRAM_MODE_REGISTER_VAL0x33/* BL: 8, CAS: 3 */
-#define SDRAM_EXT_MODE_REGISTER_VAL0x100
-
-#define MPCTL0_VAL 0x1ef15d5
-
-#define SPCTL0_VAL 0x043a1c09
-
-#define CSCR_VAL   0x33f08107
-
-#define PCDR0_VAL  0x120470c3
-#define PCDR1_VAL  0x03030303
-#define PCCR0_VAL  0x
-#define PCCR1_VAL  0xfffc
-
-#define AIPI1_PSR0_VAL 0x20040304
-#define AIPI1_PSR1_VAL 0xdffbfcfb
-#define AIPI2_PSR0_VAL 0x07ffc200
-#define AIPI2_PSR1_VAL 0x
-
-/*
- * Memory Info
- */
-/* malloc() len */
-#define CONFIG_SYS_MALLOC_LEN  (0x1 + 512 * 1024)
-/* memtest start address */
-#define CONFIG_SYS_MEMTEST_START   0xA000
-#define CONFIG_SYS_MEMTEST_END 0xA100  /* 16MB RAM test */
-#define CONFIG_NR_DRAM_BANKS   1   /* we have 1 bank of DRAM */
-#define PHYS_SDRAM_1   0xA000  /* DDR Start */
-#define PHYS_SDRAM_1_SIZE  0x0800  /* DDR size 128MB */
-
-/*
- * Serial Driver info
- */
-#define CONFIG_MXC_UART
-#define CONFIG_MXC_UART_BASE   UART1_BASE
-
-/*
- * Flash & Environment
- */
-#define CONFIG_FLASH_CFI_DRIVER
-#define CONFIG_SYS_FLASH_CFI
-/* Use buffered writes (~10x faster) */
-#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE  1
-/* Use hardware sector protection */
-#define CONFIG_SYS_FLASH_PROTECTION1
-#define CONFIG_SYS_MAX_FLASH_BANKS 1   /* max number of flash banks */
-/* CS2 Base address */
-#define PHYS_FLASH_1   0xc000
-/* Flash Base for U-Boot */
-#define CONFIG_SYS_FLASH_BASE  PHYS_FLASH_1
-#define CONFIG_SYS_MAX_FLASH_SECT  (PHYS_FLASH_SIZE / \
-   CONFIG_SYS_FLASH_SECT_SZ)
-#define CONFIG_SYS_MONITOR_BASECONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_MONITOR_LEN 0x4 /* Reserve 256KiB */
-#define CONFIG_ENV_SIZECONFIG_ENV_SECT_SIZE
-/* Address and size of Redundant Environment Sector*/
-#define CONFIG_ENV_OFFSET_REDUND   (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
-#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
-
-/*
- * Ethernet
- */
-#define CONFIG_FEC_MXC
-#define CONFIG_FEC_MXC_PHYADDR 0x1f
-
-/*
- * MTD
- */
-#define CONFIG_FLASH_CFI_MTD
-#define CONFIG_MTD_DEVICE
-
-/*
- * NAND
- */
-#define CONFIG_MXC_NAND_REGS_BASE  0xd800
-#define CONFIG_SYS_MAX_NAND_DEVICE 1
-#define CONFIG_SYS_NAND_BASE   0xd800
-#define CONFIG_JFFS2_NAND
-#define CONFIG_MXC_NAND_HWECC
-
-/*
- * U-Boot general configuration
- */
-#define CONFIG_SYS_CBSIZE  1024/* Console I/O Buffer Size  */
-/* Boot Argument Buffer Size */
-#define CONFIG_SYS_BARGSIZECONFIG_SYS_CBSIZE
-
-#define CONFIG_LOADADDR0xa080  /* loadaddr env var */
-#define CONFIG_SYS_LOAD_ADDR   CONFIG_LOADADDR
-
-#defineCONFIG_EXTRA_ENV_SETTINGS   
\
-   "netdev=eth0\0" \
-   "nfsargs=setenv bootargs root=/dev/nfs rw " \
-   "nfsroot=${serverip}:${rootpath}\0" \
-   "ramargs=setenv boot

[U-Boot] [PATCH 03/10] net: fec: Use PHY_INTERFACE_MODE_ for xcv_type

2018-07-30 Thread Jagan Teki
Use existing PHY_INTERFACE_MODE_ for xcv_type, this eventually
- remove CONFIG_FEC_XCV_TYPE in DM_ETH boards since the phy interface
  is grabbing from DT phy-mode.
- prefix PHY_INTERFACE_MODE_ for CONFIG_FEC_XCV_TYPE in non DM_ETH boards
- added MII100, SEVENWIRE PHY mode

Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c| 18 +-
 drivers/net/fec_mxc.h| 15 +--
 include/configs/advantech_dms-ba16.h |  2 +-
 include/configs/apalis_imx6.h|  2 +-
 include/configs/aristainetos.h   |  2 +-
 include/configs/aristainetos2.h  |  2 +-
 include/configs/aristainetos2b.h |  2 +-
 include/configs/cgtqmx6eval.h|  2 +-
 include/configs/cl-som-imx7.h|  2 +-
 include/configs/cm_fx6.h |  2 +-
 include/configs/colibri_imx6.h   |  2 +-
 include/configs/colibri_imx7.h   |  2 +-
 include/configs/colibri_vf.h |  2 +-
 include/configs/dh_imx6.h|  2 +-
 include/configs/display5.h   |  2 +-
 include/configs/embestmx6boards.h|  2 +-
 include/configs/ge_bx50v3.h  |  2 +-
 include/configs/gw_ventana.h |  2 +-
 include/configs/imx6-engicam.h   |  2 --
 include/configs/imx6_logic.h |  1 -
 include/configs/kp_imx6q_tpc.h   |  2 +-
 include/configs/liteboard.h  |  2 +-
 include/configs/mccmon6.h|  2 +-
 include/configs/mx6cuboxi.h  |  2 +-
 include/configs/mx6qarm2.h   |  2 +-
 include/configs/mx6sabre_common.h|  2 +-
 include/configs/mx6slevk.h   |  2 +-
 include/configs/mx6sxsabreauto.h |  2 +-
 include/configs/mx6sxsabresd.h   |  2 +-
 include/configs/mx6ul_14x14_evk.h|  4 ++--
 include/configs/mx7dsabresd.h|  2 +-
 include/configs/mxs.h|  2 +-
 include/configs/nitrogen6x.h |  2 +-
 include/configs/novena.h |  2 +-
 include/configs/opos6uldev.h |  2 +-
 include/configs/ot1200.h |  2 +-
 include/configs/pcm052.h |  2 +-
 include/configs/pcm058.h |  2 +-
 include/configs/pfla02.h |  2 +-
 include/configs/pico-imx6ul.h|  2 +-
 include/configs/pico-imx7d.h |  2 +-
 include/configs/platinum_picon.h |  2 +-
 include/configs/platinum_titanium.h  |  2 +-
 include/configs/secomx6quq7.h|  2 +-
 include/configs/sksimx6.h|  2 +-
 include/configs/tbs2910.h|  2 +-
 include/configs/titanium.h   |  2 +-
 include/configs/tqma6_mba6.h |  2 +-
 include/configs/tqma6_wru4.h |  2 +-
 include/configs/udoo.h   |  2 +-
 include/configs/udoo_neo.h   |  2 +-
 include/configs/vf610twr.h   |  2 +-
 include/configs/vining_2000.h|  2 +-
 include/configs/wandboard.h  |  2 +-
 include/configs/xpress.h |  2 +-
 include/configs/zc5202.h |  2 +-
 include/configs/zc5601.h |  2 +-
 include/phy.h|  4 
 58 files changed, 68 insertions(+), 80 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 694a0b2f7e..fc42978a20 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "fec_mxc.h"
 
 #include 
@@ -46,7 +47,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 #ifndef CONFIG_FEC_XCV_TYPE
-#define CONFIG_FEC_XCV_TYPE MII100
+#define CONFIG_FEC_XCV_TYPEPHY_INTERFACE_MODE_MII100
 #endif
 
 /*
@@ -397,11 +398,11 @@ static void fec_reg_setup(struct fec_priv *fec)
 
/* Start with frame length = 1518, common for all modes. */
rcntrl = PKTSIZE << FEC_RCNTRL_MAX_FL_SHIFT;
-   if (fec->xcv_type != SEVENWIRE) /* xMII modes */
+   if (fec->xcv_type != PHY_INTERFACE_MODE_SEVENWIRE)  /* xMII 
modes */
rcntrl |= FEC_RCNTRL_FCE | FEC_RCNTRL_MII_MODE;
-   if (fec->xcv_type == RGMII)
+   if (fec->xcv_type == PHY_INTERFACE_MODE_RGMII)
rcntrl |= FEC_RCNTRL_RGMII;
-   else if (fec->xcv_type == RMII)
+   else if (fec->xcv_type == PHY_INTERFACE_MODE_RMII)
rcntrl |= FEC_RCNTRL_RMII;
 
writel(rcntrl, &fec->eth->r_cntrl);
@@ -552,7 +553,7 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
 
fec_reg_setup(fec);
 
-   if (fec->xcv_type != SEVENWIRE)
+   if (fec->xcv_type != PHY_INTERFACE_MODE_SEVENWIRE)
fec_mii_setspeed(fec->bus->priv);
 
/* Set Opcode/Pause Duration Register */
@@ -583,7 +584,7 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
writel((uint32_t)addr, &fec->eth->erdsr);
 
 #ifndef CONFIG_PHYLIB
-   if (fec->xcv_type != SEVENWIRE)
+   if (fec->xcv_type != PHY_INTERFACE_MODE_SEVENWIRE)
miiphy_restart_aneg(dev);
 #endif
fec_open(dev);
@@ -1233,7 +1234,7 @@ static int fec_phy_init(struct fec_priv *priv, struct 
udevice *dev)
mask = 1 << CONFIG_FEC_MXC_PHYADDR;
 #en

[U-Boot] [PATCH 02/10] configs: Move CONFIG_FEC_MXC

2018-07-30 Thread Jagan Teki
- Move CONFIG_FEC_MXC to defconfigs
- Add require depends on in kconfig

Signed-off-by: Jagan Teki 
---
Note:
- On top of
"[PATCH] Convert CONFIG_MII et al to Kconfig"

 configs/apalis_imx6_defconfig   | 1 +
 configs/apalis_imx6_nospl_com_defconfig | 1 +
 configs/apalis_imx6_nospl_it_defconfig  | 1 +
 configs/apf27_defconfig | 1 +
 configs/apx4devkit_defconfig| 1 +
 configs/aristainetos2_defconfig | 1 +
 configs/aristainetos2b_defconfig| 1 +
 configs/aristainetos_defconfig  | 1 +
 configs/bg0900_defconfig| 1 +
 configs/cgtqmx6eval_defconfig   | 1 +
 configs/cl-som-imx7_defconfig   | 1 +
 configs/cm_fx6_defconfig| 1 +
 configs/colibri_imx6_defconfig  | 1 +
 configs/colibri_imx6_nospl_defconfig| 1 +
 configs/colibri_imx7_defconfig  | 1 +
 configs/colibri_vf_defconfig| 1 +
 configs/dms-ba16-1g_defconfig   | 1 +
 configs/dms-ba16_defconfig  | 1 +
 configs/flea3_defconfig | 1 +
 configs/ge_bx50v3_defconfig | 1 +
 configs/gwventana_emmc_defconfig| 1 +
 configs/gwventana_gw5904_defconfig  | 1 +
 configs/gwventana_nand_defconfig| 1 +
 configs/liteboard_defconfig | 1 +
 configs/marsboard_defconfig | 1 +
 configs/mccmon6_nor_defconfig   | 1 +
 configs/mccmon6_sd_defconfig| 1 +
 configs/mx25pdk_defconfig   | 1 +
 configs/mx28evk_auart_console_defconfig | 1 +
 configs/mx28evk_defconfig   | 1 +
 configs/mx28evk_nand_defconfig  | 1 +
 configs/mx28evk_spi_defconfig   | 1 +
 configs/mx35pdk_defconfig   | 1 +
 configs/mx51evk_defconfig   | 1 +
 configs/mx53evk_defconfig   | 1 +
 configs/mx53loco_defconfig  | 1 +
 configs/mx53ppd_defconfig   | 1 +
 configs/mx53smd_defconfig   | 1 +
 configs/mx6cuboxi_defconfig | 1 +
 configs/mx6dlarm2_defconfig | 1 +
 configs/mx6dlarm2_lpddr2_defconfig  | 1 +
 configs/mx6qarm2_defconfig  | 1 +
 configs/mx6qarm2_lpddr2_defconfig   | 1 +
 configs/mx6qsabrelite_defconfig | 1 +
 configs/mx6sabreauto_defconfig  | 1 +
 configs/mx6sabresd_defconfig| 1 +
 configs/mx6slevk_defconfig  | 1 +
 configs/mx6slevk_spinor_defconfig   | 1 +
 configs/mx6slevk_spl_defconfig  | 2 ++
 configs/mx6sxsabreauto_defconfig| 1 +
 configs/mx6sxsabresd_defconfig  | 1 +
 configs/mx6sxsabresd_spl_defconfig  | 1 +
 configs/mx6ul_14x14_evk_defconfig   | 1 +
 configs/mx6ul_9x9_evk_defconfig | 1 +
 configs/mx7dsabresd_defconfig   | 1 +
 configs/nitrogen6dl2g_defconfig | 1 +
 configs/nitrogen6dl_defconfig   | 1 +
 configs/nitrogen6q2g_defconfig  | 1 +
 configs/nitrogen6q_defconfig| 1 +
 configs/nitrogen6s1g_defconfig  | 1 +
 configs/nitrogen6s_defconfig| 1 +
 configs/novena_defconfig| 1 +
 configs/ot1200_defconfig| 1 +
 configs/ot1200_spl_defconfig| 1 +
 configs/pcm052_defconfig| 1 +
 configs/pcm058_defconfig| 1 +
 configs/pico-imx6ul_defconfig   | 1 +
 configs/pico-imx7d_defconfig| 1 +
 configs/platinum_picon_defconfig| 1 +
 configs/platinum_titanium_defconfig | 1 +
 configs/riotboard_defconfig | 1 +
 configs/sc_sps_1_defconfig  | 1 +
 configs/secomx6quq7_defconfig   | 1 +
 configs/tbs2910_defconfig   | 1 +
 configs/titanium_defconfig  | 1 +
 configs/tqma6dl_mba6_mmc_defconfig  | 1 +
 configs/tqma6dl_mba6_spi_defconfig  | 1 +
 configs/tqma6q_mba6_mmc_defconfig   | 1 +
 configs/tqma6q_mba6_spi_defconfig   | 1 +
 configs/tqma6s_mba6_mmc_defconfig   | 1 +
 configs/tqma6s_mba6_spi_defconfig   | 1 +
 configs/tqma6s_wru4_mmc_defconfig   | 1 +
 configs/ts4800_defconfig| 1 +
 configs/udoo_defconfig  | 1 +
 configs/udoo_neo_defconfig  | 1 +
 configs/vf610twr_defconfig  | 1 +
 configs/vf610twr_nand_defconfig | 1 +
 configs/vining_2000_defconfig   | 1 +
 configs/wandboard_defconfig | 1 +
 configs/woodburn_defconfig  | 1 +
 configs/woodburn_sd_defconfig   | 1 +
 configs/xpress_defconfig| 1 +
 configs/xpress_spl_defconfig| 1 +
 configs/zc5202_defconfig| 1 +
 configs/zc5601_defconfig| 1 +
 configs/zmx25_defconfig | 1 +
 drivers/net/Kconfig | 3 ++-
 include/configs/advantech_dms-ba16.h| 1 -
 include/configs/apalis_imx6.h   | 1 -
 include/configs/apf27.h | 1 -
 include/configs/apx4devkit.h| 1 -
 include/configs/aristainetos-common.h   | 1 -
 include/configs/bg0900.h

[U-Boot] [PATCH 05/10] net: fec: Use PHY_ADDR instead of FEC_MXC_PHYADDR

2018-07-30 Thread Jagan Teki
- use PHY_ADDR_ENABLE and PHY_ADDR
- few boards are using FEC_MXC_PHYADDR without PHYLIB
  enable the same.

Signed-off-by: Jagan Teki 
---
 board/compulab/cl-som-imx7/cl-som-imx7.c  |  2 +-
 board/freescale/mx6sxsabreauto/mx6sxsabreauto.c   |  3 +--
 board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c |  2 +-
 board/freescale/mx7dsabresd/mx7dsabresd.c |  3 +--
 board/samtec/vining_2000/vining_2000.c|  3 +--
 board/sks-kinkel/sksimx6/sksimx6.c|  2 +-
 board/technexion/pico-imx7d/pico-imx7d.c  |  3 +--
 board/toradex/colibri_imx7/colibri_imx7.c |  3 +--
 board/tqc/tqma6/tqma6_mba6.c  |  2 +-
 board/udoo/neo/neo.c  |  2 +-
 configs/apalis_imx6_defconfig |  1 +
 configs/apalis_imx6_nospl_com_defconfig   |  1 +
 configs/apalis_imx6_nospl_it_defconfig|  2 ++
 configs/apf27_defconfig   |  2 ++
 configs/cgtqmx6eval_defconfig |  1 +
 configs/cl-som-imx7_defconfig |  1 +
 configs/colibri_imx6_defconfig|  1 +
 configs/colibri_imx6_nospl_defconfig  |  1 +
 configs/dms-ba16-1g_defconfig |  1 +
 configs/dms-ba16_defconfig|  1 +
 configs/flea3_defconfig   |  1 +
 configs/ge_bx50v3_defconfig   |  2 ++
 configs/imx6dl_mamoj_defconfig|  1 +
 configs/imx6qdl_icore_rqs_defconfig   |  1 +
 configs/marsboard_defconfig   |  1 +
 configs/mccmon6_nor_defconfig |  1 +
 configs/mccmon6_sd_defconfig  |  1 +
 configs/mx25pdk_defconfig |  2 ++
 configs/mx35pdk_defconfig |  2 ++
 configs/mx51evk_defconfig |  2 ++
 configs/mx53cx9020_defconfig  |  2 ++
 configs/mx53evk_defconfig |  2 ++
 configs/mx53loco_defconfig|  2 ++
 configs/mx53ppd_defconfig |  2 ++
 configs/mx53smd_defconfig |  2 ++
 configs/mx6sabreauto_defconfig|  1 +
 configs/mx6sabresd_defconfig  |  1 +
 configs/mx6sxsabresd_defconfig|  1 +
 configs/mx6sxsabresd_spl_defconfig|  1 +
 configs/mx6ul_14x14_evk_defconfig |  1 +
 configs/mx6ul_9x9_evk_defconfig   |  1 +
 configs/nitrogen6dl2g_defconfig   |  1 +
 configs/nitrogen6dl_defconfig |  1 +
 configs/nitrogen6q2g_defconfig|  1 +
 configs/nitrogen6q_defconfig  |  1 +
 configs/nitrogen6s1g_defconfig|  1 +
 configs/nitrogen6s_defconfig  |  1 +
 configs/novena_defconfig  |  1 +
 configs/opos6uldev_defconfig  |  1 +
 configs/ot1200_defconfig  |  1 +
 configs/ot1200_spl_defconfig  |  1 +
 configs/pcm058_defconfig  |  1 +
 configs/pfla02_defconfig  |  1 +
 configs/pico-imx6ul_defconfig |  1 +
 configs/pico-imx7d_defconfig  |  1 +
 configs/platinum_titanium_defconfig   |  1 +
 configs/riotboard_defconfig   |  1 +
 configs/secomx6quq7_defconfig |  1 +
 configs/sksimx6_defconfig |  1 +
 configs/tbs2910_defconfig |  1 +
 configs/titanium_defconfig|  1 +
 configs/tqma6dl_mba6_mmc_defconfig|  1 +
 configs/tqma6dl_mba6_spi_defconfig|  1 +
 configs/tqma6q_mba6_mmc_defconfig |  1 +
 configs/tqma6q_mba6_spi_defconfig |  1 +
 configs/tqma6s_mba6_mmc_defconfig |  1 +
 configs/tqma6s_mba6_spi_defconfig |  1 +
 configs/tqma6s_wru4_mmc_defconfig |  1 +
 configs/udoo_defconfig|  1 +
 configs/wandboard_defconfig   |  1 +
 configs/woodburn_defconfig|  1 +
 configs/woodburn_sd_defconfig |  1 +
 configs/zc5202_defconfig  |  1 +
 configs/zc5601_defconfig  |  1 +
 configs/zmx25_defconfig   |  1 +
 doc/README.fec_mxc|  2 +-
 drivers/net/fec_mxc.c | 15 +--
 drivers/net/phy/Kconfig   |  1 +
 include/configs/advantech_dms-ba16.h  |  1 -
 include/configs/apalis_imx6.h |  1 -
 include/configs/apf27.h   |  5 -
 include/configs/aristainetos-common.h |  1 -
 include/configs/cgtqmx6eval.h |  1 -

[U-Boot] [PATCH 04/10] net: fec: Add default CONFIG_FEC_MXC_PHYADDR for few boards

2018-07-30 Thread Jagan Teki
Usually PHYADDR is used while PHYLIB is defined, but
boards like apx4devkit, mx6qarm2 are not using PHYLIB
but they are using CONFIG_FEC_MXC_PHYADDR.

So, future patches will convert CONFIG_FEC_MXC_PHYADDR to
generic CONFIG_PHY_ADDR and that will depends on PHYLIB.
Handle this special case for this boards by adding default
CONFIG_FEC_MXC_PHYADDR to 0 if not defined so-that it can't
depends on PHYLIB local to fec_mxc. Boards which are using
PHY_ADDR in future will anyway use PHYLIB.

Cc: Ye Li 
Cc: Jason Liu 
Cc: Lauri Hintsala 
Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c| 4 
 include/configs/apx4devkit.h | 1 -
 include/configs/mx6qarm2.h   | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index fc42978a20..49bb926efa 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -50,6 +50,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define CONFIG_FEC_XCV_TYPEPHY_INTERFACE_MODE_MII100
 #endif
 
+#if defined(CONFIG_TARGET_APX4DEVKIT) || defined(CONFIG_TARGET_MX6QARM2)
+# define CONFIG_FEC_MXC_PHY_ADDR   0
+#endif
+
 /*
  * The i.MX28 operates with packets in big endian. We need to swap them before
  * sending and after receiving.
diff --git a/include/configs/apx4devkit.h b/include/configs/apx4devkit.h
index 475f9c372f..aa129edc89 100644
--- a/include/configs/apx4devkit.h
+++ b/include/configs/apx4devkit.h
@@ -52,7 +52,6 @@
 /* FEC Ethernet on SoC */
 #ifdef CONFIG_CMD_NET
 #define CONFIG_ETHPRIME"FEC"
-#define CONFIG_FEC_MXC_PHYADDR 0
 #define IMX_FEC_BASE   MXS_ENET0_BASE
 #endif
 
diff --git a/include/configs/mx6qarm2.h b/include/configs/mx6qarm2.h
index b82b8325ff..06043c888f 100644
--- a/include/configs/mx6qarm2.h
+++ b/include/configs/mx6qarm2.h
@@ -22,7 +22,6 @@
 
 #define IMX_FEC_BASE   ENET_BASE_ADDR
 #defineCONFIG_FEC_XCV_TYPE PHY_INTERFACE_MODE_RGMII
-#define CONFIG_FEC_MXC_PHYADDR 0
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
"script=boot.scr\0" \
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 07/10] dm: net: fec: Move enet init in fec_enet

2018-07-30 Thread Jagan Teki
Move enet initialization code in fec_enet function,
no functional changes.

Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3ae62ff9d1..76a3bd84f0 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1254,11 +1254,8 @@ static int fec_phy_init(struct udevice *dev)
return 0;
 }
 
-static int fecmxc_probe(struct udevice *dev)
+static int fec_enet_init(struct fec_priv *priv)
 {
-   struct eth_pdata *pdata = dev_get_platdata(dev);
-   struct fec_priv *priv = dev_get_priv(dev);
-   struct mii_dev *bus = NULL;
uint32_t start;
int ret;
 
@@ -1280,6 +1277,24 @@ static int fecmxc_probe(struct udevice *dev)
 
fec_reg_setup(priv);
 
+   return 0;
+
+err_timeout:
+   fec_free_descs(priv);
+   return ret;
+}
+
+static int fecmxc_probe(struct udevice *dev)
+{
+   struct eth_pdata *pdata = dev_get_platdata(dev);
+   struct fec_priv *priv = dev_get_priv(dev);
+   struct mii_dev *bus = NULL;
+   int ret;
+
+   ret = fec_enet_init(priv);
+   if (ret)
+   return ret;
+
priv->dev_id = dev->seq;
 #ifdef CONFIG_FEC_MXC_MDIO_BASE
bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
@@ -1303,7 +1318,6 @@ err_phy:
mdio_unregister(bus);
free(bus);
 err_mii:
-err_timeout:
fec_free_descs(priv);
return ret;
 }
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 10/10] net: fec: Setup common eth_ops code for dm and non-dm

2018-07-30 Thread Jagan Teki
Setting up common code for dm and non-dm will easy and
understandable for adding new features, debugging in
both the code area.

Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c | 225 --
 drivers/net/fec_mxc.h |   3 +
 2 files changed, 108 insertions(+), 120 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 0fdad5c5bf..3640ee3471 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -345,21 +345,8 @@ static int fec_get_hwaddr(int dev_id, unsigned char *mac)
return !is_valid_ethaddr(mac);
 }
 
-#ifdef CONFIG_DM_ETH
-static int fecmxc_set_hwaddr(struct udevice *dev)
-#else
-static int fec_set_hwaddr(struct eth_device *dev)
-#endif
+static int _fec_set_hwaddr(struct fec_priv *fec, u8 *mac)
 {
-#ifdef CONFIG_DM_ETH
-   struct fec_priv *fec = dev_get_priv(dev);
-   struct eth_pdata *pdata = dev_get_platdata(dev);
-   uchar *mac = pdata->enetaddr;
-#else
-   uchar *mac = dev->enetaddr;
-   struct fec_priv *fec = (struct fec_priv *)dev->priv;
-#endif
-
writel(0, &fec->eth->iaddr1);
writel(0, &fec->eth->iaddr2);
writel(0, &fec->eth->gaddr1);
@@ -402,17 +389,8 @@ static void fec_reg_setup(struct fec_priv *fec)
  * Start the FEC engine
  * @param[in] dev Our device to handle
  */
-#ifdef CONFIG_DM_ETH
-static int fec_open(struct udevice *dev)
-#else
-static int fec_open(struct eth_device *edev)
-#endif
+static int fec_open(struct fec_priv *fec)
 {
-#ifdef CONFIG_DM_ETH
-   struct fec_priv *fec = dev_get_priv(dev);
-#else
-   struct fec_priv *fec = (struct fec_priv *)edev->priv;
-#endif
int speed;
ulong addr, size;
int i;
@@ -487,9 +465,9 @@ static int fec_open(struct eth_device *edev)
 #elif CONFIG_FEC_FIXED_SPEED
speed = CONFIG_FEC_FIXED_SPEED;
 #else
-   miiphy_wait_aneg(edev);
-   speed = miiphy_speed(edev->name, fec->phy_id);
-   miiphy_duplex(edev->name, fec->phy_id);
+   miiphy_wait_aneg(fec->edev);
+   speed = miiphy_speed(fec->edev->name, fec->phy_id);
+   miiphy_duplex(fec->edev->name, fec->phy_id);
 #endif
 
 #ifdef FEC_QUIRK_ENET_MAC
@@ -513,27 +491,13 @@ static int fec_open(struct eth_device *edev)
return 0;
 }
 
-#ifdef CONFIG_DM_ETH
-static int fecmxc_init(struct udevice *dev)
-#else
-static int fec_init(struct eth_device *dev, bd_t *bd)
-#endif
+static int _fec_init(struct fec_priv *fec, u8 *enetaddr)
 {
-#ifdef CONFIG_DM_ETH
-   struct fec_priv *fec = dev_get_priv(dev);
-#else
-   struct fec_priv *fec = (struct fec_priv *)dev->priv;
-#endif
u8 *mib_ptr = (uint8_t *)&fec->eth->rmon_t_drop;
u8 *i;
ulong addr;
 
-   /* Initialize MAC address */
-#ifdef CONFIG_DM_ETH
-   fecmxc_set_hwaddr(dev);
-#else
-   fec_set_hwaddr(dev);
-#endif
+   _fec_set_hwaddr(fec, enetaddr);
 
/* Setup transmit descriptors, there are two in total. */
fec_tbd_init(fec);
@@ -575,9 +539,9 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
 
 #ifndef CONFIG_PHYLIB
if (fec->xcv_type != PHY_INTERFACE_MODE_SEVENWIRE)
-   miiphy_restart_aneg(dev);
+   miiphy_restart_aneg(fec->edev);
 #endif
-   fec_open(dev);
+   fec_open(fec);
return 0;
 }
 
@@ -585,17 +549,8 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
  * Halt the FEC engine
  * @param[in] dev Our device to handle
  */
-#ifdef CONFIG_DM_ETH
-static void fecmxc_halt(struct udevice *dev)
-#else
-static void fec_halt(struct eth_device *dev)
-#endif
+static void _fec_halt(struct fec_priv *fec)
 {
-#ifdef CONFIG_DM_ETH
-   struct fec_priv *fec = dev_get_priv(dev);
-#else
-   struct fec_priv *fec = (struct fec_priv *)dev->priv;
-#endif
int counter = 0x;
 
/* issue graceful stop command to the FEC transmitter if necessary */
@@ -629,11 +584,7 @@ static void fec_halt(struct eth_device *dev)
  * @param[in] length Data count in bytes
  * @return 0 on success
  */
-#ifdef CONFIG_DM_ETH
-static int fecmxc_send(struct udevice *dev, void *packet, int length)
-#else
-static int fec_send(struct eth_device *dev, void *packet, int length)
-#endif
+static int _fec_send(struct fec_priv *fec, void *packet, int length)
 {
unsigned int status;
u32 size;
@@ -645,12 +596,6 @@ static int fec_send(struct eth_device *dev, void *packet, 
int length)
 * This routine transmits one frame.  This routine only accepts
 * 6-byte Ethernet addresses.
 */
-#ifdef CONFIG_DM_ETH
-   struct fec_priv *fec = dev_get_priv(dev);
-#else
-   struct fec_priv *fec = (struct fec_priv *)dev->priv;
-#endif
-
/*
 * Check for valid length of data.
 */
@@ -780,17 +725,8 @@ out:
  * @param[in] dev Our ethernet device to handle
  * @return Length of packet read
  */
-#ifdef CONFIG_DM_ETH
-static int fecmxc_recv(struct udevice *dev, int flags, uchar **packetp)
-#else
-static int fec_recv(struct eth_device *d

[U-Boot] [PATCH 09/10] dm: net: fec: Add support for PHY reset

2018-07-30 Thread Jagan Teki
Add PHY reset code for DM_ETH by retrieving phy-reset-gpios
and phy-reset-duration in fec node.

Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c | 50 +--
 drivers/net/fec_mxc.h |  7 ++
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index a87f5b6848..0fdad5c5bf 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -16,7 +16,6 @@
 #include 
 #include 
 #include 
-#include "fec_mxc.h"
 
 #include 
 #include 
@@ -25,6 +24,9 @@
 #include 
 #include 
 #include 
+#include 
+
+#include "fec_mxc.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1245,6 +1247,33 @@ static int fec_phy_init(struct udevice *dev)
return 0;
 }
 
+#if defined(CONFIG_DM_GPIO)
+static int fec_mdio_reset(struct mii_dev *bus)
+{
+   struct udevice *dev = bus->priv;
+   struct fec_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   if (!dm_gpio_is_valid(&priv->reset_gpio))
+   return 0;
+
+   ret = dm_gpio_set_value(&priv->reset_gpio, 1);
+   if (ret)
+   return ret;
+
+   if (priv->reset_delay > 20)
+   mdelay(priv->reset_delay);
+   else
+   udelay(priv->reset_delay * 1000);
+
+   ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+#endif
+
 static int fec_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
 {
struct udevice *dev = bus->priv;
@@ -1275,6 +1304,9 @@ static int fec_mdio_init(struct udevice *dev)
bus->read = fec_mdio_read;
bus->write = fec_mdio_write;
snprintf(bus->name, sizeof(bus->name), "%s", dev->name);
+#if defined(CONFIG_DM_GPIO)
+   bus->reset = fec_mdio_reset;
+#endif
bus->priv = dev;
 
return mdio_register(bus);
@@ -1365,6 +1397,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
struct eth_pdata *pdata = dev_get_platdata(dev);
struct fec_priv *priv = dev_get_priv(dev);
const char *phy_mode;
+   int ret = 0;
 
pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
priv->eth = (struct ethernet_regs *)pdata->iobase;
@@ -1379,12 +1412,17 @@ static int fecmxc_ofdata_to_platdata(struct udevice 
*dev)
return -EINVAL;
}
 
-   /* TODO
-* Need to get the reset-gpio and related properties from DT
-* and implemet the enet reset code on .probe call
-*/
+#ifdef CONFIG_DM_GPIO
+   ret = gpio_request_by_name(dev, "phy-reset-gpios", dev->seq,
+   &priv->reset_gpio, GPIOD_IS_OUT);
+   if (ret == 0) {
+   priv->reset_delay = dev_read_u32_default(dev, 
"phy-reset-duration", 1);
+   } else if (ret == -ENOENT) {
+   ret = 0;
+   }
+#endif
 
-   return 0;
+   return ret;
 }
 
 static const struct udevice_id fecmxc_ids[] = {
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 058341ca4a..ab5935bb83 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -241,6 +241,13 @@ struct fec_priv {
int phy_id;
int (*mii_postcall)(int);
 #endif
+
+#ifdef CONFIG_DM_ETH
+# if CONFIG_IS_ENABLED(DM_GPIO)
+   struct gpio_desc reset_gpio;
+   uint32_t reset_delay;
+# endif
+#endif
 };
 
 void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 06/10] net: fec_mxc: Use udevice to retrive priv, in fec_phy_init

2018-07-30 Thread Jagan Teki
Retrive priv via udevice using dev_get_priv, so just
pass udevice pointer.

Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 11182f27d8..3ae62ff9d1 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1232,8 +1232,9 @@ static const struct eth_ops fecmxc_ops = {
.read_rom_hwaddr= fecmxc_read_rom_hwaddr,
 };
 
-static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
+static int fec_phy_init(struct udevice *dev)
 {
+   struct fec_priv *priv = dev_get_priv(dev);
struct phy_device *phydev;
int mask = 0x;
 
@@ -1292,7 +1293,7 @@ static int fecmxc_probe(struct udevice *dev)
 
priv->bus = bus;
priv->xcv_type = pdata->phy_interface;
-   ret = fec_phy_init(priv, dev);
+   ret = fec_phy_init(dev);
if (ret)
goto err_phy;
 
-- 
2.18.0.321.gffc6fa0e3

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


Re: [U-Boot] [PATCH] spl: fit: Enable GZIP compression also for no kernel partitions

2018-07-30 Thread Michal Simek
On 30.7.2018 13:28, Simon Goldschmidt wrote:
> 
> 
> On 30.07.2018 10:54, Michal Simek wrote:
>> On 26.7.2018 19:16, Tom Rini wrote:
>>> On Thu, Jul 26, 2018 at 04:23:14PM +, York Sun wrote:
 On 07/25/2018 11:52 PM, Michal Simek wrote:
> On 25.7.2018 23:18, York Sun wrote:
>> On 07/24/2018 10:58 PM, Michal Simek wrote:
>>> On 24.7.2018 18:26, York Sun wrote:
 On 07/24/2018 06:07 AM, Michal Simek wrote:
> There is no reason to limit gzip usage only for OS_BOOT and
> kernel image
> type.
>
> Signed-off-by: Michal Simek 
> ---
>
>   common/spl/spl_fit.c | 5 +
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 9eabb1c1058b..dbf5ac33a845 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -257,10 +257,7 @@ static int spl_load_fit_image(struct
> spl_load_info *info, ulong sector,
>   board_fit_image_post_process(&src, &length);
>   #endif
>   -    if (IS_ENABLED(CONFIG_SPL_OS_BOOT)    &&
> -    IS_ENABLED(CONFIG_SPL_GZIP)    &&
> -    image_comp == IH_COMP_GZIP    &&
> -    type == IH_TYPE_KERNEL) {
> +    if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp ==
> IH_COMP_GZIP) {
>   size = length;
>   if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
>  src, &size)) {
>

 This will uncompress ramdisk unnecessarily.
>>>
>>> Can you please share your its fragment? Also is there any other
>>> image
>>> which should be exclude?
>>
>> I used it for falcon boot. I guess the executable image should
>> have "entry". In
>> my setup, only kernel image has "entry". Here is my its file.
>>
>> /dts-v1/;
>>
>> / {
>> description = "Image file for the LS1046A Linux Kernel";
>> #address-cells = <1>;
>>
>> images {
>>     kernel@1 {
>>     description = "ARM64 Linux kernel";
>>     data = /incbin/("./arch/arm64/boot/Image.gz");
>>     type = "kernel";
>>     arch = "arm64";
>>     os = "linux";
>>     compression = "gzip";
>>     load = <0x8008>;
>>     entry = <0x8008>;
>>     };
>>     fdt@1 {
>>     description = "Flattened Device Tree blob";
>>     data = /incbin/("./fsl-ls1046ardb.dtb");
>>     type = "flat_dt";
>>     arch = "arm64";
>>     compression = "none";
>>     load = <0x9000>;
>>     };
>>     ramdisk@1 {
>>     description = "Buildroot initramfs";
>>  data = /incbin/("./rootfs.cpio.gz");
>>     type = "ramdisk";
>>     arch = "arm64";
>>     os = "linux";
>>     compression = "gzip";
>
> I have tested full u-boot and there is also no uncompression for
> ramdisk
> when you put gzip compress there.
> I have even tried gzip compression for fdt with expectation that
> u-boot
> will uncompress it.
>
> Based on doc/uImage.FIT/source_file_format.txt:
> 165  - compression : Compression used by included data. Supported
> compressions
> 166 are "gzip" and "bzip2". If no compression is used compression
> property
> 167 should be set to "none".
>
>
> Based on me this means that data inside fit are compressed and you are
> asking u-boot in boot to uncompress it. If you are not asking for that
> you should put none there.
> But it doesn't look like this is supported at all for fdt/ramdisk
> and it
> is only handled for OS.
> I see here two cases.
> 1. I want u-boot to uncompress my data in fit image (whatever it is)
> before passing control to OS that's why I putting there compression
> method.
> 2. I want OS to uncompress data but I want pass this data unchanged
> from
> u-boot to OS that's why I am putting compression method at "none"
>
> I am expecting when you put "none" there than you will boot in falcon
> mode without any issue.

 That will work. I can put "none" for the images I don't want U-Boot to
 uncompress.
>>>
>>> Please also update the document to be clear that "none" for "don't touch
>>> my compressed data!" is expected.  The existing language isn't clear but
>>> I agree it makes sense (and follows the long standing practice of "-C
>>> none" on compressed ramdisks for legacy style images).
>>>
>>> And per Simon Goldschmidt's suggestion, after we've made the docs
>>> clearer, making it so that U-Boot does decompress things would be good,
>>> but we may also need to make that behavior confi

[U-Boot] [PATCH 08/10] dm: net: fec: Refactor mdio_init code

2018-07-30 Thread Jagan Teki
mdio initialization in dm code is assigning bus->priv
with pointer to struct ethernet_regs which leads to
improper mii. Add proper udevice to store mii_bus priv
and reuse the same in mdio ops.

Also refactor mdio code, to make common ops for dm and non-dm.

Signed-off-by: Jagan Teki 
---
 drivers/net/fec_mxc.c | 148 +-
 1 file changed, 87 insertions(+), 61 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 76a3bd84f0..a87f5b6848 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -91,11 +91,8 @@ static void swap_packet(uint32_t *packet, int length)
 #endif
 
 /* MII-interface related functions */
-static int fec_mdio_read(struct ethernet_regs *eth, uint8_t phyaddr,
-   uint8_t regaddr)
+static int _fec_mdio_read(struct ethernet_regs *eth, int addr, int reg)
 {
-   uint32_t reg;   /* convenient holder for the PHY register */
-   uint32_t phy;   /* convenient holder for the PHY */
uint32_t start;
int val;
 
@@ -104,11 +101,10 @@ static int fec_mdio_read(struct ethernet_regs *eth, 
uint8_t phyaddr,
 * programming the FEC's MII data register.
 */
writel(FEC_IEVENT_MII, ð->ievent);
-   reg = regaddr << FEC_MII_DATA_RA_SHIFT;
-   phy = phyaddr << FEC_MII_DATA_PA_SHIFT;
 
writel(FEC_MII_DATA_ST | FEC_MII_DATA_OP_RD | FEC_MII_DATA_TA |
-   phy | reg, ð->mii_data);
+  (addr << FEC_MII_DATA_PA_SHIFT) | (reg << FEC_MII_DATA_RA_SHIFT),
+  ð->mii_data);
 
/* wait for the related interrupt */
start = get_timer(0);
@@ -124,8 +120,8 @@ static int fec_mdio_read(struct ethernet_regs *eth, uint8_t 
phyaddr,
 
/* it's now safe to read the PHY's register */
val = (unsigned short)readl(ð->mii_data);
-   debug("%s: phy: %02x reg:%02x val:%#x\n", __func__, phyaddr,
- regaddr, val);
+   debug("%s: phy: %02x reg:%02x val:%#x\n", __func__, addr,
+ reg, val);
return val;
 }
 
@@ -156,18 +152,14 @@ static void fec_mii_setspeed(struct ethernet_regs *eth)
debug("%s: mii_speed %08x\n", __func__, readl(ð->mii_speed));
 }
 
-static int fec_mdio_write(struct ethernet_regs *eth, uint8_t phyaddr,
-   uint8_t regaddr, uint16_t data)
+static int _fec_mdio_write(struct ethernet_regs *eth, int addr, int reg,
+  u16 val)
 {
-   uint32_t reg;   /* convenient holder for the PHY register */
-   uint32_t phy;   /* convenient holder for the PHY */
uint32_t start;
 
-   reg = regaddr << FEC_MII_DATA_RA_SHIFT;
-   phy = phyaddr << FEC_MII_DATA_PA_SHIFT;
-
-   writel(FEC_MII_DATA_ST | FEC_MII_DATA_OP_WR |
-   FEC_MII_DATA_TA | phy | reg | data, ð->mii_data);
+   writel(FEC_MII_DATA_ST | FEC_MII_DATA_OP_WR | FEC_MII_DATA_TA |
+  (addr << FEC_MII_DATA_PA_SHIFT) | (reg << FEC_MII_DATA_RA_SHIFT) 
|
+  val, ð->mii_data);
 
/* wait for the MII interrupt */
start = get_timer(0);
@@ -180,24 +172,12 @@ static int fec_mdio_write(struct ethernet_regs *eth, 
uint8_t phyaddr,
 
/* clear MII interrupt bit */
writel(FEC_IEVENT_MII, ð->ievent);
-   debug("%s: phy: %02x reg:%02x val:%#x\n", __func__, phyaddr,
- regaddr, data);
+   debug("%s: phy: %02x reg:%02x val:%#x\n", __func__, addr,
+ reg, val);
 
return 0;
 }
 
-static int fec_phy_read(struct mii_dev *bus, int phyaddr, int dev_addr,
-   int regaddr)
-{
-   return fec_mdio_read(bus->priv, phyaddr, regaddr);
-}
-
-static int fec_phy_write(struct mii_dev *bus, int phyaddr, int dev_addr,
-int regaddr, u16 data)
-{
-   return fec_mdio_write(bus->priv, phyaddr, regaddr, data);
-}
-
 #ifndef CONFIG_PHYLIB
 static int miiphy_restart_aneg(struct eth_device *dev)
 {
@@ -211,17 +191,17 @@ static int miiphy_restart_aneg(struct eth_device *dev)
 * Reset PHY, then delay 300ns
 */
 #ifdef CONFIG_MX27
-   fec_mdio_write(eth, fec->phy_id, MII_DCOUNTER, 0x00FF);
+   _fec_mdio_write(eth, fec->phy_id, MII_DCOUNTER, 0x00FF);
 #endif
-   fec_mdio_write(eth, fec->phy_id, MII_BMCR, BMCR_RESET);
+   _fec_mdio_write(eth, fec->phy_id, MII_BMCR, BMCR_RESET);
udelay(1000);
 
/* Set the auto-negotiation advertisement register bits */
-   fec_mdio_write(eth, fec->phy_id, MII_ADVERTISE,
-  LPA_100FULL | LPA_100HALF | LPA_10FULL |
-  LPA_10HALF | PHY_ANLPAR_PSB_802_3);
-   fec_mdio_write(eth, fec->phy_id, MII_BMCR,
-  BMCR_ANENABLE | BMCR_ANRESTART);
+   _fec_mdio_write(eth, fec->phy_id, MII_ADVERTISE,
+   LPA_100FULL | LPA_100HALF | LPA_10FULL |
+   LPA_10HALF | PHY_ANLPAR_PSB_802_3);
+   _fec_mdio_write(eth, fec->phy_id, MII_BMCR,
+  

Re: [U-Boot] [PATCH 3/4] gpio: xilinx: Not read output values via regs

2018-07-30 Thread Michal Simek
On 27.7.2018 10:41, Stefan Herbrechtsmeier wrote:
> Am 27.07.2018 um 09:05 schrieb Michal Simek:
>> On 26.7.2018 21:46, Stefan Herbrechtsmeier wrote:
>>> Am 26.07.2018 um 10:41 schrieb Michal Simek:
 On 25.7.2018 20:21, Stefan Herbrechtsmeier wrote:
> Am 25.07.2018 um 08:39 schrieb Michal Simek:
>> On 24.7.2018 21:56, Stefan Herbrechtsmeier wrote:
>>> Am 24.07.2018 um 12:31 schrieb Michal Simek:
 On 23.7.2018 20:42, Stefan Herbrechtsmeier wrote:
> Am 23.07.2018 um 13:43 schrieb Michal Simek:
>> Reading registers for finding out output value is not working
>> because
>> input value is read instead in case of tristate.
>>
>> Reported-by: Stefan Herbrechtsmeier 
>> Signed-off-by: Michal Simek 
>> ---
>>
>>   drivers/gpio/xilinx_gpio.c | 38
>> +-
>>   1 file changed, 33 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpio/xilinx_gpio.c
>> b/drivers/gpio/xilinx_gpio.c
>> index 4da9ae114d87..9d3e9379d0e5 100644
>> --- a/drivers/gpio/xilinx_gpio.c
>> +++ b/drivers/gpio/xilinx_gpio.c
>>> [snip]
>>>
>>   +    priv->output_val[bank] = val;
>> +
>>   return val;
>>   };
>>   @@ -441,6 +449,7 @@ static int
>> xilinx_gpio_get_function(struct
>> udevice *dev, unsigned offset)
>>   static int xilinx_gpio_get_value(struct udevice *dev,
>> unsigned
>> offset)
>>   {
>>   struct xilinx_gpio_platdata *platdata =
>> dev_get_platdata(dev);
>> +    struct xilinx_gpio_privdata *priv = dev_get_priv(dev);
>>   int val, ret;
>>   u32 bank, pin;
>>   @@ -451,7 +460,14 @@ static int
>> xilinx_gpio_get_value(struct
>> udevice
>> *dev, unsigned offset)
>>   debug("%s: regs: %lx, gpio: %x, bank %x, pin %x\n",
>> __func__,
>>     (ulong)platdata->regs, offset, bank, pin);
>>   -    val = readl(&platdata->regs->gpiodata + bank * 2);
>> +    if (xilinx_gpio_get_function(dev, offset) == GPIOF_INPUT) {
>> +    debug("%s: Read input value from reg\n", __func__);
>> +    val = readl(&platdata->regs->gpiodata + bank * 2);
>> +    } else {
>> +    debug("%s: Read saved output value\n", __func__);
>> +    val = priv->output_val[bank];
>> +    }
> Why you don't always read the data register? This doesn't work for
> three
> state outputs.
 In three state register every bit/pin is 0 - output, 1 input.
 It means else part is output and I read saved value in
 priv->output_val.
 If pin is setup as INPUT then I need read data reg to find out
 input
 value.
 Maybe you are commenting something else but please let me know if
 there
 is any other bug.
>>> What happen if I have an open drain output. Even if the gpio output
>>> is 1
>>> the input could read a 0. You driver will always return the output
>>> value
>>> and not the real input value. According to the picture in
>>> documentation
>>> and my tests a data register write writes the output registers and a
>>> data register read reads the input registers.
>>>
>>> Why should the driver return the desired state (output register)
>>> and not
>>> the real state (input register)?
>> First of all thanks for description.
>>
>> I have another example where you have output only and you can't read
>> input because there is no wire.
> Does you mean the all outputs configuration? Does this removes the
> "gpio_io_i" signal from the IP?
 I am not sure what synthesis is doing with that unused IP pins but I
 would consider as a bug if this is automatically connected together.
>>> I mean does the IP generator removes the gpio_io_i signal because it
>>> isn't needed? If the IP generator creates the gpio_io_i signal I would
>>> expect that you can't leave it unconnected as this would lead to
>>> undefined values.
>> Normally when you know that you have output only there is no no
>> gpio_io_i or tristate signal. The same for input only.
> 
> And in this case the device tree flags "xlnx,all-inputs" or
> "xlnx,all-outputs" should be set.

yes.

> 
    And
 also wasting a logic if there is unused part.
 But in Vivado you should be able to setup output pins to and input pins
 separately. There are In/Out/Tristate.
 If you don't want to deal with external pin you can connect them
 inside PL.
>>> This isn't my point. I mean that if you have an gpio_io_i signal you
>>> have to connected it to a signal. You could connect it to the output of
>>> an IO, to the gpio_io_o sign

Re: [U-Boot] [PATCH] spl: fit: Enable GZIP compression also for no kernel partitions

2018-07-30 Thread Michal Simek
On 26.7.2018 18:23, York Sun wrote:
> On 07/25/2018 11:52 PM, Michal Simek wrote:
>> On 25.7.2018 23:18, York Sun wrote:
>>> On 07/24/2018 10:58 PM, Michal Simek wrote:
 On 24.7.2018 18:26, York Sun wrote:
> On 07/24/2018 06:07 AM, Michal Simek wrote:
>> There is no reason to limit gzip usage only for OS_BOOT and kernel image
>> type.
>>
>> Signed-off-by: Michal Simek 
>> ---
>>
>>  common/spl/spl_fit.c | 5 +
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index 9eabb1c1058b..dbf5ac33a845 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -257,10 +257,7 @@ static int spl_load_fit_image(struct spl_load_info 
>> *info, ulong sector,
>>  board_fit_image_post_process(&src, &length);
>>  #endif
>>  
>> -if (IS_ENABLED(CONFIG_SPL_OS_BOOT)  &&
>> -IS_ENABLED(CONFIG_SPL_GZIP) &&
>> -image_comp == IH_COMP_GZIP  &&
>> -type == IH_TYPE_KERNEL) {
>> +if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
>>  size = length;
>>  if (gunzip((void *)load_addr, CONFIG_SYS_BOOTM_LEN,
>> src, &size)) {
>>
>
> This will uncompress ramdisk unnecessarily.

 Can you please share your its fragment? Also is there any other image
 which should be exclude?
>>>
>>> I used it for falcon boot. I guess the executable image should have 
>>> "entry". In
>>> my setup, only kernel image has "entry". Here is my its file.
>>>
>>> /dts-v1/;
>>>
>>> / {
>>> description = "Image file for the LS1046A Linux Kernel";
>>> #address-cells = <1>;
>>>
>>> images {
>>> kernel@1 {
>>> description = "ARM64 Linux kernel";
>>> data = /incbin/("./arch/arm64/boot/Image.gz");
>>> type = "kernel";
>>> arch = "arm64";
>>> os = "linux";
>>> compression = "gzip";
>>> load = <0x8008>;
>>> entry = <0x8008>;
>>> };
>>> fdt@1 {
>>> description = "Flattened Device Tree blob";
>>> data = /incbin/("./fsl-ls1046ardb.dtb");
>>> type = "flat_dt";
>>> arch = "arm64";
>>> compression = "none";
>>> load = <0x9000>;
>>> };
>>> ramdisk@1 {
>>> description = "Buildroot initramfs";
>>> data = /incbin/("./rootfs.cpio.gz");
>>> type = "ramdisk";
>>> arch = "arm64";
>>> os = "linux";
>>> compression = "gzip";
>>
>> I have tested full u-boot and there is also no uncompression for ramdisk
>> when you put gzip compress there.
>> I have even tried gzip compression for fdt with expectation that u-boot
>> will uncompress it.
>>
>> Based on doc/uImage.FIT/source_file_format.txt:
>> 165  - compression : Compression used by included data. Supported
>> compressions
>> 166 are "gzip" and "bzip2". If no compression is used compression
>> property
>> 167 should be set to "none".
>>
>>
>> Based on me this means that data inside fit are compressed and you are
>> asking u-boot in boot to uncompress it. If you are not asking for that
>> you should put none there.
>> But it doesn't look like this is supported at all for fdt/ramdisk and it
>> is only handled for OS.
>> I see here two cases.
>> 1. I want u-boot to uncompress my data in fit image (whatever it is)
>> before passing control to OS that's why I putting there compression method.
>> 2. I want OS to uncompress data but I want pass this data unchanged from
>> u-boot to OS that's why I am putting compression method at "none"
>>
>> I am expecting when you put "none" there than you will boot in falcon
>> mode without any issue.
> 
> That will work. I can put "none" for the images I don't want U-Boot to
> uncompress.

ok. Can you please retest this patch with none and give me some tags to
add it to this patch?

Thanks,
Michal

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


[U-Boot] [PATCH 5/8] clk: Add generic_clk_valid

2018-07-30 Thread Jagan Teki
Add clock validate function for validating
specific clock to do further clock operations.

Signed-off-by: Jagan Teki 
Reviewed-by: Simon Glass 
---
 include/clk-uclass.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index e76d98e2f6..452eed008e 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -100,4 +100,14 @@ struct clk_ops {
int (*disable)(struct clk *clk);
 };
 
+/**
+ * generic_clk_valid() - check if clk port is valid
+ *
+ * @clk:   the clk port to check
+ * @return TRUE if valid, or FALSE
+ */
+static inline bool generic_clk_valid(struct clk *clk)
+{
+   return clk->dev != NULL;
+}
 #endif
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 4/8] clk: imx: imx6ul: Implement ENET clocks

2018-07-30 Thread Jagan Teki
Add support for ENET clock on i.MX6UL platform.

Signed-off-by: Jagan Teki 
Reviewed-by: Joe Hershberger 
---
 drivers/clk/imx/Kconfig  |  7 +++
 drivers/clk/imx/Makefile |  1 +
 drivers/clk/imx/clk_imx6ul.c | 92 
 3 files changed, 100 insertions(+)
 create mode 100644 drivers/clk/imx/clk_imx6ul.c

diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
index f8de5554c8..cfb9cfe2eb 100644
--- a/drivers/clk/imx/Kconfig
+++ b/drivers/clk/imx/Kconfig
@@ -15,4 +15,11 @@ config CLK_IMX6Q
  This enables common clock driver support for platforms based
  on i.MX6 QDL SoC.
 
+config CLK_IMX6UL
+   bool "Clock driver for i.MX6UL"
+   default MX6UL
+   help
+ This enables common clock driver support for platforms based
+ on i.MX6 UL SoC.
+
 endif # CLK_IMX
diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
index 8ae3a50eba..67d6f9a19f 100644
--- a/drivers/clk/imx/Makefile
+++ b/drivers/clk/imx/Makefile
@@ -5,3 +5,4 @@
 #
 
 obj-$(CONFIG_CLK_IMX6Q) += clk_imx6q.o
+obj-$(CONFIG_CLK_IMX6UL) += clk_imx6ul.o
diff --git a/drivers/clk/imx/clk_imx6ul.c b/drivers/clk/imx/clk_imx6ul.c
new file mode 100644
index 00..5451b46667
--- /dev/null
+++ b/drivers/clk/imx/clk_imx6ul.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ * Author: Jagan Teki 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct imx6ul_clk_priv {
+   void *base;
+};
+
+static ulong imx6ul_clk_get_rate(struct clk *clk)
+{
+   debug("%s(#%ld)\n", __func__, clk->id);
+
+   debug("  unhandled\n");
+   return -EINVAL;
+}
+
+static ulong imx6ul_clk_set_rate(struct clk *clk, ulong rate)
+{
+   debug("%s(#%ld)\n", __func__, clk->id);
+
+   debug("  unhandled\n");
+   return -EINVAL;
+}
+
+static int imx6ul_clk_enable(struct clk *clk)
+{
+   struct imx6ul_clk_priv *priv = dev_get_priv(clk->dev);
+
+   debug("%s(#%ld)\n", __func__, clk->id);
+
+   switch (clk->id) {
+   case IMX6UL_CLK_ENET_PTP:
+   /* ref clock handling done via IMX6UL_CLK_ENET_REF */
+   clk = NULL;
+   return 0;
+   case IMX6UL_CLK_ENET_REF:
+   return enable_fec_anatop_clock(0, ENET_50MHZ);
+   case IMX6UL_CLK_ENET2_REF_125M:
+   return enable_fec_anatop_clock(1, ENET_50MHZ);
+   case IMX6UL_CLK_ENET_AHB:
+   setbits_le32(priv->base + 0x74, GENMASK(5, 4));
+   return 0;
+   default:
+   printf("  unhandled\n");
+   return -ENODEV;
+   }
+}
+
+static struct clk_ops imx6ul_clk_ops = {
+   .get_rate = imx6ul_clk_get_rate,
+   .set_rate = imx6ul_clk_set_rate,
+   .enable = imx6ul_clk_enable,
+};
+
+static int imx6ul_clk_probe(struct udevice *dev)
+{
+   return 0;
+}
+
+static int imx6ul_clk_ofdata_to_platdata(struct udevice *dev)
+{
+   struct imx6ul_clk_priv *priv = dev_get_priv(dev);
+
+   priv->base = dev_read_addr_ptr(dev);
+
+   return 0;
+}
+
+static const struct udevice_id imx6ul_clk_ids[] = {
+   { .compatible = "fsl,imx6ul-ccm" },
+   { }
+};
+
+U_BOOT_DRIVER(fsl_imx6ul_ccm) = {
+   .name   = "fsl_imx6ul_ccm",
+   .id = UCLASS_CLK,
+   .of_match   = imx6ul_clk_ids,
+   .priv_auto_alloc_size   = sizeof(struct imx6ul_clk_priv),
+   .ofdata_to_platdata = imx6ul_clk_ofdata_to_platdata,
+   .ops= &imx6ul_clk_ops,
+   .probe  = imx6ul_clk_probe,
+};
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 3/8] clk: imx: imx6q: Implement ENET clocks

2018-07-30 Thread Jagan Teki
Add support for ENET clock on i.MX6QDL platform.

Signed-off-by: Jagan Teki 
Reviewed-by: Joe Hershberger 
---
 drivers/clk/imx/clk_imx6q.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/imx/clk_imx6q.c b/drivers/clk/imx/clk_imx6q.c
index 3019218411..039aa9b1b1 100644
--- a/drivers/clk/imx/clk_imx6q.c
+++ b/drivers/clk/imx/clk_imx6q.c
@@ -26,7 +26,7 @@ static ulong imx6q_clk_get_rate(struct clk *clk)
 
 static ulong imx6q_clk_set_rate(struct clk *clk, ulong rate)
 {
-   debug("%s(#%ld, rate: %lu)\n", __func__, clk->id, rate);
+   debug("%s(#%ld)\n", __func__, clk->id);
 
debug("  unhandled\n");
return -EINVAL;
@@ -34,10 +34,20 @@ static ulong imx6q_clk_set_rate(struct clk *clk, ulong rate)
 
 static int imx6q_clk_enable(struct clk *clk)
 {
+   struct imx6q_clk_priv *priv = dev_get_priv(clk->dev);
+
debug("%s(#%ld)\n", __func__, clk->id);
 
-   debug("  unhandled\n");
-   return -EINVAL;
+   switch (clk->id) {
+   case IMX6QDL_CLK_ENET:
+   setbits_le32(priv->base + 0x6c, GENMASK(11, 10));
+   return 0;
+   case IMX6QDL_CLK_ENET_REF:
+   return enable_fec_anatop_clock(0, ENET_50MHZ);
+   default:
+   printf("  unhandled\n");
+   return -ENODEV;
+   }
 }
 
 static struct clk_ops imx6q_clk_ops = {
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 6/8] net: fec_mxc: Add clock support via CLK

2018-07-30 Thread Jagan Teki
Now enet clock support available for imx6qdl and imx6ul,
via CLK framework, so add enable, set_rate support in
drivers.

Signed-off-by: Jagan Teki 
Acked-by: Joe Hershberger 
---
 drivers/net/fec_mxc.c | 58 ++-
 drivers/net/fec_mxc.h |  5 
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3640ee3471..53b99f6654 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1297,11 +1298,52 @@ static int fec_mdio_init(struct udevice *dev)
return mdio_register(bus);
 }
 
+#if CONFIG_IS_ENABLED(CLK)
+static int fec_clk_enable(struct fec_priv *priv)
+{
+   int ret;
+
+   ret = clk_enable(&priv->clk_ahb);
+   if (ret) {
+   printf("failed to enable ahb clk\n");
+   return ret;
+   }
+
+   if (generic_clk_valid(&priv->clk_ptp)) {
+   ret = clk_enable(&priv->clk_ptp);
+   if (ret) {
+   printf("failed to set 50MHz rate to ptp clk\n");
+   goto failed_clk_ahb;
+   }
+   }
+
+   if (generic_clk_valid(&priv->clk_enet_out)) {
+   ret = clk_enable(&priv->clk_enet_out);
+   if (ret) {
+   printf("failed to set 50MHz rate to enet_out clk\n");
+   goto failed_clk_ahb;
+   }
+   }
+
+   return 0;
+
+failed_clk_ahb:
+   clk_disable(&priv->clk_ahb);
+   return ret;
+}
+#endif
+
 static int fec_enet_init(struct fec_priv *priv)
 {
uint32_t start;
int ret;
 
+#if CONFIG_IS_ENABLED(CLK)
+   ret = fec_clk_enable(priv);
+   if (ret)
+   return ret;
+#endif
+
ret = fec_alloc_descs(priv);
if (ret)
return ret;
@@ -1407,7 +1449,21 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
}
 #endif
 
-   return ret;
+#if CONFIG_IS_ENABLED(CLK)
+   ret = clk_get_by_name(dev, "ahb", &priv->clk_ahb);
+   if (ret)
+   ret = PTR_ERR(&priv->clk_ahb);
+
+   ret = clk_get_by_name(dev, "ptp", &priv->clk_ptp);
+   if (ret)
+   dev_dbg(dev, "Warning: failed to get ptp clk\n");
+
+   ret = clk_get_by_name(dev, "enet_out", &priv->clk_enet_out);
+   if (ret)
+   dev_dbg(dev, "Warning: failed to get enet_out clk\n");
+#endif
+
+   return 0;
 }
 
 static const struct udevice_id fecmxc_ids[] = {
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 6cf2a8b3cc..76a40053a4 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -250,6 +250,11 @@ struct fec_priv {
struct gpio_desc reset_gpio;
uint32_t reset_delay;
 # endif
+#if CONFIG_IS_ENABLED(CLK)
+   struct clk clk_ahb;
+   struct clk clk_ptp;
+   struct clk clk_enet_out;
+# endif
 #endif
 };
 
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 2/8] clk: Add DM CLK driver template for i.MX6QDL

2018-07-30 Thread Jagan Teki
Add DM CLK driver for iMX6QDL platform.
- basic template for clk_imx6qdl.c
- Kconfig support

Signed-off-by: Jagan Teki 
---
 drivers/clk/Kconfig |  1 +
 drivers/clk/Makefile|  1 +
 drivers/clk/imx/Kconfig | 18 +
 drivers/clk/imx/Makefile|  7 
 drivers/clk/imx/clk_imx6q.c | 76 +
 drivers/video/ipu_common.c  |  8 
 6 files changed, 111 insertions(+)
 create mode 100644 drivers/clk/imx/Kconfig
 create mode 100644 drivers/clk/imx/Makefile
 create mode 100644 drivers/clk/imx/clk_imx6q.c

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a99abed9e9..0a535e49d4 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -85,6 +85,7 @@ config CLK_STM32MP1
 
 source "drivers/clk/at91/Kconfig"
 source "drivers/clk/exynos/Kconfig"
+source "drivers/clk/imx/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/owl/Kconfig"
 source "drivers/clk/renesas/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 146283c723..c3288b096f 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o
 obj-$(CONFIG_CLK_BOSTON) += clk_boston.o
 obj-$(CONFIG_CLK_EXYNOS) += exynos/
 obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o
+obj-$(CONFIG_CLK_IMX) += imx/
 obj-$(CONFIG_CLK_OWL) += owl/
 obj-$(CONFIG_CLK_RENESAS) += renesas/
 obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o
diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
new file mode 100644
index 00..f8de5554c8
--- /dev/null
+++ b/drivers/clk/imx/Kconfig
@@ -0,0 +1,18 @@
+config CLK_IMX
+   bool "Clock support for i.MX SoCs"
+   depends on ARCH_MX6
+   select CLK
+   help
+ This enables support for common clock driver API on i.MX
+ SoCs.
+
+if CLK_IMX
+
+config CLK_IMX6Q
+   bool "Clock driver for i.MX6QDL"
+   default MX6QDL
+   help
+ This enables common clock driver support for platforms based
+ on i.MX6 QDL SoC.
+
+endif # CLK_IMX
diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
new file mode 100644
index 00..8ae3a50eba
--- /dev/null
+++ b/drivers/clk/imx/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2018 Arm Ltd.
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+obj-$(CONFIG_CLK_IMX6Q) += clk_imx6q.o
diff --git a/drivers/clk/imx/clk_imx6q.c b/drivers/clk/imx/clk_imx6q.c
new file mode 100644
index 00..3019218411
--- /dev/null
+++ b/drivers/clk/imx/clk_imx6q.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ * Author: Jagan Teki 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct imx6q_clk_priv {
+   void *base;
+};
+
+static ulong imx6q_clk_get_rate(struct clk *clk)
+{
+   debug("%s(#%ld)\n", __func__, clk->id);
+
+   debug("  unhandled\n");
+   return -EINVAL;
+}
+
+static ulong imx6q_clk_set_rate(struct clk *clk, ulong rate)
+{
+   debug("%s(#%ld, rate: %lu)\n", __func__, clk->id, rate);
+
+   debug("  unhandled\n");
+   return -EINVAL;
+}
+
+static int imx6q_clk_enable(struct clk *clk)
+{
+   debug("%s(#%ld)\n", __func__, clk->id);
+
+   debug("  unhandled\n");
+   return -EINVAL;
+}
+
+static struct clk_ops imx6q_clk_ops = {
+   .get_rate = imx6q_clk_get_rate,
+   .set_rate = imx6q_clk_set_rate,
+   .enable = imx6q_clk_enable,
+};
+
+static int imx6q_clk_probe(struct udevice *dev)
+{
+   return 0;
+}
+
+static int imx6q_clk_ofdata_to_platdata(struct udevice *dev)
+{
+   struct imx6q_clk_priv *priv = dev_get_priv(dev);
+
+   priv->base = dev_read_addr_ptr(dev);
+
+   return 0;
+}
+
+static const struct udevice_id imx6q_clk_ids[] = {
+   { .compatible = "fsl,imx6q-ccm" },
+   { }
+};
+
+U_BOOT_DRIVER(fsl_imx6q_ccm) = {
+   .name   = "fsl_imx6q_ccm",
+   .id = UCLASS_CLK,
+   .of_match   = imx6q_clk_ids,
+   .priv_auto_alloc_size   = sizeof(struct imx6q_clk_priv),
+   .ofdata_to_platdata = imx6q_clk_ofdata_to_platdata,
+   .ops= &imx6q_clk_ops,
+   .probe  = imx6q_clk_probe,
+};
diff --git a/drivers/video/ipu_common.c b/drivers/video/ipu_common.c
index cbe1984e4f..9725f76477 100644
--- a/drivers/video/ipu_common.c
+++ b/drivers/video/ipu_common.c
@@ -86,6 +86,7 @@ struct ipu_ch_param {
 #define IPUV3_CLK_MX6Q 26400
 #define IPUV3_CLK_MX6DL19800
 
+#ifndef CONFIG_CLK
 void clk_enable(struct clk *clk)
 {
if (clk) {
@@ -104,6 +105,7 @@ void clk_disable(struct clk *clk)
}
}
 }
+#endif
 
 int clk_get_usecount(struct clk *clk)
 {
@@ -113,6 +115,7 @@ int clk_get_usecount(struct clk *clk)
return clk->usecount;
 }
 
+#ifndef CONFIG_CLK
 u32 clk_get_rate(struct clk *clk)
 {
if (!clk)
@@ -120,6 +123,7 @@ u32 clk_get_rate(struct clk *clk)
 
return clk->rate;
 }
+#endif

[U-Boot] [PATCH 1/8] clk: Kconfig: Ascending order to sub directiory kconfigs

2018-07-30 Thread Jagan Teki
sourcing of sub directiory kconfig files are not in
proper order, so keep them in ascending order.

Signed-off-by: Jagan Teki 
---
 drivers/clk/Kconfig | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 18bf8a6d28..a99abed9e9 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -83,13 +83,13 @@ config CLK_STM32MP1
  Enable the STM32 clock (RCC) driver. Enable support for
  manipulating STM32MP1's on-SoC clocks.
 
-source "drivers/clk/tegra/Kconfig"
-source "drivers/clk/uniphier/Kconfig"
-source "drivers/clk/exynos/Kconfig"
 source "drivers/clk/at91/Kconfig"
-source "drivers/clk/renesas/Kconfig"
+source "drivers/clk/exynos/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/owl/Kconfig"
+source "drivers/clk/renesas/Kconfig"
+source "drivers/clk/tegra/Kconfig"
+source "drivers/clk/uniphier/Kconfig"
 
 config ICS8N3QV01
bool "Enable ICS8N3QV01 VCXO driver"
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 8/8] configs: icorem6_rqs: Enable CLK_IMX

2018-07-30 Thread Jagan Teki
CLK support for imx6qdl is available, so enable
CLK_IMX for Engicam i.CoreM6 QDL RQS boards.

Signed-off-by: Jagan Teki 
---
 configs/imx6qdl_icore_rqs_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/imx6qdl_icore_rqs_defconfig 
b/configs/imx6qdl_icore_rqs_defconfig
index 0099717ee1..15ecc1664b 100644
--- a/configs/imx6qdl_icore_rqs_defconfig
+++ b/configs/imx6qdl_icore_rqs_defconfig
@@ -48,3 +48,4 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_MXC_UART=y
+CONFIG_CLK_IMX=y
-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 0/8] i.MX: Add initial CLK support

2018-07-30 Thread Jagan Teki
This is first version for previous RFC[1] and on top of 
fec_mxc series [2]

One of the blocking area where fec_mxc is unlikely
to move dm can be CLK support, this series trying
to add support for it and concentrated on ENET clocking
for i.MX6QDL and i.MX6UL.

Tested on i.MX6QDL

For i.MX6UL, need clearing gpr1[13] for fec1. any suggestion
how we can handle this in CLK driver?

Changes for v1:
- Set ENET_50MHZ directly from CLK diriver.

[2] https://patchwork.ozlabs.org/cover/950886/
[1] https://patchwork.ozlabs.org/cover/941549/

Jagan Teki (8):
  clk: Kconfig: Ascending order to sub directiory kconfigs
  clk: Add DM CLK driver template for i.MX6QDL
  clk: imx: imx6q: Implement ENET clocks
  clk: imx: imx6ul: Implement ENET clocks
  clk: Add generic_clk_valid
  net: fec_mxc: Add clock support via CLK
  imx6ul: engicam: Enable CLK_IMX
  configs: icorem6_rqs: Enable CLK_IMX

 arch/arm/mach-imx/mx6/Kconfig   |  1 +
 configs/imx6qdl_icore_rqs_defconfig |  1 +
 drivers/clk/Kconfig |  9 +--
 drivers/clk/Makefile|  1 +
 drivers/clk/imx/Kconfig | 25 
 drivers/clk/imx/Makefile|  8 +++
 drivers/clk/imx/clk_imx6q.c | 86 +++
 drivers/clk/imx/clk_imx6ul.c| 92 +
 drivers/net/fec_mxc.c   | 58 +-
 drivers/net/fec_mxc.h   |  5 ++
 drivers/video/ipu_common.c  |  8 +++
 include/clk-uclass.h| 10 
 12 files changed, 299 insertions(+), 5 deletions(-)
 create mode 100644 drivers/clk/imx/Kconfig
 create mode 100644 drivers/clk/imx/Makefile
 create mode 100644 drivers/clk/imx/clk_imx6q.c
 create mode 100644 drivers/clk/imx/clk_imx6ul.c

-- 
2.18.0.321.gffc6fa0e3

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


[U-Boot] [PATCH 7/8] imx6ul: engicam: Enable CLK_IMX

2018-07-30 Thread Jagan Teki
CLK support for imx6ul is available, so enable
CLK_IMX for Engicam i.MX6UL boards.

Signed-off-by: Jagan Teki 
---
 arch/arm/mach-imx/mx6/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 521fad74b5..388d2a2069 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -337,6 +337,7 @@ config TARGET_MX6UL_ENGICAM
select BOARD_LATE_INIT
select MX6UL
select OF_CONTROL
+   select CLK_IMX
select DM
select DM_ETH
select DM_GPIO
-- 
2.18.0.321.gffc6fa0e3

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


Re: [U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Simon Goldschmidt



On 30.07.2018 14:36, Wolfgang Denk wrote:

Dear Simon,

In message <6bce9049-a812-d8e4-cd2a-4b86dccae...@de.pepperl-fuchs.com> you 
wrote:


However, uncompression currently is only implemented for kernels, not
for other sub-images. This patch aims at updating the docs and the
current .its examples to what they do now.


Yes, but the current state should IMO not been taken as reference.
I don't have time ATM to achtually check with older versions, but
I'm pretty sure that that was handled correctly in the original FIT
implementation, and the examples made sense at the time they were
being written.  I suspect that later changes broke the code, so only
the code needs to be fixed.

In general for the image handling there should be no distinction at
all whether this is a kernel or ramdisk or FPGA or whatever image -
compression is a feature independent of the image type, and that's
how the code should handle it.


OK, so at least we all seem to have a common sense of how it should be :-)

I'd still argue that the standard example in 'multi.its' should have 
compression = "none" for the ramdisks.


Best regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] doc: FIT image: clarify usage of "compression" property

2018-07-30 Thread Simon Goldschmidt



On 30.07.2018 14:44, Wolfgang Denk wrote:

Dear Simon,

In message <642b8dae-f941-5255-42c7-3761e12d0...@de.pepperl-fuchs.com> you 
wrote:


As I'm not that long with U-Boot, can you point me to a rough date of a
release that I could check to see if it worked at that time?


I can only speculate...  The first bigger rework of the cose appears
to be this patch series:

30864 859e92b775   2013-05-14 15:37:25 -0400   image: Move timestamp #ifdefs to 
header file
30863 61a439a873   2013-05-14 15:37:25 -0400   image: Export fit_check_ramdisk()
30862 53fbb7e885   2013-05-14 15:37:25 -0400   image: Split FIT code into new 
image-fit.c
30861 604f23dde0   2013-05-14 15:37:25 -0400   image: Move HOSTCC image code to 
tools/
30860 94e5fa46a0   2013-05-14 15:37:25 -0400   image: Split hash node 
processing into its own function
30859 b7260910dc   2013-05-14 15:37:25 -0400   image: Convert 
fit_image_hash_set_value() to static, and rename
30858 b8da836650   2013-05-14 15:37:25 -0400   image: Rename 
fit_image_check_hashes() to fit_image_verify()
30857 ab9efc665a   2013-05-14 15:37:25 -0400   image: Move hash checking into 
its own function
30856 e754da2aee   2013-05-14 15:37:25 -0400   image: Move error! string to 
common place
30855 003efd7da4   2013-05-14 15:37:25 -0400   image: Export 
fit_conf_get_prop_node()
30854 bbb467dc3c   2013-05-14 15:37:25 -0400   image: Rename fit_add_hashes() 
to fit_add_verification_data()
30853 d8b75360ee   2013-05-14 15:37:25 -0400   image: Rename hash printing to 
fit_image_print_verification_dat  a()
30852 35e7b0f179   2013-05-14 15:37:25 -0400   sandbox: image: Add support for 
booting images in sandbox
30851 aa6d6db4d4   2013-05-14 15:37:25 -0400   mkimage: Put FIT loading in 
function and tidy error handling
30850 1fe7d93891   2013-05-14 15:37:25 -0400   image: Remove remaining #ifdefs 
in image-fit.c
30849 87ebee39e9   2013-05-14 15:37:25 -0400   image: Add CONFIG_FIT_SPL_PRINT 
to control FIT image printing i  n SPL
30848 44d3a3066b   2013-05-14 15:37:25 -0400   image: Split libfdt code into 
image-fdt.c
30847 13d06981a9   2013-05-14 15:37:25 -0400   image: Add device tree setup to 
image library
30846 c19d13b030   2013-05-14 15:37:25 -0400   arm: Refactor bootm to reduce 
#ifdefs
30845 6caa195614   2013-05-14 15:37:25 -0400   arm: Use image_setup_linux() 
instead of local code
30844 3e51266a4e   2013-05-14 15:37:25 -0400   powerpc: Use image_setup_linux() 
instead of local code
30843 24507cf50a   2013-05-14 15:37:26 -0400   m68k: Use image_setup_linux() 
instead of local code
30842 2a08b740e3   2013-05-14 15:37:26 -0400   sparc: Use image_setup_linux() 
instead of local code

But there have been earlier changes, and many later (heavy) reworks,
too.


I have checked starting with v1.3.3 (i.e. v2008.05) and even then, the 
compression property has only been handled for kernels. It seems like 
only the kernel has been loaded from FIT back then...


Next I checked v2009.01, where FDT and ramdisk are loaded from FIT, too. 
There is even a check that FDT is uncompressed. For ramdisk, the 
compression property is not checked.


Reading that, I tend to think uncompression has always been like it is now.

Best Regards,
Simon



Best regards,

Wolfgang Denk


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


Re: [U-Boot] [PATCH] video: kconfig: remove DM_I2C dependency of I2C_EDID

2018-07-30 Thread Luis Araneda
Hi,

On Wed, Jul 4, 2018 at 2:40 AM Luis Araneda  wrote:
>
> Drop the DM_I2C dependency, as the library only implements
> the parsing of EDID data and doesn't depend on any driver
>
> One user of this library, the i2c command, implements
> support for legacy and DM I2C drivers
>
> Tested on a Zynq board, whose I2C driver is not ported
> yet to DM
>
> Signed-off-by: Luis Araneda 
> ---
>  drivers/video/Kconfig | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 5ee9032dc9..a2d7e10938 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -410,7 +410,6 @@ config VIDEO_MVEBU
>
>  config I2C_EDID
> bool "Enable EDID library"
> -   depends on DM_I2C
> default n
> help
>This enables library for accessing EDID data from an LCD panel.

Ping, can I get this reviewed please, and merged if it's ok.
I'm moving some legacy board config options to kconfig and some of
them depend on removing this dependency.

Thanks,

Luis Araneda.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Wolfgang Denk
Dear Simon,

In message <0787afb7-2da1-4eaa-437e-6f7c75828...@de.pepperl-fuchs.com> you 
wrote:
> 
> I'd still argue that the standard example in 'multi.its' should have 
> compression = "none" for the ramdisks.

OK, this is your position then.  I can only explain where we are
coming from: in the early days of U-Boot (well, PPCBoot by then)
resources were much tighter than today - look at the examples in the
README: a v2.4.4 Linux kernel image would be around 780 kB
uncompressed or 330 kB compressed.  At this time it was considered a
waste of resources to have the gzip uncompression code in the boot
loader and again duplicated in the Linux kernel - so it was omitted
there and U-Boot would do all uncompression, also of the ramdisks.
I agree this is not standard any more, but it is still a valid use
case, I think.  I know, I'm an old man ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Brain: an apparatus with which we think we think.- Ambrose Bierce
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] common: Generic loader for file system

2018-07-30 Thread Simon Glass
Hi,

On 27 July 2018 at 02:40, Chee, Tien Fong  wrote:
>
> On Thu, 2018-07-26 at 11:03 +0200, Michal Simek wrote:
> > On 25.7.2018 18:03, Tom Rini wrote:
> > >
> > > On Wed, Jul 25, 2018 at 09:47:17AM -0600, Simon Glass wrote:
> > > >
> > > > Hi,
> > > >
> > > > On 25 July 2018 at 03:48, Michal Simek 
> > > > wrote:
> > > > >
> > > > >
> > > > > On 25.7.2018 08:31, Chee, Tien Fong wrote:
> > > > > >
> > > > > > On Wed, 2018-07-18 at 16:48 +0200, Michal Simek wrote:
> > > > > > >
> > > > > > > On 6.7.2018 10:28, tien.fong.c...@intel.com wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > From: Tien Fong Chee 
> > > > > > > >
> > > > [...]
> > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Also that DT binding is quite weird and I don't think you
> > > > > > > will get
> > > > > > > ACK
> > > > > > > for this from device tree community at all. I think that
> > > > > > > calling via
> > > > > > > platdata and avoid DT nodes would be better way to go.
> > > > > > Why do you think DT binding is weird? The DT is designed
> > > > > > based on Simon
> > > > > > proposal, and i believe following the rules in DTS spec.
> > > > > > There are some DT benefits with current design, i think
> > > > > > someone may be
> > > > > > maintainer need to made the final decision on the design.
> > > > > It is software configuration in file which should mostly
> > > > > describe
> > > > > hardware and state for hardware configuration.
> > > > >
> > > > > Your fs_loader node is purely describe sw configuration which
> > > > > shouldn't
> > > > > be here.
> > > > > You have there run time configuration via variables. I think
> > > > > using only
> > > > > this way is enough. Default variables will match what you would
> > > > > want to
> > > > > add to DT.
> > > > I think DT makes sense in the U-Boot context.
> > > >
> > > > We don't have a user space to handle policy decisions, and the
> > > > 'chosen' node is a good place to configure these common features.
> > > >
> > > > While you can argue that the partition or filesystem where an
> > > > image
> > > > comes from is a software config, it is something that has to be
> > > > configured. It has impact on hardware too, since the FPGA has to
> > > > get
> > > > its firmware from somewhere. We use the chosen node to specify
> > > > the
> > > > UART to use, and this is no different. Again, we don't have user-
> > > > space
> > > > config files in U-Boot.
> > > >
> > > > This argument comes up from time to time and I'd really like to
> > > > put it
> > > > to bed for U-Boot. I understand that Linux has its own approach
> > > > and
> > > > rules, but in some cases they serve U-Boot poorly.
> > > I want to second this as well.  So long as we're using our prefix
> > > and
> > > we've thought through and discussed what we're trying to do here,
> > > it's
> > > OK to do things that might not be accepted for Linux.
> > >
> > I have not a problem with using chosen node with u-boot prefix
> > properties and my colleague hopefully with finish work about moving
> > u-boot,dm-pre-reloc; to chosen node where it should be (because
> > current
> > solution has also problem with ordering).
> >
> > In this loader case doc is saying that you can rewrite it with
> > variables
> > on the prompt (or via script).
> > For cases that you want to autodetect platform and pass/load correct
> > dtb
> > which setup u-boot this can be problematic and using DT is could be
> > considered as easier for use.
> >
> > In this case this is what was proposed:
> >
> > + fs_loader0: fs-loader@0 {
> > + u-boot,dm-pre-reloc;
> > + compatible = "u-boot,fs-loader";
> > + phandlepart = <&mmc 1>;
> > + };
> >
> > + fs_loader1: fs-loader@1 {
> > + u-boot,dm-pre-reloc;
> > + compatible = "u-boot,fs-loader";
> > + mtdpart = "UBI",
> > + ubivol = "ubi0";
> > + };
> >
> > u-boot,dm-pre-reloc; requires DM_FLAG_PRE_RELOC which is not setup
> > for
> > this driver - it means this should be here.
> You are right, i missed this one. The intention of design enables user
> to call any loader with default storage through the sequence number  if
> fs loader is not defined in chosen. For example, there is a case where
> system loading the file from SDMMC, NAND and QSPI.
> >
> > compatible = "u-boot,fs-loader"; - bind and probe are empty that's
> > why
> > this is only used for filling platdata but driver has no user that's
> > why
> > this is unused till someone calls that functions.
> >
> > phandlepart/mtdpart/ubivol is just for setup.
> There are some benefits with driver model:
> 1. Saving space, calling when need.
> 2. Handle memory allocation and deallocation automatically.
> >
> > For the first case you can just use in chosen node:
> > u-boot,fs-loader = <&mmc 1>;
> >
> > And for UBIfs. I have never played with that but I expect it
> > shouldn't
> > be big problem to describe it differently too (something like)
> > 

Re: [U-Boot] [PATCH 2/3] enable fpga loadfs

2018-07-30 Thread Simon Glass
Hi,

On 27 July 2018 at 02:57, Chee, Tien Fong  wrote:
> On Thu, 2018-07-26 at 10:10 +0200, Marek Vasut wrote:
>> On 07/26/2018 09:54 AM, tien.fong.c...@intel.com wrote:
>> >
>> > From: Tien Fong Chee 
>> >
>> > Signed-off-by: Tien Fong Chee 
>> > ---
>> >  arch/arm/dts/socfpga_arria10.dtsi|   12 
>> >  arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts |6 ++
>> >  configs/socfpga_arria10_defconfig|   12 
>> >  3 files changed, 30 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/arch/arm/dts/socfpga_arria10.dtsi
>> > b/arch/arm/dts/socfpga_arria10.dtsi
>> > index b51febd..45aef6a 100644
>> > --- a/arch/arm/dts/socfpga_arria10.dtsi
>> > +++ b/arch/arm/dts/socfpga_arria10.dtsi
>> > @@ -48,6 +48,12 @@
>> >   <0xc100 0x100>;
>> > };
>> >
>> > +   fs_loader0: fs-loader@0 {
>> > +   u-boot,dm-pre-reloc;
>> > +   compatible = "u-boot,fs-loader";
>> > +   phandlepart = <&mmc 1>;
>> Which hardware does this describe ?
>> DT is hardware description ...
> I agree with Simon, it still describes some hardware information
> required for this whole mechanism to work although this pointer is not
> represent a real hardware.

Right, I would like to drop the 'DT is a hardware description' meme
:-) See the other thread about this.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V2 1/4] power-domain: add dummy functions when CONFIG_POWER_DOMAIN not defined

2018-07-30 Thread Simon Glass
On 26 July 2018 at 20:20, Peng Fan  wrote:
> Add dummy functions when CONFIG_POWER_DOMAIN not defined.
>
> Signed-off-by: Peng Fan 
> ---
>
> V2: Use CONFIG_IS_ENABLED
>
>  include/power-domain.h | 28 
>  1 file changed, 28 insertions(+)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH V2 2/4] power: Add CONFIG_SPL_POWER_DOMAIN config

2018-07-30 Thread Simon Glass
On 26 July 2018 at 20:20, Peng Fan  wrote:
> Add CONFIG_SPL_POWER_DOMAIN config entry.
> Build drivers/power/domain if this config is selected.
>
> Signed-off-by: Peng Fan 
> Cc: Simon Glass 
> ---
>
> V2: New
>
>  common/spl/Kconfig| 9 +
>  drivers/Makefile  | 1 +
>  drivers/power/domain/Makefile | 2 +-
>  3 files changed, 11 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/4] gpio: xilinx: Find out bank before use in xilinx_gpio_get_function()

2018-07-30 Thread Stefan Herbrechtsmeier

Am 30.07.2018 um 14:34 schrieb Michal Simek:

Call xilinx_gpio_get_bank_pin() before use.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

  drivers/gpio/xilinx_gpio.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 48b52c985a55..8ce08d80f491 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -435,6 +435,10 @@ static int xilinx_gpio_get_function(struct udevice *dev, 
unsigned offset)
int val, ret;
u32 bank, pin;
  
+	ret = xilinx_gpio_get_bank_pin(offset, &bank, &pin, dev);

+   if (ret)
+   return ret;
+
/* Check if all pins are inputs */
if (platdata->bank_input[bank])
return GPIOF_INPUT;
@@ -443,10 +447,6 @@ static int xilinx_gpio_get_function(struct udevice *dev, 
unsigned offset)
if (platdata->bank_output[bank])
return GPIOF_OUTPUT;
  
-	ret = xilinx_gpio_get_bank_pin(offset, &bank, &pin, dev);

-   if (ret)
-   return ret;
-
/* FIXME test on dual */
val = readl(&platdata->regs->gpiodir + bank * 2);
val = !(val & (1 << pin));


Reviewed-by: Stefan Herbrechtsmeier 

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


Re: [U-Boot] [PATCH v4 6/6] common: Generic loader for file system

2018-07-30 Thread Michal Simek
On 30.7.2018 15:26, Simon Glass wrote:
> Hi,
> 
> On 27 July 2018 at 02:40, Chee, Tien Fong  wrote:
>>
>> On Thu, 2018-07-26 at 11:03 +0200, Michal Simek wrote:
>>> On 25.7.2018 18:03, Tom Rini wrote:

 On Wed, Jul 25, 2018 at 09:47:17AM -0600, Simon Glass wrote:
>
> Hi,
>
> On 25 July 2018 at 03:48, Michal Simek 
> wrote:
>>
>>
>> On 25.7.2018 08:31, Chee, Tien Fong wrote:
>>>
>>> On Wed, 2018-07-18 at 16:48 +0200, Michal Simek wrote:

 On 6.7.2018 10:28, tien.fong.c...@intel.com wrote:
>
>
> From: Tien Fong Chee 
>
> [...]
>
>>
>>>


 Also that DT binding is quite weird and I don't think you
 will get
 ACK
 for this from device tree community at all. I think that
 calling via
 platdata and avoid DT nodes would be better way to go.
>>> Why do you think DT binding is weird? The DT is designed
>>> based on Simon
>>> proposal, and i believe following the rules in DTS spec.
>>> There are some DT benefits with current design, i think
>>> someone may be
>>> maintainer need to made the final decision on the design.
>> It is software configuration in file which should mostly
>> describe
>> hardware and state for hardware configuration.
>>
>> Your fs_loader node is purely describe sw configuration which
>> shouldn't
>> be here.
>> You have there run time configuration via variables. I think
>> using only
>> this way is enough. Default variables will match what you would
>> want to
>> add to DT.
> I think DT makes sense in the U-Boot context.
>
> We don't have a user space to handle policy decisions, and the
> 'chosen' node is a good place to configure these common features.
>
> While you can argue that the partition or filesystem where an
> image
> comes from is a software config, it is something that has to be
> configured. It has impact on hardware too, since the FPGA has to
> get
> its firmware from somewhere. We use the chosen node to specify
> the
> UART to use, and this is no different. Again, we don't have user-
> space
> config files in U-Boot.
>
> This argument comes up from time to time and I'd really like to
> put it
> to bed for U-Boot. I understand that Linux has its own approach
> and
> rules, but in some cases they serve U-Boot poorly.
 I want to second this as well.  So long as we're using our prefix
 and
 we've thought through and discussed what we're trying to do here,
 it's
 OK to do things that might not be accepted for Linux.

>>> I have not a problem with using chosen node with u-boot prefix
>>> properties and my colleague hopefully with finish work about moving
>>> u-boot,dm-pre-reloc; to chosen node where it should be (because
>>> current
>>> solution has also problem with ordering).
>>>
>>> In this loader case doc is saying that you can rewrite it with
>>> variables
>>> on the prompt (or via script).
>>> For cases that you want to autodetect platform and pass/load correct
>>> dtb
>>> which setup u-boot this can be problematic and using DT is could be
>>> considered as easier for use.
>>>
>>> In this case this is what was proposed:
>>>
>>> + fs_loader0: fs-loader@0 {
>>> + u-boot,dm-pre-reloc;
>>> + compatible = "u-boot,fs-loader";
>>> + phandlepart = <&mmc 1>;
>>> + };
>>>
>>> + fs_loader1: fs-loader@1 {
>>> + u-boot,dm-pre-reloc;
>>> + compatible = "u-boot,fs-loader";
>>> + mtdpart = "UBI",
>>> + ubivol = "ubi0";
>>> + };
>>>
>>> u-boot,dm-pre-reloc; requires DM_FLAG_PRE_RELOC which is not setup
>>> for
>>> this driver - it means this should be here.
>> You are right, i missed this one. The intention of design enables user
>> to call any loader with default storage through the sequence number  if
>> fs loader is not defined in chosen. For example, there is a case where
>> system loading the file from SDMMC, NAND and QSPI.
>>>
>>> compatible = "u-boot,fs-loader"; - bind and probe are empty that's
>>> why
>>> this is only used for filling platdata but driver has no user that's
>>> why
>>> this is unused till someone calls that functions.
>>>
>>> phandlepart/mtdpart/ubivol is just for setup.
>> There are some benefits with driver model:
>> 1. Saving space, calling when need.
>> 2. Handle memory allocation and deallocation automatically.
>>>
>>> For the first case you can just use in chosen node:
>>> u-boot,fs-loader = <&mmc 1>;
>>>
>>> And for UBIfs. I have never played with that but I expect it
>>> shouldn't
>>> be big problem to describe it differently too (something like)
>>> u-boot,fs-loader = <0 ubi0>;
>> Need consider description for UBIFS, using fs-loader seems not working
>> for UBIFS, since more arguments such as mtdpartition and mtd v

Re: [U-Boot] [PATCH 2/2] FIT image: use compression = "none" for ramdisks

2018-07-30 Thread Simon Goldschmidt



On 30.07.2018 15:25, Wolfgang Denk wrote:

Dear Simon,

In message <0787afb7-2da1-4eaa-437e-6f7c75828...@de.pepperl-fuchs.com> you 
wrote:


I'd still argue that the standard example in 'multi.its' should have
compression = "none" for the ramdisks.


OK, this is your position then.  I can only explain where we are
coming from: in the early days of U-Boot (well, PPCBoot by then)
resources were much tighter than today - look at the examples in the
README: a v2.4.4 Linux kernel image would be around 780 kB
uncompressed or 330 kB compressed.  At this time it was considered a
waste of resources to have the gzip uncompression code in the boot
loader and again duplicated in the Linux kernel - so it was omitted
there and U-Boot would do all uncompression, also of the ramdisks.


Well, my point was that I couldn't see U-Boot ever handling this. But 
this discussion got a bit confused, split into two threads...



I agree this is not standard any more, but it is still a valid use
case, I think.  I know, I'm an old man ;-)


It *is* a valid use case. But for current kernels (if compression is 
enabled), it might be faster to let the kernel unzip the content 
directly to the memory location where it should reside in the end.


However, I don't have a strong opinion on these examples. I'll let the 
maintainers decide :-)



Best regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 4/4] gpio: xilinx: Simplify logic in xilinx_gpio_set_value

2018-07-30 Thread Stefan Herbrechtsmeier

Hi Michal,

Am 30.07.2018 um 14:34 schrieb Michal Simek:

There is no reason to do read/write for if/else separately.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

  drivers/gpio/xilinx_gpio.c | 13 ++---
  1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 1e5f3da8d7e8..cccfa7561739 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -61,18 +61,17 @@ static int xilinx_gpio_set_value(struct udevice *dev, 
unsigned offset,
if (ret)
return ret;
  
+	val = readl(&platdata->regs->gpiodata + bank * 2);

+
debug("%s: regs: %lx, value: %x, gpio: %x, bank %x, pin %x\n",
  __func__, (ulong)platdata->regs, value, offset, bank, pin);
  
-	if (value) {

-   val = readl(&platdata->regs->gpiodata + bank * 2);
+   if (value)
val = val | (1 << pin);
-   writel(val, &platdata->regs->gpiodata + bank * 2);
-   } else {
-   val = readl(&platdata->regs->gpiodata + bank * 2);
+   else
val = val & ~(1 << pin);
-   writel(val, &platdata->regs->gpiodata + bank * 2);
-   }
+
+   writel(val, &platdata->regs->gpiodata + bank * 2);
  
  	return val;

  };


This doesn't work because you read the general purpose input ports 
(register) and write to the general purpose output ports (register). 
This leads to problems if an output only pin inside an bidirectional 
port has no connection between the two registers or the input and output 
registers has different values.


The value of the output register must be saved inside the driver.

Best regards
  Stefan



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


Re: [U-Boot] [PATCH 3/4] gpio: xilinx: Set value before changing direction

2018-07-30 Thread Stefan Herbrechtsmeier

Am 30.07.2018 um 14:34 schrieb Michal Simek:

Set a value before changing gpio direction. This will ensure that the
old value is not propagated when direction has changed but new value is
not written yet.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

  drivers/gpio/xilinx_gpio.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 776a147cc8d7..1e5f3da8d7e8 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -139,14 +139,14 @@ static int xilinx_gpio_direction_output(struct udevice 
*dev, unsigned offset,
if (platdata->bank_input[bank])
return -EINVAL;
  
+	xilinx_gpio_set_value(dev, offset, value);

+
if (!platdata->bank_output[bank]) {
val = readl(&platdata->regs->gpiodir + bank * 2);
val = val & ~(1 << pin);
writel(val, &platdata->regs->gpiodir + bank * 2);
}
  
-	xilinx_gpio_set_value(dev, offset, value);

-
return 0;
  }
  


Reviewed-by: Stefan Herbrechtsmeier 

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


Re: [U-Boot] [PATCH 3/4] gpio: xilinx: Not read output values via regs

2018-07-30 Thread Stefan Herbrechtsmeier

Am 30.07.2018 um 14:40 schrieb Michal Simek:

On 27.7.2018 10:41, Stefan Herbrechtsmeier wrote:

Am 27.07.2018 um 09:05 schrieb Michal Simek:

On 26.7.2018 21:46, Stefan Herbrechtsmeier wrote:

Am 26.07.2018 um 10:41 schrieb Michal Simek:

On 25.7.2018 20:21, Stefan Herbrechtsmeier wrote:

Am 25.07.2018 um 08:39 schrieb Michal Simek:

On 24.7.2018 21:56, Stefan Herbrechtsmeier wrote:

Am 24.07.2018 um 12:31 schrieb Michal Simek:

On 23.7.2018 20:42, Stefan Herbrechtsmeier wrote:

Am 23.07.2018 um 13:43 schrieb Michal Simek:

Reading registers for finding out output value is not working
because
input value is read instead in case of tristate.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

   drivers/gpio/xilinx_gpio.c | 38
+-
   1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c
b/drivers/gpio/xilinx_gpio.c
index 4da9ae114d87..9d3e9379d0e5 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c

[snip]


   +    priv->output_val[bank] = val;
+
   return val;
   };
   @@ -441,6 +449,7 @@ static int
xilinx_gpio_get_function(struct
udevice *dev, unsigned offset)
   static int xilinx_gpio_get_value(struct udevice *dev,
unsigned
offset)
   {
   struct xilinx_gpio_platdata *platdata =
dev_get_platdata(dev);
+    struct xilinx_gpio_privdata *priv = dev_get_priv(dev);
   int val, ret;
   u32 bank, pin;
   @@ -451,7 +460,14 @@ static int
xilinx_gpio_get_value(struct
udevice
*dev, unsigned offset)
   debug("%s: regs: %lx, gpio: %x, bank %x, pin %x\n",
__func__,
     (ulong)platdata->regs, offset, bank, pin);
   -    val = readl(&platdata->regs->gpiodata + bank * 2);
+    if (xilinx_gpio_get_function(dev, offset) == GPIOF_INPUT) {
+    debug("%s: Read input value from reg\n", __func__);
+    val = readl(&platdata->regs->gpiodata + bank * 2);
+    } else {
+    debug("%s: Read saved output value\n", __func__);
+    val = priv->output_val[bank];
+    }

Why you don't always read the data register? This doesn't work for
three
state outputs.

In three state register every bit/pin is 0 - output, 1 input.
It means else part is output and I read saved value in
priv->output_val.
If pin is setup as INPUT then I need read data reg to find out
input
value.
Maybe you are commenting something else but please let me know if
there
is any other bug.

What happen if I have an open drain output. Even if the gpio output
is 1
the input could read a 0. You driver will always return the output
value
and not the real input value. According to the picture in
documentation
and my tests a data register write writes the output registers and a
data register read reads the input registers.

Why should the driver return the desired state (output register)
and not
the real state (input register)?

First of all thanks for description.

I have another example where you have output only and you can't read
input because there is no wire.

Does you mean the all outputs configuration? Does this removes the
"gpio_io_i" signal from the IP?

I am not sure what synthesis is doing with that unused IP pins but I
would consider as a bug if this is automatically connected together.

I mean does the IP generator removes the gpio_io_i signal because it
isn't needed? If the IP generator creates the gpio_io_i signal I would
expect that you can't leave it unconnected as this would lead to
undefined values.

Normally when you know that you have output only there is no no
gpio_io_i or tristate signal. The same for input only.

And in this case the device tree flags "xlnx,all-inputs" or
"xlnx,all-outputs" should be set.

yes.


    And
also wasting a logic if there is unused part.
But in Vivado you should be able to setup output pins to and input pins
separately. There are In/Out/Tristate.
If you don't want to deal with external pin you can connect them
inside PL.

This isn't my point. I mean that if you have an gpio_io_i signal you
have to connected it to a signal. You could connect it to the output of
an IO, to the gpio_io_o signal or to fixed value (0 or 1). If you
connect it to a fixed value (0 or 1) you get this value if you read the
status of this GPIO.

Not a HW to tell you what's vivado is going to do with that. But you can
select that ouput/input only where these signals are out.

You mean the all-inputs or all-outputs case.

yes.


Regarding open drain output.

Also this is what it is written in manual:
"AXI GPIO Data Register Description"
"For each I/O bit programmed as output:
• R: Reads to these bits always return zeros"

This must be a mistake in the documentation. I could read the input
value.

The old driver and the Linux driver always read the register.

In old u-boot driver I see
    179 if (gpio_get_direction(gpio) == GPIO_DIRECTION_OUT)
    180 val = gpio_get_output_value(gpio);
    181 else
    182  

Re: [U-Boot] [PATCH 4/4] gpio: xilinx: Simplify logic in xilinx_gpio_set_value

2018-07-30 Thread Michal Simek
On 30.7.2018 15:31, Stefan Herbrechtsmeier wrote:
> Hi Michal,
> 
> Am 30.07.2018 um 14:34 schrieb Michal Simek:
>> There is no reason to do read/write for if/else separately.
>>
>> Reported-by: Stefan Herbrechtsmeier 
>> Signed-off-by: Michal Simek 
>> ---
>>
>>   drivers/gpio/xilinx_gpio.c | 13 ++---
>>   1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
>> index 1e5f3da8d7e8..cccfa7561739 100644
>> --- a/drivers/gpio/xilinx_gpio.c
>> +++ b/drivers/gpio/xilinx_gpio.c
>> @@ -61,18 +61,17 @@ static int xilinx_gpio_set_value(struct udevice
>> *dev, unsigned offset,
>>   if (ret)
>>   return ret;
>>   +    val = readl(&platdata->regs->gpiodata + bank * 2);
>> +
>>   debug("%s: regs: %lx, value: %x, gpio: %x, bank %x, pin %x\n",
>>     __func__, (ulong)platdata->regs, value, offset, bank, pin);
>>   -    if (value) {
>> -    val = readl(&platdata->regs->gpiodata + bank * 2);
>> +    if (value)
>>   val = val | (1 << pin);
>> -    writel(val, &platdata->regs->gpiodata + bank * 2);
>> -    } else {
>> -    val = readl(&platdata->regs->gpiodata + bank * 2);
>> +    else
>>   val = val & ~(1 << pin);
>> -    writel(val, &platdata->regs->gpiodata + bank * 2);
>> -    }
>> +
>> +    writel(val, &platdata->regs->gpiodata + bank * 2);
>>     return val;
>>   };
> 
> This doesn't work because you read the general purpose input ports
> (register) and write to the general purpose output ports (register).
> This leads to problems if an output only pin inside an bidirectional
> port has no connection between the two registers or the input and output
> registers has different values.
> 
> The value of the output register must be saved inside the driver.

This is only simplifying logic not doing changes which we are talking
about in separate thread.
Your comment is how to get that initial value.

Thanks,
Michal

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


Re: [U-Boot] [PATCH 4/4] gpio: xilinx: Simplify logic in xilinx_gpio_set_value

2018-07-30 Thread Stefan Herbrechtsmeier

Am 30.07.2018 um 15:42 schrieb Michal Simek:

On 30.7.2018 15:31, Stefan Herbrechtsmeier wrote:

Hi Michal,

Am 30.07.2018 um 14:34 schrieb Michal Simek:

There is no reason to do read/write for if/else separately.

Reported-by: Stefan Herbrechtsmeier 
Signed-off-by: Michal Simek 
---

   drivers/gpio/xilinx_gpio.c | 13 ++---
   1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 1e5f3da8d7e8..cccfa7561739 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -61,18 +61,17 @@ static int xilinx_gpio_set_value(struct udevice
*dev, unsigned offset,
   if (ret)
   return ret;
   +    val = readl(&platdata->regs->gpiodata + bank * 2);
+
   debug("%s: regs: %lx, value: %x, gpio: %x, bank %x, pin %x\n",
     __func__, (ulong)platdata->regs, value, offset, bank, pin);
   -    if (value) {
-    val = readl(&platdata->regs->gpiodata + bank * 2);
+    if (value)
   val = val | (1 << pin);
-    writel(val, &platdata->regs->gpiodata + bank * 2);
-    } else {
-    val = readl(&platdata->regs->gpiodata + bank * 2);
+    else
   val = val & ~(1 << pin);
-    writel(val, &platdata->regs->gpiodata + bank * 2);
-    }
+
+    writel(val, &platdata->regs->gpiodata + bank * 2);
     return val;
   };

This doesn't work because you read the general purpose input ports
(register) and write to the general purpose output ports (register).
This leads to problems if an output only pin inside an bidirectional
port has no connection between the two registers or the input and output
registers has different values.

The value of the output register must be saved inside the driver.

This is only simplifying logic not doing changes which we are talking
about in separate thread.
Your comment is how to get that initial value.


Okay. In this case:

Reviewed-by: Stefan Herbrechtsmeier 

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


Re: [U-Boot] [PATCH v5 8/8] armv8: ls1046a: setup SEC ICIDs and fix up device tree

2018-07-30 Thread Laurentiu Tudor
Hello,

On 27.07.2018 17:00, Horia Geanta wrote:
> On 7/27/2018 2:18 PM, Bharat Bhushan wrote:
>>
>>
>>> -Original Message-
>>> From: laurentiu.tu...@nxp.com [mailto:laurentiu.tu...@nxp.com]
>>> Sent: Friday, July 27, 2018 3:28 PM
>>> To: u-boot@lists.denx.de; Prabhakar Kushwaha
>>> ; York Sun 
>>> Cc: Bharat Bhushan ; Horia Geanta
>>> ; Laurentiu Tudor 
>>> Subject: [PATCH v5 8/8] armv8: ls1046a: setup SEC ICIDs and fix up device
>>> tree
>>>
>>> From: Laurentiu Tudor 
>>>
>>> Add support for SEC ICID configuration and apply it for ls1046a.
>>> Also add code to make the necessary device tree fixups.
>>>
>>> Signed-off-by: Laurentiu Tudor 
>>> ---
>>>   .../arm/cpu/armv8/fsl-layerscape/ls1046_ids.c | 14 +++
>>>   .../asm/arch-fsl-layerscape/fsl_icid.h| 25 +++
>>>   .../asm/arch-fsl-layerscape/immap_lsch2.h |  8 ++
>>>   3 files changed, 47 insertions(+)
>>>
>>> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
>>> b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
>>> index 30c7d8d28a..bc2fe283a1 100644
>>> --- a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
>>> +++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
>>> @@ -40,6 +40,20 @@ struct icid_id_table icid_tbl[] = {
>>> SET_EDMA_ICID(FSL_EDMA_STREAM_ID),
>>> SET_ETR_ICID(FSL_ETR_STREAM_ID),
>>> SET_DEBUG_ICID(FSL_DEBUG_STREAM_ID),
>>> +#ifdef CONFIG_FSL_CAAM
>>> +   SET_SEC_QI_ICID(FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_JR_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 3),
>>> +   SET_SEC_JR_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 4),
>>> +   SET_SEC_JR_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 5),
>>> +   SET_SEC_JR_ICID_ENTRY(3, FSL_DPAA1_STREAM_ID_START + 6),
>>> +   SET_SEC_RTIC_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_RTIC_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_RTIC_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_RTIC_ICID_ENTRY(3, FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_DECO_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_DECO_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 2),
>>> +   SET_SEC_DECO_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 2),
>>
>> Here goes my understanding:
>>
>> RTIC are independent device from JR and QI, So they should be assigned 
>> different unique steam-id. Also each RTIC are independent device, so each 
>> RTIC can also be assigned separate stream-id.
>> While we can decide to use one stream-id for all RITCs and add a comment 
>> that they are not partitionable.
>>
>> DECOs can take work from QI or JRs, and in that case they will use the 
>> stream-id of the respective QI or JR, and the stream-id programmed in DECOs 
>> is not used.
>> While DECOs can be used directly (not via JR and QI) and in that case it 
>> will use the strema-id programmed in it. So in this case also we should be 
>> using unique stream-id for each DECO if partitionable or one for all DECOs
>>
> Considering the HW offers the mechanism to program the ICIDs (and assuming the
> HW is correctly designed), it follows that these HW blocks could be used
> independently.
> 
> The only way to implement a *mechanism* is to provide different ICIDs for all
> the blocks.
> Any other solution would be imposing a *policy*, thus restricting user's
> possibilities. Admittedly there are use cases less "popular" than others, but 
> if
> possible it would be best not to decide for the user and provide full 
> flexibility.
> 
> Is there a resource (ICID values) shortage?
> 

No. I can change the patch to have distinct ICIDs and resubmit. Please 
let me know if you agree on this.

---
Best Regards, Laurentiu
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: socfpga: Convert to DM serial

2018-07-30 Thread Simon Goldschmidt



On 12.05.2018 22:28, Marek Vasut wrote:

Pull the serial port configuration from DT and use DM serial instead
of having the serial configuration in two places, DT and board config.

Signed-off-by: Marek Vasut 
Cc: Chin Liang See 
Cc: Dinh Nguyen 
---
  arch/arm/Kconfig | 3 +++
  arch/arm/dts/socfpga.dtsi| 2 ++
  arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts | 1 +
  include/configs/socfpga_common.h | 8 
  4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 532aa41a87..2012ac6410 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -737,6 +737,7 @@ config ARCH_SOCFPGA
select ARCH_MISC_INIT
select CPU_V7A
select DM
+   select DM_SERIAL
select ENABLE_ARM_SOC_BOOT0_HOOK
select OF_CONTROL
select SPL_LIBCOMMON_SUPPORT
@@ -746,11 +747,13 @@ config ARCH_SOCFPGA
select SPL_NAND_SUPPORT if SPL_NAND_DENALI
select SPL_OF_CONTROL
select SPL_SERIAL_SUPPORT
+   select SPL_DM_SERIAL
select SPL_SPI_FLASH_SUPPORT if SPL_SPI_SUPPORT
select SPL_SPI_SUPPORT if DM_SPI
select SPL_WATCHDOG_SUPPORT
select SUPPORT_SPL
select SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
+   select SYS_NS16550
select SYS_THUMB_BUILD
imply CMD_MTDPARTS
imply CRC32_VERIFY
diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi
index e64127fcb2..314449478d 100644
--- a/arch/arm/dts/socfpga.dtsi
+++ b/arch/arm/dts/socfpga.dtsi
@@ -737,6 +737,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&l4_sp_clk>;
+   clock-frequency = <1>;
};
  
  		uart1: serial1@ffc03000 {

@@ -746,6 +747,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&l4_sp_clk>;
+   clock-frequency = <1>;
};
  
  		rst: rstmgr@ffd05000 {

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index b573d0e658..06b61cb0af 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -24,6 +24,7 @@
  };
  
  &uart1 {

+   clock-frequency = <5000>;
u-boot,dm-pre-reloc;
status = "okay";
  };
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 54b9edc97c..a60da85499 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -173,14 +173,6 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
   * Serial Driver
   */
  #define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE-4
-#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
-#define CONFIG_SYS_NS16550_COM1SOCFPGA_UART0_ADDRESS
-#define CONFIG_SYS_NS16550_CLK 1
-#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
-#define CONFIG_SYS_NS16550_COM1SOCFPGA_UART1_ADDRESS
-#define CONFIG_SYS_NS16550_CLK 5000
-#endif
  
  /*

   * USB



Unfortunately I saw this just now, but it seems this breaks GEN5 SPL? At 
least git-bisect told me that 73172753f4f3351ed1c9d2f6586fc599ce4e728c 
is the first bad commit.


I tested socfpga_socrates_defconfig on my socrates board.

Any idea what's wrong there?

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: socfpga: Convert to DM serial

2018-07-30 Thread Marek Vasut
On 07/30/2018 04:03 PM, Simon Goldschmidt wrote:
> 
> 
> On 12.05.2018 22:28, Marek Vasut wrote:
>> Pull the serial port configuration from DT and use DM serial instead
>> of having the serial configuration in two places, DT and board config.
>>
>> Signed-off-by: Marek Vasut 
>> Cc: Chin Liang See 
>> Cc: Dinh Nguyen 
>> ---
>>   arch/arm/Kconfig | 3 +++
>>   arch/arm/dts/socfpga.dtsi    | 2 ++
>>   arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts | 1 +
>>   include/configs/socfpga_common.h | 8 
>>   4 files changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 532aa41a87..2012ac6410 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -737,6 +737,7 @@ config ARCH_SOCFPGA
>>   select ARCH_MISC_INIT
>>   select CPU_V7A
>>   select DM
>> +    select DM_SERIAL
>>   select ENABLE_ARM_SOC_BOOT0_HOOK
>>   select OF_CONTROL
>>   select SPL_LIBCOMMON_SUPPORT
>> @@ -746,11 +747,13 @@ config ARCH_SOCFPGA
>>   select SPL_NAND_SUPPORT if SPL_NAND_DENALI
>>   select SPL_OF_CONTROL
>>   select SPL_SERIAL_SUPPORT
>> +    select SPL_DM_SERIAL
>>   select SPL_SPI_FLASH_SUPPORT if SPL_SPI_SUPPORT
>>   select SPL_SPI_SUPPORT if DM_SPI
>>   select SPL_WATCHDOG_SUPPORT
>>   select SUPPORT_SPL
>>   select SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
>> +    select SYS_NS16550
>>   select SYS_THUMB_BUILD
>>   imply CMD_MTDPARTS
>>   imply CRC32_VERIFY
>> diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi
>> index e64127fcb2..314449478d 100644
>> --- a/arch/arm/dts/socfpga.dtsi
>> +++ b/arch/arm/dts/socfpga.dtsi
>> @@ -737,6 +737,7 @@
>>   reg-shift = <2>;
>>   reg-io-width = <4>;
>>   clocks = <&l4_sp_clk>;
>> +    clock-frequency = <1>;
>>   };
>>     uart1: serial1@ffc03000 {
>> @@ -746,6 +747,7 @@
>>   reg-shift = <2>;
>>   reg-io-width = <4>;
>>   clocks = <&l4_sp_clk>;
>> +    clock-frequency = <1>;
>>   };
>>     rst: rstmgr@ffd05000 {
>> diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
>> b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
>> index b573d0e658..06b61cb0af 100644
>> --- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
>> +++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
>> @@ -24,6 +24,7 @@
>>   };
>>     &uart1 {
>> +    clock-frequency = <5000>;
>>   u-boot,dm-pre-reloc;
>>   status = "okay";
>>   };
>> diff --git a/include/configs/socfpga_common.h
>> b/include/configs/socfpga_common.h
>> index 54b9edc97c..a60da85499 100644
>> --- a/include/configs/socfpga_common.h
>> +++ b/include/configs/socfpga_common.h
>> @@ -173,14 +173,6 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
>>    * Serial Driver
>>    */
>>   #define CONFIG_SYS_NS16550_SERIAL
>> -#define CONFIG_SYS_NS16550_REG_SIZE    -4
>> -#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
>> -#define CONFIG_SYS_NS16550_COM1    SOCFPGA_UART0_ADDRESS
>> -#define CONFIG_SYS_NS16550_CLK    1
>> -#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
>> -#define CONFIG_SYS_NS16550_COM1    SOCFPGA_UART1_ADDRESS
>> -#define CONFIG_SYS_NS16550_CLK    5000
>> -#endif
>>     /*
>>    * USB
>>
> 
> Unfortunately I saw this just now, but it seems this breaks GEN5 SPL? At
> least git-bisect told me that 73172753f4f3351ed1c9d2f6586fc599ce4e728c
> is the first bad commit.
> 
> I tested socfpga_socrates_defconfig on my socrates board.
> 
> Any idea what's wrong there?

Nope, this should work fine. Can you investigate ?

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/4] gpio: xilinx: Not read output values via regs

2018-07-30 Thread Michal Simek
On 30.7.2018 15:32, Stefan Herbrechtsmeier wrote:
> Am 30.07.2018 um 14:40 schrieb Michal Simek:
>> On 27.7.2018 10:41, Stefan Herbrechtsmeier wrote:
>>> Am 27.07.2018 um 09:05 schrieb Michal Simek:
 On 26.7.2018 21:46, Stefan Herbrechtsmeier wrote:
> Am 26.07.2018 um 10:41 schrieb Michal Simek:
>> On 25.7.2018 20:21, Stefan Herbrechtsmeier wrote:
>>> Am 25.07.2018 um 08:39 schrieb Michal Simek:
 On 24.7.2018 21:56, Stefan Herbrechtsmeier wrote:
> Am 24.07.2018 um 12:31 schrieb Michal Simek:
>> On 23.7.2018 20:42, Stefan Herbrechtsmeier wrote:
>>> Am 23.07.2018 um 13:43 schrieb Michal Simek:
 Reading registers for finding out output value is not working
 because
 input value is read instead in case of tristate.

 Reported-by: Stefan Herbrechtsmeier
 
 Signed-off-by: Michal Simek 
 ---

    drivers/gpio/xilinx_gpio.c | 38
 +-
    1 file changed, 33 insertions(+), 5 deletions(-)

 diff --git a/drivers/gpio/xilinx_gpio.c
 b/drivers/gpio/xilinx_gpio.c
 index 4da9ae114d87..9d3e9379d0e5 100644
 --- a/drivers/gpio/xilinx_gpio.c
 +++ b/drivers/gpio/xilinx_gpio.c
> [snip]
>
    +    priv->output_val[bank] = val;
 +
    return val;
    };
    @@ -441,6 +449,7 @@ static int
 xilinx_gpio_get_function(struct
 udevice *dev, unsigned offset)
    static int xilinx_gpio_get_value(struct udevice *dev,
 unsigned
 offset)
    {
    struct xilinx_gpio_platdata *platdata =
 dev_get_platdata(dev);
 +    struct xilinx_gpio_privdata *priv = dev_get_priv(dev);
    int val, ret;
    u32 bank, pin;
    @@ -451,7 +460,14 @@ static int
 xilinx_gpio_get_value(struct
 udevice
 *dev, unsigned offset)
    debug("%s: regs: %lx, gpio: %x, bank %x, pin %x\n",
 __func__,
  (ulong)platdata->regs, offset, bank, pin);
    -    val = readl(&platdata->regs->gpiodata + bank * 2);
 +    if (xilinx_gpio_get_function(dev, offset) ==
 GPIOF_INPUT) {
 +    debug("%s: Read input value from reg\n", __func__);
 +    val = readl(&platdata->regs->gpiodata + bank * 2);
 +    } else {
 +    debug("%s: Read saved output value\n", __func__);
 +    val = priv->output_val[bank];
 +    }
>>> Why you don't always read the data register? This doesn't
>>> work for
>>> three
>>> state outputs.
>> In three state register every bit/pin is 0 - output, 1 input.
>> It means else part is output and I read saved value in
>> priv->output_val.
>> If pin is setup as INPUT then I need read data reg to find out
>> input
>> value.
>> Maybe you are commenting something else but please let me know if
>> there
>> is any other bug.
> What happen if I have an open drain output. Even if the gpio
> output
> is 1
> the input could read a 0. You driver will always return the output
> value
> and not the real input value. According to the picture in
> documentation
> and my tests a data register write writes the output registers
> and a
> data register read reads the input registers.
>
> Why should the driver return the desired state (output register)
> and not
> the real state (input register)?
 First of all thanks for description.

 I have another example where you have output only and you can't
 read
 input because there is no wire.
>>> Does you mean the all outputs configuration? Does this removes the
>>> "gpio_io_i" signal from the IP?
>> I am not sure what synthesis is doing with that unused IP pins but I
>> would consider as a bug if this is automatically connected together.
> I mean does the IP generator removes the gpio_io_i signal because it
> isn't needed? If the IP generator creates the gpio_io_i signal I would
> expect that you can't leave it unconnected as this would lead to
> undefined values.
 Normally when you know that you have output only there is no no
 gpio_io_i or tristate signal. The same for input only.
>>> And in this case the device tree flags "xlnx,all-inputs" or
>>> "xlnx,all-outputs" should be set.
>> yes.
>>
>>     And
>> also wasting a logic if there is unused part.
>

Re: [U-Boot] [PATCH v5 8/8] armv8: ls1046a: setup SEC ICIDs and fix up device tree

2018-07-30 Thread Horia Geanta
On 7/30/2018 4:58 PM, Laurentiu Tudor wrote:
>> The only way to implement a *mechanism* is to provide different ICIDs for all
>> the blocks.
>> Any other solution would be imposing a *policy*, thus restricting user's
>> possibilities. Admittedly there are use cases less "popular" than others, 
>> but if
>> possible it would be best not to decide for the user and provide full 
>> flexibility.
>>
>> Is there a resource (ICID values) shortage?
>>
> No. I can change the patch to have distinct ICIDs and resubmit. Please 
> let me know if you agree on this.
> 
Yes, this is my suggestion.
IIUC it's also similar to the way LIODNs are allocated on PPC.
True, LS102x is the exception - it assigns ICID 0x10 to all SEC blocks.

Regards,
Horia
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/1] README: U_BOOT_ENV_CALLBACK functions

2018-07-30 Thread Sam Protsenko
Hi Heinrich,

On Sun, Jul 29, 2018 at 12:08 PM, Heinrich Schuchardt
 wrote:
> Describe the interface of environment variable callback functions.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  README | 11 +++
>  1 file changed, 11 insertions(+)
>
> diff --git a/README b/README
> index aee0f7371c4..179d6d74a4a 100644
> --- a/README
> +++ b/README
> @@ -3943,6 +3943,17 @@ If CONFIG_REGEX is defined, the variable_name above is 
> evaluated as a
>  regular expression. This allows multiple variables to be connected to
>  the same callback without explicitly listing them all out.
>
> +The signature of the callback functions is:
> +
> +int callback(const char *name, const char *value, enum env_op op, int 
> flags)
> +
> +* name - changed environment variable
> +* value - new value of the environment variable
> +* op - operation (create, overwrite, or delete)
> +* flags - attributes of the environment variable change, see flags H_* in
> +  include/search.h
> +
> +The return value is 0 if the variable change is accepted and 1 otherwise.
>

This description looks more like Doxygen comment to me than a
documentation. So I wonder if it makes sense to move it into "struct
env_clbk_tbl" (include/env_callback.h), as Doxygen comment for
(*callback) field documentation. Or e.g. extract callback type from
that struct (use "typedef callback_t" or something), and document it
instead. Then a reference to that doc can be added to
U_BOOT_ENV_CALLBACK to make it easier for developers to find it while
coding.

The motivation is:
 1. Callback signature may change in future, and it's easy to forget
to update README accordingly. Hence it's better to keep function
documentation in code
 2. Developer is usually looks in code rather that to README while
coding, so it may be more helpful to keep function documentation in
code as well

Does it make sense?

Thanks.

>  Command Line Parsing:
>  =
> --
> 2.18.0
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v4 00/27] SPI-NAND support

2018-07-30 Thread Stefan Roese

Hi Miquel,
Hi Jagan,

On 26.07.2018 09:29, Miquel Raynal wrote:

Hi Jagan,

Jagan Teki  wrote on Thu, 26 Jul 2018
11:00:56 +0530:


On Fri, Jul 13, 2018 at 6:01 PM, Miquel Raynal
 wrote:

During the last months, Boris Brezillon shared his work to support
serial flashes within Linux. First, he delivered (and merged) a new
layer called spi-mem. He also initiated in Linux MTD subsystem the move
of all 'raw' NAND related code to a raw/ subdirectory, adding at the
same time a NAND core that would be shared with all NAND devices. Then,
he contributed a generic SPI-NAND driver, making use of this NAND core,
as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort
of MTD devices. This should become the default command instead of having
one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514),
featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:
  

setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
setenv mtdids spi-nand0=spi-nand0
mtdparts # show the spi-nand device partitions
ubi part bar # create a static UBI volume in the bar partition


Thanks,
Miquèl

Changes since v3:
-
* Fixed the debug messages in spi-mem to print either Rx or Tx data.
* Fixed a Kconfig error that prevented to build mtdparts with plain
   defconfig.
* Fixed a compilation error due to the above error that prevented one
   file to be compiled.
* Adapted the mtd command to probe MTD partitions also.
* Declared mtd_probe_devices() in a header so mtdparts or UBI could
   use it too (to probe all devices and MTD partitions in a clean way).
* As I worked on mtdparts, I found annoying and completely useless the
   fact that we need to prefix the environment variable with
   "mtdparts=". Canceled this obligation.
* Added one patch to allow spi-nand devices to be recognized by mtdparts
   (this is purely useless but needed to be done in order to use this
   command).
* Removed useless definitions of MTD device types in UBI code.
* Wrote a generic mtdparts environment variable parser, used by the mtd
   command.
* Used the mtd_probe_devices() function from get_mtd_info() in
   cmd/mtdparts.c to be sure the desired partition really does not exist
   (otherwise it will be probed and then found).

Changes since v2:
-
* Rebased on u-boot master branch.
* Removed extra-parenthesis in
   "mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing"
* s/fiels/files/ in "mtd: move NAND fiels into a raw/ subdirectory"
* Do not describe generic SPI device properties in SPI NAND bindings.
* Changes in the mtd command:
   * Printing more information in 'mtd list' (device type, device
 characteristics)
   * Switch to do_div() instead of '(u32)value64b % value32b' which only
 worked because value32b was a power of 2.
   * Removed erase.chip option.
   * By default, erase/read/write happen on the full MTD device while a
 dump will only work on a single page.

Changes since v1:
-
* Fixed the nand_memorg structure of the MX35LF2GE4AB chip.
* Added Reviewed-by tags from Jagan.
* Backported and squashed two patches fixing things in the SPI NAND core
   received on the Linux ML.
* Backported more changes in mtdcore.c from Linux.
* Added a patch to add a fallback on mtd->_read/_write() in mtdcore.c
   when mtd->_read/write_oob() is not supported.
* Removed the DT changes, useless as the DTs are not available in
   mainline yet.
* Addressed Boris/Stefan comments on the 'mtd' command.
* Added support for multi-pages OOB read/write.


Boris Brezillon (7):
   mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
   mtd: Add sanity checks in mtd_write/read_oob()
   mtd: nand: Add core infrastructure to deal with NAND devices
   mtd: nand: Pass mode information to nand_page_io_req
   spi: Extend the core to ease integration of SPI memory controllers
   mtd: spinand: Add initial support for the MX35LF1GE4AB chip
   dt-bindings: Add bindings for SPI NAND devices

Brian Norris (1):
   mtd: add get/set of_node/flash_node helpers

Ezequiel Garcia (1):
   mtd: Uninline mtd_write_oob and move it to mtdcore.c

Frieder Schrempf (1):
   mtd: spinand: Add initial support for Winbond W25M02GV

Miquel Raynal (15):
   mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing
   mtd: fix build issue with includes
   mtd: move definitions to enlarge their range
   mtd: move all flash categories inside MTD submenu
 

Re: [U-Boot] [PATCH v4 00/27] SPI-NAND support

2018-07-30 Thread Miquel Raynal
Hi Stefan, Tom,

Stefan Roese  wrote on Mon, 30 Jul 2018 17:11:49 +0200:

> Hi Miquel,
> Hi Jagan,
> 
> On 26.07.2018 09:29, Miquel Raynal wrote:
> > Hi Jagan,  
> > > Jagan Teki  wrote on Thu, 26 Jul 2018  
> > 11:00:56 +0530:  
> > >> On Fri, Jul 13, 2018 at 6:01 PM, Miquel Raynal  
> >>  wrote:  
> >>> During the last months, Boris Brezillon shared his work to support
> >>> serial flashes within Linux. First, he delivered (and merged) a new
> >>> layer called spi-mem. He also initiated in Linux MTD subsystem the move
> >>> of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> >>> same time a NAND core that would be shared with all NAND devices. Then,
> >>> he contributed a generic SPI-NAND driver, making use of this NAND core,
> >>> as well as some vendor code to drive a few chips.
> >>>
> >>> On top of this work, I added an 'mtd' U-Boot command to handle all sort
> >>> of MTD devices. This should become the default command instead of having
> >>> one per flash flavor ('sf', 'nand', 'spi-nand' ?).
> >>>
> >>> The series has been tested on an Ocelot board PCB123 (VSC7514),
> >>> featuring a Macronix SPI NAND chip.
> >>>
> >>> TL;DR: the series contains:
> >>> - A few patches from Linux to resynchronize some areas of the MTD layer.
> >>> - Various fixes and re-organization of the MTD subsystem.
> >>> - The introduction of the SPI-mem interface.
> >>> - The addition of the generic SPI-NAND driver (and its bindings).
> >>> - Several SPI NAND chip drivers (Macronix, Micron, Winbond).
> >>> - A new 'mtd' command.
> >>> - Support for spi-nand devices in mtdparts.
> >>>
> >>> To test your SPI-NAND device with U-Boot simply follow these lines:  
> >>>    setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)  
>  setenv mtdids spi-nand0=spi-nand0
>  mtdparts # show the spi-nand device partitions
>  ubi part bar # create a static UBI volume in the bar partition  
> >>>
> >>> Thanks,
> >>> Miquèl
> >>>
> >>> Changes since v3:
> >>> -
> >>> * Fixed the debug messages in spi-mem to print either Rx or Tx data.
> >>> * Fixed a Kconfig error that prevented to build mtdparts with plain
> >>>defconfig.
> >>> * Fixed a compilation error due to the above error that prevented one
> >>>file to be compiled.
> >>> * Adapted the mtd command to probe MTD partitions also.
> >>> * Declared mtd_probe_devices() in a header so mtdparts or UBI could
> >>>use it too (to probe all devices and MTD partitions in a clean way).
> >>> * As I worked on mtdparts, I found annoying and completely useless the
> >>>fact that we need to prefix the environment variable with
> >>>"mtdparts=". Canceled this obligation.
> >>> * Added one patch to allow spi-nand devices to be recognized by mtdparts
> >>>(this is purely useless but needed to be done in order to use this
> >>>command).
> >>> * Removed useless definitions of MTD device types in UBI code.
> >>> * Wrote a generic mtdparts environment variable parser, used by the mtd
> >>>command.
> >>> * Used the mtd_probe_devices() function from get_mtd_info() in
> >>>cmd/mtdparts.c to be sure the desired partition really does not exist
> >>>(otherwise it will be probed and then found).
> >>>
> >>> Changes since v2:
> >>> -
> >>> * Rebased on u-boot master branch.
> >>> * Removed extra-parenthesis in
> >>>"mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing"
> >>> * s/fiels/files/ in "mtd: move NAND fiels into a raw/ subdirectory"
> >>> * Do not describe generic SPI device properties in SPI NAND bindings.
> >>> * Changes in the mtd command:
> >>>* Printing more information in 'mtd list' (device type, device
> >>>  characteristics)
> >>>* Switch to do_div() instead of '(u32)value64b % value32b' which only
> >>>  worked because value32b was a power of 2.
> >>>* Removed erase.chip option.
> >>>* By default, erase/read/write happen on the full MTD device while a
> >>>  dump will only work on a single page.
> >>>
> >>> Changes since v1:
> >>> -
> >>> * Fixed the nand_memorg structure of the MX35LF2GE4AB chip.
> >>> * Added Reviewed-by tags from Jagan.
> >>> * Backported and squashed two patches fixing things in the SPI NAND core
> >>>received on the Linux ML.
> >>> * Backported more changes in mtdcore.c from Linux.
> >>> * Added a patch to add a fallback on mtd->_read/_write() in mtdcore.c
> >>>when mtd->_read/write_oob() is not supported.
> >>> * Removed the DT changes, useless as the DTs are not available in
> >>>mainline yet.
> >>> * Addressed Boris/Stefan comments on the 'mtd' command.
> >>> * Added support for multi-pages OOB read/write.
> >>>
> >>>
> >>> Boris Brezillon (7):
> >>>mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
> >>>mtd: Add sanity checks in mtd_write/read_oob()
> >>>mtd: nand: Add core infrastructure to deal with NAND devices
> >>>mtd: nand: Pass mode informat

[U-Boot] [PATCH v1 0/2] Replace serial setparity by setconfig

2018-07-30 Thread Patrice Chotard

This series :
  _ replace setparity ops by more complete setconfig in serial uclass
  _ replace setparity by setconfig in STM32 serial driver



Patrice Chotard (1):
  serial: stm32: Replace setparity by setconfig

Patrick Delaunay (1):
  dm: serial: Replace setparity by setconfig

 drivers/serial/serial-uclass.c | 14 ++
 drivers/serial/serial_stm32.c  | 21 +++--
 include/serial.h   | 42 +++---
 3 files changed, 68 insertions(+), 9 deletions(-)

-- 
1.9.1

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


[U-Boot] [PATCH v1 1/2] dm: serial: Replace setparity by setconfig

2018-07-30 Thread Patrice Chotard
From: Patrick Delaunay 

Replace setparity by more generic setconfig ops
to allow uart parity, bits word length and stop bits
number change.

Adds SERIAL_GET_PARITY/BITS/STOP macros.

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

 drivers/serial/serial-uclass.c | 14 ++
 include/serial.h   | 42 +++---
 2 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 321d23ee93bf..9f523751ce17 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -287,6 +287,18 @@ void serial_setbrg(void)
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
 }
 
+void serial_setconfig(u8 config)
+{
+   struct dm_serial_ops *ops;
+
+   if (!gd->cur_serial_dev)
+   return;
+
+   ops = serial_get_ops(gd->cur_serial_dev);
+   if (ops->setconfig)
+   ops->setconfig(gd->cur_serial_dev, config);
+}
+
 void serial_stdio_init(void)
 {
 }
@@ -398,6 +410,8 @@ static int serial_post_probe(struct udevice *dev)
ops->pending += gd->reloc_off;
if (ops->clear)
ops->clear += gd->reloc_off;
+   if (ops->setconfig)
+   ops->setconfig += gd->reloc_off;
 #if CONFIG_POST & CONFIG_SYS_POST_UART
if (ops->loop)
ops->loop += gd->reloc_off
diff --git a/include/serial.h b/include/serial.h
index b9ef6d91c9c5..61c1362e9e32 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -73,6 +73,39 @@ enum serial_par {
SERIAL_PAR_EVEN
 };
 
+#define SERIAL_PAR_MASK0x03
+#define SERIAL_PAR_SHIFT   0
+#define SERIAL_GET_PARITY(config) \
+   ((config & SERIAL_PAR_MASK) >> SERIAL_PAR_SHIFT)
+
+enum serial_bits {
+   SERIAL_5_BITS,
+   SERIAL_6_BITS,
+   SERIAL_7_BITS,
+   SERIAL_8_BITS
+};
+
+#define SERIAL_BITS_MASK   0x0C
+#define SERIAL_BITS_SHIFT  2
+#define SERIAL_GET_BITS(config) \
+   ((config & SERIAL_BITS_MASK) >> SERIAL_BITS_SHIFT)
+
+enum serial_stop {
+   SERIAL_HALF_STOP,   /* 0.5 stop bit */
+   SERIAL_ONE_STOP,/*   1 stop bit */
+   SERIAL_ONE_HALF_STOP,   /* 1.5 stop bit */
+   SERIAL_TWO_STOP /*   2 stop bit */
+};
+
+#define SERIAL_STOP_MASK   0x30
+#define SERIAL_STOP_SHIFT  4
+#define SERIAL_GET_STOP(config) \
+   ((config & SERIAL_STOP_MASK) >> SERIAL_STOP_SHIFT)
+
+#define SERIAL_DEFAULT_CONFIG  SERIAL_PAR_NONE << SERIAL_PAR_SHIFT | \
+   SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
+   SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
+
 /**
  * struct struct dm_serial_ops - Driver model serial operations
  *
@@ -150,15 +183,18 @@ struct dm_serial_ops {
int (*loop)(struct udevice *dev, int on);
 #endif
/**
-* setparity() - Set up the parity
+* setconfig() - Set up the uart configuration
+* (parity, 5/6/7/8 bits word length, stop bits)
 *
-* Set up a new parity for this device.
+* Set up a new config for this device.
 *
 * @dev: Device pointer
 * @parity: parity to use
+* @bits: bits number to use
+* @stop: stop bits number to use
 * @return 0 if OK, -ve on error
 */
-   int (*setparity)(struct udevice *dev, enum serial_par parity);
+   int (*setconfig)(struct udevice *dev, u8 serial_config);
 };
 
 /**
-- 
1.9.1

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


[U-Boot] [PATCH v1 2/2] serial: stm32: Replace setparity by setconfig

2018-07-30 Thread Patrice Chotard
Replace stm32_serial_setparity by stm32_serial_setconfig
which allows to set serial bits number, parity and stop
bits number.
Only parity setting is implemented.

Signed-off-by: Patrick Delaunay 
Signed-off-by: Patrice Chotard 
---

 drivers/serial/serial_stm32.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c
index f26234549c3e..e6d383601c6c 100644
--- a/drivers/serial/serial_stm32.c
+++ b/drivers/serial/serial_stm32.c
@@ -47,20 +47,28 @@ static int stm32_serial_setbrg(struct udevice *dev, int 
baudrate)
return 0;
 }
 
-static int stm32_serial_setparity(struct udevice *dev, enum serial_par parity)
+static int stm32_serial_setconfig(struct udevice *dev, u8 serial_config)
 {
struct stm32x7_serial_platdata *plat = dev_get_platdata(dev);
bool stm32f4 = plat->uart_info->stm32f4;
u8 uart_enable_bit = plat->uart_info->uart_enable_bit;
u32 cr1 = plat->base + CR1_OFFSET(stm32f4);
u32 config = 0;
-
-   if (stm32f4)
-   return -EINVAL; /* not supported in driver*/
+   u8 parity = SERIAL_GET_PARITY(serial_config);
+   u8 bits = SERIAL_GET_BITS(serial_config);
+   u8 stop = SERIAL_GET_STOP(serial_config);
+
+   /*
+* only parity config is implemented, check if other serial settings
+* are the default one.
+* (STM32F4 serial IP didn't support parity setting)
+*/
+   if (bits != SERIAL_8_BITS || stop != SERIAL_ONE_STOP || stm32f4)
+   return -ENOTSUPP; /* not supported in driver*/
 
clrbits_le32(cr1, USART_CR1_RE | USART_CR1_TE | BIT(uart_enable_bit));
/* update usart configuration (uart need to be disable)
-* PCE: parity check control
+* PCE: parity check enable
 * PS : '0' : Even / '1' : Odd
 * M[1:0] = '00' : 8 Data bits
 * M[1:0] = '01' : 9 Data bits with parity
@@ -77,6 +85,7 @@ static int stm32_serial_setparity(struct udevice *dev, enum 
serial_par parity)
config = USART_CR1_PCE | USART_CR1_M0;
break;
}
+
clrsetbits_le32(cr1,
USART_CR1_PCE | USART_CR1_PS | USART_CR1_M1 |
USART_CR1_M0,
@@ -210,7 +219,7 @@ static const struct dm_serial_ops stm32_serial_ops = {
.pending = stm32_serial_pending,
.getc = stm32_serial_getc,
.setbrg = stm32_serial_setbrg,
-   .setparity = stm32_serial_setparity
+   .setconfig = stm32_serial_setconfig
 };
 
 U_BOOT_DRIVER(serial_stm32) = {
-- 
1.9.1

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


[U-Boot] [PATCH v5 00/27] SPI-NAND support

2018-07-30 Thread Miquel Raynal
During the last months, Boris Brezillon shared his work to support
serial flashes within Linux. First, he delivered (and merged) a new
layer called spi-mem. He also initiated in Linux MTD subsystem the move
of all 'raw' NAND related code to a raw/ subdirectory, adding at the
same time a NAND core that would be shared with all NAND devices. Then,
he contributed a generic SPI-NAND driver, making use of this NAND core,
as well as some vendor code to drive a few chips.

On top of this work, I added an 'mtd' U-Boot command to handle all sort
of MTD devices. This should become the default command instead of having
one per flash flavor ('sf', 'nand', 'spi-nand' ?).

The series has been tested on an Ocelot board PCB123 (VSC7514),
featuring a Macronix SPI NAND chip.

TL;DR: the series contains:
- A few patches from Linux to resynchronize some areas of the MTD layer.
- Various fixes and re-organization of the MTD subsystem.
- The introduction of the SPI-mem interface.
- The addition of the generic SPI-NAND driver (and its bindings).
- Several SPI NAND chip drivers (Macronix, Micron, Winbond).
- A new 'mtd' command.
- Support for spi-nand devices in mtdparts.

To test your SPI-NAND device with U-Boot simply follow these lines:

> setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
> setenv mtdids spi-nand0=spi-nand0
> mtdparts # show the spi-nand device partitions
> ubi part bar # create a static UBI volume in the bar partition

Thanks,
Miquèl

Changes since v4:
-
* Added Jagan's Acked-by tags to every patch related to the
  SPI-mem/SPI-NAND addition.
* Rebased on top of master.

Changes since v3:
-
* Fixed the debug messages in spi-mem to print either Rx or Tx data.
* Fixed a Kconfig error that prevented to build mtdparts with plain
  defconfig.
* Fixed a compilation error due to the above error that prevented one
  file to be compiled.
* Adapted the mtd command to probe MTD partitions also.
* Declared mtd_probe_devices() in a header so mtdparts or UBI could
  use it too (to probe all devices and MTD partitions in a clean way).
* As I worked on mtdparts, I found annoying and completely useless the
  fact that we need to prefix the environment variable with
  "mtdparts=". Canceled this obligation.
* Added one patch to allow spi-nand devices to be recognized by mtdparts
  (this is purely useless but needed to be done in order to use this
  command).
* Removed useless definitions of MTD device types in UBI code.
* Wrote a generic mtdparts environment variable parser, used by the mtd
  command.
* Used the mtd_probe_devices() function from get_mtd_info() in
  cmd/mtdparts.c to be sure the desired partition really does not exist
  (otherwise it will be probed and then found).

Changes since v2:
-
* Rebased on u-boot master branch.
* Removed extra-parenthesis in
  "mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing"
* s/fiels/files/ in "mtd: move NAND fiels into a raw/ subdirectory"
* Do not describe generic SPI device properties in SPI NAND bindings.
* Changes in the mtd command:
  * Printing more information in 'mtd list' (device type, device
characteristics)
  * Switch to do_div() instead of '(u32)value64b % value32b' which only
worked because value32b was a power of 2.
  * Removed erase.chip option.
  * By default, erase/read/write happen on the full MTD device while a
dump will only work on a single page.

Changes since v1:
-
* Fixed the nand_memorg structure of the MX35LF2GE4AB chip.
* Added Reviewed-by tags from Jagan.
* Backported and squashed two patches fixing things in the SPI NAND core
  received on the Linux ML.
* Backported more changes in mtdcore.c from Linux.
* Added a patch to add a fallback on mtd->_read/_write() in mtdcore.c
  when mtd->_read/write_oob() is not supported.
* Removed the DT changes, useless as the DTs are not available in
  mainline yet.
* Addressed Boris/Stefan comments on the 'mtd' command.
* Added support for multi-pages OOB read/write.


Boris Brezillon (7):
  mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
  mtd: Add sanity checks in mtd_write/read_oob()
  mtd: nand: Add core infrastructure to deal with NAND devices
  mtd: nand: Pass mode information to nand_page_io_req
  spi: Extend the core to ease integration of SPI memory controllers
  mtd: spinand: Add initial support for the MX35LF1GE4AB chip
  dt-bindings: Add bindings for SPI NAND devices

Brian Norris (1):
  mtd: add get/set of_node/flash_node helpers

Ezequiel Garcia (1):
  mtd: Uninline mtd_write_oob and move it to mtdcore.c

Frieder Schrempf (1):
  mtd: spinand: Add initial support for Winbond W25M02GV

Miquel Raynal (15):
  mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing
  mtd: fix build issue with includes
  mtd: move definitions to enlarge their range
  mtd: move all flash categories inside MTD submenu
  mtd: move NAND files into a raw/ subdirectory
  mtd: rename nand 

[U-Boot] [PATCH v5 02/27] mtd: Uninline mtd_write_oob and move it to mtdcore.c

2018-07-30 Thread Miquel Raynal
From: Ezequiel Garcia 

There's no reason for having mtd_write_oob inlined in mtd.h header.
Move it to mtdcore.c where it belongs.

Signed-off-by: Ezequiel Garcia 
Acked-by: Boris Brezillon 
Signed-off-by: Jacek Anaszewski 
Signed-off-by: Miquel Raynal 
---
 drivers/mtd/mtdcore.c   | 12 
 include/linux/mtd/mtd.h | 12 +---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 60ad28efd4..ad61406dac 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1031,6 +1031,18 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, 
struct mtd_oob_ops *ops)
 }
 EXPORT_SYMBOL_GPL(mtd_read_oob);
 
+int mtd_write_oob(struct mtd_info *mtd, loff_t to,
+   struct mtd_oob_ops *ops)
+{
+   ops->retlen = ops->oobretlen = 0;
+   if (!mtd->_write_oob)
+   return -EOPNOTSUPP;
+   if (!(mtd->flags & MTD_WRITEABLE))
+   return -EROFS;
+   return mtd->_write_oob(mtd, to, ops);
+}
+EXPORT_SYMBOL_GPL(mtd_write_oob);
+
 /**
  * mtd_ooblayout_ecc - Get the OOB region definition of a specific ECC section
  * @mtd: MTD device structure
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 823e535b82..eb39f38887 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -351,17 +351,7 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, 
size_t len, size_t *retlen,
const u_char *buf);
 
 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
-
-static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
-   struct mtd_oob_ops *ops)
-{
-   ops->retlen = ops->oobretlen = 0;
-   if (!mtd->_write_oob)
-   return -EOPNOTSUPP;
-   if (!(mtd->flags & MTD_WRITEABLE))
-   return -EROFS;
-   return mtd->_write_oob(mtd, to, ops);
-}
+int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
 
 int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
   struct otp_info *buf);
-- 
2.14.1

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


[U-Boot] [PATCH v5 03/27] mtd: Add sanity checks in mtd_write/read_oob()

2018-07-30 Thread Miquel Raynal
From: Boris Brezillon 

Unlike what's done in mtd_read/write(), there are no checks to make sure
the parameters passed to mtd_read/write_oob() are consistent, which
forces implementers of ->_read/write_oob() to do it, which in turn leads
to code duplication and possibly errors in the logic.

Do general sanity checks, like ops fields consistency and range checking.

Signed-off-by: Boris Brezillon 
Cc: Peter Pan 
Signed-off-by: Richard Weinberger 
[Miquel: squashed the fix about the chip's size check]
Signed-off-by: Miquel Raynal 
---
 drivers/mtd/mtdcore.c | 45 +
 1 file changed, 45 insertions(+)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index ad61406dac..9a3efe95df 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1010,12 +1010,50 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, 
size_t len, size_t *retlen,
 }
 EXPORT_SYMBOL_GPL(mtd_panic_write);
 
+static int mtd_check_oob_ops(struct mtd_info *mtd, loff_t offs,
+struct mtd_oob_ops *ops)
+{
+   /*
+* Some users are setting ->datbuf or ->oobbuf to NULL, but are leaving
+* ->len or ->ooblen uninitialized. Force ->len and ->ooblen to 0 in
+*  this case.
+*/
+   if (!ops->datbuf)
+   ops->len = 0;
+
+   if (!ops->oobbuf)
+   ops->ooblen = 0;
+
+   if (offs < 0 || offs + ops->len > mtd->size)
+   return -EINVAL;
+
+   if (ops->ooblen) {
+   u64 maxooblen;
+
+   if (ops->ooboffs >= mtd_oobavail(mtd, ops))
+   return -EINVAL;
+
+   maxooblen = ((mtd_div_by_ws(mtd->size, mtd) -
+ mtd_div_by_ws(offs, mtd)) *
+mtd_oobavail(mtd, ops)) - ops->ooboffs;
+   if (ops->ooblen > maxooblen)
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
 {
int ret_code;
ops->retlen = ops->oobretlen = 0;
if (!mtd->_read_oob)
return -EOPNOTSUPP;
+
+   ret_code = mtd_check_oob_ops(mtd, from, ops);
+   if (ret_code)
+   return ret_code;
+
/*
 * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
 * similar to mtd->_read(), returning a non-negative integer
@@ -1034,11 +1072,18 @@ EXPORT_SYMBOL_GPL(mtd_read_oob);
 int mtd_write_oob(struct mtd_info *mtd, loff_t to,
struct mtd_oob_ops *ops)
 {
+   int ret;
+
ops->retlen = ops->oobretlen = 0;
if (!mtd->_write_oob)
return -EOPNOTSUPP;
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
+
+   ret = mtd_check_oob_ops(mtd, to, ops);
+   if (ret)
+   return ret;
+
return mtd->_write_oob(mtd, to, ops);
 }
 EXPORT_SYMBOL_GPL(mtd_write_oob);
-- 
2.14.1

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


[U-Boot] [PATCH v5 01/27] mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing

2018-07-30 Thread Miquel Raynal
From: Boris Brezillon 

Some MTD sublayers/drivers are implementing ->_read/write_oob() and
provide dummy wrappers for their ->_read/write() implementations.
Let the core handle this case instead of duplicating the logic.

Signed-off-by: Boris Brezillon 
Acked-by: Robert Jarzmik 
Acked-by: Brian Norris 
Reviewed-by: Miquel Raynal 
Tested-by: Ladislav Michl 
Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 drivers/mtd/mtdcore.c  | 31 ++--
 drivers/mtd/mtdpart.c  |  6 ++--
 drivers/mtd/nand/nand_base.c   | 56 ---
 drivers/mtd/onenand/onenand_base.c | 60 --
 4 files changed, 33 insertions(+), 120 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 6217be2352..60ad28efd4 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -937,7 +937,20 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t 
len, size_t *retlen,
 * representing the maximum number of bitflips that were corrected on
 * any one ecc region (if applicable; zero otherwise).
 */
-   ret_code = mtd->_read(mtd, from, len, retlen, buf);
+   if (mtd->_read) {
+   ret_code = mtd->_read(mtd, from, len, retlen, buf);
+   } else if (mtd->_read_oob) {
+   struct mtd_oob_ops ops = {
+   .len = len,
+   .datbuf = buf,
+   };
+
+   ret_code = mtd->_read_oob(mtd, from, &ops);
+   *retlen = ops.retlen;
+   } else {
+   return -ENOTSUPP;
+   }
+
if (unlikely(ret_code < 0))
return ret_code;
if (mtd->ecc_strength == 0)
@@ -952,10 +965,24 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t 
len, size_t *retlen,
*retlen = 0;
if (to < 0 || to > mtd->size || len > mtd->size - to)
return -EINVAL;
-   if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE))
+   if ((!mtd->_write && !mtd->_write_oob) ||
+   !(mtd->flags & MTD_WRITEABLE))
return -EROFS;
if (!len)
return 0;
+
+   if (!mtd->_write) {
+   struct mtd_oob_ops ops = {
+   .len = len,
+   .datbuf = (u8 *)buf,
+   };
+   int ret;
+
+   ret = mtd->_write_oob(mtd, to, &ops);
+   *retlen = ops.retlen;
+   return ret;
+   }
+
return mtd->_write(mtd, to, len, retlen, buf);
 }
 EXPORT_SYMBOL_GPL(mtd_write);
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index f87c962205..ccbb1757ea 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -417,8 +417,10 @@ static struct mtd_part *allocate_partition(struct mtd_info 
*master,
slave->mtd.dev.parent = master->dev.parent;
 #endif
 
-   slave->mtd._read = part_read;
-   slave->mtd._write = part_write;
+   if (master->_read)
+   slave->mtd._read = part_read;
+   if (master->_write)
+   slave->mtd._write = part_write;
 
if (master->_panic_write)
slave->mtd._panic_write = part_panic_write;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 64e4621aaa..0b58e15b03 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1863,33 +1863,6 @@ read_retry:
return max_bitflips;
 }
 
-/**
- * nand_read - [MTD Interface] MTD compatibility function for nand_do_read_ecc
- * @mtd: MTD device structure
- * @from: offset to read from
- * @len: number of bytes to read
- * @retlen: pointer to variable to store the number of read bytes
- * @buf: the databuffer to put data
- *
- * Get hold of the chip and call nand_do_read.
- */
-static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
-size_t *retlen, uint8_t *buf)
-{
-   struct mtd_oob_ops ops;
-   int ret;
-
-   nand_get_device(mtd, FL_READING);
-   memset(&ops, 0, sizeof(ops));
-   ops.len = len;
-   ops.datbuf = buf;
-   ops.mode = MTD_OPS_PLACE_OOB;
-   ret = nand_do_read_ops(mtd, from, &ops);
-   *retlen = ops.retlen;
-   nand_release_device(mtd);
-   return ret;
-}
-
 /**
  * nand_read_oob_std - [REPLACEABLE] the most common OOB data read function
  * @mtd: mtd info structure
@@ -2674,33 +2647,6 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t 
to, size_t len,
return ret;
 }
 
-/**
- * nand_write - [MTD Interface] NAND write with ECC
- * @mtd: MTD device structure
- * @to: offset to write to
- * @len: number of bytes to write
- * @retlen: pointer to variable to store the number of written bytes
- * @buf: the data to write
- *
- * NAND write with ECC.
- */
-static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const uint8_t *buf)
-{
-   struct mtd_oob_ops ops;
-   int ret;
-
- 

[U-Boot] [PATCH v5 06/27] mtd: fix build issue with includes

2018-07-30 Thread Miquel Raynal
Fix build errors produced by mtd.h and dm/device.h if not included in
the right order.

Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 include/linux/mtd/mtd.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ea659c354b..8def104627 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_MTD_DEVICES 32
 #endif
-- 
2.14.1

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


[U-Boot] [PATCH v5 07/27] mtd: move definitions to enlarge their range

2018-07-30 Thread Miquel Raynal
Some helpers might be useful in a future 'mtd' U-Boot command to parse
MTD device list.

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/mtdcore.h   | 6 --
 include/linux/mtd/mtd.h | 6 ++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/mtdcore.h b/drivers/mtd/mtdcore.h
index 7b0353399a..1d181a1045 100644
--- a/drivers/mtd/mtdcore.h
+++ b/drivers/mtd/mtdcore.h
@@ -5,7 +5,6 @@
 
 extern struct mutex mtd_table_mutex;
 
-struct mtd_info *__mtd_next_device(int i);
 int add_mtd_device(struct mtd_info *mtd);
 int del_mtd_device(struct mtd_info *mtd);
 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
@@ -16,8 +15,3 @@ int parse_mtd_partitions(struct mtd_info *master, const char 
* const *types,
 
 int __init init_mtdchar(void);
 void __exit cleanup_mtdchar(void);
-
-#define mtd_for_each_device(mtd)   \
-   for ((mtd) = __mtd_next_device(0);  \
-(mtd) != NULL; \
-(mtd) = __mtd_next_device(mtd->index + 1))
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8def104627..6771ee2586 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -517,6 +517,12 @@ int del_mtd_device(struct mtd_info *mtd);
 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
 int del_mtd_partitions(struct mtd_info *);
 
+struct mtd_info *__mtd_next_device(int i);
+#define mtd_for_each_device(mtd)   \
+   for ((mtd) = __mtd_next_device(0);  \
+(mtd) != NULL; \
+(mtd) = __mtd_next_device(mtd->index + 1))
+
 int mtd_arg_off(const char *arg, int *idx, loff_t *off, loff_t *size,
loff_t *maxsize, int devtype, uint64_t chipsize);
 int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off,
-- 
2.14.1

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


[U-Boot] [PATCH v5 05/27] mtd: add get/set of_node/flash_node helpers

2018-07-30 Thread Miquel Raynal
From: Brian Norris 

We are going to begin using the mtd->dev.of_node field for MTD device
nodes, so let's add helpers for it. Also, we'll be making some
conversions on spi_nor (and nand_chip eventually) too, so get that ready
with their own helpers.

Signed-off-by: Brian Norris 
Reviewed-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 include/linux/mtd/mtd.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index eb39f38887..ea659c354b 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -306,6 +306,17 @@ struct mtd_info {
int usecount;
 };
 
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+  const struct device_node *np)
+{
+   mtd->dev->node.np = np;
+}
+
+static inline const struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+   return mtd->dev->node.np;
+}
+
 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
  struct mtd_oob_region *oobecc);
 int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
-- 
2.14.1

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


[U-Boot] [PATCH v5 04/27] mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing

2018-07-30 Thread Miquel Raynal
Some MTD sublayers/drivers are implementing ->_read/write() and
not ->_read/write_oob().

While for NAND devices both are usually valid, for NOR devices, using
the _oob variant has no real meaning. But, as the MTD layer is supposed
to hide as much as possible the flash complexity to the user, there is
no reason to error out while it is just a matter of rewritting things
internally.

Add a fallback on mtd->_read() (resp. mtd->_write()) when the user calls
mtd_read_oob() (resp. mtd_write_oob()) while mtd->_read_oob() (resp.
mtd->_write_oob) is not implemented. There is already a fallback on the
_oob variant if the former is used.

Signed-off-by: Miquel Raynal 
---
 drivers/mtd/mtdcore.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 9a3efe95df..fb1d68d5e2 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1047,20 +1047,27 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, 
struct mtd_oob_ops *ops)
 {
int ret_code;
ops->retlen = ops->oobretlen = 0;
-   if (!mtd->_read_oob)
-   return -EOPNOTSUPP;
 
ret_code = mtd_check_oob_ops(mtd, from, ops);
if (ret_code)
return ret_code;
 
+   /* Check the validity of a potential fallback on mtd->_read */
+   if (!mtd->_read_oob && (!mtd->_read || ops->oobbuf))
+   return -EOPNOTSUPP;
+
+   if (mtd->_read_oob)
+   ret_code = mtd->_read_oob(mtd, from, ops);
+   else
+   ret_code = mtd->_read(mtd, from, ops->len, &ops->retlen,
+ ops->datbuf);
+
/*
 * In cases where ops->datbuf != NULL, mtd->_read_oob() has semantics
 * similar to mtd->_read(), returning a non-negative integer
 * representing max bitflips. In other cases, mtd->_read_oob() may
 * return -EUCLEAN. In all cases, perform similar logic to mtd_read().
 */
-   ret_code = mtd->_read_oob(mtd, from, ops);
if (unlikely(ret_code < 0))
return ret_code;
if (mtd->ecc_strength == 0)
@@ -1075,8 +1082,7 @@ int mtd_write_oob(struct mtd_info *mtd, loff_t to,
int ret;
 
ops->retlen = ops->oobretlen = 0;
-   if (!mtd->_write_oob)
-   return -EOPNOTSUPP;
+
if (!(mtd->flags & MTD_WRITEABLE))
return -EROFS;
 
@@ -1084,7 +1090,15 @@ int mtd_write_oob(struct mtd_info *mtd, loff_t to,
if (ret)
return ret;
 
-   return mtd->_write_oob(mtd, to, ops);
+   /* Check the validity of a potential fallback on mtd->_write */
+   if (!mtd->_write_oob && (!mtd->_write || ops->oobbuf))
+   return -EOPNOTSUPP;
+
+   if (mtd->_write_oob)
+   return mtd->_write_oob(mtd, to, ops);
+   else
+   return mtd->_write(mtd, to, ops->len, &ops->retlen,
+  ops->datbuf);
 }
 EXPORT_SYMBOL_GPL(mtd_write_oob);
 
-- 
2.14.1

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


[U-Boot] [PATCH v5 08/27] mtd: move all flash categories inside MTD submenu

2018-07-30 Thread Miquel Raynal
There is no reason to have NAND, SPI flashes and UBI sections outside of
the MTD submenu in Kconfig.

Signed-off-by: Miquel Raynal 
Reviewed-by: Jagan Teki 
---
 drivers/mtd/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 41f8883ec2..9341d518f3 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -59,10 +59,10 @@ config RENESAS_RPC_HF
  This enables access to Hyperflash memory through the Renesas
  RCar Gen3 RPC controller.
 
-endmenu
-
 source "drivers/mtd/nand/Kconfig"
 
 source "drivers/mtd/spi/Kconfig"
 
 source "drivers/mtd/ubi/Kconfig"
+
+endmenu
-- 
2.14.1

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


[U-Boot] [PATCH v5 16/27] mtd: spinand: Add initial support for Winbond W25M02GV

2018-07-30 Thread Miquel Raynal
From: Frieder Schrempf 

Add support for the W25M02GV chip.

Signed-off-by: Frieder Schrempf 
Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/spi/Makefile  |   2 +-
 drivers/mtd/nand/spi/core.c|   1 +
 drivers/mtd/nand/spi/winbond.c | 143 +
 include/linux/mtd/spinand.h|   1 +
 4 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/winbond.c

diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
index 4eb745abd4..11ba5de68b 100644
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-spinand-objs := core.o micron.o
+spinand-objs := core.o micron.o winbond.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 36b8b52bc2..ef3e6445d8 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -831,6 +831,7 @@ static const struct nand_ops spinand_ops = {
 
 static const struct spinand_manufacturer *spinand_manufacturers[] = {
µn_spinand_manufacturer,
+   &winbond_spinand_manufacturer,
 };
 
 static int spinand_manufacturer_detect(struct spinand_device *spinand)
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
new file mode 100644
index 00..eac811d97c
--- /dev/null
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017 exceet electronics GmbH
+ *
+ * Authors:
+ * Frieder Schrempf 
+ * Boris Brezillon 
+ */
+
+#ifndef __UBOOT__
+#include 
+#include 
+#endif
+#include 
+
+#define SPINAND_MFR_WINBOND0xEF
+
+#define WINBOND_CFG_BUF_READ   BIT(3)
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+   SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
+   SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+   SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
+   SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
+static int w25m02gv_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+   if (section > 3)
+   return -ERANGE;
+
+   region->offset = (16 * section) + 8;
+   region->length = 8;
+
+   return 0;
+}
+
+static int w25m02gv_ooblayout_free(struct mtd_info *mtd, int section,
+  struct mtd_oob_region *region)
+{
+   if (section > 3)
+   return -ERANGE;
+
+   region->offset = (16 * section) + 2;
+   region->length = 6;
+
+   return 0;
+}
+
+static const struct mtd_ooblayout_ops w25m02gv_ooblayout = {
+   .ecc = w25m02gv_ooblayout_ecc,
+   .free = w25m02gv_ooblayout_free,
+};
+
+static int w25m02gv_select_target(struct spinand_device *spinand,
+ unsigned int target)
+{
+   struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0xc2, 1),
+ SPI_MEM_OP_NO_ADDR,
+ SPI_MEM_OP_NO_DUMMY,
+ SPI_MEM_OP_DATA_OUT(1,
+   spinand->scratchbuf,
+   1));
+
+   *spinand->scratchbuf = target;
+   return spi_mem_exec_op(spinand->slave, &op);
+}
+
+static const struct spinand_info winbond_spinand_table[] = {
+   SPINAND_INFO("W25M02GV", 0xAB,
+NAND_MEMORG(1, 2048, 64, 64, 1024, 1, 1, 2),
+NAND_ECCREQ(1, 512),
+SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+0,
+SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL),
+SPINAND_SELECT_TARGET(w25m02gv_select_target)),
+};
+
+/**
+ * winbond_spinand_detect - initialize device related part in spinand_device
+ * struct if it is a Winbond device.
+ * @spinand: SPI NAND device structure
+ */
+static int winbond_spinand_detect(struct spinand_device *spinand)
+{
+   u8 *id = spinand->id.data;
+   int ret;
+
+   /*
+* Winbond SPI NAND read ID need a dummy byte,
+* so the first byte in raw_id is dummy.
+*/
+   if (id[1] != SPINA

[U-Boot] [PATCH v5 11/27] mtd: nand: Add core infrastructure to deal with NAND devices

2018-07-30 Thread Miquel Raynal
From: Boris Brezillon 

Add an intermediate layer to abstract NAND device interface so that
some logic can be shared between SPI NANDs, parallel/raw NANDs,
OneNANDs, ...

Signed-off-by: Boris Brezillon 
Signed-off-by: Miquel Raynal 
Acked-by: Jagan Teki 
---
 drivers/mtd/nand/Kconfig  |   3 +
 drivers/mtd/nand/Makefile |   2 +
 drivers/mtd/nand/bbt.c| 132 +
 drivers/mtd/nand/core.c   | 243 +++
 include/linux/mtd/nand.h  | 731 ++
 5 files changed,  insertions(+)
 create mode 100644 drivers/mtd/nand/bbt.c
 create mode 100644 drivers/mtd/nand/core.c
 create mode 100644 include/linux/mtd/nand.h

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 6d53734718..1c1a1f487e 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1 +1,4 @@
+config MTD_NAND_CORE
+   tristate
+
 source "drivers/mtd/nand/raw/Kconfig"
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 8b2d0e118d..e07d0da46a 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -1,3 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+nandcore-objs := core.o bbt.o
+obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
 obj-$(CONFIG_MTD_NAND) += raw/
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
new file mode 100644
index 00..7e0ad3190c
--- /dev/null
+++ b/drivers/mtd/nand/bbt.c
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017 Free Electrons
+ *
+ * Authors:
+ * Boris Brezillon 
+ * Peter Pan 
+ */
+
+#define pr_fmt(fmt)"nand-bbt: " fmt
+
+#include 
+#ifndef __UBOOT__
+#include 
+#endif
+
+/**
+ * nanddev_bbt_init() - Initialize the BBT (Bad Block Table)
+ * @nand: NAND device
+ *
+ * Initialize the in-memory BBT.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+int nanddev_bbt_init(struct nand_device *nand)
+{
+   unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
+   unsigned int nblocks = nanddev_neraseblocks(nand);
+   unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block,
+  BITS_PER_LONG);
+
+   nand->bbt.cache = kzalloc(nwords, GFP_KERNEL);
+   if (!nand->bbt.cache)
+   return -ENOMEM;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_init);
+
+/**
+ * nanddev_bbt_cleanup() - Cleanup the BBT (Bad Block Table)
+ * @nand: NAND device
+ *
+ * Undoes what has been done in nanddev_bbt_init()
+ */
+void nanddev_bbt_cleanup(struct nand_device *nand)
+{
+   kfree(nand->bbt.cache);
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_cleanup);
+
+/**
+ * nanddev_bbt_update() - Update a BBT
+ * @nand: nand device
+ *
+ * Update the BBT. Currently a NOP function since on-flash bbt is not yet
+ * supported.
+ *
+ * Return: 0 in case of success, a negative error code otherwise.
+ */
+int nanddev_bbt_update(struct nand_device *nand)
+{
+   return 0;
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_update);
+
+/**
+ * nanddev_bbt_get_block_status() - Return the status of an eraseblock
+ * @nand: nand device
+ * @entry: the BBT entry
+ *
+ * Return: a positive number nand_bbt_block_status status or -%ERANGE if @entry
+ *is bigger than the BBT size.
+ */
+int nanddev_bbt_get_block_status(const struct nand_device *nand,
+unsigned int entry)
+{
+   unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
+   unsigned long *pos = nand->bbt.cache +
+((entry * bits_per_block) / BITS_PER_LONG);
+   unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG;
+   unsigned long status;
+
+   if (entry >= nanddev_neraseblocks(nand))
+   return -ERANGE;
+
+   status = pos[0] >> offs;
+   if (bits_per_block + offs > BITS_PER_LONG)
+   status |= pos[1] << (BITS_PER_LONG - offs);
+
+   return status & GENMASK(bits_per_block - 1, 0);
+}
+EXPORT_SYMBOL_GPL(nanddev_bbt_get_block_status);
+
+/**
+ * nanddev_bbt_set_block_status() - Update the status of an eraseblock in the
+ * in-memory BBT
+ * @nand: nand device
+ * @entry: the BBT entry to update
+ * @status: the new status
+ *
+ * Update an entry of the in-memory BBT. If you want to push the updated BBT
+ * the NAND you should call nanddev_bbt_update().
+ *
+ * Return: 0 in case of success or -%ERANGE if @entry is bigger than the BBT
+ *size.
+ */
+int nanddev_bbt_set_block_status(struct nand_device *nand, unsigned int entry,
+enum nand_bbt_block_status status)
+{
+   unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
+   unsigned long *pos = nand->bbt.cache +
+((entry * bits_per_block) / BITS_PER_LONG);
+   unsigned int offs = (entry * bits_per_block) % BITS_PER_LONG;
+   unsigned long val = status & GENMASK(bits_per_block - 1, 0);
+
+   if (entry >= nanddev_neraseblocks(nand))

  1   2   3   >