[U-Boot] [PATCH v5 1/4] drivers:usb:common:fsl-dt-fixup: Move device-tree fixup framework to common file

2016-03-22 Thread Sriram Dash
Move usb device-tree fixup framework from ehci-fsl.c to common place so
that it can be used by other drivers as well (xhci-fsl.c).

Signed-off-by: Ramneek Mehresh 
Signed-off-by: Sriram Dash 
---
Changes in v5:
  - No update
Changes in v4:
  - Retain copyright info
  - Remove #include from fsl-dt-fixup.c which are not used currently.
Changes in v3:
  - git commit -M -C to generate patches
  - Break the patch 1(Moving dt fix up and removing code duplication) into 2 
patches
Changes in v2:
  - Remove the #defines from the patch

 Makefile   |   1 +
 drivers/usb/common/Makefile|   6 +
 .../usb/{host/ehci-fsl.c => common/fsl-dt-fixup.c} | 157 -
 drivers/usb/host/ehci-fsl.c| 195 -
 4 files changed, 7 insertions(+), 352 deletions(-)
 create mode 100644 drivers/usb/common/Makefile
 copy drivers/usb/{host/ehci-fsl.c => common/fsl-dt-fixup.c} (54%)

diff --git a/Makefile b/Makefile
index 53569e8..97a78d3 100644
--- a/Makefile
+++ b/Makefile
@@ -648,6 +648,7 @@ libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
 libs-$(CONFIG_ALTERA_SDRAM) += drivers/ddr/altera/
 libs-y += drivers/serial/
 libs-y += drivers/usb/dwc3/
+libs-y += drivers/usb/common/
 libs-y += drivers/usb/emul/
 libs-y += drivers/usb/eth/
 libs-y += drivers/usb/gadget/
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
new file mode 100644
index 000..a38ee4a
--- /dev/null
+++ b/drivers/usb/common/Makefile
@@ -0,0 +1,6 @@
+# (C) Copyright 2016 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/common/fsl-dt-fixup.c
similarity index 54%
copy from drivers/usb/host/ehci-fsl.c
copy to drivers/usb/common/fsl-dt-fixup.c
index 97b7f14..92adb46 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -9,172 +9,16 @@
  */
 
 #include 
-#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 
-#include "ehci.h"
-
 #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
 #endif
 
-static void set_txfifothresh(struct usb_ehci *, u32);
-
-/* Check USB PHY clock valid */
-static int usb_phy_clk_valid(struct usb_ehci *ehci)
-{
-   if (!((in_be32(&ehci->control) & PHY_CLK_VALID) ||
-   in_be32(&ehci->prictrl))) {
-   printf("USB PHY clock invalid!\n");
-   return 0;
-   } else {
-   return 1;
-   }
-}
-
-/*
- * Create the appropriate control structures to manage
- * a new EHCI host controller.
- *
- * Excerpts from linux ehci fsl driver.
- */
-int ehci_hcd_init(int index, enum usb_init_type init,
-   struct ehci_hccr **hccr, struct ehci_hcor **hcor)
-{
-   struct usb_ehci *ehci = NULL;
-   const char *phy_type = NULL;
-   size_t len;
-   char current_usb_controller[5];
-#ifdef CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY
-   char usb_phy[5];
-
-   usb_phy[0] = '\0';
-#endif
-   if (has_erratum_a007075()) {
-   /*
-* A 5ms delay is needed after applying soft-reset to the
-* controller to let external ULPI phy come out of reset.
-* This delay needs to be added before re-initializing
-* the controller after soft-resetting completes
-*/
-   mdelay(5);
-   }
-   memset(current_usb_controller, '\0', 5);
-   snprintf(current_usb_controller, 4, "usb%d", index+1);
-
-   switch (index) {
-   case 0:
-   ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR;
-   break;
-   case 1:
-   ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB2_ADDR;
-   break;
-   default:
-   printf("ERROR: wrong controller index!!\n");
-   return -EINVAL;
-   };
-
-   *hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
-   *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
-   HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
-
-   /* Set to Host mode */
-   setbits_le32(&ehci->usbmode, CM_HOST);
-
-   out_be32(&ehci->snoop1, SNOOP_SIZE_2GB);
-   out_be32(&ehci->snoop2, 0x8000 | SNOOP_SIZE_2GB);
-
-   /* Init phy */
-   if (hwconfig_sub(current_usb_controller, "phy_type"))
-   phy_type = hwconfig_subarg(current_usb_controller,
-   "phy_type", &len);
-   else
-   phy_type = getenv("usb_phy_type");
-
-   if (!phy_type) {
-#ifdef CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY
-   /* if none specified assume internal UTMI */
-   strcpy(usb_phy, "utmi");
-   phy_type = usb_phy;
-#else
-   printf("WARNING: USB phy type not defined !!\n");
-   return -1;
-#endif
-   }
-
-   if (!strncmp(phy_type, "utmi"

[U-Boot] [PATCH v5 2/4] drivers:usb:common:fsl-dt-fixup: Remove code duplication for fdt_usb_get_node_type

2016-03-22 Thread Sriram Dash
Call fdt_usb_get_node_type() from fdt_fixup_usb_mode_phy_type() to
avoid code duplication.

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---
Changes in v5:
  - reorder the functions and gets rid of the forward declaration
Changes in v4:
  - Make minimal modification to code
Changes in v3:
  - Move the duplication of code to new patch

 drivers/usb/common/fsl-dt-fixup.c | 72 ---
 1 file changed, 29 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/common/fsl-dt-fixup.c 
b/drivers/usb/common/fsl-dt-fixup.c
index 92adb46..eb13f12 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -19,33 +19,45 @@
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
 #endif
 
-static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode,
-  const char *phy_type, int start_offset)
+static const char *fdt_usb_get_node_type(void *blob, int start_offset,
+int *node_offset)
 {
const char *compat_dr = "fsl-usb2-dr";
const char *compat_mph = "fsl-usb2-mph";
-   const char *prop_mode = "dr_mode";
-   const char *prop_type = "phy_type";
const char *node_type = NULL;
-   int node_offset;
-   int err;
 
-   node_offset = fdt_node_offset_by_compatible(blob,
-   start_offset, compat_mph);
-   if (node_offset < 0) {
-   node_offset = fdt_node_offset_by_compatible(blob,
-   start_offset,
-   compat_dr);
-   if (node_offset < 0) {
-   printf("WARNING: could not find compatible node: %s",
-  fdt_strerror(node_offset));
-   return -1;
+   *node_offset = fdt_node_offset_by_compatible(blob, start_offset,
+compat_mph);
+   if (*node_offset < 0) {
+   *node_offset = fdt_node_offset_by_compatible(blob,
+start_offset,
+compat_dr);
+   if (*node_offset < 0) {
+   printf("ERROR: could not find compatible node: %s\n",
+  fdt_strerror(*node_offset));
+   } else {
+   node_type = compat_dr;
}
-   node_type = compat_dr;
} else {
node_type = compat_mph;
}
 
+   return node_type;
+}
+
+static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode,
+  const char *phy_type, int start_offset)
+{
+   const char *prop_mode = "dr_mode";
+   const char *prop_type = "phy_type";
+   const char *node_type = NULL;
+   int node_offset;
+   int err;
+
+   node_type = fdt_usb_get_node_type(blob, start_offset, &node_offset);
+   if (!node_type)
+   return -1;
+
if (mode) {
err = fdt_setprop(blob, node_offset, prop_mode, mode,
  strlen(mode) + 1);
@@ -65,32 +77,6 @@ static int fdt_fixup_usb_mode_phy_type(void *blob, const 
char *mode,
return node_offset;
 }
 
-static const char *fdt_usb_get_node_type(void *blob, int start_offset,
-int *node_offset)
-{
-   const char *compat_dr = "fsl-usb2-dr";
-   const char *compat_mph = "fsl-usb2-mph";
-   const char *node_type = NULL;
-
-   *node_offset = fdt_node_offset_by_compatible(blob, start_offset,
-compat_mph);
-   if (*node_offset < 0) {
-   *node_offset = fdt_node_offset_by_compatible(blob,
-start_offset,
-compat_dr);
-   if (*node_offset < 0) {
-   printf("ERROR: could not find compatible node: %s\n",
-  fdt_strerror(*node_offset));
-   } else {
-   node_type = compat_dr;
-   }
-   } else {
-   node_type = compat_mph;
-   }
-
-   return node_type;
-}
-
 static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum,
 int start_offset)
 {
-- 
2.1.0

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


[U-Boot] [PATCH v5 4/4] drivers:usb:common:fsl-dt-fixup: fix return value of fdt_usb_get_node_type

2016-03-22 Thread Sriram Dash
Use int as it is native (and widely used) return type.

Signed-off-by: Sriram Dash 
Signed-off-by: Rajesh Bhagat 
---
Changes in v5:
  - Modified title and description
  - Using error codes for return type.

 drivers/usb/common/fsl-dt-fixup.c | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/common/fsl-dt-fixup.c 
b/drivers/usb/common/fsl-dt-fixup.c
index 13f9fb8..7183b80 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -25,11 +25,11 @@ static const char compat_usb_fsl[] = {
"snps,dwc3" "\0"
 };
 
-static const char *fdt_usb_get_node_type(void *blob, int start_offset,
-int *node_offset)
+static int fdt_usb_get_node_type(void *blob, int start_offset,
+int *node_offset, const char **node_type)
 {
-   const char *node_type = NULL;
const char *node_name, *nxt;
+   int ret = -ENOENT;
 
for (node_name = compat_usb_fsl; *node_name; node_name = nxt + 1) {
nxt = node_name;
@@ -38,12 +38,13 @@ static const char *fdt_usb_get_node_type(void *blob, int 
start_offset,
*node_offset = fdt_node_offset_by_compatible
   (blob, start_offset, node_name);
if (*node_offset >= 0) {
-   node_type = node_name;
+   *node_type = node_name;
+   ret = 0;
break;
}
}
 
-   return node_type;
+   return ret;
 }
 
 static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode,
@@ -55,9 +56,10 @@ static int fdt_fixup_usb_mode_phy_type(void *blob, const 
char *mode,
int node_offset;
int err;
 
-   node_type = fdt_usb_get_node_type(blob, start_offset, &node_offset);
-   if (!node_type)
-   return -1;
+   err = fdt_usb_get_node_type(blob, start_offset,
+   &node_offset, &node_type);
+   if (err < 0)
+   return err;
 
if (mode) {
err = fdt_setprop(blob, node_offset, prop_mode, mode,
@@ -84,9 +86,10 @@ static int fdt_fixup_usb_erratum(void *blob, const char 
*prop_erratum,
int node_offset, err;
const char *node_type = NULL;
 
-   node_type = fdt_usb_get_node_type(blob, start_offset, &node_offset);
-   if (!node_type)
-   return -1;
+   err = fdt_usb_get_node_type(blob, start_offset,
+   &node_offset, &node_type);
+   if (err < 0)
+   return err;
 
err = fdt_setprop(blob, node_offset, prop_erratum, NULL, 0);
if (err < 0) {
-- 
2.1.0

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


[U-Boot] [PATCH v5 3/4] drivers:usb:common:fsl-dt-fixup: Add device-tree fixup support for xhci controller

2016-03-22 Thread Sriram Dash
Enables usb device-tree fixup code to incorporate xhci controller

Signed-off-by: Ramneek Mehresh 
Signed-off-by: Sriram Dash 
---
Changes in v5:
  - Make the array static const
Changes in v4:
  - Use a terminating entry in the array for getting node type for controller
Changes in v3:
  - Modify the Makefile to remove comparison
  - Put the supported controllers in array and checking from array
Changes in v2:
  - Remove the #defines from the patch and adding controller support

 drivers/usb/common/Makefile   |  1 +
 drivers/usb/common/fsl-dt-fixup.c | 33 +
 include/fdt_support.h |  4 ++--
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index a38ee4a..2f3d43d 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o
+obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o
diff --git a/drivers/usb/common/fsl-dt-fixup.c 
b/drivers/usb/common/fsl-dt-fixup.c
index eb13f12..13f9fb8 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -19,27 +19,28 @@
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
 #endif
 
+static const char compat_usb_fsl[] = {
+   "fsl-usb2-mph" "\0"
+   "fsl-usb2-dr" "\0"
+   "snps,dwc3" "\0"
+};
+
 static const char *fdt_usb_get_node_type(void *blob, int start_offset,
 int *node_offset)
 {
-   const char *compat_dr = "fsl-usb2-dr";
-   const char *compat_mph = "fsl-usb2-mph";
const char *node_type = NULL;
-
-   *node_offset = fdt_node_offset_by_compatible(blob, start_offset,
-compat_mph);
-   if (*node_offset < 0) {
-   *node_offset = fdt_node_offset_by_compatible(blob,
-start_offset,
-compat_dr);
-   if (*node_offset < 0) {
-   printf("ERROR: could not find compatible node: %s\n",
-  fdt_strerror(*node_offset));
-   } else {
-   node_type = compat_dr;
+   const char *node_name, *nxt;
+
+   for (node_name = compat_usb_fsl; *node_name; node_name = nxt + 1) {
+   nxt = node_name;
+   while (*nxt)
+   ++nxt;
+   *node_offset = fdt_node_offset_by_compatible
+  (blob, start_offset, node_name);
+   if (*node_offset >= 0) {
+   node_type = node_name;
+   break;
}
-   } else {
-   node_type = compat_mph;
}
 
return node_type;
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 296add0..d34e959 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -113,11 +113,11 @@ void fdt_fixup_qe_firmware(void *fdt);
  */
 int fdt_fixup_display(void *blob, const char *path, const char *display);
 
-#if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)
+#if defined(CONFIG_USB_EHCI_FSL) || defined(CONFIG_USB_XHCI_FSL)
 void fdt_fixup_dr_usb(void *blob, bd_t *bd);
 #else
 static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
-#endif /* defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) */
+#endif /* defined(CONFIG_USB_EHCI_FSL) || defined(CONFIG_USB_XHCI_FSL) */
 
 #if defined(CONFIG_SYS_FSL_SEC_COMPAT)
 void fdt_fixup_crypto_node(void *blob, int sec_rev);
-- 
2.1.0

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


[U-Boot] [RFC PATCH] net: phy: Force master mode for RTL8211C

2016-03-22 Thread Michael Haas
The RTL8211C found on the A20-OlinuXino-Lime2 does not word in slave
mode. This patch disables master/slave mode autonegotiation and forces
master mode.

The RTL8211C identifies itself as RTL8211B via its UID. This patch uses
the revision number taken from the PHYID2 register to distinguish the
two. The NetBSD driver uses the same approach.

CC: fra...@gmail.com
CC: mer...@debian.org
CC: hdego...@redhat.com
CC: i...@hellion.org.uk
CC: joe.hershber...@ni.com
Signed-off-by: Michael Haas 
---

 drivers/net/phy/realtek.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 259a87f..cdb3376 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -5,6 +5,7 @@
  *
  * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc.
  * author Andy Fleming
+ * Copyright 2016 Karsten Merker 
  */
 #include 
 #include 
@@ -54,6 +55,19 @@ static int rtl8211x_config(struct phy_device *phydev)
phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
  MIIM_RTL8211x_PHY_INTR_DIS);
 
+   int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
+   int rev = reg & 0xf;
+   if (rev == 3 & 6 phydev->phy_id == 0x1cc912) {
+   /* RTL8211C and RTL8211C are distinguished only by
+  their revision number */
+   reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
+   /* force manual master/slave configuration */
+   reg |= (1 << 12);
+   /* force master mode */
+   reg | = (1 << 11);
+   phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
+   }
+
/* read interrupt status just to clear it */
phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
 
@@ -223,7 +237,7 @@ static int rtl8211f_startup(struct phy_device *phydev)
 /* Support for RTL8211B PHY */
 static struct phy_driver RTL8211B_driver = {
.name = "RealTek RTL8211B",
-   .uid = 0x1cc910,
+   .uid = 0x1cc912,
.mask = 0xff,
.features = PHY_GBIT_FEATURES,
.config = &rtl8211x_config,
-- 
2.7.2

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


[U-Boot] [RFC PATCH 0/1] net: phy: Force master mode for RTL8211C

2016-03-22 Thread Michael Haas

This patch is an RFC based on recent discussions. It's only lightly
tested. I have yet to verify that the registers are being set correctly.
I'm sending it out now because I have to leave for today.

Michael



Michael Haas (1):
  net: phy: Force master mode for RTL8211C

 drivers/net/phy/realtek.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

-- 
2.7.2

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


Re: [U-Boot] [PATCH v5 3/4] drivers:usb:common:fsl-dt-fixup: Add device-tree fixup support for xhci controller

2016-03-22 Thread Marek Vasut
On 03/22/2016 08:10 AM, Sriram Dash wrote:
> Enables usb device-tree fixup code to incorporate xhci controller
> 
> Signed-off-by: Ramneek Mehresh 
> Signed-off-by: Sriram Dash 
> ---
> Changes in v5:
>   - Make the array static const
> Changes in v4:
>   - Use a terminating entry in the array for getting node type for controller
> Changes in v3:
>   - Modify the Makefile to remove comparison
>   - Put the supported controllers in array and checking from array
> Changes in v2:
>   - Remove the #defines from the patch and adding controller support
> 
>  drivers/usb/common/Makefile   |  1 +
>  drivers/usb/common/fsl-dt-fixup.c | 33 +
>  include/fdt_support.h |  4 ++--
>  3 files changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
> index a38ee4a..2f3d43d 100644
> --- a/drivers/usb/common/Makefile
> +++ b/drivers/usb/common/Makefile
> @@ -4,3 +4,4 @@
>  #
>  
>  obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o
> +obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o
> diff --git a/drivers/usb/common/fsl-dt-fixup.c 
> b/drivers/usb/common/fsl-dt-fixup.c
> index eb13f12..13f9fb8 100644
> --- a/drivers/usb/common/fsl-dt-fixup.c
> +++ b/drivers/usb/common/fsl-dt-fixup.c
> @@ -19,27 +19,28 @@
>  #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
>  #endif
>  
> +static const char compat_usb_fsl[] = {
> + "fsl-usb2-mph" "\0"
> + "fsl-usb2-dr" "\0"
> + "snps,dwc3" "\0"
> +};

This is supposed to be static constant array of strings. Can you tell
me, based on your knowledge of the C language, what is wrong with this
construct ?

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


Re: [U-Boot] [PATCH v5 2/4] drivers:usb:common:fsl-dt-fixup: Remove code duplication for fdt_usb_get_node_type

2016-03-22 Thread Marek Vasut
On 03/22/2016 08:10 AM, Sriram Dash wrote:
> Call fdt_usb_get_node_type() from fdt_fixup_usb_mode_phy_type() to
> avoid code duplication.
> 
> Signed-off-by: Sriram Dash 
> Signed-off-by: Rajesh Bhagat 

Acked-by: Marek Vasut 

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


Re: [U-Boot] [PATCH v5 1/4] drivers:usb:common:fsl-dt-fixup: Move device-tree fixup framework to common file

2016-03-22 Thread Marek Vasut
On 03/22/2016 08:10 AM, Sriram Dash wrote:
> Move usb device-tree fixup framework from ehci-fsl.c to common place so
> that it can be used by other drivers as well (xhci-fsl.c).
> 
> Signed-off-by: Ramneek Mehresh 
> Signed-off-by: Sriram Dash 

Acked-by: Marek Vasut 

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


Re: [U-Boot] [PATCH v5 4/4] drivers:usb:common:fsl-dt-fixup: fix return value of fdt_usb_get_node_type

2016-03-22 Thread Marek Vasut
On 03/22/2016 08:10 AM, Sriram Dash wrote:
> Use int as it is native (and widely used) return type.

What do you mean by "int ... is native (and widely used) return type" ?

It's just a signed type, that's all there is to it.

> Signed-off-by: Sriram Dash 
> Signed-off-by: Rajesh Bhagat 

[...]

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


[U-Boot] [PATCH v5 0/4] Make usb device-tree fixup independent of USB controller

2016-03-22 Thread Sriram Dash
Makes usb device-tree fixup independent of Controller type. This enables the
usage of device-tree fixup as a common framework for EHCI and XHCI controllers

Sriram Dash (4):
  drivers:usb:common:fsl-dt-fixup: Move device-tree fixup framework to
common file
  drivers:usb:common:fsl-dt-fixup: Remove code duplication for
fdt_usb_get_node_type
  drivers:usb:common:fsl-dt-fixup: Add device-tree fixup support for
xhci controller
  drivers:usb:common:fsl-dt-fixup: fix return value of
fdt_usb_get_node_type

 Makefile  |   1 +
 drivers/usb/common/Makefile   |   7 ++
 drivers/usb/common/fsl-dt-fixup.c | 203 ++
 drivers/usb/host/ehci-fsl.c   | 195 
 include/fdt_support.h |   4 +-
 5 files changed, 213 insertions(+), 197 deletions(-)
 create mode 100644 drivers/usb/common/Makefile
 create mode 100644 drivers/usb/common/fsl-dt-fixup.c

-- 
2.1.0

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


[U-Boot] [PATCH v7 00/87] mtd: Add SPI-NOR core support

2016-03-22 Thread Jagan Teki
Some of the SPI device drivers at drivers/spi not a real
spi controllers, Unlike normal/generic SPI controllers they
operates only with SPI-NOR flash devices. these were technically
termed as SPI-NOR controllers, Ex: drivers/spi/fsl_qspi.c

The problem with these were resides at drivers/spi is entire
SPI layer becomes SPI-NOR flash oriented which is absolutely
a wrong indication where SPI layer getting effected more with
flash operations - So this SPI-NOR core will resolve this issue
by separating all SPI-NOR flash operations from spi layer and
creats a generic layer called SPI-NOR core which can be used to
interact SPI-NOR to SPI driver interface layer and the SPI-NOR
controller driver. The idea is taken from Linux spi-nor framework.

Before SPI-NOR:

---
cmd/sf.c
---
spi_flash.c
---
sf_probe.c
---
spi-uclass
---
spi drivers
---
SPI NOR chip
---

After SPI-NOR:

--
cmd/sf.c
--
spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

SPI-NOR with MTD:

--
cmd/sf.c
--
MTD core
--
spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

drivers/mtd/spi-nor/spi-nor.c: spi-nor core
drivers/mtd/spi-nor/m25p80.c: mtd uclass driver
which is an interface layer b/w spi-nor core drivers/spi
drivers/mtd/spi-nor/fsl_qspi.c: spi-nor controller driver(mtd uclass)

Changes for v7:
- Rebase to latest
- Fixed git bisectable issues, with buildman.
- Fixed spi-nor compilation issues
- newly designed changes.

Changes for v6:
- Fixed git bisectable issues, with buildman.
- Fixed spi-nor compilation issues
- newly designed changes.

Changes for v5:
- newly designed changes

Testing:
$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b spi-nor-test origin/spi-nor-test

Alison Wang (1):
  defconfig: ls1021atwr_sdcard_qspi: Enable CONFIG_MTD

Jagan Teki (86):
  mtd: Add m25p80 driver
  mtd: Add Kconfig entry for MTD_M25P80
  mtd: Add SPI-NOR core support
  doc: device-tree-bindings: jedec,spi-nor
  mtd: spi-nor: Add Kconfig entry for MTD_SPI_NOR
  mtd: spi-nor: Add kconfig for MTD_SPI_NOR_USE_4K_SECTORS
  mtd: spi-nor: Add MTD support
  mtd: spi-nor: Add spi_nor support in m25p80
  mtd: spi-nor: Add dm spi-nor probing
  mtd: spi-nor: Add spi_flash_probe for mtd-dm-spi-nor
  mtd: spi-nor: Add spi_flash_free for mtd-dm-spi-nor
  mtd: spi-nor: m25p80: Add spi_nor support for non-dm
  sf: Rename erase_size to erasesize
  sf: Use erasesize instead of sector_size
  sf: Use uint64_t for flash->size
  spi_flash: Use mtd_info operation for SPI-NOR
  spi_flash: Use spi_flash_t instead of struct spi_flash
  mtd: spi-nor: Move spi_read_then_write to spi layer
  spi: Rename spi_read_then_write to spi_write_then_read
  mtd: spi-nor: Rename SPI_FLASH_BAR to SPI_NOR_BAR
  mtd: spi-nor: Add Kconfig entry for SPI_NOR_BAR
  mtd: spi-nor: Copy spl files from drivers/mtd/spi
  mtd: spi-nor: spl: Follow ascending order of include headers
  mtd: spi-nor: fsl_espi_spl: Use mtd_info
  mtd: spi-nor: fsl_espi_spl: Use writebufsize instead of page_size
  mtd: spi-nor: spi_spl_load: Use mtd_info
  spl: Add CONFIG_SPL_SPI_NOR_SUPPORT
  mtd: spi-nor: Add flash vendor Kconfig entries
  arm: zynq: Kconfig: Select MTD uclass
  arm: zynq: Kconfig: Drop DM_SPI_FLASH
  mtd: spi-nor: Copy sf_dataflash
  mtd: dataflash: Remove unneeded spi data
  mtd: dataflash: Move flash id detection into jedec_probe
  mtd: dataflash: Fix add_dataflash return logic
  mtd: dataflash: Add UCLASS_MTD support
  mtd: dataflash: Use spi_write_then_read
  mtd: dataflash: Drop sf_internal.h
  mtd: dataflash: Minor cleanups
  mtd: Rename sf_dataflash.c to mtd_dataflash.c
  mtd: spi-nor: Add Kconfig entry for mtd_dataflash
  mtd: dataflash: Add MTD_DATAFLASH_WRITE_VERIFY
  mtd: spi-nor: Add kconfig MTD_DATAFLASH_WRITE_VERIFY
  configs: ls1021aqds: Drop DM_SPI_FLASH and DATAFLASH
  defconfig: ls1021aqds_qspi: Enable SPI-NOR
  defconfig: ls1021aqds_qspi: Enable CONFIG_MTD_DATAFLASH
  mtd: spi-nor: Copy sandbox
  mtd: spi-nor: sandbox: Use spi-nor header
  mtd: spi-nor: sandbox: Fix ID exctract from spi_nor_info
  mtd: spi-nor: Add SPI_NOR_SANDBOX
  test/dm: Makefile: Use CONFIG_DM_MTD_SPI_NOR
  test/dm: spi: Use CONFIG_DM_MTD_SPI_NOR
  configs: sandbox: Enable SPI-NOR sandbox driver
  test/dm: spi: Use m25p80 as dri

[U-Boot] [PATCH v7 02/87] mtd: Add Kconfig entry for MTD_M25P80

2016-03-22 Thread Jagan Teki
Added Kconfig entry for MTD_M25P80

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/Kconfig

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
new file mode 100644
index 000..d32486c
--- /dev/null
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -0,0 +1,15 @@
+config MTD_M25P80
+   tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)"
+   help
+ This enables access to most modern SPI flash chips, used for
+ program and data storage.   Series supported include Atmel AT26DF,
+ Spansion S25SL, SST 25VF, ST M25P, and Winbond W25X.  Other chips
+ are supported as well.  See the driver source for the current list,
+ or to add other chips.
+
+ Note that the original DataFlash chips (AT45 series, not AT26DF),
+ need an entirely different driver.
+
+ Set up your spi devices with the right board-specific platform data,
+ if you want to specify device partitioning or to use a device which
+ doesn't support the JEDEC ID instruction.
-- 
1.9.1

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


[U-Boot] [PATCH v7 01/87] mtd: Add m25p80 driver

2016-03-22 Thread Jagan Teki
This is MTD SPI-NOR driver for ST M25Pxx (and similar)
serial flash chips which is written as MTD_UCLASS.

More features will be adding on further patches.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 Makefile |  1 +
 drivers/mtd/spi-nor/Makefile |  6 ++
 drivers/mtd/spi-nor/m25p80.c | 37 +
 3 files changed, 44 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/Makefile
 create mode 100644 drivers/mtd/spi-nor/m25p80.c

diff --git a/Makefile b/Makefile
index 53569e8..9830410 100644
--- a/Makefile
+++ b/Makefile
@@ -633,6 +633,7 @@ libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
 libs-y += drivers/mtd/onenand/
 libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
 libs-y += drivers/mtd/spi/
+libs-y += drivers/mtd/spi-nor/
 libs-y += drivers/net/
 libs-y += drivers/net/phy/
 libs-y += drivers/pci/
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
new file mode 100644
index 000..a4c19e3
--- /dev/null
+++ b/drivers/mtd/spi-nor/Makefile
@@ -0,0 +1,6 @@
+#
+# Copyright (C) 2016 Jagan Teki 
+#
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_MTD_M25P80)   += m25p80.o
diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
new file mode 100644
index 000..833a9c3
--- /dev/null
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -0,0 +1,37 @@
+/*
+ * MTD SPI-NOR driver for ST M25Pxx (and similar) serial flash chips
+ *
+ * Copyright (C) 2016 Jagan Teki 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int m25p_probe(struct udevice *dev)
+{
+   struct spi_slave *spi = dev_get_parent_priv(dev);
+   struct mtd_info *mtd = dev_get_uclass_priv(dev);
+
+   return 0;
+}
+
+static const struct udevice_id m25p_ids[] = {
+   /*
+* Generic compatibility for SPI NOR that can be identified by the
+* JEDEC READ ID opcode (0x9F). Use this, if possible.
+*/
+   { .compatible = "jedec,spi-nor" },
+   { }
+};
+
+U_BOOT_DRIVER(m25p80) = {
+   .name   = "m25p80",
+   .id = UCLASS_MTD,
+   .of_match   = m25p_ids,
+   .probe  = m25p_probe,
+};
-- 
1.9.1

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


[U-Boot] [PATCH v7 03/87] mtd: Add SPI-NOR core support

2016-03-22 Thread Jagan Teki
Some of the SPI device drivers at drivers/spi not a real
spi controllers, Unlike normal/generic SPI controllers they
operates only with SPI-NOR flash devices. these were technically
termed as SPI-NOR controllers, Ex: drivers/spi/fsl_qspi.c

The problem with these were resides at drivers/spi is entire
SPI layer becomes SPI-NOR flash oriented which is absolutely
a wrong indication where SPI layer getting effected more with
flash operations - So this SPI-NOR core will resolve this issue
by separating all SPI-NOR flash operations from spi layer and
creats a generic layer called SPI-NOR core which can be used to
interact SPI-NOR to SPI driver interface layer and the SPI-NOR
controller driver. The idea is taken from Linux spi-nor framework.

Before SPI-NOR:

---
cmd_sf.c
---
spi_flash.c
---
sf_probe.c
---
spi-uclass
---
spi drivers
---
SPI NOR chip
---

After SPI-NOR:

--
cmd_sf.c
--
spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

Cc: Simon Glass 
Cc: Bin Meng 
Cc: York Sun 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 doc/mtd/spi-nor.txt   |   81 +++
 drivers/mtd/Kconfig   |2 +
 drivers/mtd/spi-nor/Makefile  |5 +
 drivers/mtd/spi-nor/spi-nor-ids.c |  276 ++
 drivers/mtd/spi-nor/spi-nor.c | 1084 +
 include/linux/err.h   |5 +
 include/linux/mtd/spi-nor.h   |  253 +
 7 files changed, 1706 insertions(+)
 create mode 100644 doc/mtd/spi-nor.txt
 create mode 100644 drivers/mtd/spi-nor/spi-nor-ids.c
 create mode 100644 drivers/mtd/spi-nor/spi-nor.c
 create mode 100644 include/linux/mtd/spi-nor.h

diff --git a/doc/mtd/spi-nor.txt b/doc/mtd/spi-nor.txt
new file mode 100644
index 000..8b381c1
--- /dev/null
+++ b/doc/mtd/spi-nor.txt
@@ -0,0 +1,81 @@
+  SPI NOR framework
+   
+
+Part I - Why do we need this framework?
+---
+
+SPI bus controllers (drivers/spi/) only deal with streams of bytes; the bus
+controller operates agnostic of the specific device attached. However, some
+controllers (such as Freescale's QuadSPI controller) cannot easily handle
+arbitrary streams of bytes, but rather are designed specifically for SPI NOR.
+
+In particular, Freescale's QuadSPI controller must know the NOR commands to
+find the right LUT sequence. Unfortunately, the SPI subsystem has no notion of
+opcodes, addresses, or data payloads; a SPI controller simply knows to send or
+receive bytes (Tx and Rx). Therefore, we must define a new layering scheme 
under
+which the controller driver is aware of the opcodes, addressing, and other
+details of the SPI NOR protocol.
+
+Part II - How does the framework work?
+--
+
+This framework just adds a new layer between the MTD and the SPI bus driver.
+With this new layer, the SPI NOR controller driver does not depend on the
+m25p80 code anymore.
+
+Before SPI-NOR:
+
+   ---
+   cmd_sf.c
+   ---
+   spi_flash.c
+   ---
+   sf_probe.c
+   ---
+   spi-uclass
+   ---
+   spi drivers
+   ---
+   SPI NOR chip
+   ---
+
+After SPI-NOR:
+
+   --
+   cmd_sf.c
+   --
+   spi-nor.c
+   ---
+   m25p80.cspi nor drivers
+   ---
+   spi-uclass  SPI NOR chip
+   ---
+   spi drivers
+   ---
+   SPI NOR chip
+   ---
+
+SPI-NOR with MTD:
+
+   --
+   cmd_sf.c
+   --
+   MTD core
+   --
+   spi-nor.c
+   ---
+   m25p80.cspi nor drivers
+   ---
+   spi-uclass  SPI NOR chip
+   ---
+   s

[U-Boot] [PATCH v7 04/87] doc: device-tree-bindings: jedec, spi-nor

2016-03-22 Thread Jagan Teki
Since m25p80 follows similar naming convention as Linux,
hence added jedec, spi-nor device tree bindings from Linux.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 doc/device-tree-bindings/mtd/jedec,spi-nor.txt | 78 ++
 1 file changed, 78 insertions(+)
 create mode 100644 doc/device-tree-bindings/mtd/jedec,spi-nor.txt

diff --git a/doc/device-tree-bindings/mtd/jedec,spi-nor.txt 
b/doc/device-tree-bindings/mtd/jedec,spi-nor.txt
new file mode 100644
index 000..2c91c03
--- /dev/null
+++ b/doc/device-tree-bindings/mtd/jedec,spi-nor.txt
@@ -0,0 +1,78 @@
+* SPI NOR flash: ST M25Pxx (and similar) serial flash chips
+
+Required properties:
+- #address-cells, #size-cells : Must be present if the device has sub-nodes
+  representing partitions.
+- compatible : May include a device-specific string consisting of the
+   manufacturer and name of the chip. A list of supported chip
+   names follows.
+   Must also include "jedec,spi-nor" for any SPI NOR flash that can
+   be identified by the JEDEC READ ID opcode (0x9F).
+
+   Supported chip names:
+ at25df321a
+ at25df641
+ at26df081a
+ mr25h256
+ mx25l4005a
+ mx25l1606e
+ mx25l6405d
+ mx25l12805d
+ mx25l25635e
+ n25q064
+ n25q128a11
+ n25q128a13
+ n25q512a
+ s25fl256s1
+ s25fl512s
+ s25sl12801
+ s25fl008k
+ s25fl064k
+ sst25vf040b
+ m25p40
+ m25p80
+ m25p16
+ m25p32
+ m25p64
+ m25p128
+ w25x80
+ w25x32
+ w25q32
+ w25q32dw
+ w25q80bl
+ w25q128
+ w25q256
+
+   The following chip names have been used historically to
+   designate quirky versions of flash chips that do not support the
+   JEDEC READ ID opcode (0x9F):
+ m25p05-nonjedec
+ m25p10-nonjedec
+ m25p20-nonjedec
+ m25p40-nonjedec
+ m25p80-nonjedec
+ m25p16-nonjedec
+ m25p32-nonjedec
+ m25p64-nonjedec
+ m25p128-nonjedec
+
+- reg : Chip-Select number
+- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
+
+Optional properties:
+- m25p,fast-read : Use the "fast read" opcode to read data from the chip 
instead
+   of the usual "read" opcode. This opcode is not supported by
+   all chips and support for it can not be detected at runtime.
+   Refer to your chips' datasheet to check if this is supported
+   by your chip.
+
+Example:
+
+   flash: m25p80@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "spansion,m25p80", "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <4000>;
+   m25p,fast-read;
+   };
-- 
1.9.1

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


[U-Boot] [PATCH v7 06/87] mtd: spi-nor: Add kconfig for MTD_SPI_NOR_USE_4K_SECTORS

2016-03-22 Thread Jagan Teki
Added kconfig entry for MTD_SPI_NOR_USE_4K_SECTORS.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index f0ea9f9..374cdcb 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -30,4 +30,18 @@ config MTD_M25P80
  if you want to specify device partitioning or to use a device which
  doesn't support the JEDEC ID instruction.
 
+config MTD_SPI_NOR_USE_4K_SECTORS
+   bool "Use small 4096 B erase sectors"
+   default y
+   help
+ Many flash memories support erasing small (4096 B) sectors. Depending
+ on the usage this feature may provide performance gain in comparison
+ to erasing whole blocks (32/64 KiB).
+ Changing a small part of the flash's contents is usually faster with
+ small sectors. On the other hand erasing should be faster when using
+ 64 KiB block instead of 16 × 4 KiB sectors.
+
+ Please note that some tools/drivers/filesystems may not work with
+ 4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
+
 endif # MTD_SPI_NOR
-- 
1.9.1

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


[U-Boot] [PATCH v7 05/87] mtd: spi-nor: Add Kconfig entry for MTD_SPI_NOR

2016-03-22 Thread Jagan Teki
Added kconfig entry for MTD_SPI_NOR

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index d32486c..f0ea9f9 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -1,3 +1,19 @@
+menuconfig MTD_SPI_NOR
+   tristate "SPI-NOR device support"
+   help
+ This is the core SPI NOR framework which can be used to interact 
SPI-NOR
+ to SPI driver interface layer and the SPI-NOR controller driver.
+
+ Unlike normal/generic spi controllers, they are few controllers which 
are
+ exclusively used to connect SPI-NOR devices, called SPI-NOR 
controllers.
+ So technically these controllers shouldn't reside at drivers/spi as 
these
+ may effect the generic SPI bus functionalities, so this SPI-NOR core 
acts
+ as a common core framework between the generic SPI controller drivers 
vs
+ SPI-NOR controller drivers for SPI-NOR device access. Note that from 
SPI-NOR
+ core to SPI drivers there should be an interface layer.
+
+if MTD_SPI_NOR
+
 config MTD_M25P80
tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)"
help
@@ -13,3 +29,5 @@ config MTD_M25P80
  Set up your spi devices with the right board-specific platform data,
  if you want to specify device partitioning or to use a device which
  doesn't support the JEDEC ID instruction.
+
+endif # MTD_SPI_NOR
-- 
1.9.1

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


[U-Boot] [PATCH v7 10/87] mtd: spi-nor: Add spi_flash_probe for mtd-dm-spi-nor

2016-03-22 Thread Jagan Teki
While probing spi-nor in SPL spi_flash_probe is needed,
so add the flash probe code in spi-nor-probe.c

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor-probe.c | 15 +++
 include/spi_flash.h |  6 ++
 2 files changed, 21 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor-probe.c 
b/drivers/mtd/spi-nor/spi-nor-probe.c
index 532d8a7..713968b 100644
--- a/drivers/mtd/spi-nor/spi-nor-probe.c
+++ b/drivers/mtd/spi-nor/spi-nor-probe.c
@@ -9,6 +9,21 @@
 #include 
 #include 
 
+/*
+ * TODO(s...@chromium.org): This is an old-style function. We should remove
+ * it when all SPI flash drivers use dm
+ */
+spi_flash_t *spi_flash_probe(unsigned int bus, unsigned int cs,
+unsigned int max_hz, unsigned int spi_mode)
+{
+   struct udevice *dev;
+
+   if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
+   return NULL;
+
+   return dev_get_uclass_priv(dev);
+}
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
   struct udevice **devp)
diff --git a/include/spi_flash.h b/include/spi_flash.h
index d39941f..0350767 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -110,10 +110,16 @@ struct spi_flash {
 
 #if defined(CONFIG_MTD_SPI_NOR) && defined(CONFIG_DM_MTD_SPI_NOR)
 
+typedef struct mtd_info spi_flash_t;
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
   struct udevice **devp);
 
+/* Compatibility function - this is the old U-Boot API */
+spi_flash_t *spi_flash_probe(unsigned int bus, unsigned int cs,
+unsigned int max_hz, unsigned int spi_mode);
+
 #endif
 
 struct dm_spi_flash_ops {
-- 
1.9.1

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


[U-Boot] [PATCH v7 11/87] mtd: spi-nor: Add spi_flash_free for mtd-dm-spi-nor

2016-03-22 Thread Jagan Teki
env_sf need to free the flash while read error, so
add the flash probe code in spi-nor-probe.c

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor-probe.c | 7 +++
 include/spi_flash.h | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor-probe.c 
b/drivers/mtd/spi-nor/spi-nor-probe.c
index 713968b..76c48b7 100644
--- a/drivers/mtd/spi-nor/spi-nor-probe.c
+++ b/drivers/mtd/spi-nor/spi-nor-probe.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 
+#include 
+
 /*
  * TODO(s...@chromium.org): This is an old-style function. We should remove
  * it when all SPI flash drivers use dm
@@ -24,6 +26,11 @@ spi_flash_t *spi_flash_probe(unsigned int bus, unsigned int 
cs,
return dev_get_uclass_priv(dev);
 }
 
+void spi_flash_free(spi_flash_t *flash)
+{
+   device_remove(flash->dev);
+}
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
   struct udevice **devp)
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 0350767..5895d8b 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -120,6 +120,9 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned 
int cs,
 spi_flash_t *spi_flash_probe(unsigned int bus, unsigned int cs,
 unsigned int max_hz, unsigned int spi_mode);
 
+/* Compatibility function - this is the old U-Boot API */
+void spi_flash_free(spi_flash_t *flash);
+
 #endif
 
 struct dm_spi_flash_ops {
-- 
1.9.1

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


[U-Boot] [PATCH v7 07/87] mtd: spi-nor: Add MTD support

2016-03-22 Thread Jagan Teki
This patch adds mtd_info support to spi-nor core instead
of using legacy spi_flash{}.

SPI-NOR with MTD:

--
cmd_sf.c
--
MTD core
--
spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor.c | 275 +-
 1 file changed, 166 insertions(+), 109 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index f142ae4..b867ce9 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -14,6 +15,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -209,10 +211,11 @@ bar_end:
 
 static int spi_nor_read_bar(struct spi_nor *nor, const struct spi_nor_info 
*info)
 {
+   struct mtd_info *mtd = nor->mtd;
u8 curr_bank = 0;
int ret;
 
-   if (flash->size <= SNOR_16MB_BOUN)
+   if (mtd->size <= SNOR_16MB_BOUN)
goto bar_end;
 
switch (JEDEC_MFR(info)) {
@@ -240,12 +243,12 @@ bar_end:
 #ifdef CONFIG_SF_DUAL_FLASH
 static void spi_nor_dual(struct spi_nor *nor, u32 *addr)
 {
-   struct spi_flash *flash = nor->flash;
+   struct mtd_info *mtd = nor->mtd;
 
switch (nor->dual) {
case SNOR_DUAL_STACKED:
-   if (*addr >= (flash->size >> 1)) {
-   *addr -= flash->size >> 1;
+   if (*addr >= (mtd->size >> 1)) {
+   *addr -= mtd->size >> 1;
nor->flags |= SNOR_F_U_PAGE;
} else {
nor->flags &= ~SNOR_F_U_PAGE;
@@ -263,8 +266,9 @@ static void spi_nor_dual(struct spi_nor *nor, u32 *addr)
 
 #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
 static void stm_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs,
-u32 *len)
+uint64_t *len)
 {
+   struct mtd_info *mtd = nor->mtd;
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
int shift = ffs(mask) - 1;
int pow;
@@ -275,18 +279,19 @@ static void stm_get_locked_range(struct spi_nor *nor, u8 
sr, loff_t *ofs,
*len = 0;
} else {
pow = ((sr & mask) ^ mask) >> shift;
-   *len = flash->size >> pow;
-   *ofs = flash->size - *len;
+   *len = mtd->size >> pow;
+   *ofs = mtd->size - *len;
}
 }
 
 /*
  * Return 1 if the entire region is locked, 0 otherwise
  */
-static int stm_is_locked_sr(struct spi_nor *nor, u32 ofs, u32 len, u8 sr)
+static int stm_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len,
+   u8 sr)
 {
loff_t lock_offs;
-   u32 lock_len;
+   uint64_t lock_len;
 
stm_get_locked_range(nor, sr, &lock_offs, &lock_len);
 
@@ -294,24 +299,6 @@ static int stm_is_locked_sr(struct spi_nor *nor, u32 ofs, 
u32 len, u8 sr)
 }
 
 /*
- * Check if a region of the flash is (completely) locked. See stm_lock() for
- * more info.
- *
- * Returns 1 if entire region is locked, 0 if any portion is unlocked, and
- * negative on errors.
- */
-static int stm_is_locked(struct spi_nor *nor, u32 ofs, size_t len)
-{
-   int status;
-
-   status = read_sr(nor);
-   if (status < 0)
-   return status;
-
-   return stm_is_locked_sr(nor, ofs, len, status);
-}
-
-/*
  * Lock a region of the flash. Compatible with ST Micro and similar flash.
  * Supports only the block protection bits BP{0,1,2} in the status register
  * (SR). Does not support these features found in newer SR bitfields:
@@ -334,9 +321,10 @@ static int stm_is_locked(struct spi_nor *nor, u32 ofs, 
size_t len)
  *
  * Returns negative on errors, 0 on success.
  */
-static int stm_lock(struct spi_nor *nor, u32 ofs, size_t len)
+static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
 {
-   u8 status_old, status_new;
+   struct mtd_info *mtd = nor->mtd;
+   int status_old, status_new;
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
u8 shift = ffs(mask) - 1, pow, val;
 
@@ -345,12 +333,12 @@ static int stm_lock(struct spi_nor *nor, u32 ofs, size_t 
len)
return status_old;
 
/* SPI NOR always locks to the end */
-   if (ofs + len != flash->size) {
+   if (ofs + len != mtd->size) {
/* Does combined region extend to end? */
-   if 

[U-Boot] [PATCH v7 09/87] mtd: spi-nor: Add dm spi-nor probing

2016-03-22 Thread Jagan Teki
This patch adds driver-model probe from cmd_sf through
MTD_DM_SPI_NOR which is depends on MTD and DM_SPI uclass.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 cmd/sf.c|  4 ++--
 common/env_sf.c |  4 ++--
 drivers/mtd/spi-nor/Kconfig |  7 +++
 drivers/mtd/spi-nor/Makefile|  2 ++
 drivers/mtd/spi-nor/spi-nor-probe.c | 36 
 include/spi_flash.h | 18 +-
 6 files changed, 66 insertions(+), 5 deletions(-)
 create mode 100644 drivers/mtd/spi-nor/spi-nor-probe.c

diff --git a/cmd/sf.c b/cmd/sf.c
index 42862d9..89ab41e 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -85,7 +85,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
unsigned int mode = CONFIG_SF_DEFAULT_MODE;
char *endp;
-#ifdef CONFIG_DM_SPI_FLASH
+#if defined(CONFIG_DM_SPI_FLASH) || defined(CONFIG_DM_MTD_SPI_NOR)
struct udevice *new, *bus_dev;
int ret;
 #else
@@ -118,7 +118,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
return -1;
}
 
-#ifdef CONFIG_DM_SPI_FLASH
+#if defined(CONFIG_DM_SPI_FLASH) || defined(CONFIG_DM_MTD_SPI_NOR)
/* Remove the old device, otherwise probe will just be a nop */
ret = spi_find_bus_and_cs(bus, cs, &bus_dev, &new);
if (!ret) {
diff --git a/common/env_sf.c b/common/env_sf.c
index 892e6cb..ec88792 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -52,7 +52,7 @@ int saveenv(void)
char*saved_buffer = NULL, flag = OBSOLETE_FLAG;
u32 saved_size, saved_offset, sector = 1;
int ret;
-#ifdef CONFIG_DM_SPI_FLASH
+#if defined(CONFIG_DM_SPI_FLASH) || defined(CONFIG_DM_MTD_SPI_NOR)
struct udevice *new;
 
ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
@@ -242,7 +242,7 @@ int saveenv(void)
char*saved_buffer = NULL;
int ret = 1;
env_t   env_new;
-#ifdef CONFIG_DM_SPI_FLASH
+#if defined(CONFIG_DM_SPI_FLASH) || defined(CONFIG_DM_MTD_SPI_NOR)
struct udevice *new;
 
ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 374cdcb..342164d 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -1,5 +1,6 @@
 menuconfig MTD_SPI_NOR
tristate "SPI-NOR device support"
+   select DM_MTD_SPI_NOR if DM_SPI && MTD
help
  This is the core SPI NOR framework which can be used to interact 
SPI-NOR
  to SPI driver interface layer and the SPI-NOR controller driver.
@@ -12,6 +13,12 @@ menuconfig MTD_SPI_NOR
  SPI-NOR controller drivers for SPI-NOR device access. Note that from 
SPI-NOR
  core to SPI drivers there should be an interface layer.
 
+config DM_MTD_SPI_NOR
+   bool "MTD driver model for SPI-NOR"
+   help
+ This is enables MTD driver model support for SPI-NOR. Both MTD and SPI
+ driver models need to define for enabling this support.
+
 if MTD_SPI_NOR
 
 config MTD_M25P80
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 9ab6e3d..2f41630 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -6,6 +6,8 @@
 ifdef CONFIG_MTD_SPI_NOR
 obj-y += spi-nor.o
 obj-y += spi-nor-ids.o
+
+obj-$(CONFIG_DM_MTD_SPI_NOR)   += spi-nor-probe.o
 endif
 
 obj-$(CONFIG_MTD_M25P80)   += m25p80.o
diff --git a/drivers/mtd/spi-nor/spi-nor-probe.c 
b/drivers/mtd/spi-nor/spi-nor-probe.c
new file mode 100644
index 000..532d8a7
--- /dev/null
+++ b/drivers/mtd/spi-nor/spi-nor-probe.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
+  unsigned int max_hz, unsigned int spi_mode,
+  struct udevice **devp)
+{
+   struct spi_slave *slave;
+   struct udevice *bus;
+   char *str;
+   int ret;
+
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_USE_TINY_PRINTF)
+   str = "spi_flash";
+#else
+   char name[30];
+
+   snprintf(name, sizeof(name), "spi_flash@%d:%d", busnum, cs);
+   str = strdup(name);
+#endif
+   ret = spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode,
+ "spi_flash_std", str, &bus, &slave);
+   if (ret)
+   return ret;
+
+   *devp = slave->dev;
+   return 0;
+}
diff --git a/include/spi_flash.h b/include/spi_flash.h
index d0ce9e7..d39941f 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -108,6 +108,14 @@ struct spi_flash {
 #endif
 };
 
+#if defined(CONFIG_MTD_SPI_NOR) && defined(CONFIG_DM_MTD_SPI_NOR)
+
+int spi_

[U-Boot] [PATCH v7 08/87] mtd: spi-nor: Add spi_nor support in m25p80

2016-03-22 Thread Jagan Teki
m25p80 is flash interface for spi-nor core and drivers/spi
so add spi_nor{} functionalities like
- allocate spi_nor{}
- basic initilization
- install hooks
- call to spi-nor core, using spi_nor_scan
- register with mtd core

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 245 +++
 1 file changed, 245 insertions(+)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 833a9c3..6a892d2 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -8,16 +8,260 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
+
+#include 
+
 #include 
+#include 
+
+struct m25p {
+   struct spi_slave*spi;
+   struct spi_nor  spi_nor;
+};
+
+static int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
+  size_t cmd_len, const u8 *data_out,
+  u8 *data_in, size_t data_len)
+{
+   unsigned long flags = SPI_XFER_BEGIN;
+   int ret;
+
+   if (data_len == 0)
+   flags |= SPI_XFER_END;
+
+   ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
+   if (ret) {
+   debug("SF: Failed to send command (%zu bytes): %d\n",
+ cmd_len, ret);
+   } else if (data_len != 0) {
+   ret = spi_xfer(spi, data_len * 8, data_out, data_in,
+   SPI_XFER_END);
+   if (ret)
+   debug("SF: Failed to transfer %zu bytes of data: %d\n",
+ data_len, ret);
+   }
+
+   return ret;
+}
+
+static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len)
+{
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
+   int ret;
+
+   ret = spi_claim_bus(spi);
+   if (ret < 0) {
+   debug("m25p80: unable to claim SPI bus\n");
+   return ret;
+   }
+
+   if (nor->flags & SNOR_F_U_PAGE)
+   spi->flags |= SPI_XFER_U_PAGE;
+
+   ret = spi_read_then_write(spi, &cmd, 1, NULL, val, len);
+   if (ret < 0) {
+   debug("m25p80: error %d reading register %x\n", ret, cmd);
+   return ret;
+   }
+
+   spi_release_bus(spi);
+
+   return ret;
+}
+
+static int m25p80_write_reg(struct spi_nor *nor, u8 cmd, u8 *buf, int len)
+{
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
+   int ret;
+
+   ret = spi_claim_bus(spi);
+   if (ret < 0) {
+   debug("m25p80: unable to claim SPI bus\n");
+   return ret;
+   }
+
+   if (nor->flags & SNOR_F_U_PAGE)
+   spi->flags |= SPI_XFER_U_PAGE;
+
+   ret = spi_read_then_write(spi, &cmd, 1, buf, NULL, len);
+   if (ret < 0) {
+   debug("m25p80: error %d writing register %x\n", ret, cmd);
+   return ret;
+   }
+
+   spi_release_bus(spi);
+
+   return ret;
+}
+
+/*
+ * TODO: remove the weak after all the other spi_flash_copy_mmap
+ * implementations removed from drivers
+ */
+void __weak flash_copy_mmap(void *data, void *offset, size_t len)
+{
+#ifdef CONFIG_DMA
+   if (!dma_memcpy(data, offset, len))
+   return;
+#endif
+   memcpy(data, offset, len);
+}
+
+static int m25p80_read_mmap(struct spi_nor *nor, void *data,
+   void *offset, size_t len)
+{
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
+   int ret;
+
+   ret = spi_claim_bus(spi);
+   if (ret) {
+   debug("m25p80: unable to claim SPI bus\n");
+   return ret;
+   }
+
+   spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP);
+   flash_copy_mmap(data, offset, len);
+   spi_xfer(spi, 0, NULL, NULL, SPI_XFER_MMAP_END);
+
+   spi_release_bus(spi);
+
+   return ret;
+}
+
+static int m25p80_read(struct spi_nor *nor, const u8 *cmd, size_t cmd_len,
+   void *data, size_t data_len)
+{
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
+   int ret;
+
+   ret = spi_claim_bus(spi);
+   if (ret < 0) {
+   debug("m25p80: unable to claim SPI bus\n");
+   return ret;
+   }
+
+   if (nor->flags & SNOR_F_U_PAGE)
+   spi->flags |= SPI_XFER_U_PAGE;
+
+   ret = spi_read_then_write(spi, cmd, cmd_len, NULL, data, data_len);
+   if (ret < 0) {
+   debug("m25p80: error %d reading %x\n", ret, *cmd);
+   return ret;
+   }
+
+   spi_release_bus(spi);
+
+   return ret;
+}
+
+static int m25p80_write(struct spi_nor *nor, const u8 *cmd, size_t cmd_len,
+   const void *data, size_t data_len)
+{
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
+   

[U-Boot] [PATCH v7 12/87] mtd: spi-nor: m25p80: Add spi_nor support for non-dm

2016-03-22 Thread Jagan Teki
Like adding spi_nor support for dm-driven code in m25p80
add the same way for non-dm code as well.
- allocate spi_nor{}
- basic initilization
- install hooks
- call to spi-nor core, using spi_nor_scan
- register with mtd core

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 108 ++-
 include/spi_flash.h  |  18 +++-
 2 files changed, 112 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 6a892d2..79293b2 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -20,6 +20,9 @@
 struct m25p {
struct spi_slave*spi;
struct spi_nor  spi_nor;
+#ifndef CONFIG_DM_MTD_SPI_NOR
+   struct mtd_info mtd;
+#endif
 };
 
 static int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
@@ -188,16 +191,13 @@ static int m25p80_write(struct spi_nor *nor, const u8 
*cmd, size_t cmd_len,
return ret;
 }
 
-static int m25p_probe(struct udevice *dev)
+static int m25p80_spi_nor(struct spi_nor *nor)
 {
-   struct spi_slave *spi = dev_get_parent_priv(dev);
-   struct mtd_info *mtd = dev_get_uclass_priv(dev);
-   struct m25p *flash = dev_get_priv(dev);
-   struct spi_nor *nor;
+   struct mtd_info *mtd = nor->mtd;
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
int ret;
 
-   nor = &flash->spi_nor;
-
/* install hooks */
nor->read_mmap = m25p80_read_mmap;
nor->read = m25p80_read;
@@ -205,10 +205,6 @@ static int m25p_probe(struct udevice *dev)
nor->read_reg = m25p80_read_reg;
nor->write_reg = m25p80_write_reg;
 
-   nor->mtd = mtd;
-   nor->priv = flash;
-   flash->spi = spi;
-
/* claim spi bus */
ret = spi_claim_bus(spi);
if (ret) {
@@ -260,10 +256,33 @@ err_scan:
spi_release_bus(spi);
 err_mtd:
spi_free_slave(spi);
-   device_remove(dev);
return ret;
 }
 
+#ifdef CONFIG_DM_MTD_SPI_NOR
+static int m25p_probe(struct udevice *dev)
+{
+   struct spi_slave *spi = dev_get_parent_priv(dev);
+   struct mtd_info *mtd = dev_get_uclass_priv(dev);
+   struct m25p *flash = dev_get_priv(dev);
+   struct spi_nor *nor;
+   int ret;
+
+   nor = &flash->spi_nor;
+
+   nor->mtd = mtd;
+   nor->priv = flash;
+   flash->spi = spi;
+
+   ret = m25p80_spi_nor(nor);
+   if (ret) {
+   device_remove(dev);
+   return ret;
+   }
+
+   return 0;
+}
+
 static const struct udevice_id m25p_ids[] = {
/*
 * Generic compatibility for SPI NOR that can be identified by the
@@ -280,3 +299,68 @@ U_BOOT_DRIVER(m25p80) = {
.probe  = m25p_probe,
.priv_auto_alloc_size = sizeof(struct m25p),
 };
+
+#else
+
+static struct mtd_info *m25p80_probe_tail(struct spi_slave *bus)
+{
+   struct m25p *flash;
+   struct spi_nor *nor;
+   int ret;
+
+   flash = calloc(1, sizeof(*flash));
+   if (!flash) {
+   debug("mp25p80: failed to allocate m25p\n");
+   return NULL;
+   }
+
+   nor = &flash->spi_nor;
+   nor->mtd = &flash->mtd;
+
+   nor->priv = flash;
+   flash->spi = bus;
+
+   ret = m25p80_spi_nor(nor);
+   if (ret) {
+   free(flash);
+   return NULL;
+   }
+
+   return nor->mtd;
+}
+
+struct mtd_info *spi_flash_probe(unsigned int busnum, unsigned int cs,
+unsigned int max_hz, unsigned int spi_mode)
+{
+   struct spi_slave *bus;
+
+   bus = spi_setup_slave(busnum, cs, max_hz, spi_mode);
+   if (!bus)
+   return NULL;
+   return m25p80_probe_tail(bus);
+}
+
+#ifdef CONFIG_OF_SPI_FLASH
+struct mtd_info *spi_flash_probe_fdt(const void *blob, int slave_node,
+int spi_node)
+{
+   struct spi_slave *bus;
+
+   bus = spi_setup_slave_fdt(blob, slave_node, spi_node);
+   if (!bus)
+   return NULL;
+   return m25p80_probe_tail(bus);
+}
+#endif
+
+void spi_flash_free(struct mtd_info *info)
+{
+   struct spi_nor *nor = info->priv;
+   struct m25p *flash = nor->priv;
+
+   del_mtd_device(info);
+   spi_free_slave(flash->spi);
+   free(flash);
+}
+
+#endif /* CONFIG_DM_MTD_SPI_NOR */
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 5895d8b..e137ede 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -108,10 +108,12 @@ struct spi_flash {
 #endif
 };
 
-#if defined(CONFIG_MTD_SPI_NOR) && defined(CONFIG_DM_MTD_SPI_NOR)
+#ifdef CONFIG_MTD_SPI_NOR
 
 typedef struct mtd_info spi_flash_t;
 
+#ifdef CONFIG_DM_MTD_SPI_NOR
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
  

[U-Boot] [PATCH v7 14/87] sf: Use erasesize instead of sector_size

2016-03-22 Thread Jagan Teki
For computing proper sector_size the below patch
assigned erase_size which is a proper sector
computation size, so this patch directly used
erasesize instead of assignment.
"sf: Fix to compute proper sector_size"
(sha1: c650ca7b4c160193791dc7a52381c71c6a29e871)

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 cmd/sf.c| 20 ++--
 drivers/dfu/dfu_sf.c|  8 
 drivers/mtd/spi/sf_mtd.c|  2 +-
 drivers/mtd/spi/spi_flash.c |  3 ---
 4 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/cmd/sf.c b/cmd/sf.c
index 89ab41e..1e0dcb4 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -53,8 +53,8 @@ static int sf_parse_len_arg(char *arg, ulong *len)
if (ep == arg || *ep != '\0')
return -1;
 
-   if (round_up_len && flash->sector_size > 0)
-   *len = ROUND(len_arg, flash->sector_size);
+   if (round_up_len && flash->erasesize > 0)
+   *len = ROUND(len_arg, flash->erasesize);
else
*len = len_arg;
 
@@ -171,10 +171,10 @@ static const char *spi_flash_update_block(struct 
spi_flash *flash, u32 offset,
 {
char *ptr = (char *)buf;
 
-   debug("offset=%#x, sector_size=%#x, len=%#zx\n",
- offset, flash->sector_size, len);
+   debug("offset=%#x, erasesize=%#x, len=%#zx\n",
+ offset, flash->erasesize, len);
/* Read the entire sector so to allow for rewriting */
-   if (spi_flash_read(flash, offset, flash->sector_size, cmp_buf))
+   if (spi_flash_read(flash, offset, flash->erasesize, cmp_buf))
return "read";
/* Compare only what is meaningful (len) */
if (memcmp(cmp_buf, buf, len) == 0) {
@@ -184,15 +184,15 @@ static const char *spi_flash_update_block(struct 
spi_flash *flash, u32 offset,
return NULL;
}
/* Erase the entire sector */
-   if (spi_flash_erase(flash, offset, flash->sector_size))
+   if (spi_flash_erase(flash, offset, flash->erasesize))
return "erase";
/* If it's a partial sector, copy the data into the temp-buffer */
-   if (len != flash->sector_size) {
+   if (len != flash->erasesize) {
memcpy(cmp_buf, buf, len);
ptr = cmp_buf;
}
/* Write one complete sector */
-   if (spi_flash_write(flash, offset, flash->sector_size, ptr))
+   if (spi_flash_write(flash, offset, flash->erasesize, ptr))
return "write";
 
return NULL;
@@ -223,12 +223,12 @@ static int spi_flash_update(struct spi_flash *flash, u32 
offset,
 
if (end - buf >= 200)
scale = (end - buf) / 100;
-   cmp_buf = memalign(ARCH_DMA_MINALIGN, flash->sector_size);
+   cmp_buf = memalign(ARCH_DMA_MINALIGN, flash->erasesize);
if (cmp_buf) {
ulong last_update = get_timer(0);
 
for (; buf < end && !err_oper; buf += todo, offset += todo) {
-   todo = min_t(size_t, end - buf, flash->sector_size);
+   todo = min_t(size_t, end - buf, flash->erasesize);
if (get_timer(last_update) > 100) {
printf("   \rUpdating, %zu%% %lu B/s",
   100 - (end - buf) / scale,
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 9702eee..13e7f92 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -25,8 +25,8 @@ static int dfu_read_medium_sf(struct dfu_entity *dfu, u64 
offset, void *buf,
 
 static u64 find_sector(struct dfu_entity *dfu, u64 start, u64 offset)
 {
-   return (lldiv((start + offset), dfu->data.sf.dev->sector_size)) *
-   dfu->data.sf.dev->sector_size;
+   return (lldiv((start + offset), dfu->data.sf.dev->erasesize)) *
+   dfu->data.sf.dev->erasesize;
 }
 
 static int dfu_write_medium_sf(struct dfu_entity *dfu,
@@ -36,7 +36,7 @@ static int dfu_write_medium_sf(struct dfu_entity *dfu,
 
ret = spi_flash_erase(dfu->data.sf.dev,
  find_sector(dfu, dfu->data.sf.start, offset),
- dfu->data.sf.dev->sector_size);
+ dfu->data.sf.dev->erasesize);
if (ret)
return ret;
 
@@ -123,7 +123,7 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char 
*devstr, char *s)
return -ENODEV;
 
dfu->dev_type = DFU_DEV_SF;
-   dfu->max_buf_size = dfu->data.sf.dev->sector_size;
+   dfu->max_buf_size = dfu->data.sf.dev->erasesize;
 
st = strsep(&s, " ");
if (!strcmp(st, "raw")) {
diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c
index 0b9cb62..9a8302d 100644
--- a/drivers/mtd/spi/sf_mtd.c
+++ b/drivers/mtd/spi/sf_mtd.c
@@ -93,7 +93,7 @@ int spi_flash_mtd_register(struct spi_flash *flash)
 
/* Only uniform flash devices for now */

[U-Boot] [PATCH v7 13/87] sf: Rename erase_size to erasesize

2016-03-22 Thread Jagan Teki
erasesize name looks similar as the way mtd_info{}
used so renamed erase_size to erasesize and more over
the spi-flash will use mtd in future patches.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi/sf_dataflash.c |  4 ++--
 drivers/mtd/spi/spi_flash.c| 14 +++---
 include/spi_flash.h|  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c
index b2a56da..0f66b99 100644
--- a/drivers/mtd/spi/sf_dataflash.c
+++ b/drivers/mtd/spi/sf_dataflash.c
@@ -427,12 +427,12 @@ static int add_dataflash(struct udevice *dev, char *name, 
int nr_pages,
spi_flash->name = name;
spi_flash->page_size = pagesize;
spi_flash->size = nr_pages * pagesize;
-   spi_flash->erase_size = pagesize;
+   spi_flash->erasesize = pagesize;
 
 #ifndef CONFIG_SPL_BUILD
printf("SPI DataFlash: Detected %s with page size ", spi_flash->name);
print_size(spi_flash->page_size, ", erase size ");
-   print_size(spi_flash->erase_size, ", total ");
+   print_size(spi_flash->erasesize, ", total ");
print_size(spi_flash->size, "");
printf(", revision %c", revision);
puts("\n");
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 44d9e9b..dfadb77 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -329,7 +329,7 @@ int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 
offset, size_t len)
u8 cmd[SPI_FLASH_CMD_LEN];
int ret = -1;
 
-   erase_size = flash->erase_size;
+   erase_size = flash->erasesize;
if (offset % erase_size || len % erase_size) {
debug("SF: Erase offset/length not multiple of erase size\n");
return -1;
@@ -804,7 +804,7 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
return ret;
 
/* Cannot unlock; would unlock larger region than requested */
-   if (stm_is_locked_sr(flash, ofs - flash->erase_size, flash->erase_size,
+   if (stm_is_locked_sr(flash, ofs - flash->erasesize, flash->erasesize,
 status_old))
return -EINVAL;
/*
@@ -1091,17 +1091,17 @@ int spi_flash_scan(struct spi_flash *flash)
/* Compute erase sector and command */
if (params->flags & SECT_4K) {
flash->erase_cmd = CMD_ERASE_4K;
-   flash->erase_size = 4096 << flash->shift;
+   flash->erasesize = 4096 << flash->shift;
} else if (params->flags & SECT_32K) {
flash->erase_cmd = CMD_ERASE_32K;
-   flash->erase_size = 32768 << flash->shift;
+   flash->erasesize = 32768 << flash->shift;
} else {
flash->erase_cmd = CMD_ERASE_64K;
-   flash->erase_size = flash->sector_size;
+   flash->erasesize = flash->sector_size;
}
 
/* Now erase size becomes valid sector size */
-   flash->sector_size = flash->erase_size;
+   flash->sector_size = flash->erasesize;
 
/* Look for the fastest read cmd */
cmd = fls(params->e_rd_cmd & spi->mode_rx);
@@ -1173,7 +1173,7 @@ int spi_flash_scan(struct spi_flash *flash)
 #ifndef CONFIG_SPL_BUILD
printf("SF: Detected %s with page size ", flash->name);
print_size(flash->page_size, ", erase size ");
-   print_size(flash->erase_size, ", total ");
+   print_size(flash->erasesize, ", total ");
print_size(flash->size, "");
if (flash->memory_map)
printf(", mapped at %p", flash->memory_map);
diff --git a/include/spi_flash.h b/include/spi_flash.h
index e137ede..4b92605 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -40,7 +40,7 @@ struct spi_slave;
  * @size:  Total flash size
  * @page_size: Write (page) size
  * @sector_size:   Sector size
- * @erase_size:Erase size
+ * @erasesize: Erase size
  * @bank_read_cmd: Bank read cmd
  * @bank_write_cmd:Bank write cmd
  * @bank_curr: Current flash bank
@@ -73,7 +73,7 @@ struct spi_flash {
u32 size;
u32 page_size;
u32 sector_size;
-   u32 erase_size;
+   u32 erasesize;
 #ifdef CONFIG_SPI_FLASH_BAR
u8 bank_read_cmd;
u8 bank_write_cmd;
-- 
1.9.1

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


[U-Boot] [PATCH v7 15/87] sf: Use uint64_t for flash->size

2016-03-22 Thread Jagan Teki
To sync with size in mtd_info{} this patch change
data type of size to uint64_t

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 cmd/sf.c| 4 ++--
 include/spi_flash.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/sf.c b/cmd/sf.c
index 1e0dcb4..0d0a02c 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -280,7 +280,7 @@ static int do_spi_flash_read_write(int argc, char * const 
argv[])
 
/* Consistency checking */
if (offset + len > flash->size) {
-   printf("ERROR: attempting %s past flash size (%#x)\n",
+   printf("ERROR: attempting %s past flash size (%#llx)\n",
   argv[0], flash->size);
return 1;
}
@@ -336,7 +336,7 @@ static int do_spi_flash_erase(int argc, char * const argv[])
 
/* Consistency checking */
if (offset + size > flash->size) {
-   printf("ERROR: attempting %s past flash size (%#x)\n",
+   printf("ERROR: attempting %s past flash size (%#llx)\n",
   argv[0], flash->size);
return 1;
}
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 4b92605..c7fd4f3 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -70,7 +70,7 @@ struct spi_flash {
u8 shift;
u16 flags;
 
-   u32 size;
+   uint64_t size;
u32 page_size;
u32 sector_size;
u32 erasesize;
-- 
1.9.1

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


[U-Boot] [PATCH v7 16/87] spi_flash: Use mtd_info operation for SPI-NOR

2016-03-22 Thread Jagan Teki
Since spi-nor is using mtd layer for flash operations
this patch used mtd ops from user commands instead of
legacy spi_flash{} ops.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 include/spi_flash.h | 60 ++---
 1 file changed, 48 insertions(+), 12 deletions(-)

diff --git a/include/spi_flash.h b/include/spi_flash.h
index c7fd4f3..43abec9 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -12,6 +12,7 @@
 
 #include /* Because we dereference struct udevice here */
 #include 
+#include 
 
 #ifndef CONFIG_SF_DEFAULT_SPEED
 # define CONFIG_SF_DEFAULT_SPEED   100
@@ -112,6 +113,39 @@ struct spi_flash {
 
 typedef struct mtd_info spi_flash_t;
 
+static inline int spi_flash_read(spi_flash_t *info, u32 offset,
+size_t len, void *buf)
+{
+   return mtd_read(info, offset, len, &len, (u_char *)buf);
+}
+
+static inline int spi_flash_write(spi_flash_t *info, u32 offset,
+ size_t len, const void *buf)
+{
+   return mtd_write(info, offset, len, &len, (u_char *)buf);
+}
+
+static inline int spi_flash_erase(spi_flash_t *info, u32 offset, size_t len)
+{
+   struct erase_info instr;
+
+   instr.mtd = info;
+   instr.addr = offset;
+   instr.len = len;
+   instr.callback = 0;
+
+   return mtd_erase(info, &instr);
+}
+
+static inline int spi_flash_protect(spi_flash_t *info, u32 ofs,
+   u32 len, bool prot)
+{
+   if (prot)
+   return mtd_lock(info, ofs, len);
+   else
+   return mtd_unlock(info, ofs, len);
+}
+
 #ifdef CONFIG_DM_MTD_SPI_NOR
 
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
@@ -137,6 +171,20 @@ void spi_flash_free(spi_flash_t *flash);
 
 #endif /* CONFIG_DM_MTD_SPI_NOR */
 
+#else
+
+static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
+   bool prot)
+{
+   if (!flash->flash_lock || !flash->flash_unlock)
+   return -EOPNOTSUPP;
+
+   if (prot)
+   return flash->flash_lock(flash, ofs, len);
+   else
+   return flash->flash_unlock(flash, ofs, len);
+}
+
 #endif /* CONFIG_MTD_SPI_NOR */
 
 struct dm_spi_flash_ops {
@@ -266,18 +314,6 @@ static inline int spi_flash_erase(struct spi_flash *flash, 
u32 offset,
 }
 #endif
 
-static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
-   bool prot)
-{
-   if (!flash->flash_lock || !flash->flash_unlock)
-   return -EOPNOTSUPP;
-
-   if (prot)
-   return flash->flash_lock(flash, ofs, len);
-   else
-   return flash->flash_unlock(flash, ofs, len);
-}
-
 void spi_boot(void) __noreturn;
 void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst);
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 22/87] mtd: spi-nor: Copy spl files from drivers/mtd/spi

2016-03-22 Thread Jagan Teki
Copy spl files from drivers/mtd/spi to spi-nor,
more changes will added on future patches.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Makefile   |  5 +++
 drivers/mtd/spi-nor/fsl_espi_spl.c | 90 ++
 drivers/mtd/spi-nor/spi_spl_load.c | 90 ++
 3 files changed, 185 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/fsl_espi_spl.c
 create mode 100644 drivers/mtd/spi-nor/spi_spl_load.c

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 2f41630..4a854fa 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -3,6 +3,11 @@
 #
 # SPDX-License-Identifier: GPL-2.0+
 
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_SPI_LOAD) += spi_spl_load.o
+obj-$(CONFIG_SPL_SPI_BOOT) += fsl_espi_spl.o
+endif
+
 ifdef CONFIG_MTD_SPI_NOR
 obj-y += spi-nor.o
 obj-y += spi-nor-ids.o
diff --git a/drivers/mtd/spi-nor/fsl_espi_spl.c 
b/drivers/mtd/spi-nor/fsl_espi_spl.c
new file mode 100644
index 000..b915469
--- /dev/null
+++ b/drivers/mtd/spi-nor/fsl_espi_spl.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+#define ESPI_BOOT_IMAGE_SIZE   0x48
+#define ESPI_BOOT_IMAGE_ADDR   0x50
+#define CONFIG_CFG_DATA_SECTOR 0
+
+void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst)
+{
+   struct spi_flash *flash;
+
+   flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
+   CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
+   if (flash == NULL) {
+   puts("\nspi_flash_probe failed");
+   hang();
+   }
+
+   spi_flash_read(flash, offs, size, vdst);
+}
+
+/*
+ * The main entry for SPI booting. It's necessary that SDRAM is already
+ * configured and available since this code loads the main U-Boot image
+ * from SPI into SDRAM and starts it from there.
+ */
+void spi_boot(void)
+{
+   void (*uboot)(void) __noreturn;
+   u32 offset, code_len, copy_len = 0;
+#ifndef CONFIG_FSL_CORENET
+   unsigned char *buf = NULL;
+#endif
+   struct spi_flash *flash;
+
+   flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
+   CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
+   if (flash == NULL) {
+   puts("\nspi_flash_probe failed");
+   hang();
+   }
+
+#ifdef CONFIG_FSL_CORENET
+   offset = CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS;
+   code_len = CONFIG_SYS_SPI_FLASH_U_BOOT_SIZE;
+#else
+   /*
+   * Load U-Boot image from SPI flash into RAM
+   */
+   buf = malloc(flash->page_size);
+   if (buf == NULL) {
+   puts("\nmalloc failed");
+   hang();
+   }
+   memset(buf, 0, flash->page_size);
+
+   spi_flash_read(flash, CONFIG_CFG_DATA_SECTOR,
+  flash->page_size, (void *)buf);
+   offset = *(u32 *)(buf + ESPI_BOOT_IMAGE_ADDR);
+   /* Skip spl code */
+   offset += CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS;
+   /* Get the code size from offset 0x48 */
+   code_len = *(u32 *)(buf + ESPI_BOOT_IMAGE_SIZE);
+   /* Skip spl code */
+   code_len = code_len - CONFIG_SPL_MAX_SIZE;
+#endif
+   /* copy code to DDR */
+   printf("Loading second stage boot loader ");
+   while (copy_len <= code_len) {
+   spi_flash_read(flash, offset + copy_len, 0x2000,
+  (void *)(CONFIG_SYS_SPI_FLASH_U_BOOT_DST
+  + copy_len));
+   copy_len = copy_len + 0x2000;
+   putc('.');
+   }
+
+   /*
+   * Jump to U-Boot image
+   */
+   flush_cache(CONFIG_SYS_SPI_FLASH_U_BOOT_DST, code_len);
+   uboot = (void *)CONFIG_SYS_SPI_FLASH_U_BOOT_START;
+   (*uboot)();
+}
diff --git a/drivers/mtd/spi-nor/spi_spl_load.c 
b/drivers/mtd/spi-nor/spi_spl_load.c
new file mode 100644
index 000..ca56fe9
--- /dev/null
+++ b/drivers/mtd/spi-nor/spi_spl_load.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2011 OMICRON electronics GmbH
+ *
+ * based on drivers/mtd/nand/nand_spl_load.c
+ *
+ * Copyright (C) 2011
+ * Heiko Schocher, DENX Software Engineering, h...@denx.de.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifdef CONFIG_SPL_OS_BOOT
+/*
+ * Load the kernel, check for a valid header we can parse, and if found load
+ * the kernel and then device tree.
+ */
+static int spi_load_image_os(struct spi_flash *flash,
+struct image_header *header)
+{
+   /* Read for a header, parse or error out. */
+   spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, 0x40,
+  (void *)header);
+
+   if (image_get_magic(header) != IH_MAGIC)
+   return -1;
+
+   spl_

[U-Boot] [PATCH v7 18/87] mtd: spi-nor: Move spi_read_then_write to spi layer

2016-03-22 Thread Jagan Teki
Since spi_read_then_write is doing spi operations like
setting up commands, tx and rx through spi_xfer, So
it is meanfull to have this definition at spi layer and
flash layer should use this whenever required.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 25 -
 drivers/spi/spi-uclass.c | 25 +
 drivers/spi/spi.c| 31 +++
 include/spi.h|  5 +
 4 files changed, 61 insertions(+), 25 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 79293b2..6033b48 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -25,31 +25,6 @@ struct m25p {
 #endif
 };
 
-static int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
-  size_t cmd_len, const u8 *data_out,
-  u8 *data_in, size_t data_len)
-{
-   unsigned long flags = SPI_XFER_BEGIN;
-   int ret;
-
-   if (data_len == 0)
-   flags |= SPI_XFER_END;
-
-   ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
-   if (ret) {
-   debug("SF: Failed to send command (%zu bytes): %d\n",
- cmd_len, ret);
-   } else if (data_len != 0) {
-   ret = spi_xfer(spi, data_len * 8, data_out, data_in,
-   SPI_XFER_END);
-   if (ret)
-   debug("SF: Failed to transfer %zu bytes of data: %d\n",
- data_len, ret);
-   }
-
-   return ret;
-}
-
 static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len)
 {
struct m25p *flash = nor->priv;
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 5561f36..2cf2a52 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -95,6 +95,31 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
return spi_get_ops(bus)->xfer(dev, bitlen, dout, din, flags);
 }
 
+int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
+   size_t cmd_len, const u8 *data_out,
+   u8 *data_in, size_t data_len)
+{
+   unsigned long flags = SPI_XFER_BEGIN;
+   int ret;
+
+   if (data_len == 0)
+   flags |= SPI_XFER_END;
+
+   ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
+   if (ret) {
+   debug("spi: failed to send command (%zu bytes): %d\n",
+ cmd_len, ret);
+   } else if (data_len != 0) {
+   ret = spi_xfer(spi, data_len * 8, data_out, data_in,
+  SPI_XFER_END);
+   if (ret)
+   debug("spi: failed to transfer %zu bytes of data: %d\n",
+ data_len, ret);
+   }
+
+   return ret;
+}
+
 static int spi_post_bind(struct udevice *dev)
 {
/* Scan the bus for devices */
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 7d81fbd..aceaf9b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -39,6 +39,37 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int 
bus,
return ptr;
 }
 
+int __weak spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+   const void *dout, void *din, unsigned long flags)
+{
+   return 0;
+}
+
+int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
+   size_t cmd_len, const u8 *data_out,
+   u8 *data_in, size_t data_len)
+{
+   unsigned long flags = SPI_XFER_BEGIN;
+   int ret;
+
+   if (data_len == 0)
+   flags |= SPI_XFER_END;
+
+   ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
+   if (ret) {
+   debug("spi: failed to send command (%zu bytes): %d\n",
+ cmd_len, ret);
+   } else if (data_len != 0) {
+   ret = spi_xfer(spi, data_len * 8, data_out, data_in,
+   SPI_XFER_END);
+   if (ret)
+   debug("spi: failed to transfer %zu bytes of data: %d\n",
+ data_len, ret);
+   }
+
+   return ret;
+}
+
 #ifdef CONFIG_OF_SPI
 struct spi_slave *spi_base_setup_slave_fdt(const void *blob, int busnum,
   int node)
diff --git a/include/spi.h b/include/spi.h
index 4b88d39..139292c 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -265,6 +265,11 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int 
wordlen);
 int  spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
void *din, unsigned long flags);
 
+/* spi_write_then_read - SPI synchronous read followed by write */
+int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
+   size_t cmd_len, const u8 *data_out,
+

[U-Boot] [PATCH v7 20/87] mtd: spi-nor: Rename SPI_FLASH_BAR to SPI_NOR_BAR

2016-03-22 Thread Jagan Teki
Renamed SPI_FLASH_BAR to SPI_NOR_BAR

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index b867ce9..130f7af 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -181,7 +181,7 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor, 
unsigned long timeout)
return -ETIMEDOUT;
 }
 
-#ifdef CONFIG_SPI_FLASH_BAR
+#ifdef CONFIG_SPI_NOR_BAR
 static int spi_nor_write_bar(struct spi_nor *nor, u32 offset)
 {
u8 bank_sel;
@@ -514,7 +514,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct 
erase_info *instr)
if (nor->dual > SNOR_DUAL_SINGLE)
spi_nor_dual(nor, &erase_addr);
 #endif
-#ifdef CONFIG_SPI_FLASH_BAR
+#ifdef CONFIG_SPI_NOR_BAR
ret = spi_nor_write_bar(nor, erase_addr);
if (ret < 0)
return ret;
@@ -577,7 +577,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t 
offset, size_t len,
if (nor->dual > SNOR_DUAL_SINGLE)
spi_nor_dual(nor, &write_addr);
 #endif
-#ifdef CONFIG_SPI_FLASH_BAR
+#ifdef CONFIG_SPI_NOR_BAR
ret = spi_nor_write_bar(nor, write_addr);
if (ret < 0)
return ret;
@@ -647,7 +647,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, 
size_t len,
if (nor->dual > SNOR_DUAL_SINGLE)
spi_nor_dual(nor, &read_addr);
 #endif
-#ifdef CONFIG_SPI_FLASH_BAR
+#ifdef CONFIG_SPI_NOR_BAR
ret = spi_nor_write_bar(nor, read_addr);
if (ret < 0)
return ret;
@@ -1103,7 +1103,7 @@ int spi_nor_scan(struct spi_nor *nor)
}
 
/* Configure the BAR - discover bank cmds and read current bank */
-#ifdef CONFIG_SPI_FLASH_BAR
+#ifdef CONFIG_SPI_NOR_BAR
ret = spi_nor_read_bar(nor, info);
if (ret < 0)
return ret;
@@ -1127,13 +1127,13 @@ int spi_nor_scan(struct spi_nor *nor)
puts("\n");
 #endif
 
-#ifndef CONFIG_SPI_FLASH_BAR
+#ifndef CONFIG_SPI_NOR_BAR
if (((nor->dual == SNOR_DUAL_SINGLE) &&
 (mtd->size > SNOR_16MB_BOUN)) ||
 ((nor->dual > SNOR_DUAL_SINGLE) &&
 (mtd->size > SNOR_16MB_BOUN << 1))) {
puts("spi-nor: Warning - Only lower 16MiB accessible,");
-   puts(" Full access #define CONFIG_SPI_FLASH_BAR\n");
+   puts(" Full access #define CONFIG_SPI_NOR_BAR\n");
}
 #endif
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 17/87] spi_flash: Use spi_flash_t instead of struct spi_flash

2016-03-22 Thread Jagan Teki
spi_flash_t same typedef alias name for spi_flash
and mtd_info so which one will use based on the
user config definition.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 cmd/sf.c| 10 +-
 common/env_sf.c |  2 +-
 include/spi_flash.h |  2 ++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cmd/sf.c b/cmd/sf.c
index 0d0a02c..389244b 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -19,7 +19,7 @@
 #include 
 #include 
 
-static struct spi_flash *flash;
+static spi_flash_t *flash;
 
 /*
  * This function computes the length argument for the erase command.
@@ -89,7 +89,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
struct udevice *new, *bus_dev;
int ret;
 #else
-   struct spi_flash *new;
+   spi_flash_t *new;
 #endif
 
if (argc >= 2) {
@@ -166,7 +166,7 @@ static int do_spi_flash_probe(int argc, char * const argv[])
  * @param skipped  Count of skipped data (incremented by this function)
  * @return NULL if OK, else a string containing the stage which failed
  */
-static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
+static const char *spi_flash_update_block(spi_flash_t *flash, u32 offset,
size_t len, const char *buf, char *cmp_buf, size_t *skipped)
 {
char *ptr = (char *)buf;
@@ -208,7 +208,7 @@ static const char *spi_flash_update_block(struct spi_flash 
*flash, u32 offset,
  * @param buf  buffer to write from
  * @return 0 if ok, 1 on error
  */
-static int spi_flash_update(struct spi_flash *flash, u32 offset,
+static int spi_flash_update(spi_flash_t *flash, u32 offset,
size_t len, const char *buf)
 {
const char *err_oper = NULL;
@@ -436,7 +436,7 @@ static void spi_test_next_stage(struct test_info *test)
  * @param vbuf Verification buffer
  * @return 0 if ok, -1 on error
  */
-static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
+static int spi_flash_test(spi_flash_t *flash, uint8_t *buf, ulong len,
   ulong offset, uint8_t *vbuf)
 {
struct test_info test;
diff --git a/common/env_sf.c b/common/env_sf.c
index ec88792..b927fe8 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -43,7 +43,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 char *env_name_spec = "SPI Flash";
 
-static struct spi_flash *env_flash;
+static spi_flash_t *env_flash;
 
 #if defined(CONFIG_ENV_OFFSET_REDUND)
 int saveenv(void)
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 43abec9..f77a9c9 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -173,6 +173,8 @@ void spi_flash_free(spi_flash_t *flash);
 
 #else
 
+typedef struct spi_flash spi_flash_t;
+
 static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
bool prot)
 {
-- 
1.9.1

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


[U-Boot] [PATCH v7 19/87] spi: Rename spi_read_then_write to spi_write_then_read

2016-03-22 Thread Jagan Teki
Since spi_read_then_write moved into spi layer,
the meaning of data transfer is also change from
read_then_write to write_then_read, this means
first spi will write the opcode through and then
read the respective buffer.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c |  8 
 drivers/spi/spi-uclass.c | 19 +--
 drivers/spi/spi.c| 19 +--
 include/spi.h| 23 +++
 4 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 6033b48..429d710 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -40,7 +40,7 @@ static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 
*val, int len)
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_read_then_write(spi, &cmd, 1, NULL, val, len);
+   ret = spi_write_then_read(spi, &cmd, 1, NULL, val, len);
if (ret < 0) {
debug("m25p80: error %d reading register %x\n", ret, cmd);
return ret;
@@ -66,7 +66,7 @@ static int m25p80_write_reg(struct spi_nor *nor, u8 cmd, u8 
*buf, int len)
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_read_then_write(spi, &cmd, 1, buf, NULL, len);
+   ret = spi_write_then_read(spi, &cmd, 1, buf, NULL, len);
if (ret < 0) {
debug("m25p80: error %d writing register %x\n", ret, cmd);
return ret;
@@ -128,7 +128,7 @@ static int m25p80_read(struct spi_nor *nor, const u8 *cmd, 
size_t cmd_len,
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_read_then_write(spi, cmd, cmd_len, NULL, data, data_len);
+   ret = spi_write_then_read(spi, cmd, cmd_len, NULL, data, data_len);
if (ret < 0) {
debug("m25p80: error %d reading %x\n", ret, *cmd);
return ret;
@@ -155,7 +155,7 @@ static int m25p80_write(struct spi_nor *nor, const u8 *cmd, 
size_t cmd_len,
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_read_then_write(spi, cmd, cmd_len, data, NULL, data_len);
+   ret = spi_write_then_read(spi, cmd, cmd_len, data, NULL, data_len);
if (ret < 0) {
debug("m25p80: error %d writing %x\n", ret, *cmd);
return ret;
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 2cf2a52..7ef2496 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -95,26 +95,25 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
return spi_get_ops(bus)->xfer(dev, bitlen, dout, din, flags);
 }
 
-int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
-   size_t cmd_len, const u8 *data_out,
-   u8 *data_in, size_t data_len)
+int spi_write_then_read(struct spi_slave *slave, const u8 *opcode,
+   size_t n_opcode, const u8 *txbuf, u8 *rxbuf,
+   size_t n_buf)
 {
unsigned long flags = SPI_XFER_BEGIN;
int ret;
 
-   if (data_len == 0)
+   if (n_buf == 0)
flags |= SPI_XFER_END;
 
-   ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
+   ret = spi_xfer(slave, n_opcode * 8, opcode, NULL, flags);
if (ret) {
debug("spi: failed to send command (%zu bytes): %d\n",
- cmd_len, ret);
-   } else if (data_len != 0) {
-   ret = spi_xfer(spi, data_len * 8, data_out, data_in,
-  SPI_XFER_END);
+ n_opcode, ret);
+   } else if (n_buf != 0) {
+   ret = spi_xfer(slave, n_buf * 8, txbuf, rxbuf, SPI_XFER_END);
if (ret)
debug("spi: failed to transfer %zu bytes of data: %d\n",
- data_len, ret);
+ n_buf, ret);
}
 
return ret;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index aceaf9b..80aba57 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -45,26 +45,25 @@ int __weak spi_xfer(struct spi_slave *slave, unsigned int 
bitlen,
return 0;
 }
 
-int spi_read_then_write(struct spi_slave *spi, const u8 *cmd,
-   size_t cmd_len, const u8 *data_out,
-   u8 *data_in, size_t data_len)
+int spi_write_then_read(struct spi_slave *slave, const u8 *opcode,
+   size_t n_opcode, const u8 *txbuf, u8 *rxbuf,
+   size_t n_buf)
 {
unsigned long flags = SPI_XFER_BEGIN;
int ret;
 
-   if (data_len == 0)
+   if (n_buf == 0)
flags |= SPI_XFER_END;
 
-   ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
+

[U-Boot] [PATCH v7 21/87] mtd: spi-nor: Add Kconfig entry for SPI_NOR_BAR

2016-03-22 Thread Jagan Teki
Added kconfig entry for SPI_NOR_BAR

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 342164d..dd62e24 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -51,4 +51,11 @@ config MTD_SPI_NOR_USE_4K_SECTORS
  Please note that some tools/drivers/filesystems may not work with
  4096 B erase size (e.g. UBIFS requires 15 KiB as a minimum).
 
+config SPI_NOR_BAR
+   bool "SPI NOR Bank/Extended address register support"
+   help
+ Enable the SPI NOR Bank/Extended address register support.
+ Bank/Extended address registers are used to access the flash
+ which has size > 16MiB in 3-byte addressing.
+
 endif # MTD_SPI_NOR
-- 
1.9.1

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


[U-Boot] [PATCH v7 23/87] mtd: spi-nor: spl: Follow ascending order of include headers

2016-03-22 Thread Jagan Teki
Use ascending order while including headers files.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/fsl_espi_spl.c | 2 +-
 drivers/mtd/spi-nor/spi_spl_load.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/fsl_espi_spl.c 
b/drivers/mtd/spi-nor/fsl_espi_spl.c
index b915469..7c40245 100644
--- a/drivers/mtd/spi-nor/fsl_espi_spl.c
+++ b/drivers/mtd/spi-nor/fsl_espi_spl.c
@@ -5,8 +5,8 @@
  */
 
 #include 
-#include 
 #include 
+#include 
 
 #define ESPI_BOOT_IMAGE_SIZE   0x48
 #define ESPI_BOOT_IMAGE_ADDR   0x50
diff --git a/drivers/mtd/spi-nor/spi_spl_load.c 
b/drivers/mtd/spi-nor/spi_spl_load.c
index ca56fe9..285b6da 100644
--- a/drivers/mtd/spi-nor/spi_spl_load.c
+++ b/drivers/mtd/spi-nor/spi_spl_load.c
@@ -10,9 +10,9 @@
  */
 
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 #ifdef CONFIG_SPL_OS_BOOT
-- 
1.9.1

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


[U-Boot] [PATCH v7 24/87] mtd: spi-nor: fsl_espi_spl: Use mtd_info

2016-03-22 Thread Jagan Teki
Replace spi_flash{} with mtd_info{}

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/fsl_espi_spl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/fsl_espi_spl.c 
b/drivers/mtd/spi-nor/fsl_espi_spl.c
index 7c40245..93b0b2e 100644
--- a/drivers/mtd/spi-nor/fsl_espi_spl.c
+++ b/drivers/mtd/spi-nor/fsl_espi_spl.c
@@ -14,7 +14,7 @@
 
 void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst)
 {
-   struct spi_flash *flash;
+   spi_flash_t *flash;
 
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
@@ -38,7 +38,7 @@ void spi_boot(void)
 #ifndef CONFIG_FSL_CORENET
unsigned char *buf = NULL;
 #endif
-   struct spi_flash *flash;
+   spi_flash_t *flash;
 
flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
-- 
1.9.1

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


Re: [U-Boot] [RFC PATCH] net: phy: Force master mode for RTL8211C

2016-03-22 Thread Michael Haas
On 03/22/2016 08:19 AM, Michael Haas wrote:
> The RTL8211C found on the A20-OlinuXino-Lime2 does not word in slave
> mode. This patch disables master/slave mode autonegotiation and forces
> master mode.
>
> The RTL8211C identifies itself as RTL8211B via its UID. This patch uses
> the revision number taken from the PHYID2 register to distinguish the
> two. The NetBSD driver uses the same approach.
>
> CC: fra...@gmail.com
> CC: mer...@debian.org
> CC: hdego...@redhat.com
> CC: i...@hellion.org.uk
> CC: joe.hershber...@ni.com
> Signed-off-by: Michael Haas 
> ---
>
>  drivers/net/phy/realtek.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 259a87f..cdb3376 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -5,6 +5,7 @@
>   *
>   * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc.
>   * author Andy Fleming
> + * Copyright 2016 Karsten Merker 
>   */
>  #include 
>  #include 
> @@ -54,6 +55,19 @@ static int rtl8211x_config(struct phy_device *phydev)
>   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
> MIIM_RTL8211x_PHY_INTR_DIS);
>  
> + int reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
> + int rev = reg & 0xf;
> + if (rev == 3 & 6 phydev->phy_id == 0x1cc912) {
> + /* RTL8211C and RTL8211C are distinguished only by
> +their revision number */
> + reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
> + /* force manual master/slave configuration */
> + reg |= (1 << 12);
> + /* force master mode */
> + reg | = (1 << 11);
> + phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
> + }
> +
>   /* read interrupt status just to clear it */
>   phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
>  
> @@ -223,7 +237,7 @@ static int rtl8211f_startup(struct phy_device *phydev)
>  /* Support for RTL8211B PHY */
>  static struct phy_driver RTL8211B_driver = {
>   .name = "RealTek RTL8211B",
> - .uid = 0x1cc910,
> + .uid = 0x1cc912,
>   .mask = 0xff,
>   .features = PHY_GBIT_FEATURES,
>   .config = &rtl8211x_config,

I have accidentally included Karsten Merkers '[PATCH] net: phy: Realtek
RTL8211B/C PHY ID fix' due to a botched call to git am earlier. I'll be
re-sending a clean version, but note that Karsten's patch is required.

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


[U-Boot] [PATCH v7 25/87] mtd: spi-nor: fsl_espi_spl: Use writebufsize instead of page_size

2016-03-22 Thread Jagan Teki
Replace spi_flash{} with mtd_info{}

Cc: Simon Glass 
Cc: Bin Meng 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/fsl_espi_spl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/fsl_espi_spl.c 
b/drivers/mtd/spi-nor/fsl_espi_spl.c
index 93b0b2e..581c346 100644
--- a/drivers/mtd/spi-nor/fsl_espi_spl.c
+++ b/drivers/mtd/spi-nor/fsl_espi_spl.c
@@ -54,15 +54,15 @@ void spi_boot(void)
/*
* Load U-Boot image from SPI flash into RAM
*/
-   buf = malloc(flash->page_size);
+   buf = malloc(flash->writebufsize);
if (buf == NULL) {
puts("\nmalloc failed");
hang();
}
-   memset(buf, 0, flash->page_size);
+   memset(buf, 0, flash->writebufsize);
 
spi_flash_read(flash, CONFIG_CFG_DATA_SECTOR,
-  flash->page_size, (void *)buf);
+  flash->writebufsize, (void *)buf);
offset = *(u32 *)(buf + ESPI_BOOT_IMAGE_ADDR);
/* Skip spl code */
offset += CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS;
-- 
1.9.1

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


[U-Boot] [PATCH v7 26/87] mtd: spi-nor: spi_spl_load: Use mtd_info

2016-03-22 Thread Jagan Teki
Replace spi_flash{} with mtd_info{}

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi_spl_load.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi_spl_load.c 
b/drivers/mtd/spi-nor/spi_spl_load.c
index 285b6da..9f33826 100644
--- a/drivers/mtd/spi-nor/spi_spl_load.c
+++ b/drivers/mtd/spi-nor/spi_spl_load.c
@@ -20,8 +20,7 @@
  * Load the kernel, check for a valid header we can parse, and if found load
  * the kernel and then device tree.
  */
-static int spi_load_image_os(struct spi_flash *flash,
-struct image_header *header)
+static int spi_load_image_os(spi_flash_t *flash, struct image_header *header)
 {
/* Read for a header, parse or error out. */
spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, 0x40,
@@ -52,7 +51,7 @@ static int spi_load_image_os(struct spi_flash *flash,
 int spl_spi_load_image(void)
 {
int err = 0;
-   struct spi_flash *flash;
+   spi_flash_t *flash;
struct image_header *header;
 
/*
-- 
1.9.1

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


[U-Boot] [PATCH v7 27/87] spl: Add CONFIG_SPL_SPI_NOR_SUPPORT

2016-03-22 Thread Jagan Teki
Add SPL support for SPI-NOR flash.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/Makefile b/drivers/Makefile
index e7eab66..1d179b9 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
 obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
 obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/
 obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/
+obj-$(CONFIG_SPL_SPI_NOR_SUPPORT) += mtd/spi-nor/
 obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
-- 
1.9.1

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


[U-Boot] [PATCH v7 30/87] arm: zynq: Kconfig: Drop DM_SPI_FLASH

2016-03-22 Thread Jagan Teki
Drop using legacy DM_SPI_FLASH.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 arch/arm/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1e92be0..b22a04f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -569,7 +569,6 @@ config ARCH_ZYNQ
select DM_SPI
select DM_SERIAL
select MTD
-   select DM_SPI_FLASH
select SPL_SEPARATE_BSS if SPL
 
 config ARCH_ZYNQMP
-- 
1.9.1

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


[U-Boot] [PATCH v7 29/87] arm: zynq: Kconfig: Select MTD uclass

2016-03-22 Thread Jagan Teki
Since SPI-NOR core relies on MTD uclass.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e5f57ef..1e92be0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -568,6 +568,7 @@ config ARCH_ZYNQ
select DM_MMC
select DM_SPI
select DM_SERIAL
+   select MTD
select DM_SPI_FLASH
select SPL_SEPARATE_BSS if SPL
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 28/87] mtd: spi-nor: Add flash vendor Kconfig entries

2016-03-22 Thread Jagan Teki
Added flash vendor kconfig entries from drivers/mtd/spi

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index dd62e24..a035fd3 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -58,4 +58,44 @@ config SPI_NOR_BAR
  Bank/Extended address registers are used to access the flash
  which has size > 16MiB in 3-byte addressing.
 
+config SPI_FLASH_ATMEL
+   bool "Atmel SPI flash support"
+   help
+ Add support for various Atmel SPI flash chips (AT45xxx and AT25xxx)
+
+config SPI_FLASH_EON
+   bool "EON SPI flash support"
+   help
+ Add support for various EON SPI flash chips (EN25xxx)
+
+config SPI_FLASH_GIGADEVICE
+   bool "GigaDevice SPI flash support"
+   help
+ Add support for various GigaDevice SPI flash chips (GD25xxx)
+
+config SPI_FLASH_MACRONIX
+   bool "Macronix SPI flash support"
+   help
+ Add support for various Macronix SPI flash chips (MX25Lxxx)
+
+config SPI_FLASH_SPANSION
+   bool "Spansion SPI flash support"
+   help
+ Add support for various Spansion SPI flash chips (S25FLxxx)
+
+config SPI_FLASH_STMICRO
+   bool "STMicro SPI flash support"
+   help
+ Add support for various STMicro SPI flash chips (M25Pxxx and N25Qxxx)
+
+config SPI_FLASH_SST
+   bool "SST SPI flash support"
+   help
+ Add support for various SST SPI flash chips (SST25xxx)
+
+config SPI_FLASH_WINBOND
+   bool "Winbond SPI flash support"
+   help
+ Add support for various Winbond SPI flash chips (W25xxx)
+
 endif # MTD_SPI_NOR
-- 
1.9.1

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


[U-Boot] [PATCH v7 33/87] mtd: dataflash: Move flash id detection into jedec_probe

2016-03-22 Thread Jagan Teki
Flash id detection should be the first step to enumerate
the connected flash on the board, once ie done checking
with respective id codes locally in the driver all this
should be part of jedec_probe instead of id detection and
validated through flash_info{} table separatly.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index 6a9dfef..7c6c8d2 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -501,9 +501,10 @@ static struct flash_info dataflash_data[] = {
{ "at45db642d",  0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
 };
 
-static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id)
+static struct flash_info *jedec_probe(struct spi_slave *spi)
 {
int tmp;
+   uint8_t id[5];
uint32_tjedec;
struct flash_info   *info;
int status;
@@ -517,6 +518,11 @@ static struct flash_info *jedec_probe(struct spi_slave 
*spi, u8 *id)
 * That's not an error; only rev C and newer chips handle it, and
 * only Atmel sells these chips.
 */
+   tmp = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id));
+   if (tmp < 0) {
+   printf("dataflash: error %d reading JEDEC ID\n", tmp);
+   return ERR_PTR(tmp);
+   }
if (id[0] != 0x1f)
return NULL;
 
@@ -580,7 +586,6 @@ static int spi_dataflash_probe(struct udevice *dev)
struct spi_slave *spi = dev_get_parent_priv(dev);
struct spi_flash *spi_flash;
struct flash_info *info;
-   u8 idcode[5];
int ret, status = 0;
 
spi_flash = dev_get_uclass_priv(dev);
@@ -591,12 +596,6 @@ static int spi_dataflash_probe(struct udevice *dev)
if (ret)
return ret;
 
-   ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
-   if (ret) {
-   printf("SPI DataFlash: Failed to get idcodes\n");
-   goto err_read_cmd;
-   }
-
/*
 * Try to detect dataflash by JEDEC ID.
 * If it succeeds we know we have either a C or D part.
@@ -604,7 +603,9 @@ static int spi_dataflash_probe(struct udevice *dev)
 * Both support the security register, though with different
 * write procedures.
 */
-   info = jedec_probe(spi, idcode);
+   info = jedec_probe(spi);
+   if (IS_ERR(info))
+   return PTR_ERR(info);
if (info != NULL)
add_dataflash(dev, info->name, info->nr_pages,
  info->pagesize, info->pageoffset,
-- 
1.9.1

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


[U-Boot] [PATCH v7 34/87] mtd: dataflash: Fix add_dataflash return logic

2016-03-22 Thread Jagan Teki
This patch fixed the add_dataflash return logic,
so-that it can handle both jedec and older chips
same as Linux.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 127 ++---
 1 file changed, 61 insertions(+), 66 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index 7c6c8d2..b7e2a83 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -586,15 +586,15 @@ static int spi_dataflash_probe(struct udevice *dev)
struct spi_slave *spi = dev_get_parent_priv(dev);
struct spi_flash *spi_flash;
struct flash_info *info;
-   int ret, status = 0;
+   int status;
 
spi_flash = dev_get_uclass_priv(dev);
spi_flash->spi = spi;
spi_flash->dev = dev;
 
-   ret = spi_claim_bus(spi);
-   if (ret)
-   return ret;
+   status = spi_claim_bus(spi);
+   if (status)
+   return status;
 
/*
 * Try to detect dataflash by JEDEC ID.
@@ -605,74 +605,69 @@ static int spi_dataflash_probe(struct udevice *dev)
 */
info = jedec_probe(spi);
if (IS_ERR(info))
-   return PTR_ERR(info);
-   if (info != NULL)
-   add_dataflash(dev, info->name, info->nr_pages,
- info->pagesize, info->pageoffset,
- (info->flags & SUP_POW2PS) ? 'd' : 'c');
-   else {
-   /*
-   * Older chips support only legacy commands, identifing
-   * capacity using bits in the status byte.
-   */
-   status = dataflash_status(spi);
-   if (status <= 0 || status == 0xff) {
-   printf("SPI DataFlash: read status error %d\n", status);
-   if (status == 0 || status == 0xff)
-   status = -ENODEV;
-   goto err_read_cmd;
-   }
-   /*
-   * if there's a device there, assume it's dataflash.
-   * board setup should have set spi->max_speed_max to
-   * match f(car) for continuous reads, mode 0 or 3.
-   */
-   switch (status & 0x3c) {
-   case 0x0c:  /* 0 0 1 1 x x */
-   status = add_dataflash(dev, "AT45DB011B",
-  512, 264, 9, 0);
-   break;
-   case 0x14:  /* 0 1 0 1 x x */
-   status = add_dataflash(dev, "AT45DB021B",
-  1024, 264, 9, 0);
-   break;
-   case 0x1c:  /* 0 1 1 1 x x */
-   status = add_dataflash(dev, "AT45DB041x",
-  2048, 264, 9, 0);
-   break;
-   case 0x24:  /* 1 0 0 1 x x */
-   status = add_dataflash(dev, "AT45DB081B",
-  4096, 264, 9, 0);
-   break;
-   case 0x2c:  /* 1 0 1 1 x x */
-   status = add_dataflash(dev, "AT45DB161x",
-  4096, 528, 10, 0);
-   break;
-   case 0x34:  /* 1 1 0 1 x x */
-   status = add_dataflash(dev, "AT45DB321x",
-  8192, 528, 10, 0);
-   break;
-   case 0x38:  /* 1 1 1 x x x */
-   case 0x3c:
-   status = add_dataflash(dev, "AT45DB642x",
-  8192, 1056, 11, 0);
-   break;
-   /* obsolete AT45DB1282 not (yet?) supported */
-   default:
-   dev_info(&spi->dev, "unsupported device (%x)\n",
-status & 0x3c);
+   goto err_jedec_probe;
+   if (info != NULL) {
+   status = add_dataflash(dev, info->name, info->nr_pages,
+   info->pagesize, info->pageoffset,
+   (info->flags & SUP_POW2PS) ? 'd' : 'c');
+   if (status < 0)
+   goto err_status;
+   }
+
+   /*
+   * Older chips support only legacy commands, identifing
+   * capacity using bits in the status byte.
+   */
+   status = dataflash_status(spi);
+   if (status <= 0 || status == 0xff) {
+   printf("SPI DataFlash: read status error %d\n", status);
+   if (status == 0 || status == 0xff)
status = -ENODEV;
-   goto err_read_cmd;
-   }
+   goto err_jedec_probe;
}
 
-   spi_release_bus(spi);
+   /*
+   * if there's a device there, assume 

[U-Boot] [PATCH v7 31/87] mtd: spi-nor: Copy sf_dataflash

2016-03-22 Thread Jagan Teki
Copy sf_dataflash.c from drivers/mtd/spi to spi-nor,
more changes will see on future patches.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 701 +
 1 file changed, 701 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/sf_dataflash.c

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
new file mode 100644
index 000..b2a56da
--- /dev/null
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -0,0 +1,701 @@
+/*
+ *
+ * Atmel DataFlash probing
+ *
+ * Copyright (C) 2004-2009, 2015 Freescale Semiconductor, Inc.
+ * Haikun Wang (haikun.w...@freescale.com)
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+*/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sf_internal.h"
+
+/* reads can bypass the buffers */
+#define OP_READ_CONTINUOUS 0xE8
+#define OP_READ_PAGE   0xD2
+
+/* group B requests can run even while status reports "busy" */
+#define OP_READ_STATUS 0xD7/* group B */
+
+/* move data between host and buffer */
+#define OP_READ_BUFFER10xD4/* group B */
+#define OP_READ_BUFFER20xD6/* group B */
+#define OP_WRITE_BUFFER1   0x84/* group B */
+#define OP_WRITE_BUFFER2   0x87/* group B */
+
+/* erasing flash */
+#define OP_ERASE_PAGE  0x81
+#define OP_ERASE_BLOCK 0x50
+
+/* move data between buffer and flash */
+#define OP_TRANSFER_BUF1   0x53
+#define OP_TRANSFER_BUF2   0x55
+#define OP_MREAD_BUFFER1   0xD4
+#define OP_MREAD_BUFFER2   0xD6
+#define OP_MWERASE_BUFFER1 0x83
+#define OP_MWERASE_BUFFER2 0x86
+#define OP_MWRITE_BUFFER1  0x88/* sector must be pre-erased */
+#define OP_MWRITE_BUFFER2  0x89/* sector must be pre-erased */
+
+/* write to buffer, then write-erase to flash */
+#define OP_PROGRAM_VIA_BUF10x82
+#define OP_PROGRAM_VIA_BUF20x85
+
+/* compare buffer to flash */
+#define OP_COMPARE_BUF10x60
+#define OP_COMPARE_BUF20x61
+
+/* read flash to buffer, then write-erase to flash */
+#define OP_REWRITE_VIA_BUF10x58
+#define OP_REWRITE_VIA_BUF20x59
+
+/*
+ * newer chips report JEDEC manufacturer and device IDs; chip
+ * serial number and OTP bits; and per-sector writeprotect.
+ */
+#define OP_READ_ID 0x9F
+#define OP_READ_SECURITY   0x77
+#define OP_WRITE_SECURITY_REVC 0x9A
+#define OP_WRITE_SECURITY  0x9B/* revision D */
+
+
+struct dataflash {
+   uint8_t command[16];
+   unsigned short  page_offset;/* offset in flash address */
+};
+
+/*
+ * Return the status of the DataFlash device.
+ */
+static inline int dataflash_status(struct spi_slave *spi)
+{
+   int ret;
+   u8 status;
+   /*
+* NOTE:  at45db321c over 25 MHz wants to write
+* a dummy byte after the opcode...
+*/
+   ret = spi_flash_cmd(spi, OP_READ_STATUS, &status, 1);
+   return ret ? -EIO : status;
+}
+
+/*
+ * Poll the DataFlash device until it is READY.
+ * This usually takes 5-20 msec or so; more for sector erase.
+ * ready: return > 0
+ */
+static int dataflash_waitready(struct spi_slave *spi)
+{
+   int status;
+   int timeout = 2 * CONFIG_SYS_HZ;
+   int timebase;
+
+   timebase = get_timer(0);
+   do {
+   status = dataflash_status(spi);
+   if (status < 0)
+   status = 0;
+
+   if (status & (1 << 7))  /* RDY/nBSY */
+   return status;
+
+   mdelay(3);
+   } while (get_timer(timebase) < timeout);
+
+   return -ETIME;
+}
+
+/*
+ * Erase pages of flash.
+ */
+static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len)
+{
+   struct dataflash*dataflash;
+   struct spi_flash*spi_flash;
+   struct spi_slave*spi;
+   unsignedblocksize;
+   uint8_t *command;
+   uint32_trem;
+   int status;
+
+   dataflash = dev_get_priv(dev);
+   spi_flash = dev_get_uclass_priv(dev);
+   spi = spi_flash->spi;
+
+   blocksize = spi_flash->page_size << 3;
+
+   memset(dataflash->command, 0 , sizeof(dataflash->command));
+   command = dataflash->command;
+
+   debug("%s: erase addr=0x%x len 0x%x\n", dev->name, offset, len);
+
+   div_u64_rem(len, spi_flash->page_size, &rem);
+   if (rem)
+   return -EINVAL;
+   div_u64_rem(offset, spi_flash->page_size, &rem);
+   if (rem)
+   return -EINVAL;
+
+   status = spi_claim_bus(spi);
+   if (status) {
+   debug("SPI DATAFLASH: unable to claim SPI bus\n");
+   return status;
+   }
+
+   while (len > 0) {
+   unsigned intpageaddr;
+   int do_block;
+  

[U-Boot] [PATCH v7 32/87] mtd: dataflash: Remove unneeded spi data

2016-03-22 Thread Jagan Teki
dataflash doesn't require options, memory_map from spi.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index b2a56da..6a9dfef 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -584,6 +584,7 @@ static int spi_dataflash_probe(struct udevice *dev)
int ret, status = 0;
 
spi_flash = dev_get_uclass_priv(dev);
+   spi_flash->spi = spi;
spi_flash->dev = dev;
 
ret = spi_claim_bus(spi);
@@ -664,11 +665,6 @@ static int spi_dataflash_probe(struct udevice *dev)
}
}
 
-   /* Assign spi data */
-   spi_flash->spi = spi;
-   spi_flash->memory_map = spi->memory_map;
-   spi_flash->dual_flash = spi->option;
-
spi_release_bus(spi);
 
return 0;
-- 
1.9.1

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


[U-Boot] [PATCH v7 35/87] mtd: dataflash: Add UCLASS_MTD support

2016-03-22 Thread Jagan Teki
This patch replace the dataflash driver from SPI_FLASH
uclass to MTD UCLASS along with the support of mtd opertaions.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 214 ++---
 1 file changed, 107 insertions(+), 107 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index b7e2a83..722ab7e 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -2,6 +2,7 @@
  *
  * Atmel DataFlash probing
  *
+ * Copyright (C) 2016 Jagan Teki 
  * Copyright (C) 2004-2009, 2015 Freescale Semiconductor, Inc.
  * Haikun Wang (haikun.w...@freescale.com)
  *
@@ -12,10 +13,10 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
+#include 
 
 #include "sf_internal.h"
 
@@ -70,7 +71,11 @@
 
 struct dataflash {
uint8_t command[16];
+
unsigned short  page_offset;/* offset in flash address */
+   unsigned intpage_size;  /* of bytes per page */
+
+   struct spi_slave*spi;
 };
 
 /*
@@ -117,31 +122,25 @@ static int dataflash_waitready(struct spi_slave *spi)
 /*
  * Erase pages of flash.
  */
-static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len)
+static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
-   struct dataflash*dataflash;
-   struct spi_flash*spi_flash;
-   struct spi_slave*spi;
-   unsignedblocksize;
+   struct dataflash*priv = mtd->priv;
+   struct spi_slave*spi = priv->spi;
+   unsignedblocksize = priv->page_size << 3;
uint8_t *command;
uint32_trem;
int status;
 
-   dataflash = dev_get_priv(dev);
-   spi_flash = dev_get_uclass_priv(dev);
-   spi = spi_flash->spi;
-
-   blocksize = spi_flash->page_size << 3;
-
-   memset(dataflash->command, 0 , sizeof(dataflash->command));
-   command = dataflash->command;
+   memset(priv->command, 0 , sizeof(priv->command));
+   command = priv->command;
 
-   debug("%s: erase addr=0x%x len 0x%x\n", dev->name, offset, len);
+   debug("%s: erase addr=0x%llx len 0x%llx\n", mtd->name,
+ instr->addr, instr->len);
 
-   div_u64_rem(len, spi_flash->page_size, &rem);
+   div_u64_rem(instr->len, priv->page_size, &rem);
if (rem)
return -EINVAL;
-   div_u64_rem(offset, spi_flash->page_size, &rem);
+   div_u64_rem(instr->addr, priv->page_size, &rem);
if (rem)
return -EINVAL;
 
@@ -151,16 +150,16 @@ static int spi_dataflash_erase(struct udevice *dev, u32 
offset, size_t len)
return status;
}
 
-   while (len > 0) {
+   while (instr->len > 0) {
unsigned intpageaddr;
int do_block;
/*
 * Calculate flash page address; use block erase (for speed) if
 * we're at a block boundary and need to erase the whole block.
 */
-   pageaddr = div_u64(offset, spi_flash->page_size);
-   do_block = (pageaddr & 0x7) == 0 && len >= blocksize;
-   pageaddr = pageaddr << dataflash->page_offset;
+   pageaddr = div_u64(instr->addr, priv->page_size);
+   do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize;
+   pageaddr = pageaddr << priv->page_offset;
 
command[0] = do_block ? OP_ERASE_BLOCK : OP_ERASE_PAGE;
command[1] = (uint8_t)(pageaddr >> 16);
@@ -168,67 +167,68 @@ static int spi_dataflash_erase(struct udevice *dev, u32 
offset, size_t len)
command[3] = 0;
 
debug("%s ERASE %s: (%x) %x %x %x [%d]\n",
- dev->name, do_block ? "block" : "page",
+ mtd->name, do_block ? "block" : "page",
  command[0], command[1], command[2], command[3],
  pageaddr);
 
status = spi_flash_cmd_write(spi, command, 4, NULL, 0);
if (status < 0) {
-   debug("%s: erase send command error!\n", dev->name);
+   debug("%s: erase send command error!\n", mtd->name);
return -EIO;
}
 
status = dataflash_waitready(spi);
if (status < 0) {
-   debug("%s: erase waitready error!\n", dev->name);
+   debug("%s: erase waitready error!\n", mtd->name);
return status;
}
 
if (do_block) {
-   offset += blocksize;
-   len -= blocksize;
+   instr->addr += blocksize;
+   instr->len -= block

[U-Boot] [PATCH v7 36/87] mtd: dataflash: Use spi_write_then_read

2016-03-22 Thread Jagan Teki
Use spi_write_then_read call from spi layer for
dataflash write and then read calling.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index 722ab7e..525af0a 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -84,12 +84,12 @@ struct dataflash {
 static inline int dataflash_status(struct spi_slave *spi)
 {
int ret;
-   u8 status;
+   u8 cmd = OP_READ_STATUS, status;
/*
 * NOTE:  at45db321c over 25 MHz wants to write
 * a dummy byte after the opcode...
 */
-   ret = spi_flash_cmd(spi, OP_READ_STATUS, &status, 1);
+   ret = spi_write_then_read(spi, &cmd, 1, NULL, &status, 1);
return ret ? -EIO : status;
 }
 
@@ -171,7 +171,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct 
erase_info *instr)
  command[0], command[1], command[2], command[3],
  pageaddr);
 
-   status = spi_flash_cmd_write(spi, command, 4, NULL, 0);
+   status = spi_write_then_read(spi, command, 4, NULL, NULL, 0);
if (status < 0) {
debug("%s: erase send command error!\n", mtd->name);
return -EIO;
@@ -247,7 +247,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t 
from, size_t len,
command[3] = (uint8_t)(addr >> 0);
 
/* plus 4 "don't care" bytes, command len: 4 + 4 "don't care" bytes */
-   status = spi_flash_cmd_read(spi, command, 8, buf, len);
+   status = spi_write_then_read(spi, command, 8, NULL, buf, len);
if (status >= 0) {
*retlen = len - 8;
status = 0;
@@ -327,7 +327,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
debug("TRANSFER: (%x) %x %x %x\n",
  command[0], command[1], command[2], command[3]);
 
-   status = spi_flash_cmd_write(spi, command, 4, NULL, 0);
+   status = spi_write_then_read(spi, command, 4, NULL, 
NULL, 0);
if (status < 0) {
debug("%s: write(name);
@@ -352,8 +352,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
debug("PROGRAM: (%x) %x %x %x\n",
  command[0], command[1], command[2], command[3]);
 
-   status = spi_flash_cmd_write(spi, command,
-4, writebuf, writelen);
+   status = spi_write_then_read(spi, command, 4,
+writebuf, NULL, writelen);
if (status < 0) {
debug("%s: write send command error!\n", mtd->name);
return -EIO;
@@ -376,8 +376,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
debug("COMPARE: (%x) %x %x %x\n",
  command[0], command[1], command[2], command[3]);
 
-   status = spi_flash_cmd_write(spi, command,
-4, writebuf, writelen);
+   status = spi_write_then_read(spi, command, 4,
+writebuf, NULL, writelen);
if (status < 0) {
debug("%s: write(compare) send command error!\n",
  mtd->name);
@@ -519,6 +519,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
uint8_t id[5];
uint32_tjedec;
struct flash_info   *info;
+   u8 cmd = CMD_READ_ID;
int status;
 
/*
@@ -530,7 +531,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
 * That's not an error; only rev C and newer chips handle it, and
 * only Atmel sells these chips.
 */
-   tmp = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id));
+   tmp = spi_write_then_read(spi, &cmd, 1, NULL, id, sizeof(id));
if (tmp < 0) {
printf("dataflash: error %d reading JEDEC ID\n", tmp);
return ERR_PTR(tmp);
-- 
1.9.1

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


[U-Boot] [PATCH v7 37/87] mtd: dataflash: Drop sf_internal.h

2016-03-22 Thread Jagan Teki
Drop using sf_internal.h and get the RDID from spi-nor.h

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index 525af0a..9943560 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -17,8 +17,7 @@
 #include 
 #include 
 #include 
-
-#include "sf_internal.h"
+#include 
 
 /* reads can bypass the buffers */
 #define OP_READ_CONTINUOUS 0xE8
@@ -519,7 +518,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
uint8_t id[5];
uint32_tjedec;
struct flash_info   *info;
-   u8 cmd = CMD_READ_ID;
+   u8 cmd = SNOR_OP_RDID;
int status;
 
/*
-- 
1.9.1

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


[U-Boot] [PATCH v7 38/87] mtd: dataflash: Minor cleanups

2016-03-22 Thread Jagan Teki
- rename spi_dataflash to mtd_dataflash
- fix single line comments
- remove unneeded spaces
- ascending order of include files
- rename spi_dataflash_* to dataflash_*
- rename SPI DATAFLASH to dataflash
- rename SPI DataFlash to dataflash
- return NULL replaced with error code

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sf_dataflash.c | 51 --
 1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/sf_dataflash.c
index 9943560..2a5f5ae 100644
--- a/drivers/mtd/spi-nor/sf_dataflash.c
+++ b/drivers/mtd/spi-nor/sf_dataflash.c
@@ -1,5 +1,4 @@
 /*
- *
  * Atmel DataFlash probing
  *
  * Copyright (C) 2016 Jagan Teki 
@@ -7,8 +6,10 @@
  * Haikun Wang (haikun.w...@freescale.com)
  *
  * SPDX-License-Identifier:GPL-2.0+
-*/
+ */
+
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -67,7 +68,6 @@
 #define OP_WRITE_SECURITY_REVC 0x9A
 #define OP_WRITE_SECURITY  0x9B/* revision D */
 
-
 struct dataflash {
uint8_t command[16];
 
@@ -77,9 +77,7 @@ struct dataflash {
struct spi_slave*spi;
 };
 
-/*
- * Return the status of the DataFlash device.
- */
+/* Return the status of the DataFlash device */
 static inline int dataflash_status(struct spi_slave *spi)
 {
int ret;
@@ -118,9 +116,7 @@ static int dataflash_waitready(struct spi_slave *spi)
return -ETIME;
 }
 
-/*
- * Erase pages of flash.
- */
+/* Erase pages of flash */
 static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
struct dataflash*priv = mtd->priv;
@@ -145,7 +141,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct 
erase_info *instr)
 
status = spi_claim_bus(spi);
if (status) {
-   debug("SPI DATAFLASH: unable to claim SPI bus\n");
+   debug("dataflash: unable to claim SPI bus\n");
return status;
}
 
@@ -231,7 +227,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t 
from, size_t len,
 
status = spi_claim_bus(spi);
if (status) {
-   debug("SPI DATAFLASH: unable to claim SPI bus\n");
+   debug("dataflash: unable to claim SPI bus\n");
return status;
}
 
@@ -290,7 +286,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
 
status = spi_claim_bus(spi);
if (status) {
-   debug("SPI DATAFLASH: unable to claim SPI bus\n");
+   debug("dataflash: unable to claim SPI bus\n");
return status;
}
 
@@ -387,7 +383,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
 
/* Check result of the compare operation */
if (status & (1 << 6)) {
-   printf("SPI DataFlash: write compare page %u, err %d\n",
+   printf("dataflash: write compare page %u, err %d\n",
   pageaddr, status);
remaining = 0;
status = -EIO;
@@ -551,7 +547,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
if (info->flags & SUP_POW2PS) {
status = dataflash_status(spi);
if (status < 0) {
-   debug("SPI DataFlash: status error 
%d\n",
+   debug("dataflash: status error %d\n",
  status);
return NULL;
}
@@ -573,10 +569,8 @@ static struct flash_info *jedec_probe(struct spi_slave 
*spi)
 * size (it might be binary) even when we can tell which density
 * class is involved (legacy chip id scheme).
 */
-   printf("SPI DataFlash: Unsupported flash IDs: ");
-   printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
-  id[0], jedec, id[3] << 8 | id[4]);
-   return NULL;
+   printf("dataflash: JEDEC id %06x not handled\n", jedec);
+   return ERR_PTR(-ENODEV);
 }
 
 /*
@@ -593,7 +587,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi)
  *   AT45DB0642  64Mbit  (8M)xx111xxx (0x3c)   8192   1056 11
  *   AT45DB1282  128Mbit (16M)   xx0100xx (0x10)  16384   1056 11
  */
-static int spi_dataflash_probe(struct udevice *dev)
+static int dataflash_probe(struct udevice *dev)
 {
struct spi_slave*spi = dev_get_parent_priv(dev);
struct flash_info   *info;
@@ -621,19 +615,19 @@ static int spi_dataflash_probe(struct udevice *dev)
goto err_status;
}
 
-   /*
+   /*
* Older chips support only legacy commands, identifing
* capacity using bits in the status byte.
*/
status = dataflash_status(spi);
if (status <

[U-Boot] [PATCH v7 40/87] mtd: spi-nor: Add Kconfig entry for mtd_dataflash

2016-03-22 Thread Jagan Teki
Added kconfig entry for MTD_DATAFLASH

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index a035fd3..f2bd630 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -99,3 +99,18 @@ config SPI_FLASH_WINBOND
  Add support for various Winbond SPI flash chips (W25xxx)
 
 endif # MTD_SPI_NOR
+
+config MTD_DATAFLASH
+   bool "AT45xxx DataFlash support"
+   depends on MTD
+   help
+ Enable the access for SPI-flash-based AT45xxx DataFlash chips.
+ DataFlash is a kind of SPI flash. Most AT45 chips have two buffers
+ in each chip, which may be used for double buffered I/O; but this
+ driver doesn't (yet) use these for any kind of i/o overlap or 
prefetching.
+
+ Sometimes DataFlash is packaged in MMC-format cards, although the
+ MMC stack can't (yet?) distinguish between MMC and DataFlash
+ protocols during enumeration.
+
+ If unsure, say N
-- 
1.9.1

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


[U-Boot] [PATCH v7 41/87] mtd: dataflash: Add MTD_DATAFLASH_WRITE_VERIFY

2016-03-22 Thread Jagan Teki
mtd_dataflash driver almost similar to Linux, so rename the
CONFIG_SPI_DATAFLASH_WRITE_VERIFY => CONFIG_MTD_DATAFLASH_WRITE_VERIFY

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/mtd_dataflash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/mtd_dataflash.c 
b/drivers/mtd/spi-nor/mtd_dataflash.c
index 2a5f5ae..fae862e 100644
--- a/drivers/mtd/spi-nor/mtd_dataflash.c
+++ b/drivers/mtd/spi-nor/mtd_dataflash.c
@@ -360,7 +360,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
return status;
}
 
-#ifdef CONFIG_SPI_DATAFLASH_WRITE_VERIFY
+#ifdef CONFIG_MTD_DATAFLASH_WRITE_VERIFY
/* (3) Compare to Buffer1 */
addr = pageaddr << priv->page_offset;
command[0] = OP_COMPARE_BUF1;
@@ -392,7 +392,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, 
size_t len,
status = 0;
}
 
-#endif /* CONFIG_SPI_DATAFLASH_WRITE_VERIFY */
+#endif /* CONFIG_MTD_DATAFLASH_WRITE_VERIFY */
remaining = remaining - writelen;
pageaddr++;
offset = 0;
-- 
1.9.1

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


[U-Boot] [PATCH v7 39/87] mtd: Rename sf_dataflash.c to mtd_dataflash.c

2016-03-22 Thread Jagan Teki
Since dataflash driver is using mtd_info core
functionalities this patch renames file and
config name similar way as Linux.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Makefile| 1 +
 drivers/mtd/spi-nor/{sf_dataflash.c => mtd_dataflash.c} | 0
 2 files changed, 1 insertion(+)
 rename drivers/mtd/spi-nor/{sf_dataflash.c => mtd_dataflash.c} (100%)

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 4a854fa..525fccd 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_DM_MTD_SPI_NOR)  += spi-nor-probe.o
 endif
 
 obj-$(CONFIG_MTD_M25P80)   += m25p80.o
+obj-$(CONFIG_MTD_DATAFLASH)+= mtd_dataflash.o
diff --git a/drivers/mtd/spi-nor/sf_dataflash.c 
b/drivers/mtd/spi-nor/mtd_dataflash.c
similarity index 100%
rename from drivers/mtd/spi-nor/sf_dataflash.c
rename to drivers/mtd/spi-nor/mtd_dataflash.c
-- 
1.9.1

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


[U-Boot] [PATCH v7 42/87] mtd: spi-nor: Add kconfig MTD_DATAFLASH_WRITE_VERIFY

2016-03-22 Thread Jagan Teki
Added kconfig entry for MTD_DATAFLASH_WRITE_VERIFY

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index f2bd630..12dcede 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -114,3 +114,13 @@ config MTD_DATAFLASH
  protocols during enumeration.
 
  If unsure, say N
+
+config MTD_DATAFLASH_WRITE_VERIFY
+   bool "Verify DataFlash page writes"
+   depends on MTD_DATAFLASH
+   help
+ This adds an extra check when data is written to the flash.
+ It may help if you are verifying chip setup (timings etc) on
+ your board.  There is a rare possibility that even though the
+ device thinks the write was successful, a bit could have been
+ flipped accidentally due to device wear or something else.
-- 
1.9.1

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


[U-Boot] [PATCH v7 43/87] configs: ls1021aqds: Drop DM_SPI_FLASH and DATAFLASH

2016-03-22 Thread Jagan Teki
Dropped DM_SPI_FLASH and SPI_FLASH_DATAFLASH

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 include/configs/ls1021aqds.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h
index d7025f6..b5415f4 100644
--- a/include/configs/ls1021aqds.h
+++ b/include/configs/ls1021aqds.h
@@ -432,8 +432,6 @@ unsigned long get_board_ddr_clk(void);
 /* DM SPI */
 #if defined(CONFIG_FSL_DSPI) || defined(CONFIG_FSL_QSPI)
 #define CONFIG_CMD_SF
-#define CONFIG_DM_SPI_FLASH
-#define CONFIG_SPI_FLASH_DATAFLASH
 #endif
 #endif
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 45/87] defconfig: ls1021aqds_qspi: Enable CONFIG_MTD_DATAFLASH

2016-03-22 Thread Jagan Teki
Enable CONFIG_MTD_DATAFLASH

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 configs/ls1021aqds_qspi_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/ls1021aqds_qspi_defconfig 
b/configs/ls1021aqds_qspi_defconfig
index 32a8662..ce4b677 100644
--- a/configs/ls1021aqds_qspi_defconfig
+++ b/configs/ls1021aqds_qspi_defconfig
@@ -12,6 +12,7 @@ CONFIG_DM=y
 CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD_DATAFLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
-- 
1.9.1

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


[U-Boot] [PATCH v7 47/87] mtd: spi-nor: sandbox: Use spi-nor header

2016-03-22 Thread Jagan Teki
Since sandbox moved to use spi-nor layer, this patch
replaced the header changes from sf_internal.h to
mtd/spi-nor.h

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sandbox.c | 46 +--
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/spi-nor/sandbox.c b/drivers/mtd/spi-nor/sandbox.c
index 53470b9..cc7b2a4 100644
--- a/drivers/mtd/spi-nor/sandbox.c
+++ b/drivers/mtd/spi-nor/sandbox.c
@@ -12,10 +12,8 @@
 #include 
 #include 
 #include 
-#include 
-
 #include 
-#include "sf_internal.h"
+#include 
 
 #include 
 #include 
@@ -24,6 +22,8 @@
 #include 
 #include 
 
+#include 
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
@@ -88,7 +88,7 @@ struct sandbox_spi_flash {
/* The current flash status (see STAT_XXX defines above) */
u16 status;
/* Data describing the flash we're emulating */
-   const struct spi_flash_params *data;
+   const struct spi_nor_info *data;
/* The file on disk to serv up data from */
int fd;
 };
@@ -112,7 +112,7 @@ static int sandbox_sf_probe(struct udevice *dev)
struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
const char *file;
size_t len, idname_len;
-   const struct spi_flash_params *data;
+   const struct spi_nor_info *data;
struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
struct sandbox_state *state = state_get_current();
struct udevice *bus = dev->parent;
@@ -168,7 +168,7 @@ static int sandbox_sf_probe(struct udevice *dev)
}
debug("%s: device='%s'\n", __func__, spec);
 
-   for (data = spi_flash_params_table; data->name; data++) {
+   for (data = spi_nor_ids; data->name; data++) {
len = strlen(data->name);
if (idname_len != len)
continue;
@@ -256,45 +256,45 @@ static int sandbox_sf_process_cmd(struct 
sandbox_spi_flash *sbsf, const u8 *rx,
 
sbsf->cmd = rx[0];
switch (sbsf->cmd) {
-   case CMD_READ_ID:
+   case SNOR_OP_RDID:
sbsf->state = SF_ID;
sbsf->cmd = SF_ID;
break;
-   case CMD_READ_ARRAY_FAST:
+   case SNOR_OP_READ_FAST:
sbsf->pad_addr_bytes = 1;
-   case CMD_READ_ARRAY_SLOW:
-   case CMD_PAGE_PROGRAM:
+   case SNOR_OP_READ:
+   case SNOR_OP_PP:
sbsf->state = SF_ADDR;
break;
-   case CMD_WRITE_DISABLE:
+   case SNOR_OP_WRDI:
debug(" write disabled\n");
sbsf->status &= ~STAT_WEL;
break;
-   case CMD_READ_STATUS:
+   case SNOR_OP_RDSR:
sbsf->state = SF_READ_STATUS;
break;
-   case CMD_READ_STATUS1:
+   case SNOR_OP_RDCR:
sbsf->state = SF_READ_STATUS1;
break;
-   case CMD_WRITE_ENABLE:
+   case SNOR_OP_WREN:
debug(" write enabled\n");
sbsf->status |= STAT_WEL;
break;
-   case CMD_WRITE_STATUS:
+   case SNOR_OP_WRSR:
sbsf->state = SF_WRITE_STATUS;
break;
default: {
int flags = sbsf->data->flags;
 
/* we only support erase here */
-   if (sbsf->cmd == CMD_ERASE_CHIP) {
+   if (sbsf->cmd == SPINOR_OP_CHIP_ERASE) {
sbsf->erase_size = sbsf->data->sector_size *
-   sbsf->data->nr_sectors;
-   } else if (sbsf->cmd == CMD_ERASE_4K && (flags & SECT_4K)) {
+   sbsf->data->n_sectors;
+   } else if (sbsf->cmd == SNOR_OP_BE_4K && (flags & SECT_4K)) {
sbsf->erase_size = 4 << 10;
-   } else if (sbsf->cmd == CMD_ERASE_32K && (flags & SECT_32K)) {
+   } else if (sbsf->cmd == SNOR_OP_BE_32K && (flags & SECT_32K)) {
sbsf->erase_size = 32 << 10;
-   } else if (sbsf->cmd == CMD_ERASE_64K &&
+   } else if (sbsf->cmd == SNOR_OP_SE &&
   !(flags & (SECT_4K | SECT_32K))) {
sbsf->erase_size = 64 << 10;
} else {
@@ -395,11 +395,11 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned 
int bitlen,
return -EIO;
}
switch (sbsf->cmd) {
-   case CMD_READ_ARRAY_FAST:
-   case CMD_READ_ARRAY_SLOW:
+   case SNOR_OP_READ_FAST:
+   case SNOR_OP_READ:
sbsf->state = SF_READ;
break;
-   case CMD_PAGE_PROGRAM:
+   case SNOR_OP_PP:
sbsf->state = SF_WRITE;
break;
default:
-- 
1.9.1


[U-Boot] [PATCH v7 44/87] defconfig: ls1021aqds_qspi: Enable SPI-NOR

2016-03-22 Thread Jagan Teki
Enable SPI-NOR with MTD uclass.

Cc: Bin Meng 
Cc: Simon Glass 
Cc: York Sun 
Signed-off-by: Jagan Teki 
---
 configs/ls1021aqds_qspi_defconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/ls1021aqds_qspi_defconfig 
b/configs/ls1021aqds_qspi_defconfig
index 025fd4e..32a8662 100644
--- a/configs/ls1021aqds_qspi_defconfig
+++ b/configs/ls1021aqds_qspi_defconfig
@@ -9,7 +9,9 @@ CONFIG_SYS_EXTRA_OPTIONS="QSPI_BOOT"
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
-CONFIG_SPI_FLASH=y
+CONFIG_MTD=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_M25P80=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
-- 
1.9.1

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


[U-Boot] [PATCH v7 46/87] mtd: spi-nor: Copy sandbox

2016-03-22 Thread Jagan Teki
Copy sandbox.c from drivers/mtd/spi to spi-nor,
more changes will added on future patches.

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sandbox.c | 703 ++
 1 file changed, 703 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/sandbox.c

diff --git a/drivers/mtd/spi-nor/sandbox.c b/drivers/mtd/spi-nor/sandbox.c
new file mode 100644
index 000..53470b9
--- /dev/null
+++ b/drivers/mtd/spi-nor/sandbox.c
@@ -0,0 +1,703 @@
+/*
+ * Simulate a SPI flash
+ *
+ * Copyright (c) 2011-2013 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "sf_internal.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * The different states that our SPI flash transitions between.
+ * We need to keep track of this across multiple xfer calls since
+ * the SPI bus could possibly call down into us multiple times.
+ */
+enum sandbox_sf_state {
+   SF_CMD,   /* default state -- we're awaiting a command */
+   SF_ID,/* read the flash's (jedec) ID code */
+   SF_ADDR,  /* processing the offset in the flash to read/etc... */
+   SF_READ,  /* reading data from the flash */
+   SF_WRITE, /* writing data to the flash, i.e. page programming */
+   SF_ERASE, /* erase the flash */
+   SF_READ_STATUS, /* read the flash's status register */
+   SF_READ_STATUS1, /* read the flash's status register upper 8 bits*/
+   SF_WRITE_STATUS, /* write the flash's status register */
+};
+
+static const char *sandbox_sf_state_name(enum sandbox_sf_state state)
+{
+   static const char * const states[] = {
+   "CMD", "ID", "ADDR", "READ", "WRITE", "ERASE", "READ_STATUS",
+   "READ_STATUS1", "WRITE_STATUS",
+   };
+   return states[state];
+}
+
+/* Bits for the status register */
+#define STAT_WIP   (1 << 0)
+#define STAT_WEL   (1 << 1)
+
+/* Assume all SPI flashes have 3 byte addresses since they do atm */
+#define SF_ADDR_LEN3
+
+#define IDCODE_LEN 3
+
+/* Used to quickly bulk erase backing store */
+static u8 sandbox_sf_0xff[0x1000];
+
+/* Internal state data for each SPI flash */
+struct sandbox_spi_flash {
+   unsigned int cs;/* Chip select we are attached to */
+   /*
+* As we receive data over the SPI bus, our flash transitions
+* between states.  For example, we start off in the SF_CMD
+* state where the first byte tells us what operation to perform
+* (such as read or write the flash).  But the operation itself
+* can go through a few states such as first reading in the
+* offset in the flash to perform the requested operation.
+* Thus "state" stores the exact state that our machine is in
+* while "cmd" stores the overall command we're processing.
+*/
+   enum sandbox_sf_state state;
+   uint cmd;
+   /* Erase size of current erase command */
+   uint erase_size;
+   /* Current position in the flash; used when reading/writing/etc... */
+   uint off;
+   /* How many address bytes we've consumed */
+   uint addr_bytes, pad_addr_bytes;
+   /* The current flash status (see STAT_XXX defines above) */
+   u16 status;
+   /* Data describing the flash we're emulating */
+   const struct spi_flash_params *data;
+   /* The file on disk to serv up data from */
+   int fd;
+};
+
+struct sandbox_spi_flash_plat_data {
+   const char *filename;
+   const char *device_name;
+   int bus;
+   int cs;
+};
+
+/**
+ * This is a very strange probe function. If it has platform data (which may
+ * have come from the device tree) then this function gets the filename and
+ * device type from there. Failing that it looks at the command line
+ * parameter.
+ */
+static int sandbox_sf_probe(struct udevice *dev)
+{
+   /* spec = idcode:file */
+   struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
+   const char *file;
+   size_t len, idname_len;
+   const struct spi_flash_params *data;
+   struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
+   struct sandbox_state *state = state_get_current();
+   struct udevice *bus = dev->parent;
+   const char *spec = NULL;
+   int ret = 0;
+   int cs = -1;
+   int i;
+
+   debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev);
+   if (bus->seq >= 0 && bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS) {
+   for (i = 0; i < CONFIG_SANDBOX_SPI_MAX_CS; i++) {
+   if (state->spi[bus->seq][i].emul == dev)
+   cs = i;
+   }
+   }
+   if (cs == -1) {
+   printf("Error: Unknown chip select for device '%s'\n",
+  dev

[U-Boot] [PATCH v7 49/87] mtd: spi-nor: Add SPI_NOR_SANDBOX

2016-03-22 Thread Jagan Teki
To follow spi-nor notation replaced CONFIG_SPI_FLASH_SANDBOX
with CONFIG_SPI_NOR_SANDBOX.

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig  | 10 ++
 drivers/mtd/spi-nor/Makefile |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 12dcede..cdef6aa 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -98,6 +98,16 @@ config SPI_FLASH_WINBOND
help
  Add support for various Winbond SPI flash chips (W25xxx)
 
+config SPI_NOR_SANDBOX
+   bool "Support sandbox SPI flash device"
+   depends on SANDBOX
+   help
+ Since sandbox cannot access real devices, an emulation mechanism is
+ provided instead. Drivers can be connected up to the sandbox SPI
+ bus (see CONFIG_SANDBOX_SPI) and SPI traffic will be routed to this
+ device. Typically the contents of the emulated SPI flash device is
+ stored in a file on the host filesystem.
+
 endif # MTD_SPI_NOR
 
 config MTD_DATAFLASH
diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 525fccd..a4bd5ba 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -17,3 +17,4 @@ endif
 
 obj-$(CONFIG_MTD_M25P80)   += m25p80.o
 obj-$(CONFIG_MTD_DATAFLASH)+= mtd_dataflash.o
+obj-$(CONFIG_SPI_NOR_SANDBOX)  += sandbox.o
-- 
1.9.1

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


[U-Boot] [PATCH v7 51/87] test/dm: spi: Use CONFIG_DM_MTD_SPI_NOR

2016-03-22 Thread Jagan Teki
Use CONFIG_DM_MTD_SPI_NOR instead of CONFIG_DM_SPI_FLASH

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 test/dm/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/dm/spi.c b/test/dm/spi.c
index 2e27da7..f234c80 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -118,7 +118,7 @@ static int dm_test_spi_xfer(struct unit_test_state *uts)
 * Since we are about to destroy all devices, we must tell sandbox
 * to forget the emulation device
 */
-#ifdef CONFIG_DM_SPI_FLASH
+#ifdef CONFIG_DM_MTD_SPI_NOR
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
 #endif
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 48/87] mtd: spi-nor: sandbox: Fix ID exctract from spi_nor_info

2016-03-22 Thread Jagan Teki
This patch fix the id exctract from spi_nor_info ids.

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/sandbox.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/sandbox.c b/drivers/mtd/spi-nor/sandbox.c
index cc7b2a4..8bd06f4 100644
--- a/drivers/mtd/spi-nor/sandbox.c
+++ b/drivers/mtd/spi-nor/sandbox.c
@@ -362,7 +362,8 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned 
int bitlen,
debug(" id: off:%u tx:", sbsf->off);
if (sbsf->off < IDCODE_LEN) {
/* Extract correct byte from ID 0x00aabbcc */
-   id = sbsf->data->jedec >>
+   id = ((JEDEC_MFR(sbsf->data) << 16) |
+   JEDEC_ID(sbsf->data)) >>
(8 * (IDCODE_LEN - 1 - sbsf->off));
} else {
id = 0;
-- 
1.9.1

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


[U-Boot] [PATCH v7 53/87] test/dm: spi: Use m25p80 as driver name

2016-03-22 Thread Jagan Teki
Since new spi-nor using m25p80 as a driver name for
probing flash chip using spi_get_bus_and_cs, hence
replace the 'spi_flash_std' with 'm25p80

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 test/dm/spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/dm/spi.c b/test/dm/spi.c
index f234c80..82ddd7e 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -59,7 +59,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
 */
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode,
-   "spi_flash_std", "name", &bus,
+   "m25p80", "name", &bus,
&slave));
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
ut_assertok(spi_cs_info(bus, cs, &info));
@@ -70,7 +70,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
 "name"));
ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode,
-  "spi_flash_std", "name", &bus, &slave));
+  "m25p80", "name", &bus, &slave));
 
ut_assertok(spi_cs_info(bus, cs, &info));
ut_asserteq_ptr(info.dev, slave->dev);
@@ -79,7 +79,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, of_offset,
 "name"));
ut_assertok(spi_get_bus_and_cs(busnum, cs_b, speed, mode,
-  "spi_flash_std", "name", &bus, &slave));
+  "m25p80", "name", &bus, &slave));
ut_assertok(spi_cs_info(bus, cs_b, &info));
ut_asserteq_ptr(info.dev, slave->dev);
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 52/87] configs: sandbox: Enable SPI-NOR sandbox driver

2016-03-22 Thread Jagan Teki
- CONFIG_DM_SPI_FLASH
+ CONFIG_MTD
+ CONFIG_MTD_M25P80
+ CONFIG_MTD_SPI_NOR
+ CONFIG_SPI_NOR_SANDBOX

Replace CONFIG_SPI_FLASH with CONFIG_MTD_SPI_NOR

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 arch/Kconfig  |  2 +-
 configs/sandbox_defconfig |  5 +++--
 drivers/mtd/spi-nor/sandbox.c |  2 +-
 include/spi_flash.h   | 14 +++---
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index ec12013..2c58b9a 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -87,11 +87,11 @@ config SANDBOX
select SYS_GENERIC_BOARD
select SUPPORT_OF_CONTROL
select DM
-   select DM_SPI_FLASH
select DM_SERIAL
select DM_I2C
select DM_SPI
select DM_GPIO
+   select MTD
 
 config SH
bool "SuperH architecture"
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index d69c9fc..6873d7a 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -40,8 +40,9 @@ CONFIG_CROS_EC=y
 CONFIG_CROS_EC_SANDBOX=y
 CONFIG_RESET=y
 CONFIG_DM_MMC=y
-CONFIG_SPI_FLASH_SANDBOX=y
-CONFIG_SPI_FLASH=y
+CONFIG_SPI_NOR_SANDBOX=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_M25P80=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_EON=y
 CONFIG_SPI_FLASH_GIGADEVICE=y
diff --git a/drivers/mtd/spi-nor/sandbox.c b/drivers/mtd/spi-nor/sandbox.c
index 8bd06f4..a3ffea2 100644
--- a/drivers/mtd/spi-nor/sandbox.c
+++ b/drivers/mtd/spi-nor/sandbox.c
@@ -536,7 +536,7 @@ static const struct dm_spi_emul_ops sandbox_sf_emul_ops = {
.xfer  = sandbox_sf_xfer,
 };
 
-#ifdef CONFIG_SPI_FLASH
+#ifdef CONFIG_MTD_SPI_NOR
 static int sandbox_cmdline_cb_spi_sf(struct sandbox_state *state,
 const char *arg)
 {
diff --git a/include/spi_flash.h b/include/spi_flash.h
index f77a9c9..712ad61 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -148,6 +148,13 @@ static inline int spi_flash_protect(spi_flash_t *info, u32 
ofs,
 
 #ifdef CONFIG_DM_MTD_SPI_NOR
 
+struct sandbox_state;
+
+int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
+struct udevice *bus, int of_offset, const char *spec);
+
+void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs);
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
   struct udevice **devp);
@@ -273,13 +280,6 @@ void sandbox_sf_unbind_emul(struct sandbox_state *state, 
int busnum, int cs);
 
 #elif !defined(CONFIG_MTD_SPI_NOR)
 
-struct sandbox_state;
-
-int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
-struct udevice *bus, int of_offset, const char *spec);
-
-void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs);
-
 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int spi_mode);
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 50/87] test/dm: Makefile: Use CONFIG_DM_MTD_SPI_NOR

2016-03-22 Thread Jagan Teki
Use CONFIG_DM_MTD_SPI_NOR instead of CONFIG_DM_SPI_FLASH

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 test/dm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/dm/Makefile b/test/dm/Makefile
index df2d71f..ae8e5c2 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -28,7 +28,7 @@ obj-y += regmap.o
 obj-$(CONFIG_REMOTEPROC) += remoteproc.o
 obj-$(CONFIG_RESET) += reset.o
 obj-$(CONFIG_DM_RTC) += rtc.o
-obj-$(CONFIG_DM_SPI_FLASH) += sf.o
+obj-$(CONFIG_DM_MTD_SPI_NOR) += sf.o
 obj-$(CONFIG_DM_SPI) += spi.o
 obj-y += syscon.o
 obj-$(CONFIG_DM_USB) += usb.o
-- 
1.9.1

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


[U-Boot] [PATCH v7 54/87] dts: sandbox: Use jedec, spi-nor compatible string

2016-03-22 Thread Jagan Teki
Use spi-nor flash driver compatible string as 'jedec,spi-nor'
instead of spi-flash

Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 arch/sandbox/dts/test.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 9b8d658..cdb21a5 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -267,7 +267,7 @@
cs-gpios = <0>, <&gpio_a 0>;
spi.bin@0 {
reg = <0>;
-   compatible = "spansion,m25p16", "spi-flash";
+   compatible = "spansion,m25p16", "jedec,spi-nor";
spi-max-frequency = <4000>;
sandbox,filename = "spi.bin";
};
-- 
1.9.1

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


[U-Boot] [PATCH v7 55/87] x86: Drop using spi_flash_dm_ops

2016-03-22 Thread Jagan Teki
Since spi-nor flash is part of MTD uclass, so replaced
UCLASS_SPI_FLASH with UCLASS_MTD and use respective
spi_flash operations as well.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 arch/arm/mach-rockchip/rk3288-board-spl.c | 2 +-
 arch/x86/lib/mrccache.c   | 9 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-rockchip/rk3288-board-spl.c 
b/arch/arm/mach-rockchip/rk3288-board-spl.c
index e133cca..7aed5c6 100644
--- a/arch/arm/mach-rockchip/rk3288-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3288-board-spl.c
@@ -53,7 +53,7 @@ u32 spl_boot_device(void)
}
debug("Found device %s\n", dev->name);
switch (device_get_uclass_id(dev)) {
-   case UCLASS_SPI_FLASH:
+   case UCLASS_MTD:
return BOOT_DEVICE_SPI;
case UCLASS_MMC:
return BOOT_DEVICE_MMC1;
diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index 67bace4..1d6ce35 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -109,6 +109,7 @@ static struct mrc_data_container 
*find_next_mrc_cache(struct mrc_region *entry,
 int mrccache_update(struct udevice *sf, struct mrc_region *entry,
struct mrc_data_container *cur)
 {
+   spi_flash_t *flash = dev_get_uclass_priv(sf);
struct mrc_data_container *cache;
ulong offset;
ulong base_addr;
@@ -139,7 +140,7 @@ int mrccache_update(struct udevice *sf, struct mrc_region 
*entry,
debug("Erasing the MRC cache region of %x bytes at %x\n",
  entry->length, entry->offset);
 
-   ret = spi_flash_erase_dm(sf, entry->offset, entry->length);
+   ret = spi_flash_erase(flash, entry->offset, entry->length);
if (ret) {
debug("Failed to erase flash region\n");
return ret;
@@ -150,8 +151,7 @@ int mrccache_update(struct udevice *sf, struct mrc_region 
*entry,
/* Write the data out */
offset = (ulong)cache - base_addr + entry->offset;
debug("Write MRC cache update to flash at %lx\n", offset);
-   ret = spi_flash_write_dm(sf, offset, cur->data_size + sizeof(*cur),
-cur);
+   ret = spi_flash_write(flash, offset, cur->data_size + sizeof(*cur), 
cur);
if (ret) {
debug("Failed to write to SPI flash\n");
return ret;
@@ -216,8 +216,7 @@ int mrccache_get_region(struct udevice **devp, struct 
mrc_region *entry)
entry->length = reg[1];
 
if (devp) {
-   ret = uclass_get_device_by_of_offset(UCLASS_SPI_FLASH, node,
-devp);
+   ret = uclass_get_device_by_of_offset(UCLASS_MTD, node, devp);
debug("ret = %d\n", ret);
if (ret)
return ret;
-- 
1.9.1

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


[U-Boot] [PATCH v7 56/87] spi_flash: Use spi_flash_t

2016-03-22 Thread Jagan Teki
Use spi_flash_t instead of struct spi_flash.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 board/Arcturus/ucp1020/cmd_arc.c | 2 +-
 board/Synology/ds414/cmd_syno.c  | 2 +-
 board/buffalo/lsxl/lsxl.c| 2 +-
 board/congatec/cgtqmx6eval/cgtqmx6eval.c | 2 +-
 board/davinci/da8xxevm/da850evm.c| 2 +-
 board/renesas/sh7752evb/sh7752evb.c  | 4 ++--
 board/renesas/sh7753evb/sh7753evb.c  | 4 ++--
 board/renesas/sh7757lcr/sh7757lcr.c  | 6 +++---
 board/siemens/taurus/taurus.c| 2 +-
 common/splash_source.c   | 2 +-
 drivers/dfu/dfu_sf.c | 4 ++--
 drivers/net/fm/fm.c  | 2 +-
 drivers/net/phy/cortina.c| 2 +-
 include/dfu.h| 2 +-
 14 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/board/Arcturus/ucp1020/cmd_arc.c b/board/Arcturus/ucp1020/cmd_arc.c
index fa6b485..9f98d6d 100644
--- a/board/Arcturus/ucp1020/cmd_arc.c
+++ b/board/Arcturus/ucp1020/cmd_arc.c
@@ -37,7 +37,7 @@
 #define FIRM_ADDR3 (CONFIG_ENV_SECT_SIZE + 0x200 - sizeof(smac))
 #define FIRM_ADDR4 (CONFIG_ENV_SECT_SIZE + 0x400 - sizeof(smac))
 
-static struct spi_flash *flash;
+static spi_flash_t *flash;
 char smac[4][18];
 
 static int ishwaddr(char *hwaddr)
diff --git a/board/Synology/ds414/cmd_syno.c b/board/Synology/ds414/cmd_syno.c
index 20544e2..1d0f3e7 100644
--- a/board/Synology/ds414/cmd_syno.c
+++ b/board/Synology/ds414/cmd_syno.c
@@ -27,7 +27,7 @@ static int do_syno_populate(int argc, char * const argv[])
unsigned int cs = CONFIG_SF_DEFAULT_CS;
unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
unsigned int mode = CONFIG_SF_DEFAULT_MODE;
-   struct spi_flash *flash;
+   spi_flash_t *flash;
unsigned long addr = 0x8; /* XXX: parameterize this? */
loff_t offset = 0x007d;
loff_t len = 0x0001;
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 0f37345..298d26e 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -211,7 +211,7 @@ void check_enetaddr(void)
 
 static void erase_environment(void)
 {
-   struct spi_flash *flash;
+   spi_flash_t *flash;
 
printf("Erasing environment..\n");
flash = spi_flash_probe(0, 0, 100, SPI_MODE_3);
diff --git a/board/congatec/cgtqmx6eval/cgtqmx6eval.c 
b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
index 225de7c..8db2b9e 100644
--- a/board/congatec/cgtqmx6eval/cgtqmx6eval.c
+++ b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
@@ -1005,7 +1005,7 @@ static void conv_ascii(unsigned char *dst, unsigned char 
*src, int len)
 #define CFG_MFG_ADDR_OFFSET(spi->size - SZ_16K)
 static bool is_2gb(void)
 {
-   struct spi_flash *spi;
+   spi_flash_t *spi;
int ret;
char buf[sizeof(struct mfgdata)];
struct mfgdata *data = (struct mfgdata *)buf;
diff --git a/board/davinci/da8xxevm/da850evm.c 
b/board/davinci/da8xxevm/da850evm.c
index b82385a..356d3ce 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -49,7 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
 static int get_mac_addr(u8 *addr)
 {
-   struct spi_flash *flash;
+   spi_flash_t *flash;
int ret;
 
flash = spi_flash_probe(CFG_MAC_ADDR_SPI_BUS, CFG_MAC_ADDR_SPI_CS,
diff --git a/board/renesas/sh7752evb/sh7752evb.c 
b/board/renesas/sh7752evb/sh7752evb.c
index 3aad532..35360fd 100644
--- a/board/renesas/sh7752evb/sh7752evb.c
+++ b/board/renesas/sh7752evb/sh7752evb.c
@@ -185,7 +185,7 @@ int board_mmc_init(bd_t *bis)
 
 static int get_sh_eth_mac_raw(unsigned char *buf, int size)
 {
-   struct spi_flash *spi;
+   spi_flash_t *spi;
int ret;
 
spi = spi_flash_probe(0, 0, 100, SPI_MODE_3);
@@ -254,7 +254,7 @@ int do_write_mac(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 {
int i, ret;
char mac_string[256];
-   struct spi_flash *spi;
+   spi_flash_t *spi;
unsigned char *buf;
 
if (argc != 3) {
diff --git a/board/renesas/sh7753evb/sh7753evb.c 
b/board/renesas/sh7753evb/sh7753evb.c
index 52a1906..8d609ec 100644
--- a/board/renesas/sh7753evb/sh7753evb.c
+++ b/board/renesas/sh7753evb/sh7753evb.c
@@ -201,7 +201,7 @@ int board_mmc_init(bd_t *bis)
 
 static int get_sh_eth_mac_raw(unsigned char *buf, int size)
 {
-   struct spi_flash *spi;
+   spi_flash_t *spi;
int ret;
 
spi = spi_flash_probe(0, 0, 100, SPI_MODE_3);
@@ -270,7 +270,7 @@ int do_write_mac(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
 {
int i, ret;
char mac_string[256];
-   struct spi_flash *spi;
+   spi_flash_t *spi;
unsigned char *buf;
 
if (argc != 3) {
diff --git a/board/renesas/sh7757lcr/sh7757lcr.c 
b/board/renesas/sh7757lcr/sh7757lcr.c
index ddcf275..9793f1f 100644
--- 

[U-Boot] [PATCH v7 57/87] defconfig: zynq_zc770_xm013: Enable ZYNQ_QSPI

2016-03-22 Thread Jagan Teki
Use zynq qspi driver for zynq zc770_xm013 board.

Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 configs/zynq_zc770_xm013_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/zynq_zc770_xm013_defconfig 
b/configs/zynq_zc770_xm013_defconfig
index 9672940..9feaca8 100644
--- a/configs/zynq_zc770_xm013_defconfig
+++ b/configs/zynq_zc770_xm013_defconfig
@@ -17,3 +17,4 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_BAR=y
 CONFIG_ZYNQ_GEM=y
+CONFIG_ZYNQ_QSPI=y
-- 
1.9.1

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


[U-Boot] [PATCH v7 58/87] configs: Drop CONFIG_SPI_FLASH_MTD

2016-03-22 Thread Jagan Teki
Since mtd support is part of spi-nor core, hence
removed legacy defines.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 include/configs/aristainetos-common.h | 1 -
 include/configs/gw_ventana.h  | 1 -
 include/configs/socfpga_common.h  | 1 -
 3 files changed, 3 deletions(-)

diff --git a/include/configs/aristainetos-common.h 
b/include/configs/aristainetos-common.h
index efbf816..d9e14b2 100644
--- a/include/configs/aristainetos-common.h
+++ b/include/configs/aristainetos-common.h
@@ -42,7 +42,6 @@
 #define CONFIG_PHY_MICREL
 
 #define CONFIG_CMD_SF
-#define CONFIG_SPI_FLASH_MTD
 #define CONFIG_MXC_SPI
 #define CONFIG_SF_DEFAULT_SPEED2000
 #define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
index 38c921a..cf71f21 100644
--- a/include/configs/gw_ventana.h
+++ b/include/configs/gw_ventana.h
@@ -68,7 +68,6 @@
 #define CONFIG_CMD_SF
 #ifdef CONFIG_CMD_SF
   #define CONFIG_MXC_SPI
-  #define CONFIG_SPI_FLASH_MTD
   #define CONFIG_SPI_FLASH_BAR
   #define CONFIG_SF_DEFAULT_BUS  0
   #define CONFIG_SF_DEFAULT_CS   0
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 56d32e6..b002260 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -206,7 +206,6 @@ unsigned int cm_get_l4_sp_clk_hz(void);
  */
 /* Enable multiple SPI NOR flash manufacturers */
 #ifndef CONFIG_SPL_BUILD
-#define CONFIG_SPI_FLASH_MTD
 #define CONFIG_CMD_MTDPARTS
 #define CONFIG_MTD_DEVICE
 #define CONFIG_MTD_PARTITIONS
-- 
1.9.1

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


[U-Boot] [PATCH v7 60/87] spi-nor: Use CONFIG_MTD_SPI_NOR

2016-03-22 Thread Jagan Teki
Replace legacy CONFIG_SPI_FLASH with CONFIG_MTD_SPI_NOR

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 board/davinci/da8xxevm/da850evm.c | 2 +-
 common/splash_source.c| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/davinci/da8xxevm/da850evm.c 
b/board/davinci/da8xxevm/da850evm.c
index 356d3ce..7a2b8e0 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -234,7 +234,7 @@ const struct pinmux_resource pinmuxes[] = {
PINMUX_ITEM(emac_pins_mii),
 #endif
 #endif
-#ifdef CONFIG_SPI_FLASH
+#ifdef CONFIG_MTD_SPI_NOR
PINMUX_ITEM(spi1_pins_base),
PINMUX_ITEM(spi1_pins_scs0),
 #endif
diff --git a/common/splash_source.c b/common/splash_source.c
index 3393f73..505fa2a 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -19,7 +19,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_SPI_FLASH
+#ifdef CONFIG_MTD_SPI_NOR
 static spi_flash_t *sf;
 static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)
 {
-- 
1.9.1

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


[U-Boot] [PATCH v7 63/87] mtd: spi-nor: Add CONFIG_SPI_NOR_MISC

2016-03-22 Thread Jagan Teki
The flash chips vendors like
- Atmel
- EON
- ESMT
- Everspin
- Fujitsu
- GigaDevice
- Intel
- ISSI
- PMC
- non-JEDEC

have shared most of the spi-nor core code, so group
all of them into a common config CONFIG_SPI_NOR_MISC
this certainly reduced the individual chip configs.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/Kconfig   | 17 -
 drivers/mtd/spi-nor/spi-nor-ids.c | 21 ++---
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/spi-nor/Kconfig b/drivers/mtd/spi-nor/Kconfig
index 15e0746..f9c6ca9 100644
--- a/drivers/mtd/spi-nor/Kconfig
+++ b/drivers/mtd/spi-nor/Kconfig
@@ -58,20 +58,11 @@ config SPI_NOR_BAR
  Bank/Extended address registers are used to access the flash
  which has size > 16MiB in 3-byte addressing.
 
-config SPI_FLASH_ATMEL
-   bool "Atmel SPI flash support"
+config SPI_NOR_MISC
+   bool "Miscellaneous SPI NOR flash's support"
help
- Add support for various Atmel SPI flash chips (AT45xxx and AT25xxx)
-
-config SPI_FLASH_EON
-   bool "EON SPI flash support"
-   help
- Add support for various EON SPI flash chips (EN25xxx)
-
-config SPI_FLASH_GIGADEVICE
-   bool "GigaDevice SPI flash support"
-   help
- Add support for various GigaDevice SPI flash chips (GD25xxx)
+ Add support for various Atmel, EON, ESMT, Everspin, Fujitsu,
+ GigaDevice, Intel, ISSI, PMC and non-JEDEC SPI NOR flash chips.
 
 config SPI_NOR_MACRONIX
bool "Macronix SPI flash support"
diff --git a/drivers/mtd/spi-nor/spi-nor-ids.c 
b/drivers/mtd/spi-nor/spi-nor-ids.c
index b523948..4c22140 100644
--- a/drivers/mtd/spi-nor/spi-nor-ids.c
+++ b/drivers/mtd/spi-nor/spi-nor-ids.c
@@ -41,6 +41,7 @@
.flash_read = _flash_read,  
\
.flags = (_flags),
 
+#ifdef CONFIG_SPI_NOR_MISC
 #define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width, 
_flash_read, _flags) \
.sector_size = (_sector_size),  \
.n_sectors = (_n_sectors),  \
@@ -48,6 +49,7 @@
.addr_width = (_addr_width),\
.flash_read = _flash_read,  
\
.flags = (_flags),
+#endif
 
 /* NOTE: double check command sets and memory organization when you add
  * more nor chips.  This current list focusses on newer chips, which
@@ -61,7 +63,7 @@
  * old entries may be missing 4K flag.
  */
 const struct spi_nor_info spi_nor_ids[] = {
-#ifdef CONFIG_SPI_FLASH_ATMEL  /* ATMEL */
+#ifdef CONFIG_SPI_NOR_MISC
/* Atmel -- some are (confusingly) marketed as "DataFlash" */
{ "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SNOR_READ_BASE, 
SECT_4K) },
{ "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SNOR_READ_BASE, 
SECT_4K) },
@@ -83,7 +85,7 @@ const struct spi_nor_info spi_nor_ids[] = {
{ "at45db321d", INFO(0x1f2700, 0, 64 * 1024,  64, SNOR_READ_BASE, 
SECT_4K) },
{ "at45db641d", INFO(0x1f2800, 0, 64 * 1024, 128, SNOR_READ_BASE, 
SECT_4K) },
 #endif
-#ifdef CONFIG_SPI_FLASH_EON/* EON */
+#ifdef CONFIG_SPI_NOR_MISC
/* EON -- en25xxx */
{ "en25f32",INFO(0x1c3116, 0, 64 * 1024,   64, SNOR_READ_BASE, 
SECT_4K) },
{ "en25p32",INFO(0x1c2016, 0, 64 * 1024,   64, SNOR_READ_BASE, 0) },
@@ -95,6 +97,7 @@ const struct spi_nor_info spi_nor_ids[] = {
{ "en25qh256",  INFO(0x1c7019, 0, 64 * 1024,  512, SNOR_READ_BASE, 0) },
{ "en25s64",INFO(0x1c3817, 0, 64 * 1024,  128, SNOR_READ_BASE, 
SECT_4K) },
 #endif
+#ifdef CONFIG_SPI_NOR_MISC
/* ESMT */
{ "f25l32pa", INFO(0x8c2016, 0, 64 * 1024, 64, SNOR_READ_BASE, SECT_4K) 
},
 
@@ -104,20 +107,21 @@ const struct spi_nor_info spi_nor_ids[] = {
 
/* Fujitsu */
{ "mb85rs1mt", INFO(0x047f27, 0, 128 * 1024, 1, SNOR_READ_BASE, 
SPI_NOR_NO_ERASE) },
-
-#ifdef CONFIG_SPI_FLASH_GIGADEVICE /* GIGADEVICE */
+#endif
+#ifdef CONFIG_SPI_NOR_MISC
/* GigaDevice */
{ "gd25q32", INFO(0xc84016, 0, 64 * 1024,  64, SNOR_READ_BASE, SECT_4K) 
},
{ "gd25q64", INFO(0xc84017, 0, 64 * 1024, 128, SNOR_READ_BASE, SECT_4K) 
},
{ "gd25q128", INFO(0xc84018, 0, 64 * 1024, 256, SNOR_READ_BASE, 
SECT_4K) },
{ "gd25lq32", INFO(0xc86016, 0, 64 * 1024,  64, SNOR_READ_BASE, 
SECT_4K) },
 #endif
+#ifdef CONFIG_SPI_NOR_MISC
/* Intel/Numonyx -- xxxs33b */
{ "160s33b",  INFO(0x898911, 0, 64 * 1024,  32, SNOR_READ_BASE, 0) },
{ "320s33b",  INFO(0x898912, 0, 64 * 1024,  64, SNOR_READ_BASE, 0) },
{ "640s33b",  INFO(0x898913, 0, 64 * 1024, 128, SNOR_READ_BASE, 0) },
-
-#ifdef CONFIG_SPI_FLASH_ISSI   /* ISSI */
+#endif
+#ifdef CONFIG_SPI_NOR_MISC
/*

[U-Boot] [PATCH v7 64/87] configs: Use CONFIG_SPI_NOR_MISC

2016-03-22 Thread Jagan Teki
CONFIG_SPI_FLASH_ATMEL
CONFIG_SPI_FLASH_EON
CONFIG_SPI_FLASH_GIGADEVICE
CONFIG_SPI_FLASH_ISSI

All these configs are grouped in CONFIG_SPI_NOR_MISC

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 configs/C29XPCIE_NAND_defconfig   | 2 +-
 configs/C29XPCIE_NOR_SECBOOT_defconfig| 2 +-
 configs/C29XPCIE_SPIFLASH_SECBOOT_defconfig   | 2 +-
 configs/C29XPCIE_SPIFLASH_defconfig   | 2 +-
 configs/C29XPCIE_defconfig| 2 +-
 configs/M54418TWR_defconfig   | 2 +-
 configs/M54418TWR_nand_mii_defconfig  | 2 +-
 configs/M54418TWR_nand_rmii_defconfig | 2 +-
 configs/M54418TWR_nand_rmii_lowfreq_defconfig | 2 +-
 configs/M54418TWR_serial_mii_defconfig| 2 +-
 configs/M54418TWR_serial_rmii_defconfig   | 2 +-
 configs/T1024QDS_DDR4_SECURE_BOOT_defconfig   | 2 +-
 configs/T1024QDS_DDR4_defconfig   | 2 +-
 configs/T1024QDS_NAND_defconfig   | 2 +-
 configs/T1024QDS_SDCARD_defconfig | 2 +-
 configs/T1024QDS_SECURE_BOOT_defconfig| 2 +-
 configs/T1024QDS_SPIFLASH_defconfig   | 2 +-
 configs/T1024QDS_defconfig| 2 +-
 configs/T1040QDS_DDR4_defconfig   | 2 +-
 configs/T1040QDS_SECURE_BOOT_defconfig| 2 +-
 configs/T1040QDS_defconfig| 2 +-
 configs/T2080QDS_NAND_defconfig   | 2 +-
 configs/T2080QDS_SDCARD_defconfig | 2 +-
 configs/T2080QDS_SECURE_BOOT_defconfig| 2 +-
 configs/T2080QDS_SPIFLASH_defconfig   | 2 +-
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig | 2 +-
 configs/T2080QDS_defconfig| 2 +-
 configs/T2081QDS_NAND_defconfig   | 2 +-
 configs/T2081QDS_SDCARD_defconfig | 2 +-
 configs/T2081QDS_SPIFLASH_defconfig   | 2 +-
 configs/T2081QDS_SRIO_PCIE_BOOT_defconfig | 2 +-
 configs/T2081QDS_defconfig| 2 +-
 configs/at91sam9n12ek_mmc_defconfig   | 2 +-
 configs/at91sam9n12ek_nandflash_defconfig | 2 +-
 configs/at91sam9n12ek_spiflash_defconfig  | 2 +-
 configs/at91sam9x5ek_dataflash_defconfig  | 2 +-
 configs/at91sam9x5ek_mmc_defconfig| 2 +-
 configs/at91sam9x5ek_nandflash_defconfig  | 2 +-
 configs/at91sam9x5ek_spiflash_defconfig   | 2 +-
 configs/atngw100_defconfig| 2 +-
 configs/atngw100mkii_defconfig| 2 +-
 configs/bayleybay_defconfig   | 2 +-
 configs/bf525-ucr2_defconfig  | 2 +-
 configs/bf527-sdp_defconfig   | 3 +--
 configs/bf537-stamp_defconfig | 3 +--
 configs/bf561-acvilon_defconfig   | 2 +-
 configs/bf609-ezkit_defconfig | 3 +--
 configs/chromebook_link_defconfig | 2 +-
 configs/chromebook_samus_defconfig| 2 +-
 configs/chromebox_panther_defconfig   | 2 +-
 configs/cm_fx6_defconfig  | 4 +---
 configs/cm_t43_defconfig  | 5 +
 configs/conga-qeval20-qa3-e3845_defconfig | 2 +-
 configs/coreboot-x86_defconfig| 2 +-
 configs/crownbay_defconfig| 2 +-
 configs/ethernut5_defconfig   | 2 +-
 configs/galileo_defconfig | 2 +-
 configs/gplugd_defconfig  | 2 +-
 configs/ls1021atwr_qspi_defconfig | 2 +-
 configs/ls1021atwr_sdcard_qspi_defconfig  | 2 +-
 configs/minnowmax_defconfig   | 2 +-
 configs/peach-pi_defconfig| 2 +-
 configs/peach-pit_defconfig   | 2 +-
 configs/qemu-x86_defconfig| 2 +-
 configs/sama5d3xek_mmc_defconfig  | 2 +-
 configs/sama5d3xek_nandflash_defconfig| 2 +-
 configs/sama5d3xek_spiflash_defconfig | 2 +-
 configs/sama5d4_xplained_mmc_defconfig| 2 +-
 configs/sama5d4_xplained_nandflash_defconfig  | 2 +-
 configs/sama5d4_xplained_spiflash_defconfig   | 2 +-
 configs/sama5d4ek_mmc_defconfig   | 2 +-
 configs/sama5d4ek_nandflash_defconfig | 2 +-
 configs/sama5d4ek_spiflash_defconfig  | 2 +-
 configs/sandbox_defconfig | 4 +---
 configs/smdk5250_defconfig| 2 +-
 configs/smdk5420_defconfig| 2 +-
 configs/snow_defconfig| 2 +-
 configs/spring_defconfig  | 2 +-
 examples/standalone/Makefile  | 2 +-
 include/configs/chromebook_jerry.h| 2 +-
 include/configs/ls1043a_common.h  | 2 +-
 include/configs/rk3036_common.h   | 2 +-
 include/configs/sama5d2_xplained.h| 2 +-
 include/configs/zynq-common.h | 2 +-
 84 files changed, 84 insertions(+), 94 deletions(-)

diff --git a/configs/C29XPCIE_NAND_defconfig b/configs/C29XPCIE_NAND_defconfig
index 61ac704..c8d33f3 100644
--- a/conf

[U-Boot] [PATCH v7 65/87] powerpc/mpc85xx: Use spi.h instead of spi_flash.h

2016-03-22 Thread Jagan Teki
For spi_set_speed this patch unnecessarily using
spi_flash.h instead of spi.h
"powerpc/mpc85xx: Add board support for ucp1020"
(sha1: 8b0044ff5942943eaa49935f49d5006b346a60f8)

So, fix this by using spi.h instead of spi_flash.h

Cc: York Sun 
Cc: Oleksandr G Zhadan 
Cc: Michael Durrant 
Signed-off-by: Jagan Teki 
---
 board/Arcturus/ucp1020/ucp1020.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/Arcturus/ucp1020/ucp1020.c b/board/Arcturus/ucp1020/ucp1020.c
index 0fc2bac..452d221 100644
--- a/board/Arcturus/ucp1020/ucp1020.c
+++ b/board/Arcturus/ucp1020/ucp1020.c
@@ -22,7 +22,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
1.9.1

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


[U-Boot] [PATCH v7 67/87] uclass: Drop UCLASS_SPI_FLASH

2016-03-22 Thread Jagan Teki
Drop using UCLASS_SPI_FLASH, spi-nor flash is part
of MTD uclass now.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 include/dm/uclass-id.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 37c4176..747fcc8 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -66,7 +66,6 @@ enum uclass_id {
UCLASS_RTC, /* Real time clock device */
UCLASS_SERIAL,  /* Serial UART */
UCLASS_SPI, /* SPI bus */
-   UCLASS_SPI_FLASH,   /* SPI flash */
UCLASS_SPI_GENERIC, /* Generic SPI flash target */
UCLASS_SYSCON,  /* System configuration device */
UCLASS_THERMAL, /* Thermal sensor */
-- 
1.9.1

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


[U-Boot] [PATCH v7 68/87] spi: Drop mode_rx

2016-03-22 Thread Jagan Teki
mp2580 will take care of tx and rx mode's so there is
no need to differentiate these into spi layer level
hence replaced all mode_rx macros with mode.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 19 +--
 drivers/spi/ich.c|  6 ++
 drivers/spi/spi-uclass.c | 11 ---
 drivers/spi/ti_qspi.c|  6 +++---
 include/spi.h| 14 --
 5 files changed, 18 insertions(+), 38 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 429d710..bf9fe02 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -187,26 +187,17 @@ static int m25p80_spi_nor(struct spi_nor *nor)
return ret;
}
 
-   switch (spi->mode_rx) {
-   case SPI_RX_SLOW:
+   if (spi->mode & SPI_RX_SLOW)
nor->read_mode = SNOR_READ;
-   break;
-   case SPI_RX_DUAL:
+   else if (spi->mode & SPI_RX_DUAL)
nor->read_mode = SNOR_READ_1_1_2;
-   break;
-   case SPI_RX_QUAD:
+   else if (spi->mode & SPI_RX_QUAD)
nor->read_mode = SNOR_READ_1_1_4;
-   break;
-   }
 
-   switch (spi->mode) {
-   case SPI_TX_BYTE:
+   if (spi->mode & SPI_TX_BYTE)
nor->mode = SNOR_WRITE_1_1_BYTE;
-   break;
-   case SPI_TX_QUAD:
+   else if (spi->mode & SPI_TX_QUAD)
nor->mode = SNOR_WRITE_1_1_4;
-   break;
-   }
 
nor->memory_map = spi->memory_map;
nor->max_write_size = spi->max_write_size;
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index 00b2fed..a89f859 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -649,10 +649,8 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
 * ICH 7 SPI controller only supports array read command
 * and byte program command for SST flash
 */
-   if (plat->ich_version == ICHV_7) {
-   slave->mode_rx = SPI_RX_SLOW;
-   slave->mode = SPI_TX_BYTE;
-   }
+   if (plat->ich_version == ICHV_7)
+   slave->mode = SPI_TX_BYTE | SPI_RX_SLOW;
 
return 0;
 }
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 7ef2496..0e52ac8 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -181,7 +181,6 @@ static int spi_child_pre_probe(struct udevice *dev)
 
slave->max_hz = plat->max_hz;
slave->mode = plat->mode;
-   slave->mode_rx = plat->mode_rx;
slave->wordlen = SPI_DEFAULT_WORDLEN;
 
return 0;
@@ -394,7 +393,7 @@ void spi_free_slave(struct spi_slave *slave)
 int spi_slave_ofdata_to_platdata(const void *blob, int node,
 struct dm_spi_slave_platdata *plat)
 {
-   int mode = 0, mode_rx = 0;
+   int mode = 0;
int value;
 
plat->cs = fdtdec_get_int(blob, node, "reg", -1);
@@ -426,24 +425,22 @@ int spi_slave_ofdata_to_platdata(const void *blob, int 
node,
break;
}
 
-   plat->mode = mode;
-
value = fdtdec_get_uint(blob, node, "spi-rx-bus-width", 1);
switch (value) {
case 1:
break;
case 2:
-   mode_rx |= SPI_RX_DUAL;
+   mode |= SPI_RX_DUAL;
break;
case 4:
-   mode_rx |= SPI_RX_QUAD;
+   mode |= SPI_RX_QUAD;
break;
default:
error("spi-rx-bus-width %d not supported\n", value);
break;
}
 
-   plat->mode_rx = mode_rx;
+   plat->mode = mode;
 
return 0;
 }
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index e69ec0d..de687d1 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -338,7 +338,7 @@ static void ti_spi_setup_spi_register(struct ti_qspi_priv 
*priv)
QSPI_SETUP0_NUM_D_BYTES_8_BITS |
QSPI_SETUP0_READ_QUAD | QSPI_CMD_WRITE |
QSPI_NUM_DUMMY_BITS);
-   slave->mode_rx = SPI_RX_QUAD;
+   slave->mode |= SPI_RX_QUAD;
 #else
memval |= QSPI_CMD_READ | QSPI_SETUP0_NUM_A_BYTES |
QSPI_SETUP0_NUM_D_BYTES_NO_BITS |
@@ -422,7 +422,7 @@ static void __ti_qspi_setup_memorymap(struct ti_qspi_priv 
*priv,
  bool enable)
 {
u32 memval;
-   u32 mode = slave->mode_rx & (SPI_RX_QUAD | SPI_RX_DUAL);
+   u32 mode = slave->mode & (SPI_RX_QUAD | SPI_RX_DUAL);
 
if (!enable) {
writel(0, &priv->base->setup0);
@@ -436,7 +436,7 @@ static void __ti_qspi_setup_memorymap(struct ti_qspi_priv 
*priv,
memval |= QSPI_CMD_READ_QUAD;
memval |= QSPI_SETUP0_NUM_D_BYTES_8_BITS;
memval |= QSPI_SETUP0_READ_QUAD;
-   slave->mode_r

[U-Boot] [PATCH v7 69/87] spi: Drop SPI_RX_FAST

2016-03-22 Thread Jagan Teki
SPI_RX_FAST at spi layer used for spi-nor core to find
the fastest read mode, but this handling is taking care
at m25p80 hence removed the same at spi layer level.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 include/spi.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/spi.h b/include/spi.h
index 61fefa4..9af2fbb 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -27,9 +27,8 @@
 #define SPI_TX_DUALBIT(9)  /* transmit with 2 wires */
 #define SPI_TX_QUADBIT(10) /* transmit with 4 wires */
 #define SPI_RX_SLOWBIT(11) /* receive with 1 wire slow */
-#define SPI_RX_FASTBIT(12) /* receive with 1 wire fast */
-#define SPI_RX_DUALBIT(13) /* receive with 2 wires */
-#define SPI_RX_QUADBIT(14) /* receive with 4 wires */
+#define SPI_RX_DUALBIT(12) /* receive with 2 wires */
+#define SPI_RX_QUADBIT(13) /* receive with 4 wires */
 
 /* SPI bus connection options - see enum spi_dual_flash */
 #define SPI_CONN_DUAL_SHARED   (1 << 0)
-- 
1.9.1

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


[U-Boot] [PATCH v7 61/87] configs: Use CONFIG_SPI_NOR_BAR

2016-03-22 Thread Jagan Teki
- CONFIG_SPI_FLASH_BAR
+ CONFIG_SPI_NOR_BAR

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 configs/alt_defconfig   |  2 +-
 configs/am437x_sk_evm_defconfig |  2 +-
 configs/am43xx_evm_defconfig|  2 +-
 configs/am57xx_evm_defconfig|  2 +-
 configs/bg0900_defconfig|  2 +-
 configs/cm_t43_defconfig|  2 +-
 configs/dra72_evm_defconfig |  2 +-
 configs/dra74_evm_defconfig |  2 +-
 configs/dra7xx_evm_defconfig|  2 +-
 configs/ds414_defconfig |  2 +-
 configs/gose_defconfig  |  2 +-
 configs/koelsch_defconfig   |  2 +-
 configs/lager_defconfig |  2 +-
 configs/maxbcm_defconfig|  2 +-
 configs/mx6sxsabreauto_defconfig|  2 +-
 configs/mx6sxsabresd_defconfig  |  2 +-
 configs/porter_defconfig|  2 +-
 configs/silk_defconfig  |  2 +-
 configs/stout_defconfig |  2 +-
 configs/zynq_zc702_defconfig|  2 +-
 configs/zynq_zc706_defconfig|  2 +-
 configs/zynq_zc770_xm010_defconfig  |  2 +-
 configs/zynq_zc770_xm013_defconfig  |  2 +-
 configs/zynq_zed_defconfig  |  2 +-
 doc/SPI/README.ti_qspi_dra_test |  2 +-
 drivers/spi/fsl_qspi.c  | 18 +-
 include/configs/T102xQDS.h  |  2 +-
 include/configs/T102xRDB.h  |  2 +-
 include/configs/T104xRDB.h  |  2 +-
 include/configs/T208xQDS.h  |  2 +-
 include/configs/T208xRDB.h  |  2 +-
 include/configs/gw_ventana.h|  2 +-
 include/configs/km/kmp204x-common.h |  2 +-
 include/configs/ls2080ardb.h|  2 +-
 include/configs/mx6ul_14x14_evk.h   |  2 +-
 include/configs/mx7dsabresd.h   |  2 +-
 include/configs/socfpga_common.h|  4 ++--
 include/linux/mtd/spi-nor.h |  2 +-
 38 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/configs/alt_defconfig b/configs/alt_defconfig
index 72ba038..07428c7 100644
--- a/configs/alt_defconfig
+++ b/configs/alt_defconfig
@@ -19,6 +19,6 @@ CONFIG_TARGET_ALT=y
 CONFIG_SH_SDHI=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/am437x_sk_evm_defconfig b/configs/am437x_sk_evm_defconfig
index 08d006b..456d978 100644
--- a/configs/am437x_sk_evm_defconfig
+++ b/configs/am437x_sk_evm_defconfig
@@ -18,7 +18,7 @@ CONFIG_DM=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SYS_NS16550=y
 CONFIG_TI_QSPI=y
diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index a8b84e4..eccb04a 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -8,7 +8,7 @@ CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SYS_NS16550=y
 CONFIG_TI_QSPI=y
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index 824107c..504a25a 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -17,5 +17,5 @@ CONFIG_DM=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/bg0900_defconfig b/configs/bg0900_defconfig
index 60d2a53..acc2b5e 100644
--- a/configs/bg0900_defconfig
+++ b/configs/bg0900_defconfig
@@ -6,6 +6,6 @@ CONFIG_SPL=y
 CONFIG_CMD_GPIO=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/cm_t43_defconfig b/configs/cm_t43_defconfig
index 7f4b247..ae79cdf 100644
--- a/configs/cm_t43_defconfig
+++ b/configs/cm_t43_defconfig
@@ -15,7 +15,7 @@ CONFIG_OF_LIBFDT=y
 CONFIG_DM_SERIAL=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_SST=y
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/dra72_evm_defconfig b/configs/dra72_evm_defconfig
index 4b9ced4..24dd7fb 100644
--- a/configs/dra72_evm_defconfig
+++ b/configs/dra72_evm_defconfig
@@ -18,7 +18,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_DM=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SYS_NS16550=y
 CONFIG_TI_QSPI=y
diff --git a/configs/dra74_evm_defconfig b/configs/dra74_evm_defconfig
index 9c7773a..743a2aa 100644
--- a/configs/dra74_evm_defconfig
+++ b/configs/dra74_evm_defconfig
@@ -17,7 +17,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_DM=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
-CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_NOR_BAR=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SYS_NS16550=y
 CONFIG_TI_QSPI=y
diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 0c22f7f..e82c264 100644

[U-Boot] [PATCH v7 70/87] MAINTAINERS: Add myself as SPI NOR maintainer

2016-03-22 Thread Jagan Teki
Cc: Simon Glass 
Cc: Bin Meng 
Signed-off-by: Jagan Teki 
---
 MAINTAINERS | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3a9c205..c46d54d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -393,7 +393,15 @@ M: Jagan Teki 
 S: Maintained
 T: git git://git.denx.de/u-boot-spi.git
 F: drivers/spi/
-F: include/spi*
+F: include/spi.h
+
+SPI NOR
+M: Jagan Teki 
+S: Maintained
+T: git git://git.denx.de/u-boot-spi.git
+F: drivers/mtd/spi-nor/
+F: include/spi_flash.h
+F: include/linux/mtd/spi-nor.h
 
 TQ GROUP
 #M:Martin Krause 
-- 
1.9.1

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


[U-Boot] [PATCH v7 71/87] configs: CONFIG_MTD_SPI_NOR_USE_4K_SECTORS

2016-03-22 Thread Jagan Teki
- CONFIG_SPI_FLASH_USE_4K_SECTORS
+ CONFIG_MTD_SPI_NOR_USE_4K_SECTORS

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 configs/socfpga_arria5_defconfig   | 2 +-
 configs/socfpga_cyclone5_defconfig | 2 +-
 configs/socfpga_sockit_defconfig   | 2 +-
 configs/socfpga_sr1500_defconfig   | 2 +-
 configs/tseries_spi_defconfig  | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/configs/socfpga_arria5_defconfig b/configs/socfpga_arria5_defconfig
index 4b932fb..813495e 100644
--- a/configs/socfpga_arria5_defconfig
+++ b/configs/socfpga_arria5_defconfig
@@ -19,7 +19,7 @@ CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_SPANSION=y
 CONFIG_SPI_NOR_STMICRO=y
-# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/socfpga_cyclone5_defconfig 
b/configs/socfpga_cyclone5_defconfig
index 4dea413..0b69490 100644
--- a/configs/socfpga_cyclone5_defconfig
+++ b/configs/socfpga_cyclone5_defconfig
@@ -19,7 +19,7 @@ CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_SPANSION=y
 CONFIG_SPI_NOR_STMICRO=y
-# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/socfpga_sockit_defconfig b/configs/socfpga_sockit_defconfig
index 715428b..e76f478 100644
--- a/configs/socfpga_sockit_defconfig
+++ b/configs/socfpga_sockit_defconfig
@@ -19,7 +19,7 @@ CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_SPANSION=y
 CONFIG_SPI_NOR_STMICRO=y
-# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/socfpga_sr1500_defconfig b/configs/socfpga_sr1500_defconfig
index 28099bf..f530876 100644
--- a/configs/socfpga_sr1500_defconfig
+++ b/configs/socfpga_sr1500_defconfig
@@ -17,7 +17,7 @@ CONFIG_DM_MMC=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_STMICRO=y
-# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/tseries_spi_defconfig b/configs/tseries_spi_defconfig
index e2d5c5e..5f06b90 100644
--- a/configs/tseries_spi_defconfig
+++ b/configs/tseries_spi_defconfig
@@ -28,7 +28,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_STMICRO=y
-# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_SYS_NS16550=y
 CONFIG_OF_LIBFDT=y
 CONFIG_USB=y
-- 
1.9.1

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


[U-Boot] [PATCH v7 74/87] mtd: spi-nor: Add erase ops

2016-03-22 Thread Jagan Teki
Added spi_nor erase ops for m25p80.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c  | 27 +++
 drivers/mtd/spi-nor/spi-nor.c |  2 +-
 include/linux/mtd/spi-nor.h   |  4 +++-
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index bf9fe02..cf27ba0 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -166,6 +166,32 @@ static int m25p80_write(struct spi_nor *nor, const u8 
*cmd, size_t cmd_len,
return ret;
 }
 
+static int m25p80_erase(struct spi_nor *nor, const u8 *cmd, size_t cmd_len)
+{
+   struct m25p *flash = nor->priv;
+   struct spi_slave *spi = flash->spi;
+   int ret;
+
+   ret = spi_claim_bus(spi);
+   if (ret < 0) {
+   debug("m25p80: unable to claim SPI bus\n");
+   return ret;
+   }
+
+   if (nor->flags & SNOR_F_U_PAGE)
+   spi->flags |= SPI_XFER_U_PAGE;
+
+   ret = spi_write_then_read(spi, cmd, cmd_len, NULL, NULL, 0);
+   if (ret < 0) {
+   debug("m25p80: error %d writing %x\n", ret, *cmd);
+   return ret;
+   }
+
+   spi_release_bus(spi);
+
+   return ret;
+}
+
 static int m25p80_spi_nor(struct spi_nor *nor)
 {
struct mtd_info *mtd = nor->mtd;
@@ -176,6 +202,7 @@ static int m25p80_spi_nor(struct spi_nor *nor)
/* install hooks */
nor->read_mmap = m25p80_read_mmap;
nor->read = m25p80_read;
+   nor->erase = m25p80_erase;
nor->write = m25p80_write;
nor->read_reg = m25p80_read_reg;
nor->write_reg = m25p80_write_reg;
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 1ee1510..befee67 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -526,7 +526,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct 
erase_info *instr)
 
write_enable(nor);
 
-   ret = nor->write(nor, cmd, sizeof(cmd), NULL, 0);
+   ret = nor->erase(nor, cmd, sizeof(cmd));
if (ret < 0)
goto erase_err;
 
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 8b46b93..4749ff4 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -191,7 +191,8 @@ extern const struct spi_nor_info spi_nor_ids[];
  * @read_mmap: [DRIVER-SPECIFIC] read data from the mmapped SPI NOR
  * @read:  [DRIVER-SPECIFIC] read data from the SPI NOR
  * @write: [DRIVER-SPECIFIC] write data to the SPI NOR
- * @flash_lock:[FLASH-SPECIFIC] lock a region of the SPI NOR
+ * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR
+ * @flash_lock:[FLASH-SPECIFIC] unlock a region of the SPI NOR
  * @flash_unlock:  [FLASH-SPECIFIC] unlock a region of the SPI NOR
  * @flash_is_locked:   [FLASH-SPECIFIC] check if a region of the SPI NOR is
  * @memory_map:address of read-only SPI NOR access
@@ -227,6 +228,7 @@ struct spi_nor {
void *data, size_t data_len);
int (*write)(struct spi_nor *nor, const u8 *cmd, size_t cmd_len,
const void *data, size_t data_len);
+   int (*erase)(struct spi_nor *nor, const u8 *cmd, size_t cmd_len);
 
int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
-- 
1.9.1

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


[U-Boot] [PATCH v7 73/87] dts: spi-nor: Use spi-nor as node name

2016-03-22 Thread Jagan Teki
Use spi-nor flash driver node name as 'spi-nor'
instead of spi-flash

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 arch/arm/dts/armada-388-clearfog.dts  | 2 +-
 arch/arm/dts/armada-388-gp.dts| 2 +-
 arch/arm/dts/armada-xp-gp.dts | 2 +-
 arch/arm/dts/armada-xp-maxbcm.dts | 2 +-
 arch/arm/dts/armada-xp-synology-ds414.dts | 2 +-
 arch/arm/dts/armada-xp-theadorable.dts| 2 +-
 arch/arm/dts/tegra30-beaver.dts   | 2 +-
 arch/x86/dts/bayleybay.dts| 2 +-
 arch/x86/dts/broadwell_som-6896.dts   | 2 +-
 arch/x86/dts/chromebook_link.dts  | 2 +-
 arch/x86/dts/chromebox_panther.dts| 2 +-
 arch/x86/dts/cougarcanyon2.dts| 2 +-
 arch/x86/dts/crownbay.dts | 2 +-
 arch/x86/dts/galileo.dts  | 2 +-
 arch/x86/dts/minnowmax.dts| 2 +-
 15 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/armada-388-clearfog.dts 
b/arch/arm/dts/armada-388-clearfog.dts
index b2dfd56..196ff0e 100644
--- a/arch/arm/dts/armada-388-clearfog.dts
+++ b/arch/arm/dts/armada-388-clearfog.dts
@@ -342,7 +342,7 @@
pinctrl-names = "default";
status = "okay";
 
-   spi-flash@0 {
+   spi-nor@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "w25q32", "jedec,spi-nor";
diff --git a/arch/arm/dts/armada-388-gp.dts b/arch/arm/dts/armada-388-gp.dts
index 7bc878f..c9ff1e0 100644
--- a/arch/arm/dts/armada-388-gp.dts
+++ b/arch/arm/dts/armada-388-gp.dts
@@ -73,7 +73,7 @@
status = "okay";
u-boot,dm-pre-reloc;
 
-   spi-flash@0 {
+   spi-nor@0 {
u-boot,dm-pre-reloc;
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/dts/armada-xp-gp.dts b/arch/arm/dts/armada-xp-gp.dts
index 27799d1..77b6c86 100644
--- a/arch/arm/dts/armada-xp-gp.dts
+++ b/arch/arm/dts/armada-xp-gp.dts
@@ -230,7 +230,7 @@
status = "okay";
u-boot,dm-pre-reloc;
 
-   spi-flash@0 {
+   spi-nor@0 {
u-boot,dm-pre-reloc;
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/dts/armada-xp-maxbcm.dts 
b/arch/arm/dts/armada-xp-maxbcm.dts
index d7d7f65..371346d 100644
--- a/arch/arm/dts/armada-xp-maxbcm.dts
+++ b/arch/arm/dts/armada-xp-maxbcm.dts
@@ -228,7 +228,7 @@
spi0: spi@10600 {
status = "okay";
 
-   spi-flash@0 {
+   spi-nor@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "n25q128a13", 
"jedec,spi-nor";
diff --git a/arch/arm/dts/armada-xp-synology-ds414.dts 
b/arch/arm/dts/armada-xp-synology-ds414.dts
index 0a60ddf..1273bf4 100644
--- a/arch/arm/dts/armada-xp-synology-ds414.dts
+++ b/arch/arm/dts/armada-xp-synology-ds414.dts
@@ -84,7 +84,7 @@
status = "okay";
u-boot,dm-pre-reloc;
 
-   spi-flash@0 {
+   spi-nor@0 {
u-boot,dm-pre-reloc;
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/dts/armada-xp-theadorable.dts 
b/arch/arm/dts/armada-xp-theadorable.dts
index cf1be2a..1ab1a7c 100644
--- a/arch/arm/dts/armada-xp-theadorable.dts
+++ b/arch/arm/dts/armada-xp-theadorable.dts
@@ -129,7 +129,7 @@
status = "okay";
u-boot,dm-pre-reloc;
 
-   spi-flash@0 {
+   spi-nor@0 {
u-boot,dm-pre-reloc;
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/dts/tegra30-beaver.dts b/arch/arm/dts/tegra30-beaver.dts
index ae83636..17af221 100644
--- a/arch/arm/dts/tegra30-beaver.dts
+++ b/arch/arm/dts/tegra30-beaver.dts
@@ -187,7 +187,7 @@
spi@7000da00 {
status = "okay";
spi-max-frequency = <2500>;
-   spi-flash@1 {
+   spi-nor@1 {
   

[U-Boot] [PATCH v7 75/87] mtd: spi-nor: Not required to memset dummy byte

2016-03-22 Thread Jagan Teki
Dummy byte(s) are need to send followed by address opcode
for read operation, and that dummy byte(s) not required
to malloc as well memset.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index befee67..97f5eaa 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -617,7 +617,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, 
size_t len,
 {
struct spi_nor *nor = mtd->priv;
u32 remain_len, read_len, read_addr;
-   u8 *cmd, cmdsz;
+   u8 cmd[SNOR_MAX_CMD_SIZE], cmdsz;
int bank_sel = 0;
int ret = -1;
 
@@ -633,12 +633,6 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, 
size_t len,
}
 
cmdsz = SNOR_MAX_CMD_SIZE + nor->read_dummy;
-   cmd = calloc(1, cmdsz);
-   if (!cmd) {
-   debug("spi-nor: Failed to allocate cmd\n");
-   return -ENOMEM;
-   }
-
cmd[0] = nor->read_opcode;
while (len) {
read_addr = from;
@@ -672,7 +666,6 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, 
size_t len,
*retlen += read_len;
}
 
-   free(cmd);
return ret;
 }
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 76/87] mtd: spi-nor: Move opcode handling in m25p80

2016-03-22 Thread Jagan Teki
It's required to handling opcode in spi drivers
interface layer, m25p80 from spi-nor, becuase some
spi-nor controller drivers like fsl_qspi have separate
opcode's to handling the same operations.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c  | 53 
 drivers/mtd/spi-nor/spi-nor.c | 62 +++
 include/linux/mtd/spi-nor.h   | 10 +++
 3 files changed, 56 insertions(+), 69 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index cf27ba0..560e5b2 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -17,14 +17,24 @@
 #include 
 #include 
 
+#define MAX_CMD_SIZE   6
 struct m25p {
struct spi_slave*spi;
struct spi_nor  spi_nor;
 #ifndef CONFIG_DM_MTD_SPI_NOR
struct mtd_info mtd;
 #endif
+   u8  command[MAX_CMD_SIZE];
 };
 
+static void spi_nor_addr(u32 addr, u8 *cmd)
+{
+   /* cmd[0] is actual command */
+   cmd[1] = addr >> 16;
+   cmd[2] = addr >> 8;
+   cmd[3] = addr >> 0;
+}
+
 static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len)
 {
struct m25p *flash = nor->priv;
@@ -112,8 +122,8 @@ static int m25p80_read_mmap(struct spi_nor *nor, void *data,
return ret;
 }
 
-static int m25p80_read(struct spi_nor *nor, const u8 *cmd, size_t cmd_len,
-   void *data, size_t data_len)
+static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
+  u_char *buf)
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
@@ -125,12 +135,16 @@ static int m25p80_read(struct spi_nor *nor, const u8 
*cmd, size_t cmd_len,
return ret;
}
 
+   flash->command[0] = nor->read_opcode;
+   spi_nor_addr(from, flash->command);
+
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, cmd, cmd_len, NULL, data, data_len);
+   ret = spi_write_then_read(spi, flash->command, 4 + nor->read_dummy,
+ NULL, buf, len);
if (ret < 0) {
-   debug("m25p80: error %d reading %x\n", ret, *cmd);
+   debug("m25p80: error %d reading %x\n", ret, flash->command[0]);
return ret;
}
 
@@ -139,11 +153,12 @@ static int m25p80_read(struct spi_nor *nor, const u8 
*cmd, size_t cmd_len,
return ret;
 }
 
-static int m25p80_write(struct spi_nor *nor, const u8 *cmd, size_t cmd_len,
-   const void *data, size_t data_len)
+static int m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
+   const u_char *buf)
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
+   int cmd_sz = 4;
int ret;
 
ret = spi_claim_bus(spi);
@@ -152,12 +167,22 @@ static int m25p80_write(struct spi_nor *nor, const u8 
*cmd, size_t cmd_len,
return ret;
}
 
+   if (nor->program_opcode == SNOR_OP_AAI_WP)
+   cmd_sz = 1;
+
+   flash->command[0] = nor->program_opcode;
+   spi_nor_addr(to, flash->command);
+
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, cmd, cmd_len, data, NULL, data_len);
+   debug("m25p80: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = 
%zu\n",
+  buf, flash->command[0], flash->command[1], flash->command[2],
+  flash->command[3], len);
+
+   ret = spi_write_then_read(spi, flash->command, cmd_sz, buf, NULL, len);
if (ret < 0) {
-   debug("m25p80: error %d writing %x\n", ret, *cmd);
+   debug("m25p80: error %d writing %x\n", ret, flash->command[0]);
return ret;
}
 
@@ -166,7 +191,7 @@ static int m25p80_write(struct spi_nor *nor, const u8 *cmd, 
size_t cmd_len,
return ret;
 }
 
-static int m25p80_erase(struct spi_nor *nor, const u8 *cmd, size_t cmd_len)
+static int m25p80_erase(struct spi_nor *nor, loff_t offset)
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
@@ -178,12 +203,18 @@ static int m25p80_erase(struct spi_nor *nor, const u8 
*cmd, size_t cmd_len)
return ret;
}
 
+   flash->command[0] = nor->erase_opcode;
+   spi_nor_addr(offset, flash->command);
+
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, cmd, cmd_len, NULL, NULL, 0);
+   debug("m25p80: erase %2x %2x %2x %2x (%llx)\n", flash->command[0],
+  flash->command[1], flash->command[2], flash->command[3], offset);
+
+   ret = spi_write_then_read(spi, flash->command, 4, NULL, N

[U-Boot] [PATCH v7 77/87] mtd: spi-nor: Rename spi_nor_addr to m25p_addr2cmd

2016-03-22 Thread Jagan Teki
opcode handling is part of spi_nor_addr routine, since
it's been part of m25p80 so rename the function related
to that file name.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 560e5b2..a6e9cfe 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -27,7 +27,7 @@ struct m25p {
u8  command[MAX_CMD_SIZE];
 };
 
-static void spi_nor_addr(u32 addr, u8 *cmd)
+static void m25p_addr2cmd(u32 addr, u8 *cmd)
 {
/* cmd[0] is actual command */
cmd[1] = addr >> 16;
@@ -136,7 +136,7 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, 
size_t len,
}
 
flash->command[0] = nor->read_opcode;
-   spi_nor_addr(from, flash->command);
+   m25p_addr2cmd(from, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
@@ -171,7 +171,7 @@ static int m25p80_write(struct spi_nor *nor, loff_t to, 
size_t len,
cmd_sz = 1;
 
flash->command[0] = nor->program_opcode;
-   spi_nor_addr(to, flash->command);
+   m25p_addr2cmd(to, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
@@ -204,7 +204,7 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
}
 
flash->command[0] = nor->erase_opcode;
-   spi_nor_addr(offset, flash->command);
+   m25p_addr2cmd(offset, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
-- 
1.9.1

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


[U-Boot] [PATCH v7 79/87] mtd: spi-nor: Add m25p_cmdsz

2016-03-22 Thread Jagan Teki
Added m25p_cmdsz for finding command size based on
the addr_width.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 266407f..42c5a96 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -36,6 +36,11 @@ static void m25p_addr2cmd(struct spi_nor *nor, unsigned int 
addr, u8 *cmd)
cmd[4] = addr >> (nor->addr_width * 8 - 32);
 }
 
+static int m25p_cmdsz(struct spi_nor *nor)
+{
+   return 1 + nor->addr_width;
+}
+
 static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len)
 {
struct m25p *flash = nor->priv;
@@ -142,8 +147,9 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, 
size_t len,
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, flash->command, 4 + nor->read_dummy,
- NULL, buf, len);
+   ret = spi_write_then_read(spi, flash->command,
+ m25p_cmdsz(nor) + nor->read_dummy, NULL,
+ buf, len);
if (ret < 0) {
debug("m25p80: error %d reading %x\n", ret, flash->command[0]);
return ret;
@@ -159,7 +165,7 @@ static int m25p80_write(struct spi_nor *nor, loff_t to, 
size_t len,
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
-   int cmd_sz = 4;
+   int cmd_sz = m25p_cmdsz(nor);
int ret;
 
ret = spi_claim_bus(spi);
@@ -213,7 +219,8 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
debug("m25p80: erase %2x %2x %2x %2x (%llx)\n", flash->command[0],
   flash->command[1], flash->command[2], flash->command[3], offset);
 
-   ret = spi_write_then_read(spi, flash->command, 4, NULL, NULL, 0);
+   ret = spi_write_then_read(spi, flash->command, m25p_cmdsz(nor),
+ NULL, NULL, 0);
if (ret < 0) {
debug("m25p80: error %d writing %x\n", ret, flash->command[0]);
return ret;
-- 
1.9.1

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


[U-Boot] [PATCH v7 78/87] mtd: spi-nor: Add addr_width

2016-03-22 Thread Jagan Teki
addr_width is required to configure the flash
with 3 and 4 byte addressing, more features
will add in future patches.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c  | 17 +
 drivers/mtd/spi-nor/spi-nor.c |  5 +
 include/linux/mtd/spi-nor.h   |  2 ++
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index a6e9cfe..266407f 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -27,12 +27,13 @@ struct m25p {
u8  command[MAX_CMD_SIZE];
 };
 
-static void m25p_addr2cmd(u32 addr, u8 *cmd)
+static void m25p_addr2cmd(struct spi_nor *nor, unsigned int addr, u8 *cmd)
 {
-   /* cmd[0] is actual command */
-   cmd[1] = addr >> 16;
-   cmd[2] = addr >> 8;
-   cmd[3] = addr >> 0;
+   /* opcode is in cmd[0] */
+   cmd[1] = addr >> (nor->addr_width * 8 -  8);
+   cmd[2] = addr >> (nor->addr_width * 8 - 16);
+   cmd[3] = addr >> (nor->addr_width * 8 - 24);
+   cmd[4] = addr >> (nor->addr_width * 8 - 32);
 }
 
 static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len)
@@ -136,7 +137,7 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, 
size_t len,
}
 
flash->command[0] = nor->read_opcode;
-   m25p_addr2cmd(from, flash->command);
+   m25p_addr2cmd(nor, from, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
@@ -171,7 +172,7 @@ static int m25p80_write(struct spi_nor *nor, loff_t to, 
size_t len,
cmd_sz = 1;
 
flash->command[0] = nor->program_opcode;
-   m25p_addr2cmd(to, flash->command);
+   m25p_addr2cmd(nor, to, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
@@ -204,7 +205,7 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset)
}
 
flash->command[0] = nor->erase_opcode;
-   m25p_addr2cmd(offset, flash->command);
+   m25p_addr2cmd(nor, offset, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index cb9ab21..0b3140d 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1032,6 +1032,11 @@ int spi_nor_scan(struct spi_nor *nor)
}
}
 
+   if (info->addr_width)
+   nor->addr_width = info->addr_width;
+   else
+   nor->addr_width = 3;
+
/* read_dummy: dummy byte is determined based on the
 * dummy cycles of a particular command.
 * Fast commands - read_dummy = dummy_cycles/8
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 19a5dd0..b144341 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -171,6 +171,7 @@ extern const struct spi_nor_info spi_nor_ids[];
  * @mtd:   point to a mtd_info structure
  * @name:  name of the SPI NOR device
  * @page_size: the page size of the SPI NOR
+ * @addr_width:number of address bytes
  * @erase_opcode:  the opcode for erasing a sector
  * @read_opcode:   the read opcode
  * @read_dummy:the dummy bytes needed by the read operation
@@ -202,6 +203,7 @@ struct spi_nor {
struct mtd_info *mtd;
const char  *name;
u32 page_size;
+   u8  addr_width;
u8  erase_opcode;
u8  read_opcode;
u8  read_dummy;
-- 
1.9.1

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


[U-Boot] [PATCH v7 80/87] mtd: spi-nor: read_dummy refers to dummy cycles not bytes

2016-03-22 Thread Jagan Teki
read_dummy refered as dummy cycles and dummy bytes
will findout during read operations.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c  | 9 ++---
 drivers/mtd/spi-nor/spi-nor.c | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 42c5a96..c65534c 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -133,6 +133,7 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, 
size_t len,
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
+   unsigned int dummy = nor->read_dummy;
int ret;
 
ret = spi_claim_bus(spi);
@@ -141,15 +142,17 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, 
size_t len,
return ret;
}
 
+   /* convert the dummy cycles to the number of bytes */
+   dummy /= 8;
+
flash->command[0] = nor->read_opcode;
m25p_addr2cmd(nor, from, flash->command);
 
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, flash->command,
- m25p_cmdsz(nor) + nor->read_dummy, NULL,
- buf, len);
+   ret = spi_write_then_read(spi, flash->command, m25p_cmdsz(nor) + dummy,
+ NULL, buf, len);
if (ret < 0) {
debug("m25p80: error %d reading %x\n", ret, flash->command[0]);
return ret;
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 0b3140d..fb7fb1c 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1047,13 +1047,13 @@ int spi_nor_scan(struct spi_nor *nor)
 */
switch (nor->read_opcode) {
case SNOR_OP_READ_1_1_4_IO:
-   nor->read_dummy = 2;
+   nor->read_dummy = 16;
break;
case SNOR_OP_READ:
nor->read_dummy = 0;
break;
default:
-   nor->read_dummy = 1;
+   nor->read_dummy = 8;
}
 
/* Configure the BAR - discover bank cmds and read current bank */
-- 
1.9.1

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


[U-Boot] [PATCH v7 82/87] mtd: spi-nor: offset with addr

2016-03-22 Thread Jagan Teki
For more readability use addr instead of offset.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 36dfe77..6166b62 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -642,8 +642,8 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, 
size_t len,
 }
 
 #ifdef CONFIG_SPI_NOR_SST
-static int sst_byte_write(struct spi_nor *nor, u32 offset,
- const void *buf, size_t *retlen)
+static int sst_byte_write(struct spi_nor *nor, u32 addr, const void *buf,
+ size_t *retlen)
 {
int ret;
 
@@ -653,7 +653,7 @@ static int sst_byte_write(struct spi_nor *nor, u32 offset,
 
nor->program_opcode = SNOR_OP_BP;
 
-   ret = nor->write(nor, offset, 1, buf);
+   ret = nor->write(nor, addr, 1, buf);
if (ret)
return ret;
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 81/87] mtd: spi-nor: Use to instead of offset in write

2016-03-22 Thread Jagan Teki
Used write operation address variable as 'to' instead
of 'offset' for more readability.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/spi-nor.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index fb7fb1c..36dfe77 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -535,7 +535,7 @@ erase_err:
return ret;
 }
 
-static int spi_nor_write(struct mtd_info *mtd, loff_t offset, size_t len,
+static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 size_t *retlen, const u_char *buf)
 {
struct spi_nor *nor = mtd->priv;
@@ -544,9 +544,9 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t 
offset, size_t len,
int ret = -1;
 
if (mtd->_is_locked) {
-   if (mtd->_is_locked(mtd, offset, len) > 0) {
+   if (mtd->_is_locked(mtd, to, len) > 0) {
printf("offset 0x%llx is protected and cannot be 
written\n",
-  offset);
+  to);
return -EINVAL;
}
}
@@ -554,7 +554,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t 
offset, size_t len,
page_size = nor->page_size;
 
for (actual = 0; actual < len; actual += chunk_len) {
-   write_addr = offset;
+   write_addr = to;
 
 #ifdef CONFIG_SF_DUAL_FLASH
if (nor->dual > SNOR_DUAL_SINGLE)
@@ -565,7 +565,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t 
offset, size_t len,
if (ret < 0)
return ret;
 #endif
-   byte_addr = offset % page_size;
+   byte_addr = to % page_size;
chunk_len = min(len - actual, (size_t)(page_size - byte_addr));
 
if (nor->max_write_size)
@@ -582,7 +582,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t 
offset, size_t len,
if (ret < 0)
return ret;
 
-   offset += chunk_len;
+   to += chunk_len;
*retlen += chunk_len;
}
 
@@ -662,7 +662,7 @@ static int sst_byte_write(struct spi_nor *nor, u32 offset,
return spi_nor_wait_till_ready(nor, SNOR_READY_WAIT_PROG);
 }
 
-static int sst_write_wp(struct mtd_info *mtd, loff_t offset, size_t len,
+static int sst_write_wp(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
 {
struct spi_nor *nor = mtd->priv;
@@ -670,13 +670,13 @@ static int sst_write_wp(struct mtd_info *mtd, loff_t 
offset, size_t len,
int ret;
 
/* If the data is not word aligned, write out leading single byte */
-   actual = offset % 2;
+   actual = to % 2;
if (actual) {
-   ret = sst_byte_write(nor, offset, buf, retlen);
+   ret = sst_byte_write(nor, to, buf, retlen);
if (ret)
goto done;
}
-   offset += actual;
+   to += actual;
 
ret = write_enable(nor);
if (ret)
@@ -685,7 +685,7 @@ static int sst_write_wp(struct mtd_info *mtd, loff_t 
offset, size_t len,
for (; actual < len - 1; actual += 2) {
nor->program_opcode = SNOR_OP_AAI_WP;
 
-   ret = nor->write(nor, offset, 2, buf + actual);
+   ret = nor->write(nor, to, 2, buf + actual);
if (ret) {
debug("spi-nor: sst word program failed\n");
break;
@@ -695,7 +695,7 @@ static int sst_write_wp(struct mtd_info *mtd, loff_t 
offset, size_t len,
if (ret)
break;
 
-   offset += 2;
+   to += 2;
*retlen += 2;
}
 
@@ -704,13 +704,13 @@ static int sst_write_wp(struct mtd_info *mtd, loff_t 
offset, size_t len,
 
/* If there is a single trailing byte, write it out */
if (!ret && actual != len)
-   ret = sst_byte_write(nor, offset, buf + actual, retlen);
+   ret = sst_byte_write(nor, to, buf + actual, retlen);
 
  done:
return ret;
 }
 
-static int sst_write_bp(struct mtd_info *mtd, loff_t offset, size_t len,
+static int sst_write_bp(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
 {
struct spi_nor *nor = mtd->priv;
@@ -718,12 +718,12 @@ static int sst_write_bp(struct mtd_info *mtd, loff_t 
offset, size_t len,
int ret;
 
for (actual = 0; actual < len; actual++) {
-   ret = sst_byte_write(nor, offset, buf + actual, retlen);
+   ret = sst_byte_write(nor, to, buf + actual, retlen);
if (ret) {
debug("spi-nor: sst byte progr

[U-Boot] [PATCH v7 72/87] dts: spi-nor: Use jedec, spi-nor compatible string

2016-03-22 Thread Jagan Teki
Use spi-nor flash driver compatible string as 'jedec,spi-nor'
instead of spi-flash

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 arch/arm/dts/am437x-sk-evm.dts   | 2 +-
 arch/arm/dts/dra7-evm.dts| 2 +-
 arch/arm/dts/dra72-evm.dts   | 2 +-
 arch/arm/dts/exynos5250-snow.dts | 2 +-
 arch/arm/dts/exynos5250-spring.dts   | 2 +-
 arch/arm/dts/exynos5420-peach-pit.dts| 2 +-
 arch/arm/dts/fsl-ls1043a-qds.dtsi| 8 
 arch/arm/dts/fsl-ls1043a-rdb.dts | 2 +-
 arch/arm/dts/fsl-ls2080a-qds.dts | 6 +++---
 arch/arm/dts/fsl-ls2080a-rdb.dts | 2 +-
 arch/arm/dts/ls1021a-qds.dtsi| 2 +-
 arch/arm/dts/ls1021a-twr.dtsi| 4 ++--
 arch/arm/dts/rk3288-veyron.dtsi  | 2 +-
 arch/arm/dts/socfpga_cyclone5_sockit.dts | 2 +-
 arch/arm/dts/socfpga_cyclone5_sr1500.dts | 2 +-
 arch/arm/dts/stv0991.dts | 2 +-
 arch/arm/dts/zynq-zc770-xm010.dts| 2 +-
 arch/x86/dts/bayleybay.dts   | 2 +-
 arch/x86/dts/broadwell_som-6896.dts  | 2 +-
 arch/x86/dts/chromebook_link.dts | 2 +-
 arch/x86/dts/chromebox_panther.dts   | 2 +-
 arch/x86/dts/cougarcanyon2.dts   | 2 +-
 arch/x86/dts/crownbay.dts| 2 +-
 arch/x86/dts/galileo.dts | 2 +-
 arch/x86/dts/minnowmax.dts   | 2 +-
 25 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/arch/arm/dts/am437x-sk-evm.dts b/arch/arm/dts/am437x-sk-evm.dts
index 260edb9..8879a66 100644
--- a/arch/arm/dts/am437x-sk-evm.dts
+++ b/arch/arm/dts/am437x-sk-evm.dts
@@ -568,7 +568,7 @@
 
spi-max-frequency = <4800>;
m25p80@0 {
-   compatible = "mx66l51235l","spi-flash";
+   compatible = "mx66l51235l","jedec,spi-nor";
spi-max-frequency = <4800>;
reg = <0>;
spi-cpol;
diff --git a/arch/arm/dts/dra7-evm.dts b/arch/arm/dts/dra7-evm.dts
index 242fd53..225e4f7 100644
--- a/arch/arm/dts/dra7-evm.dts
+++ b/arch/arm/dts/dra7-evm.dts
@@ -488,7 +488,7 @@
 
spi-max-frequency = <4800>;
m25p80@0 {
-   compatible = "s25fl256s1","spi-flash";
+   compatible = "s25fl256s1","jedec,spi-nor";
spi-max-frequency = <4800>;
reg = <0>;
spi-tx-bus-width = <1>;
diff --git a/arch/arm/dts/dra72-evm.dts b/arch/arm/dts/dra72-evm.dts
index fc2d167..0f91d50 100644
--- a/arch/arm/dts/dra72-evm.dts
+++ b/arch/arm/dts/dra72-evm.dts
@@ -605,7 +605,7 @@
 
spi-max-frequency = <4800>;
m25p80@0 {
-   compatible = "s25fl256s1","spi-flash";
+   compatible = "s25fl256s1","jedec,spi-nor";
spi-max-frequency = <4800>;
reg = <0>;
spi-tx-bus-width = <1>;
diff --git a/arch/arm/dts/exynos5250-snow.dts b/arch/arm/dts/exynos5250-snow.dts
index bda5499..e6c200c 100644
--- a/arch/arm/dts/exynos5250-snow.dts
+++ b/arch/arm/dts/exynos5250-snow.dts
@@ -218,7 +218,7 @@
spi@12d3 {
spi-max-frequency = <5000>;
firmware_storage_spi: flash@0 {
-   compatible = "spi-flash";
+   compatible = "jedec,spi-nor";
reg = <0>;
};
};
diff --git a/arch/arm/dts/exynos5250-spring.dts 
b/arch/arm/dts/exynos5250-spring.dts
index 81b3d29..acb64dc 100644
--- a/arch/arm/dts/exynos5250-spring.dts
+++ b/arch/arm/dts/exynos5250-spring.dts
@@ -98,7 +98,7 @@
spi@12d3 {
spi-max-frequency = <5000>;
firmware_storage_spi: flash@0 {
-   compatible = "spi-flash";
+   compatible = "jedec,spi-nor";
reg = <0>;
};
};
diff --git a/arch/arm/dts/exynos5420-peach-pit.dts 
b/arch/arm/dts/exynos5420-peach-pit.dts
index 16d52f4..f217468 100644
--- a/arch/arm/dts/exynos5420-peach-pit.dts
+++ b/arch/arm/dts/exynos5420-peach-pit.dts
@@ -206,7 +206,7 @@
spi@12d3 { /* spi1 */
spi-max-frequency = <5000>;
firmware_storage_spi: flash@0 {
-   compatible = "spi-flash";
+   compatible = "jedec,spi-nor";
reg = <0>;
 
/*
diff --git a/arch/arm/dts/fsl-ls1043a-qds.dtsi 
b/arch/arm/dts/fsl-ls1043a-qds.dtsi
index 66efe67..59f3669 100644
--- a/arch/arm/dts/fsl-ls1043a-qds.dtsi
+++ b/arch/arm/dts/fsl-ls1043a-qds.dtsi
@@ -27,7 +27,7 @@
dflash0: n25q128a {
#address-cells = <1>;
#size-cells = <1>;
-   compatible = "spi-flash";
+   compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <100>; /* input clock */
};
@@ -35,7 +35,7 @@
dflash1: 

[U-Boot] [PATCH v7 83/87] mtd: m25p80: Rename cmd with opcode

2016-03-22 Thread Jagan Teki
Use opcode instead of cmd, for more readability.

Cc: Simon Glass 
Cc: Bin Meng 
Cc: Mugunthan V N 
Cc: Michal Simek 
Cc: Siva Durga Prasad Paladugu 
Signed-off-by: Jagan Teki 
---
 drivers/mtd/spi-nor/m25p80.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index c65534c..bdf54be 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -41,7 +41,7 @@ static int m25p_cmdsz(struct spi_nor *nor)
return 1 + nor->addr_width;
 }
 
-static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 *val, int len)
+static int m25p80_read_reg(struct spi_nor *nor, u8 opcode, u8 *val, int len)
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
@@ -56,9 +56,9 @@ static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 
*val, int len)
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, &cmd, 1, NULL, val, len);
+   ret = spi_write_then_read(spi, &opcode, 1, NULL, val, len);
if (ret < 0) {
-   debug("m25p80: error %d reading register %x\n", ret, cmd);
+   debug("m25p80: error %d reading register %x\n", ret, opcode);
return ret;
}
 
@@ -67,7 +67,7 @@ static int m25p80_read_reg(struct spi_nor *nor, u8 cmd, u8 
*val, int len)
return ret;
 }
 
-static int m25p80_write_reg(struct spi_nor *nor, u8 cmd, u8 *buf, int len)
+static int m25p80_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len)
 {
struct m25p *flash = nor->priv;
struct spi_slave *spi = flash->spi;
@@ -82,9 +82,9 @@ static int m25p80_write_reg(struct spi_nor *nor, u8 cmd, u8 
*buf, int len)
if (nor->flags & SNOR_F_U_PAGE)
spi->flags |= SPI_XFER_U_PAGE;
 
-   ret = spi_write_then_read(spi, &cmd, 1, buf, NULL, len);
+   ret = spi_write_then_read(spi, &opcode, 1, buf, NULL, len);
if (ret < 0) {
-   debug("m25p80: error %d writing register %x\n", ret, cmd);
+   debug("m25p80: error %d writing register %x\n", ret, opcode);
return ret;
}
 
-- 
1.9.1

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


[U-Boot] [PATCH v7 84/87] armv8/ls1043a: move CONFIG_MTD to defconfig

2016-03-22 Thread Jagan Teki
To make it take effect to enable MTD driver model for SPI-NOR.

Cc: York Sun 
Signed-off-by: Gong Qianyu 
Signed-off-by: Jagan Teki 
---
 configs/ls1043aqds_defconfig | 1 +
 configs/ls1043aqds_lpuart_defconfig  | 1 +
 configs/ls1043aqds_nand_defconfig| 1 +
 configs/ls1043aqds_nor_ddr3_defconfig| 1 +
 configs/ls1043aqds_qspi_defconfig| 1 +
 configs/ls1043aqds_sdcard_ifc_defconfig  | 1 +
 configs/ls1043aqds_sdcard_qspi_defconfig | 1 +
 configs/ls1043ardb_SECURE_BOOT_defconfig | 1 +
 configs/ls1043ardb_defconfig | 1 +
 configs/ls1043ardb_nand_defconfig| 1 +
 configs/ls1043ardb_sdcard_defconfig  | 1 +
 include/configs/ls1043a_common.h | 1 -
 12 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/configs/ls1043aqds_defconfig b/configs/ls1043aqds_defconfig
index cde7708..361480a 100644
--- a/configs/ls1043aqds_defconfig
+++ b/configs/ls1043aqds_defconfig
@@ -11,3 +11,4 @@ CONFIG_DM=y
 CONFIG_SYS_NS16550=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD=y
diff --git a/configs/ls1043aqds_lpuart_defconfig 
b/configs/ls1043aqds_lpuart_defconfig
index 5e000bd..da5315b 100644
--- a/configs/ls1043aqds_lpuart_defconfig
+++ b/configs/ls1043aqds_lpuart_defconfig
@@ -9,6 +9,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4,LPUART"
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_FSL_LPUART=y
diff --git a/configs/ls1043aqds_nand_defconfig 
b/configs/ls1043aqds_nand_defconfig
index 46990c6..cc48f6f 100644
--- a/configs/ls1043aqds_nand_defconfig
+++ b/configs/ls1043aqds_nand_defconfig
@@ -9,6 +9,7 @@ CONFIG_SYS_NS16550=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1043a-qds-duart"
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_DM_SPI=y
diff --git a/configs/ls1043aqds_nor_ddr3_defconfig 
b/configs/ls1043aqds_nor_ddr3_defconfig
index b18..083667d 100644
--- a/configs/ls1043aqds_nor_ddr3_defconfig
+++ b/configs/ls1043aqds_nor_ddr3_defconfig
@@ -7,6 +7,7 @@ CONFIG_SYS_NS16550=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1043a-qds-duart"
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_DM_SPI=y
diff --git a/configs/ls1043aqds_qspi_defconfig 
b/configs/ls1043aqds_qspi_defconfig
index 01c8045..35bc65b 100644
--- a/configs/ls1043aqds_qspi_defconfig
+++ b/configs/ls1043aqds_qspi_defconfig
@@ -8,6 +8,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_DM_SPI=y
diff --git a/configs/ls1043aqds_sdcard_ifc_defconfig 
b/configs/ls1043aqds_sdcard_ifc_defconfig
index 9e8cac1..0df5863 100644
--- a/configs/ls1043aqds_sdcard_ifc_defconfig
+++ b/configs/ls1043aqds_sdcard_ifc_defconfig
@@ -9,6 +9,7 @@ CONFIG_SYS_NS16550=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1043a-qds-duart"
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_DM_SPI=y
diff --git a/configs/ls1043aqds_sdcard_qspi_defconfig 
b/configs/ls1043aqds_sdcard_qspi_defconfig
index b43e5d4..3d99937 100644
--- a/configs/ls1043aqds_sdcard_qspi_defconfig
+++ b/configs/ls1043aqds_sdcard_qspi_defconfig
@@ -9,6 +9,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_NS16550=y
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_DM_SPI=y
diff --git a/configs/ls1043ardb_SECURE_BOOT_defconfig 
b/configs/ls1043ardb_SECURE_BOOT_defconfig
index 094e6b1..aad8540 100644
--- a/configs/ls1043ardb_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_SECURE_BOOT_defconfig
@@ -12,3 +12,4 @@ CONFIG_SYS_NS16550=y
 CONFIG_RSA=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD=y
diff --git a/configs/ls1043ardb_defconfig b/configs/ls1043ardb_defconfig
index 3945432..6b1999c 100644
--- a/configs/ls1043ardb_defconfig
+++ b/configs/ls1043ardb_defconfig
@@ -11,3 +11,4 @@ CONFIG_DM=y
 CONFIG_SYS_NS16550=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD=y
diff --git a/configs/ls1043ardb_nand_defconfig 
b/configs/ls1043ardb_nand_defconfig
index 180f464..c4a2e41 100644
--- a/configs/ls1043ardb_nand_defconfig
+++ b/configs/ls1043ardb_nand_defconfig
@@ -12,3 +12,4 @@ CONFIG_DM=y
 CONFIG_SYS_NS16550=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD=y
diff --git a/configs/ls1043ardb_sdcard_defconfig 
b/configs/ls1043ardb_sdcard_defconfig
index b8731df..2c5da16 100644
--- a/configs/ls1043ardb_sdcard_defconfig
+++ b/configs/ls1043ardb_sdcard_defconfig
@@ -12,3 +12,4 @@ CONFIG_DM=y
 CONFIG_SYS_NS16550=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD=y
diff --git a/include/configs/ls1043a_common.h b/include/configs/ls1043a_common.h
index b86845f..1f023f3 100644
--- a/include/configs/ls1043a_common.h
+++ b/include/configs/ls1043a_common.h
@@ -195,7 +195,6 @@
 #define CONFIG_FSL_DSPI
 #ifdef CONFIG_FSL_DSPI
 #define CONFIG_CMD_SF
-#define CONFIG_MTD
 #define CONFIG_SPI_NOR_STMICRO /* cs0 */
 #define C

[U-Boot] [PATCH v7 85/87] defconfig: ls1021atwr_sdcard_qspi: Enable CONFIG_MTD

2016-03-22 Thread Jagan Teki
From: Alison Wang 

As QSPI driver is supported in ls1021atwr_sdcard_qspi_defconfig,
CONFIG_MTD needs to be enabled for SPI-NOR with MTD uclass.

Cc: York Sun 
Cc: Jagan Teki 
Signed-off-by: Alison Wang 
Signed-off-by: Jagan Teki 
---
 configs/ls1021atwr_sdcard_qspi_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/ls1021atwr_sdcard_qspi_defconfig 
b/configs/ls1021atwr_sdcard_qspi_defconfig
index c0e1d49..05eab68 100644
--- a/configs/ls1021atwr_sdcard_qspi_defconfig
+++ b/configs/ls1021atwr_sdcard_qspi_defconfig
@@ -8,6 +8,7 @@ CONFIG_OF_STDOUT_VIA_ALIAS=y
 CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,SD_BOOT,SD_BOOT_QSPI"
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_MISC=y
-- 
1.9.1

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


[U-Boot] [PATCH v7 86/87] defconfig: ls1021aqds_sdcard_qspi: Enable MTD

2016-03-22 Thread Jagan Teki
+ CONFIG_MTD

Cc: York Sun 
Cc: Alison Wang 
Signed-off-by: Jagan Teki 
---
 configs/ls1021aqds_sdcard_qspi_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/ls1021aqds_sdcard_qspi_defconfig 
b/configs/ls1021aqds_sdcard_qspi_defconfig
index 9a06631..054c5ff 100644
--- a/configs/ls1021aqds_sdcard_qspi_defconfig
+++ b/configs/ls1021aqds_sdcard_qspi_defconfig
@@ -7,6 +7,7 @@ CONFIG_DEFAULT_DEVICE_TREE="ls1021a-qds-duart"
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
 CONFIG_DM=y
+CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
 CONFIG_SPI_NOR_SPANSION=y
-- 
1.9.1

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


[U-Boot] [PATCH v7 87/87] defconfig: ls1021aqds_sdcard_qspi: Enable MTD_DATAFLASH

2016-03-22 Thread Jagan Teki
+ CONFIG_MTD_DATAFLASH

Cc: York Sun 
Cc: Alison Wang 
Signed-off-by: Jagan Teki 
---
 configs/ls1021aqds_sdcard_qspi_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/ls1021aqds_sdcard_qspi_defconfig 
b/configs/ls1021aqds_sdcard_qspi_defconfig
index 054c5ff..25ab3ee 100644
--- a/configs/ls1021aqds_sdcard_qspi_defconfig
+++ b/configs/ls1021aqds_sdcard_qspi_defconfig
@@ -10,6 +10,7 @@ CONFIG_DM=y
 CONFIG_MTD=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD_DATAFLASH=y
 CONFIG_SPI_NOR_SPANSION=y
 CONFIG_NETDEVICES=y
 CONFIG_E1000=y
-- 
1.9.1

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


Re: [U-Boot] [PATCH v7 00/87] mtd: Add SPI-NOR core support

2016-03-22 Thread Jagan Teki

On Tuesday 22 March 2016 01:17 PM, Jagan Teki wrote:

On Tuesday 22 March 2016 01:07 PM, Jagan Teki wrote:

Some of the SPI device drivers at drivers/spi not a real
spi controllers, Unlike normal/generic SPI controllers they
operates only with SPI-NOR flash devices. these were technically
termed as SPI-NOR controllers, Ex: drivers/spi/fsl_qspi.c

The problem with these were resides at drivers/spi is entire
SPI layer becomes SPI-NOR flash oriented which is absolutely
a wrong indication where SPI layer getting effected more with
flash operations - So this SPI-NOR core will resolve this issue
by separating all SPI-NOR flash operations from spi layer and
creats a generic layer called SPI-NOR core which can be used to
interact SPI-NOR to SPI driver interface layer and the SPI-NOR
controller driver. The idea is taken from Linux spi-nor framework.

Before SPI-NOR:

---
 cmd/sf.c
---
 spi_flash.c
---
 sf_probe.c
---
 spi-uclass
---
 spi drivers
---
 SPI NOR chip
---

After SPI-NOR:

--
 cmd/sf.c
--
 spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

SPI-NOR with MTD:

--
 cmd/sf.c
--
 MTD core
--
 spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

drivers/mtd/spi-nor/spi-nor.c: spi-nor core
drivers/mtd/spi-nor/m25p80.c: mtd uclass driver
which is an interface layer b/w spi-nor core drivers/spi
drivers/mtd/spi-nor/fsl_qspi.c: spi-nor controller driver(mtd uclass)

Changes for v7:
- Rebase to latest
- Fixed git bisectable issues, with buildman.
- Fixed spi-nor compilation issues
- newly designed changes.

Changes for v6:
- Fixed git bisectable issues, with buildman.
- Fixed spi-nor compilation issues
- newly designed changes.

Changes for v5:
- newly designed changes

Testing:
$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b spi-nor-test origin/spi-nor-test

Alison Wang (1):
   defconfig: ls1021atwr_sdcard_qspi: Enable CONFIG_MTD


Tested in hardware and sandbox [1]

Tested-by: Jagan Teki 

[1] http://paste.ubuntu.com/15470696/


Here is buildman logs:

$> ./tools/buildman/buildman -b master -c 87 -s
boards.cfg is up to date. Nothing to do.
Summary of 87 commits for 1107 boards (32 threads, 1 job per thread)
01: mtd: Add m25p80 driver
  m68k:  +   M5329AFEE M5249EVB M5208EVBE astro_mcf5373l 
M54455EVB_intel M5282EVB M54455EVB_i66 M54455EVB_a66 M5253DEMO 
M54455EVB_stm33 M54455EVB M5272C3 M5329BFEE cobra5272 M5275EVB M5253EVBE 
M5235EVB_Flash32 M5373EVB M5235EVB

02: mtd: Add Kconfig entry for MTD_M25P80
03: mtd: Add SPI-NOR core support
04: doc: device-tree-bindings: jedec,spi-nor
05: mtd: spi-nor: Add Kconfig entry for MTD_SPI_NOR
06: mtd: spi-nor: Add kconfig for MTD_SPI_NOR_USE_4K_SECTORS
07: mtd: spi-nor: Add MTD support
08: mtd: spi-nor: Add spi_nor support in m25p80
09: mtd: spi-nor: Add dm spi-nor probing
10: mtd: spi-nor: Add spi_flash_probe for mtd-dm-spi-nor
11: mtd: spi-nor: Add spi_flash_free for mtd-dm-spi-nor
12: mtd: spi-nor: m25p80: Add spi_nor support for non-dm
13: sf: Rename erase_size to erasesize
14: sf: Use erasesize instead of sector_size
15: sf: Use uint64_t for flash->size
16: spi_flash: Use mtd_info operation for SPI-NOR
17: spi_flash: Use spi_flash_t instead of struct spi_flash
18: mtd: spi-nor: Move spi_read_then_write to spi layer
19: spi: Rename spi_read_then_write to spi_write_then_read
20: mtd: spi-nor: Rename SPI_FLASH_BAR to SPI_NOR_BAR
21: mtd: spi-nor: Add Kconfig entry for SPI_NOR_BAR
22: mtd: spi-nor: Copy spl files from drivers/mtd/spi
23: mtd: spi-nor: spl: Follow ascending order of include headers
24: mtd: spi-nor: fsl_espi_spl: Use mtd_info
25: mtd: spi-nor: fsl_espi_spl: Use writebufsize instead of page_size
26: mtd: spi-nor: spi_spl_load: Use mtd_info
27: spl: Add CONFIG_SPL_SPI_NOR_SUPPORT
28: mtd: spi-nor: Add flash vendor Kconfig entries
29: arm: zynq: Kconfig: Select MTD uclass
30: arm: zynq: Kconfig: Drop DM_SPI_FLASH
31: mtd: spi-nor: Copy sf_dataflash
32: mtd: dataflash: Remove unneeded spi data
33: mtd: dataflash: Move flash id detection into jedec_probe
34: mtd: dataflash: Fix add_dataflash return logic
35: mtd: dataflash: Add UCLASS_MTD support
36: mtd: dataflash: Use spi_write_then_read
37: mtd: dataflash: Drop sf_internal.h
38: mtd: dataflash: Minor cleanups
39:

[U-Boot] [RFC PATCH 0/1] net: phy: Force master mode for RTL8211C

2016-03-22 Thread Michael Haas

This patch is an RFC based on recent discussions. It's only lightly
tested. I have yet to verify that the registers are being set correctly.
I'm sending it out now because I have to leave for today.

Note that this patch requires Karsten Merkers '[PATCH] net: phy: Realtek
RTL8211B/C PHY ID fix'.

Series-Version: 2
Series-changes: 2
 - Removed accidental inclusion of Karsten's patch in my first submission of 
this series.
 - Fix a typo in the code: 6 -> &

Michael



Michael Haas (1):
  net: phy: Force master mode for RTL8211C

 drivers/net/phy/realtek.c | 13 +
 1 file changed, 13 insertions(+)

-- 
2.7.2

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


Re: [U-Boot] [PATCH v7 00/87] mtd: Add SPI-NOR core support

2016-03-22 Thread Jagan Teki

On Tuesday 22 March 2016 01:07 PM, Jagan Teki wrote:

Some of the SPI device drivers at drivers/spi not a real
spi controllers, Unlike normal/generic SPI controllers they
operates only with SPI-NOR flash devices. these were technically
termed as SPI-NOR controllers, Ex: drivers/spi/fsl_qspi.c

The problem with these were resides at drivers/spi is entire
SPI layer becomes SPI-NOR flash oriented which is absolutely
a wrong indication where SPI layer getting effected more with
flash operations - So this SPI-NOR core will resolve this issue
by separating all SPI-NOR flash operations from spi layer and
creats a generic layer called SPI-NOR core which can be used to
interact SPI-NOR to SPI driver interface layer and the SPI-NOR
controller driver. The idea is taken from Linux spi-nor framework.

Before SPI-NOR:

---
 cmd/sf.c
---
 spi_flash.c
---
 sf_probe.c
---
 spi-uclass
---
 spi drivers
---
 SPI NOR chip
---

After SPI-NOR:

--
 cmd/sf.c
--
 spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

SPI-NOR with MTD:

--
 cmd/sf.c
--
 MTD core
--
 spi-nor.c
---
m25p80.cspi nor drivers
---
spi-uclass  SPI NOR chip
---
spi drivers
---
SPI NOR chip
---

drivers/mtd/spi-nor/spi-nor.c: spi-nor core
drivers/mtd/spi-nor/m25p80.c: mtd uclass driver
which is an interface layer b/w spi-nor core drivers/spi
drivers/mtd/spi-nor/fsl_qspi.c: spi-nor controller driver(mtd uclass)

Changes for v7:
- Rebase to latest
- Fixed git bisectable issues, with buildman.
- Fixed spi-nor compilation issues
- newly designed changes.

Changes for v6:
- Fixed git bisectable issues, with buildman.
- Fixed spi-nor compilation issues
- newly designed changes.

Changes for v5:
- newly designed changes

Testing:
$ git clone git://git.denx.de/u-boot-spi.git
$ cd u-boot-spi
$ git checkout -b spi-nor-test origin/spi-nor-test

Alison Wang (1):
   defconfig: ls1021atwr_sdcard_qspi: Enable CONFIG_MTD


Tested in hardware and sandbox [1]

Tested-by: Jagan Teki 

[1] http://paste.ubuntu.com/15470696/
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


  1   2   3   >