Skip to contentSkip to conversation

x86: timer: Use a separate flag for whether timer is inited

PATCH New Simon Glass 6 participants 201 messages Oct 21, 2019 – Nov 21, 2019 Page 2 of 2

Subsystems (6)
lore
Share & tools
lore
#149 lore raw

PATCH v3 84/108 spi: ich: Support hardware sequencing

In reply to Simon Glass

Apollolake (APL) only supports hardware sequencing. Add support for this into the SPI driver, as an option.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 205 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/spi/ich.h |  39 +++++++++
 2 files changed, 241 insertions(+), 3 deletions(-)
drivers/spi/ich.c +202 -3
index ae3bff36bba..ae1dc64bde8 100644
@@ -17,7 +17,9 @@
 #include <pci.h>
 #include <pci_ids.h>
 #include <spi.h>
+#include <spi_flash.h>
 #include <spi-mem.h>
+#include <asm/fast_spi.h>
 #include <asm/io.h>
 
 #include "ich.h"
@@ -36,6 +38,7 @@ struct ich_spi_platdata {
 	bool lockdown;			/* lock down controller settings? */
 	ulong mmio_base;		/* Base of MMIO registers */
 	pci_dev_t bdf;			/* PCI address used by of-platdata */
+	bool hwseq;			/* Use hardware sequencing (not s/w) */
 };
 
 static u8 ich_readb(struct ich_spi_priv *priv, int reg)
@@ -244,7 +247,8 @@ static void ich_spi_config_opcode(struct udevice *dev)
 	ich_writel(ctlr, SPI_OPMENU_UPPER, ctlr->opmenu + sizeof(u32));
 }
 
-static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
+static int ich_spi_exec_op_swseq(struct spi_slave *slave,
+				 const struct spi_mem_op *op)
 {
 	struct udevice *bus = dev_get_parent(slave->dev);
 	struct ich_spi_platdata *plat = dev_get_platdata(bus);
@@ -415,6 +419,197 @@ static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
 	return 0;
 }
 
+/*
+ * Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and
+ * that the operation does not cross page boundary.
+ */
+static uint get_xfer_len(u32 offset, int len, int page_size)
+{
+	uint xfer_len = min(len, SPIBAR_FDATA_FIFO_SIZE);
+	uint bytes_left = ALIGN(offset, page_size) - offset;
+
+	if (bytes_left)
+		xfer_len = min(xfer_len, bytes_left);
+
+	return xfer_len;
+}
+
+/* Fill FDATAn FIFO in preparation for a write transaction */
+static void fill_xfer_fifo(struct fast_spi_regs *regs, const void *data,
+			   uint len)
+{
+	memcpy(regs->fdata, data, len);
+}
+
+/* Drain FDATAn FIFO after a read transaction populates data */
+static void drain_xfer_fifo(struct fast_spi_regs *regs, void *dest, uint len)
+{
+	memcpy(dest, regs->fdata, len);
+}
+
+/* Fire up a transfer using the hardware sequencer */
+static void start_hwseq_xfer(struct fast_spi_regs *regs, uint hsfsts_cycle,
+			     uint offset, uint len)
+{
+	/* Make sure all W1C status bits get cleared */
+	u32 hsfsts;
+
+	hsfsts = readl(&regs->hsfsts_ctl);
+	hsfsts &= ~(HSFSTS_FCYCLE_MASK | HSFSTS_FDBC_MASK);
+	hsfsts |= HSFSTS_AEL | HSFSTS_FCERR | HSFSTS_FDONE;
+
+	/* Set up transaction parameters */
+	hsfsts |= hsfsts_cycle << HSFSTS_FCYCLE_SHIFT;
+	hsfsts |= ((len - 1) << HSFSTS_FDBC_SHIFT) & HSFSTS_FDBC_MASK;
+	hsfsts |= HSFSTS_FGO;
+
+	writel(offset, &regs->faddr);
+	writel(hsfsts, &regs->hsfsts_ctl);
+}
+
+static int wait_for_hwseq_xfer(struct fast_spi_regs *regs, uint offset)
+{
+	ulong start;
+	u32 hsfsts;
+
+	start = get_timer(0);
+	do {
+		hsfsts = readl(&regs->hsfsts_ctl);
+		if (hsfsts & HSFSTS_FCERR) {
+			debug("SPI transaction error at offset %x HSFSTS = %08x\n",
+			      offset, hsfsts);
+			return -EIO;
+		}
+		if (hsfsts & HSFSTS_AEL)
+			return -EPERM;
+
+		if (hsfsts & HSFSTS_FDONE)
+			return 0;
+	} while (get_timer(start) < SPIBAR_HWSEQ_XFER_TIMEOUT_MS);
+
+	debug("SPI transaction timeout@offset %x HSFSTS = %08x, timer %d\n",
+	      offset, hsfsts, (uint)get_timer(start));
+
+	return -ETIMEDOUT;
+}
+
+/**
+ * exec_sync_hwseq_xfer() - Execute FAST_SPI flash transfer
+ *
+ * This waits until complete or timeout
+ *
+ * @regs: SPI registers
+ * @hsfsts_cycle: Cycle type (enum hsfsts_cycle_t)
+ * @offset: Offset to access
+ * @len: Number of bytes to transfer (can be 0)
+ * @return 9 if OK, -EIO on flash-cycle error (FCERR), -EPERM on access error
+ *	(AEL), -ETIMEDOUT on timeout
+ */
+static int exec_sync_hwseq_xfer(struct fast_spi_regs *regs, uint hsfsts_cycle,
+				uint offset, uint len)
+{
+	start_hwseq_xfer(regs, hsfsts_cycle, offset, len);
+
+	return wait_for_hwseq_xfer(regs, offset);
+}
+
+static int ich_spi_exec_op_hwseq(struct spi_slave *slave,
+				 const struct spi_mem_op *op)
+{
+	struct spi_flash *flash = dev_get_uclass_priv(slave->dev);
+	struct udevice *bus = dev_get_parent(slave->dev);
+	struct ich_spi_priv *priv = dev_get_priv(bus);
+	struct fast_spi_regs *regs = priv->base;
+	uint page_size;
+	uint offset;
+	int cycle;
+	uint len;
+	bool out;
+	int ret;
+	u8 *buf;
+
+	offset = op->addr.val;
+	len = op->data.nbytes;
+
+	switch (op->cmd.opcode) {
+	case SPINOR_OP_RDID:
+		cycle = HSFSTS_CYCLE_RDID;
+		break;
+	case SPINOR_OP_READ_FAST:
+		cycle = HSFSTS_CYCLE_READ;
+		break;
+	case SPINOR_OP_PP:
+		cycle = HSFSTS_CYCLE_WRITE;
+		break;
+	case SPINOR_OP_WREN:
+		/* Nothing needs to be done */
+		return 0;
+	case SPINOR_OP_WRSR:
+		cycle = HSFSTS_CYCLE_WR_STATUS;
+		break;
+	case SPINOR_OP_RDSR:
+		cycle = HSFSTS_CYCLE_RD_STATUS;
+		break;
+	case SPINOR_OP_WRDI:
+		return 0;  /* ignore */
+	case SPINOR_OP_BE_4K:
+		cycle = HSFSTS_CYCLE_4K_ERASE;
+		while (len) {
+			uint xfer_len = 0x1000;
+
+			ret = exec_sync_hwseq_xfer(regs, cycle, offset, 0);
+			if (ret)
+				return ret;
+			offset += xfer_len;
+			len -= xfer_len;
+		}
+		return 0;
+	default:
+		debug("Unknown cycle %x\n", op->cmd.opcode);
+		return -EINVAL;
+	};
+
+	out = op->data.dir == SPI_MEM_DATA_OUT;
+	buf = out ? (u8 *)op->data.buf.out : op->data.buf.in;
+	page_size = flash->page_size ? : 256;
+
+	while (len) {
+		uint xfer_len = get_xfer_len(offset, len, page_size);
+
+		if (out)
+			fill_xfer_fifo(regs, buf, xfer_len);
+
+		ret = exec_sync_hwseq_xfer(regs, cycle, offset, xfer_len);
+		if (ret)
+			return ret;
+
+		if (!out)
+			drain_xfer_fifo(regs, buf, xfer_len);
+
+		offset += xfer_len;
+		buf += xfer_len;
+		len -= xfer_len;
+	}
+
+	return 0;
+}
+
+static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
+{
+	struct udevice *bus = dev_get_parent(slave->dev);
+	struct ich_spi_platdata *plat = dev_get_platdata(bus);
+	int ret;
+
+	bootstage_start(BOOTSTAGE_ID_ACCUM_SPI, "fast_spi");
+	if (plat->hwseq)
+		ret = ich_spi_exec_op_hwseq(slave, op);
+	else
+		ret = ich_spi_exec_op_swseq(slave, op);
+	bootstage_accum(BOOTSTAGE_ID_ACCUM_SPI);
+
+	return ret;
+}
+
 static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op)
 {
 	unsigned int page_offset;
@@ -585,9 +780,11 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
 
 	/*
 	 * Yes this controller can only write a small number of bytes at
-	 * once! The limit is typically 64 bytes.
+	 * once! The limit is typically 64 bytes. For hardware sequencing a
+	 * a loop is used to get around this.
 	 */
-	slave->max_write_size = priv->databytes;
+	if (!plat->hwseq)
+		slave->max_write_size = priv->databytes;
 	/*
 	 * ICH 7 SPI controller only supports array read command
 	 * and byte program command for SST flash
@@ -606,10 +803,12 @@ static int ich_spi_ofdata_to_platdata(struct udevice *dev)
 	plat->ich_version = dev_get_driver_data(dev);
 	plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down");
 	pch_get_spi_base(dev->parent, &plat->mmio_base);
+	plat->hwseq = dev_read_u32_default(dev, "intel,hardware-seq", 0);
 #else
 	plat->ich_version = ICHV_APL;
 	plat->mmio_base = plat->dtplat.early_regs[0];
 	plat->bdf = pci_x86_ofplat_get_devfn(plat->dtplat.reg[0]);
+	plat->hwseq = plat->dtplat.intel_hardware_seq;
 #endif
 	debug("%s: mmio_base=%lx\n", __func__, plat->mmio_base);
 
drivers/spi/ich.h +39 -0
index 623b2c547a6..c7cf37b9321 100644
@@ -163,6 +163,45 @@ struct spi_trans {
 
 #define ICH_BOUNDARY	0x1000
 
+#define HSFSTS_FDBC_SHIFT	24
+#define HSFSTS_FDBC_MASK	(0x3f << HSFSTS_FDBC_SHIFT)
+#define HSFSTS_WET		BIT(21)
+#define HSFSTS_FCYCLE_SHIFT	17
+#define HSFSTS_FCYCLE_MASK	(0xf << HSFSTS_FCYCLE_SHIFT)
+
+/* Supported flash cycle types */
+enum hsfsts_cycle_t {
+	HSFSTS_CYCLE_READ	= 0,
+	HSFSTS_CYCLE_WRITE	= 2,
+	HSFSTS_CYCLE_4K_ERASE,
+	HSFSTS_CYCLE_64K_ERASE,
+	HSFSTS_CYCLE_RDSFDP,
+	HSFSTS_CYCLE_RDID,
+	HSFSTS_CYCLE_WR_STATUS,
+	HSFSTS_CYCLE_RD_STATUS,
+};
+
+#define HSFSTS_FGO		BIT(16)
+#define HSFSTS_FLOCKDN		BIT(15)
+#define HSFSTS_FDV		BIT(14)
+#define HSFSTS_FDOPSS		BIT(13)
+#define HSFSTS_WRSDIS		BIT(11)
+#define HSFSTS_SAF_CE		BIT(8)
+#define HSFSTS_SAF_ACTIVE	BIT(7)
+#define HSFSTS_SAF_LE		BIT(6)
+#define HSFSTS_SCIP		BIT(5)
+#define HSFSTS_SAF_DLE		BIT(4)
+#define HSFSTS_SAF_ERROR	BIT(3)
+#define HSFSTS_AEL		BIT(2)
+#define HSFSTS_FCERR		BIT(1)
+#define HSFSTS_FDONE		BIT(0)
+#define HSFSTS_W1C_BITS		0xff
+
+/* Maximum bytes of data that can fit in FDATAn (0x10) registers */
+#define SPIBAR_FDATA_FIFO_SIZE		0x40
+
+#define SPIBAR_HWSEQ_XFER_TIMEOUT_MS	5000
+
 enum ich_version {
 	ICHV_7,
 	ICHV_9,
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#150 lore raw

PATCH v3 84/108 spi: ich: Support hardware sequencing

Hi Simon,

Quoted 116 lines · Simon Glass

Apollolake (APL) only supports hardware sequencing. Add support for this into the SPI driver, as an option.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 205 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/spi/ich.h |  39 +++++++++
 2 files changed, 241 insertions(+), 3 deletions(-)
drivers/spi/ich.c +71 -1
index ae3bff36bba..ae1dc64bde8 100644
@@ -17,7 +17,9 @@
 #include <pci.h>
 #include <pci_ids.h>
 #include <spi.h>
+#include <spi_flash.h>
 #include <spi-mem.h>
+#include <asm/fast_spi.h>
 #include <asm/io.h>
 
 #include "ich.h"
@@ -36,6 +38,7 @@ struct ich_spi_platdata {
        bool lockdown;                  /* lock down controller settings? */
        ulong mmio_base;                /* Base of MMIO registers */
        pci_dev_t bdf;                  /* PCI address used by of-platdata */
+       bool hwseq;                     /* Use hardware sequencing (not s/w) */
 };
 
 static u8 ich_readb(struct ich_spi_priv *priv, int reg)
@@ -244,7 +247,8 @@ static void ich_spi_config_opcode(struct udevice *dev)
        ich_writel(ctlr, SPI_OPMENU_UPPER, ctlr->opmenu + sizeof(u32));
 }
 
-static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
+static int ich_spi_exec_op_swseq(struct spi_slave *slave,
+                                const struct spi_mem_op *op)
 {
        struct udevice *bus = dev_get_parent(slave->dev);
        struct ich_spi_platdata *plat = dev_get_platdata(bus);
@@ -415,6 +419,197 @@ static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
        return 0;
 }
 
+/*
+ * Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and
+ * that the operation does not cross page boundary.
+ */
+static uint get_xfer_len(u32 offset, int len, int page_size)
+{
+       uint xfer_len = min(len, SPIBAR_FDATA_FIFO_SIZE);
+       uint bytes_left = ALIGN(offset, page_size) - offset;
+
+       if (bytes_left)
+               xfer_len = min(xfer_len, bytes_left);
+
+       return xfer_len;
+}
+
+/* Fill FDATAn FIFO in preparation for a write transaction */
+static void fill_xfer_fifo(struct fast_spi_regs *regs, const void *data,
+                          uint len)
+{
+       memcpy(regs->fdata, data, len);
+}
+
+/* Drain FDATAn FIFO after a read transaction populates data */
+static void drain_xfer_fifo(struct fast_spi_regs *regs, void *dest, uint len)
+{
+       memcpy(dest, regs->fdata, len);
+}
+
+/* Fire up a transfer using the hardware sequencer */
+static void start_hwseq_xfer(struct fast_spi_regs *regs, uint hsfsts_cycle,
+                            uint offset, uint len)
+{
+       /* Make sure all W1C status bits get cleared */
+       u32 hsfsts;
+
+       hsfsts = readl(&regs->hsfsts_ctl);
+       hsfsts &= ~(HSFSTS_FCYCLE_MASK | HSFSTS_FDBC_MASK);
+       hsfsts |= HSFSTS_AEL | HSFSTS_FCERR | HSFSTS_FDONE;
+
+       /* Set up transaction parameters */
+       hsfsts |= hsfsts_cycle << HSFSTS_FCYCLE_SHIFT;
+       hsfsts |= ((len - 1) << HSFSTS_FDBC_SHIFT) & HSFSTS_FDBC_MASK;
+       hsfsts |= HSFSTS_FGO;
+
+       writel(offset, &regs->faddr);
+       writel(hsfsts, &regs->hsfsts_ctl);
+}
+
+static int wait_for_hwseq_xfer(struct fast_spi_regs *regs, uint offset)
+{
+       ulong start;
+       u32 hsfsts;
+
+       start = get_timer(0);
+       do {
+               hsfsts = readl(&regs->hsfsts_ctl);
+               if (hsfsts & HSFSTS_FCERR) {
+                       debug("SPI transaction error at offset %x HSFSTS = %08x\n",
+                             offset, hsfsts);
+                       return -EIO;
+               }
+               if (hsfsts & HSFSTS_AEL)
+                       return -EPERM;
+
+               if (hsfsts & HSFSTS_FDONE)
+                       return 0;

drivers/spi/ich.c static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) · line 497

Quoted 10 lines
drivers/spi/ich.c +10 -0
+       } while (get_timer(start) < SPIBAR_HWSEQ_XFER_TIMEOUT_MS);
+
+       debug("SPI transaction timeout at offset %x HSFSTS = %08x, timer %d\n",
+             offset, hsfsts, (uint)get_timer(start));
+
+       return -ETIMEDOUT;
+}
+
+/**
+ * exec_sync_hwseq_xfer() - Execute FAST_SPI flash transfer

Should we just mention this is flash transfer using hardware sequencer, instead of FAST_SPI?

drivers/spi/ich.c static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) · line 505

Quoted 8 lines
drivers/spi/ich.c +8 -0
+ *
+ * This waits until complete or timeout
+ *
+ * @regs: SPI registers
+ * @hsfsts_cycle: Cycle type (enum hsfsts_cycle_t)
+ * @offset: Offset to access
+ * @len: Number of bytes to transfer (can be 0)
+ * @return 9 if OK, -EIO on flash-cycle error (FCERR), -EPERM on access error

0 if OK

Quoted 178 lines
drivers/spi/ich.c +113 -2
+ *     (AEL), -ETIMEDOUT on timeout
+ */
+static int exec_sync_hwseq_xfer(struct fast_spi_regs *regs, uint hsfsts_cycle,
+                               uint offset, uint len)
+{
+       start_hwseq_xfer(regs, hsfsts_cycle, offset, len);
+
+       return wait_for_hwseq_xfer(regs, offset);
+}
+
+static int ich_spi_exec_op_hwseq(struct spi_slave *slave,
+                                const struct spi_mem_op *op)
+{
+       struct spi_flash *flash = dev_get_uclass_priv(slave->dev);
+       struct udevice *bus = dev_get_parent(slave->dev);
+       struct ich_spi_priv *priv = dev_get_priv(bus);
+       struct fast_spi_regs *regs = priv->base;
+       uint page_size;
+       uint offset;
+       int cycle;
+       uint len;
+       bool out;
+       int ret;
+       u8 *buf;
+
+       offset = op->addr.val;
+       len = op->data.nbytes;
+
+       switch (op->cmd.opcode) {
+       case SPINOR_OP_RDID:
+               cycle = HSFSTS_CYCLE_RDID;
+               break;
+       case SPINOR_OP_READ_FAST:
+               cycle = HSFSTS_CYCLE_READ;
+               break;
+       case SPINOR_OP_PP:
+               cycle = HSFSTS_CYCLE_WRITE;
+               break;
+       case SPINOR_OP_WREN:
+               /* Nothing needs to be done */
+               return 0;
+       case SPINOR_OP_WRSR:
+               cycle = HSFSTS_CYCLE_WR_STATUS;
+               break;
+       case SPINOR_OP_RDSR:
+               cycle = HSFSTS_CYCLE_RD_STATUS;
+               break;
+       case SPINOR_OP_WRDI:
+               return 0;  /* ignore */
+       case SPINOR_OP_BE_4K:
+               cycle = HSFSTS_CYCLE_4K_ERASE;
+               while (len) {
+                       uint xfer_len = 0x1000;
+
+                       ret = exec_sync_hwseq_xfer(regs, cycle, offset, 0);
+                       if (ret)
+                               return ret;
+                       offset += xfer_len;
+                       len -= xfer_len;
+               }
+               return 0;
+       default:
+               debug("Unknown cycle %x\n", op->cmd.opcode);
+               return -EINVAL;
+       };
+
+       out = op->data.dir == SPI_MEM_DATA_OUT;
+       buf = out ? (u8 *)op->data.buf.out : op->data.buf.in;
+       page_size = flash->page_size ? : 256;
+
+       while (len) {
+               uint xfer_len = get_xfer_len(offset, len, page_size);
+
+               if (out)
+                       fill_xfer_fifo(regs, buf, xfer_len);
+
+               ret = exec_sync_hwseq_xfer(regs, cycle, offset, xfer_len);
+               if (ret)
+                       return ret;
+
+               if (!out)
+                       drain_xfer_fifo(regs, buf, xfer_len);
+
+               offset += xfer_len;
+               buf += xfer_len;
+               len -= xfer_len;
+       }
+
+       return 0;
+}
+
+static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
+{
+       struct udevice *bus = dev_get_parent(slave->dev);
+       struct ich_spi_platdata *plat = dev_get_platdata(bus);
+       int ret;
+
+       bootstage_start(BOOTSTAGE_ID_ACCUM_SPI, "fast_spi");
+       if (plat->hwseq)
+               ret = ich_spi_exec_op_hwseq(slave, op);
+       else
+               ret = ich_spi_exec_op_swseq(slave, op);
+       bootstage_accum(BOOTSTAGE_ID_ACCUM_SPI);
+
+       return ret;
+}
+
 static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op)
 {
        unsigned int page_offset;
@@ -585,9 +780,11 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
 
        /*
         * Yes this controller can only write a small number of bytes at
-        * once! The limit is typically 64 bytes.
+        * once! The limit is typically 64 bytes. For hardware sequencing a
+        * a loop is used to get around this.
         */
-       slave->max_write_size = priv->databytes;
+       if (!plat->hwseq)
+               slave->max_write_size = priv->databytes;
        /*
         * ICH 7 SPI controller only supports array read command
         * and byte program command for SST flash
@@ -606,10 +803,12 @@ static int ich_spi_ofdata_to_platdata(struct udevice *dev)
        plat->ich_version = dev_get_driver_data(dev);
        plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down");
        pch_get_spi_base(dev->parent, &plat->mmio_base);
+       plat->hwseq = dev_read_u32_default(dev, "intel,hardware-seq", 0);
 #else
        plat->ich_version = ICHV_APL;
        plat->mmio_base = plat->dtplat.early_regs[0];
        plat->bdf = pci_x86_ofplat_get_devfn(plat->dtplat.reg[0]);
+       plat->hwseq = plat->dtplat.intel_hardware_seq;
 #endif
        debug("%s: mmio_base=%lx\n", __func__, plat->mmio_base);
 
drivers/spi/ich.h +33 -0
index 623b2c547a6..c7cf37b9321 100644
@@ -163,6 +163,45 @@ struct spi_trans {
 
 #define ICH_BOUNDARY   0x1000
 
+#define HSFSTS_FDBC_SHIFT      24
+#define HSFSTS_FDBC_MASK       (0x3f << HSFSTS_FDBC_SHIFT)
+#define HSFSTS_WET             BIT(21)
+#define HSFSTS_FCYCLE_SHIFT    17
+#define HSFSTS_FCYCLE_MASK     (0xf << HSFSTS_FCYCLE_SHIFT)
+
+/* Supported flash cycle types */
+enum hsfsts_cycle_t {
+       HSFSTS_CYCLE_READ       = 0,
+       HSFSTS_CYCLE_WRITE      = 2,
+       HSFSTS_CYCLE_4K_ERASE,
+       HSFSTS_CYCLE_64K_ERASE,
+       HSFSTS_CYCLE_RDSFDP,
+       HSFSTS_CYCLE_RDID,
+       HSFSTS_CYCLE_WR_STATUS,
+       HSFSTS_CYCLE_RD_STATUS,
+};
+
+#define HSFSTS_FGO             BIT(16)
+#define HSFSTS_FLOCKDN         BIT(15)
+#define HSFSTS_FDV             BIT(14)
+#define HSFSTS_FDOPSS          BIT(13)
+#define HSFSTS_WRSDIS          BIT(11)
+#define HSFSTS_SAF_CE          BIT(8)
+#define HSFSTS_SAF_ACTIVE      BIT(7)
+#define HSFSTS_SAF_LE          BIT(6)
+#define HSFSTS_SCIP            BIT(5)
+#define HSFSTS_SAF_DLE         BIT(4)
+#define HSFSTS_SAF_ERROR       BIT(3)
+#define HSFSTS_AEL             BIT(2)
+#define HSFSTS_FCERR           BIT(1)
+#define HSFSTS_FDONE           BIT(0)
+#define HSFSTS_W1C_BITS                0xff

drivers/spi/ich.h struct spi_trans {

Quoted 10 lines
drivers/spi/ich.h +6 -1
+
+/* Maximum bytes of data that can fit in FDATAn (0x10) registers */
+#define SPIBAR_FDATA_FIFO_SIZE         0x40
+
+#define SPIBAR_HWSEQ_XFER_TIMEOUT_MS   5000
+
 enum ich_version {
        ICHV_7,
        ICHV_9,
--

Regards,
Bin

#151 lore raw

PATCH v3 85/108 spi: ich: Add support for get_mmap() method

In reply to Simon Glass

Add this method so that the memory-mapped location of the SPI flash can be queried.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/spi/ich.c +32 -0
index ae1dc64bde8..ec0f77f6e40 100644
@@ -610,6 +610,37 @@ static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
 	return ret;
 }
 
+static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep,
+			    uint *map_sizep, uint *offsetp)
+{
+	pci_dev_t spi_bdf;
+
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+	struct pci_child_platdata *pplat = dev_get_parent_platdata(bus);
+
+	spi_bdf = pplat->devfn;
+#else
+	struct ich_spi_platdata *plat = dev_get_platdata(bus);
+
+	/*
+	 * We cannot rely on plat->bdf being set up yet since this method can
+	 * be called before the device is probed. Use the of-platdata directly
+	 * instead.
+	 */
+	spi_bdf = pci_x86_ofplat_get_devfn(plat->dtplat.reg[0]);
+#endif
+
+	return fast_spi_get_bios_mmap(spi_bdf, map_basep, map_sizep, offsetp);
+}
+
+static int ich_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep,
+			uint *offsetp)
+{
+	struct udevice *bus = dev_get_parent(dev);
+
+	return ich_get_mmap_bus(bus, map_basep, map_sizep, offsetp);
+}
+
 static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op)
 {
 	unsigned int page_offset;
@@ -826,6 +857,7 @@ static const struct dm_spi_ops ich_spi_ops = {
 	.set_speed	= ich_spi_set_speed,
 	.set_mode	= ich_spi_set_mode,
 	.mem_ops	= &ich_controller_mem_ops,
+	.get_mmap	= ich_get_mmap,
 	/*
 	 * cs_info is not needed, since we require all chip selects to be
 	 * in the device tree explicitly
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#152 lore raw

PATCH v3 85/108 spi: ich: Add support for get_mmap() method

Hi Simon,

Quoted 32 lines · Simon Glass

Add this method so that the memory-mapped location of the SPI flash can be queried.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/spi/ich.c +11 -0
index ae1dc64bde8..ec0f77f6e40 100644
@@ -610,6 +610,37 @@ static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
        return ret;
 }
 
+static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep,
+                           uint *map_sizep, uint *offsetp)
+{
+       pci_dev_t spi_bdf;
+
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct pci_child_platdata *pplat = dev_get_parent_platdata(bus);
+
+       spi_bdf = pplat->devfn;
+#else
+       struct ich_spi_platdata *plat = dev_get_platdata(bus);

drivers/spi/ich.c static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) · line 633

Quoted 10 lines
drivers/spi/ich.c +10 -0
+
+       /*
+        * We cannot rely on plat->bdf being set up yet since this method can
+        * be called before the device is probed. Use the of-platdata directly
+        * instead.
+        */
+       spi_bdf = pci_x86_ofplat_get_devfn(plat->dtplat.reg[0]);
+#endif
+
+       return fast_spi_get_bios_mmap(spi_bdf, map_basep, map_sizep, offsetp);

I think we should move fast_spi_get_bios_mmap() to this driver, instead of having the ICH driver depend on something external.

Quoted 14 lines
drivers/spi/ich.c +10 -0
+}
+
+static int ich_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep,
+                       uint *offsetp)
+{
+       struct udevice *bus = dev_get_parent(dev);
+
+       return ich_get_mmap_bus(bus, map_basep, map_sizep, offsetp);
+}
+
 static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op)
 {
        unsigned int page_offset;

drivers/spi/ich.c static const struct dm_spi_ops ich_spi_ops = {

Quoted 8 lines
drivers/spi/ich.c +1 -1
@@ -826,6 +857,7 @@ static const struct dm_spi_ops ich_spi_ops = {
        .set_speed      = ich_spi_set_speed,
        .set_mode       = ich_spi_set_mode,
        .mem_ops        = &ich_controller_mem_ops,
+       .get_mmap       = ich_get_mmap,
        /*
         * cs_info is not needed, since we require all chip selects to be
         * in the device tree explicitly
--

Regards,
Bin

#153 lore raw

PATCH v3 85/108 spi: ich: Add support for get_mmap() method

Hi BIn,

Quoted 41 lines · Bin Meng

Hi Simon,

Quoted 37 lines · Simon Glass

Add this method so that the memory-mapped location of the SPI flash can be queried.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/spi/ich.c +16 -0
index ae1dc64bde8..ec0f77f6e40 100644
@@ -610,6 +610,37 @@ static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
        return ret;
 }
 
+static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep,
+                           uint *map_sizep, uint *offsetp)
+{
+       pci_dev_t spi_bdf;
+
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+       struct pci_child_platdata *pplat = dev_get_parent_platdata(bus);
+
+       spi_bdf = pplat->devfn;
+#else
+       struct ich_spi_platdata *plat = dev_get_platdata(bus);
+
+       /*
+        * We cannot rely on plat->bdf being set up yet since this method can
+        * be called before the device is probed. Use the of-platdata directly
+        * instead.
Quoted 8 lines

drivers/spi/ich.c static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) · line 633

Quoted 5 lines
drivers/spi/ich.c +5 -0
+        */
+       spi_bdf = pci_x86_ofplat_get_devfn(plat->dtplat.reg[0]);
+#endif
+
+       return fast_spi_get_bios_mmap(spi_bdf, map_basep, map_sizep, offsetp);

I think we should move fast_spi_get_bios_mmap() to this driver, instead of having the ICH driver depend on something external.

The problem is that this function is needed in APL's cpu_spl.c to cache the BIOS region.and also by rom_load_image() to read from the mapped SPI flash.

This driver is in fact not normally included in TPL, since it is quite large and not needed.

So we have to call these functions from outside the driver and therefore it is best to have them in the arch-specific code.

It is in intel_common so is shared.

Regards,
Simon

#154 lore raw

PATCH v3 86/108 spi: ich: Add TPL support

In reply to Simon Glass

In TPL we want to reduce code size and support running with CONFIG_PCI disabled. Add special code to handle this using a fixed BAR programmed into the SPI on boot. Also cache the SPI flash to speed up boot.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/spi/ich.c +42 -4
index ec0f77f6e40..daa69c25a3a 100644
@@ -19,8 +19,10 @@
 #include <spi.h>
 #include <spi_flash.h>
 #include <spi-mem.h>
+#include <spl.h>
 #include <asm/fast_spi.h>
 #include <asm/io.h>
+#include <asm/mtrr.h>
 
 #include "ich.h"
 
@@ -114,6 +116,8 @@ static bool ich9_can_do_33mhz(struct udevice *dev)
 {
 	u32 fdod, speed;
 
+	if (!CONFIG_IS_ENABLED(PCI))
+		return false;
 	/* Observe SPI Descriptor Component Section 0 */
 	dm_pci_write_config32(dev->parent, 0xb0, 0x1000);
 
@@ -705,6 +709,15 @@ static int ich_init_controller(struct udevice *dev,
 			       struct ich_spi_platdata *plat,
 			       struct ich_spi_priv *ctlr)
 {
+	if (spl_phase() == PHASE_TPL) {
+		struct ich_spi_platdata *plat = dev_get_platdata(dev);
+		int ret;
+
+		ret = fast_spi_early_init(plat->bdf, plat->mmio_base);
+		if (ret)
+			return ret;
+	}
+
 	ctlr->base = (void *)plat->mmio_base;
 	if (plat->ich_version == ICHV_7) {
 		struct ich7_spi_regs *ich7_spi = ctlr->base;
@@ -753,6 +766,25 @@ static int ich_init_controller(struct udevice *dev,
 	return 0;
 }
 
+static int ich_cache_bios_region(struct udevice *dev)
+{
+	ulong map_base;
+	uint map_size;
+	uint offset;
+	ulong base;
+	int ret;
+
+	ret = ich_get_mmap_bus(dev, &map_base, &map_size, &offset);
+	if (ret)
+		return ret;
+
+	base = (4ULL << 30) - map_size;
+	mtrr_set_next_var(MTRR_TYPE_WRPROT, base, map_size);
+	log_debug("BIOS cache base=%lx, size=%x\n", base, (uint)map_size);
+
+	return 0;
+}
+
 static int ich_spi_probe(struct udevice *dev)
 {
 	struct ich_spi_platdata *plat = dev_get_platdata(dev);
@@ -766,10 +798,16 @@ static int ich_spi_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
-	ret = ich_protect_lockdown(dev);
-	if (ret)
-		return ret;
-
+	if (spl_phase() == PHASE_TPL) {
+		/* Cache the BIOS to speed things up */
+		ret = ich_cache_bios_region(dev);
+		if (ret)
+			return ret;
+	} else {
+		ret = ich_protect_lockdown(dev);
+		if (ret)
+			return ret;
+	}
 	priv->cur_speed = priv->max_speed;
 
 	return 0;
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#155 lore raw

PATCH v3 86/108 spi: ich: Add TPL support

Hi Simon,

Quoted 39 lines · Simon Glass

In TPL we want to reduce code size and support running with CONFIG_PCI disabled. Add special code to handle this using a fixed BAR programmed into the SPI on boot. Also cache the SPI flash to speed up boot.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/spi/ich.c +4 -0
index ec0f77f6e40..daa69c25a3a 100644
@@ -19,8 +19,10 @@
 #include <spi.h>
 #include <spi_flash.h>
 #include <spi-mem.h>
+#include <spl.h>
 #include <asm/fast_spi.h>
 #include <asm/io.h>
+#include <asm/mtrr.h>
 
 #include "ich.h"
 
@@ -114,6 +116,8 @@ static bool ich9_can_do_33mhz(struct udevice *dev)
 {
        u32 fdod, speed;
 
+       if (!CONFIG_IS_ENABLED(PCI))
+               return false;
        /* Observe SPI Descriptor Component Section 0 */
        dm_pci_write_config32(dev->parent, 0xb0, 0x1000);
 

drivers/spi/ich.c static int ich_init_controller(struct udevice *dev, · line 716

Quoted 8 lines
drivers/spi/ich.c +5 -0
@@ -705,6 +709,15 @@ static int ich_init_controller(struct udevice *dev,
                               struct ich_spi_platdata *plat,
                               struct ich_spi_priv *ctlr)
 {
+       if (spl_phase() == PHASE_TPL) {
+               struct ich_spi_platdata *plat = dev_get_platdata(dev);
+               int ret;
+
+               ret = fast_spi_early_init(plat->bdf, plat->mmio_base);

Can we move the fast_spi_early_init() contents to ich_spi_probe(), where the bios_cntl register is programmed to disable the write protect for ICH_V7? This helps reading as it's disabling write protect, but for different ICH SPI variants.

Quoted 45 lines
drivers/spi/ich.c +27 -4
+               if (ret)
+                       return ret;
+       }
+
        ctlr->base = (void *)plat->mmio_base;
        if (plat->ich_version == ICHV_7) {
                struct ich7_spi_regs *ich7_spi = ctlr->base;
@@ -753,6 +766,25 @@ static int ich_init_controller(struct udevice *dev,
        return 0;
 }
 
+static int ich_cache_bios_region(struct udevice *dev)
+{
+       ulong map_base;
+       uint map_size;
+       uint offset;
+       ulong base;
+       int ret;
+
+       ret = ich_get_mmap_bus(dev, &map_base, &map_size, &offset);
+       if (ret)
+               return ret;
+
+       base = (4ULL << 30) - map_size;
+       mtrr_set_next_var(MTRR_TYPE_WRPROT, base, map_size);
+       log_debug("BIOS cache base=%lx, size=%x\n", base, (uint)map_size);
+
+       return 0;
+}
+
 static int ich_spi_probe(struct udevice *dev)
 {
        struct ich_spi_platdata *plat = dev_get_platdata(dev);
@@ -766,10 +798,16 @@ static int ich_spi_probe(struct udevice *dev)
        if (ret)
                return ret;
 
-       ret = ich_protect_lockdown(dev);
-       if (ret)
-               return ret;
-
+       if (spl_phase() == PHASE_TPL) {
+               /* Cache the BIOS to speed things up */
+               ret = ich_cache_bios_region(dev);
+               if (ret)

drivers/spi/ich.c static int ich_spi_probe(struct udevice *dev)

Quoted 10 lines
drivers/spi/ich.c +6 -1
+                       return ret;
+       } else {
+               ret = ich_protect_lockdown(dev);
+               if (ret)
+                       return ret;
+       }
        priv->cur_speed = priv->max_speed;
 
        return 0;
--

Regards,
Bin

#156 lore raw

PATCH v3 86/108 spi: ich: Add TPL support

Hi Bin,

Quoted 42 lines · Bin Meng

Hi Simon,

Quoted 38 lines · Simon Glass

In TPL we want to reduce code size and support running with CONFIG_PCI disabled. Add special code to handle this using a fixed BAR programmed into the SPI on boot. Also cache the SPI flash to speed up boot.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)
drivers/spi/ich.c +4 -0
index ec0f77f6e40..daa69c25a3a 100644
@@ -19,8 +19,10 @@
 #include <spi.h>
 #include <spi_flash.h>
 #include <spi-mem.h>
+#include <spl.h>
 #include <asm/fast_spi.h>
 #include <asm/io.h>
+#include <asm/mtrr.h>
 
 #include "ich.h"
 
@@ -114,6 +116,8 @@ static bool ich9_can_do_33mhz(struct udevice *dev)
 {
        u32 fdod, speed;
 
+       if (!CONFIG_IS_ENABLED(PCI))
+               return false;
        /* Observe SPI Descriptor Component Section 0 */
        dm_pci_write_config32(dev->parent, 0xb0, 0x1000);
 
Quoted 14 lines

drivers/spi/ich.c static int ich_init_controller(struct udevice *dev, · line 716

Quoted 9 lines
drivers/spi/ich.c +5 -0
@@ -705,6 +709,15 @@ static int ich_init_controller(struct udevice *dev,
                               struct ich_spi_platdata *plat,
                               struct ich_spi_priv *ctlr)
 {
+       if (spl_phase() == PHASE_TPL) {
+               struct ich_spi_platdata *plat = dev_get_platdata(dev);
+               int ret;
+
+               ret = fast_spi_early_init(plat->bdf, plat->mmio_base);

Can we move the fast_spi_early_init() contents to ich_spi_probe(), where the bios_cntl register is programmed to disable the write protect for ICH_V7? This helps reading as it's disabling write protect, but for different ICH SPI variants.

That driver is not included in TPL. It adds about 7KB to code size and puts us very close to the limit.

Regards,
Simon

#157 lore raw

PATCH v3 87/108 spi: ich: Add Apollolake support

In reply to Simon Glass

Add support for Apollolake to the ICH driver. This involves adjusting the mmio address and skipping setting of the bbar.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 19 ++++++++++++++-----
 drivers/spi/ich.h |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/spi/ich.c +14 -5
index daa69c25a3a..77ab951edc1 100644
@@ -105,10 +105,12 @@ static void ich_set_bbar(struct ich_spi_priv *ctlr, uint32_t minaddr)
 	const uint32_t bbar_mask = 0x00ffff00;
 	uint32_t ichspi_bbar;
 
-	minaddr &= bbar_mask;
-	ichspi_bbar = ich_readl(ctlr, ctlr->bbar) & ~bbar_mask;
-	ichspi_bbar |= minaddr;
-	ich_writel(ctlr, ichspi_bbar, ctlr->bbar);
+	if (ctlr->bbar) {
+		minaddr &= bbar_mask;
+		ichspi_bbar = ich_readl(ctlr, ctlr->bbar) & ~bbar_mask;
+		ichspi_bbar |= minaddr;
+		ich_writel(ctlr, ichspi_bbar, ctlr->bbar);
+	}
 }
 
 /* @return 1 if the SPI flash supports the 33MHz speed */
@@ -748,6 +750,7 @@ static int ich_init_controller(struct udevice *dev,
 		ctlr->preop = offsetof(struct ich9_spi_regs, preop);
 		ctlr->bcr = offsetof(struct ich9_spi_regs, bcr);
 		ctlr->pr = &ich9_spi->pr[0];
+	} else if (plat->ich_version == ICHV_APL) {
 	} else {
 		debug("ICH SPI: Unrecognised ICH version %d\n",
 		      plat->ich_version);
@@ -871,7 +874,12 @@ static int ich_spi_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	plat->ich_version = dev_get_driver_data(dev);
 	plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down");
-	pch_get_spi_base(dev->parent, &plat->mmio_base);
+	if (plat->ich_version == ICHV_APL) {
+		plat->mmio_base = dm_pci_read_bar32(dev, 0);
+	} else  {
+		/* SBASE is similar */
+		pch_get_spi_base(dev->parent, &plat->mmio_base);
+	}
 	plat->hwseq = dev_read_u32_default(dev, "intel,hardware-seq", 0);
 #else
 	plat->ich_version = ICHV_APL;
@@ -905,6 +913,7 @@ static const struct dm_spi_ops ich_spi_ops = {
 static const struct udevice_id ich_spi_ids[] = {
 	{ .compatible = "intel,ich7-spi", ICHV_7 },
 	{ .compatible = "intel,ich9-spi", ICHV_9 },
+	{ .compatible = "intel,fast-spi", ICHV_APL },
 	{ }
 };
 
drivers/spi/ich.h +1 -0
index c7cf37b9321..d7f1ffdf37d 100644
@@ -205,6 +205,7 @@ enum hsfsts_cycle_t {
 enum ich_version {
 	ICHV_7,
 	ICHV_9,
+	ICHV_APL,
 };
 
 struct ich_spi_priv {
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#158 lore raw

PATCH v3 87/108 spi: ich: Add Apollolake support

Hi Simon,

Quoted 44 lines · Simon Glass

Add support for Apollolake to the ICH driver. This involves adjusting the mmio address and skipping setting of the bbar.

---

Changes in v3: None
Changes in v2: None

 drivers/spi/ich.c | 19 ++++++++++++++-----
 drivers/spi/ich.h |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/spi/ich.c +7 -4
index daa69c25a3a..77ab951edc1 100644
@@ -105,10 +105,12 @@ static void ich_set_bbar(struct ich_spi_priv *ctlr, uint32_t minaddr)
        const uint32_t bbar_mask = 0x00ffff00;
        uint32_t ichspi_bbar;
 
-       minaddr &= bbar_mask;
-       ichspi_bbar = ich_readl(ctlr, ctlr->bbar) & ~bbar_mask;
-       ichspi_bbar |= minaddr;
-       ich_writel(ctlr, ichspi_bbar, ctlr->bbar);
+       if (ctlr->bbar) {
+               minaddr &= bbar_mask;
+               ichspi_bbar = ich_readl(ctlr, ctlr->bbar) & ~bbar_mask;
+               ichspi_bbar |= minaddr;
+               ich_writel(ctlr, ichspi_bbar, ctlr->bbar);
+       }
 }
 
 /* @return 1 if the SPI flash supports the 33MHz speed */
@@ -748,6 +750,7 @@ static int ich_init_controller(struct udevice *dev,
                ctlr->preop = offsetof(struct ich9_spi_regs, preop);
                ctlr->bcr = offsetof(struct ich9_spi_regs, bcr);
                ctlr->pr = &ich9_spi->pr[0];
+       } else if (plat->ich_version == ICHV_APL) {
        } else {
                debug("ICH SPI: Unrecognised ICH version %d\n",
                      plat->ich_version);

drivers/spi/ich.c static int ich_spi_ofdata_to_platdata(struct udevice *dev) · line 881

Quoted 9 lines
drivers/spi/ich.c +5 -1
@@ -871,7 +874,12 @@ static int ich_spi_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        plat->ich_version = dev_get_driver_data(dev);
        plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down");
-       pch_get_spi_base(dev->parent, &plat->mmio_base);
+       if (plat->ich_version == ICHV_APL) {
+               plat->mmio_base = dm_pci_read_bar32(dev, 0);
+       } else  {
+               /* SBASE is similar */
+               pch_get_spi_base(dev->parent, &plat->mmio_base);

priv->pch, instead of dev->parent?

Quoted 17 lines
drivers/spi/ich.c +2 -0
+       }
        plat->hwseq = dev_read_u32_default(dev, "intel,hardware-seq", 0);
 #else
        plat->ich_version = ICHV_APL;
@@ -905,6 +913,7 @@ static const struct dm_spi_ops ich_spi_ops = {
 static const struct udevice_id ich_spi_ids[] = {
        { .compatible = "intel,ich7-spi", ICHV_7 },
        { .compatible = "intel,ich9-spi", ICHV_9 },
+       { .compatible = "intel,fast-spi", ICHV_APL },
        { }
 };
 
drivers/spi/ich.h +0 -0
index c7cf37b9321..d7f1ffdf37d 100644

drivers/spi/ich.h enum hsfsts_cycle_t {

Quoted 8 lines
drivers/spi/ich.h +1 -1
@@ -205,6 +205,7 @@ enum hsfsts_cycle_t {
 enum ich_version {
        ICHV_7,
        ICHV_9,
+       ICHV_APL,
 };
 
 struct ich_spi_priv {
--

Regards,
Bin

#159 lore raw

PATCH v3 88/108 mtd: spi: Export spi_flash_std_probe()

In reply to Simon Glass

With of-platdata we need to create drivers for particular chips, or at least drivers that are separate from the standard code, since C structures are created by dtoc which are private to that driver.

To avoid duplicating the probing code, export this probe function for use by these drivers.

---

Changes in v3: None
Changes in v2: None

 drivers/mtd/spi/sf_probe.c |  2 +-
 include/spi_flash.h        | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/mtd/spi/sf_probe.c +1 -1
index 73297e1a0a5..755aba27116 100644
@@ -137,7 +137,7 @@ static int spi_flash_std_get_sw_write_prot(struct udevice *dev)
 	return spi_flash_cmd_get_sw_write_prot(flash);
 }
 
-static int spi_flash_std_probe(struct udevice *dev)
+int spi_flash_std_probe(struct udevice *dev)
 {
 	struct spi_slave *slave = dev_get_parent_priv(dev);
 	struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
include/spi_flash.h +12 -0
index 55b4721813a..0b23f57a71b 100644
@@ -102,6 +102,18 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len);
  */
 int spl_flash_get_sw_write_prot(struct udevice *dev);
 
+/**
+ * spi_flash_std_probe() - Probe a SPI flash device
+ *
+ * This is the standard internal method for probing a SPI flash device to
+ * determine its type. It can be used in chip-specific drivers which need to
+ * do this, typically with of-platdata
+ *
+ * @dev: SPI-flash device to probe
+ * @return 0 if OK, -ve on error
+ */
+int spi_flash_std_probe(struct udevice *dev);
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
 			   unsigned int max_hz, unsigned int spi_mode,
 			   struct udevice **devp);
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#160 lore raw

PATCH v3 88/108 mtd: spi: Export spi_flash_std_probe()

Quoted 9 lines · Simon Glass

With of-platdata we need to create drivers for particular chips, or at least drivers that are separate from the standard code, since C structures are created by dtoc which are private to that driver.

To avoid duplicating the probing code, export this probe function for use by these drivers.

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 drivers/mtd/spi/sf_probe.c |  2 +-
 include/spi_flash.h        | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
#161 lore raw

PATCH v3 89/108 x86: apollolake: Add basic IO addresses

In reply to Simon Glass

Add some fixed IO and mmap addresses for use in the device tree and with some early-init code.

---

Changes in v3: None
Changes in v2: None

 arch/x86/include/asm/arch-apollolake/iomap.h | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 arch/x86/include/asm/arch-apollolake/iomap.h
arch/x86/include/asm/arch-apollolake/iomap.h new file +28 -0
new file mode 100644
index 00000000000..200c76a8eef
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2017 Intel Corporation.
+ * Take from coreboot project file of the same name
+ */
+
+#ifndef __ARCH_IOMAP_H
+#define __ARCH_IOMAP_H
+
+#define TCO_BASE_ADDRESS	(ACPI_BASE_ADDRESS + 0x60)
+#define TCO_BASE_SIZE		0x20
+
+#define R_ACPI_PM1_TMR			0x8
+
+/* Put p2sb at 0xd0000000 in TPL */
+#define IOMAP_P2SB_BAR		0xd0000000
+
+#define IOMAP_SPI_BASE		0xfe010000
+/*
+ * Use UART2. To use UART1 you need to set '2' to '1', change device tree serial
+ * node name and 'reg' property, and update CONFIG_DEBUG_UART_BASE.
+ */
+#define PCH_DEV_UART		PCI_BDF(0, 0x18, 2)
+
+#define PCH_DEV_LPC		PCI_BDF(0, 0x1f, 0)
+#define PCH_DEV_SPI		PCI_BDF(0, 0x0d, 2)
+
+#endif
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#162 lore raw

PATCH v3 89/108 x86: apollolake: Add basic IO addresses

Quoted 5 lines · Simon Glass

Add some fixed IO and mmap addresses for use in the device tree and with some early-init code.

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 arch/x86/include/asm/arch-apollolake/iomap.h | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 arch/x86/include/asm/arch-apollolake/iomap.h
#163 lore raw

PATCH v3 90/108 x86: apollolake: Add PMC driver

In reply to Simon Glass

Add a driver for the apollolake SoC. It supports the basic operations and can use device tree or of-platdata.

---

Changes in v3:
- Use pci_get_devfn()

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile          |   5 +
 arch/x86/cpu/apollolake/pmc.c             | 216 ++++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/pm.h |  19 ++
 drivers/power/acpi_pmc/acpi-pmc-uclass.c  |  51 +++++
 4 files changed, 291 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/Makefile
 create mode 100644 arch/x86/cpu/apollolake/pmc.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/pm.h
arch/x86/cpu/apollolake/Makefile new file +5 -0
new file mode 100644
index 00000000000..5d98a5a6db2
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2016 Google, Inc
+
+obj-y += pmc.o
arch/x86/cpu/apollolake/pmc.c new file +216 -0

216 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/pm.h new file +19 -0
new file mode 100644
index 00000000000..8226ee775e1
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2015-2016 Intel Corp.
+ * (Written by Lance Zhao <[email protected]> for Intel Corp.)
+ */
+
+#ifndef __ASM_ARCH_PM_H
+#define __ASM_ARCH_PM_H
+
+#define  PMC_GPE_SW_31_0	0
+#define  PMC_GPE_SW_63_32	1
+#define  PMC_GPE_NW_31_0	3
+#define  PMC_GPE_NW_63_32	4
+#define  PMC_GPE_NW_95_64	5
+#define  PMC_GPE_N_31_0		6
+#define  PMC_GPE_N_63_32	7
+#define  PMC_GPE_W_31_0		9
+
+#endif
drivers/power/acpi_pmc/acpi-pmc-uclass.c +51 -0

57 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#164 lore raw

PATCH v3 91/108 x86: apollolake: Add low-power subsystem (lpss) support

In reply to Simon Glass

Add very basic support for taking an lpss device out of reset.

---

Changes in v3: None
Changes in v2: None

 arch/x86/cpu/apollolake/Makefile |  1 +
 arch/x86/cpu/apollolake/lpss.c   | 31 +++++++++++++++++++++++++++++++
 arch/x86/include/asm/lpss.h      | 11 +++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/lpss.c
 create mode 100644 arch/x86/include/asm/lpss.h
arch/x86/cpu/apollolake/Makefile +1 -0
index 5d98a5a6db2..b58ef8e019c 100644
@@ -2,4 +2,5 @@
 #
 # Copyright (c) 2016 Google, Inc
 
+obj-y += lpss.o
 obj-y += pmc.o
arch/x86/cpu/apollolake/lpss.c new file +31 -0
new file mode 100644
index 00000000000..2f4aea79c07
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Special driver to handle of-platdata
+ *
+ * Copyright 2019 Google LLC
+ *
+ * Some code from coreboot lpss.c
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/lpss.h>
+
+enum {
+	LPSS_RESET_CTL_REG	= 0x204,
+
+	/*
+	 * Bit 1:0 controls LPSS controller reset.
+	 *
+	 * 00 ->LPSS Host Controller is in reset (Reset Asserted)
+	 * 01/10 ->Reserved
+	 * 11 ->LPSS Host Controller is NOT at reset (Reset Released)
+	 */
+	LPSS_CNT_RST_RELEASE	= 3,
+};
+
+/* Take controller out of reset */
+void lpss_reset_release(void *regs)
+{
+	writel(LPSS_CNT_RST_RELEASE, regs + LPSS_RESET_CTL_REG);
+}
arch/x86/include/asm/lpss.h new file +11 -0
new file mode 100644
index 00000000000..4bd56a5fa30
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __ASM_LPSS_H
+#define __ASM_LPSS_H
+
+void lpss_reset_release(void *regs);
+
+#endif
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#165 lore raw

PATCH v3 91/108 x86: apollolake: Add low-power subsystem (lpss) support

Quoted 4 lines · Simon Glass

Add very basic support for taking an lpss device out of reset.

 arch/x86/cpu/apollolake/lpss.c   | 31 +++++++++++++++++++++++++++++++

Must be in intel_common.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#166 lore raw

PATCH v3 92/108 x86: apollolake: Add UART driver

In reply to Simon Glass

Add a driver for the apollolake UART. It uses the standard ns16550 device but also sets up the input clock with LPSS and supports configuration via of-platdata.

---

Changes in v3:
- Use the LPSS code from a separate file

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile            |   1 +
 arch/x86/cpu/apollolake/uart.c              | 141 ++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/uart.h |  17 +++
 3 files changed, 159 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/uart.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/uart.h
arch/x86/cpu/apollolake/Makefile +1 -0
index b58ef8e019c..ff42d0fd619 100644
@@ -4,3 +4,4 @@
 
 obj-y += lpss.o
 obj-y += pmc.o
+obj-y += uart.o
arch/x86/cpu/apollolake/uart.c new file +141 -0

141 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/uart.h new file +17 -0
new file mode 100644
index 00000000000..521316d0a93
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __ASM_ARCH_UART_H
+#define __ASM_ARCH_UART_H
+
+/**
+ * apl_uart_init() - Set up the APL UART device and clock
+ *
+ * The UART won't actually work unless the GPIO settings are correct and the
+ * signals actually exit the SoC. See init_for_uart() for that.
+ */
+int apl_uart_init(pci_dev_t bdf, ulong base);
+
+#endif
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#167 lore raw

PATCH v3 92/108 x86: apollolake: Add UART driver

Quoted 4 lines · Simon Glass

Add a driver for the apollolake UART. It uses the standard ns16550 device but also sets up the input clock with LPSS and supports configuration via of-platdata.

This must be generic driver. The LPSS block is the same for all Intel SoCs starting from Skylake.
Making it generic will reduce double efforts in the future.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#168 lore raw

PATCH v3 92/108 x86: apollolake: Add UART driver

Hi Andy,

Quoted 10 lines · Andy Shevchenko
Quoted 4 lines · Simon Glass

Add a driver for the apollolake UART. It uses the standard ns16550 device but also sets up the input clock with LPSS and supports configuration via of-platdata.

This must be generic driver. The LPSS block is the same for all Intel SoCs starting from Skylake.
Making it generic will reduce double efforts in the future.

This uses ns16550.

Are you saying that lpss.c should go in intel_common? I can do that.

Regards,
Simon

#169 lore raw

PATCH v3 92/108 x86: apollolake: Add UART driver

Quoted 8 lines · Simon Glass
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Simon Glass

Add a driver for the apollolake UART. It uses the standard ns16550 device but also sets up the input clock with LPSS and supports configuration via of-platdata.

Quoted 7 lines
Quoted 3 lines

This must be generic driver. The LPSS block is the same for all Intel SoCs starting from Skylake.
Making it generic will reduce double efforts in the future.

This uses ns16550.

Are you saying that lpss.c should go in intel_common? I can do that.

Yes.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#170 lore raw

PATCH v3 93/108 x86: apollolake: Add GPIO driver

In reply to Simon Glass

Add a driver for the apollolake GPIOs. It also handles pinctrl since this is not very well separated on x86.

---

Changes in v3:
- Fix mixed case in GPIO defines
- Rework how pads configuration is defined in TPL and SPL
- Use the IRQ uclass instead of ITSS

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile              |   1 +
 arch/x86/cpu/apollolake/gpio.c                | 735 ++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/gpio.h   | 180 +++++
 .../include/asm/arch-apollolake/gpio_apl.h    | 491 ++++++++++++
 .../include/asm/arch-apollolake/gpio_defs.h   | 398 ++++++++++
 5 files changed, 1805 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/gpio.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/gpio.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/gpio_apl.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/gpio_defs.h
arch/x86/cpu/apollolake/Makefile +1 -0
index ff42d0fd619..fa53ea10b79 100644
@@ -2,6 +2,7 @@
 #
 # Copyright (c) 2016 Google, Inc
 
+obj-y += gpio.o
 obj-y += lpss.o
 obj-y += pmc.o
 obj-y += uart.o
arch/x86/cpu/apollolake/gpio.c new file +735 -0

735 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/gpio.h new file +180 -0

180 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/gpio_apl.h new file +491 -0

491 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/gpio_defs.h new file +398 -0

398 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#171 lore raw

PATCH v3 93/108 x86: apollolake: Add GPIO driver

Quoted 5 lines · Simon Glass

Add a driver for the apollolake GPIOs. It also handles pinctrl since this is not very well separated on x86.

 arch/x86/cpu/apollolake/gpio.c                | 735 ++++++++++++++++++

No, no. It must be a common for x86, starting from Skylake. See how it's done in Linux kernel.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#172 lore raw

PATCH v3 94/108 i2c: designware: Add apollolake support

In reply to Simon Glass

For apollolake we need to take the I2C bus controller out of reset before using this. Add this functionality to the driver.

---

Changes in v3:
- Add a weak function to avoid errors on other platforms

Changes in v2: None

 drivers/i2c/dw_i2c_pci.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/i2c/dw_i2c_pci.c +19 -1
index 065c0aa5994..d6d93f08a56 100644
@@ -6,8 +6,14 @@
  */
 
 #include <dm.h>
+#include <asm/lpss.h>
 #include "designware_i2c.h"
 
+enum {
+	VANILLA		= 0,
+	INTEL_APL,
+};
+
 /* BayTrail HCNT/LCNT/SDA hold time */
 static struct dw_scl_sda_cfg byt_config = {
 	.ss_hcnt = 0x200,
@@ -17,6 +23,9 @@ static struct dw_scl_sda_cfg byt_config = {
 	.sda_hold = 0x6,
 };
 
+/* Have a weak function for now - possibly should be a new uclass */
+void lpss_reset_release(void *regs);
+
 static int designware_i2c_pci_probe(struct udevice *dev)
 {
 	struct dw_i2c *priv = dev_get_priv(dev);
@@ -25,9 +34,12 @@ static int designware_i2c_pci_probe(struct udevice *dev)
 	priv->regs = (struct i2c_regs *)
 		dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
 	if (IS_ENABLED(CONFIG_INTEL_BAYTRAIL))
-		/* Use BayTrail specific timing values */
+		/* Use BayTrail-specific timing values */
 		priv->scl_sda_cfg = &byt_config;
 
+	if (dev_get_driver_data(dev) == INTEL_APL)
+		lpss_reset_release(priv->regs);
+
 	return designware_i2c_probe(dev);
 }
 
@@ -72,6 +84,12 @@ static struct pci_device_id designware_pci_supported[] = {
 	{ PCI_VDEVICE(INTEL, 0x0f45) },
 	{ PCI_VDEVICE(INTEL, 0x0f46) },
 	{ PCI_VDEVICE(INTEL, 0x0f47) },
+	{ PCI_VDEVICE(INTEL, 0x5aac), .driver_data = INTEL_APL },
+	{ PCI_VDEVICE(INTEL, 0x5aae), .driver_data = INTEL_APL },
+	{ PCI_VDEVICE(INTEL, 0x5ab0), .driver_data = INTEL_APL },
+	{ PCI_VDEVICE(INTEL, 0x5ab2), .driver_data = INTEL_APL },
+	{ PCI_VDEVICE(INTEL, 0x5ab4), .driver_data = INTEL_APL },
+	{ PCI_VDEVICE(INTEL, 0x5ab6), .driver_data = INTEL_APL },
 	{},
 };
 
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#173 lore raw

PATCH v3 94/108 i2c: designware: Add apollolake support

Hello Simon,

Am 21.10.2019 um 05:38 schrieb Simon Glass:

Quoted 44 lines

For apollolake we need to take the I2C bus controller out of reset before using this. Add this functionality to the driver.

---

Changes in v3:
- Add a weak function to avoid errors on other platforms

Changes in v2: None

  drivers/i2c/dw_i2c_pci.c | 20 +++++++++++++++++++-
  1 file changed, 19 insertions(+), 1 deletion(-)
drivers/i2c/dw_i2c_pci.c +9 -0
index 065c0aa5994..d6d93f08a56 100644
@@ -6,8 +6,14 @@
   */
 
  #include <dm.h>
+#include <asm/lpss.h>
  #include "designware_i2c.h"
 
+enum {
+	VANILLA		= 0,
+	INTEL_APL,
+};
+
  /* BayTrail HCNT/LCNT/SDA hold time */
  static struct dw_scl_sda_cfg byt_config = {
  	.ss_hcnt = 0x200,
@@ -17,6 +23,9 @@ static struct dw_scl_sda_cfg byt_config = {
  	.sda_hold = 0x6,
  };
 
+/* Have a weak function for now - possibly should be a new uclass */
+void lpss_reset_release(void *regs);
+
  static int designware_i2c_pci_probe(struct udevice *dev)
  {
  	struct dw_i2c *priv = dev_get_priv(dev);

drivers/i2c/dw_i2c_pci.c static int designware_i2c_pci_probe(struct udevice *dev) · line 37

Quoted 5 lines
drivers/i2c/dw_i2c_pci.c +1 -1
@@ -25,9 +34,12 @@ static int designware_i2c_pci_probe(struct udevice *dev)
  	priv->regs = (struct i2c_regs *)
  		dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
  	if (IS_ENABLED(CONFIG_INTEL_BAYTRAIL))
-		/* Use BayTrail specific timing values */
+		/* Use BayTrail-specific timing values */

Nitpick only: unrelated change.

[...]

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#174 lore raw

PATCH v3 95/108 x86: apollolake: Add systemagent driver

In reply to Simon Glass

This driver handles communication with the systemagent which needs to be told when U-Boot has completed its init.

---

Changes in v3: None
Changes in v2: None

 arch/x86/cpu/apollolake/Makefile              |  2 ++
 arch/x86/cpu/apollolake/systemagent.c         | 19 ++++++++++++
 .../include/asm/arch-apollolake/systemagent.h | 31 +++++++++++++++++++
 3 files changed, 52 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/systemagent.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/systemagent.h
arch/x86/cpu/apollolake/Makefile +2 -0
index fa53ea10b79..351fba21298 100644
@@ -2,6 +2,8 @@
 #
 # Copyright (c) 2016 Google, Inc
 
+obj-$(CONFIG_SPL_BUILD) += systemagent.o
+
 obj-y += gpio.o
 obj-y += lpss.o
 obj-y += pmc.o
arch/x86/cpu/apollolake/systemagent.c new file +19 -0
new file mode 100644
index 00000000000..3a41b329c3d
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2017 Intel Corporation.
+ * Take from coreboot project file of the same name
+ */
+
+#include <common.h>
+#include <asm/intel_regs.h>
+#include <asm/io.h>
+#include <asm/arch/systemagent.h>
+
+void enable_bios_reset_cpl(void)
+{
+	/*
+	 * Set bits 0+1 of BIOS_RESET_CPL to indicate to the CPU
+	 * that BIOS has initialised memory and power management
+	 */
+	setbits_8(MCHBAR_REG(BIOS_RESET_CPL), 3);
+}
arch/x86/include/asm/arch-apollolake/systemagent.h new file +31 -0
new file mode 100644
index 00000000000..5983e4e6302
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2017 Intel Corporation.
+ * Take from coreboot project file of the same name
+ */
+
+#ifndef __ARCH_SYSTEMAGENT_H
+#define __ARCH_SYSTEMAGENT_H
+
+/* Device 0:0.0 PCI configuration space */
+#define MCHBAR		0x48
+
+/* RAPL Package Power Limit register under MCHBAR */
+#define PUNIT_THERMAL_DEVICE_IRQ		0x700C
+#define PUINT_THERMAL_DEVICE_IRQ_VEC_NUMBER	0x18
+#define PUINT_THERMAL_DEVICE_IRQ_LOCK		0x80000000
+#define BIOS_RESET_CPL		0x7078
+#define   PCODE_INIT_DONE	BIT(8)
+#define MCHBAR_RAPL_PPL		0x70A8
+#define CORE_DISABLE_MASK	0x7168
+#define CAPID0_A		0xE4
+#define   VTD_DISABLE		BIT(23)
+#define DEFVTBAR		0x6c80
+#define GFXVTBAR		0x6c88
+#define   VTBAR_ENABLED		0x01
+#define VTBAR_MASK		0xfffffff000ull
+#define VTBAR_SIZE		0x1000
+
+void enable_bios_reset_cpl(void);
+
+#endif
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#175 lore raw

PATCH v3 95/108 x86: apollolake: Add systemagent driver

Quoted 5 lines · Simon Glass

This driver handles communication with the systemagent which needs to be told when U-Boot has completed its init.

+#define VTBAR_MASK 0xfffffff000ull

Don't we have GENMASK() ?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#176 lore raw

PATCH v3 96/108 x86: apollolake: Add hostbridge driver

In reply to Simon Glass

This driver models the hostbridge as a northbridge. It simply sets up the graphics BAR. It supports of-platdata.

---

Changes in v3:
- Move pad programming into the hostbridge to reduce TPL device-tree size
- Use pci_get_devfn()

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile            |   1 +
 arch/x86/cpu/apollolake/hostbridge.c        | 220 ++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/gpio.h |  11 +
 3 files changed, 232 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/hostbridge.c
arch/x86/cpu/apollolake/Makefile +1 -0
index 351fba21298..0615bb120d3 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_SPL_BUILD) += systemagent.o
 
 obj-y += gpio.o
+obj-y += hostbridge.o
 obj-y += lpss.o
 obj-y += pmc.o
 obj-y += uart.o
arch/x86/cpu/apollolake/hostbridge.c new file +220 -0

220 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/gpio.h +11 -0
index 19421950e61..47f87bb0142 100644
@@ -177,4 +177,15 @@ int gpio_config_pads(struct udevice *dev, int num_cfgs, u32 *pads,
  */
 int gpio_gpi_clear_int_cfg(void);
 
+/**
+ * hostbridge_config_pads_for_node() - Configure GPIO pads
+ *
+ * Set up the pads using the data in a given node
+ *
+ * @dev: Hostbridge device
+ * @node: Node containing the 'pads' property with the data in it
+ * @return 0 if OK, -ve on error
+ */
+int hostbridge_config_pads_for_node(struct udevice *dev, ofnode node);
+
 #endif
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#177 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

In reply to Simon Glass

This driver models some sort of interrupt thingy but there are so many abreviations that I cannot find out what it stands for. Possibly something to do with interrupts.

---

Changes in v3:
- Add snapshot/restore for IRQs
- Use the IRQ uclass instead of ITSS

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile            |   1 +
 arch/x86/cpu/apollolake/itss.c              | 214 ++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/itss.h |  43 ++++
 3 files changed, 258 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/itss.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/itss.h
arch/x86/cpu/apollolake/Makefile +1 -0
index 0615bb120d3..edd7e49154b 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_SPL_BUILD) += systemagent.o
 
 obj-y += gpio.o
 obj-y += hostbridge.o
+obj-y += itss.o
 obj-y += lpss.o
 obj-y += pmc.o
 obj-y += uart.o
arch/x86/cpu/apollolake/itss.c new file +214 -0

214 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/itss.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#178 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

Quoted 4 lines · Simon Glass

This driver models some sort of interrupt thingy but there are so many abreviations that I cannot find out what it stands for. Possibly something to do with interrupts.

From documentation.
Interrupt Timer Subsystem

The below code is only small part of what it can do / does.

Quoted 1 line
 arch/x86/cpu/apollolake/itss.c              | 214 ++++++++++++++++++++

P.S. Heard first time today about it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#179 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Simon Glass

This driver models some sort of interrupt thingy but there are so many abreviations that I cannot find out what it stands for. Possibly something to do with interrupts.

Quoted 8 lines

From documentation.
Interrupt Timer Subsystem

The below code is only small part of what it can do / does.

Quoted 1 line
 arch/x86/cpu/apollolake/itss.c              | 214 ++++++++++++++++++++

P.S. Heard first time today about it.

Okay, nailed it. It's a re-make of iLB. So, basically this has to be a part of iLB driver(s).

In BXT it contains legacy (8254, 8259) and standard (HPET, IOAPIC) devices.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#180 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

Hi Andy,

Quoted 15 lines · Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 4 lines · Simon Glass

This driver models some sort of interrupt thingy but there are so many abreviations that I cannot find out what it stands for. Possibly something to do with interrupts.

From documentation.
Interrupt Timer Subsystem

The below code is only small part of what it can do / does.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line
 arch/x86/cpu/apollolake/itss.c              | 214 ++++++++++++++++++++

P.S. Heard first time today about it.

Okay, nailed it. It's a re-make of iLB. So, basically this has to be a part of iLB driver(s).

In BXT it contains legacy (8254, 8259) and standard (HPET, IOAPIC) devices.

OK. Where is the iLB driver? So are any changes needed for this patch?

Regards,
Simon

#181 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

Quoted 3 lines · Simon Glass

On Mon, 21 Oct 2019 at 02:44, Andy Shevchenko <[email protected]> wrote:

OK. Where is the iLB driver? So are any changes needed for this patch?

I guess in U-Boot we call it LPC... (What a mess with all this abbreviations!)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#182 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

Hi Andy,

Quoted 7 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass

On Mon, 21 Oct 2019 at 02:44, Andy Shevchenko <[email protected]> wrote:

OK. Where is the iLB driver? So are any changes needed for this patch?

I guess in U-Boot we call it LPC... (What a mess with all this abbreviations!)

OK. So is this right?

LPC - Low-Pin-Count bus
iLB - Intel Legacy Block

Regards,
Simon

#183 lore raw

PATCH v3 97/108 x86: apollolake: Add ITSS driver

Quoted 4 lines · Simon Glass
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Simon Glass

On Mon, 21 Oct 2019 at 02:44, Andy Shevchenko <[email protected]> wrote:

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

OK. Where is the iLB driver? So are any changes needed for this patch?

I guess in U-Boot we call it LPC... (What a mess with all this abbreviations!)

OK. So is this right?

LPC - Low-Pin-Count bus
iLB - Intel Legacy Block

Yes.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#184 lore raw

PATCH v3 98/108 x86: apollolake: Add LPC driver

In reply to Simon Glass

This driver the LPC and provides a few functions to set up LPC features. These should probably use ioctls() or perhaps, better, have specific uclass methods.

---

Changes in v3:
- Drop unused code in lpc_configure_pads()
- Fix value of LPC_BC_LE

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile           |   1 +
 arch/x86/cpu/apollolake/lpc.c              | 141 +++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/lpc.h |  61 +++++++++
 3 files changed, 203 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/lpc.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/lpc.h
arch/x86/cpu/apollolake/Makefile +1 -0
index edd7e49154b..71c3cd08241 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_SPL_BUILD) += systemagent.o
 obj-y += gpio.o
 obj-y += hostbridge.o
 obj-y += itss.o
+obj-y += lpc.o
 obj-y += lpss.o
 obj-y += pmc.o
 obj-y += uart.o
arch/x86/cpu/apollolake/lpc.c new file +141 -0

141 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/lpc.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#185 lore raw

PATCH v3 99/108 x86: apollolake: Add PCH driver

In reply to Simon Glass

Add a driver for the apollolake Platform Controller Hub. It does not have any functionality and is just a placeholder for now.

---

Changes in v3: None
Changes in v2:
- Drop probe() function
- Implement set_spi_protect()

 arch/x86/cpu/apollolake/Makefile           |  1 +
 arch/x86/cpu/apollolake/pch.c              | 36 ++++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/pch.h |  9 ++++++
 3 files changed, 46 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/pch.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/pch.h
arch/x86/cpu/apollolake/Makefile +1 -0
index 71c3cd08241..7f76572e551 100644
@@ -9,5 +9,6 @@ obj-y += hostbridge.o
 obj-y += itss.o
 obj-y += lpc.o
 obj-y += lpss.o
+obj-y += pch.o
 obj-y += pmc.o
 obj-y += uart.o
arch/x86/cpu/apollolake/pch.c new file +36 -0
new file mode 100644
index 00000000000..89667b65224
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <pch.h>
+#include <spl.h>
+#include <asm/lpc_common.h>
+
+#define BIOS_CTRL	0xdc
+
+static int apl_set_spi_protect(struct udevice *dev, bool protect)
+{
+	if (spl_phase() != PHASE_TPL)
+		return lpc_set_spi_protect(dev, BIOS_CTRL, protect);
+
+	return 0;
+}
+
+static const struct pch_ops apl_pch_ops = {
+	.set_spi_protect = apl_set_spi_protect,
+};
+
+static const struct udevice_id apl_pch_ids[] = {
+	{ .compatible = "intel,apl-pch" },
+	{ }
+};
+
+U_BOOT_DRIVER(apl_pch) = {
+	.name		= "apl_pch",
+	.id		= UCLASS_PCH,
+	.of_match	= apl_pch_ids,
+	.ops		= &apl_pch_ops,
+};
arch/x86/include/asm/arch-apollolake/pch.h new file +9 -0
new file mode 100644
index 00000000000..7f19903a3fe
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __ASM_ARCH_PCH_H
+#define __ASM_ARCH_PCH_H
+
+#endif /* __ASM_ARCH_PCH_H */
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#186 lore raw

PATCH v3 100/108 x86: apollolake: Add PUNIT driver

In reply to Simon Glass

Add a driver for the apollolake power unit. It is modelled as a syscon driver since it only needs to be probed.

---

Changes in v3:
- Use pci_get_devfn()

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile |   3 +
 arch/x86/cpu/apollolake/punit.c  | 121 +++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/punit.c
arch/x86/cpu/apollolake/Makefile +3 -0
index 7f76572e551..8a177d93d00 100644
@@ -3,6 +3,9 @@
 # Copyright (c) 2016 Google, Inc
 
 obj-$(CONFIG_SPL_BUILD) += systemagent.o
+ifndef CONFIG_TPL_BUILD
+obj-y += punit.o
+endif
 
 obj-y += gpio.o
 obj-y += hostbridge.o
arch/x86/cpu/apollolake/punit.c new file +121 -0

121 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#187 lore raw

PATCH v3 100/108 x86: apollolake: Add PUNIT driver

Quoted 3 lines · Simon Glass

Add a driver for the apollolake power unit. It is modelled as a syscon driver since it only needs to be probed.

appollolake -> Appollo Lake (everywhere in the series) power unit -> P-Unit (it's very known for Intel SoCs term, you may decode it as well, but use this known semi-abbreviation) modelled -> modeled

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#188 lore raw

PATCH v3 101/108 x86: apollolake: Add SPL loaders

In reply to Simon Glass

Add loaders for SPL and TPL so that the next stage can be loaded from memory-mapped SPI or, failing that, the Fast SPI driver.

---

Changes in v3:
- Add a driver for APL SPI for TPL (using of-platdata)
- Support TPL without CONFIG_TPL_SPI_SUPPORT
- Support bootstage timing

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile |   2 +
 arch/x86/cpu/apollolake/spl.c    | 202 +++++++++++++++++++++++++++++++
 2 files changed, 204 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/spl.c
arch/x86/cpu/apollolake/Makefile +2 -0
index 8a177d93d00..c4ec71e2b76 100644
@@ -2,7 +2,9 @@
 #
 # Copyright (c) 2016 Google, Inc
 
+obj-$(CONFIG_SPL_BUILD) += spl.o
 obj-$(CONFIG_SPL_BUILD) += systemagent.o
+
 ifndef CONFIG_TPL_BUILD
 obj-y += punit.o
 endif
arch/x86/cpu/apollolake/spl.c new file +202 -0

202 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#189 lore raw

PATCH v3 102/108 x86: apollolake: Add a CPU driver

In reply to Simon Glass

Add a bare-bones CPU driver so that CPUs can be probed.

---

Changes in v3:
- Add two more defines for the CPU driver
- Expand comments for BOOT_FROM_FAST_SPI_FLASH

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile           |  1 +
 arch/x86/cpu/apollolake/cpu.c              | 51 ++++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/cpu.h | 27 ++++++++++++
 3 files changed, 79 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/cpu.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/cpu.h
arch/x86/cpu/apollolake/Makefile +1 -0
index c4ec71e2b76..ee7114b40c9 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_SPL_BUILD) += spl.o
 obj-$(CONFIG_SPL_BUILD) += systemagent.o
 
 ifndef CONFIG_TPL_BUILD
+obj-y += cpu.o
 obj-y += punit.o
 endif
 
arch/x86/cpu/apollolake/cpu.c new file +51 -0

51 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/cpu.h new file +27 -0
new file mode 100644
index 00000000000..3047d502fab
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __ASM_ARCH_CPU_H
+#define __ASM_ARCH_CPU_H
+
+/* Common Timer Copy (CTC) frequency - 19.2MHz */
+#define CTC_FREQ		19200000
+
+/*
+ * Set to true to use the fast SPI driver to boot, instead of mapped SPI.
+ * You also need to enabled CONFIG_SUPPORT_SPI_FLASHBOOT.
+ */
+#define BOOT_FROM_FAST_SPI_FLASH	false
+
+/*
+ * We need to read well past the end of the region in order for execution from
+ * the loaded data to work. It is not clear why.
+ */
+#define SAFETY_MARGIN	0x4000
+
+#define MAX_PCIE_PORTS		6
+#define CLKREQ_DISABLED		0xf
+
+#endif /* __ASM_ARCH_CPU_H */
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#190 lore raw

PATCH v3 103/108 x86: apollolake: Add SPL/TPL init

In reply to Simon Glass

Add code to init the system both in TPL and SPL. Each phase has its own procedure.

---

Changes in v3:
- Adjust fast_spi_cache_bios_region() to avoid using SPI driver
- Drop calls to x86_cpu_init_f(), x86_cpu_reinit_f()
- Fix build error when debug UART is disabled
- Init the p2sb before the northbridge since the latter so it can use GPIOs
- Move location of fast_spi.h header file
- Shorten log_msg_ret() calls since the function name is always printed
- Support TPL without CONFIG_TPL_SPI_SUPPORT (reduces code size)

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile  |   1 +
 arch/x86/cpu/apollolake/cpu_spl.c | 278 ++++++++++++++++++++++++++++++
 2 files changed, 279 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/cpu_spl.c
arch/x86/cpu/apollolake/Makefile +1 -0
index ee7114b40c9..65c17d4b779 100644
@@ -2,6 +2,7 @@
 #
 # Copyright (c) 2016 Google, Inc
 
+obj-$(CONFIG_SPL_BUILD) += cpu_spl.o
 obj-$(CONFIG_SPL_BUILD) += spl.o
 obj-$(CONFIG_SPL_BUILD) += systemagent.o
 
arch/x86/cpu/apollolake/cpu_spl.c new file +278 -0

278 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#191 lore raw

PATCH v3 104/108 x86: apollolake: Add P2SB driver

In reply to Simon Glass

Adds a driver for the apollolake Primary-to-sideband bus. This supports various child devices. It supposed both device tree and of-platdata.

---

Changes in v3:
- Use pci_get_devfn()

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile |   1 +
 arch/x86/cpu/apollolake/p2sb.c   | 167 +++++++++++++++++++++++++++++++
 2 files changed, 168 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/p2sb.c
arch/x86/cpu/apollolake/Makefile +1 -0
index 65c17d4b779..7b040c37a72 100644
@@ -16,6 +16,7 @@ obj-y += hostbridge.o
 obj-y += itss.o
 obj-y += lpc.o
 obj-y += lpss.o
+obj-y += p2sb.o
 obj-y += pch.o
 obj-y += pmc.o
 obj-y += uart.o
arch/x86/cpu/apollolake/p2sb.c new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#192 lore raw

PATCH v3 104/108 x86: apollolake: Add P2SB driver

arch/x86/cpu/apollolake/p2sb.c line 130

Quoted 10 lines · Simon Glass

Adds a driver for the apollolake Primary-to-sideband bus. This supports various child devices. It supposed both device tree and of-platdata.

arch/x86/cpu/apollolake/p2sb.c new file +5 -0
+static int apl_p2sb_probe(struct udevice *dev)
+{
+       if (spl_phase() == PHASE_TPL)
+               return apl_p2sb_early_init(dev);
 
+       else if (spl_phase() == PHASE_SPL)

Redundant 'else' (recommended to check for a such in the entire series)

Quoted 4 lines
arch/x86/cpu/apollolake/p2sb.c new file +4 -0
+               return apl_p2sb_spl_init(dev);
+
+       return 0;
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#193 lore raw

PATCH v3 104/108 x86: apollolake: Add P2SB driver

Hi Andy,

Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass

Adds a driver for the apollolake Primary-to-sideband bus. This supports various child devices. It supposed both device tree and of-platdata.

Quoted 8 lines

arch/x86/cpu/apollolake/p2sb.c line 130

Quoted 6 lines
arch/x86/cpu/apollolake/p2sb.c new file +5 -0
+static int apl_p2sb_probe(struct udevice *dev)
+{
+       if (spl_phase() == PHASE_TPL)
+               return apl_p2sb_early_init(dev);
 
+       else if (spl_phase() == PHASE_SPL)

Redundant 'else' (recommended to check for a such in the entire series)

This is a style thing. I like the else so that it is clear that we have two options. I could use a switch() but then it needs to have a 'default' which is ugly.

Quoted 5 lines

arch/x86/cpu/apollolake/p2sb.c line 134

Quoted 5 lines
arch/x86/cpu/apollolake/p2sb.c new file +4 -0
+               return apl_p2sb_spl_init(dev);
+
+       return 0;
+}

Regards,
Simon

#194 lore raw

PATCH v3 105/108 x86: apollolake: Add Kconfig and Makefile

In reply to Simon Glass

Add basic plumbing to allow apollolake support to be used.

---

Changes in v3:
- Add MMC, video, USB configs
- Add an APL_SPI_FLASH_BOOT option to enable non-mmap boot
- Fix the incorrect value of CPU_ADDR_BITS

Changes in v2: None

 arch/x86/Kconfig                |  1 +
 arch/x86/cpu/Makefile           |  1 +
 arch/x86/cpu/apollolake/Kconfig | 87 +++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/Kconfig
arch/x86/Kconfig +1 -0
index c9f1b6d8ada..36a0021adb7 100644
@@ -106,6 +106,7 @@ source "board/google/Kconfig"
 source "board/intel/Kconfig"
 
 # platform-specific options below
+source "arch/x86/cpu/apollolake/Kconfig"
 source "arch/x86/cpu/baytrail/Kconfig"
 source "arch/x86/cpu/braswell/Kconfig"
 source "arch/x86/cpu/broadwell/Kconfig"
arch/x86/cpu/Makefile +1 -0
index b6a010ea320..4c151f8c94d 100644
@@ -41,6 +41,7 @@ extra-y += call32.o
 endif
 
 obj-y += intel_common/
+obj-$(CONFIG_INTEL_APOLLOLAKE) += apollolake/
 obj-$(CONFIG_INTEL_BAYTRAIL) += baytrail/
 obj-$(CONFIG_INTEL_BRASWELL) += braswell/
 obj-$(CONFIG_INTEL_BROADWELL) += broadwell/
arch/x86/cpu/apollolake/Kconfig new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#195 lore raw

PATCH v3 106/108 x86: apollolake: Add FSP structures

In reply to Simon Glass

These are mostly specific to a particular SoC. Add the definitions for apollolake.

---

Changes in v3:
- Add VBT signature
- Add structures for FSP-S also
- Drop struct fsp_usp_header as it is now in the API file

Changes in v2: None

 .../asm/arch-apollolake/fsp/fsp_configs.h     |  14 +
 .../asm/arch-apollolake/fsp/fsp_m_upd.h       | 123 ++++++++
 .../asm/arch-apollolake/fsp/fsp_s_upd.h       | 292 ++++++++++++++++++
 .../include/asm/arch-apollolake/fsp/fsp_vpd.h |  11 +
 4 files changed, 440 insertions(+)
 create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_configs.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_m_upd.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_s_upd.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/fsp/fsp_vpd.h
arch/x86/include/asm/arch-apollolake/fsp/fsp_configs.h new file +14 -0
new file mode 100644
index 00000000000..9185d94b2bc
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: Intel */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __FSP_CONFIGS_H__
+#define __FSP_CONFIGS_H__
+
+#define FSPT_UPD_SIGNATURE	0x545F4450554C5041	/* 'APLUPD_T' */
+#define FSPM_UPD_SIGNATURE	0x4D5F4450554C5041	/* 'APLUPD_M' */
+#define FSPS_UPD_SIGNATURE	0x535F4450554C5041	/* 'APLUPD_S' */
+#define VBT_SIGNATURE		0x54425624
+
+#endif
arch/x86/include/asm/arch-apollolake/fsp/fsp_m_upd.h new file +123 -0

123 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/fsp/fsp_s_upd.h new file +292 -0

292 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/fsp/fsp_vpd.h new file +11 -0
new file mode 100644
index 00000000000..b14f28b2364
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: Intel */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __FSP_VPD_H
+#define __FSP_VPD_H
+
+/* Nothing to declare here for FSP2 */
+
+#endif
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#196 lore raw

PATCH v3 107/108 x86: apollolake: Add FSP support

In reply to Simon Glass

The memory and silicon init parts of the FSP need support code to work. Add this for apollolake.

---

Changes in v3:
- Add bootstage timing for reading vbt
- Add fspm_done() hook to handle FSP-S wierdness (it breaks SPI flash)
- Don't allow BOOT_FROM_FAST_SPI_FLASH with FSP-S
- Set boot_loader_tolum_size to 0
- Use the IRQ uclass instead of ITSS

Changes in v2: None

 arch/x86/cpu/apollolake/Makefile |   6 +
 arch/x86/cpu/apollolake/fsp_m.c  | 210 ++++++++++
 arch/x86/cpu/apollolake/fsp_s.c  | 665 +++++++++++++++++++++++++++++++
 3 files changed, 881 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/fsp_m.c
 create mode 100644 arch/x86/cpu/apollolake/fsp_s.c
arch/x86/cpu/apollolake/Makefile +6 -0
index 7b040c37a72..d0cbeabaecb 100644
@@ -9,6 +9,12 @@ obj-$(CONFIG_SPL_BUILD) += systemagent.o
 ifndef CONFIG_TPL_BUILD
 obj-y += cpu.o
 obj-y += punit.o
+ifdef CONFIG_SPL_BUILD
+obj-y += fsp_m.o
+endif
+endif
+ifndef CONFIG_SPL_BUILD
+obj-y += fsp_s.o
 endif
 
 obj-y += gpio.o
arch/x86/cpu/apollolake/fsp_m.c new file +210 -0

210 lines not on this page · raw message

arch/x86/cpu/apollolake/fsp_s.c new file +665 -0

665 lines not on this page · raw message

Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#197 lore raw

PATCH v3 108/108 x86: Add chromebook_coral

In reply to Simon Glass

Add support for coral which is a range of apollolake-based Chromebook released in 2017. This also includes reef released in 2016, since it is based on the same SoC.

---

Changes in v3:
- Ad FSP-S support
- Add CONFIG_TPL_X86_ASSUME_CPUID to reduce code size
- Add Chrome OS EC support
- Add a proper SPI node and make the SPI flash node a child
- Add bootstage support
- Add more documentation
- Add spi alias in device tree
- Disable the bootcommand since it does nothing useful on coral
- Don't enable SPI flash in TPL by default
- Drop CONFIG_SPL_NET_SUPPORT
- Drop patch '86: timer: Reduce timer code size in TPL on Intel CPUs'
- Drop patch 'dm: core: Don't include ofnode functions with of-platdata'
- Drop patch 'spi: sandbox: Add a test driver for sandbox SPI flash'
- Drop patch 'spl: Allow SPL/TPL to use of-platdata without libfdt'
- Drop patch 'x86: apollolake: Add definitions for the Intel Fast SPI interface'
- Drop patch 'x86: timer: Set up the timer in timer_early_get_count()'
- Enable video and USB3
- Reduce amount of early-pad data in TPL
- Tidy up the pad settings in the device tree
- Use a zero-based tsc timer

Changes in v2: None

 arch/x86/dts/Makefile                     |   1 +
 arch/x86/dts/chromebook_coral.dts         | 790 ++++++++++++++++++++++
 board/google/Kconfig                      |  15 +
 board/google/chromebook_coral/Kconfig     |  43 ++
 board/google/chromebook_coral/MAINTAINERS |   6 +
 board/google/chromebook_coral/Makefile    |   5 +
 board/google/chromebook_coral/coral.c     |  18 +
 configs/chromebook_coral_defconfig        | 101 +++
 doc/board/google/chromebook_coral.rst     | 238 +++++++
 drivers/i2c/dw_i2c_pci.c                  |   2 +-
 include/configs/chromebook_coral.h        |  31 +
 11 files changed, 1249 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/dts/chromebook_coral.dts
 create mode 100644 board/google/chromebook_coral/Kconfig
 create mode 100644 board/google/chromebook_coral/MAINTAINERS
 create mode 100644 board/google/chromebook_coral/Makefile
 create mode 100644 board/google/chromebook_coral/coral.c
 create mode 100644 configs/chromebook_coral_defconfig
 create mode 100644 doc/board/google/chromebook_coral.rst
 create mode 100644 include/configs/chromebook_coral.h
arch/x86/dts/Makefile +1 -0
index d4bdf62be6d..be209aaaf8f 100644
@@ -2,6 +2,7 @@
 
 dtb-y += bayleybay.dtb \
 	cherryhill.dtb \
+	chromebook_coral.dtb \
 	chromebook_link.dtb \
 	chromebox_panther.dtb \
 	chromebook_samus.dtb \
arch/x86/dts/chromebook_coral.dts new file +790 -0

790 lines not on this page · raw message

board/google/Kconfig +15 -0
index 679a0f10239..1d67fda0676 100644
@@ -60,8 +60,23 @@ config TARGET_CHROMEBOOK_SAMUS_TPL
 	  between different A/B versions of SPL/U-Boot, to allow upgrading of
 	  almost all U-Boot code in the field.
 
+config TARGET_CHROMEBOOK_CORAL
+	bool "Chromebook coral"
+	help
+	  This is a range of Intel-based laptops released in 2018. They use an
+	  Intel Apollolake CPU. The design supports WiFi, 4GB to 16GB of
+	  LPDDR4 1600MHz SDRAM, PCIe WiFi and Bluetooth, eMMC (typically 32GB),
+	  up two cameras (front-facing 720p and another 5MP option), USB SD
+	  reader, microphone and speakers. It also includes two USB 3 Type A and
+	  two Type C ports. The latter are used as power input and can also
+	  charge external devices as well as a 4K external display. There is a
+	  Chrome OS EC connected on LPC, a Cr50 secure chip from Google and
+	  various display options. OEMs products include Acer Chromebook 11
+	  (e.g. C732, CB11, CP311) and Lenovo Chromebook (100e, 300e, 500e).
+
 endchoice
 
+source "board/google/chromebook_coral/Kconfig"
 source "board/google/chromebook_link/Kconfig"
 source "board/google/chromebox_panther/Kconfig"
 source "board/google/chromebook_samus/Kconfig"
board/google/chromebook_coral/Kconfig new file +43 -0

43 lines not on this page · raw message

board/google/chromebook_coral/MAINTAINERS new file +6 -0
new file mode 100644
index 00000000000..904227e2e21
@@ -0,0 +1,6 @@
+CHROMEBOOK_CORAL_BOARD
+M:	Simon Glass <[email protected]>
+S:	Maintained
+F:	board/google/chromebook_coral/
+F:	include/configs/chromebook_coral.h
+F:	configs/chromebook_coral_defconfig
board/google/chromebook_coral/Makefile new file +5 -0
new file mode 100644
index 00000000000..6a27ce3da1b
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2019 Google LLC
+
+obj-y	+= coral.o
board/google/chromebook_coral/coral.c new file +18 -0
new file mode 100644
index 00000000000..dfe0fa484a1
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#include <common.h>
+
+int arch_misc_init(void)
+{
+	return 0;
+}
+
+int board_run_command(const char *cmdline)
+{
+	printf("No command line\n");
+
+	return 0;
+}
configs/chromebook_coral_defconfig new file +101 -0

101 lines not on this page · raw message

doc/board/google/chromebook_coral.rst new file +238 -0

238 lines not on this page · raw message

drivers/i2c/dw_i2c_pci.c +1 -1
index d6d93f08a56..34cdc7bf59c 100644
@@ -24,7 +24,7 @@ static struct dw_scl_sda_cfg byt_config = {
 };
 
 /* Have a weak function for now - possibly should be a new uclass */
-void lpss_reset_release(void *regs);
+__weak void lpss_reset_release(void *regs);
 
 static int designware_i2c_pci_probe(struct udevice *dev)
 {
include/configs/chromebook_coral.h new file +31 -0
new file mode 100644
index 00000000000..b5603e09ef2
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+/*
+ * board/config.h - configuration options, board-specific
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_BOOTCOMMAND
+
+#include <configs/x86-common.h>
+#include <configs/x86-chromebook.h>
+
+#undef CONFIG_STD_DEVICES_SETTINGS
+#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,i8042-kbd,serial\0" \
+					"stdout=vidconsole,serial\0" \
+					"stderr=vidconsole,serial\0"
+
+#define CONFIG_ENV_SECT_SIZE		0x1000
+#define CONFIG_ENV_OFFSET		0x003f8000
+
+#define CONFIG_TPL_TEXT_BASE		0xffff8000
+
+#define CONFIG_SYS_NS16550_MEM32
+#undef CONFIG_SYS_NS16550_PORT_MAPPED
+
+#endif	/* __CONFIG_H */
Signature · 1 line
2.23.0.866.gb869b98d4c-goog
#198 lore raw

PATCH v3 22/108 x86: timer: Use a separate flag for whether timer is inited

In reply to Simon Glass
Quoted 64 lines

-----Original Message-----
From: Simon Glass [mailto:sjg at chromium.org]
Sent: Sunday, October 20, 2019 8:38 PM
To: U-Boot Mailing List <[email protected]>
Cc: Bin Meng <[email protected]>; Simon Glass <[email protected]>; Andy Shevchenko <[email protected]>; Bernhard Messerklinger <[email protected]>; Park, Aiden <[email protected]>; Simon Goldschmidt <[email protected]>; Stefan Roese <[email protected]>
Subject: [PATCH v3 022/108] x86: timer: Use a separate flag for whether timer is inited

At present the value of the timer base is used to determine whether the timer has been set up or not. It is true that the timer is essentially never exactly 0 when it is read. However 'time 0' may indicate the time that the machine was reset so it is useful to be able to denote that.

Update the code to use a separate flag instead.

---

Changes in v3: None
Changes in v2: None

 arch/x86/include/asm/global_data.h | 1 +
 drivers/timer/tsc_timer.c          | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/include/asm/global_data.h +1 -0
index 17a4d344913..7f3ada06f61 100644
@@ -76,6 +76,7 @@ struct arch_global_data {
 	uint8_t x86_mask;
 	uint32_t x86_device;
 	uint64_t tsc_base;		/* Initial value returned by rdtsc() */
+	bool tsc_inited;		/* true if tsc is ready for use */
 	unsigned long clock_rate;	/* Clock rate of timer in Hz */
 	void *new_fdt;			/* Relocated FDT */
 	uint32_t bist;			/* Built-in self test value */
drivers/timer/tsc_timer.c index renamed from drivers/timer/tsc_timer.c +0 -0

f19d2237e4f..637c8ff25a5 100644

drivers/timer/tsc_timer.c +2 -2
@@ -394,7 +394,7 @@ static int tsc_timer_get_count(struct udevice *dev,
 u64 *count)
 
 static void tsc_timer_ensure_setup(bool early)  {
-	if (gd->arch.tsc_base)
+	if (gd->arch.tsc_inited)
 		return;
 	gd->arch.tsc_base = rdtsc();
 
@@ -425,6 +425,7 @@ static void tsc_timer_ensure_setup(bool early)
 done:
 		gd->arch.clock_rate = fast_calibrate * 1000000;
 	}
+	gd->arch.tsc_inited = true;
 }
 
 static int tsc_timer_probe(struct udevice *dev)
--
Quoted 1 line

2.23.0.866.gb869b98d4c-goog

Verified with slimbootloader on QEMU and an APL board

Best Regards,
Aiden

#199 lore raw

PATCH v3 22/108 x86: timer: Use a separate flag for whether timer is inited

In reply to Simon Glass
Quoted 9 lines · Simon Glass

At present the value of the timer base is used to determine whether the timer has been set up or not. It is true that the timer is essentially never exactly 0 when it is read. However 'time 0' may indicate the time that the machine was reset so it is useful to be able to denote that.

Update the code to use a separate flag instead.

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 arch/x86/include/asm/global_data.h | 1 +
 drivers/timer/tsc_timer.c          | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
#200 lore raw

PATCH v3 22/108 x86: timer: Use a separate flag for whether timer is inited

Quoted 16 lines · Bin Meng
Quoted 14 lines · Simon Glass

At present the value of the timer base is used to determine whether the timer has been set up or not. It is true that the timer is essentially never exactly 0 when it is read. However 'time 0' may indicate the time that the machine was reset so it is useful to be able to denote that.

Update the code to use a separate flag instead.

---

Changes in v3: None
Changes in v2: None

Quoted 6 lines
Quoted 4 lines
 arch/x86/include/asm/global_data.h | 1 +
 drivers/timer/tsc_timer.c          | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

applied to u-boot-x86, thanks!