[U-Boot] OMAP35xx boards working on master?

2017-07-29 Thread Derald Woods
Are any OMAP35xx boards/systems working since this commit:


"arm: omap: Unify get_device_type() function"

http://git.denx.de/?p=u-boot.git;a=commit;h=00bbe96ebabbc83777cd8d6c6fd2791c5c8cf619


I have an OMAP3EVM (3530) system which stopped booting, with the default
config, at this commit. The commit seems to have been tested on newer SOC
boards (37xx+). I am trying to put together some patches for this board
against the current master, but this is the point where things stopped. At
least in my setup. Any suggestions would be appreciated.


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


[U-Boot] Please pull u-boot-x86

2017-07-29 Thread Bin Meng
Hi Tom,

The following changes since commit 19d1f1a2f3ccfbf85125150f7876ce22714b38bd:

  Merge git://git.denx.de/u-boot-socfpga (2017-07-29 11:44:08 -0400)

are available in the git repository at:

  git://git.denx.de/u-boot-x86.git

for you to fetch changes up to 55f228b07e2d84938a88737445441e736de41340:

  x86: minnowmax: Remove CONFIG_SMSC_LPC47M (2017-07-30 10:30:25 +0800)


Andy Shevchenko (10):
  arch/x86: Select USB before selecting host driver
  x86: Add dma-mapping.h to architectural code
  x86: Add Intel Edison board files
  Makefile: Don't shadow actual error when compile ASL
  Makefile: Export build date as integer
  x86: acpi: Fill OEM revision
  x86: acpi: Name fields in FADT in accordance with specification
  x86: acpi: Deduplicate acpi_fill_madt() implementation
  x86: acpi: Export acpi_fill_mcfg() with __weak attribute
  x86: acpi: Don't touch hardware on HW reduced platforms

Bin Meng (1):
  x86: minnowmax: Remove CONFIG_SMSC_LPC47M

Felipe Balbi (2):
  watchdog: Introduce watchdog driver for Intel Tangier
  x86: Add Intel Tangier support

Stefan Roese (4):
  x86: theadorable-x86-dfi-bt700: Add Spansion SPI support and
move VIDEO blob
  x86: conga-qeval20-qa3-e3845: Select CONFIG_BOARD_LATE_INIT
  x86: dfi-bt700: Add xHCI USB support
  x86: conga-qeval20-qa3-e3845.dts: Enable xHCI support in dts

 Makefile|   2 ++
 arch/Kconfig|   1 +
 arch/x86/Kconfig|   1 +
 arch/x86/cpu/Makefile   |   1 +
 arch/x86/cpu/baytrail/acpi.c|  29 ---
 arch/x86/cpu/quark/acpi.c   |  29 ---
 arch/x86/cpu/tangier/Kconfig|  24 +
 arch/x86/cpu/tangier/Makefile   |   7 
 arch/x86/cpu/tangier/car.S  |  13 +++
 arch/x86/cpu/tangier/sdram.c| 206
+++
 arch/x86/cpu/tangier/tangier.c  |  34
++
 arch/x86/dts/Makefile   |   1 +
 arch/x86/dts/conga-qeval20-qa3-e3845.dts|   3 ++
 arch/x86/dts/dfi-bt700.dtsi |  12 +++
 arch/x86/dts/edison.dts |  89
++
 arch/x86/include/asm/acpi_table.h   |   8 +++--
 arch/x86/include/asm/dma-mapping.h  |  41
++
 arch/x86/include/asm/sfi.h  |  19 ++
 arch/x86/lib/acpi_table.c   |  41
--
 board/congatec/conga-qeval20-qa3-e3845/Kconfig  |   1 +
 board/dfi/dfi-bt700/Kconfig |   1 +
 board/dfi/dfi-bt700/dfi-bt700.c |  27 ++
 board/intel/Kconfig |   8 +
 board/intel/edison/Kconfig  |  26 ++
 board/intel/edison/MAINTAINERS  |   6 
 board/intel/edison/Makefile |   7 
 board/intel/edison/config.mk|  18 ++
 board/intel/edison/edison.c | 104
++
 board/intel/edison/start.S  |  13 +++
 configs/bayleybay_defconfig |   1 -
 configs/chromebook_link64_defconfig |   1 -
 configs/chromebook_link_defconfig   |   1 -
 configs/chromebook_samus_defconfig  |   1 -
 configs/chromebox_panther_defconfig |   1 -
 configs/conga-qeval20-qa3-e3845-internal-uart_defconfig |   1 -
 configs/conga-qeval20-qa3-e3845_defconfig   |   1 -
 configs/coreboot-x86_defconfig  |   1 -
 configs/cougarcanyon2_defconfig |   1 -
 configs/crownbay_defconfig  |   1 -
 configs/dfi-bt700-q7x-151_defconfig |   1 -
 configs/edison_defconfig|  53

 configs/efi-x86_defconfig   |   1 -
 configs/galileo_defconfig   |   1 -
 configs/minnowmax_defconfig |   1 -
 configs/qemu-x86_64_defconfig   |   1 -
 configs/qemu-x86_defconfig  |   1 -
 configs/qemu-x86_efi_payload32_defconfig|   1 -
 configs/qemu-x86_efi_payload64_defconfig|   1 -

Re: [U-Boot] [PULL] u-boot-usb/master

2017-07-29 Thread Tom Rini
On Sat, Jul 29, 2017 at 05:26:45PM +0200, Marek Vasut wrote:

> The following changes since commit 26722335253a9fa384ceb423419254cb00d0def1:
> 
>   rockchip: puma-rk3399: remove duplicate code (merge artifact)
> (2017-07-27 14:59:04 +0200)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-usb.git master
> 
> for you to fetch changes up to b108d8a0de3ddc6fe8aae55bc54e3edc69b4778b:
> 
>   clk: fix compilation errors for poplar platform (2017-07-28 23:34:46
> +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PULL] u-boot-socfpga/master

2017-07-29 Thread Tom Rini
On Sat, Jul 29, 2017 at 05:27:19PM +0200, Marek Vasut wrote:

> The following changes since commit 609bf924117950b88987a5fa477acf1239bfdbc1:
> 
>   Convert CONFIG_ENV_IS_IN_ONENAND to Kconfig (2017-07-25 21:34:39 -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-socfpga.git master
> 
> for you to fetch changes up to 9af91b7c4041a455de5f3e3da4e36644768bff68:
> 
>   arm: socfpga: Enable all FPGA config support for Arria 10 (2017-07-26
> 10:31:44 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


[U-Boot] [PATCH v2 31/40] dm: mmc: fsl_esdhc: Drop mmc_init() call from fsl_esdhc_init()

2017-07-29 Thread Simon Glass
We want to use fsl_esdhc_init() with driver model. Move the mmc_init() out
of this function so that we can use it for our common init.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/fsl_esdhc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 409231e93d..9796b174c8 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -765,7 +765,6 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 {
struct mmc_config *cfg;
struct fsl_esdhc *regs;
-   struct mmc *mmc;
u32 caps, voltage_caps;
int ret;
 
@@ -856,12 +855,6 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
 
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
-   mmc = mmc_create(cfg, priv);
-   if (mmc == NULL)
-   return -1;
-
-   priv->mmc = mmc;
-
return 0;
 }
 
@@ -885,6 +878,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg 
*cfg)
 {
struct fsl_esdhc_plat *plat;
struct fsl_esdhc_priv *priv;
+   struct mmc *mmc;
int ret;
 
if (!cfg)
@@ -915,6 +909,12 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg 
*cfg)
return ret;
}
 
+   mmc = mmc_create(>cfg, priv);
+   if (!mmc)
+   return -EIO;
+
+   priv->mmc = mmc;
+
return 0;
 }
 
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 26/40] dm: mmc: fsl_esdhc: Pass private data to internal functions

2017-07-29 Thread Simon Glass
With driver model we will not use mmc->priv to access driver-private data.
To accomodate this, update internal functions so that we can pass the
private data directly. This will allow the caller to obtain it as it
prefers.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/fsl_esdhc.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 3abd2d30af..bb93b09f51 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -156,10 +156,9 @@ static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct 
mmc_data *data)
 /*
  * PIO Read/Write Mode reduce the performace as DMA is not used in this mode.
  */
-static void
-esdhc_pio_read_write(struct mmc *mmc, struct mmc_data *data)
+static void esdhc_pio_read_write(struct fsl_esdhc_priv *priv,
+struct mmc_data *data)
 {
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
uint blocks;
char *buffer;
@@ -218,10 +217,10 @@ esdhc_pio_read_write(struct mmc *mmc, struct mmc_data 
*data)
 }
 #endif
 
-static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
+static int esdhc_setup_data(struct fsl_esdhc_priv *priv, struct mmc *mmc,
+   struct mmc_data *data)
 {
int timeout;
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234)
dma_addr_t addr;
@@ -384,7 +383,7 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct 
mmc_data *data)
 
/* Set up for a data transfer if we have one */
if (data) {
-   err = esdhc_setup_data(mmc, data);
+   err = esdhc_setup_data(priv, mmc, data);
if(err)
return err;
 
@@ -470,7 +469,7 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct 
mmc_data *data)
/* Wait until all of the blocks are transferred */
if (data) {
 #ifdef CONFIG_SYS_FSL_ESDHC_USE_PIO
-   esdhc_pio_read_write(mmc, data);
+   esdhc_pio_read_write(priv, data);
 #else
do {
irqstat = esdhc_read32(>irqstat);
@@ -522,7 +521,7 @@ out:
return err;
 }
 
-static void set_sysctl(struct mmc *mmc, uint clock)
+static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint 
clock)
 {
int div = 1;
 #ifdef ARCH_MXC
@@ -531,7 +530,6 @@ static void set_sysctl(struct mmc *mmc, uint clock)
int pre_div = 2;
 #endif
int ddr_pre_div = mmc->ddr_mode ? 2 : 1;
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
int sdhc_clk = priv->sdhc_clk;
uint clk;
@@ -569,9 +567,8 @@ static void set_sysctl(struct mmc *mmc, uint clock)
 }
 
 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
-static void esdhc_clock_control(struct mmc *mmc, bool enable)
+static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 {
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
u32 value;
u32 time_out;
@@ -605,12 +602,12 @@ static int esdhc_set_ios(struct mmc *mmc)
 
 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
/* Select to use peripheral clock */
-   esdhc_clock_control(mmc, false);
+   esdhc_clock_control(priv, false);
esdhc_setbits32(>scr, ESDHCCTL_PCS);
-   esdhc_clock_control(mmc, true);
+   esdhc_clock_control(priv, true);
 #endif
/* Set the clock speed */
-   set_sysctl(mmc, mmc->clock);
+   set_sysctl(priv, mmc, mmc->clock);
 
/* Set the bus width */
esdhc_clrbits32(>proctl, PROCTL_DTW_4 | PROCTL_DTW_8);
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 32/40] dm: mmc: fsl_esdhc: Update to support livetree

2017-07-29 Thread Simon Glass
Update this driver to support a live device tree.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/fsl_esdhc.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 9796b174c8..46707c6def 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -1015,21 +1015,19 @@ static int fsl_esdhc_probe(struct udevice *dev)
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
struct fsl_esdhc_priv *priv = dev_get_priv(dev);
-   const void *fdt = gd->fdt_blob;
-   int node = dev_of_offset(dev);
struct udevice *vqmmc_dev;
fdt_addr_t addr;
unsigned int val;
int ret;
 
-   addr = devfdt_get_addr(dev);
+   addr = dev_read_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
 
priv->esdhc_regs = (struct fsl_esdhc *)addr;
priv->dev = dev;
 
-   val = fdtdec_get_int(fdt, node, "bus-width", -1);
+   val = dev_read_u32_default(dev, "bus-width", -1);
if (val == 8)
priv->bus_width = 8;
else if (val == 4)
@@ -1037,21 +1035,21 @@ static int fsl_esdhc_probe(struct udevice *dev)
else
priv->bus_width = 1;
 
-   if (fdt_get_property(fdt, node, "non-removable", NULL)) {
+   if (dev_read_bool(dev, "non-removable")) {
priv->non_removable = 1;
 } else {
priv->non_removable = 0;
 #ifdef CONFIG_DM_GPIO
-   gpio_request_by_name_nodev(offset_to_ofnode(node), "cd-gpios",
-  0, >cd_gpio, GPIOD_IS_IN);
+   gpio_request_by_name(dev, "cd-gpios", 0, >cd_gpio,
+GPIOD_IS_IN);
 #endif
}
 
priv->wp_enable = 1;
 
 #ifdef CONFIG_DM_GPIO
-   ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "wp-gpios", 0,
->wp_gpio, GPIOD_IS_IN);
+   ret = gpio_request_by_name(dev, "wp-gpios", 0, >wp_gpio,
+  GPIOD_IS_IN);
if (ret)
priv->wp_enable = 0;
 #endif
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 36/40] dm: imx: cm_fx6: Add MMC support for CONFIG_BLK

2017-07-29 Thread Simon Glass
When CONFIG_BLK is enabled our weak board_mmc_init() will not be called.
Since there is no clock driver for MX6 yet, we must manually enable the
clocks.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 board/compulab/cm_fx6/cm_fx6.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index ecefe394f1..ff3bab7889 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -678,6 +678,17 @@ int board_init(void)
 
cm_fx6_setup_display();
 
+   /* This should be done in the MMC driver when MX6 has a clock driver */
+#ifdef CONFIG_FSL_ESDHC
+   if (IS_ENABLED(CONFIG_BLK)) {
+   int i;
+
+   cm_fx6_set_usdhc_iomux();
+   for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++)
+   enable_usdhc_clk(1, i);
+   }
+#endif
+
return 0;
 }
 
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 40/40] dm: mmc: Drop CONFIG_DM_MMC_OPS

2017-07-29 Thread Simon Glass
All boards which use DM_MMC have now been converted to use DM_MMC_OPS.
Drop the option and good riddance.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to u-boot-mmc/master

 arch/arm/Kconfig  |  2 --
 drivers/mmc/Kconfig   | 39 +--
 drivers/mmc/dw_mmc.c  |  8 
 drivers/mmc/fsl_esdhc.c   |  8 +++-
 drivers/mmc/mmc-uclass.c  |  4 
 drivers/mmc/mmc.c | 12 ++--
 drivers/mmc/mmc_legacy.c  |  2 +-
 drivers/mmc/sdhci.c   |  8 
 include/configs/am335x_evm.h  |  1 -
 include/configs/am335x_shc.h  |  1 -
 include/configs/chiliboard.h  |  1 -
 include/configs/omap3_logic.h |  1 -
 include/dwmmc.h   |  2 +-
 include/mmc.h |  6 +++---
 include/sdhci.h   |  2 +-
 15 files changed, 32 insertions(+), 65 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7f6ab4ac7e..e06e31dd09 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -711,7 +711,6 @@ config ARCH_ZYNQ
select DM_GPIO
select SPL_DM if SPL
select DM_MMC
-   select DM_MMC_OPS
select DM_SPI
select DM_SERIAL
select DM_SPI_FLASH
@@ -1059,7 +1058,6 @@ config ARCH_ROCKCHIP
select DM_GPIO
select DM_I2C
select DM_MMC
-   select DM_MMC_OPS
select DM_SERIAL
select DM_SPI
select DM_SPI_FLASH
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 5a526945b7..56c352e72a 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -20,16 +20,6 @@ config DM_MMC
  appear as block devices in U-Boot and can support filesystems such
  as EXT4 and FAT.
 
-config DM_MMC_OPS
-   bool "Support MMC controller operations using Driver Model"
-   depends on DM_MMC
-   default y if DM_MMC
-   help
- Driver model provides a means of supporting device operations. This
- option moves MMC operations under the control of driver model. The
- option will be removed as soon as all DM_MMC drivers use it, as it
- will the only supported behaviour.
-
 config SPL_DM_MMC
bool "Enable MMC controllers using Driver Model in SPL"
depends on SPL_DM && DM_MMC
@@ -41,16 +31,6 @@ config SPL_DM_MMC
  appear as block devices in U-Boot and can support filesystems such
  as EXT4 and FAT.
 
-config SPL_DM_MMC_OPS
-   bool "Support MMC controller operations using Driver Model in SPL"
-   depends on SPL_DM_MMC && DM_MMC_OPS
-   default y
-   help
- Driver model provides a means of supporting device operations. This
- option moves MMC operations under the control of driver model. The
- option will be removed as soon as all DM_MMC drivers use it, as it
- will the only supported behaviour.
-
 if MMC
 
 config SPL_MMC_TINY
@@ -124,7 +104,7 @@ config MMC_DW_SOCFPGA
 
 config MMC_MESON_GX
bool "Meson GX EMMC controller support"
-   depends on DM_MMC && BLK && DM_MMC_OPS && ARCH_MESON
+   depends on DM_MMC && BLK && ARCH_MESON
help
 Support for EMMC host controller on Meson GX ARM SoCs platform (S905)
 
@@ -155,7 +135,6 @@ config MMC_PCI
 
 config MMC_OMAP_HS
bool "TI OMAP High Speed Multimedia Card Interface support"
-   select DM_MMC_OPS if DM_MMC
select DM_REGULATOR_PBIAS if DM_MMC && DM_REGULATOR
help
  This selects the TI OMAP High Speed Multimedia card Interface.
@@ -185,7 +164,7 @@ config SH_SDHI
 config MMC_UNIPHIER
bool "UniPhier SD/MMC Host Controller support"
depends on ARCH_UNIPHIER
-   depends on BLK && DM_MMC_OPS
+   depends on BLK && DM_MMC
depends on OF_CONTROL
help
  This selects support for the SD/MMC Host Controller on UniPhier SoCs.
@@ -193,7 +172,7 @@ config MMC_UNIPHIER
 config MMC_SANDBOX
bool "Sandbox MMC support"
depends on SANDBOX
-   depends on BLK && DM_MMC_OPS && OF_CONTROL
+   depends on BLK && DM_MMC && OF_CONTROL
help
  This select a dummy sandbox MMC driver. At present this does nothing
  other than allow sandbox to be build with MMC support. This
@@ -228,7 +207,7 @@ config MMC_SDHCI_SDMA
 config MMC_SDHCI_ATMEL
bool "Atmel SDHCI controller support"
depends on ARCH_AT91
-   depends on DM_MMC && BLK && DM_MMC_OPS && ARCH_AT91
+   depends on DM_MMC && BLK && ARCH_AT91
depends on MMC_SDHCI
help
  This enables support for the Atmel SDHCI controller, which supports
@@ -252,7 +231,7 @@ config MMC_SDHCI_BCM2835
 
 config MMC_SDHCI_CADENCE
bool "SDHCI support for the Cadence SD/SDIO/eMMC controller"
-   depends on BLK && DM_MMC_OPS
+   depends on BLK && DM_MMC
depends on MMC_SDHCI
depends on OF_CONTROL
help
@@ -274,7 +253,7 @@ config MMC_SDHCI_KONA
 
 config MMC_SDHCI_MSM
bool 

[U-Boot] [PATCH v2 38/40] dm: imx: Move i.MX devices to use CONFIG_DM_MMC_OPS

2017-07-29 Thread Simon Glass
Now that the driver supports it, move these boards over to use driver
model fully for MMC.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 configs/imx6q_logic_defconfig | 1 -
 configs/imx6qdl_icore_mmc_defconfig   | 1 -
 configs/imx6qdl_icore_rqs_defconfig   | 1 -
 configs/imx6ul_geam_mmc_defconfig | 1 -
 configs/imx6ul_geam_nand_defconfig| 1 -
 configs/imx6ul_isiot_emmc_defconfig   | 1 -
 configs/imx6ul_isiot_mmc_defconfig| 1 -
 configs/imx6ul_isiot_nand_defconfig   | 1 -
 configs/ls1012aqds_qspi_defconfig | 1 -
 configs/ls1012ardb_qspi_defconfig | 1 -
 configs/mx6slevk_defconfig| 1 -
 configs/mx6slevk_spinor_defconfig | 1 -
 configs/mx6sllevk_defconfig   | 1 -
 configs/mx6sllevk_plugin_defconfig| 1 -
 configs/mx6sxsabreauto_defconfig  | 1 -
 configs/mx6ull_14x14_evk_defconfig| 1 -
 configs/mx6ull_14x14_evk_plugin_defconfig | 1 -
 configs/mx7dsabresd_defconfig | 1 -
 configs/mx7dsabresd_secure_defconfig  | 1 -
 configs/mx7ulp_evk_defconfig  | 1 -
 configs/mx7ulp_evk_plugin_defconfig   | 1 -
 configs/opos6uldev_defconfig  | 1 -
 22 files changed, 22 deletions(-)

diff --git a/configs/imx6q_logic_defconfig b/configs/imx6q_logic_defconfig
index 03c278a35c..d271eda6cc 100644
--- a/configs/imx6q_logic_defconfig
+++ b/configs/imx6q_logic_defconfig
@@ -31,7 +31,6 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_MTDPARTS=y
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_NAND_MXS=y
 CONFIG_FEC_MXC=y
 CONFIG_PINCTRL=y
diff --git a/configs/imx6qdl_icore_mmc_defconfig 
b/configs/imx6qdl_icore_mmc_defconfig
index d1a2756bda..3d2184a9b1 100644
--- a/configs/imx6qdl_icore_mmc_defconfig
+++ b/configs/imx6qdl_icore_mmc_defconfig
@@ -38,7 +38,6 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_LIST="imx6q-icore imx6dl-icore"
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_PHYLIB=y
 CONFIG_PHY_SMSC=y
 CONFIG_FEC_MXC=y
diff --git a/configs/imx6qdl_icore_rqs_defconfig 
b/configs/imx6qdl_icore_rqs_defconfig
index 80205fe6ad..412139f8b6 100644
--- a/configs/imx6qdl_icore_rqs_defconfig
+++ b/configs/imx6qdl_icore_rqs_defconfig
@@ -36,7 +36,6 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_LIST="imx6q-icore-rqs imx6dl-icore-rqs"
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ9021=y
diff --git a/configs/imx6ul_geam_mmc_defconfig 
b/configs/imx6ul_geam_mmc_defconfig
index c956f072ce..b40138b001 100644
--- a/configs/imx6ul_geam_mmc_defconfig
+++ b/configs/imx6ul_geam_mmc_defconfig
@@ -35,7 +35,6 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_PHYLIB=y
 CONFIG_PHY_SMSC=y
 CONFIG_FEC_MXC=y
diff --git a/configs/imx6ul_geam_nand_defconfig 
b/configs/imx6ul_geam_nand_defconfig
index 1f0cc60653..596e490a55 100644
--- a/configs/imx6ul_geam_nand_defconfig
+++ b/configs/imx6ul_geam_nand_defconfig
@@ -35,7 +35,6 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_NAND_MXS=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_SMSC=y
diff --git a/configs/imx6ul_isiot_emmc_defconfig 
b/configs/imx6ul_isiot_emmc_defconfig
index 467a18cd6b..53e867e4f0 100644
--- a/configs/imx6ul_isiot_emmc_defconfig
+++ b/configs/imx6ul_isiot_emmc_defconfig
@@ -33,7 +33,6 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 # CONFIG_BLK is not set
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_PHYLIB=y
 CONFIG_PHY_SMSC=y
 CONFIG_FEC_MXC=y
diff --git a/configs/imx6ul_isiot_mmc_defconfig 
b/configs/imx6ul_isiot_mmc_defconfig
index 4bb75f7029..cfb7e56c6c 100644
--- a/configs/imx6ul_isiot_mmc_defconfig
+++ b/configs/imx6ul_isiot_mmc_defconfig
@@ -35,7 +35,6 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_PHYLIB=y
 CONFIG_PHY_SMSC=y
 CONFIG_FEC_MXC=y
diff --git a/configs/imx6ul_isiot_nand_defconfig 
b/configs/imx6ul_isiot_nand_defconfig
index fce0b0d2e5..0e3c195b10 100644
--- a/configs/imx6ul_isiot_nand_defconfig
+++ b/configs/imx6ul_isiot_nand_defconfig
@@ -35,7 +35,6 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_UBI=y
 # CONFIG_BLK is not set
 CONFIG_SYS_I2C_MXC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_NAND_MXS=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_SMSC=y
diff --git a/configs/ls1012aqds_qspi_defconfig 
b/configs/ls1012aqds_qspi_defconfig
index 15a73fcb17..18451dc789 100644
--- a/configs/ls1012aqds_qspi_defconfig
+++ b/configs/ls1012aqds_qspi_defconfig
@@ -34,7 +34,6 @@ CONFIG_DM=y
 CONFIG_SCSI=y
 # CONFIG_BLK is not set
 CONFIG_DM_MMC=y
-# CONFIG_DM_MMC_OPS is not set
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_NETDEVICES=y
diff --git a/configs/ls1012ardb_qspi_defconfig 
b/configs/ls1012ardb_qspi_defconfig

[U-Boot] [PATCH v2 35/40] dm: imx: cm_fx6: Add device tree for cm_fx6

2017-07-29 Thread Simon Glass
Add this file so we can use device-tree control for cm_fx6. It comes from
linux 4.12.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/imx6q-cm-fx6.dts | 115 ++
 2 files changed, 116 insertions(+)
 create mode 100644 arch/arm/dts/imx6q-cm-fx6.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 132fa69fe5..94dd0cbcbb 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -355,6 +355,7 @@ dtb-$(CONFIG_MX6) += imx6ull-14x14-evk.dtb \
imx6sll-evk.dtb \
imx6dl-icore.dtb \
imx6dl-icore-rqs.dtb \
+   imx6q-cm-fx6.dtb \
imx6q-icore.dtb \
imx6q-icore-rqs.dtb \
imx6q-logicpd.dtb \
diff --git a/arch/arm/dts/imx6q-cm-fx6.dts b/arch/arm/dts/imx6q-cm-fx6.dts
new file mode 100644
index 00..4f1fced40e
--- /dev/null
+++ b/arch/arm/dts/imx6q-cm-fx6.dts
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2013 CompuLab Ltd.
+ *
+ * Author: Valentin Raevsky 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx6q.dtsi"
+
+/ {
+   model = "CompuLab CM-FX6";
+   compatible = "compulab,cm-fx6", "fsl,imx6q";
+
+   memory {
+   reg = <0x1000 0x8000>;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   heartbeat-led {
+   label = "Heartbeat";
+   gpios = < 31 0>;
+   linux,default-trigger = "heartbeat";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_enet>;
+   phy-mode = "rgmii";
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpmi_nand>;
+   status = "okay";
+};
+
+ {
+   imx6q-cm-fx6 {
+   pinctrl_enet: enetgrp {
+   fsl,pins = <
+   MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b0b0
+   MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x1b0b0
+   MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x1b0b0
+   MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b0b0
+   MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b0b0
+   MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL   0x1b0b0
+   MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x1b0b0
+   MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b0b0
+   MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b0b0
+   MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b0b0
+   MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b0b0
+   MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL   0x1b0b0
+   MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK0x1b0b0
+   MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0
+   MX6QDL_PAD_ENET_MDC__ENET_MDC   0x1b0b0
+   MX6QDL_PAD_GPIO_16__ENET_REF_CLK
0x4001b0a8
+   >;
+   };
+
+   pinctrl_gpmi_nand: gpminandgrp {
+   fsl,pins = <
+   MX6QDL_PAD_NANDF_CLE__NAND_CLE  0xb0b1
+   MX6QDL_PAD_NANDF_ALE__NAND_ALE  0xb0b1
+   MX6QDL_PAD_NANDF_WP_B__NAND_WP_B0xb0b1
+   MX6QDL_PAD_NANDF_RB0__NAND_READY_B  0xb000
+   MX6QDL_PAD_NANDF_CS0__NAND_CE0_B0xb0b1
+   MX6QDL_PAD_NANDF_CS1__NAND_CE1_B0xb0b1
+   MX6QDL_PAD_SD4_CMD__NAND_RE_B   0xb0b1
+   MX6QDL_PAD_SD4_CLK__NAND_WE_B   0xb0b1
+   MX6QDL_PAD_NANDF_D0__NAND_DATA000xb0b1
+   MX6QDL_PAD_NANDF_D1__NAND_DATA010xb0b1
+   MX6QDL_PAD_NANDF_D2__NAND_DATA020xb0b1
+   MX6QDL_PAD_NANDF_D3__NAND_DATA030xb0b1
+   MX6QDL_PAD_NANDF_D4__NAND_DATA040xb0b1
+   MX6QDL_PAD_NANDF_D5__NAND_DATA050xb0b1
+   MX6QDL_PAD_NANDF_D6__NAND_DATA060xb0b1
+   MX6QDL_PAD_NANDF_D7__NAND_DATA070xb0b1
+   MX6QDL_PAD_SD4_DAT0__NAND_DQS   0x00b1
+   >;
+   };
+
+   

[U-Boot] saveenv command on odroid c2

2017-07-29 Thread Tyna Pelletier-Bilodeau

Hi there,
I recently installed mainline u-boot on my odroid c2, that is latest 
release which is 2017.07. However I'm having a small issue and I don't 
know if it should be reported here or not, please feel free to correct 
me if not. I'm noticing that once it's installed, if I interrupt 
automatic booting and get in the u-boot console and type help, the 
saveenv command is not there. Even typing saveenv gives me 'unknown 
command'. So I checked the .config file in the source and I see this:


CONFIG_CMD_SAVEENV=y

What could possibly be missing ?
Thanks a lot :)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 29/40] dm: mmc: fsl_esdhc: Detect init failure

2017-07-29 Thread Simon Glass
Since esdhc_init_common() can fail it should return an error code. Update
this and also adjust the timeout mechanism to use get_timer(), which is a
more common approach.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/fsl_esdhc.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index f975c425d2..1cf0faea81 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -621,14 +621,17 @@ static int esdhc_set_ios_common(struct fsl_esdhc_priv 
*priv, struct mmc *mmc)
 static int esdhc_init_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
 {
struct fsl_esdhc *regs = priv->esdhc_regs;
-   int timeout = 1000;
+   ulong start;
 
/* Reset the entire host controller */
esdhc_setbits32(>sysctl, SYSCTL_RSTA);
 
/* Wait until the controller is available */
-   while ((esdhc_read32(>sysctl) & SYSCTL_RSTA) && --timeout)
-   udelay(1000);
+   start = get_timer(0);
+   while ((esdhc_read32(>sysctl) & SYSCTL_RSTA)) {
+   if (get_timer(start) > 1000)
+   return -ETIMEDOUT;
+   }
 
 #if defined(CONFIG_FSL_USDHC)
/* RSTA doesn't reset MMC_BOOT register, so manually reset it */
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 34/40] dm: imx: cm_fx6: Support driver model for SATA

2017-07-29 Thread Simon Glass
Add support for using driver model for SATA with the cm_fx6 board. The old
code remains for now to permit testing.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 board/compulab/cm_fx6/cm_fx6.c | 69 ++
 1 file changed, 69 insertions(+)

diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index c59884a8c3..ecefe394f1 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -9,7 +9,9 @@
  */
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "common.h"
 #include "../common/eeprom.h"
@@ -206,6 +209,8 @@ static int cm_fx6_setup_issd(void)
 }
 
 #define CM_FX6_SATA_INIT_RETRIES   10
+
+# if !CONFIG_IS_ENABLED(AHCI)
 int sata_initialize(void)
 {
int err, i;
@@ -246,6 +251,7 @@ int sata_stop(void)
 
return 0;
 }
+# endif
 #else
 static int cm_fx6_setup_issd(void) { return 0; }
 #endif
@@ -757,3 +763,66 @@ U_BOOT_DEVICE(cm_fx6_serial) = {
.name   = "serial_mxc",
.platdata = _fx6_mxc_serial_plat,
 };
+
+#if CONFIG_IS_ENABLED(AHCI)
+static int sata_imx_probe(struct udevice *dev)
+{
+   int i, err;
+
+   /* Make sure this gpio has logical 0 value */
+   gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 0);
+   udelay(100);
+   cm_fx6_sata_power(1);
+
+   for (i = 0; i < CM_FX6_SATA_INIT_RETRIES; i++) {
+   err = setup_sata();
+   if (err) {
+   printf("SATA setup failed: %d\n", err);
+   return err;
+   }
+
+   udelay(100);
+
+   err = dwc_ahsata_probe(dev);
+   if (!err)
+   break;
+
+   /* There is no device on the SATA port */
+   if (sata_dm_port_status(0, 0) == 0)
+   break;
+
+   /* There's a device, but link not established. Retry */
+   device_remove(dev, DM_REMOVE_NORMAL);
+   }
+
+   return 0;
+}
+
+static int sata_imx_remove(struct udevice *dev)
+{
+   cm_fx6_sata_power(0);
+   mdelay(250);
+
+   return 0;
+}
+
+struct ahci_ops sata_imx_ops = {
+   .port_status = dwc_ahsata_port_status,
+   .reset  = dwc_ahsata_bus_reset,
+   .scan   = dwc_ahsata_scan,
+};
+
+static const struct udevice_id sata_imx_ids[] = {
+   { .compatible = "fsl,imx6q-ahci" },
+   { }
+};
+
+U_BOOT_DRIVER(sata_imx) = {
+   .name   = "dwc_ahci",
+   .id = UCLASS_AHCI,
+   .of_match   = sata_imx_ids,
+   .ops= _imx_ops,
+   .probe  = sata_imx_probe,
+   .remove = sata_imx_remove,  /* reset bus to stop it */
+};
+#endif /* AHCI */
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 25/40] dm: sata: dwc_ahsata: Add support for driver model

2017-07-29 Thread Simon Glass
Update this driver to support driver model. This involves implementing the
AHCI operations and reusing existing common code.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 113 +++
 include/dwc_ahsata.h |  16 +++
 2 files changed, 129 insertions(+)
 create mode 100644 include/dwc_ahsata.h

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 1e3ddd75db..480ae115af 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -7,6 +7,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -845,6 +847,7 @@ static ulong sata_write_common(struct ahci_uc_priv *uc_priv,
return rc;
 }
 
+#if !CONFIG_IS_ENABLED(AHCI)
 static int ahci_init_one(int pdev)
 {
int rc;
@@ -964,3 +967,113 @@ int scan_sata(int dev)
 
return dwc_ahsata_scan_common(uc_priv, pdev);
 }
+#endif /* CONFIG_IS_ENABLED(AHCI) */
+
+#if CONFIG_IS_ENABLED(AHCI)
+
+int dwc_ahsata_port_status(struct udevice *dev, int port)
+{
+   struct ahci_uc_priv *uc_priv = dev_get_uclass_priv(dev);
+   struct sata_port_regs *port_mmio;
+
+   port_mmio = uc_priv->port[port].port_mmio;
+   return readl(_mmio->ssts) & SATA_PORT_SSTS_DET_MASK ? 0 : -ENXIO;
+}
+
+int dwc_ahsata_bus_reset(struct udevice *dev)
+{
+   struct ahci_uc_priv *uc_priv = dev_get_uclass_priv(dev);
+   struct sata_host_regs *host_mmio = uc_priv->mmio_base;
+
+   setbits_le32(_mmio->ghc, SATA_HOST_GHC_HR);
+   while (readl(_mmio->ghc) & SATA_HOST_GHC_HR)
+   udelay(100);
+
+   return 0;
+}
+
+int dwc_ahsata_scan(struct udevice *dev)
+{
+   struct ahci_uc_priv *uc_priv = dev_get_uclass_priv(dev);
+   struct blk_desc *desc;
+   struct udevice *blk;
+   int ret;
+
+   /*
+   * Create only one block device and do detection
+   * to make sure that there won't be a lot of
+   * block devices created
+   */
+   device_find_first_child(dev, );
+   if (!blk) {
+   ret = blk_create_devicef(dev, "dwc_ahsata_blk", "blk",
+IF_TYPE_SATA, -1, 512, 0, );
+   if (ret) {
+   debug("Can't create device\n");
+   return ret;
+   }
+   }
+
+   desc = dev_get_uclass_platdata(blk);
+   ret = dwc_ahsata_scan_common(uc_priv, desc);
+   if (ret) {
+   debug("%s: Failed to scan bus\n", __func__);
+   return ret;
+   }
+
+   return 0;
+}
+
+int dwc_ahsata_probe(struct udevice *dev)
+{
+   struct ahci_uc_priv *uc_priv = dev_get_uclass_priv(dev);
+   int ret;
+
+   uc_priv->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+   ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | ATA_FLAG_NO_ATAPI;
+   uc_priv->mmio_base = (void __iomem *)dev_read_addr(dev);
+
+   /* initialize adapter */
+   ret = ahci_host_init(uc_priv);
+   if (ret)
+   return ret;
+
+   ahci_print_info(uc_priv);
+
+   return dwc_ahci_start_ports(uc_priv);
+}
+
+static ulong dwc_ahsata_read(struct udevice *blk, lbaint_t blknr,
+lbaint_t blkcnt, void *buffer)
+{
+   struct blk_desc *desc = dev_get_uclass_platdata(blk);
+   struct udevice *dev = dev_get_parent(blk);
+   struct ahci_uc_priv *uc_priv;
+
+   uc_priv = dev_get_uclass_priv(dev);
+   return sata_read_common(uc_priv, desc, blknr, blkcnt, buffer);
+}
+
+static ulong dwc_ahsata_write(struct udevice *blk, lbaint_t blknr,
+ lbaint_t blkcnt, const void *buffer)
+{
+   struct blk_desc *desc = dev_get_uclass_platdata(blk);
+   struct udevice *dev = dev_get_parent(blk);
+   struct ahci_uc_priv *uc_priv;
+
+   uc_priv = dev_get_uclass_priv(dev);
+   return sata_write_common(uc_priv, desc, blknr, blkcnt, buffer);
+}
+
+static const struct blk_ops dwc_ahsata_blk_ops = {
+   .read   = dwc_ahsata_read,
+   .write  = dwc_ahsata_write,
+};
+
+U_BOOT_DRIVER(dwc_ahsata_blk) = {
+   .name   = "dwc_ahsata_blk",
+   .id = UCLASS_BLK,
+   .ops= _ahsata_blk_ops,
+};
+
+#endif
diff --git a/include/dwc_ahsata.h b/include/dwc_ahsata.h
new file mode 100644
index 00..cae275fe75
--- /dev/null
+++ b/include/dwc_ahsata.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2017 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __DWC_AHSATA_H__
+#define __DWC_AHSATA_H__
+
+int dwc_ahsata_bus_reset(struct udevice *dev);
+int dwc_ahsata_probe(struct udevice *dev);
+int dwc_ahsata_scan(struct udevice *dev);
+int dwc_ahsata_port_status(struct udevice *dev, int port);
+
+#endif
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 27/40] dm: mmc: fsl_esdhc: Set up common versions of operations

2017-07-29 Thread Simon Glass
Driver model wants to use the core functions in this file but accesses the
driver-private data in a different way. Move the code into new 'common'
functions and set up stubs to call these. Also sort the operations into
alphabetical order for consistency.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/fsl_esdhc.c | 47 ---
 1 file changed, 36 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index bb93b09f51..c3a1f31d37 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -348,13 +348,12 @@ static void check_and_invalidate_dcache_range
  * Sends a command out on the bus.  Takes the mmc pointer,
  * a command pointer, and an optional data pointer.
  */
-static int
-esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
+struct mmc_cmd *cmd, struct mmc_data *data)
 {
int err = 0;
uintxfertyp;
uintirqstat;
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
 
 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC111
@@ -595,9 +594,8 @@ static void esdhc_clock_control(struct fsl_esdhc_priv 
*priv, bool enable)
 }
 #endif
 
-static int esdhc_set_ios(struct mmc *mmc)
+static int esdhc_set_ios_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
 {
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
 
 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
@@ -620,9 +618,8 @@ static int esdhc_set_ios(struct mmc *mmc)
return 0;
 }
 
-static int esdhc_init(struct mmc *mmc)
+static int esdhc_init_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
 {
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
int timeout = 1000;
 
@@ -676,9 +673,8 @@ static int esdhc_init(struct mmc *mmc)
return 0;
 }
 
-static int esdhc_getcd(struct mmc *mmc)
+static int esdhc_getcd_common(struct fsl_esdhc_priv *priv)
 {
-   struct fsl_esdhc_priv *priv = mmc->priv;
struct fsl_esdhc *regs = priv->esdhc_regs;
int timeout = 1000;
 
@@ -716,11 +712,40 @@ static void esdhc_reset(struct fsl_esdhc *regs)
printf("MMC/SD: Reset never completed.\n");
 }
 
+static int esdhc_getcd(struct mmc *mmc)
+{
+   struct fsl_esdhc_priv *priv = mmc->priv;
+
+   return esdhc_getcd_common(priv);
+}
+
+static int esdhc_init(struct mmc *mmc)
+{
+   struct fsl_esdhc_priv *priv = mmc->priv;
+
+   return esdhc_init_common(priv, mmc);
+}
+
+static int esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+ struct mmc_data *data)
+{
+   struct fsl_esdhc_priv *priv = mmc->priv;
+
+   return esdhc_send_cmd_common(priv, mmc, cmd, data);
+}
+
+static int esdhc_set_ios(struct mmc *mmc)
+{
+   struct fsl_esdhc_priv *priv = mmc->priv;
+
+   return esdhc_set_ios_common(priv, mmc);
+}
+
 static const struct mmc_ops esdhc_ops = {
+   .getcd  = esdhc_getcd,
+   .init   = esdhc_init,
.send_cmd   = esdhc_send_cmd,
.set_ios= esdhc_set_ios,
-   .init   = esdhc_init,
-   .getcd  = esdhc_getcd,
 };
 
 static int fsl_esdhc_init(struct fsl_esdhc_priv *priv)
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 21/40] dm: sata: dw_sata: Set up common versions of operations

2017-07-29 Thread Simon Glass
Driver model wants to use the core functions in this file but accesses the
uclass-private data in a different way. Move the code into new 'common'
functions and set up stubs to call these.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 236 ++-
 1 file changed, 131 insertions(+), 105 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 2695bef222..1e3ddd75db 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -720,6 +721,130 @@ static u32 ata_low_level_rw_lba28(struct ahci_uc_priv 
*uc_priv, u32 blknr,
return blkcnt;
 }
 
+static int dwc_ahci_start_ports(struct ahci_uc_priv *uc_priv)
+{
+   u32 linkmap;
+   int i;
+
+   linkmap = uc_priv->link_port_map;
+
+   if (0 == linkmap) {
+   printf("No port device detected!\n");
+   return -ENXIO;
+   }
+
+   for (i = 0; i < uc_priv->n_ports; i++) {
+   if ((linkmap >> i) && ((linkmap >> i) & 0x01)) {
+   if (ahci_port_start(uc_priv, (u8)i)) {
+   printf("Can not start port %d\n", i);
+   return 1;
+   }
+   uc_priv->hard_port_no = i;
+   break;
+   }
+   }
+
+   return 0;
+}
+
+static int dwc_ahsata_scan_common(struct ahci_uc_priv *uc_priv,
+ struct blk_desc *pdev)
+{
+   u8 serial[ATA_ID_SERNO_LEN + 1] = { 0 };
+   u8 firmware[ATA_ID_FW_REV_LEN + 1] = { 0 };
+   u8 product[ATA_ID_PROD_LEN + 1] = { 0 };
+   u64 n_sectors;
+   u8 port = uc_priv->hard_port_no;
+   ALLOC_CACHE_ALIGN_BUFFER(u16, id, ATA_ID_WORDS);
+
+   /* Identify device to get information */
+   dwc_ahsata_identify(uc_priv, id);
+
+   /* Serial number */
+   ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
+   memcpy(pdev->product, serial, sizeof(serial));
+
+   /* Firmware version */
+   ata_id_c_string(id, firmware, ATA_ID_FW_REV, sizeof(firmware));
+   memcpy(pdev->revision, firmware, sizeof(firmware));
+
+   /* Product model */
+   ata_id_c_string(id, product, ATA_ID_PROD, sizeof(product));
+   memcpy(pdev->vendor, product, sizeof(product));
+
+   /* Totoal sectors */
+   n_sectors = ata_id_n_sectors(id);
+   pdev->lba = (u32)n_sectors;
+
+   pdev->type = DEV_TYPE_HARDDISK;
+   pdev->blksz = ATA_SECT_SIZE;
+   pdev->lun = 0;
+
+   /* Check if support LBA48 */
+   if (ata_id_has_lba48(id)) {
+   pdev->lba48 = 1;
+   debug("Device support LBA48\n\r");
+   }
+
+   /* Get the NCQ queue depth from device */
+   uc_priv->flags &= (~SATA_FLAG_Q_DEP_MASK);
+   uc_priv->flags |= ata_id_queue_depth(id);
+
+   /* Get the xfer mode from device */
+   dwc_ahsata_xfer_mode(uc_priv, id);
+
+   /* Get the write cache status from device */
+   dwc_ahsata_init_wcache(uc_priv, id);
+
+   /* Set the xfer mode to highest speed */
+   ahci_set_feature(uc_priv, port);
+
+   dwc_ahsata_print_info(pdev);
+
+   return 0;
+}
+
+/*
+ * SATA interface between low level driver and command layer
+ */
+static ulong sata_read_common(struct ahci_uc_priv *uc_priv,
+ struct blk_desc *desc, ulong blknr,
+ lbaint_t blkcnt, void *buffer)
+{
+   u32 rc;
+
+   if (desc->lba48)
+   rc = ata_low_level_rw_lba48(uc_priv, blknr, blkcnt, buffer,
+   READ_CMD);
+   else
+   rc = ata_low_level_rw_lba28(uc_priv, blknr, blkcnt, buffer,
+   READ_CMD);
+
+   return rc;
+}
+
+static ulong sata_write_common(struct ahci_uc_priv *uc_priv,
+  struct blk_desc *desc, ulong blknr,
+  lbaint_t blkcnt, const void *buffer)
+{
+   u32 rc;
+   u32 flags = uc_priv->flags;
+
+   if (desc->lba48) {
+   rc = ata_low_level_rw_lba48(uc_priv, blknr, blkcnt, buffer,
+   WRITE_CMD);
+   if ((flags & SATA_FLAG_WCACHE) && (flags & SATA_FLAG_FLUSH_EXT))
+   dwc_ahsata_flush_cache_ext(uc_priv);
+   } else {
+   rc = ata_low_level_rw_lba28(uc_priv, blknr, blkcnt, buffer,
+   WRITE_CMD);
+   if ((flags & SATA_FLAG_WCACHE) && (flags & SATA_FLAG_FLUSH))
+   dwc_ahsata_flush_cache(uc_priv);
+   }
+
+   return rc;
+}
+
 static int ahci_init_one(int pdev)
 {
int rc;
@@ -755,8 +880,6 @@ err_out:
 
 int init_sata(int dev)
 {
-   int i;
-   u32 linkmap;
struct ahci_uc_priv 

[U-Boot] [PATCH v2 39/40] dm: mmc: Correct Kconfig condition for SPL_DM_MMC_OPS

2017-07-29 Thread Simon Glass
This should depend on SPL_DM_MMC, not SPL_DM. For it and update the only
affected board's defconfig.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 configs/Linksprite_pcDuino3_defconfig | 3 ---
 drivers/mmc/Kconfig   | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/configs/Linksprite_pcDuino3_defconfig 
b/configs/Linksprite_pcDuino3_defconfig
index f0d382c002..fb81bad00f 100644
--- a/configs/Linksprite_pcDuino3_defconfig
+++ b/configs/Linksprite_pcDuino3_defconfig
@@ -15,10 +15,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
-# CONFIG_SPL_BLK is not set
 CONFIG_DM_MMC=y
-# CONFIG_SPL_DM_MMC is not set
-# CONFIG_SPL_DM_MMC_OPS is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 0902a5a103..5a526945b7 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -43,7 +43,7 @@ config SPL_DM_MMC
 
 config SPL_DM_MMC_OPS
bool "Support MMC controller operations using Driver Model in SPL"
-   depends on SPL_DM && DM_MMC_OPS
+   depends on SPL_DM_MMC && DM_MMC_OPS
default y
help
  Driver model provides a means of supporting device operations. This
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 24/40] dm: sata: Update the AHCI uclass to support operations

2017-07-29 Thread Simon Glass
At present the AHCI uclass is just a shell and we still use the global
functions to access SATA. Fix this by adding operations to the uclass.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/sata.c | 37 +
 include/ahci.h | 54 ++
 2 files changed, 91 insertions(+)

diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
index 42ff5c7755..b3ebc05ead 100644
--- a/drivers/ata/sata.c
+++ b/drivers/ata/sata.c
@@ -11,17 +11,52 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
+#ifndef CONFIG_AHCI
 struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
+#endif
+
+int sata_reset(struct udevice *dev)
+{
+   struct ahci_ops *ops = ahci_get_ops(dev);
+
+   if (!ops->reset)
+   return -ENOSYS;
+
+   return ops->reset(dev);
+}
+
+int sata_dm_port_status(struct udevice *dev, int port)
+{
+   struct ahci_ops *ops = ahci_get_ops(dev);
+
+   if (!ops->port_status)
+   return -ENOSYS;
 
+   return ops->port_status(dev, port);
+}
+
+int sata_scan(struct udevice *dev)
+{
+   struct ahci_ops *ops = ahci_get_ops(dev);
+
+   if (!ops->scan)
+   return -ENOSYS;
+
+   return ops->scan(dev);
+}
+
+#ifndef CONFIG_AHCI
 #ifdef CONFIG_PARTITIONS
 struct blk_desc *sata_get_dev(int dev)
 {
return (dev < CONFIG_SYS_SATA_MAX_DEVICE) ? _dev_desc[dev] : NULL;
 }
 #endif
+#endif
 
 #ifdef CONFIG_BLK
 static unsigned long sata_bread(struct udevice *dev, lbaint_t start,
@@ -49,6 +84,7 @@ static unsigned long sata_bwrite(struct blk_desc *block_dev, 
lbaint_t start,
 }
 #endif
 
+#ifndef CONFIG_AHCI
 int __sata_initialize(void)
 {
int rc, ret = -1;
@@ -95,6 +131,7 @@ __weak int __sata_stop(void)
return err;
 }
 int sata_stop(void) __attribute__((weak, alias("__sata_stop")));
+#endif
 
 #ifdef CONFIG_BLK
 static const struct blk_ops sata_blk_ops = {
diff --git a/include/ahci.h b/include/ahci.h
index 29f4ba1d13..33171b7ffd 100644
--- a/include/ahci.h
+++ b/include/ahci.h
@@ -176,6 +176,60 @@ struct ahci_uc_priv {
u32 link_port_map; /*linkup port map*/
 };
 
+struct ahci_ops {
+   /**
+* reset() - reset the controller
+*
+* @dev:Controller to reset
+* @return 0 if OK, -ve on error
+*/
+   int (*reset)(struct udevice *dev);
+
+   /**
+* port_status() - get the status of a SATA port
+*
+* @dev:Controller to reset
+* @port:   Port number to check (0 for first)
+* @return 0 if detected, -ENXIO if nothing on port, other -ve on error
+*/
+   int (*port_status)(struct udevice *dev, int port);
+
+   /**
+* scan() - scan SATA ports
+*
+* @dev:Controller to scan
+* @return 0 if OK, -ve on error
+*/
+   int (*scan)(struct udevice *dev);
+};
+
+#define ahci_get_ops(dev)((struct ahci_ops *)(dev)->driver->ops)
+
+/**
+ * sata_reset() - reset the controller
+ *
+ * @dev:   Controller to reset
+ * @return 0 if OK, -ve on error
+ */
+int sata_reset(struct udevice *dev);
+
+/**
+ * sata_port_status() - get the status of a SATA port
+ *
+ * @dev:   Controller to reset
+ * @port:  Port number to check (0 for first)
+ * @return 0 if detected, -ENXIO if nothin on port, other -ve on error
+ */
+int sata_dm_port_status(struct udevice *dev, int port);
+
+/**
+ * sata_scan() - scan SATA ports
+ *
+ * @dev:   Controller to scan
+ * @return 0 if OK, -ve on error
+ */
+int sata_scan(struct udevice *dev);
+
 int ahci_init(void __iomem *base);
 int ahci_reset(void __iomem *base);
 
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 14/40] dm: sata: dw_sata: Drop unnecessary casts

2017-07-29 Thread Simon Glass
Most of the casts in this driver are not necessary. With driver model we
do not cast from void *. Update the driver to follow this rule.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 60 ++--
 1 file changed, 22 insertions(+), 38 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 2eb9c81957..8db894b16f 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -102,8 +102,7 @@ static int waiting_for_cmd_completed(u8 *offset,
 
 static int ahci_setup_oobr(struct ahci_uc_priv *uc_priv, int clk)
 {
-   struct sata_host_regs *host_mmio =
-   (struct sata_host_regs *)uc_priv->mmio_base;
+   struct sata_host_regs *host_mmio = uc_priv->mmio_base;
 
writel(SATA_HOST_OOBR_WE, &(host_mmio->oobr));
writel(0x02060b14, &(host_mmio->oobr));
@@ -116,8 +115,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
u32 tmp, cap_save, num_ports;
int i, j, timeout = 1000;
struct sata_port_regs *port_mmio = NULL;
-   struct sata_host_regs *host_mmio =
-   (struct sata_host_regs *)uc_priv->mmio_base;
+   struct sata_host_regs *host_mmio = uc_priv->mmio_base;
int clk = mxc_get_clock(MXC_SATA_CLK);
 
cap_save = readl(&(host_mmio->cap));
@@ -165,8 +163,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 
for (i = 0; i < uc_priv->n_ports; i++) {
uc_priv->port[i].port_mmio = ahci_port_base(host_mmio, i);
-   port_mmio =
-   (struct sata_port_regs *)uc_priv->port[i].port_mmio;
+   port_mmio = uc_priv->port[i].port_mmio;
 
/* Ensure that the DWC_ahsata is in idle state */
tmp = readl(&(port_mmio->cmd));
@@ -274,8 +271,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 
 static void ahci_print_info(struct ahci_uc_priv *uc_priv)
 {
-   struct sata_host_regs *host_mmio =
-   (struct sata_host_regs *)uc_priv->mmio_base;
+   struct sata_host_regs *host_mmio = uc_priv->mmio_base;
u32 vers, cap, impl, speed;
const char *speed_s;
const char *scc_s;
@@ -350,7 +346,7 @@ static int ahci_init_one(int pdev)
ahci_print_info(uc_priv);
 
/* Save the uc_private struct to block device struct */
-   sata_dev_desc[pdev].priv = (void *)uc_priv;
+   sata_dev_desc[pdev].priv = uc_priv;
 
return 0;
 
@@ -410,8 +406,7 @@ static int ahci_exec_ata_cmd(struct ahci_uc_priv *uc_priv, 
u8 port,
 s32 is_write)
 {
struct ahci_ioports *pp = &(uc_priv->port[port]);
-   struct sata_port_regs *port_mmio =
-   (struct sata_port_regs *)pp->port_mmio;
+   struct sata_port_regs *port_mmio = pp->port_mmio;
u32 opts;
int sg_count = 0, cmd_slot = 0;
 
@@ -458,8 +453,7 @@ static int ahci_exec_ata_cmd(struct ahci_uc_priv *uc_priv, 
u8 port,
 
 static void ahci_set_feature(u8 dev, u8 port)
 {
-   struct ahci_uc_priv *uc_priv =
-   (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
+   struct ahci_uc_priv *uc_priv = sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = 
 
@@ -476,8 +470,7 @@ static void ahci_set_feature(u8 dev, u8 port)
 static int ahci_port_start(struct ahci_uc_priv *uc_priv, u8 port)
 {
struct ahci_ioports *pp = &(uc_priv->port[port]);
-   struct sata_port_regs *port_mmio =
-   (struct sata_port_regs *)pp->port_mmio;
+   struct sata_port_regs *port_mmio = pp->port_mmio;
u32 port_status;
u32 mem;
int timeout = 1000;
@@ -570,8 +563,7 @@ static void dwc_ahsata_print_info(int dev)
 
 static void dwc_ahsata_identify(int dev, u16 *id)
 {
-   struct ahci_uc_priv *uc_priv =
-   (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
+   struct ahci_uc_priv *uc_priv = sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
struct sata_fis_h2d *cfis = 
u8 port = uc_priv->hard_port_no;
@@ -589,8 +581,7 @@ static void dwc_ahsata_identify(int dev, u16 *id)
 
 static void dwc_ahsata_xfer_mode(int dev, u16 *id)
 {
-   struct ahci_uc_priv *uc_priv =
-   (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
+   struct ahci_uc_priv *uc_priv = sata_dev_desc[dev].priv;
 
uc_priv->pio_mask = id[ATA_ID_PIO_MODES];
uc_priv->udma_mask = id[ATA_ID_UDMA_MODES];
@@ -600,8 +591,7 @@ static void dwc_ahsata_xfer_mode(int dev, u16 *id)
 static u32 dwc_ahsata_rw_cmd(int dev, u32 start, u32 blkcnt,
u8 *buffer, int is_write)
 {
-   struct ahci_uc_priv *uc_priv =
-   (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
+   struct ahci_uc_priv *uc_priv = sata_dev_desc[dev].priv;
struct sata_fis_h2d h2d 

[U-Boot] [PATCH v2 06/40] dm: ide: Adjust the 'ide' command to use blk_common_cmd()

2017-07-29 Thread Simon Glass
Instead of having separate code in the 'ide' command, adjust it to use
the common function.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 cmd/ide.c | 107 ++
 1 file changed, 3 insertions(+), 104 deletions(-)

diff --git a/cmd/ide.c b/cmd/ide.c
index 10fb2f95a7..e3c32420cf 100644
--- a/cmd/ide.c
+++ b/cmd/ide.c
@@ -34,116 +34,15 @@ static int curr_device = -1;
 
 int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
-   int rcode = 0;
-
-   switch (argc) {
-   case 0:
-   case 1:
-   return CMD_RET_USAGE;
-   case 2:
+   if (argc == 2) {
if (strncmp(argv[1], "res", 3) == 0) {
puts("\nReset IDE: ");
ide_init();
return 0;
-   } else if (strncmp(argv[1], "inf", 3) == 0) {
-   blk_list_devices(IF_TYPE_IDE);
-   return 0;
-
-   } else if (strncmp(argv[1], "dev", 3) == 0) {
-   if (blk_print_device_num(IF_TYPE_IDE, curr_device)) {
-   printf("\nno IDE devices available\n");
-   return CMD_RET_FAILURE;
-   }
-
-   return 0;
-   } else if (strncmp(argv[1], "part", 4) == 0) {
-   if (blk_list_part(IF_TYPE_IDE))
-   printf("\nno IDE devices available\n");
-   return 1;
}
-   return CMD_RET_USAGE;
-   case 3:
-   if (strncmp(argv[1], "dev", 3) == 0) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-   if (!blk_show_device(IF_TYPE_IDE, dev)) {
-   curr_device = dev;
-   printf("... is now current device\n");
-   } else {
-   return CMD_RET_FAILURE;
-   }
-   return 0;
-   } else if (strncmp(argv[1], "part", 4) == 0) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-   if (blk_print_part_devnum(IF_TYPE_IDE, dev)) {
-   printf("\nIDE device %d not available\n", dev);
-   return CMD_RET_FAILURE;
-   }
-   return 1;
-   }
-
-   return CMD_RET_USAGE;
-   default:
-   /* at least 4 args */
-
-   if (strcmp(argv[1], "read") == 0) {
-   ulong addr = simple_strtoul(argv[2], NULL, 16);
-   ulong cnt = simple_strtoul(argv[4], NULL, 16);
-   ulong n;
-
-#ifdef CONFIG_SYS_64BIT_LBA
-   lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
-
-   printf("\nIDE read: device %d block # %lld, count 
%ld...",
-  curr_device, blk, cnt);
-#else
-   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
-
-   printf("\nIDE read: device %d block # %ld, count 
%ld...",
-  curr_device, blk, cnt);
-#endif
-
-   n = blk_read_devnum(IF_TYPE_IDE, curr_device, blk, cnt,
-   (ulong *)addr);
-
-   printf("%ld blocks read: %s\n",
-  n, (n == cnt) ? "OK" : "ERROR");
-   if (n == cnt)
-   return 0;
-   else
-   return 1;
-   } else if (strcmp(argv[1], "write") == 0) {
-   ulong addr = simple_strtoul(argv[2], NULL, 16);
-   ulong cnt = simple_strtoul(argv[4], NULL, 16);
-   ulong n;
-
-#ifdef CONFIG_SYS_64BIT_LBA
-   lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
-
-   printf("\nIDE write: device %d block # %lld, count 
%ld...",
-  curr_device, blk, cnt);
-#else
-   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
-
-   printf("\nIDE write: device %d block # %ld, count 
%ld...",
-  curr_device, blk, cnt);
-#endif
-   n = blk_write_devnum(IF_TYPE_IDE, curr_device, blk, cnt,
-(ulong *)addr);
-
-   printf("%ld blocks written: %s\n", n,
-  n == cnt ? "OK" : "ERROR");
-   if (n == cnt)
-   return 0;
-   else
-   return 1;
-   } else {
-   return CMD_RET_USAGE;
-   }
-
-   return rcode;
  

[U-Boot] [PATCH v2 30/40] dm: mmc: fsl_esdhc: Set up platform data

2017-07-29 Thread Simon Glass
With driver model we want to store the mmc and configuration structure in
platform data. Set up structure up and use it for non-DM as well.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/mmc/fsl_esdhc.c | 61 +++--
 1 file changed, 39 insertions(+), 22 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 1cf0faea81..409231e93d 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -81,6 +81,11 @@ struct fsl_esdhc {
uintscr;/* eSDHC control register */
 };
 
+struct fsl_esdhc_plat {
+   struct mmc_config cfg;
+   struct mmc mmc;
+};
+
 /**
  * struct fsl_esdhc_priv
  *
@@ -101,7 +106,6 @@ struct fsl_esdhc_priv {
struct fsl_esdhc *esdhc_regs;
unsigned int sdhc_clk;
unsigned int bus_width;
-   struct mmc_config cfg;
struct mmc *mmc;
struct udevice *dev;
int non_removable;
@@ -756,8 +760,10 @@ static const struct mmc_ops esdhc_ops = {
.set_ios= esdhc_set_ios,
 };
 
-static int fsl_esdhc_init(struct fsl_esdhc_priv *priv)
+static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
+ struct fsl_esdhc_plat *plat)
 {
+   struct mmc_config *cfg;
struct fsl_esdhc *regs;
struct mmc *mmc;
u32 caps, voltage_caps;
@@ -785,7 +791,8 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv)
esdhc_setbits32(>vendorspec, ESDHC_VENDORSPEC_VSELECT);
 
writel(SDHCI_IRQ_EN_BITS, >irqstaten);
-   memset(>cfg, 0, sizeof(priv->cfg));
+   cfg = >cfg;
+   memset(cfg, '\0', sizeof(*cfg));
 
voltage_caps = 0;
caps = esdhc_read32(>hostcapblt);
@@ -807,49 +814,49 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv)
if (caps & ESDHC_HOSTCAPBLT_VS33)
voltage_caps |= MMC_VDD_32_33 | MMC_VDD_33_34;
 
-   priv->cfg.name = "FSL_SDHC";
-   priv->cfg.ops = _ops;
+   cfg->name = "FSL_SDHC";
+   cfg->ops = _ops;
 #ifdef CONFIG_SYS_SD_VOLTAGE
-   priv->cfg.voltages = CONFIG_SYS_SD_VOLTAGE;
+   cfg->voltages = CONFIG_SYS_SD_VOLTAGE;
 #else
-   priv->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
+   cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 #endif
-   if ((priv->cfg.voltages & voltage_caps) == 0) {
+   if ((cfg->voltages & voltage_caps) == 0) {
printf("voltage not supported by controller\n");
return -1;
}
 
if (priv->bus_width == 8)
-   priv->cfg.host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
+   cfg->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
else if (priv->bus_width == 4)
-   priv->cfg.host_caps = MMC_MODE_4BIT;
+   cfg->host_caps = MMC_MODE_4BIT;
 
-   priv->cfg.host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
+   cfg->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
 #ifdef CONFIG_SYS_FSL_ESDHC_HAS_DDR_MODE
-   priv->cfg.host_caps |= MMC_MODE_DDR_52MHz;
+   cfg->host_caps |= MMC_MODE_DDR_52MHz;
 #endif
 
if (priv->bus_width > 0) {
if (priv->bus_width < 8)
-   priv->cfg.host_caps &= ~MMC_MODE_8BIT;
+   cfg->host_caps &= ~MMC_MODE_8BIT;
if (priv->bus_width < 4)
-   priv->cfg.host_caps &= ~MMC_MODE_4BIT;
+   cfg->host_caps &= ~MMC_MODE_4BIT;
}
 
if (caps & ESDHC_HOSTCAPBLT_HSS)
-   priv->cfg.host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
+   cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
 #ifdef CONFIG_ESDHC_DETECT_8_BIT_QUIRK
if (CONFIG_ESDHC_DETECT_8_BIT_QUIRK)
-   priv->cfg.host_caps &= ~MMC_MODE_8BIT;
+   cfg->host_caps &= ~MMC_MODE_8BIT;
 #endif
 
-   priv->cfg.f_min = 40;
-   priv->cfg.f_max = min(priv->sdhc_clk, (u32)5200);
+   cfg->f_min = 40;
+   cfg->f_max = min(priv->sdhc_clk, (u32)5200);
 
-   priv->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
+   cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
-   mmc = mmc_create(>cfg, priv);
+   mmc = mmc_create(cfg, priv);
if (mmc == NULL)
return -1;
 
@@ -876,6 +883,7 @@ static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,
 
 int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
 {
+   struct fsl_esdhc_plat *plat;
struct fsl_esdhc_priv *priv;
int ret;
 
@@ -885,17 +893,24 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg 
*cfg)
priv = calloc(sizeof(struct fsl_esdhc_priv), 1);
if (!priv)
return -ENOMEM;
+   plat = calloc(sizeof(struct fsl_esdhc_plat), 1);
+   if (!plat) {
+   free(priv);
+   return -ENOMEM;
+   }
 
ret = fsl_esdhc_cfg_to_priv(cfg, priv);
if (ret) {
debug("%s xlate failure\n", __func__);
+  

[U-Boot] [PATCH v2 04/40] dm: sata: Adjust the 'sata' command to use blk_common_cmd()

2017-07-29 Thread Simon Glass
Instead of having separate code in the 'sata' command, adjust it to use
the common function.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 cmd/sata.c | 83 +-
 1 file changed, 1 insertion(+), 82 deletions(-)

diff --git a/cmd/sata.c b/cmd/sata.c
index 4c53022ff6..d34a56dccc 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -40,88 +40,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
sata_curr_device = rc;
}
 
-   switch (argc) {
-   case 0:
-   case 1:
-   return CMD_RET_USAGE;
-   case 2:
-   if (strncmp(argv[1], "inf", 3) == 0) {
-   blk_list_devices(IF_TYPE_SATA);
-   return 0;
-   } else if (strncmp(argv[1], "dev", 3) == 0) {
-   if (blk_print_device_num(IF_TYPE_SATA,
-sata_curr_device)) {
-   printf("\nno SATA devices available\n");
-   return CMD_RET_FAILURE;
-   }
-   return 0;
-   } else if (strncmp(argv[1], "part", 4) == 0) {
-   if (blk_list_part(IF_TYPE_SATA))
-   puts("\nno SATA devices available\n");
-   return 0;
-   }
-   return CMD_RET_USAGE;
-   case 3:
-   if (strncmp(argv[1], "dev", 3) == 0) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-   if (!blk_show_device(IF_TYPE_SATA, dev)) {
-   sata_curr_device = dev;
-   printf("... is now current device\n");
-   } else {
-   return CMD_RET_FAILURE;
-   }
-   return 0;
-   } else if (strncmp(argv[1], "part", 4) == 0) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-   if (blk_print_part_devnum(IF_TYPE_SATA, dev)) {
-   printf("\nSATA device %d not available\n",
-  dev);
-   return CMD_RET_FAILURE;
-   }
-   return rc;
-   }
-   return CMD_RET_USAGE;
-
-   default: /* at least 4 args */
-   if (strcmp(argv[1], "read") == 0) {
-   ulong addr = simple_strtoul(argv[2], NULL, 16);
-   ulong cnt = simple_strtoul(argv[4], NULL, 16);
-   ulong n;
-   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
-
-   printf("\nSATA read: device %d block # %ld, count %ld 
... ",
-   sata_curr_device, blk, cnt);
-
-   n = blk_read_devnum(IF_TYPE_SATA, sata_curr_device, blk,
-   cnt, (ulong *)addr);
-
-   printf("%ld blocks read: %s\n",
-   n, (n==cnt) ? "OK" : "ERROR");
-   return (n == cnt) ? 0 : 1;
-   } else if (strcmp(argv[1], "write") == 0) {
-   ulong addr = simple_strtoul(argv[2], NULL, 16);
-   ulong cnt = simple_strtoul(argv[4], NULL, 16);
-   ulong n;
-
-   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
-
-   printf("\nSATA write: device %d block # %ld, count %ld 
... ",
-   sata_curr_device, blk, cnt);
-
-   n = blk_write_devnum(IF_TYPE_SATA, sata_curr_device,
-blk, cnt, (ulong *)addr);
-
-   printf("%ld blocks written: %s\n",
-   n, (n == cnt) ? "OK" : "ERROR");
-   return (n == cnt) ? 0 : 1;
-   } else {
-   return CMD_RET_USAGE;
-   }
-
-   return rc;
-   }
+   return blk_common_cmd(argc, argv, IF_TYPE_SATA, _curr_device);
 }
 
 U_BOOT_CMD(
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 07/40] dm: usb: Adjust the 'usb' command to use blk_common_cmd()

2017-07-29 Thread Simon Glass
Instead of having separate code in the 'usb' command, adjust it to use
the common function.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 cmd/usb.c | 111 ++
 1 file changed, 3 insertions(+), 108 deletions(-)

diff --git a/cmd/usb.c b/cmd/usb.c
index 4fa456e318..c897f99170 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -618,9 +618,6 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
struct usb_device *udev = NULL;
int i;
extern char usb_started;
-#ifdef CONFIG_USB_STORAGE
-   struct blk_desc *stor_dev;
-#endif
 
if (argc < 2)
return CMD_RET_USAGE;
@@ -709,112 +706,10 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
if (strncmp(argv[1], "stor", 4) == 0)
return usb_stor_info();
 
-   if (strncmp(argv[1], "part", 4) == 0) {
-   int devno, ok = 0;
-   if (argc == 2) {
-   for (devno = 0; ; ++devno) {
-   stor_dev = blk_get_devnum_by_type(IF_TYPE_USB,
- devno);
-   if (stor_dev == NULL)
-   break;
-   if (stor_dev->type != DEV_TYPE_UNKNOWN) {
-   ok++;
-   if (devno)
-   printf("\n");
-   debug("print_part of %x\n", devno);
-   part_print(stor_dev);
-   }
-   }
-   } else {
-   devno = simple_strtoul(argv[2], NULL, 16);
-   stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, devno);
-   if (stor_dev != NULL &&
-   stor_dev->type != DEV_TYPE_UNKNOWN) {
-   ok++;
-   debug("print_part of %x\n", devno);
-   part_print(stor_dev);
-   }
-   }
-   if (!ok) {
-   printf("\nno USB devices available\n");
-   return 1;
-   }
-   return 0;
-   }
-   if (strcmp(argv[1], "read") == 0) {
-   if (usb_stor_curr_dev < 0) {
-   printf("no current device selected\n");
-   return 1;
-   }
-   if (argc == 5) {
-   unsigned long addr = simple_strtoul(argv[2], NULL, 16);
-   unsigned long blk  = simple_strtoul(argv[3], NULL, 16);
-   unsigned long cnt  = simple_strtoul(argv[4], NULL, 16);
-   unsigned long n;
-   printf("\nUSB read: device %d block # %ld, count %ld"
-   " ... ", usb_stor_curr_dev, blk, cnt);
-   stor_dev = blk_get_devnum_by_type(IF_TYPE_USB,
- usb_stor_curr_dev);
-   n = blk_dread(stor_dev, blk, cnt, (ulong *)addr);
-   printf("%ld blocks read: %s\n", n,
-   (n == cnt) ? "OK" : "ERROR");
-   if (n == cnt)
-   return 0;
-   return 1;
-   }
-   }
-   if (strcmp(argv[1], "write") == 0) {
-   if (usb_stor_curr_dev < 0) {
-   printf("no current device selected\n");
-   return 1;
-   }
-   if (argc == 5) {
-   unsigned long addr = simple_strtoul(argv[2], NULL, 16);
-   unsigned long blk  = simple_strtoul(argv[3], NULL, 16);
-   unsigned long cnt  = simple_strtoul(argv[4], NULL, 16);
-   unsigned long n;
-   printf("\nUSB write: device %d block # %ld, count %ld"
-   " ... ", usb_stor_curr_dev, blk, cnt);
-   stor_dev = blk_get_devnum_by_type(IF_TYPE_USB,
- usb_stor_curr_dev);
-   n = blk_dwrite(stor_dev, blk, cnt, (ulong *)addr);
-   printf("%ld blocks write: %s\n", n,
-   (n == cnt) ? "OK" : "ERROR");
-   if (n == cnt)
-   return 0;
-   return 1;
-   }
-   }
-   if (strncmp(argv[1], "dev", 3) == 0) {
-   if (argc == 3) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
-   printf("\nUSB device %d: ", dev);
-   stor_dev = 

[U-Boot] [PATCH v2 11/40] dm: sata: dw_sata: Drop dwc_ahsata_rw_ncq_cmd()

2017-07-29 Thread Simon Glass
This function is not called from anywhere. Drop it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 43 ---
 1 file changed, 43 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index b587ec4492..49552ca633 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -750,49 +750,6 @@ static u32 dwc_ahsata_rw_cmd_ext(int dev, u32 start, 
lbaint_t blkcnt,
return 0;
 }
 
-u32 dwc_ahsata_rw_ncq_cmd(int dev, u32 start, lbaint_t blkcnt,
-   u8 *buffer, int is_write)
-{
-   struct ahci_uc_priv *probe_ent =
-   (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
-   struct sata_fis_h2d h2d __aligned(ARCH_DMA_MINALIGN);
-   struct sata_fis_h2d *cfis = 
-   u8 port = probe_ent->hard_port_no;
-   u64 block;
-
-   if (sata_dev_desc[dev].lba48 != 1) {
-   printf("execute FPDMA command on non-LBA48 hard disk\n\r");
-   return -1;
-   }
-
-   block = (u64)start;
-
-   memset(cfis, 0, sizeof(struct sata_fis_h2d));
-
-   cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
-   cfis->pm_port_c = 0x80; /* is command */
-
-   cfis->command = (is_write) ? ATA_CMD_FPDMA_WRITE
-: ATA_CMD_FPDMA_READ;
-
-   cfis->lba_high_exp = (block >> 40) & 0xff;
-   cfis->lba_mid_exp = (block >> 32) & 0xff;
-   cfis->lba_low_exp = (block >> 24) & 0xff;
-   cfis->lba_high = (block >> 16) & 0xff;
-   cfis->lba_mid = (block >> 8) & 0xff;
-   cfis->lba_low = block & 0xff;
-
-   cfis->device = ATA_LBA;
-   cfis->features_exp = (blkcnt >> 8) & 0xff;
-   cfis->features = blkcnt & 0xff;
-
-   /* Use the latest queue */
-   ahci_exec_ata_cmd(probe_ent, port, cfis,
-   buffer, ATA_SECT_SIZE * blkcnt, is_write);
-
-   return blkcnt;
-}
-
 static void dwc_ahsata_flush_cache_ext(int dev)
 {
struct ahci_uc_priv *probe_ent =
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 20/40] dm: sata: dw_sata: More ahci_init_one() futher down

2017-07-29 Thread Simon Glass
This function will not be used with driver model and it relates to the
other exported functions. Move it down next to them.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 66 
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 4b89a8b788..2695bef222 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -316,39 +316,6 @@ static void ahci_print_info(struct ahci_uc_priv *uc_priv)
cap & (1 << 13) ? "part " : "");
 }
 
-static int ahci_init_one(int pdev)
-{
-   int rc;
-   struct ahci_uc_priv *uc_priv = NULL;
-
-   uc_priv = malloc(sizeof(struct ahci_uc_priv));
-   memset(uc_priv, 0, sizeof(struct ahci_uc_priv));
-   uc_priv->dev = pdev;
-
-   uc_priv->host_flags = ATA_FLAG_SATA
-   | ATA_FLAG_NO_LEGACY
-   | ATA_FLAG_MMIO
-   | ATA_FLAG_PIO_DMA
-   | ATA_FLAG_NO_ATAPI;
-
-   uc_priv->mmio_base = (void __iomem *)CONFIG_DWC_AHSATA_BASE_ADDR;
-
-   /* initialize adapter */
-   rc = ahci_host_init(uc_priv);
-   if (rc)
-   goto err_out;
-
-   ahci_print_info(uc_priv);
-
-   /* Save the uc_private struct to block device struct */
-   sata_dev_desc[pdev].priv = uc_priv;
-
-   return 0;
-
-err_out:
-   return rc;
-}
-
 static int ahci_fill_sg(struct ahci_uc_priv *uc_priv, u8 port,
unsigned char *buf, int buf_len)
 {
@@ -753,6 +720,39 @@ static u32 ata_low_level_rw_lba28(struct ahci_uc_priv 
*uc_priv, u32 blknr,
return blkcnt;
 }
 
+static int ahci_init_one(int pdev)
+{
+   int rc;
+   struct ahci_uc_priv *uc_priv = NULL;
+
+   uc_priv = malloc(sizeof(struct ahci_uc_priv));
+   memset(uc_priv, 0, sizeof(struct ahci_uc_priv));
+   uc_priv->dev = pdev;
+
+   uc_priv->host_flags = ATA_FLAG_SATA
+   | ATA_FLAG_NO_LEGACY
+   | ATA_FLAG_MMIO
+   | ATA_FLAG_PIO_DMA
+   | ATA_FLAG_NO_ATAPI;
+
+   uc_priv->mmio_base = (void __iomem *)CONFIG_DWC_AHSATA_BASE_ADDR;
+
+   /* initialize adapter */
+   rc = ahci_host_init(uc_priv);
+   if (rc)
+   goto err_out;
+
+   ahci_print_info(uc_priv);
+
+   /* Save the uc_private struct to block device struct */
+   sata_dev_desc[pdev].priv = uc_priv;
+
+   return 0;
+
+err_out:
+   return rc;
+}
+
 int init_sata(int dev)
 {
int i;
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 23/40] dm: sata: imx: Allow driver model to be used for sata

2017-07-29 Thread Simon Glass
Update the sata call to work with driver model.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 arch/arm/mach-imx/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c
index 9e83b4221e..1017eb84f9 100644
--- a/arch/arm/mach-imx/cpu.c
+++ b/arch/arm/mach-imx/cpu.c
@@ -279,7 +279,7 @@ void arch_preboot_os(void)
imx_pcie_remove();
 #endif
 #if defined(CONFIG_SATA)
-   sata_stop();
+   sata_remove(0);
 #if defined(CONFIG_MX6)
disable_sata_clock();
 #endif
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 09/40] dm: core: Add a comment about the device_remove() flags

2017-07-29 Thread Simon Glass
We should explain which flags are used for this function. Update the
comment to indicate this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 include/dm/device-internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 81ab893b60..eaeadd48d2 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -98,7 +98,7 @@ int device_probe(struct udevice *dev);
  * children are deactivated first.
  *
  * @dev: Pointer to device to remove
- * @flags: Flags for selective device removal
+ * @flags: Flags for selective device removal (DM_REMOVE_...)
  * @return 0 if OK, -ve on error (an error here is normally a very bad thing)
  */
 #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 13/40] dm: sata: dw_sata: Rename 'probe_ent' to uc_priv

2017-07-29 Thread Simon Glass
With driver model this becomes uclass-private data. Rename the parameter
varable to reflect this.

With the driver model conversion we will not have any exported functions.
Move all exported functions to be together at the end of the file so that
we can deal with them in one #ifdef block.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 175 +++
 1 file changed, 85 insertions(+), 90 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 8a030a1d11..2eb9c81957 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -100,11 +100,10 @@ static int waiting_for_cmd_completed(u8 *offset,
return (i < timeout_msec) ? 0 : -1;
 }
 
-static int ahci_setup_oobr(struct ahci_uc_priv *probe_ent,
-   int clk)
+static int ahci_setup_oobr(struct ahci_uc_priv *uc_priv, int clk)
 {
struct sata_host_regs *host_mmio =
-   (struct sata_host_regs *)probe_ent->mmio_base;
+   (struct sata_host_regs *)uc_priv->mmio_base;
 
writel(SATA_HOST_OOBR_WE, &(host_mmio->oobr));
writel(0x02060b14, &(host_mmio->oobr));
@@ -112,13 +111,13 @@ static int ahci_setup_oobr(struct ahci_uc_priv *probe_ent,
return 0;
 }
 
-static int ahci_host_init(struct ahci_uc_priv *probe_ent)
+static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 {
u32 tmp, cap_save, num_ports;
int i, j, timeout = 1000;
struct sata_port_regs *port_mmio = NULL;
struct sata_host_regs *host_mmio =
-   (struct sata_host_regs *)probe_ent->mmio_base;
+   (struct sata_host_regs *)uc_priv->mmio_base;
int clk = mxc_get_clock(MXC_SATA_CLK);
 
cap_save = readl(&(host_mmio->cap));
@@ -141,7 +140,7 @@ static int ahci_host_init(struct ahci_uc_priv *probe_ent)
/* Set timer 1ms */
writel(clk / 1000, &(host_mmio->timer1ms));
 
-   ahci_setup_oobr(probe_ent, 0);
+   ahci_setup_oobr(uc_priv, 0);
 
writel_with_flush(SATA_HOST_GHC_AE, &(host_mmio->ghc));
writel(cap_save, &(host_mmio->cap));
@@ -155,21 +154,19 @@ static int ahci_host_init(struct ahci_uc_priv *probe_ent)
 * software to determine how many Ports are available and
 * which Port registers need to be initialized.
 */
-   probe_ent->cap = readl(&(host_mmio->cap));
-   probe_ent->port_map = readl(&(host_mmio->pi));
+   uc_priv->cap = readl(&(host_mmio->cap));
+   uc_priv->port_map = readl(&(host_mmio->pi));
 
/* Determine how many command slots the HBA supports */
-   probe_ent->n_ports =
-   (probe_ent->cap & SATA_HOST_CAP_NP_MASK) + 1;
+   uc_priv->n_ports = (uc_priv->cap & SATA_HOST_CAP_NP_MASK) + 1;
 
debug("cap 0x%x  port_map 0x%x  n_ports %d\n",
-   probe_ent->cap, probe_ent->port_map, probe_ent->n_ports);
+   uc_priv->cap, uc_priv->port_map, uc_priv->n_ports);
 
-   for (i = 0; i < probe_ent->n_ports; i++) {
-   probe_ent->port[i].port_mmio =
-   ahci_port_base(host_mmio, i);
+   for (i = 0; i < uc_priv->n_ports; i++) {
+   uc_priv->port[i].port_mmio = ahci_port_base(host_mmio, i);
port_mmio =
-   (struct sata_port_regs *)probe_ent->port[i].port_mmio;
+   (struct sata_port_regs *)uc_priv->port[i].port_mmio;
 
/* Ensure that the DWC_ahsata is in idle state */
tmp = readl(&(port_mmio->cmd));
@@ -263,7 +260,7 @@ static int ahci_host_init(struct ahci_uc_priv *probe_ent)
tmp = readl(&(port_mmio->ssts));
debug("Port %d status: 0x%x\n", i, tmp);
if ((tmp & SATA_PORT_SSTS_DET_MASK) == 0x03)
-   probe_ent->link_port_map |= (0x01 << i);
+   uc_priv->link_port_map |= (0x01 << i);
}
 
tmp = readl(&(host_mmio->ghc));
@@ -275,17 +272,17 @@ static int ahci_host_init(struct ahci_uc_priv *probe_ent)
return 0;
 }
 
-static void ahci_print_info(struct ahci_uc_priv *probe_ent)
+static void ahci_print_info(struct ahci_uc_priv *uc_priv)
 {
struct sata_host_regs *host_mmio =
-   (struct sata_host_regs *)probe_ent->mmio_base;
+   (struct sata_host_regs *)uc_priv->mmio_base;
u32 vers, cap, impl, speed;
const char *speed_s;
const char *scc_s;
 
vers = readl(&(host_mmio->vs));
-   cap = probe_ent->cap;
-   impl = probe_ent->port_map;
+   cap = uc_priv->cap;
+   impl = uc_priv->port_map;
 
speed = (cap & SATA_HOST_CAP_ISS_MASK)
>> SATA_HOST_CAP_ISS_OFFSET;
@@ -331,29 +328,29 @@ static void ahci_print_info(struct ahci_uc_priv 
*probe_ent)
 static int ahci_init_one(int pdev)
 {
int rc;
-   struct ahci_uc_priv *probe_ent = NULL;
+   struct 

[U-Boot] [PATCH v2 12/40] dm: sata: dw_sata: Move exported functions to the end

2017-07-29 Thread Simon Glass
With the driver model conversion we will not have any exported functions.
Move all exported functions to be together at the end of the file so that
we can deal with them in one #ifdef block.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 124 +++
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 49552ca633..8a030a1d11 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -556,68 +556,6 @@ static int ahci_port_start(struct ahci_uc_priv *probe_ent,
return 0;
 }
 
-int init_sata(int dev)
-{
-   int i;
-   u32 linkmap;
-   struct ahci_uc_priv *probe_ent = NULL;
-
-#if defined(CONFIG_MX6)
-   if (!is_mx6dq() && !is_mx6dqp())
-   return 1;
-#endif
-   if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1)) {
-   printf("The sata index %d is out of ranges\n\r", dev);
-   return -1;
-   }
-
-   ahci_init_one(dev);
-
-   probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
-   linkmap = probe_ent->link_port_map;
-
-   if (0 == linkmap) {
-   printf("No port device detected!\n");
-   return 1;
-   }
-
-   for (i = 0; i < probe_ent->n_ports; i++) {
-   if ((linkmap >> i) && ((linkmap >> i) & 0x01)) {
-   if (ahci_port_start(probe_ent, (u8)i)) {
-   printf("Can not start port %d\n", i);
-   return 1;
-   }
-   probe_ent->hard_port_no = i;
-   break;
-   }
-   }
-
-   return 0;
-}
-
-int reset_sata(int dev)
-{
-   struct ahci_uc_priv *probe_ent;
-   struct sata_host_regs *host_mmio;
-
-   if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1)) {
-   printf("The sata index %d is out of ranges\n\r", dev);
-   return -1;
-   }
-
-   probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
-   if (NULL == probe_ent)
-   /* not initialized, so nothing to reset */
-   return 0;
-
-   host_mmio = (struct sata_host_regs *)probe_ent->mmio_base;
-   setbits_le32(_mmio->ghc, SATA_HOST_GHC_HR);
-   while (readl(_mmio->ghc) & SATA_HOST_GHC_HR)
-   udelay(100);
-
-   return 0;
-}
-
 static void dwc_ahsata_print_info(int dev)
 {
struct blk_desc *pdev = &(sata_dev_desc[dev]);
@@ -847,6 +785,68 @@ static u32 ata_low_level_rw_lba28(int dev, u32 blknr, 
lbaint_t blkcnt,
return blkcnt;
 }
 
+int init_sata(int dev)
+{
+   int i;
+   u32 linkmap;
+   struct ahci_uc_priv *probe_ent = NULL;
+
+#if defined(CONFIG_MX6)
+   if (!is_mx6dq() && !is_mx6dqp())
+   return 1;
+#endif
+   if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1)) {
+   printf("The sata index %d is out of ranges\n\r", dev);
+   return -1;
+   }
+
+   ahci_init_one(dev);
+
+   probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
+   linkmap = probe_ent->link_port_map;
+
+   if (0 == linkmap) {
+   printf("No port device detected!\n");
+   return 1;
+   }
+
+   for (i = 0; i < probe_ent->n_ports; i++) {
+   if ((linkmap >> i) && ((linkmap >> i) & 0x01)) {
+   if (ahci_port_start(probe_ent, (u8)i)) {
+   printf("Can not start port %d\n", i);
+   return 1;
+   }
+   probe_ent->hard_port_no = i;
+   break;
+   }
+   }
+
+   return 0;
+}
+
+int reset_sata(int dev)
+{
+   struct ahci_uc_priv *probe_ent;
+   struct sata_host_regs *host_mmio;
+
+   if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1)) {
+   printf("The sata index %d is out of ranges\n\r", dev);
+   return -1;
+   }
+
+   probe_ent = (struct ahci_uc_priv *)sata_dev_desc[dev].priv;
+   if (NULL == probe_ent)
+   /* not initialized, so nothing to reset */
+   return 0;
+
+   host_mmio = (struct sata_host_regs *)probe_ent->mmio_base;
+   setbits_le32(_mmio->ghc, SATA_HOST_GHC_HR);
+   while (readl(_mmio->ghc) & SATA_HOST_GHC_HR)
+   udelay(100);
+
+   return 0;
+}
+
 int sata_port_status(int dev, int port)
 {
struct sata_port_regs *port_mmio;
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 17/40] dm: sata: dw_sata: Sort #include directives

2017-07-29 Thread Simon Glass
Sort the header file inclusions into the correct order.

Signed-off-by: Simon Glass 
---

Changes in v2: None

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

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 63e7b7d7a1..b6915d217b 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -5,19 +5,18 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 
-#include 
+#include 
 #include 
 #include 
-#include 
-
-#include 
+#include 
 #include 
-#include 
-#include 
+#include 
 #include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include "dwc_ahsata.h"
 
 struct sata_port_regs {
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 08/40] dm: blk: Update return value in blk_create_devicef()

2017-07-29 Thread Simon Glass
This returns 'ret' but the value is always zero. Update it to simply
return 0, for clarity.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/block/blk-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index fbe5f30fc0..8ab613d460 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -594,7 +594,7 @@ int blk_create_devicef(struct udevice *parent, const char 
*drv_name,
}
device_set_name_alloced(*devp);
 
-   return ret;
+   return 0;
 }
 
 int blk_unbind_all(int if_type)
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 05/40] dm: scsi: Adjust the 'scsi' command to use blk_common_cmd()

2017-07-29 Thread Simon Glass
Instead of having separate code in the 'scsi' command, adjust it to use
the common function.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 cmd/scsi.c | 79 +++---
 1 file changed, 3 insertions(+), 76 deletions(-)

diff --git a/cmd/scsi.c b/cmd/scsi.c
index 570971891e..75b88baa95 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -29,11 +29,7 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
 {
int ret;
 
-   switch (argc) {
-   case 0:
-   case 1:
-   return CMD_RET_USAGE;
-   case 2:
+   if (argc == 2) {
if (strncmp(argv[1], "res", 3) == 0) {
printf("\nReset SCSI\n");
scsi_bus_reset(NULL);
@@ -42,84 +38,15 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
return CMD_RET_FAILURE;
return ret;
}
-   if (strncmp(argv[1], "inf", 3) == 0) {
-   blk_list_devices(IF_TYPE_SCSI);
-   return 0;
-   }
-   if (strncmp(argv[1], "dev", 3) == 0) {
-   if (blk_print_device_num(IF_TYPE_SCSI, scsi_curr_dev)) {
-   printf("\nno SCSI devices available\n");
-   return CMD_RET_FAILURE;
-   }
-
-   return 0;
-   }
if (strncmp(argv[1], "scan", 4) == 0) {
ret = scsi_scan(true);
if (ret)
return CMD_RET_FAILURE;
return ret;
}
-   if (strncmp(argv[1], "part", 4) == 0) {
-   if (blk_list_part(IF_TYPE_SCSI))
-   printf("\nno SCSI devices available\n");
-   return 0;
-   }
-   return CMD_RET_USAGE;
-   case 3:
-   if (strncmp(argv[1], "dev", 3) == 0) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
+   }
 
-   if (!blk_show_device(IF_TYPE_SCSI, dev)) {
-   scsi_curr_dev = dev;
-   printf("... is now current device\n");
-   } else {
-   return CMD_RET_FAILURE;
-   }
-   return 0;
-   }
-   if (strncmp(argv[1], "part", 4) == 0) {
-   int dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-   if (blk_print_part_devnum(IF_TYPE_SCSI, dev)) {
-   printf("\nSCSI device %d not available\n",
-  dev);
-   return CMD_RET_FAILURE;
-   }
-   return 0;
-   }
-   return CMD_RET_USAGE;
-   default:
-   /* at least 4 args */
-   if (strcmp(argv[1], "read") == 0) {
-   ulong addr = simple_strtoul(argv[2], NULL, 16);
-   ulong blk  = simple_strtoul(argv[3], NULL, 16);
-   ulong cnt  = simple_strtoul(argv[4], NULL, 16);
-   ulong n;
-
-   printf("\nSCSI read: device %d block # %ld, count %ld 
... ",
-  scsi_curr_dev, blk, cnt);
-   n = blk_read_devnum(IF_TYPE_SCSI, scsi_curr_dev, blk,
-   cnt, (ulong *)addr);
-   printf("%ld blocks read: %s\n", n,
-  n == cnt ? "OK" : "ERROR");
-   return 0;
-   } else if (strcmp(argv[1], "write") == 0) {
-   ulong addr = simple_strtoul(argv[2], NULL, 16);
-   ulong blk = simple_strtoul(argv[3], NULL, 16);
-   ulong cnt = simple_strtoul(argv[4], NULL, 16);
-   ulong n;
-
-   printf("\nSCSI write: device %d block # %ld, count %ld 
... ",
-  scsi_curr_dev, blk, cnt);
-   n = blk_write_devnum(IF_TYPE_SCSI, scsi_curr_dev, blk,
-cnt, (ulong *)addr);
-   printf("%ld blocks written: %s\n", n,
-  n == cnt ? "OK" : "ERROR");
-   return 0;
-   }
-   } /* switch */
-   return CMD_RET_USAGE;
+   return blk_common_cmd(argc, argv, IF_TYPE_SCSI, _curr_dev);
 }
 
 U_BOOT_CMD(
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 16/40] dm: sata: dw_sata: Drop unnecessary brackets

2017-07-29 Thread Simon Glass
There is a strange &(var) coding style in this driver. Adjust it to use
 instead, which is more usual.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 98 
 1 file changed, 48 insertions(+), 50 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 33804e92dc..63e7b7d7a1 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -104,8 +104,8 @@ static int ahci_setup_oobr(struct ahci_uc_priv *uc_priv, 
int clk)
 {
struct sata_host_regs *host_mmio = uc_priv->mmio_base;
 
-   writel(SATA_HOST_OOBR_WE, &(host_mmio->oobr));
-   writel(0x02060b14, &(host_mmio->oobr));
+   writel(SATA_HOST_OOBR_WE, _mmio->oobr);
+   writel(0x02060b14, _mmio->oobr);
 
return 0;
 }
@@ -118,16 +118,15 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
struct sata_host_regs *host_mmio = uc_priv->mmio_base;
int clk = mxc_get_clock(MXC_SATA_CLK);
 
-   cap_save = readl(&(host_mmio->cap));
+   cap_save = readl(_mmio->cap);
cap_save |= SATA_HOST_CAP_SSS;
 
/* global controller reset */
-   tmp = readl(&(host_mmio->ghc));
+   tmp = readl(_mmio->ghc);
if ((tmp & SATA_HOST_GHC_HR) == 0)
-   writel_with_flush(tmp | SATA_HOST_GHC_HR, &(host_mmio->ghc));
+   writel_with_flush(tmp | SATA_HOST_GHC_HR, _mmio->ghc);
 
-   while ((readl(&(host_mmio->ghc)) & SATA_HOST_GHC_HR)
-   && --timeout)
+   while ((readl(_mmio->ghc) & SATA_HOST_GHC_HR) && --timeout)
;
 
if (timeout <= 0) {
@@ -136,15 +135,14 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
}
 
/* Set timer 1ms */
-   writel(clk / 1000, &(host_mmio->timer1ms));
+   writel(clk / 1000, _mmio->timer1ms);
 
ahci_setup_oobr(uc_priv, 0);
 
-   writel_with_flush(SATA_HOST_GHC_AE, &(host_mmio->ghc));
-   writel(cap_save, &(host_mmio->cap));
+   writel_with_flush(SATA_HOST_GHC_AE, _mmio->ghc);
+   writel(cap_save, _mmio->cap);
num_ports = (cap_save & SATA_HOST_CAP_NP_MASK) + 1;
-   writel_with_flush((1 << num_ports) - 1,
-   &(host_mmio->pi));
+   writel_with_flush((1 << num_ports) - 1, _mmio->pi);
 
/*
 * Determine which Ports are implemented by the DWC_ahsata,
@@ -152,8 +150,8 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 * software to determine how many Ports are available and
 * which Port registers need to be initialized.
 */
-   uc_priv->cap = readl(&(host_mmio->cap));
-   uc_priv->port_map = readl(&(host_mmio->pi));
+   uc_priv->cap = readl(_mmio->cap);
+   uc_priv->port_map = readl(_mmio->pi);
 
/* Determine how many command slots the HBA supports */
uc_priv->n_ports = (uc_priv->cap & SATA_HOST_CAP_NP_MASK) + 1;
@@ -166,7 +164,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
port_mmio = uc_priv->port[i].port_mmio;
 
/* Ensure that the DWC_ahsata is in idle state */
-   tmp = readl(&(port_mmio->cmd));
+   tmp = readl(_mmio->cmd);
 
/*
 * When P#CMD.ST, P#CMD.CR, P#CMD.FRE and P#CMD.FR
@@ -181,7 +179,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 * 0 when read.
 */
tmp &= ~SATA_PORT_CMD_ST;
-   writel_with_flush(tmp, &(port_mmio->cmd));
+   writel_with_flush(tmp, _mmio->cmd);
 
/*
 * spec says 500 msecs for each bit, so
@@ -190,7 +188,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
mdelay(500);
 
timeout = 1000;
-   while ((readl(&(port_mmio->cmd)) & SATA_PORT_CMD_CR)
+   while ((readl(_mmio->cmd) & SATA_PORT_CMD_CR)
&& --timeout)
;
 
@@ -201,12 +199,12 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
}
 
/* Spin-up device */
-   tmp = readl(&(port_mmio->cmd));
-   writel((tmp | SATA_PORT_CMD_SUD), &(port_mmio->cmd));
+   tmp = readl(_mmio->cmd);
+   writel((tmp | SATA_PORT_CMD_SUD), _mmio->cmd);
 
/* Wait for spin-up to finish */
timeout = 1000;
-   while (!(readl(&(port_mmio->cmd)) | SATA_PORT_CMD_SUD)
+   while (!(readl(_mmio->cmd) | SATA_PORT_CMD_SUD)
&& --timeout)
;
if (timeout <= 0) {
@@ -216,7 +214,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)
 
for (j = 0; j < 100; ++j) {
mdelay(10);
-   

[U-Boot] [PATCH v2 10/40] dm: sata: dwc_ahsata: Make functions static

2017-07-29 Thread Simon Glass
Some functions are not called from outside this file. Make these static
to make that obvious.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 78572a5b73..b587ec4492 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -696,7 +696,7 @@ static u32 dwc_ahsata_rw_cmd(int dev, u32 start, u32 blkcnt,
return 0;
 }
 
-void dwc_ahsata_flush_cache(int dev)
+static void dwc_ahsata_flush_cache(int dev)
 {
struct ahci_uc_priv *probe_ent =
(struct ahci_uc_priv *)sata_dev_desc[dev].priv;
@@ -793,7 +793,7 @@ u32 dwc_ahsata_rw_ncq_cmd(int dev, u32 start, lbaint_t 
blkcnt,
return blkcnt;
 }
 
-void dwc_ahsata_flush_cache_ext(int dev)
+static void dwc_ahsata_flush_cache_ext(int dev)
 {
struct ahci_uc_priv *probe_ent =
(struct ahci_uc_priv *)sata_dev_desc[dev].priv;
@@ -823,8 +823,8 @@ static void dwc_ahsata_init_wcache(int dev, u16 *id)
probe_ent->flags |= SATA_FLAG_FLUSH_EXT;
 }
 
-u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
-   const void *buffer, int is_write)
+static u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t blkcnt,
+ const void *buffer, int is_write)
 {
u32 start, blks;
u8 *addr;
@@ -857,8 +857,8 @@ u32 ata_low_level_rw_lba48(int dev, u32 blknr, lbaint_t 
blkcnt,
return blkcnt;
 }
 
-u32 ata_low_level_rw_lba28(int dev, u32 blknr, lbaint_t blkcnt,
-   const void *buffer, int is_write)
+static u32 ata_low_level_rw_lba28(int dev, u32 blknr, lbaint_t blkcnt,
+ const void *buffer, int is_write)
 {
u32 start, blks;
u8 *addr;
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 22/40] dm: sata: Support driver model with the 'sata' command

2017-07-29 Thread Simon Glass
Update this command to support driver model. This has a different way of
starting and stopping SATA.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 cmd/sata.c | 95 --
 common/splash_source.c |  2 +-
 include/sata.h |  5 ++-
 3 files changed, 89 insertions(+), 13 deletions(-)

diff --git a/cmd/sata.c b/cmd/sata.c
index d34a56dccc..7817442532 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -11,33 +11,106 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static int sata_curr_device = -1;
 
+int sata_remove(int devnum)
+{
+#ifdef CONFIG_AHCI
+   struct udevice *dev;
+   int rc;
+
+   rc = uclass_find_device(UCLASS_AHCI, devnum, );
+   if (!rc && !dev)
+   rc = uclass_find_first_device(UCLASS_AHCI, );
+   if (rc || !dev) {
+   printf("Cannot find SATA device %d (err=%d)\n", devnum, rc);
+   return CMD_RET_FAILURE;
+   }
+
+   rc = device_remove(dev, DM_REMOVE_NORMAL);
+   if (rc) {
+   printf("Cannot remove SATA device '%s' (err=%d)\n", dev->name,
+  rc);
+   return CMD_RET_FAILURE;
+   }
+
+   return 0;
+#else
+   return sata_stop();
+#endif
+}
+
+int sata_probe(int devnum)
+{
+#ifdef CONFIG_AHCI
+   struct udevice *dev;
+   struct udevice *blk;
+   int rc;
+
+   rc = uclass_get_device(UCLASS_AHCI, devnum, );
+   if (rc)
+   rc = uclass_find_first_device(UCLASS_AHCI, );
+   if (rc) {
+   printf("Cannot probe SATA device %d (err=%d)\n", devnum, rc);
+   return CMD_RET_FAILURE;
+   }
+   rc = sata_scan(dev);
+   if (rc) {
+   printf("Cannot scan SATA device %d (err=%d)\n", devnum, rc);
+   return CMD_RET_FAILURE;
+   }
+
+   rc = blk_get_from_parent(dev, );
+   if (!rc) {
+   struct blk_desc *desc = dev_get_uclass_platdata(blk);
+
+   if (desc->lba > 0 && desc->blksz > 0)
+   part_init(desc);
+   }
+
+   return 0;
+#else
+   return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
+#endif
+}
+
 static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
int rc = 0;
 
-   if (argc == 2 && strcmp(argv[1], "stop") == 0)
-   return sata_stop();
+   if (argc >= 2) {
+   int devnum = 0;
+
+   if (argc == 3)
+   devnum = (int)simple_strtoul(argv[2], NULL, 10);
+   if (!strcmp(argv[1], "stop"))
+   return sata_remove(devnum);
 
-   if (argc == 2 && strcmp(argv[1], "init") == 0) {
-   if (sata_curr_device != -1)
-   sata_stop();
+   if (!strcmp(argv[1], "init")) {
+   if (sata_curr_device != -1) {
+   rc = sata_remove(devnum);
+   if (rc)
+   return rc;
+   }
 
-   return (sata_initialize() < 0) ?
-   CMD_RET_FAILURE : CMD_RET_SUCCESS;
+   return sata_probe(devnum);
+   }
}
 
/* If the user has not yet run `sata init`, do it now */
if (sata_curr_device == -1) {
-   rc = sata_initialize();
-   if (rc == -1)
+   rc = sata_probe(0);
+   if (rc < 0)
return CMD_RET_FAILURE;
-   sata_curr_device = rc;
+   sata_curr_device = 0;
}
 
return blk_common_cmd(argc, argv, IF_TYPE_SATA, _curr_device);
@@ -47,7 +120,7 @@ U_BOOT_CMD(
sata, 5, 1, do_sata,
"SATA sub system",
"init - init SATA sub system\n"
-   "sata stop - disable SATA sub system\n"
+   "sata stop [dev] - disable SATA sub system or device\n"
"sata info - show available SATA devices\n"
"sata device [dev] - show or set current device\n"
"sata part [dev] - print partition table\n"
diff --git a/common/splash_source.c b/common/splash_source.c
index 867a798487..206a45df37 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -166,7 +166,7 @@ static inline int splash_init_usb(void)
 #ifdef CONFIG_SATA
 static int splash_init_sata(void)
 {
-   return sata_initialize();
+   return sata_probe(0);
 }
 #else
 static inline int splash_init_sata(void)
diff --git a/include/sata.h b/include/sata.h
index d18cc9aa87..d89f7a8a29 100644
--- a/include/sata.h
+++ b/include/sata.h
@@ -2,7 +2,7 @@
 #define __SATA_H__
 #include 
 
-#if !defined(CONFIG_DM_SCSI)
+#if !defined(CONFIG_DM_SCSI) && !defined(CONFIG_AHCI)
 int init_sata(int dev);
 int reset_sata(int dev);
 int scan_sata(int dev);
@@ -18,4 +18,7 @@ int sata_port_status(int dev, int port);
 extern struct blk_desc sata_dev_desc[];
 

[U-Boot] [PATCH v2 19/40] dm: sata: dw_sata: Drop is_ready

2017-07-29 Thread Simon Glass
This variable is set but never used. Drop it.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/ata/dwc_ahsata.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 8056bc94a3..4b89a8b788 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -77,8 +77,6 @@ struct sata_host_regs {
 
 #define writel_with_flush(a, b)do { writel(a, b); readl(b); } while (0)
 
-static int is_ready;
-
 static inline void __iomem *ahci_port_base(void __iomem *base, u32 port)
 {
return base + 0x100 + (port * 0x80);
@@ -938,7 +936,5 @@ int scan_sata(int dev)
 
dwc_ahsata_print_info(_dev_desc[dev]);
 
-   is_ready = 1;
-
return 0;
 }
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 01/40] dm: core: Avoid calling dm_scan_fdt_dev() with of-platdata

2017-07-29 Thread Simon Glass
We cannot call dm_scan_fdt_dev() with of-platdata since there is no device
tree. Fix this with an #if check.

Fixes: 3be9a37 (dm: syscon: scan sub-nodes of the syscon node)
Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to avoid calling dm_scan_fdt_dev() with of-platdata

 drivers/core/syscon-uclass.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index b06ca6a8f2..a69937e63c 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -104,6 +104,8 @@ static const struct udevice_id generic_syscon_ids[] = {
 U_BOOT_DRIVER(generic_syscon) = {
.name   = "syscon",
.id = UCLASS_SYSCON,
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
.bind   = dm_scan_fdt_dev,
+#endif
.of_match = generic_syscon_ids,
 };
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 03/40] dm: blk: Add a generic function for block device commands

2017-07-29 Thread Simon Glass
Most block devices provide a command (e.g. 'sata', 'scsi', 'ide') and
these commands generally do the same thing. This makes it harder to
maintain this code and keep it consistent.

We now have a block device interface which is either implemented by driver
model (when CONFIG_BLK is enabled) or with a legacy interface. Therefore
it is possible to handle most of what these commands do with generic code.

Add a new generic function to process block-device commands using the
interface type and the current device number for that type.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 cmd/Makefile |   1 +
 cmd/blk_common.c | 104 +++
 include/blk.h|  12 +++
 3 files changed, 117 insertions(+)
 create mode 100644 cmd/blk_common.c

diff --git a/cmd/Makefile b/cmd/Makefile
index bd231f24d8..e2b3a9cc71 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -15,6 +15,7 @@ obj-y += version.o
 # command
 obj-$(CONFIG_CMD_AES) += aes.o
 obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
+obj-y += blk_common.o
 obj-$(CONFIG_SOURCE) += source.o
 obj-$(CONFIG_CMD_SOURCE) += source.o
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
new file mode 100644
index 00..86c75e78d8
--- /dev/null
+++ b/cmd/blk_common.c
@@ -0,0 +1,104 @@
+/*
+ * Handling of common block commands
+ *
+ * Copyright (c) 2017 Google, Inc
+ *
+ * (C) Copyright 2000-2011
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+
+#ifdef HAVE_BLOCK_DEVICE
+int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
+  int *cur_devnump)
+{
+   const char *if_name = blk_get_if_type_name(if_type);
+
+   switch (argc) {
+   case 0:
+   case 1:
+   return CMD_RET_USAGE;
+   case 2:
+   if (strncmp(argv[1], "inf", 3) == 0) {
+   blk_list_devices(if_type);
+   return 0;
+   } else if (strncmp(argv[1], "dev", 3) == 0) {
+   if (blk_print_device_num(if_type, *cur_devnump)) {
+   printf("\nno %s devices available\n", if_name);
+   return CMD_RET_FAILURE;
+   }
+   return 0;
+   } else if (strncmp(argv[1], "part", 4) == 0) {
+   if (blk_list_part(if_type))
+   printf("\nno %s devices available\n", if_name);
+   return 0;
+   }
+   return CMD_RET_USAGE;
+   case 3:
+   if (strncmp(argv[1], "dev", 3) == 0) {
+   int dev = (int)simple_strtoul(argv[2], NULL, 10);
+
+   if (!blk_show_device(if_type, dev)) {
+   *cur_devnump = dev;
+   printf("... is now current device\n");
+   } else {
+   return CMD_RET_FAILURE;
+   }
+   return 0;
+   } else if (strncmp(argv[1], "part", 4) == 0) {
+   int dev = (int)simple_strtoul(argv[2], NULL, 10);
+
+   if (blk_print_part_devnum(if_type, dev)) {
+   printf("\n%s device %d not available\n",
+  if_name, dev);
+   return CMD_RET_FAILURE;
+   }
+   return 0;
+   }
+   return CMD_RET_USAGE;
+
+   default: /* at least 4 args */
+   if (strcmp(argv[1], "read") == 0) {
+   ulong addr = simple_strtoul(argv[2], NULL, 16);
+   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
+   ulong cnt = simple_strtoul(argv[4], NULL, 16);
+   ulong n;
+
+   printf("\n%s read: device %d block # %lld, count %ld 
... ",
+  if_name, *cur_devnump, (unsigned long long)blk,
+  cnt);
+
+   n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
+   (ulong *)addr);
+
+   printf("%ld blocks read: %s\n", n,
+  n == cnt ? "OK" : "ERROR");
+   return n == cnt ? 0 : 1;
+   } else if (strcmp(argv[1], "write") == 0) {
+   ulong addr = simple_strtoul(argv[2], NULL, 16);
+   lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
+   ulong cnt = simple_strtoul(argv[4], NULL, 16);
+   ulong n;
+
+   printf("\n%s write: device %d block # %lld, count %ld 
... ",
+  if_name, *cur_devnump, (unsigned long long)blk,
+   

[U-Boot] [PATCH v2 02/40] dm: blk: Add a function to find an interface-type name

2017-07-29 Thread Simon Glass
Add a function to find the name of an interface type (e.g. "sata", "scsi")
from the interface type enum.

This is useful for generic code (not specific to SATA or SCSI, for
example) that wants to display the type of interface it is dealing with.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 drivers/block/blk-uclass.c | 5 +
 drivers/block/blk_legacy.c | 7 +++
 include/blk.h  | 8 
 3 files changed, 20 insertions(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 23f131b7ad..fbe5f30fc0 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -55,6 +55,11 @@ static enum uclass_id if_type_to_uclass_id(enum if_type 
if_type)
return if_type_uclass_id[if_type];
 }
 
+const char *blk_get_if_type_name(enum if_type if_type)
+{
+   return if_typename_str[if_type];
+}
+
 struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
 {
struct blk_desc *desc;
diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
index 7b90a8a6e1..981872ecb3 100644
--- a/drivers/block/blk_legacy.c
+++ b/drivers/block/blk_legacy.c
@@ -38,6 +38,13 @@ static struct blk_driver *blk_driver_lookup_typename(const 
char *if_typename)
return NULL;
 }
 
+const char *blk_get_if_type_name(enum if_type if_type)
+{
+   struct blk_driver *drv = blk_driver_lookup_type(if_type);
+
+   return drv ? drv->if_typename : NULL;
+}
+
 /**
  * get_desc() - Get the block device descriptor for the given device number
  *
diff --git a/include/blk.h b/include/blk.h
index 1e6239ac9e..69076d3683 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -623,4 +623,12 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, 
lbaint_t start,
  */
 int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
 
+/**
+ * blk_get_if_type_name() - Get the name of an interface type
+ *
+ * @if_type: Interface type to check
+ * @return name of interface, or NULL if none
+ */
+const char *blk_get_if_type_name(enum if_type if_type);
+
 #endif
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


[U-Boot] [PATCH v2 00/40] dm: sata: Complete driver-model support for SATA

2017-07-29 Thread Simon Glass
Note: This series is rebased to u-boot-mmc/master with a fix-up patch
for a broken patch there.

This series completes the conversion of SATA to driver model.

Previous work converted SCSI including the SCSI-based SATA driver. This
series converts the AHCI uclass itself, adding operations and adjusting
the 'sata' command to work correctly.

An existing board (Compulab Utilite) is used for this work. It uses SATA
without the SCSI layer. Unfortunately this board does not currently use
driver model for MMC or USB, nor does it include a device tree. Therefore
additional patches are included in this series to convert this over. Note
that USB is rendered inoperative since the relevant device-tree nodes are
disabled. Further work is needed here (e.g. by the board maintainer) but
it is well beyond the objective of this series.

A long-standing niggle with MMC has been the CONFIG_DM_MMC_OPS option.
This was introduced to allow driver model to handle MMC operations rather
than having them in struct mmc. This was needed since the original uclass
did not have support for operations.

At present i.MX is the only SoC that defines CONFIG_DM_MMC without
CONFIG_DM_MMC_OPS. With this driver converted, the option is no longer
necessary so this series takes the opportunity to drop that option.

Changes in v2:
- Add new patch to avoid calling dm_scan_fdt_dev() with of-platdata
- Rebase to u-boot-mmc/master

Simon Glass (40):
  dm: core: Avoid calling dm_scan_fdt_dev() with of-platdata
  dm: blk: Add a function to find an interface-type name
  dm: blk: Add a generic function for block device commands
  dm: sata: Adjust the 'sata' command to use blk_common_cmd()
  dm: scsi: Adjust the 'scsi' command to use blk_common_cmd()
  dm: ide: Adjust the 'ide' command to use blk_common_cmd()
  dm: usb: Adjust the 'usb' command to use blk_common_cmd()
  dm: blk: Update return value in blk_create_devicef()
  dm: core: Add a comment about the device_remove() flags
  dm: sata: dwc_ahsata: Make functions static
  dm: sata: dw_sata: Drop dwc_ahsata_rw_ncq_cmd()
  dm: sata: dw_sata: Move exported functions to the end
  dm: sata: dw_sata: Rename 'probe_ent' to uc_priv
  dm: sata: dw_sata: Drop unnecessary casts
  dm: sata: dw_sata: Pass uc_priv to internal functions
  dm: sata: dw_sata: Drop unnecessary brackets
  dm: sata: dw_sata: Sort #include directives
  dm: sata: dw_sata: Rename the dwc_ahsata private header
  dm: sata: dw_sata: Drop is_ready
  dm: sata: dw_sata: More ahci_init_one() futher down
  dm: sata: dw_sata: Set up common versions of operations
  dm: sata: Support driver model with the 'sata' command
  dm: sata: imx: Allow driver model to be used for sata
  dm: sata: Update the AHCI uclass to support operations
  dm: sata: dwc_ahsata: Add support for driver model
  dm: mmc: fsl_esdhc: Pass private data to internal functions
  dm: mmc: fsl_esdhc: Set up common versions of operations
  dm: mmc: fsl_esdhc: Detect reset failure
  dm: mmc: fsl_esdhc: Detect init failure
  dm: mmc: fsl_esdhc: Set up platform data
  dm: mmc: fsl_esdhc: Drop mmc_init() call from fsl_esdhc_init()
  dm: mmc: fsl_esdhc: Update to support livetree
  dm: mmc: fsl_esdhc: Update to support MMC operations
  dm: imx: cm_fx6: Support driver model for SATA
  dm: imx: cm_fx6: Add device tree for cm_fx6
  dm: imx: cm_fx6: Add MMC support for CONFIG_BLK
  dm: imx: cm_fx6: Enable more driver model support
  dm: imx: Move i.MX devices to use CONFIG_DM_MMC_OPS
  dm: mmc: Correct Kconfig condition for SPL_DM_MMC_OPS
  dm: mmc: Drop CONFIG_DM_MMC_OPS

 arch/arm/Kconfig|   2 -
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/imx6q-cm-fx6.dts   | 115 
 arch/arm/mach-imx/cpu.c |   2 +-
 board/compulab/cm_fx6/cm_fx6.c  |  80 +++
 cmd/Makefile|   1 +
 cmd/blk_common.c| 104 
 cmd/ide.c   | 107 +---
 cmd/sata.c  | 178 +++---
 cmd/scsi.c  |  79 +--
 cmd/usb.c   | 111 +---
 common/splash_source.c  |   2 +-
 configs/Linksprite_pcDuino3_defconfig   |   3 -
 configs/cm_fx6_defconfig|   8 +-
 configs/imx6q_logic_defconfig   |   1 -
 configs/imx6qdl_icore_mmc_defconfig |   1 -
 configs/imx6qdl_icore_rqs_defconfig |   1 -
 configs/imx6ul_geam_mmc_defconfig   |   1 -
 configs/imx6ul_geam_nand_defconfig  |   1 -
 configs/imx6ul_isiot_emmc_defconfig |   1 -
 configs/imx6ul_isiot_mmc_defconfig  |   1 -
 configs/imx6ul_isiot_nand_defconfig |   1 -
 configs/ls1012aqds_qspi_defconfig   |   1 -
 configs/ls1012ardb_qspi_defconfig   |   1 -
 configs/mx6slevk_defconfig  |   1 -
 

Re: [U-Boot] [PATCH] efi_gop.c: Store gd->fb_base as uintptr_t

2017-07-29 Thread Mark Kettenis
> From: Tom Rini 
> Date: Sat, 29 Jul 2017 11:43:21 -0400
> 
> Otherwise we get a warning about assignment about making a pointer from
> int without a cast.

That (uintptr_t *) cast makes no sense.  Either leave the member as a
"void *" and use a (void *) cast, or change it to uintptr_t and use a
(uintptr_t) cast.

Cheers,

Mark

> Cc: Alexander Graf 
> Signed-off-by: Tom Rini 
> ---
>  lib/efi_loader/efi_gop.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
> index 806cfaeea181..bd7b93ff 100644
> --- a/lib/efi_loader/efi_gop.c
> +++ b/lib/efi_loader/efi_gop.c
> @@ -131,7 +131,7 @@ int efi_gop_register(void)
>   struct efi_gop_obj *gopobj;
>   u32 bpix, col, row;
>   u64 fb_base, fb_size;
> - void *fb;
> + uintptr_t *fb;
>  
>  #ifdef CONFIG_DM_VIDEO
>   struct udevice *vdev;
> @@ -155,7 +155,7 @@ int efi_gop_register(void)
>   row = panel_info.vl_row;
>   fb_base = gd->fb_base;
>   fb_size = lcd_get_size(_len);
> - fb = gd->fb_base;
> + fb = (uintptr_t *)gd->fb_base;
>  #endif
>  
>   switch (bpix) {
> -- 
> 1.9.1
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] efi_gop.c: Store gd->fb_base as uintptr_t

2017-07-29 Thread Tom Rini
Otherwise we get a warning about assignment about making a pointer from
int without a cast.

Cc: Alexander Graf 
Signed-off-by: Tom Rini 
---
 lib/efi_loader/efi_gop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index 806cfaeea181..bd7b93ff 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -131,7 +131,7 @@ int efi_gop_register(void)
struct efi_gop_obj *gopobj;
u32 bpix, col, row;
u64 fb_base, fb_size;
-   void *fb;
+   uintptr_t *fb;
 
 #ifdef CONFIG_DM_VIDEO
struct udevice *vdev;
@@ -155,7 +155,7 @@ int efi_gop_register(void)
row = panel_info.vl_row;
fb_base = gd->fb_base;
fb_size = lcd_get_size(_len);
-   fb = gd->fb_base;
+   fb = (uintptr_t *)gd->fb_base;
 #endif
 
switch (bpix) {
-- 
1.9.1

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


[U-Boot] [PULL] u-boot-socfpga/master

2017-07-29 Thread Marek Vasut
The following changes since commit 609bf924117950b88987a5fa477acf1239bfdbc1:

  Convert CONFIG_ENV_IS_IN_ONENAND to Kconfig (2017-07-25 21:34:39 -0400)

are available in the git repository at:

  git://git.denx.de/u-boot-socfpga.git master

for you to fetch changes up to 9af91b7c4041a455de5f3e3da4e36644768bff68:

  arm: socfpga: Enable all FPGA config support for Arria 10 (2017-07-26
10:31:44 +0200)


Tien Fong Chee (8):
  arm: socfpga: Remove unused passing parameter of socfpga_bridges_reset
  arm: socfpga: Restructure FPGA driver in the preparation to
support A10
  kconfig: Convert FPGA and FPGA_ALTERA configuration to Kconfig
  kconfig: Convert FPGA_SOCFPGA configuration to Kconfig
  drivers: Enable FPGA driver build on SPL
  configs: Add FPGA driver config for Arria 10
  arm: socfpga: Add FPGA driver support for Arria 10
  arm: socfpga: Enable all FPGA config support for Arria 10

 arch/arm/mach-socfpga/Makefile |   2 +-
 arch/arm/mach-socfpga/include/mach/fpga_manager.h  |  70
+++-
 arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h  | 100

 arch/arm/mach-socfpga/include/mach/fpga_manager_gen5.h |  68
+++
 arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h |   2 +-
 arch/arm/mach-socfpga/reset_manager_arria10.c  |   4 +-
 configs/astro_mcf5373l_defconfig   |   1 +
 configs/socfpga_arria10_defconfig  |   2 +
 configs/socfpga_arria5_defconfig   |   1 +
 configs/socfpga_cyclone5_defconfig |   1 +
 configs/socfpga_de0_nano_soc_defconfig |   1 +
 configs/socfpga_de10_nano_defconfig|   1 +
 configs/socfpga_de1_soc_defconfig  |   1 +
 configs/socfpga_is1_defconfig  |   1 +
 configs/socfpga_mcvevk_defconfig   |   1 +
 configs/socfpga_sockit_defconfig   |   1 +
 configs/socfpga_socrates_defconfig |   1 +
 configs/socfpga_sr1500_defconfig   |   1 +
 configs/socfpga_vining_fpga_defconfig  |   1 +
 configs/theadorable_debug_defconfig|   1 +
 configs/theadorable_defconfig  |   1 +
 drivers/Makefile   |   1 +
 drivers/fpga/Kconfig   |   8 ++
 drivers/fpga/Makefile  |   2 +
 drivers/fpga/socfpga.c | 235
+-
 drivers/fpga/socfpga_arria10.c | 479
+
 drivers/fpga/socfpga_gen5.c| 252

 include/configs/astro_mcf5373l.h   |   2 -
 include/configs/socfpga_common.h   |   6 +-
 include/configs/theadorable.h  |   2 -
 30 files changed, 947 insertions(+), 302 deletions(-)
 create mode 100644
arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/fpga_manager_gen5.h
 create mode 100644 drivers/fpga/socfpga_arria10.c
 create mode 100644 drivers/fpga/socfpga_gen5.c
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PULL] u-boot-usb/master

2017-07-29 Thread Marek Vasut
The following changes since commit 26722335253a9fa384ceb423419254cb00d0def1:

  rockchip: puma-rk3399: remove duplicate code (merge artifact)
(2017-07-27 14:59:04 +0200)

are available in the git repository at:

  git://git.denx.de/u-boot-usb.git master

for you to fetch changes up to b108d8a0de3ddc6fe8aae55bc54e3edc69b4778b:

  clk: fix compilation errors for poplar platform (2017-07-28 23:34:46
+0200)


Bin Meng (33):
  usb: xhci: Remove incorrect comments for struct xhci_container_ctx
  usb: xhci: Correct command TRB 4th dword initialization
  usb: xhci: Initialize scratchpad buffer array and scratchpad buffers
  usb: xhci: Add input slot context in xhci_set_configuration()
  usb: hub: Update handling connect status/change in usb_scan_port()
  usb: hub: Send correct wValue to get hub descriptor of a USB 3.0 hub
  usb: hub: Revise wLength for 'get port status' request
  usb: hub: Change USB hub descriptor to match USB 3.0 hubs
  usb: hub: Add 3.0 hub port status mask of 2.0 hub
  usb: xhci: Change MAX_HC_PORTS to 255

  usb: xhci: Get rid of CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS

  configs: Remove CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS in all boards

  usb: ehci: Get rid of CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS

  configs: Remove CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS in all boards

  usb: cmd: Print actual packet size for super speed devices

  usb: xhci: Convert CONFIG_USB_XHCI_PCI to Kconfig
  x86: minnowmax: Add a environment variable for USB power-on delay
  x86: minnowmax: Enable USB xHCI support
  usb: xhci-pci: Drop non-DM version of xhci-pci driver
  usb: xhci-pci: Clean up the driver a little bit
  usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv
  usb: hub: Remove hub_port_reset()
  usb: hub: Add a new API to test if a hub device is root hub
  usb: hub: Translate USB 3.0 hub port status into old version
  usb: hub: Support 'set hub depth' request for USB 3.0 hubs
  usb: xhci: Change xhci_setup_addressable_virt_dev() signature
  usb: xhci: Program 'route string' in the input slot context
  usb: hub: Parse and save TT details from device descriptor
  dm: usb: Add a new USB controller operation 'update_hub_device'
  usb: hub: Call usb_update_hub_device() after hub descriptor is fetched
  usb: xhci: Implement update_hub_device() operation
  usb: xhci: Correct TT_SLOT and TT_PORT macros
  usb: xhci: Enable TT to support LS/FS devices behind a HS hub

Jean-Jacques Hiblot (1):
  phy: add a NO-OP phy driver

Masahiro Yamada (1):
  usb: add static to local symbols

Patrice Chotard (21):
  usb: host: xhci-dwc3: Convert driver to DM
  usb: host: xhci-dwc3: Add dual role mode support from DT
  drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index()
fails
  drivers: phy: add generic_phy_valid() method
  usb: host: xhci-dwc3: Add generic PHY support
  reset: add reset_request()
  reset: add reset_release_all()
  clk: add clk_release_all()
  dm: core: add ofnode_count_phandle_with_args()
  usb: host: ehci-generic: replace printf() by error()
  usb: host: ehci-generic: add error path and .remove callback
  usb: host: ehci-generic: add generic PHY support
  usb: host: ohci-generic: add CLOCK support
  usb: host: ohci-generic: add RESET support
  usb: host: ohci-generic: add generic PHY support
  dm: phy: add missing #ifdef CONFIG_PHY
  dm: usb: host: xhci-dwc3: add missing #ifdef CONFIG_DM_USB
  usb: host: ehci-generic: initialize PHY only when found
  usb: host: ohci-generic: initialize PHY only when found
  usb: host: xhci-dxc3: fix compilation warnings
  clk: fix compilation errors for poplar platform

Patrick Delaunay (4):
  dfu: allow dfu read on partition greater than 2GB
  dfu: remove limitation on partition size
  dfu: factorize transaction cleanup
  dfu: add common function to initiate transaction

Siva Durga Prasad Paladugu (1):
  usb: gadget: f_thor: Free the allocated out request buffer

 Documentation/devicetree/bindings/phy/no-op.txt |  16 ++
 arch/arm/include/asm/ehci-omap.h|   4 --
 arch/x86/dts/minnowmax.dts  |   3 ++
 cmd/usb.c   |   7 ++-
 common/usb_hub.c| 249
+---
 configs/minnowmax_defconfig |   1 +
 drivers/clk/clk-uclass.c|  27 ++
 drivers/core/of_access.c|   7 +++
 drivers/core/ofnode.c   |  12 +
 drivers/dfu/dfu.c   | 100
---
 drivers/dfu/dfu_mmc.c   |  20 +++
 drivers/dfu/dfu_nand.c 

Re: [U-Boot] [PATCH v3 00/13] usb: xhci: Add interrupt transfer support and full speed device support

2017-07-29 Thread Marek Vasut
On 07/29/2017 05:25 PM, Bin Meng wrote:
> Hi Marek,
> 
> On Fri, Jul 21, 2017 at 8:36 PM, Marek Vasut  wrote:
>> On 07/21/2017 02:34 PM, Bin Meng wrote:
>>> Hi Marek,
>>>
>>> On Fri, Jul 21, 2017 at 6:06 PM, Marek Vasut  wrote:
 On 07/21/2017 12:04 PM, Bin Meng wrote:
> Hi Marek,
>
> On Fri, Jul 21, 2017 at 4:56 PM, Marek Vasut  wrote:
>> On 07/21/2017 10:54 AM, Bin Meng wrote:
>>> Hi Marek,
>>>
>>> On Thu, Jul 20, 2017 at 8:20 PM, Marek Vasut  wrote:
 On 07/20/2017 02:16 PM, Bin Meng wrote:
> Hi Marek,
>
> On Thu, Jul 20, 2017 at 7:12 AM, Bin Meng  wrote:
>> This series is the final series of the xHCI driver update.
>>
>> This adds the missing interrupt transfer support to xHCI driver, so
>> that devices like USB keyboard that uses interrupt transfer when
>> CONFIG_SYS_USB_EVENT_POLL is defined can work.
>>
>> This also adds full speed device support. Unlike low/high/super speed
>> devices, full speed device may report its endpoint 0 max packet size
>> as 8/16/32/64. xHCI driver guesses 64 for the first attempt to get 
>> the
>> initial 8 bytes device descriptor, and later adjusts the context for
>> endpoint 0.
>>
>> This series also made several updates to xHCI driver to conform with
>> the spec.
>>
>> Previous two series:
>> [1]: usb: xhci: Fix USB xHCI support on Intel platform
>> https://lists.denx.de/pipermail/u-boot/2017-June/296166.html
>> [2]: usb: hub: Support USB 3.0 hubs
>> https://lists.denx.de/pipermail/u-boot/2017-June/296284.html
>>
>> This series is available at u-boot-x86/xhci-working3 for testing.
>>
>> Changes in v3:
>> - rebase on u-boot-usb/master
>> - add changes to poplar.h
>>
>> Bin Meng (13):
>>   usb: xhci: Add interrupt transfer support
>>   usb: configs: Clean up CONFIG_SYS_USB_EVENT_POLL_(xxx) in board
>> configs
>>   usb: kbd: kconfig: Set a default polling mechanism for USB keyboard
>>   usb: Only get 64 bytes device descriptor for full speed devices
>>   usb: Read device descriptor after device is addressed for xHCI
>>   usb: xhci: Fix max packet size for full speed device endpoint 0
>>   usb: hub: Clear port reset before usb_hub_port_connect_change()
>>   usb: hub: Clear BH reset status change for a 3.0 hub
>>   usb: Handle audio extension endpoint descriptor in 
>> usb_parse_config()
>>   usb: xhci: Honor endpoint's interval
>>   usb: xhci: Program max burst size for endpoint
>>   usb: xhci: Set 'Error Count' to 0 for isoch endpoints
>>   usb: xhci: Set 'Average TRB Length' to 8 for control endpoints
>>
>
> This is the last xHCI series I have. Can you please take a look and 
> apply?

 I'd like to see some RB/TB from Stefan Roese first if possible.

>>>
>>> OK, if that's the case, can you send a pull request to Tom to get usb
>>> in? So that I can apply Stefan's x86 patch series on top of this. (I
>>> cannot send PR for x86 before the usb changes)
>>
>> I actually cannot because the USB is currently broken, sorry, I'm
>> waiting for a fix before I do that.
>>
>> Stefan, can you look at this series please?
>
> What "broken" issues are you seeing?

 I think Layerscape stopped building. Look at email with this subject
 "Compile failure encountered on latest (2017-07-20)
 git://git.denx.de/u-boot-usb.git branch master for target
 ls1021atwr_nor_defconfig"
>>>
>>> I see Patrice is working on a fix for the build failure.
>>
>> Correct, it's almost done. Sorry for the delay.
> 
> FYI, since it was reported by Ran this series has some issues on NXP
> LS1021ATWR, I will need allocate some time to figure out why.
> 
> BTW: when will the u-boot-usb PR be sent? Not for any push, but
> Stefan's x86 patches are in the x86 repo which depends on contents on
> u-boot-usb and lots of Kconfig was changed in u-boot/master. The
> longer time our patches are staying off stream, the more chances we
> get rebase conflicts.

Today-ish .

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


Re: [U-Boot] [PATCH v3 00/13] usb: xhci: Add interrupt transfer support and full speed device support

2017-07-29 Thread Bin Meng
Hi Marek,

On Fri, Jul 21, 2017 at 8:36 PM, Marek Vasut  wrote:
> On 07/21/2017 02:34 PM, Bin Meng wrote:
>> Hi Marek,
>>
>> On Fri, Jul 21, 2017 at 6:06 PM, Marek Vasut  wrote:
>>> On 07/21/2017 12:04 PM, Bin Meng wrote:
 Hi Marek,

 On Fri, Jul 21, 2017 at 4:56 PM, Marek Vasut  wrote:
> On 07/21/2017 10:54 AM, Bin Meng wrote:
>> Hi Marek,
>>
>> On Thu, Jul 20, 2017 at 8:20 PM, Marek Vasut  wrote:
>>> On 07/20/2017 02:16 PM, Bin Meng wrote:
 Hi Marek,

 On Thu, Jul 20, 2017 at 7:12 AM, Bin Meng  wrote:
> This series is the final series of the xHCI driver update.
>
> This adds the missing interrupt transfer support to xHCI driver, so
> that devices like USB keyboard that uses interrupt transfer when
> CONFIG_SYS_USB_EVENT_POLL is defined can work.
>
> This also adds full speed device support. Unlike low/high/super speed
> devices, full speed device may report its endpoint 0 max packet size
> as 8/16/32/64. xHCI driver guesses 64 for the first attempt to get the
> initial 8 bytes device descriptor, and later adjusts the context for
> endpoint 0.
>
> This series also made several updates to xHCI driver to conform with
> the spec.
>
> Previous two series:
> [1]: usb: xhci: Fix USB xHCI support on Intel platform
> https://lists.denx.de/pipermail/u-boot/2017-June/296166.html
> [2]: usb: hub: Support USB 3.0 hubs
> https://lists.denx.de/pipermail/u-boot/2017-June/296284.html
>
> This series is available at u-boot-x86/xhci-working3 for testing.
>
> Changes in v3:
> - rebase on u-boot-usb/master
> - add changes to poplar.h
>
> Bin Meng (13):
>   usb: xhci: Add interrupt transfer support
>   usb: configs: Clean up CONFIG_SYS_USB_EVENT_POLL_(xxx) in board
> configs
>   usb: kbd: kconfig: Set a default polling mechanism for USB keyboard
>   usb: Only get 64 bytes device descriptor for full speed devices
>   usb: Read device descriptor after device is addressed for xHCI
>   usb: xhci: Fix max packet size for full speed device endpoint 0
>   usb: hub: Clear port reset before usb_hub_port_connect_change()
>   usb: hub: Clear BH reset status change for a 3.0 hub
>   usb: Handle audio extension endpoint descriptor in 
> usb_parse_config()
>   usb: xhci: Honor endpoint's interval
>   usb: xhci: Program max burst size for endpoint
>   usb: xhci: Set 'Error Count' to 0 for isoch endpoints
>   usb: xhci: Set 'Average TRB Length' to 8 for control endpoints
>

 This is the last xHCI series I have. Can you please take a look and 
 apply?
>>>
>>> I'd like to see some RB/TB from Stefan Roese first if possible.
>>>
>>
>> OK, if that's the case, can you send a pull request to Tom to get usb
>> in? So that I can apply Stefan's x86 patch series on top of this. (I
>> cannot send PR for x86 before the usb changes)
>
> I actually cannot because the USB is currently broken, sorry, I'm
> waiting for a fix before I do that.
>
> Stefan, can you look at this series please?

 What "broken" issues are you seeing?
>>>
>>> I think Layerscape stopped building. Look at email with this subject
>>> "Compile failure encountered on latest (2017-07-20)
>>> git://git.denx.de/u-boot-usb.git branch master for target
>>> ls1021atwr_nor_defconfig"
>>
>> I see Patrice is working on a fix for the build failure.
>
> Correct, it's almost done. Sorry for the delay.

FYI, since it was reported by Ran this series has some issues on NXP
LS1021ATWR, I will need allocate some time to figure out why.

BTW: when will the u-boot-usb PR be sent? Not for any push, but
Stefan's x86 patches are in the x86 repo which depends on contents on
u-boot-usb and lots of Kconfig was changed in u-boot/master. The
longer time our patches are staying off stream, the more chances we
get rebase conflicts.

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


Re: [U-Boot] [PATCH] Use packed structures for networking

2017-07-29 Thread Tom Rini
On Sat, Jul 29, 2017 at 12:53:36PM +0300, Denis Pynkin wrote:
> 28.07.2017 00:26, Joe Hershberger wrote:
> 
> >>>PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled
> >>>by default for '-O2':
> 
> >>So, what I've been wondering, and others have poked me about (who can
> >>chime in if they like), how is the kernel not also tripping over this?
> >
> >Great question.
> 
> Believe kernel do not work in single static buffer for the whole
> packet as u-boot do.
> 
> Problem is in ethernet header structure with size ETHER_HDR_SIZE=14,
> so IP and BOOTP headers are not aligned to 4 bytes.
> 
> Let's take bootp.c code as example:
> 
> 755 bp = (struct bootp_hdr *)pkt;
> 756 bp->bp_op = OP_BOOTREQUEST;
> 757 bp->bp_htype = HWT_ETHER;
> 758 bp->bp_hlen = HWL_ETHER;
> 759 bp->bp_hops = 0;
> 
> Without '-fstore-merging' or with enabled 'packed' structures
> assembler code looks like:
>   6a:   77a3  strbr3, [r4, #30]
>   6c:   f884 b01c strb.w  fp, [r4, #28]
>   70:   f884 b01d strb.w  fp, [r4, #29]
>   74:   77e5  strbr5, [r4, #31]
> 
> but with option '-fstore-merging' all these instructions merged into
> single instruction:
>   62:   61e3  str r3, [r4, #28]
> 
> and store address is not aligned to 32b boundary here, so it results
> to 'data abort'.
> 
> I see some possible solutions here:
> - add option '-fno-store-merging' -- works, I test it already
> - use packed structures -- since there are some unsafe code in sources
> - rewrite networking part to work with any protocol separately and
> merge headers and data only on send.
> 
> Even simple reordering of header flags initialization helps here,
> but it looks like a bit of black magic in code.
> 
> PS forgot to mention in patch description -- '-Os' includes
> '-fstore-merging' option as well for gcc 7.1.

Thanks for explaining.  My inclination is that we should have a packed
change in for -rc1.  Philipp, have you had a chance to edit
doc/README.unaligned-memory-access.txt to your liking?  Thanks!

-- 
Tom


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


Re: [U-Boot] [PATCH] Use packed structures for networking

2017-07-29 Thread Denis Pynkin

28.07.2017 00:26, Joe Hershberger wrote:


PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled
by default for '-O2':



So, what I've been wondering, and others have poked me about (who can
chime in if they like), how is the kernel not also tripping over this?


Great question.


Believe kernel do not work in single static buffer for the whole packet 
as u-boot do.


Problem is in ethernet header structure with size ETHER_HDR_SIZE=14, so 
IP and BOOTP headers are not aligned to 4 bytes.


Let's take bootp.c code as example:

755 bp = (struct bootp_hdr *)pkt;
756 bp->bp_op = OP_BOOTREQUEST;
757 bp->bp_htype = HWT_ETHER;
758 bp->bp_hlen = HWL_ETHER;
759 bp->bp_hops = 0;

Without '-fstore-merging' or with enabled 'packed' structures assembler 
code looks like:

  6a:   77a3  strbr3, [r4, #30]
  6c:   f884 b01c strb.w  fp, [r4, #28]
  70:   f884 b01d strb.w  fp, [r4, #29]
  74:   77e5  strbr5, [r4, #31]

but with option '-fstore-merging' all these instructions merged into 
single instruction:

  62:   61e3  str r3, [r4, #28]

and store address is not aligned to 32b boundary here, so it results to 
'data abort'.


I see some possible solutions here:
- add option '-fno-store-merging' -- works, I test it already
- use packed structures -- since there are some unsafe code in sources
- rewrite networking part to work with any protocol separately and merge 
headers and data only on send.


Even simple reordering of header flags initialization helps here, but it 
looks like a bit of black magic in code.


PS forgot to mention in patch description -- '-Os' includes 
'-fstore-merging' option as well for gcc 7.1.



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


Re: [U-Boot] [PATCH] Use packed structures for networking

2017-07-29 Thread Denis Pynkin



28.07.2017 00:26, Joe Hershberger wrote:


PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled
by default for '-O2':



So, what I've been wondering, and others have poked me about (who can
chime in if they like), how is the kernel not also tripping over this?


Great question.



Believe kernel do not work in single static buffer for the whole packet 
as u-boot do.


Problem is in ethernet header structure with size ETHER_HDR_SIZE=14, so 
IP and BOOTP headers are not aligned to 4 bytes.


Let's take bootp.c code as example:

755 bp = (struct bootp_hdr *)pkt;
756 bp->bp_op = OP_BOOTREQUEST;
757 bp->bp_htype = HWT_ETHER;
758 bp->bp_hlen = HWL_ETHER;
759 bp->bp_hops = 0;

Without '-fstore-merging' or with enabled 'packed' structures assembler 
code looks like:

  6a:   77a3  strbr3, [r4, #30]
  6c:   f884 b01c strb.w  fp, [r4, #28]
  70:   f884 b01d strb.w  fp, [r4, #29]
  74:   77e5  strbr5, [r4, #31]

but with option '-fstore-merging' all these instructions merged into 
single instruction:

  62:   61e3  str r3, [r4, #28]

and store address is not aligned to 32b boundary here, so it results to 
'data abort'.


I see some possible solutions here:
- add option '-fno-store-merging' -- works, I test it already
- use packed structures -- since there are some unsafe code in sources
- rewrite networking part to work with any protocol separately and merge 
headers and data only on send.


Even simple reordering of header flags initialization helps here, but it 
looks like a bit of black magic in code.


PS forgot to mention in patch description -- '-Os' includes 
'-fstore-merging' option as well for gcc 7.1.


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


[U-Boot] [PATCH 1/1] efi_loader: notify when ExitBootServices is invoked

2017-07-29 Thread Heinrich Schuchardt
All events of type EVT_SIGNAL_EXIT_BOOT_SERVICES have to be
notified when ExitBootServices is invoked.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_boottime.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 468d14fda3..bd7e23bb89 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -786,8 +786,17 @@ static void efi_exit_caches(void)
 static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,
  unsigned long map_key)
 {
+   int i;
+
EFI_ENTRY("%p, %ld", image_handle, map_key);
 
+   /* Notify that ExitBootServices is invoked. */
+   for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
+   if (efi_events[i].type != EVT_SIGNAL_EXIT_BOOT_SERVICES)
+   continue;
+   efi_signal_event(_events[i]);
+   }
+
board_quiesce_devices();
 
/* Fix up caches for EFI payloads if necessary */
-- 
2.13.2

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


Re: [U-Boot] [PATCH v1] x86: Make table address selectable

2017-07-29 Thread Bin Meng
On Sat, Jul 29, 2017 at 1:02 AM, Andy Shevchenko
 wrote:
> Some firmwares might have another window for generated tables.
>
> So, introduce two configuration options to select start address and
> maximum length for the generated tables.
>
> Signed-off-by: Andy Shevchenko 
> ---
>  arch/x86/Kconfig  | 13 +
>  arch/x86/include/asm/tables.h |  9 ++---
>  2 files changed, 15 insertions(+), 7 deletions(-)
>

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