Skip to contentSkip to conversation

fdt: Add fdtdec_get_addr_size() to read reg properties

PATCH New Simon Glass 1 participant 2 messages Mar 19, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/15 fdt: Add fdtdec_get_addr_size() to read reg properties

It is common to have a "reg = <address size>" property in the FDT. Add a function to handle this, similar to the existing fdtdec_get_addr();

---
Changes in v3:
- Fix new checkpatch check

Changes in v2: None

 include/fdtdec.h | 15 +++++++++++++++
 lib/fdtdec.c     | 27 +++++++++++++++++++++------
 2 files changed, 36 insertions(+), 6 deletions(-)
include/fdtdec.h +15 -0
index 2189483..5ca84a0 100644
@@ -38,11 +38,13 @@
  */
 #ifdef CONFIG_PHYS_64BIT
 typedef u64 fdt_addr_t;
+typedef u64 fdt_size_t;
 #define FDT_ADDR_T_NONE (-1ULL)
 #define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
 #define fdt_size_to_cpu(reg) be64_to_cpu(reg)
 #else
 typedef u32 fdt_addr_t;
+typedef u32 fdt_size_t;
 #define FDT_ADDR_T_NONE (-1U)
 #define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
 #define fdt_size_to_cpu(reg) be32_to_cpu(reg)
@@ -200,6 +202,19 @@ fdt_addr_t fdtdec_get_addr(const void *blob, int node,
 		const char *prop_name);
 
 /**
+ * Look up an address property in a node and return it as an address.
+ * The property must hold one address with a length. This is only tested
+ * on 32-bit machines.
+ *
+ * @param blob	FDT blob
+ * @param node	node to examine
+ * @param prop_name	name of property to find
+ * @return address, if found, or FDT_ADDR_T_NONE if not
+ */
+fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
+		const char *prop_name, fdt_size_t *sizep);
+
+/**
  * Look up a 32-bit integer property in a node and return it. The property
  * must have at least 4 bytes of data. The value of the first cell is
  * returned.
lib/fdtdec.c +21 -6
index 43f29f5..cffba94 100644
@@ -68,25 +68,40 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id)
 	return compat_names[id];
 }
 
-fdt_addr_t fdtdec_get_addr(const void *blob, int node,
-		const char *prop_name)
+fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
+		const char *prop_name, fdt_size_t *sizep)
 {
 	const fdt_addr_t *cell;
 	int len;
 
 	debug("%s: %s: ", __func__, prop_name);
 	cell = fdt_getprop(blob, node, prop_name, &len);
-	if (cell && (len == sizeof(fdt_addr_t) ||
-			len == sizeof(fdt_addr_t) * 2)) {
+	if (cell && ((!sizep && len == sizeof(fdt_addr_t)) ||
+		     len == sizeof(fdt_addr_t) * 2)) {
 		fdt_addr_t addr = fdt_addr_to_cpu(*cell);
-
-		debug("%p\n", (void *)addr);
+		if (sizep) {
+			const fdt_size_t *size;
+
+			size = (fdt_size_t *)((char *)cell +
+					sizeof(fdt_addr_t));
+			*sizep = fdt_size_to_cpu(*size);
+			debug("addr=%p, size=%p\n", (void *)addr,
+			      (void *)*sizep);
+		} else {
+			debug("%p\n", (void *)addr);
+		}
 		return addr;
 	}
 	debug("(not found)\n");
 	return FDT_ADDR_T_NONE;
 }
 
+fdt_addr_t fdtdec_get_addr(const void *blob, int node,
+		const char *prop_name)
+{
+	return fdtdec_get_addr_size(blob, node, prop_name, NULL);
+}
+
 s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
 		s32 default_val)
 {
Signature · 1 line
1.8.1.3
#1 lore raw

PATCH v3 6/15 x86: spi: Add Intel ICH driver

This supports Intel ICH7/9. The Intel controller is a little unusual in that it is mostly intended for use with SPI flash, and has some optimisations and features specifically for that application. In particular it is not possible to support ongoing transactions that continue over many calls with SPI_XFER_BEGIN and SPI_XFER_END.

This driver supports writes of up to 64 bytes at a time, the limit for the controller. Future work will improve this.

---
Changes in v3:
- Fix new checkpatch checks/warning
- Fix whitespace error

Changes in v2:
- Support both 33MHz and 20MHz operation
- Replace while() loop with memcpy_to/fromio()

 drivers/spi/Makefile |   1 +
 drivers/spi/ich.c    | 749 +++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/ich.h    | 143 ++++++++++
 3 files changed, 893 insertions(+)
 create mode 100644 drivers/spi/ich.c
 create mode 100644 drivers/spi/ich.h
drivers/spi/Makefile +1 -0
index 45862ec..4268595 100644
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_CF_SPI) += cf_spi.o
 COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
 COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
+COBJS-$(CONFIG_ICH_SPI) +=  ich.o
 COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/ich.c new file +749 -0

749 lines not on this page · raw message

drivers/spi/ich.h new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
1.8.1.3