Skip to contentSkip to conversation

imx: imximage: add new CHECK/CLR BIT command

PATCH Superseded Adrian Alonso 6 participants 22 messages Jul 15, 2015 – Jul 20, 2015

Subsystems (8)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/11 imx: imximage: add new CHECK/CLR BIT command

* Extend imximage DCD version 2 to support DCD commands CMD_WRITE_CLR_BIT 4 [address] [mask bit] means:

    while ((*address & ~mask) != 0);
  CMD_CHECK_BITS_SET 4 [address] [mask bit] means:
    while ((*address & mask) != mask);
  CMD_CHECK_BITS_CLR 4 [address] [mask bit] means:
    *address = *address & ~mask;

* Add set_dcd_param_v2 helper function to set DCD
command parameters

---
Changes for V2
- Add set_dcd_param_v2 helper function to set DCD command tag and parameters

 tools/imximage.c | 99 ++++++++++++++++++++++++++++++++++++++++++++------------
 tools/imximage.h | 25 ++++++++++----
 2 files changed, 97 insertions(+), 27 deletions(-)
tools/imximage.c +79 -20
index 6f469ae..cc0392f 100644
@@ -21,7 +21,10 @@
 static table_entry_t imximage_cmds[] = {
 	{CMD_BOOT_FROM,         "BOOT_FROM",            "boot command",	  },
 	{CMD_BOOT_OFFSET,       "BOOT_OFFSET",          "Boot offset",	  },
-	{CMD_DATA,              "DATA",                 "Reg Write Data", },
+	{CMD_WRITE_DATA,        "DATA",                 "Reg Write Data", },
+	{CMD_WRITE_CLR_BIT,     "CLR_BIT",              "Reg clear bit",  },
+	{CMD_CHECK_BITS_SET,    "CHECK_BITS_SET",   "Reg Check bits set", },
+	{CMD_CHECK_BITS_CLR,    "CHECK_BITS_CLR",   "Reg Check bits clr", },
 	{CMD_CSF,               "CSF",           "Command Sequence File", },
 	{CMD_IMAGE_VERSION,     "IMAGE_VERSION",        "image version",  },
 	{-1,                    "",                     "",	          },
@@ -62,7 +65,7 @@ static table_entry_t imximage_boot_loadsize[] = {
  */
 static table_entry_t imximage_versions[] = {
 	{IMXIMAGE_V1,	"",	" (i.MX25/35/51 compatible)", },
-	{IMXIMAGE_V2,	"",	" (i.MX53/6 compatible)",     },
+	{IMXIMAGE_V2,	"",	" (i.MX53/6/7 compatible)",   },
 	{-1,            "",     " (Invalid)",                 },
 };
 
@@ -79,6 +82,7 @@ static uint32_t imximage_csf_size = UNDEFINED;
 static uint32_t imximage_init_loadsize;
 
 static set_dcd_val_t set_dcd_val;
+static set_dcd_param_t set_dcd_param;
 static set_dcd_rst_t set_dcd_rst;
 static set_imx_hdr_t set_imx_hdr;
 static uint32_t max_dcd_entries;
@@ -128,6 +132,12 @@ static void err_imximage_version(int version)
 	exit(EXIT_FAILURE);
 }
 
+static void set_dcd_param_v1(struct imx_header *imxhdr, uint32_t dcd_len,
+		int32_t cmd)
+{
+	/* DCD V1 no parameter settings */
+}
+
 static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno,
 					int fld, uint32_t value, uint32_t off)
 {
@@ -156,6 +166,43 @@ static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno,
 	}
 }
 
+static void set_dcd_param_v2(struct imx_header *imxhdr, uint32_t dcd_len,
+		int32_t cmd)
+{
+	dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.dcd_table;
+
+	switch (cmd) {
+	case CMD_WRITE_DATA:
+		dcd_v2->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG;
+		dcd_v2->write_dcd_command.length = cpu_to_be16(
+				dcd_len * sizeof(dcd_addr_data_t) + 4);
+		dcd_v2->write_dcd_command.param = DCD_WRITE_DATA_PARAM;
+		break;
+	case CMD_WRITE_CLR_BIT:
+		dcd_v2->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG;
+		dcd_v2->write_dcd_command.length = cpu_to_be16(
+				dcd_len * sizeof(dcd_addr_data_t) + 4);
+		dcd_v2->write_dcd_command.param = DCD_WRITE_CLR_BIT_PARAM;
+		break;
+	case CMD_CHECK_BITS_SET:
+		dcd_v2->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG;
+		/*
+		 * Check data command only supports one entry,
+		 * so use 0xC = size(address + value + command).
+		 */
+		dcd_v2->write_dcd_command.length = cpu_to_be16(0xC);
+		dcd_v2->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM;
+		break;
+	case CMD_CHECK_BITS_CLR:
+		dcd_v2->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG;
+		dcd_v2->write_dcd_command.length = cpu_to_be16(0xC);
+		dcd_v2->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM;
+		break;
+	default:
+		break;
+	}
+}
+
 static void set_dcd_val_v2(struct imx_header *imxhdr, char *name, int lineno,
 					int fld, uint32_t value, uint32_t off)
 {
@@ -200,10 +247,7 @@ static void set_dcd_rst_v2(struct imx_header *imxhdr, uint32_t dcd_len,
 	dcd_v2->header.length = cpu_to_be16(
 			dcd_len * sizeof(dcd_addr_data_t) + 8);
 	dcd_v2->header.version = DCD_VERSION;
-	dcd_v2->write_dcd_command.tag = DCD_COMMAND_TAG;
-	dcd_v2->write_dcd_command.length = cpu_to_be16(
-			dcd_len * sizeof(dcd_addr_data_t) + 4);
-	dcd_v2->write_dcd_command.param = DCD_COMMAND_PARAM;
+	set_dcd_param_v2(imxhdr, dcd_len, CMD_WRITE_DATA);
 }
 
 static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len,
@@ -266,12 +310,14 @@ static void set_hdr_func(void)
 	switch (imximage_version) {
 	case IMXIMAGE_V1:
 		set_dcd_val = set_dcd_val_v1;
+		set_dcd_param = set_dcd_param_v1;
 		set_dcd_rst = set_dcd_rst_v1;
 		set_imx_hdr = set_imx_hdr_v1;
 		max_dcd_entries = MAX_HW_CFG_SIZE_V1;
 		break;
 	case IMXIMAGE_V2:
 		set_dcd_val = set_dcd_val_v2;
+		set_dcd_param = set_dcd_param_v2;
 		set_dcd_rst = set_dcd_rst_v2;
 		set_imx_hdr = set_imx_hdr_v2;
 		max_dcd_entries = MAX_HW_CFG_SIZE_V2;
@@ -396,8 +442,12 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
 		if (unlikely(cmd_ver_first != 1))
 			cmd_ver_first = 0;
 		break;
-	case CMD_DATA:
+	case CMD_WRITE_DATA:
+	case CMD_WRITE_CLR_BIT:
+	case CMD_CHECK_BITS_SET:
+	case CMD_CHECK_BITS_CLR:
 		value = get_cfg_value(token, name, lineno);
+		(*set_dcd_param)(imxhdr, dcd_len, cmd);
 		(*set_dcd_val)(imxhdr, name, lineno, fld, value, dcd_len);
 		if (unlikely(cmd_ver_first != 1))
 			cmd_ver_first = 0;
@@ -436,20 +486,29 @@ static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd,
 		break;
 	case CFG_REG_ADDRESS:
 	case CFG_REG_VALUE:
-		if (*cmd != CMD_DATA)
-			return;
-
-		value = get_cfg_value(token, name, lineno);
-		(*set_dcd_val)(imxhdr, name, lineno, fld, value, *dcd_len);
-
-		if (fld == CFG_REG_VALUE) {
-			(*dcd_len)++;
-			if (*dcd_len > max_dcd_entries) {
-				fprintf(stderr, "Error: %s[%d] -"
-					"DCD table exceeds maximum size(%d)\n",
-					name, lineno, max_dcd_entries);
-				exit(EXIT_FAILURE);
+		switch(*cmd) {
+		case CMD_WRITE_DATA:
+		case CMD_WRITE_CLR_BIT:
+		case CMD_CHECK_BITS_SET:
+		case CMD_CHECK_BITS_CLR:
+
+			value = get_cfg_value(token, name, lineno);
+			(*set_dcd_param)(imxhdr, *dcd_len, *cmd);
+			(*set_dcd_val)(imxhdr, name, lineno, fld, value,
+					*dcd_len);
+
+			if (fld == CFG_REG_VALUE) {
+				(*dcd_len)++;
+				if (*dcd_len > max_dcd_entries) {
+					fprintf(stderr, "Error: %s[%d] -"
+						"DCD table exceeds maximum size(%d)\n",
+						name, lineno, max_dcd_entries);
+					exit(EXIT_FAILURE);
+				}
 			}
+			break;
+		default:
+			break;
 		}
 		break;
 	default:
tools/imximage.h +18 -7
index 36fe095..c199814 100644
@@ -42,19 +42,27 @@
 #define FLASH_LOADSIZE_SATA		FLASH_LOADSIZE_STANDARD
 #define FLASH_LOADSIZE_QSPI		0x0 /* entire image */
 
-#define IVT_HEADER_TAG 0xD1
-#define IVT_VERSION 0x40
-#define DCD_HEADER_TAG 0xD2
-#define DCD_COMMAND_TAG 0xCC
-#define DCD_VERSION 0x40
-#define DCD_COMMAND_PARAM 0x4
+/* Command tags and parameters */
+#define IVT_HEADER_TAG			0xD1
+#define IVT_VERSION			0x40
+#define DCD_HEADER_TAG			0xD2
+#define DCD_VERSION			0x40
+#define DCD_WRITE_DATA_COMMAND_TAG	0xCC
+#define DCD_WRITE_DATA_PARAM		0x4
+#define DCD_WRITE_CLR_BIT_PARAM	0xC
+#define DCD_CHECK_DATA_COMMAND_TAG	0xCF
+#define DCD_CHECK_BITS_SET_PARAM	0x14
+#define DCD_CHECK_BITS_CLR_PARAM	0x04
 
 enum imximage_cmd {
 	CMD_INVALID,
 	CMD_IMAGE_VERSION,
 	CMD_BOOT_FROM,
 	CMD_BOOT_OFFSET,
-	CMD_DATA,
+	CMD_WRITE_DATA,
+	CMD_WRITE_CLR_BIT,
+	CMD_CHECK_BITS_SET,
+	CMD_CHECK_BITS_CLR,
 	CMD_CSF,
 };
 
@@ -167,6 +175,9 @@ typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
 					int fld, uint32_t value,
 					uint32_t off);
 
+typedef void (*set_dcd_param_t)(struct imx_header *imxhdr, uint32_t dcd_len,
+					int32_t cmd);
+
 typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr,
 					uint32_t dcd_len,
 					char *name, int lineno);
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/11 imx: power: add pmic pfuze300 support

* Add pmic pfuze300 support for imx7 and iMX6 DL/SL/SX SoC's
* Implement power_pfuze300_init to be used in power_init_board callback function.

---
 drivers/power/pmic/Makefile        |  1 +
 drivers/power/pmic/pmic_pfuze300.c | 32 ++++++++++++++++
 include/power/pfuze300_pmic.h      | 78 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 drivers/power/pmic/pmic_pfuze300.c
 create mode 100644 include/power/pfuze300_pmic.h
drivers/power/pmic/Makefile +1 -0
index ae86f04..43040ff 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
 obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
 obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
 obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
+obj-$(CONFIG_POWER_PFUZE300) += pmic_pfuze300.o
 obj-$(CONFIG_POWER_TPS65090_I2C) += pmic_tps65090.o
 obj-$(CONFIG_POWER_TPS65090_EC) += pmic_tps65090_ec.o
 obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
drivers/power/pmic/pmic_pfuze300.c new file +32 -0
new file mode 100644
index 0000000..4304ddd
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Peng Fan <[email protected]>
+ *
+ * SPDX-License-Identifier:      GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <i2c.h>
+#include <power/pmic.h>
+#include <power/pfuze300_pmic.h>
+
+int power_pfuze300_init(unsigned char bus)
+{
+	static const char name[] = "PFUZE300";
+	struct pmic *p = pmic_alloc();
+
+	if (!p) {
+		printf("%s: POWER allocation error!\n", __func__);
+		return -ENOMEM;
+	}
+
+	p->name = name;
+	p->interface = PMIC_I2C;
+	p->number_of_regs = PMIC_NUM_OF_REGS;
+	p->hw.i2c.addr = CONFIG_POWER_PFUZE300_I2C_ADDR;
+	p->hw.i2c.tx_num = 1;
+	p->bus = bus;
+
+	return 0;
+}
include/power/pfuze300_pmic.h new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/11 imx: power: add pmic pfuze300 support

Quoted 139 lines · Adrian Alonso

* Add pmic pfuze300 support for imx7 and iMX6 DL/SL/SX SoC's
* Implement power_pfuze300_init to be used in power_init_board callback function.

---
 drivers/power/pmic/Makefile        |  1 +
 drivers/power/pmic/pmic_pfuze300.c | 32 ++++++++++++++++
 include/power/pfuze300_pmic.h      | 78 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 drivers/power/pmic/pmic_pfuze300.c
 create mode 100644 include/power/pfuze300_pmic.h
drivers/power/pmic/Makefile +1 -0
index ae86f04..43040ff 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
 obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
 obj-$(CONFIG_POWER_MAX77686) += pmic_max77686.o
 obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
+obj-$(CONFIG_POWER_PFUZE300) += pmic_pfuze300.o
 obj-$(CONFIG_POWER_TPS65090_I2C) += pmic_tps65090.o
 obj-$(CONFIG_POWER_TPS65090_EC) += pmic_tps65090_ec.o
 obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
drivers/power/pmic/pmic_pfuze300.c new file +32 -0
new file mode 100644
index 0000000..4304ddd
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Peng Fan <[email protected]>
+ *
+ * SPDX-License-Identifier:      GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <i2c.h>
+#include <power/pmic.h>
+#include <power/pfuze300_pmic.h>
+
+int power_pfuze300_init(unsigned char bus)
+{
+	static const char name[] = "PFUZE300";
+	struct pmic *p = pmic_alloc();
+
+	if (!p) {
+		printf("%s: POWER allocation error!\n", __func__);
+		return -ENOMEM;
+	}
+
+	p->name = name;
+	p->interface = PMIC_I2C;
+	p->number_of_regs = PMIC_NUM_OF_REGS;
+	p->hw.i2c.addr = CONFIG_POWER_PFUZE300_I2C_ADDR;
+	p->hw.i2c.tx_num = 1;
+	p->bus = bus;
+
+	return 0;
+}
include/power/pfuze300_pmic.h new file +68 -0
new file mode 100644
index 0000000..c7ec5ce
@@ -0,0 +1,78 @@
+/*
+ *  Copyright (C) 2015 Freescale Semiconductor, Inc
+ *  Peng Fan <[email protected]>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+#ifndef __PFUZE300_PMIC_H_
+#define __PFUZE300_PMIC_H_
+
+/* PFUZE300 registers */
+enum {
+	PFUZE300_DEVICEID	= 0x00,
+
+	PFUZE300_REVID		= 0x03,
+	PFUZE300_FABID		= 0x04,
+	PFUZE300_INTSTAT0	= 0x05,
+	PFUZE300_INTMASK0	= 0x06,
+	PFUZE300_INTSENSE0	= 0x07,
+	PFUZE300_INTSTAT1	= 0x08,
+	PFUZE300_INTMASK1	= 0x09,
+	PFUZE300_INTSENSE1	= 0x0A,
+
+	PFUZE300_INTSTAT3	= 0x0E,
+	PFUZE300_INTMASK3	= 0x0F,
+	PFUZE300_INTSENSE3	= 0x10,
+	PFUZE300_INTSTAT4	= 0x11,
+	PFUZE300_INTMASK4	= 0x12,
+	PFUZE300_INTSENSE4	= 0x13,
+
+	PFUZE300_COINCTL	= 0x1A,
+	PFUZE300_PWRCTL		= 0x1B,
+	PFUZE300_MEMA		= 0x1C,
+	PFUZE300_MEMB		= 0x1D,
+	PFUZE300_MEMC		= 0x1E,
+	PFUZE300_MEMD		= 0x1F,
+
+	PFUZE300_SW1AVOLT	= 0x20,
+	PFUZE300_SW1ASTBY	= 0x21,
+	PFUZE300_SW1AOFF	= 0x22,
+	PFUZE300_SW1AMODE	= 0x23,
+	PFUZE300_SW1ACONF	= 0x24,
+
+	PFUZE300_SW1BVOLT	= 0x2E,
+	PFUZE300_SW1BSTBY	= 0x2F,
+	PFUZE300_SW1BOFF	= 0x30,
+	PFUZE300_SW1BMODE	= 0x31,
+	PFUZE300_SW1BCONF	= 0x32,
+
+	PFUZE300_SW2VOLT	= 0x35,
+	PFUZE300_SW2STBY	= 0x36,
+	PFUZE300_SW2OFF		= 0x37,
+	PFUZE300_SW2MODE	= 0x38,
+	PFUZE300_SW2CONF	= 0x39,
+
+	PFUZE300_SW3VOLT	= 0x3C,
+	PFUZE300_SW3STBY	= 0x3D,
+	PFUZE300_SW3OFF		= 0x3E,
+	PFUZE300_SW3MODE	= 0x3F,
+	PFUZE300_SW3CONF	= 0x40,
+
+	PFUZE300_SWBSTCTL	= 0x66,
+
+	PFUZE300_LDOGCTL	= 0x69,
+	PFUZE300_VREFDDRCTL	= 0x6A,
+	PFUZE300_VSNVSCTL	= 0x6B,
+	PFUZE300_VLDO1CTL	= 0x6C,
+	PFUZE300_VLDO2CTL	= 0x6D,
+	PFUZE300_VCC_SDCTL	= 0x6E,

include/power/pfuze300_pmic.h line 78

Quoted 10 lines
include/power/pfuze300_pmic.h new file +10 -0
+	PFUZE300_V33CTL		= 0x6F,
+	PFUZE300_VLDO3CTL	= 0x70,
+	PFUZE300_VLD4CTL	= 0x71,
+
+	PMIC_NUM_OF_REGS	= 0x7F,
+};
+
+int power_pfuze300_init(unsigned char bus);
+
+#endif

I think the PMIC name is pfuze3000 not pfuse300.

Regards,
Nitin

reviewer
#3 lore raw

PATCH 2/11 imx: power: add pmic pfuze300 support

In reply to Adrian Alonso
Quoted 1 line · Adrian Alonso

* Add pmic pfuze300 support for imx7 and iMX6 DL/SL/SX SoC's

The PMIC support is independent of the CPU that is used, so I would remove the "imx7 and iMX6 DL/SL/SX SoC's".

Also, in the subject you should remove imx, as this patch is not related to imx.

#4 lore raw

PATCH 3/11 imx: usb: ehci-mx7 add usb driver for i.MX7D

In reply to Adrian Alonso

* Add support for usb driver for i.MX7D SoC

---
 drivers/usb/host/Makefile   |   1 +
 drivers/usb/host/ehci-mx7.c | 103 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)
 create mode 100644 drivers/usb/host/ehci-mx7.c
drivers/usb/host/Makefile +1 -0
index 4d35d3e..7267160 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 obj-$(CONFIG_USB_EHCI_MXS) += ehci-mxs.o
 obj-$(CONFIG_USB_EHCI_MX5) += ehci-mx5.o
 obj-$(CONFIG_USB_EHCI_MX6) += ehci-mx6.o
+obj-$(CONFIG_USB_EHCI_MX7) += ehci-mx7.o
 obj-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
 obj-$(CONFIG_USB_EHCI_PPC4XX) += ehci-ppc4xx.o
 obj-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o
drivers/usb/host/ehci-mx7.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.1.4
#6 lore raw

PATCH 5/11 imx: iomux-v3: add imx7d support for iomuxc

In reply to Adrian Alonso

* Add imx7d support for iomux controller
* Since mx7d introduces LPSR IOMUX pins, add new base to IOMUX v3 driver for these LPSR pins.

---
 arch/arm/imx-common/iomux-v3.c             | 20 ++++++++++++++++++-
 arch/arm/include/asm/imx-common/iomux-v3.h | 32 ++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)
arch/arm/imx-common/iomux-v3.c +19 -1
index 7fb23dd..07e75a6 100644
@@ -4,7 +4,7 @@
  * Copyright (C) 2009 by Jan Weitzel Phytec Messtechnik GmbH,
  *                       <[email protected]>
  *
- * Copyright (C) 2004-2011 Freescale Semiconductor, Inc.
+ * Copyright (C) 2004-2015 Freescale Semiconductor, Inc.
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -41,6 +41,18 @@ void imx_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
 	}
 #endif
 
+#ifdef CONFIG_IOMUX_LPSR
+	u32 lpsr = (pad & MUX_MODE_LPSR) >> MUX_MODE_SHIFT;
+
+	if (lpsr == IOMUX_CONFIG_LPSR) {
+		base = (void *)IOMUXC_LPSR_BASE_ADDR;
+		mux_mode &= ~IOMUX_CONFIG_LPSR;
+		/* set daisy chain sel_input */
+		if (sel_input_ofs)
+			sel_input_ofs += IOMUX_LPSR_SEL_INPUT_OFS;
+	}
+#endif
+
 	if (mux_ctrl_ofs)
 		__raw_writel(mux_mode, base + mux_ctrl_ofs);
 
@@ -55,6 +67,12 @@ void imx_iomux_v3_setup_pad(iomux_v3_cfg_t pad)
 	if (!(pad_ctrl & NO_PAD_CTRL) && pad_ctrl_ofs)
 		__raw_writel(pad_ctrl, base + pad_ctrl_ofs);
 #endif
+
+#ifdef CONFIG_IOMUX_LPSR
+	if (lpsr == IOMUX_CONFIG_LPSR)
+		base = (void *)IOMUXC_BASE_ADDR;
+#endif
+
 }
 
 /* configures a list of pads within declared with IOMUX_PADS macro */
arch/arm/include/asm/imx-common/iomux-v3.h +32 -0
index 2581019..5dd64f5 100644
@@ -85,6 +85,36 @@ typedef u64 iomux_v3_cfg_t;
 
 #define NO_PAD_CTRL		(1 << 17)
 
+#ifdef CONFIG_MX7
+
+#define IOMUX_LPSR_SEL_INPUT_OFS 0x70000
+#define IOMUX_CONFIG_LPSR       0x8
+#define MUX_MODE_LPSR           ((iomux_v3_cfg_t)IOMUX_CONFIG_LPSR << \
+		        MUX_MODE_SHIFT)
+
+#define PAD_CTL_DSE_1P8V_140OHM   (0x0<<0)
+#define PAD_CTL_DSE_1P8V_35OHM    (0x1<<0)
+#define PAD_CTL_DSE_1P8V_70OHM    (0x2<<0)
+#define PAD_CTL_DSE_1P8V_23OHM    (0x3<<0)
+
+#define PAD_CTL_DSE_3P3V_196OHM   (0x0<<0)
+#define PAD_CTL_DSE_3P3V_49OHM    (0x1<<0)
+#define PAD_CTL_DSE_3P3V_98OHM    (0x2<<0)
+#define PAD_CTL_DSE_3P3V_32OHM    (0x3<<0)
+
+#define PAD_CTL_SRE_FAST     (0 << 2)
+#define PAD_CTL_SRE_SLOW     (0x1 << 2)
+
+#define PAD_CTL_HYS       (0x1 << 3)
+#define PAD_CTL_PUE       (0x1 << 4)
+
+#define PAD_CTL_PUS_PD100KOHM  ((0x0 << 5) | PAD_CTL_PUE)
+#define PAD_CTL_PUS_PU5KOHM    ((0x1 << 5) | PAD_CTL_PUE)
+#define PAD_CTL_PUS_PU47KOHM   ((0x2 << 5) | PAD_CTL_PUE)
+#define PAD_CTL_PUS_PU100KOHM  ((0x3 << 5) | PAD_CTL_PUE)
+
+#else
+
 #ifdef CONFIG_MX6
 
 #define PAD_CTL_HYS		(1 << 16)
@@ -167,6 +197,8 @@ typedef u64 iomux_v3_cfg_t;
 #define PAD_CTL_SRE_SLOW	(0 << 0)
 #define PAD_CTL_SRE_FAST	(1 << 0)
 
+#endif
+
 #define IOMUX_CONFIG_SION	0x10
 
 #define GPIO_PIN_MASK		0x1f
Signature · 1 line
2.1.4
#7 lore raw

PATCH 6/11 imx: mxc_gpio: add support for imx7d SoC

In reply to Adrian Alonso

* Add mxc_gpio support for imx7d SoC
* Use CONFIG_MX7 to extend mxc gpio driver support for imx7d

---
 drivers/gpio/mxc_gpio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpio/mxc_gpio.c +5 -3
index 2012f99..332ed40 100644
@@ -40,14 +40,16 @@ static unsigned long gpio_ports[] = {
 	[1] = GPIO2_BASE_ADDR,
 	[2] = GPIO3_BASE_ADDR,
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
-		defined(CONFIG_MX53) || defined(CONFIG_MX6)
+		defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
+		defined(CONFIG_MX7)
 	[3] = GPIO4_BASE_ADDR,
 #endif
-#if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6)
+#if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
+		defined(CONFIG_MX7)
 	[4] = GPIO5_BASE_ADDR,
 	[5] = GPIO6_BASE_ADDR,
 #endif
-#if defined(CONFIG_MX53) || defined(CONFIG_MX6)
+#if defined(CONFIG_MX53) || defined(CONFIG_MX6) || defined(CONFIG_MX7)
 	[6] = GPIO7_BASE_ADDR,
 #endif
 };
Signature · 1 line
2.1.4
#8 lore raw

PATCH 7/11 imx: ocotp: mxc add i.MX7D support

In reply to Adrian Alonso

* Ocotp of i.MX7D has different operation rule.
This patch is to add support for i.MX7D ocotp.

---
 drivers/misc/mxc_ocotp.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+), 1 deletion(-)
drivers/misc/mxc_ocotp.c +73 -1
index d92044e..7f0e9e4 100644
@@ -25,8 +25,21 @@
 #define BM_CTRL_ERROR			0x00000200
 #define BM_CTRL_BUSY			0x00000100
 #define BO_CTRL_ADDR			0
+#ifdef CONFIG_MX7
+#define BM_CTRL_ADDR                    0x0000000f
+#define BM_CTRL_RELOAD                  0x00000400
+#else
 #define BM_CTRL_ADDR			0x0000007f
-
+#endif
+
+#ifdef CONFIG_MX7
+#define BO_TIMING_FSOURCE               12
+#define BM_TIMING_FSOURCE               0x0007f000
+#define BV_TIMING_FSOURCE_NS            1001
+#define BO_TIMING_PROG                  0
+#define BM_TIMING_PROG                  0x00000fff
+#define BV_TIMING_PROG_US               10
+#else
 #define BO_TIMING_STROBE_READ		16
 #define BM_TIMING_STROBE_READ		0x003f0000
 #define BV_TIMING_STROBE_READ_NS	37
@@ -36,6 +49,7 @@
 #define BO_TIMING_STROBE_PROG		0
 #define BM_TIMING_STROBE_PROG		0x00000fff
 #define BV_TIMING_STROBE_PROG_US	10
+#endif
 
 #define BM_READ_CTRL_READ_FUSE		0x00000001
 
@@ -109,6 +123,25 @@ int fuse_read(u32 bank, u32 word, u32 *val)
 	return finish_access(regs, __func__);
 }
 
+#ifdef CONFIG_MX7
+static void set_timing(struct ocotp_regs *regs)
+{
+	u32 ipg_clk;
+	u32 fsource, prog;
+	u32 timing;
+
+	ipg_clk = mxc_get_clock(MXC_IPG_CLK);
+
+	fsource = DIV_ROUND_UP((ipg_clk / 1000) * BV_TIMING_FSOURCE_NS,
+			+       1000000) + 1;
+	prog = DIV_ROUND_CLOSEST(ipg_clk * BV_TIMING_PROG_US, 1000000) + 1;
+
+	timing = BF(fsource, TIMING_FSOURCE) | BF(prog, TIMING_PROG);
+
+	clrsetbits_le32(&regs->timing, BM_TIMING_FSOURCE | BM_TIMING_PROG,
+			timing);
+}
+#else
 static void set_timing(struct ocotp_regs *regs)
 {
 	u32 ipg_clk;
@@ -130,12 +163,17 @@ static void set_timing(struct ocotp_regs *regs)
 	clrsetbits_le32(&regs->timing, BM_TIMING_STROBE_READ | BM_TIMING_RELAX |
 			BM_TIMING_STROBE_PROG, timing);
 }
+#endif
 
 static void setup_direct_access(struct ocotp_regs *regs, u32 bank, u32 word,
 				int write)
 {
 	u32 wr_unlock = write ? BV_CTRL_WR_UNLOCK_KEY : 0;
+#ifdef CONFIG_MX7
+	u32 addr = bank;
+#else
 	u32 addr = bank << 3 | word;
+#endif
 
 	set_timing(regs);
 	clrsetbits_le32(&regs->ctrl, BM_CTRL_WR_UNLOCK | BM_CTRL_ADDR,
@@ -155,7 +193,11 @@ int fuse_sense(u32 bank, u32 word, u32 *val)
 	setup_direct_access(regs, bank, word, false);
 	writel(BM_READ_CTRL_READ_FUSE, &regs->read_ctrl);
 	wait_busy(regs, 1);
+#ifdef CONFIG_MX7
+	*val = readl((&regs->read_fuse_data0) + (word << 2));
+#else
 	*val = readl(&regs->read_fuse_data);
+#endif
 
 	return finish_access(regs, __func__);
 }
@@ -176,8 +218,38 @@ int fuse_prog(u32 bank, u32 word, u32 val)
 		return ret;
 
 	setup_direct_access(regs, bank, word, true);
+#ifdef CONFIG_MX7
+	switch (word) {
+	case 0:
+		writel(0, &regs->data1);
+		writel(0, &regs->data2);
+		writel(0, &regs->data3);
+		writel(val, &regs->data0);
+		break;
+	case 1:
+	        writel(val, &regs->data1);
+		writel(0, &regs->data2);
+		writel(0, &regs->data3);
+		writel(0, &regs->data0);
+		break;
+	case 2:
+		writel(0, &regs->data1);
+		writel(val, &regs->data2);
+		writel(0, &regs->data3);
+		writel(0, &regs->data0);
+		break;
+	case 3:
+		writel(0, &regs->data1);
+		writel(0, &regs->data2);
+		writel(val, &regs->data3);
+		writel(0, &regs->data0);
+		break;
+	}
+	wait_busy(regs, BV_TIMING_PROG_US);
+#else
 	writel(val, &regs->data);
 	wait_busy(regs, BV_TIMING_STROBE_PROG_US);
+#endif
 	udelay(WRITE_POSTAMBLE_US);
 
 	return finish_access(regs, __func__);
Signature · 1 line
2.1.4
#9 lore raw

PATCH 8/11 imx: mx7 dm thermal driver support

In reply to Adrian Alonso

* Add thermal driver support for imx7 SoC read_cpu_temperature is SoC dependent
* Redefine config macro to support imx7 and imx6 SoC

---
 arch/arm/imx-common/cpu.c         |  10 ++--
 drivers/thermal/Makefile          |   2 +-
 drivers/thermal/imx_thermal.c     | 100 +++++++++++++++++++++++++++++++++++---
 include/configs/mx6cuboxi.h       |   2 +-
 include/configs/mx6sabre_common.h |   4 +-
 include/configs/mx6slevk.h        |   4 +-
 include/configs/mx6sxsabresd.h    |   4 +-
 7 files changed, 108 insertions(+), 18 deletions(-)
arch/arm/imx-common/cpu.c +7 -3
index 5e56cfe..2e803f3 100644
@@ -148,14 +148,16 @@ int print_cpuinfo(void)
 	u32 cpurev;
 	__maybe_unused u32 max_freq;
 
-#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_IMX_THERMAL)
 	struct udevice *thermal_dev;
-	int cpu_tmp, minc, maxc, ret;
+	int cpu_tmp, ret;
 #endif
 
 	cpurev = get_cpu_rev();
 
 #if defined(CONFIG_MX6)
+	int minc, maxc;
+
 	printf("CPU:   Freescale i.MX%s rev%d.%d",
 	       get_imx_type((cpurev & 0xFF000) >> 12),
 	       (cpurev & 0x000F0) >> 4,
@@ -175,7 +177,7 @@ int print_cpuinfo(void)
 		mxc_get_clock(MXC_ARM_CLK) / 1000000);
 #endif
 
-#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_MX6) && defined(CONFIG_IMX_THERMAL)
 	puts("CPU:   ");
 	switch (get_cpu_temp_grade(&minc, &maxc)) {
 	case TEMP_AUTOMOTIVE:
@@ -192,6 +194,8 @@ int print_cpuinfo(void)
 		break;
 	}
 	printf("(%dC to %dC)", minc, maxc);
+#endif
+#if defined(CONFIG_IMX_THERMAL)
 	ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev);
 	if (!ret) {
 		ret = thermal_get_temp(thermal_dev, &cpu_tmp);
drivers/thermal/Makefile +1 -1
index 6d4cacd..d768f5e 100644
@@ -6,4 +6,4 @@
 #
 
 obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
-obj-$(CONFIG_IMX6_THERMAL) += imx_thermal.o
+obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
drivers/thermal/imx_thermal.c +93 -7

133 lines not on this page · raw message

include/configs/mx6cuboxi.h +1 -1
index 3d5bba7..d42b7f0 100644
@@ -14,7 +14,7 @@
 #define CONFIG_SPL_MMC_SUPPORT
 #include "imx6_spl.h"
 
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
 
 #define CONFIG_SYS_MALLOC_LEN		(10 * SZ_1M)
 #define CONFIG_BOARD_EARLY_INIT_F
include/configs/mx6sabre_common.h +2 -2
index 6c3c52e..4b1f898 100644
@@ -11,7 +11,7 @@
 
 #include "mx6_common.h"
 
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
 
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(10 * SZ_1M)
@@ -22,7 +22,7 @@
 #define CONFIG_MXC_UART
 
 #define CONFIG_CMD_FUSE
-#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX_THERMAL)
 #define CONFIG_MXC_OCOTP
 #endif
 
include/configs/mx6slevk.h +2 -2
index a7da111..756acf6 100644
@@ -190,10 +190,10 @@
 #define CONFIG_SYS_MMC_ENV_DEV		1	/* SDHC2*/
 #endif
 
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
 
 #define CONFIG_CMD_FUSE
-#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX_THERMAL)
 #define CONFIG_MXC_OCOTP
 #endif
 
include/configs/mx6sxsabresd.h +2 -2
index 2b278a8..b54f2bd 100644
@@ -176,10 +176,10 @@
 #define CONFIG_PCIE_IMX_POWER_GPIO	IMX_GPIO_NR(2, 1)
 #endif
 
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
 
 #define CONFIG_CMD_FUSE
-#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX_THERMAL)
 #define CONFIG_MXC_OCOTP
 #endif
 
Signature · 1 line
2.1.4
reviewer
#10 lore raw

PATCH 8/11 imx: mx7 dm thermal driver support

Hi Adrian,

include/configs/mx6cuboxi.h line 17

Quoted 10 lines · Adrian Alonso
include/configs/mx6cuboxi.h +1 -1
index 3d5bba7..d42b7f0 100644
@@ -14,7 +14,7 @@
 #define CONFIG_SPL_MMC_SUPPORT
 #include "imx6_spl.h"
 
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL

This would cause a conflict with Peter Robinson's series that centralizas CONFIG_IMX6_THERMAL

#11 lore raw

PATCH 8/11 imx: mx7 dm thermal driver support

Hi Fabio,

Quoted 20 lines

-----Original Message-----
From: Fabio Estevam [mailto:festevam at gmail.com]
Sent: Thursday, July 16, 2015 9:15 AM
To: Alonso Lazcano Adrian-B38018
Cc: U-Boot-Denx; Stefano Babic; Estevam Fabio-R49496; Otavio Salvador
Subject: Re: [U-Boot] [PATCH 08/11] imx: mx7 dm thermal driver support

Hi Adrian,

Quoted 8 lines · Adrian Alonso
include/configs/mx6cuboxi.h +0 -0
index 3d5bba7..d42b7f0 100644
@@ -14,7 +14,7 @@
 #define CONFIG_SPL_MMC_SUPPORT
 #include "imx6_spl.h"
 
Quoted 5 lines

include/configs/mx6cuboxi.h line 17

Quoted 2 lines
include/configs/mx6cuboxi.h +1 -1
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL

This would cause a conflict with Peter Robinson's series that centralizas CONFIG_IMX6_THERMAL

[Adrian] So far Peter Robinson patch's have been Acked but not yet committed into u-boot master.
I will wait into patch's are committed to rework and send and new patch series for imx7 support addressing All the comment and suggestion.

Thanks :)

#12 lore raw

PATCH 8/11 imx: mx7 dm thermal driver support

Quoted 3 lines · Alonso Adrian

[Adrian] So far Peter Robinson patch's have been Acked but not yet committed into u-boot master.
I will wait into patch's are committed to rework and send and new patch series for imx7 support addressing All the comment and suggestion.

Instead you can apply it locally and base on this. Add the dependency in the series cover and we gain some more review time ...

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#13 lore raw

PATCH 9/11 imx: system counter driver for imx7d and mx6ul

In reply to Adrian Alonso

* The system counter driver for imx7d abd mx6ul, move this timer driver to imx-common and rename it as syscounter.c

For mx6ul and mx7, configurations are used for choose the GPT timer or system counter timer (default).

GPT timer: CONFIG_GPT_TIMER
System counter timer: CONFIG_SYSCOUNTER_TIMER

For mx6dqp GPT timer is the default setting.

---
 arch/arm/imx-common/syscounter.c             | 126 +++++++++++++++++++++++++++
 arch/arm/include/asm/imx-common/syscounter.h |  29 ++++++
 include/configs/mx6_common.h                 |   1 +
 3 files changed, 156 insertions(+)
 create mode 100644 arch/arm/imx-common/syscounter.c
 create mode 100644 arch/arm/include/asm/imx-common/syscounter.h
arch/arm/imx-common/syscounter.c new file +126 -0
new file mode 100644
index 0000000..f5e5cdc
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * The file use ls102xa/timer.c as a reference.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <div64.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/imx-common/syscounter.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function is intended for SHORT delays only.
+ * It will overflow at around 10 seconds @ 400MHz,
+ * or 20 seconds @ 200MHz.
+ */
+unsigned long usec2ticks(unsigned long usec)
+{
+	ulong ticks;
+
+	if (usec < 1000)
+		ticks = ((usec * (get_tbclk()/1000)) + 500) / 1000;
+	else
+		ticks = ((usec / 10) * (get_tbclk() / 100000));
+
+	return ticks;
+}
+
+static inline unsigned long long tick_to_time(unsigned long long tick)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	tick *= CONFIG_SYS_HZ;
+	do_div(tick, freq);
+
+	return tick;
+}
+
+static inline unsigned long long us_to_tick(unsigned long long usec)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	usec = usec * freq  + 999999;
+	do_div(usec, 1000000);
+
+	return usec;
+}
+
+int timer_init(void)
+{
+	struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR;
+	unsigned long val, freq;
+
+	freq = CONFIG_SC_TIMER_CLK;
+	asm("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+
+	writel(freq, &sctr->cntfid0);
+
+	/* Enable system counter */
+	val = readl(&sctr->cntcr);
+	val &= ~(SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1);
+	val |= SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG;
+	writel(val, &sctr->cntcr);
+
+	gd->arch.tbl = 0;
+	gd->arch.tbu = 0;
+
+	return 0;
+}
+
+unsigned long long get_ticks(void)
+{
+	unsigned long long now;
+
+	asm("mrrc p15, 0, %Q0, %R0, c14" : "=r" (now));
+
+	gd->arch.tbl = (unsigned long)(now & 0xffffffff);
+	gd->arch.tbu = (unsigned long)(now >> 32);
+
+	return now;
+}
+
+ulong get_timer_masked(void)
+{
+	return tick_to_time(get_ticks());
+}
+
+ulong get_timer(ulong base)
+{
+	return get_timer_masked() - base;
+}
+
+void __udelay(unsigned long usec)
+{
+	unsigned long long tmp;
+	ulong tmo;
+
+	tmo = us_to_tick(usec);
+	tmp = get_ticks() + tmo;	/* get current timestamp */
+
+	while (get_ticks() < tmp)	/* loop till event */
+		 /*NOP*/;
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	return freq;
+}
arch/arm/include/asm/imx-common/syscounter.h new file +29 -0
new file mode 100644
index 0000000..ddb412e
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_SYSTEM_COUNTER_H
+#define _ASM_ARCH_SYSTEM_COUNTER_H
+
+/* System Counter */
+struct sctr_regs {
+	u32 cntcr;
+	u32 cntsr;
+	u32 cntcv1;
+	u32 cntcv2;
+	u32 resv1[4];
+	u32 cntfid0;
+	u32 cntfid1;
+	u32 cntfid2;
+	u32 resv2[1001];
+	u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE		(1 << 0)
+#define SC_CNTCR_HDBG		(1 << 1)
+#define SC_CNTCR_FREQ0		(1 << 8)
+#define SC_CNTCR_FREQ1		(1 << 9)
+
+#endif
include/configs/mx6_common.h +1 -0
index 86d7b16..690038d 100644
@@ -30,6 +30,7 @@
 
 #define CONFIG_MP
 #define CONFIG_MXC_GPT_HCLK
+#define CONFIG_GPT_TIMER
 
 #define CONFIG_SYS_NO_FLASH
 
Signature · 1 line
2.1.4
#14 lore raw

PATCH 9/11 imx: system counter driver for imx7d and mx6ul

Hi Adrian,

Quoted 74 lines · Adrian Alonso

* The system counter driver for imx7d abd mx6ul, move this timer driver to imx-common and rename it as syscounter.c

For mx6ul and mx7, configurations are used for choose the GPT timer or system counter timer (default).

GPT timer: CONFIG_GPT_TIMER
System counter timer: CONFIG_SYSCOUNTER_TIMER

For mx6dqp GPT timer is the default setting.

---
  arch/arm/imx-common/syscounter.c             | 126 +++++++++++++++++++++++++++
  arch/arm/include/asm/imx-common/syscounter.h |  29 ++++++
  include/configs/mx6_common.h                 |   1 +
  3 files changed, 156 insertions(+)

create mode 100644 arch/arm/imx-common/syscounter.c create mode 100644 arch/arm/include/asm/imx-common/syscounter.h

arch/arm/imx-common/syscounter.c new file +47 -0
new file mode 100644
index 0000000..f5e5cdc
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * The file use ls102xa/timer.c as a reference.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <div64.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/imx-common/syscounter.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function is intended for SHORT delays only.
+ * It will overflow at around 10 seconds @ 400MHz,
+ * or 20 seconds @ 200MHz.
+ */
+unsigned long usec2ticks(unsigned long usec)
+{
+	ulong ticks;
+
+	if (usec < 1000)
+		ticks = ((usec * (get_tbclk()/1000)) + 500) / 1000;
+	else
+		ticks = ((usec / 10) * (get_tbclk() / 100000));
+
+	return ticks;
+}
+
+static inline unsigned long long tick_to_time(unsigned long long tick)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	tick *= CONFIG_SYS_HZ;
+	do_div(tick, freq);
+
+	return tick;
+}
+
+static inline unsigned long long us_to_tick(unsigned long long usec)

arch/arm/imx-common/syscounter.c line 57

Quoted 10 lines
arch/arm/imx-common/syscounter.c new file +10 -0
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	usec = usec * freq  + 999999;
+	do_div(usec, 1000000);
+
+	return usec;
+}

Is it possible to use the same naming convention for usec2ticks(), tick_to_time() and us_to_tick() (e.g. choose either "2" or "_to_")? Thanks.

Quoted 110 lines
arch/arm/imx-common/syscounter.c new file +69 -0
+
+int timer_init(void)
+{
+	struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR;
+	unsigned long val, freq;
+
+	freq = CONFIG_SC_TIMER_CLK;
+	asm("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+
+	writel(freq, &sctr->cntfid0);
+
+	/* Enable system counter */
+	val = readl(&sctr->cntcr);
+	val &= ~(SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1);
+	val |= SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG;
+	writel(val, &sctr->cntcr);
+
+	gd->arch.tbl = 0;
+	gd->arch.tbu = 0;
+
+	return 0;
+}
+
+unsigned long long get_ticks(void)
+{
+	unsigned long long now;
+
+	asm("mrrc p15, 0, %Q0, %R0, c14" : "=r" (now));
+
+	gd->arch.tbl = (unsigned long)(now & 0xffffffff);
+	gd->arch.tbu = (unsigned long)(now >> 32);
+
+	return now;
+}
+
+ulong get_timer_masked(void)
+{
+	return tick_to_time(get_ticks());
+}
+
+ulong get_timer(ulong base)
+{
+	return get_timer_masked() - base;
+}
+
+void __udelay(unsigned long usec)
+{
+	unsigned long long tmp;
+	ulong tmo;
+
+	tmo = us_to_tick(usec);
+	tmp = get_ticks() + tmo;	/* get current timestamp */
+
+	while (get_ticks() < tmp)	/* loop till event */
+		 /*NOP*/;
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	return freq;
+}
arch/arm/include/asm/imx-common/syscounter.h new file +29 -0
new file mode 100644
index 0000000..ddb412e
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_SYSTEM_COUNTER_H
+#define _ASM_ARCH_SYSTEM_COUNTER_H
+
+/* System Counter */
+struct sctr_regs {
+	u32 cntcr;
+	u32 cntsr;
+	u32 cntcv1;
+	u32 cntcv2;
+	u32 resv1[4];
+	u32 cntfid0;
+	u32 cntfid1;
+	u32 cntfid2;
+	u32 resv2[1001];
+	u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE		(1 << 0)
+#define SC_CNTCR_HDBG		(1 << 1)
+#define SC_CNTCR_FREQ0		(1 << 8)
+#define SC_CNTCR_FREQ1		(1 << 9)
+
+#endif
include/configs/mx6_common.h +0 -0
index 86d7b16..690038d 100644

include/configs/mx6_common.h line 36

Quoted 7 lines
include/configs/mx6_common.h +1 -0
@@ -30,6 +30,7 @@
 
  #define CONFIG_MP
  #define CONFIG_MXC_GPT_HCLK
+#define CONFIG_GPT_TIMER
 
  #define CONFIG_SYS_NO_FLASH
 

Regards,
Nikolay

#15 lore raw

PATCH 9/11 imx: system counter driver for imx7d and mx6ul

Hi Nikolay,

Quoted 93 lines

-----Original Message-----
From: Nikolay Dimitrov [mailto:picmaster at mail.bg]
Sent: Monday, July 20, 2015 3:43 PM
To: Alonso Lazcano Adrian-B38018
Cc: u-boot at lists.denx.de; sbabic at denx.de; Estevam Fabio-R49496; otavio at ossystems.com.br
Subject: Re: [U-Boot] [PATCH 09/11] imx: system counter driver for imx7d and mx6ul

Hi Adrian,

Quoted 9 lines · Adrian Alonso

* The system counter driver for imx7d abd mx6ul, move this timer driver to imx-common and rename it as syscounter.c

For mx6ul and mx7, configurations are used for choose the GPT timer or system counter timer (default).

GPT timer: CONFIG_GPT_TIMER
System counter timer: CONFIG_SYSCOUNTER_TIMER

Quoted 6 lines

For mx6dqp GPT timer is the default setting.

---
  arch/arm/imx-common/syscounter.c             | 126

+++++++++++++++++++++++++++

Quoted 65 lines
  arch/arm/include/asm/imx-common/syscounter.h |  29 ++++++
  include/configs/mx6_common.h                 |   1 +
  3 files changed, 156 insertions(+)

create mode 100644 arch/arm/imx-common/syscounter.c create mode 100644 arch/arm/include/asm/imx-common/syscounter.h

arch/arm/imx-common/syscounter.c new file +52 -0
new file mode 100644
index 0000000..f5e5cdc
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * The file use ls102xa/timer.c as a reference.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <div64.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/imx-common/syscounter.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function is intended for SHORT delays only.
+ * It will overflow at around 10 seconds @ 400MHz,
+ * or 20 seconds @ 200MHz.
+ */
+unsigned long usec2ticks(unsigned long usec) {
+	ulong ticks;
+
+	if (usec < 1000)
+		ticks = ((usec * (get_tbclk()/1000)) + 500) / 1000;
+	else
+		ticks = ((usec / 10) * (get_tbclk() / 100000));
+
+	return ticks;
+}
+
+static inline unsigned long long tick_to_time(unsigned long long
+tick) {
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	tick *= CONFIG_SYS_HZ;
+	do_div(tick, freq);
+
+	return tick;
+}
+
+static inline unsigned long long us_to_tick(unsigned long long usec)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	usec = usec * freq  + 999999;
Quoted 8 lines

arch/arm/imx-common/syscounter.c line 57

Quoted 4 lines
arch/arm/imx-common/syscounter.c new file +4 -0
+	do_div(usec, 1000000);
+
+	return usec;
+}

Is it possible to use the same naming convention for usec2ticks(), tick_to_time() and us_to_tick() (e.g. choose either "2" or "_to_")? Thanks.

[Adrian] usec2ticks follows the definition of prototype function in header file "include/common.h"
the comment in the header /* arch/$(ARCH)/lib/time.c */ implies that each platform should provide that function; For iMX SoC's case usec2ticks is only used in drivers/crypto/fsl/jr.c and drivers/i2c/fsl_i2c.c IMHO we should keep the same naming convention defined in the "include/common.h" file.

Quoted 122 lines
Quoted 112 lines
arch/arm/imx-common/syscounter.c new file +69 -0
+
+int timer_init(void)
+{
+	struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR;
+	unsigned long val, freq;
+
+	freq = CONFIG_SC_TIMER_CLK;
+	asm("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+
+	writel(freq, &sctr->cntfid0);
+
+	/* Enable system counter */
+	val = readl(&sctr->cntcr);
+	val &= ~(SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1);
+	val |= SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG;
+	writel(val, &sctr->cntcr);
+
+	gd->arch.tbl = 0;
+	gd->arch.tbu = 0;
+
+	return 0;
+}
+
+unsigned long long get_ticks(void)
+{
+	unsigned long long now;
+
+	asm("mrrc p15, 0, %Q0, %R0, c14" : "=r" (now));
+
+	gd->arch.tbl = (unsigned long)(now & 0xffffffff);
+	gd->arch.tbu = (unsigned long)(now >> 32);
+
+	return now;
+}
+
+ulong get_timer_masked(void)
+{
+	return tick_to_time(get_ticks());
+}
+
+ulong get_timer(ulong base)
+{
+	return get_timer_masked() - base;
+}
+
+void __udelay(unsigned long usec)
+{
+	unsigned long long tmp;
+	ulong tmo;
+
+	tmo = us_to_tick(usec);
+	tmp = get_ticks() + tmo;	/* get current timestamp */
+
+	while (get_ticks() < tmp)	/* loop till event */
+		 /*NOP*/;
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	return freq;
+}
arch/arm/include/asm/imx-common/syscounter.h new file +29 -0
new file mode 100644
index 0000000..ddb412e
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_SYSTEM_COUNTER_H
+#define _ASM_ARCH_SYSTEM_COUNTER_H
+
+/* System Counter */
+struct sctr_regs {
+	u32 cntcr;
+	u32 cntsr;
+	u32 cntcv1;
+	u32 cntcv2;
+	u32 resv1[4];
+	u32 cntfid0;
+	u32 cntfid1;
+	u32 cntfid2;
+	u32 resv2[1001];
+	u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE		(1 << 0)
+#define SC_CNTCR_HDBG		(1 << 1)
+#define SC_CNTCR_FREQ0		(1 << 8)
+#define SC_CNTCR_FREQ1		(1 << 9)
+
+#endif
(quoted diff) +0 -0

b/include/configs/mx6_common.h index 86d7b16..690038d 100644

include/configs/mx6_common.h line 36

Quoted 7 lines
include/configs/mx6_common.h +1 -0
@@ -30,6 +30,7 @@
 
  #define CONFIG_MP
  #define CONFIG_MXC_GPT_HCLK
+#define CONFIG_GPT_TIMER
 
  #define CONFIG_SYS_NO_FLASH
 

Regards,
Nikolay

#16 lore raw

PATCH 9/11 imx: system counter driver for imx7d and mx6ul

Hi Adrian,

Quoted 104 lines · Alonso Adrian

Hi Nikolay,

Quoted 93 lines

-----Original Message-----
From: Nikolay Dimitrov [mailto:picmaster at mail.bg]
Sent: Monday, July 20, 2015 3:43 PM
To: Alonso Lazcano Adrian-B38018
Cc: u-boot at lists.denx.de; sbabic at denx.de; Estevam Fabio-R49496; otavio at ossystems.com.br
Subject: Re: [U-Boot] [PATCH 09/11] imx: system counter driver for imx7d and mx6ul

Hi Adrian,

Quoted 9 lines · Adrian Alonso

* The system counter driver for imx7d abd mx6ul, move this timer driver to imx-common and rename it as syscounter.c

For mx6ul and mx7, configurations are used for choose the GPT timer or system counter timer (default).

GPT timer: CONFIG_GPT_TIMER
System counter timer: CONFIG_SYSCOUNTER_TIMER

Quoted 6 lines

For mx6dqp GPT timer is the default setting.

---
   arch/arm/imx-common/syscounter.c             | 126

+++++++++++++++++++++++++++

Quoted 65 lines
   arch/arm/include/asm/imx-common/syscounter.h |  29 ++++++
   include/configs/mx6_common.h                 |   1 +
   3 files changed, 156 insertions(+)

create mode 100644 arch/arm/imx-common/syscounter.c create mode 100644 arch/arm/include/asm/imx-common/syscounter.h

arch/arm/imx-common/syscounter.c new file +52 -0
new file mode 100644
index 0000000..f5e5cdc
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * The file use ls102xa/timer.c as a reference.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <div64.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/imx-common/syscounter.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function is intended for SHORT delays only.
+ * It will overflow at around 10 seconds @ 400MHz,
+ * or 20 seconds @ 200MHz.
+ */
+unsigned long usec2ticks(unsigned long usec) {
+	ulong ticks;
+
+	if (usec < 1000)
+		ticks = ((usec * (get_tbclk()/1000)) + 500) / 1000;
+	else
+		ticks = ((usec / 10) * (get_tbclk() / 100000));
+
+	return ticks;
+}
+
+static inline unsigned long long tick_to_time(unsigned long long
+tick) {
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	tick *= CONFIG_SYS_HZ;
+	do_div(tick, freq);
+
+	return tick;
+}
+
+static inline unsigned long long us_to_tick(unsigned long long usec)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	usec = usec * freq  + 999999;
Quoted 8 lines

arch/arm/imx-common/syscounter.c line 57

Quoted 4 lines
arch/arm/imx-common/syscounter.c new file +4 -0
+	do_div(usec, 1000000);
+
+	return usec;
+}

Is it possible to use the same naming convention for usec2ticks(), tick_to_time() and us_to_tick() (e.g. choose either "2" or "_to_")? Thanks.

Quoted 4 lines

[Adrian] usec2ticks follows the definition of prototype function in header file "include/common.h"
the comment in the header /* arch/$(ARCH)/lib/time.c */ implies that each platform should provide that function; For iMX SoC's case usec2ticks is only used in drivers/crypto/fsl/jr.c and drivers/i2c/fsl_i2c.c IMHO we should keep the same naming convention defined in the "include/common.h" file.

I see. Thanks for explaining!

Quoted 117 lines
Quoted 117 lines
Quoted 117 lines
arch/arm/imx-common/syscounter.c new file +69 -0
+
+int timer_init(void)
+{
+	struct sctr_regs *sctr = (struct sctr_regs *)SCTR_BASE_ADDR;
+	unsigned long val, freq;
+
+	freq = CONFIG_SC_TIMER_CLK;
+	asm("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
+
+	writel(freq, &sctr->cntfid0);
+
+	/* Enable system counter */
+	val = readl(&sctr->cntcr);
+	val &= ~(SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1);
+	val |= SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG;
+	writel(val, &sctr->cntcr);
+
+	gd->arch.tbl = 0;
+	gd->arch.tbu = 0;
+
+	return 0;
+}
+
+unsigned long long get_ticks(void)
+{
+	unsigned long long now;
+
+	asm("mrrc p15, 0, %Q0, %R0, c14" : "=r" (now));
+
+	gd->arch.tbl = (unsigned long)(now & 0xffffffff);
+	gd->arch.tbu = (unsigned long)(now >> 32);
+
+	return now;
+}
+
+ulong get_timer_masked(void)
+{
+	return tick_to_time(get_ticks());
+}
+
+ulong get_timer(ulong base)
+{
+	return get_timer_masked() - base;
+}
+
+void __udelay(unsigned long usec)
+{
+	unsigned long long tmp;
+	ulong tmo;
+
+	tmo = us_to_tick(usec);
+	tmp = get_ticks() + tmo;	/* get current timestamp */
+
+	while (get_ticks() < tmp)	/* loop till event */
+		 /*NOP*/;
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk(void)
+{
+	unsigned long freq;
+
+	asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (freq));
+
+	return freq;
+}
arch/arm/include/asm/imx-common/syscounter.h new file +29 -0
new file mode 100644
index 0000000..ddb412e
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_SYSTEM_COUNTER_H
+#define _ASM_ARCH_SYSTEM_COUNTER_H
+
+/* System Counter */
+struct sctr_regs {
+	u32 cntcr;
+	u32 cntsr;
+	u32 cntcv1;
+	u32 cntcv2;
+	u32 resv1[4];
+	u32 cntfid0;
+	u32 cntfid1;
+	u32 cntfid2;
+	u32 resv2[1001];
+	u32 counterid[1];
+};
+
+#define SC_CNTCR_ENABLE		(1 << 0)
+#define SC_CNTCR_HDBG		(1 << 1)
+#define SC_CNTCR_FREQ0		(1 << 8)
+#define SC_CNTCR_FREQ1		(1 << 9)
+
+#endif
(quoted diff) +0 -0

b/include/configs/mx6_common.h index 86d7b16..690038d 100644

include/configs/mx6_common.h +1 -0
@@ -30,6 +30,7 @@
 
   #define CONFIG_MP
   #define CONFIG_MXC_GPT_HCLK
+#define CONFIG_GPT_TIMER
 
Quoted 9 lines
Quoted 6 lines

include/configs/mx6_common.h line 36

Quoted 3 lines
include/configs/mx6_common.h +0 -0
   #define CONFIG_SYS_NO_FLASH
 

Regards,
Nikolay

Regards,
Nikolay

#17 lore raw

PATCH 10/11 imx: imx7d: initial arch level support

In reply to Adrian Alonso

* Introduce a new cpu type MXC_CPU_MX7D and relevant functions for mx7d. Implement the soc.c for various system level functions like:
temperature check, arch init, get mac fuse, boot mode get/apply, etc.
* Additional, enable building imx common platform files for mx7d.

---
 arch/arm/Kconfig                            |    7 +
 arch/arm/Makefile                           |    4 +-
 arch/arm/cpu/armv7/Makefile                 |    3 +-
 arch/arm/cpu/armv7/mx7/Makefile             |    9 +
 arch/arm/cpu/armv7/mx7/clock.c              | 1130 +++++++++++
 arch/arm/cpu/armv7/mx7/clock_slice.c        |  757 +++++++
 arch/arm/cpu/armv7/mx7/hab.c                |  277 +++
 arch/arm/cpu/armv7/mx7/soc.c                |  409 ++++
 arch/arm/imx-common/Makefile                |   17 +-
 arch/arm/imx-common/cpu.c                   |   17 +
 arch/arm/imx-common/timer.c                 |    9 +-
 arch/arm/include/asm/arch-imx/cpu.h         |    1 +
 arch/arm/include/asm/arch-mx7/clock.h       |  348 ++++
 arch/arm/include/asm/arch-mx7/clock_slice.h |  116 ++
 arch/arm/include/asm/arch-mx7/crm_regs.h    | 2813 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx7/gpio.h        |   12 +
 arch/arm/include/asm/arch-mx7/hab.h         |   69 +
 arch/arm/include/asm/arch-mx7/imx-regs.h    | 1303 +++++++++++++
 arch/arm/include/asm/arch-mx7/mx7-pins.h    |   19 +
 arch/arm/include/asm/arch-mx7/mx7d_pins.h   | 1308 +++++++++++++
 arch/arm/include/asm/arch-mx7/sys_proto.h   |   45 +
 arch/arm/include/asm/imx-common/boot_mode.h |   21 +
 drivers/watchdog/Makefile                   |    2 +-
 23 files changed, 8688 insertions(+), 8 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/mx7/Makefile
 create mode 100644 arch/arm/cpu/armv7/mx7/clock.c
 create mode 100644 arch/arm/cpu/armv7/mx7/clock_slice.c
 create mode 100644 arch/arm/cpu/armv7/mx7/hab.c
 create mode 100644 arch/arm/cpu/armv7/mx7/soc.c
 create mode 100644 arch/arm/include/asm/arch-mx7/clock.h
 create mode 100644 arch/arm/include/asm/arch-mx7/clock_slice.h
 create mode 100644 arch/arm/include/asm/arch-mx7/crm_regs.h
 create mode 100644 arch/arm/include/asm/arch-mx7/gpio.h
 create mode 100644 arch/arm/include/asm/arch-mx7/hab.h
 create mode 100644 arch/arm/include/asm/arch-mx7/imx-regs.h
 create mode 100644 arch/arm/include/asm/arch-mx7/mx7-pins.h
 create mode 100644 arch/arm/include/asm/arch-mx7/mx7d_pins.h
 create mode 100644 arch/arm/include/asm/arch-mx7/sys_proto.h
arch/arm/Kconfig +7 -0
index 506463c..40aabb6 100644
@@ -578,6 +578,12 @@ config TARGET_MX6SXSABRESD
 	select DM
 	select DM_THERMAL
 
+config TARGET_MX7DSABRESD
+	bool "Support mx7dsabresd"
+	select CPU_V7
+	select DM
+	select DM_THERMAL
+
 config TARGET_GW_VENTANA
 	bool "Support gw_ventana"
 	select CPU_V7
@@ -923,6 +929,7 @@ source "board/freescale/mx6qsabreauto/Kconfig"
 source "board/freescale/mx6sabresd/Kconfig"
 source "board/freescale/mx6slevk/Kconfig"
 source "board/freescale/mx6sxsabresd/Kconfig"
+source "board/freescale/mx7dsabresd/Kconfig"
 source "board/freescale/vf610twr/Kconfig"
 source "board/gateworks/gw_ventana/Kconfig"
 source "board/genesi/mx51_efikamx/Kconfig"
arch/arm/Makefile +2 -2
index 6f30098..6708140 100644
@@ -78,11 +78,11 @@ libs-y += arch/arm/cpu/
 libs-y += arch/arm/lib/
 
 ifeq ($(CONFIG_SPL_BUILD),y)
-ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
+ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx31 mx35))
 libs-y += arch/arm/imx-common/
 endif
 else
-ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
+ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx31 mx35 mxs vf610))
 libs-y += arch/arm/imx-common/
 endif
 endif
arch/arm/cpu/armv7/Makefile +2 -1
index 5a76100..8defb1b 100644
@@ -12,7 +12,7 @@ obj-y	+= cache_v7.o
 obj-y	+= cpu.o cp15.o
 obj-y	+= syslib.o
 
-ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI)$(CONFIG_ARCH_SOCFPGA),)
+ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_MX7)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI)$(CONFIG_ARCH_SOCFPGA),)
 ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
 obj-y	+= lowlevel_init.o
 endif
@@ -45,6 +45,7 @@ obj-$(CONFIG_ARCH_EXYNOS) += exynos/
 obj-$(if $(filter ls102xa,$(SOC)),y) += ls102xa/
 obj-$(if $(filter mx5,$(SOC)),y) += mx5/
 obj-$(CONFIG_MX6) += mx6/
+obj-$(CONFIG_MX7) += mx7/
 obj-$(CONFIG_OMAP34XX) += omap3/
 obj-$(CONFIG_OMAP44XX) += omap4/
 obj-$(CONFIG_OMAP54XX) += omap5/
arch/arm/cpu/armv7/mx7/Makefile new file +9 -0
new file mode 100644
index 0000000..d36501d
@@ -0,0 +1,9 @@
+#
+# (C) Copyright 2015 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+#
+
+obj-y	:= soc.o clock.o clock_slice.o
+obj-$(CONFIG_SECURE_BOOT)    += hab.o
arch/arm/cpu/armv7/mx7/clock.c new file +1130 -0

1,130 lines not on this page · raw message

arch/arm/cpu/armv7/mx7/clock_slice.c new file +757 -0

757 lines not on this page · raw message

arch/arm/cpu/armv7/mx7/hab.c new file +277 -0

277 lines not on this page · raw message

arch/arm/cpu/armv7/mx7/soc.c new file +409 -0

409 lines not on this page · raw message

arch/arm/imx-common/Makefile +14 -3
index b9f1ca4..99bec53 100644
@@ -7,20 +7,31 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 vf610))
+ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 mx7 vf610))
 obj-y	= iomux-v3.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
-obj-y	+= timer.o cpu.o speed.o
+obj-y	+= cpu.o speed.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
 endif
-ifeq ($(SOC),$(filter $(SOC),mx6 mxs))
+ifeq ($(SOC),$(filter $(SOC),mx5))
+obj-y  += timer.o
+endif
+ifeq ($(SOC),$(filter $(SOC),mx7))
+obj-y	+= cpu.o
+obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
+obj-$(CONFIG_GPT_TIMER) += timer.o
+obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
+endif
+ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs))
 obj-y	+= misc.o
 obj-$(CONFIG_SPL_BUILD)	+= spl.o
 endif
 ifeq ($(SOC),$(filter $(SOC),mx6))
 obj-$(CONFIG_CMD_SATA) += sata.o
 obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
+obj-$(CONFIG_GPT_TIMER) += timer.o
+obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
 endif
 ifeq ($(SOC),$(filter $(SOC),vf610))
 obj-y += ddrmc-vf610.o
arch/arm/imx-common/cpu.c +17 -0
index 2e803f3..3cd30e7 100644
@@ -46,13 +46,26 @@ static char *get_reset_cause(void)
 	case 0x00008:
 		return "IPP USER";
 	case 0x00010:
+#ifdef CONFIG_MX7
+		return "WDOG1";
+#else
 		return "WDOG";
+#endif
 	case 0x00020:
 		return "JTAG HIGH-Z";
 	case 0x00040:
 		return "JTAG SW";
+#ifdef CONFIG_MX7
+	case 0x00080:
+		return "WDOG3";
+	case 0x00100:
+		return "WDOG4";
+	case 0x00200:
+		return "TEMPSENSE";
+#else
 	case 0x10000:
 		return "WARM BOOT";
+#endif
 	default:
 		return "unknown reset";
 	}
@@ -122,6 +135,8 @@ unsigned imx_ddr_size(void)
 const char *get_imx_type(u32 imxtype)
 {
 	switch (imxtype) {
+	case MXC_CPU_MX7D:
+		return "7D";	/* Dual-core version of the mx7 */
 	case MXC_CPU_MX6Q:
 		return "6Q";	/* Quad-core version of the mx6 */
 	case MXC_CPU_MX6D:
@@ -236,6 +251,7 @@ int cpu_mmc_init(bd_t *bis)
 }
 #endif
 
+#ifndef CONFIG_MX7
 u32 get_ahb_clk(void)
 {
 	struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
@@ -247,6 +263,7 @@ u32 get_ahb_clk(void)
 
 	return get_periph_clk() / (ahb_podf + 1);
 }
+#endif
 
 void arch_preboot_os(void)
 {
arch/arm/imx-common/timer.c +8 -1
index c12556a..bc4a673 100644
@@ -49,6 +49,8 @@ static inline int gpt_has_clk_source_osc(void)
 		return 1;
 
 	return 0;
+#elif defined(CONFIG_MX7)
+	return 1;
 #else
 	return 0;
 #endif
@@ -56,6 +58,9 @@ static inline int gpt_has_clk_source_osc(void)
 
 static inline ulong gpt_get_clk(void)
 {
+#if defined(CONFIG_MX7)
+	return MXC_HCLK >> 3;
+#else
 #ifdef CONFIG_MXC_GPT_HCLK
 	if (gpt_has_clk_source_osc())
 		return MXC_HCLK >> 3;
@@ -64,6 +69,7 @@ static inline ulong gpt_get_clk(void)
 #else
 	return MXC_CLK32;
 #endif
+#endif
 }
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
@@ -106,7 +112,8 @@ int timer_init(void)
 		/* For DL/S, SX, set 24Mhz OSC Enable bit and prescaler */
 		if (is_cpu_type(MXC_CPU_MX6DL) ||
 		    is_cpu_type(MXC_CPU_MX6SOLO) ||
-		    is_cpu_type(MXC_CPU_MX6SX)) {
+		    is_cpu_type(MXC_CPU_MX6SX) ||
+		    is_cpu_type(MXC_CPU_MX7D)) {
 			i |= GPTCR_24MEN;
 
 			/* Produce 3Mhz clock */
arch/arm/include/asm/arch-imx/cpu.h +1 -0
index 4715f4e..e0b4bc8 100644
@@ -12,6 +12,7 @@
 #define MXC_CPU_MX6Q		0x63
 #define MXC_CPU_MX6D		0x64
 #define MXC_CPU_MX6SOLO		0x65 /* dummy ID */
+#define MXC_CPU_MX7D		0x72
 
 #define CS0_128					0
 #define CS0_64M_CS1_64M				1
arch/arm/include/asm/arch-mx7/clock.h new file +348 -0

249 lines not on this page · raw message

arch/arm/include/asm/arch-mx7/clock_slice.h new file +116 -0

116 lines not on this page · raw message

arch/arm/include/asm/arch-mx7/crm_regs.h new file +2813 -0

2,813 lines not on this page · raw message

arch/arm/include/asm/arch-mx7/gpio.h new file +12 -0
new file mode 100644
index 0000000..b7890c2

Lines of this file are not shown. View the raw message.

arch/arm/include/asm/arch-mx7/hab.h new file +69 -0

69 lines not on this page · raw message

arch/arm/include/asm/arch-mx7/imx-regs.h new file +1303 -0

1,303 lines not on this page · raw message

arch/arm/include/asm/arch-mx7/mx7-pins.h new file +19 -0
new file mode 100644
index 0000000..164c2be

Lines of this file are not shown. View the raw message.

arch/arm/include/asm/arch-mx7/mx7d_pins.h new file +1308 -0

1,308 lines not on this page · raw message

arch/arm/include/asm/arch-mx7/sys_proto.h new file +45 -0

45 lines not on this page · raw message

arch/arm/include/asm/imx-common/boot_mode.h +21 -0
index de0205c..62dd01d 100644

Lines of this file are not shown. View the raw message.

drivers/watchdog/Makefile +1 -1
index 482a4bd..9e9cb55 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.1.4

Part of the diff is not shown here. View the raw message.

reviewer
#18 lore raw

PATCH 10/11 imx: imx7d: initial arch level support

Quoted 25 lines · Adrian Alonso

* Introduce a new cpu type MXC_CPU_MX7D and relevant functions for mx7d. Implement the soc.c for various system level functions like:
temperature check, arch init, get mac fuse, boot mode get/apply, etc.
* Additional, enable building imx common platform files for mx7d.

---
 arch/arm/Kconfig                            |    7 +
 arch/arm/Makefile                           |    4 +-
 arch/arm/cpu/armv7/Makefile                 |    3 +-
 arch/arm/cpu/armv7/mx7/Makefile             |    9 +
 arch/arm/cpu/armv7/mx7/clock.c              | 1130 +++++++++++
 arch/arm/cpu/armv7/mx7/clock_slice.c        |  757 +++++++
 arch/arm/cpu/armv7/mx7/hab.c                |  277 +++
 arch/arm/cpu/armv7/mx7/soc.c                |  409 ++++
 arch/arm/imx-common/Makefile                |   17 +-
 arch/arm/imx-common/cpu.c                   |   17 +
 arch/arm/imx-common/timer.c                 |    9 +-
 arch/arm/include/asm/arch-imx/cpu.h         |    1 +
 arch/arm/include/asm/arch-mx7/clock.h       |  348 ++++
 arch/arm/include/asm/arch-mx7/clock_slice.h |  116 ++
 arch/arm/include/asm/arch-mx7/crm_regs.h    | 2813 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx7/gpio.h        |   12 +
Quoted 8 lines
 arch/arm/include/asm/arch-mx7/hab.h         |   69 +
 arch/arm/include/asm/arch-mx7/imx-regs.h    | 1303 +++++++++++++
 arch/arm/include/asm/arch-mx7/mx7-pins.h    |   19 +
 arch/arm/include/asm/arch-mx7/mx7d_pins.h   | 1308 +++++++++++++
 arch/arm/include/asm/arch-mx7/sys_proto.h   |   45 +
 arch/arm/include/asm/imx-common/boot_mode.h |   21 +
 drivers/watchdog/Makefile                   |    2 +-
 23 files changed, 8688 insertions(+), 8 deletions(-)

Wow! This is too big to review. Please split in smaller pieces.

Quoted 20 lines
 create mode 100644 arch/arm/cpu/armv7/mx7/Makefile
 create mode 100644 arch/arm/cpu/armv7/mx7/clock.c
 create mode 100644 arch/arm/cpu/armv7/mx7/clock_slice.c
 create mode 100644 arch/arm/cpu/armv7/mx7/hab.c
 create mode 100644 arch/arm/cpu/armv7/mx7/soc.c
 create mode 100644 arch/arm/include/asm/arch-mx7/clock.h
 create mode 100644 arch/arm/include/asm/arch-mx7/clock_slice.h
 create mode 100644 arch/arm/include/asm/arch-mx7/crm_regs.h
 create mode 100644 arch/arm/include/asm/arch-mx7/gpio.h
 create mode 100644 arch/arm/include/asm/arch-mx7/hab.h
 create mode 100644 arch/arm/include/asm/arch-mx7/imx-regs.h
 create mode 100644 arch/arm/include/asm/arch-mx7/mx7-pins.h
 create mode 100644 arch/arm/include/asm/arch-mx7/mx7d_pins.h
 create mode 100644 arch/arm/include/asm/arch-mx7/sys_proto.h
arch/arm/Kconfig +0 -0
index 506463c..40aabb6 100644

arch/arm/Kconfig config TARGET_MX6SXSABRESD · line 585

Quoted 8 lines
arch/arm/Kconfig +5 -0
@@ -578,6 +578,12 @@ config TARGET_MX6SXSABRESD
        select DM
        select DM_THERMAL
 
+config TARGET_MX7DSABRESD
+       bool "Support mx7dsabresd"
+       select CPU_V7
+       select DM
+       select DM_THERMAL

This should not be part of this patch.

#19 lore raw

PATCH 11/11 imx: mx7dsabresd: Add support for MX7D SABRESD board

In reply to Adrian Alonso

* Add i.MX7D SABRESD board BSP codes, with enabled modules:
UART, PMIC, USB/OTG, SD, eMMC, ENET, I2C, 74LV IOX.

Build target: mx7dsabresd_config

---
 board/freescale/mx7dsabresd/Kconfig       |  15 +
 board/freescale/mx7dsabresd/Makefile      |   6 +
 board/freescale/mx7dsabresd/imximage.cfg  | 110 +++++
 board/freescale/mx7dsabresd/mx7dsabresd.c | 656 ++++++++++++++++++++++++++++++
 configs/mx7dsabresd_defconfig             |  10 +
 include/configs/mx7_common.h              |  22 +
 include/configs/mx7dsabresd.h             | 382 +++++++++++++++++
 7 files changed, 1201 insertions(+)
 create mode 100644 board/freescale/mx7dsabresd/Kconfig
 create mode 100644 board/freescale/mx7dsabresd/Makefile
 create mode 100644 board/freescale/mx7dsabresd/imximage.cfg
 create mode 100644 board/freescale/mx7dsabresd/mx7dsabresd.c
 create mode 100644 configs/mx7dsabresd_defconfig
 create mode 100644 include/configs/mx7_common.h
 create mode 100644 include/configs/mx7dsabresd.h
board/freescale/mx7dsabresd/Kconfig new file +15 -0
new file mode 100644
index 0000000..d7c6ae4
@@ -0,0 +1,15 @@
+if TARGET_MX7DSABRESD
+
+config SYS_BOARD
+	default "mx7dsabresd"
+
+config SYS_VENDOR
+	default "freescale"
+
+config SYS_SOC
+	default "mx7"
+
+config SYS_CONFIG_NAME
+	default "mx7dsabresd"
+
+endif
board/freescale/mx7dsabresd/Makefile new file +6 -0
new file mode 100644
index 0000000..14336ab
@@ -0,0 +1,6 @@
+# (C) Copyright 2015 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y  := mx7dsabresd.o
board/freescale/mx7dsabresd/imximage.cfg new file +110 -0

110 lines not on this page · raw message

board/freescale/mx7dsabresd/mx7dsabresd.c new file +656 -0

656 lines not on this page · raw message

configs/mx7dsabresd_defconfig new file +10 -0
new file mode 100644
index 0000000..879847c
@@ -0,0 +1,10 @@
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7dsabresd/imximage.cfg,MX7D"
+CONFIG_ARM=y
+CONFIG_TARGET_MX7DSABRESD=y
+CONFIG_SYS_MALLOC_F=y
+CONFIG_SYS_MALLOC_F_LEN=0x400
+# CONFIG_CMD_BOOTD is not set
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_XIMG is not set
include/configs/mx7_common.h new file +22 -0
new file mode 100644
index 0000000..25f79f3
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ *
+ * Configuration settings for the Freescale i.MX7.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+
+#ifndef __MX7_COMMON_H
+#define __MX7_COMMON_H
+
+#define CONFIG_BOARD_POSTCLK_INIT
+#define CONFIG_MXC_GPT_HCLK
+
+#define CONFIG_SYSCOUNTER_TIMER
+#define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
+
+#define CONFIG_IOMUX_LPSR
+#define CONFIG_IMX_FIXED_IVT_OFFSET
+
+#endif
include/configs/mx7dsabresd.h new file +382 -0

382 lines not on this page · raw message

Signature · 1 line
2.1.4
reviewer
#20 lore raw

PATCH 11/11 imx: mx7dsabresd: Add support for MX7D SABRESD board

Quoted 1 line · Adrian Alonso

* Add i.MX7D SABRESD board BSP codes, with enabled modules:

Better to remove "board BSP codes" as this is too vague.

Quoted 8 lines

UART, PMIC, USB/OTG, SD, eMMC, ENET, I2C, 74LV IOX.

Build target: mx7dsabresd_config

Quoted 16 lines
---
 board/freescale/mx7dsabresd/Kconfig       |  15 +
 board/freescale/mx7dsabresd/Makefile      |   6 +
 board/freescale/mx7dsabresd/imximage.cfg  | 110 +++++
 board/freescale/mx7dsabresd/mx7dsabresd.c | 656 ++++++++++++++++++++++++++++++
 configs/mx7dsabresd_defconfig             |  10 +
 include/configs/mx7_common.h              |  22 +
 include/configs/mx7dsabresd.h             | 382 +++++++++++++++++
 7 files changed, 1201 insertions(+)
 create mode 100644 board/freescale/mx7dsabresd/Kconfig
 create mode 100644 board/freescale/mx7dsabresd/Makefile
 create mode 100644 board/freescale/mx7dsabresd/imximage.cfg
 create mode 100644 board/freescale/mx7dsabresd/mx7dsabresd.c
 create mode 100644 configs/mx7dsabresd_defconfig
 create mode 100644 include/configs/mx7_common.h
 create mode 100644 include/configs/mx7dsabresd.h

You missed to add a MAINTAINERS file for this board.

Quoted 25 lines
board/freescale/mx7dsabresd/imximage.cfg new file +22 -0
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ *
+ * Refer docs/README.imxmage for more details about how-to configure
+ * and create imximage boot image
+ *
+ * The syntax is taken as close as possible with the kwbimage
+ */
+
+#define __ASSEMBLY__
+#include <config.h>
+
+/* image version */
+
+IMAGE_VERSION 2
+
+/*
+ * Boot Device : one of
+ * spi/sd/nand/onenand, qspi/nor
+ */

board/freescale/mx7dsabresd/imximage.cfg line 32

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+
+#ifdef CONFIG_SYS_BOOT_QSPI
+BOOT_FROM      qspi
+#elif defined(CONFIG_SYS_BOOT_EIMNOR)
+BOOT_FROM      nor
+#else
+BOOT_FROM      sd
+#endif
+
+#ifdef CONFIG_USE_PLUGIN

This option only exists in the FSL U-boot, not in mainline.

Quoted 16 lines
board/freescale/mx7dsabresd/imximage.cfg new file +15 -0
+/*PLUGIN    plugin-binary-file    IRAM_FREE_START_ADDR*/
+PLUGIN board/freescale/mx7dsabresd/plugin.bin 0x00910000
+#else
+
+#ifdef CONFIG_SECURE_BOOT
+CSF CONFIG_CSF_SIZE
+#endif
 
+#include <asm/arch/clock.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/mx7-pins.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/gpio.h>
+#include <asm/imx-common/iomux-v3.h>
+#include <asm/imx-common/boot_mode.h>
+#include <asm/io.h>

board/freescale/mx7dsabresd/imximage.cfg

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+#include <linux/sizes.h>
+#include <common.h>
+#include <fsl_esdhc.h>
+#include <mmc.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <power/pmic.h>
+#include <power/pfuze300_pmic.h>
+#include "../common/pfuze.h"
+#ifdef CONFIG_SYS_I2C_MXC

No need to use ifdef for header files.

board/freescale/mx7dsabresd/imximage.cfg

Quoted 6 lines
board/freescale/mx7dsabresd/imximage.cfg new file +6 -0
+static struct fsl_esdhc_cfg usdhc_cfg[3] = {
+       {USDHC1_BASE_ADDR, 0, 4},
+       {USDHC3_BASE_ADDR},
+};
+
+int mmc_get_env_devno(void)

static

Quoted 8 lines
board/freescale/mx7dsabresd/imximage.cfg new file +8 -0
+{
+       struct bootrom_sw_info **p =
+               (struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
+
+       u8 boot_type = (*p)->boot_dev_type;
+       u8 dev_no = (*p)->boot_dev_instance;
+
+       /* If not boot from sd/mmc, use default value */

board/freescale/mx7dsabresd/imximage.cfg

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+       if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
+               return CONFIG_SYS_MMC_ENV_DEV;
+
+       if (2 == dev_no)
+               dev_no--;
+
+       return dev_no;
+}
+
+int mmc_map_to_kernel_blk(int dev_no)

static

Quoted 49 lines
board/freescale/mx7dsabresd/imximage.cfg new file +49 -0
+{
+       if (1 == dev_no)
+               dev_no++;
+
+       return dev_no;
+}
+
+int board_mmc_getcd(struct mmc *mmc)
+{
+       struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+       int ret = 0;
+
+       switch (cfg->esdhc_base) {
+       case USDHC1_BASE_ADDR:
+               ret = !gpio_get_value(USDHC1_CD_GPIO);
+               break;
+       case USDHC3_BASE_ADDR:
+               ret = 1; /* Assume uSDHC3 emmc is always present */
+               break;
+       }
+
+       return ret;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       int i, ret;
+       /*
+        * According to the board_mmc_init() the following map is done:
+        * (U-boot device node)    (Physical Port)
+        * mmc0                    USDHC1
+        * mmc2                    USDHC3 (eMMC)
+        */
+       for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
+               switch (i) {
+               case 0:
+                       imx_iomux_v3_setup_multiple_pads(
+                               usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
+                       gpio_request(USDHC1_CD_GPIO, "usdhc1_cd");
+                       gpio_direction_input(USDHC1_CD_GPIO);
+                       gpio_request(USDHC1_PWR_GPIO, "usdhc1_pwr");
+                       gpio_direction_output(USDHC1_PWR_GPIO, 0);
+                       udelay(500);
+                       gpio_direction_output(USDHC1_PWR_GPIO, 1);
+                       usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+                       break;
+               case 1:
+                       imx_iomux_v3_setup_multiple_pads(
+                               usdhc3_emmc_pads, ARRAY_SIZE(usdhc3_emmc_pads));

board/freescale/mx7dsabresd/imximage.cfg

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+                       gpio_request(USDHC3_PWR_GPIO, "usdhc3_pwr");
+                       gpio_direction_output(USDHC3_PWR_GPIO, 0);
+                       udelay(500);
+                       gpio_direction_output(USDHC3_PWR_GPIO, 1);
+                       usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+                       break;
+               default:
+                       printf("Warning: you configured more USDHC controllers"
+                               "(%d) than supported by the board\n", i + 1);
+                       return 0;

You should return -EINVAL.

Quoted 65 lines
board/freescale/mx7dsabresd/imximage.cfg new file +65 -0
+                       }
+
+                       ret = fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
+                       if (ret)
+                               return ret;
+       }
+
+       return 0;
+}
+
+int check_mmc_autodetect(void)
+{
+       char *autodetect_str = getenv("mmcautodetect");
+
+       if ((autodetect_str != NULL) &&
+               (strcmp(autodetect_str, "yes") == 0)) {
+               return 1;
+       }
+
+       return 0;
+}
+
+void board_late_mmc_init(void)
+{
+       char cmd[32];
+       char mmcblk[32];
+       u32 dev_no = mmc_get_env_devno();
+
+       if (!check_mmc_autodetect())
+               return;
+
+       setenv_ulong("mmcdev", dev_no);
+
+       /* Set mmcblk env */
+       sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
+               mmc_map_to_kernel_blk(dev_no));
+       setenv("mmcroot", mmcblk);
+
+       sprintf(cmd, "mmc dev %d", dev_no);
+       run_command(cmd, 0);
+}
+
+#endif
+
+#ifdef CONFIG_FEC_MXC
+int board_eth_init(bd_t *bis)
+{
+       int ret;
+
+       setup_iomux_fec();
+
+       ret = fecmxc_initialize_multi(bis, 0,
+               CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE);
+       if (ret)
+               printf("FEC1 MXC: %s:failed\n", __func__);
+
+       return ret;
+}
+
+static int setup_fec(void)
+{
+       struct iomuxc_gpr_base_regs *const iomuxc_gpr_regs
+               = (struct iomuxc_gpr_base_regs *) IOMUXC_GPR_BASE_ADDR;
+       int ret;
+

board/freescale/mx7dsabresd/imximage.cfg

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+       /* Use 125M anatop REF_CLK1 for ENET1, clear gpr1[13], gpr1[17]*/
+       clrsetbits_le32(&iomuxc_gpr_regs->gpr[1],
+               (IOMUXC_GPR_GPR1_GPR_ENET1_TX_CLK_SEL_MASK |
+                IOMUXC_GPR_GPR1_GPR_ENET1_CLK_DIR_MASK), 0);
+
+       ret = set_clk_enet(ENET_125MHz);
+       if (ret)
+               return ret;
+
+       return 0;

You could return set_clk_enet

Quoted 13 lines
board/freescale/mx7dsabresd/imximage.cfg new file +13 -0
+#ifdef CONFIG_USB_EHCI_MX7
+iomux_v3_cfg_t const usb_otg1_pads[] = {
+       MX7D_PAD_GPIO1_IO05__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+iomux_v3_cfg_t const usb_otg2_pads[] = {
+       MX7D_PAD_UART3_CTS_B__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+int board_ehci_hcd_init(int port)
+{
+       switch (port) {
+       case 0:

board/freescale/mx7dsabresd/imximage.cfg

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+               imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
+                                                ARRAY_SIZE(usb_otg1_pads));
+               break;
+       case 1:
+               imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
+                                                ARRAY_SIZE(usb_otg2_pads));
+               break;
+       default:
+               printf("MXC USB port %d not yet supported\n", port);
+               return 1;

-EINVAL

board/freescale/mx7dsabresd/imximage.cfg

Quoted 10 lines
board/freescale/mx7dsabresd/imximage.cfg new file +10 -0
+       }
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_IMX_UDC
+void udc_pins_setting(void)
+{
+}
+

CONFIG_IMX_UDC does not exist in mainline U-boot.

Quoted 162 lines
board/freescale/mx7dsabresd/imximage.cfg new file +1 -0
+#endif /*CONFIG_IMX_UDC*/
configs/mx7dsabresd_defconfig new file +10 -0
new file mode 100644
index 0000000..879847c
@@ -0,0 +1,10 @@
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7dsabresd/imximage.cfg,MX7D"
+CONFIG_ARM=y
+CONFIG_TARGET_MX7DSABRESD=y
+CONFIG_SYS_MALLOC_F=y
+CONFIG_SYS_MALLOC_F_LEN=0x400
+# CONFIG_CMD_BOOTD is not set
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_XIMG is not set
include/configs/mx7_common.h new file +22 -0
new file mode 100644
index 0000000..25f79f3
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ *
+ * Configuration settings for the Freescale i.MX7.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+
+#ifndef __MX7_COMMON_H
+#define __MX7_COMMON_H
+
+#define CONFIG_BOARD_POSTCLK_INIT
+#define CONFIG_MXC_GPT_HCLK
+
+#define CONFIG_SYSCOUNTER_TIMER
+#define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
+
+#define CONFIG_IOMUX_LPSR
+#define CONFIG_IMX_FIXED_IVT_OFFSET
+
+#endif
include/configs/mx7dsabresd.h new file +111 -0
new file mode 100644
index 0000000..4119646
@@ -0,0 +1,382 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ *
+ * Configuration settings for the Freescale i.MX7D SABRESD board.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __MX7D_SABRESD_CONFIG_H
+#define __MX7D_SABRESD_CONFIG_H
+
+#include <asm/arch/imx-regs.h>
+#include <linux/sizes.h>
+#include "mx7_common.h"
+#include <asm/imx-common/gpio.h>
+
+#define CONFIG_MX7
+#define CONFIG_ROM_UNIFIED_SECTIONS
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_DISPLAY_CPUINFO
+#define CONFIG_DISPLAY_BOARDINFO
+
+#define CONFIG_DBG_MONITOR
+/* uncomment for PLUGIN mode support */
+/* #define CONFIG_USE_PLUGIN */
+
+/* uncomment for SECURE mode support */
+/* #define CONFIG_SECURE_BOOT */
+
+#ifdef CONFIG_SECURE_BOOT
+#ifndef CONFIG_CSF_SIZE
+#define CONFIG_CSF_SIZE 0x4000
+#endif
+#endif
+
+#define CONFIG_CMDLINE_TAG
+#define CONFIG_SETUP_MEMORY_TAGS
+#define CONFIG_INITRD_TAG
+#define CONFIG_REVISION_TAG
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (32 * SZ_1M)
+
+#define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_LATE_INIT
+#define CONFIG_MXC_GPIO
+
+#define CONFIG_MXC_UART
+#define CONFIG_MXC_UART_BASE           UART1_IPS_BASE_ADDR
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_CONS_INDEX              1
+#define CONFIG_BAUDRATE                        115200
+
+#define CONFIG_CMD_FUSE
+#ifdef CONFIG_CMD_FUSE
+#define CONFIG_MXC_OCOTP
+#endif
+
+/* MMC Configs */
+#define CONFIG_FSL_ESDHC
+#define CONFIG_FSL_USDHC
+#define CONFIG_SYS_FSL_ESDHC_ADDR      0
+
+#define CONFIG_MMC
+#define CONFIG_CMD_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */
+
+#define PHYS_SDRAM_SIZE                        SZ_1G
+
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_MII
+#define CONFIG_FEC_MXC
+#define CONFIG_MII
+#define CONFIG_FEC_XCV_TYPE             RGMII
+#define CONFIG_ETHPRIME                 "FEC"
+#define CONFIG_FEC_MXC_PHYADDR          0
+
+#define CONFIG_PHYLIB
+#define CONFIG_PHY_BROADCOM
+#define CONFIG_FEC_DMA_MINALIGN                64
+
+/* ENET1 */
+#define IMX_FEC_BASE                   ENET_IPS_BASE_ADDR
+
+/* PMIC */
+#define CONFIG_POWER
+#define CONFIG_POWER_I2C
+#define CONFIG_POWER_PFUZE300
+#define CONFIG_POWER_PFUZE300_I2C_ADDR 0x08
+
+#undef CONFIG_BOOTM_NETBSD
+#undef CONFIG_BOOTM_PLAN9
+#undef CONFIG_BOOTM_RTEMS
+
+#undef CONFIG_CMD_EXPORTENV
+#undef CONFIG_CMD_IMPORTENV
+
+/* I2C configs */
+#define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MXC
+#define CONFIG_SYS_I2C_MXC_I2C1
+#define CONFIG_SYS_I2C_SPEED           100000
+
+#undef CONFIG_CMD_IMLS

include/configs/mx7dsabresd.h line 121

Quoted 10 lines
include/configs/mx7dsabresd.h new file +10 -0
+
+#define CONFIG_BOOTDELAY               3
+
+#define CONFIG_LOADADDR                        0x80800000
+#define CONFIG_SYS_TEXT_BASE           0x87800000
+
+#define CONFIG_SYS_AUXCORE_BOOTDATA 0x60000000 /* Set to QSPI1 A flash at default */
+#define CONFIG_CMD_BOOTAUX /* Boot M4 */
+
+#ifdef CONFIG_CMD_BOOTAUX

This config option does not exist in U-boot mainline.

include/configs/mx7dsabresd.h line 255

Quoted 4 lines
include/configs/mx7dsabresd.h new file +4 -0
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT              "=> "

This is the default prompt, no need to set it explicitly.

include/configs/mx7dsabresd.h line 260

Quoted 5 lines
include/configs/mx7dsabresd.h new file +5 -0
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_CBSIZE              1024
+
+/* Print Buffer Size */
+#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)

Please remove this line, as it is better to use the default. This value can cause a U-boot hang if the maximum allowed number of strings is entered in console.

#21 lore raw

PATCH v2 1/11 imx: imximage: add new CHECK/CLR BIT command

In reply to Adrian Alonso

Hi Adrian, hi Peng,

Quoted 55 lines · Adrian Alonso

* Extend imximage DCD version 2 to support DCD commands CMD_WRITE_CLR_BIT 4 [address] [mask bit] means:

    while ((*address & ~mask) != 0);
  CMD_CHECK_BITS_SET 4 [address] [mask bit] means:
    while ((*address & mask) != mask);
  CMD_CHECK_BITS_CLR 4 [address] [mask bit] means:
    *address = *address & ~mask;

* Add set_dcd_param_v2 helper function to set DCD
command parameters

---
Changes for V2
- Add set_dcd_param_v2 helper function to set DCD command tag and parameters

 tools/imximage.c | 99 ++++++++++++++++++++++++++++++++++++++++++++------------
 tools/imximage.h | 25 ++++++++++----
 2 files changed, 97 insertions(+), 27 deletions(-)
tools/imximage.c +6 -2
index 6f469ae..cc0392f 100644
@@ -21,7 +21,10 @@
 static table_entry_t imximage_cmds[] = {
 	{CMD_BOOT_FROM,         "BOOT_FROM",            "boot command",	  },
 	{CMD_BOOT_OFFSET,       "BOOT_OFFSET",          "Boot offset",	  },
-	{CMD_DATA,              "DATA",                 "Reg Write Data", },
+	{CMD_WRITE_DATA,        "DATA",                 "Reg Write Data", },
+	{CMD_WRITE_CLR_BIT,     "CLR_BIT",              "Reg clear bit",  },
+	{CMD_CHECK_BITS_SET,    "CHECK_BITS_SET",   "Reg Check bits set", },
+	{CMD_CHECK_BITS_CLR,    "CHECK_BITS_CLR",   "Reg Check bits clr", },
 	{CMD_CSF,               "CSF",           "Command Sequence File", },
 	{CMD_IMAGE_VERSION,     "IMAGE_VERSION",        "image version",  },
 	{-1,                    "",                     "",	          },
@@ -62,7 +65,7 @@ static table_entry_t imximage_boot_loadsize[] = {
  */
 static table_entry_t imximage_versions[] = {
 	{IMXIMAGE_V1,	"",	" (i.MX25/35/51 compatible)", },
-	{IMXIMAGE_V2,	"",	" (i.MX53/6 compatible)",     },
+	{IMXIMAGE_V2,	"",	" (i.MX53/6/7 compatible)",   },
 	{-1,            "",     " (Invalid)",                 },
 };
 
@@ -79,6 +82,7 @@ static uint32_t imximage_csf_size = UNDEFINED;
 static uint32_t imximage_init_loadsize;
 
 static set_dcd_val_t set_dcd_val;
+static set_dcd_param_t set_dcd_param;
 static set_dcd_rst_t set_dcd_rst;
 static set_imx_hdr_t set_imx_hdr;
 static uint32_t max_dcd_entries;

tools/imximage.c static void err_imximage_version(int version) · line 139

Quoted 8 lines
tools/imximage.c +5 -0
@@ -128,6 +132,12 @@ static void err_imximage_version(int version)
 	exit(EXIT_FAILURE);
 }
 
+static void set_dcd_param_v1(struct imx_header *imxhdr, uint32_t dcd_len,
+		int32_t cmd)
+{
+	/* DCD V1 no parameter settings */
+}

It is better you check if you drop this and you check if the pointer is set to NULL before calling.

Quoted 22 lines
tools/imximage.c +15 -0
+
 static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno,
 					int fld, uint32_t value, uint32_t off)
 {
@@ -156,6 +166,43 @@ static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno,
 	}
 }
 
+static void set_dcd_param_v2(struct imx_header *imxhdr, uint32_t dcd_len,
+		int32_t cmd)
+{
+	dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.dcd_table;
+
+	switch (cmd) {
+	case CMD_WRITE_DATA:
+		dcd_v2->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG;
+		dcd_v2->write_dcd_command.length = cpu_to_be16(
+				dcd_len * sizeof(dcd_addr_data_t) + 4);
+		dcd_v2->write_dcd_command.param = DCD_WRITE_DATA_PARAM;
+		break;
+	case CMD_WRITE_CLR_BIT:
+		dcd_v2->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG;

tools/imximage.c static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno, · line 192

Quoted 10 lines
tools/imximage.c +10 -0
+		dcd_v2->write_dcd_command.length = cpu_to_be16(
+				dcd_len * sizeof(dcd_addr_data_t) + 4);
+		dcd_v2->write_dcd_command.param = DCD_WRITE_CLR_BIT_PARAM;
+		break;
+	case CMD_CHECK_BITS_SET:
+		dcd_v2->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG;
+		/*
+		 * Check data command only supports one entry,
+		 * so use 0xC = size(address + value + command).
+		 */

Comment applied to both CHECK_BITS, you could move it before (or put it also in CMD_CHECK_BITS_CLR case).

Quoted 72 lines
tools/imximage.c +21 -16
+		dcd_v2->write_dcd_command.length = cpu_to_be16(0xC);
+		dcd_v2->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM;
+		break;
+	case CMD_CHECK_BITS_CLR:
+		dcd_v2->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG;
+		dcd_v2->write_dcd_command.length = cpu_to_be16(0xC);
+		dcd_v2->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM;
+		break;
+	default:
+		break;
+	}
+}
+
 static void set_dcd_val_v2(struct imx_header *imxhdr, char *name, int lineno,
 					int fld, uint32_t value, uint32_t off)
 {
@@ -200,10 +247,7 @@ static void set_dcd_rst_v2(struct imx_header *imxhdr, uint32_t dcd_len,
 	dcd_v2->header.length = cpu_to_be16(
 			dcd_len * sizeof(dcd_addr_data_t) + 8);
 	dcd_v2->header.version = DCD_VERSION;
-	dcd_v2->write_dcd_command.tag = DCD_COMMAND_TAG;
-	dcd_v2->write_dcd_command.length = cpu_to_be16(
-			dcd_len * sizeof(dcd_addr_data_t) + 4);
-	dcd_v2->write_dcd_command.param = DCD_COMMAND_PARAM;
+	set_dcd_param_v2(imxhdr, dcd_len, CMD_WRITE_DATA);
 }
 
 static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len,
@@ -266,12 +310,14 @@ static void set_hdr_func(void)
 	switch (imximage_version) {
 	case IMXIMAGE_V1:
 		set_dcd_val = set_dcd_val_v1;
+		set_dcd_param = set_dcd_param_v1;
 		set_dcd_rst = set_dcd_rst_v1;
 		set_imx_hdr = set_imx_hdr_v1;
 		max_dcd_entries = MAX_HW_CFG_SIZE_V1;
 		break;
 	case IMXIMAGE_V2:
 		set_dcd_val = set_dcd_val_v2;
+		set_dcd_param = set_dcd_param_v2;
 		set_dcd_rst = set_dcd_rst_v2;
 		set_imx_hdr = set_imx_hdr_v2;
 		max_dcd_entries = MAX_HW_CFG_SIZE_V2;
@@ -396,8 +442,12 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
 		if (unlikely(cmd_ver_first != 1))
 			cmd_ver_first = 0;
 		break;
-	case CMD_DATA:
+	case CMD_WRITE_DATA:
+	case CMD_WRITE_CLR_BIT:
+	case CMD_CHECK_BITS_SET:
+	case CMD_CHECK_BITS_CLR:
 		value = get_cfg_value(token, name, lineno);
+		(*set_dcd_param)(imxhdr, dcd_len, cmd);
 		(*set_dcd_val)(imxhdr, name, lineno, fld, value, dcd_len);
 		if (unlikely(cmd_ver_first != 1))
 			cmd_ver_first = 0;
@@ -436,20 +486,29 @@ static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd,
 		break;
 	case CFG_REG_ADDRESS:
 	case CFG_REG_VALUE:
-		if (*cmd != CMD_DATA)
-			return;
-
-		value = get_cfg_value(token, name, lineno);
-		(*set_dcd_val)(imxhdr, name, lineno, fld, value, *dcd_len);
-
-		if (fld == CFG_REG_VALUE) {
-			(*dcd_len)++;
-			if (*dcd_len > max_dcd_entries) {
-				fprintf(stderr, "Error: %s[%d] -"
-					"DCD table exceeds maximum size(%d)\n",

tools/imximage.c static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd, · line 496

Quoted 10 lines
tools/imximage.c +8 -2
-					name, lineno, max_dcd_entries);
-				exit(EXIT_FAILURE);
+		switch(*cmd) {
+		case CMD_WRITE_DATA:
+		case CMD_WRITE_CLR_BIT:
+		case CMD_CHECK_BITS_SET:
+		case CMD_CHECK_BITS_CLR:
+
+			value = get_cfg_value(token, name, lineno);
+			(*set_dcd_param)(imxhdr, *dcd_len, *cmd);

What I meant before was:

	if (set_dcd_param)
		(*set_dcd_param)(imxhdr, *dcd_len, *cmd);

and then
case IMXIMAGE_V1:
set_dcd_val = set_dcd_val_v1;
+ set_dcd_param = NULL;

Quoted 60 lines
tools/imximage.c +14 -0
+			(*set_dcd_val)(imxhdr, name, lineno, fld, value,
+					*dcd_len);
+
+			if (fld == CFG_REG_VALUE) {
+				(*dcd_len)++;
+				if (*dcd_len > max_dcd_entries) {
+					fprintf(stderr, "Error: %s[%d] -"
+						"DCD table exceeds maximum size(%d)\n",
+						name, lineno, max_dcd_entries);
+					exit(EXIT_FAILURE);
+				}
 			}
+			break;
+		default:
+			break;
 		}
 		break;
 	default:
tools/imximage.h +15 -7
index 36fe095..c199814 100644
@@ -42,19 +42,27 @@
 #define FLASH_LOADSIZE_SATA		FLASH_LOADSIZE_STANDARD
 #define FLASH_LOADSIZE_QSPI		0x0 /* entire image */
 
-#define IVT_HEADER_TAG 0xD1
-#define IVT_VERSION 0x40
-#define DCD_HEADER_TAG 0xD2
-#define DCD_COMMAND_TAG 0xCC
-#define DCD_VERSION 0x40
-#define DCD_COMMAND_PARAM 0x4
+/* Command tags and parameters */
+#define IVT_HEADER_TAG			0xD1
+#define IVT_VERSION			0x40
+#define DCD_HEADER_TAG			0xD2
+#define DCD_VERSION			0x40
+#define DCD_WRITE_DATA_COMMAND_TAG	0xCC
+#define DCD_WRITE_DATA_PARAM		0x4
+#define DCD_WRITE_CLR_BIT_PARAM	0xC
+#define DCD_CHECK_DATA_COMMAND_TAG	0xCF
+#define DCD_CHECK_BITS_SET_PARAM	0x14
+#define DCD_CHECK_BITS_CLR_PARAM	0x04
 
 enum imximage_cmd {
 	CMD_INVALID,
 	CMD_IMAGE_VERSION,
 	CMD_BOOT_FROM,
 	CMD_BOOT_OFFSET,
-	CMD_DATA,
+	CMD_WRITE_DATA,
+	CMD_WRITE_CLR_BIT,
+	CMD_CHECK_BITS_SET,
+	CMD_CHECK_BITS_CLR,
 	CMD_CSF,
 };
 

tools/imximage.h typedef void (*set_dcd_val_t)(struct imx_header *imxhdr, · line 183

Quoted 9 lines
tools/imximage.h +3 -0
@@ -167,6 +175,9 @@ typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
 					int fld, uint32_t value,
 					uint32_t off);
 
+typedef void (*set_dcd_param_t)(struct imx_header *imxhdr, uint32_t dcd_len,
+					int32_t cmd);
+
 typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr,
 					uint32_t dcd_len,
 					char *name, int lineno);

V2 looks like much more easier to understand - apart the very small comments, it is ok for me.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================