All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aswath Govindraju <a-govindraju@ti.com>
Cc: <u-boot@lists.denx.de>, Wolfgang Denk <wd@denx.de>,
	Hari Nagalla <hnagalla@ti.com>, David Huang <d-huang@ti.com>,
	Keerthy <j-keerthy@ti.com>, Dave Gerlach <d-gerlach@ti.com>,
	Suman Anna <s-anna@ti.com>, Nishanth Menon <nm@ti.com>,
	Tero Kristo <kristo@kernel.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Christian Hewitt <christianshewitt@gmail.com>,
	Tim Harvey <tharvey@gateworks.com>,
	Peter Robinson <pbrobinson@gmail.com>,
	Kever Yang <kever.yang@rock-chips.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Fabio Estevam <festevam@denx.de>,
	Andre Przywara <andre.przywara@arm.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Sean Anderson <seanga2@gmail.com>,
	Lukasz Majewski <lukma@denx.de>,
	Aswath Govindraju <a-govindraju@ti.com>
Subject: [PATCH v2 04/20] ram: k3-ddrss: Add support for configuring MSMC subsystem in case of Multiple DDR subsystems
Date: Tue, 11 Jan 2022 13:25:29 +0530	[thread overview]
Message-ID: <20220111075545.1880-5-a-govindraju@ti.com> (raw)
In-Reply-To: <20220111075545.1880-1-a-govindraju@ti.com>

In Multi DDR subystems with interleaving support, the following needs to
configured,

- interleaving granular size and region
- EMIFs to be enabled
- EMIFs with ecc to be enabled
- EMIF separated or interleaved
- number of cycles of unsuccessful EMIF arbitration to wait before
  arbitrating for a different EMIF port, by default set to 3

Add support for configuring all the above by using a MSMC device

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
---
 drivers/ram/k3-ddrss/k3-ddrss.c | 158 ++++++++++++++++++++++++++++++++
 1 file changed, 158 insertions(+)

diff --git a/drivers/ram/k3-ddrss/k3-ddrss.c b/drivers/ram/k3-ddrss/k3-ddrss.c
index 96084d0b83d9..25e3976e6569 100644
--- a/drivers/ram/k3-ddrss/k3-ddrss.c
+++ b/drivers/ram/k3-ddrss/k3-ddrss.c
@@ -33,6 +33,75 @@
 #define SINGLE_DDR_SUBSYSTEM	0x1
 #define MULTI_DDR_SUBSYSTEM	0x2
 
+#define MULTI_DDR_CFG0  0x00114100
+#define MULTI_DDR_CFG1  0x00114104
+#define DDR_CFG_LOAD    0x00114110
+
+enum intrlv_gran {
+	GRAN_128B,
+	GRAN_512B,
+	GRAN_2KB,
+	GRAN_4KB,
+	GRAN_16KB,
+	GRAN_32KB,
+	GRAN_512KB,
+	GRAN_1GB,
+	GRAN_1_5GB,
+	GRAN_2GB,
+	GRAN_3GB,
+	GRAN_4GB,
+	GRAN_6GB,
+	GRAN_8GB,
+	GRAN_16GB
+};
+
+enum intrlv_size {
+	SIZE_0,
+	SIZE_128MB,
+	SIZE_256MB,
+	SIZE_512MB,
+	SIZE_1GB,
+	SIZE_2GB,
+	SIZE_3GB,
+	SIZE_4GB,
+	SIZE_6GB,
+	SIZE_8GB,
+	SIZE_12GB,
+	SIZE_16GB,
+	SIZE_32GB
+};
+
+struct k3_ddrss_data {
+	u32 flags;
+};
+
+enum ecc_enable {
+	DISABLE_ALL = 0,
+	ENABLE_0,
+	ENABLE_1,
+	ENABLE_ALL
+};
+
+enum emif_config {
+	INTERLEAVE_ALL = 0,
+	SEPR0,
+	SEPR1
+};
+
+enum emif_active {
+	EMIF_0 = 1,
+	EMIF_1,
+	EMIF_ALL
+};
+
+struct k3_msmc {
+	enum intrlv_gran gran;
+	enum intrlv_size size;
+	enum ecc_enable enable;
+	enum emif_config config;
+	enum emif_active active;
+};
+
 struct k3_ddrss_desc {
 	struct udevice *dev;
 	void __iomem *ddrss_ss_cfg;
@@ -512,3 +581,92 @@ U_BOOT_DRIVER(k3_ddrss) = {
 	.probe			= k3_ddrss_probe,
 	.priv_auto		= sizeof(struct k3_ddrss_desc),
 };
+
+static int k3_msmc_set_config(struct k3_msmc *msmc)
+{
+	u32 ddr_cfg0 = 0;
+	u32 ddr_cfg1 = 0;
+
+	ddr_cfg0 |= msmc->gran << 24;
+	ddr_cfg0 |= msmc->size << 16;
+	/* heartbeat_per, bit[4:0] setting to 3 is advisable */
+	ddr_cfg0 |= 3;
+
+	/* Program MULTI_DDR_CFG0 */
+	writel(ddr_cfg0, MULTI_DDR_CFG0);
+
+	ddr_cfg1 |= msmc->enable << 16;
+	ddr_cfg1 |= msmc->config << 8;
+	ddr_cfg1 |= msmc->active;
+
+	/* Program MULTI_DDR_CFG1 */
+	writel(ddr_cfg1, MULTI_DDR_CFG1);
+
+	/* Program DDR_CFG_LOAD */
+	writel(0x60000000, DDR_CFG_LOAD);
+
+	return 0;
+}
+
+static int k3_msmc_probe(struct udevice *dev)
+{
+	struct k3_msmc *msmc = dev_get_priv(dev);
+	int ret = 0;
+
+	/* Read the granular size from DT */
+	ret = dev_read_u32(dev, "intrlv-gran", &msmc->gran);
+	if (ret) {
+		dev_err(dev, "missing intrlv-gran property");
+		return -EINVAL;
+	}
+
+	/* Read the interleave region from DT */
+	ret = dev_read_u32(dev, "intrlv-size", &msmc->size);
+	if (ret) {
+		dev_err(dev, "missing intrlv-size property");
+		return -EINVAL;
+	}
+
+	/* Read ECC enable config */
+	ret = dev_read_u32(dev, "ecc-enable", &msmc->enable);
+	if (ret) {
+		dev_err(dev, "missing ecc-enable property");
+		return -EINVAL;
+	}
+
+	/* Read EMIF configuration */
+	ret = dev_read_u32(dev, "emif-config", &msmc->config);
+	if (ret) {
+		dev_err(dev, "missing emif-config property");
+		return -EINVAL;
+	}
+
+	/* Read EMIF active */
+	ret = dev_read_u32(dev, "emif-active", &msmc->active);
+	if (ret) {
+		dev_err(dev, "missing emif-active property");
+		return -EINVAL;
+	}
+
+	ret = k3_msmc_set_config(msmc);
+	if (ret) {
+		dev_err(dev, "error setting msmc config");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct udevice_id k3_msmc_ids[] = {
+	{ .compatible = "ti,j721s2-msmc"},
+	{}
+};
+
+U_BOOT_DRIVER(k3_msmc) = {
+	.name = "k3_msmc",
+	.of_match = k3_msmc_ids,
+	.id = UCLASS_MISC,
+	.probe = k3_msmc_probe,
+	.priv_auto = sizeof(struct k3_msmc),
+	.flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
+};
-- 
2.17.1


  parent reply	other threads:[~2022-01-11  7:57 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11  7:55 [PATCH v2 00/20] J721S2: Add initial support Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 01/20] remoteproc: k3_system_controller: Support optional boot_notification channel Aswath Govindraju
2022-01-13 14:12   ` Tom Rini
2022-01-17  5:31     ` Aswath Govindraju
2022-01-17  6:52       ` Aswath Govindraju
2022-01-17 13:54         ` Tom Rini
2022-01-18  5:56           ` Aswath Govindraju
2022-01-18 12:50             ` Tom Rini
2022-01-18 13:50               ` Nishanth Menon
2022-01-18 14:17                 ` Tom Rini
2022-01-11  7:55 ` [PATCH v2 02/20] ram: k3-ddrss: lpddr4_structs_if.h: Add a pointer to ddr instance Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 03/20] ram: k3-ddrss: Add support for multiple instances of DDR subsystems Aswath Govindraju
2022-01-11  7:55 ` Aswath Govindraju [this message]
2022-01-11  7:55 ` [PATCH v2 05/20] arm: K3: Add basic support for J721S2 SoC definition Aswath Govindraju
2022-01-13 14:13   ` Tom Rini
2022-01-11  7:55 ` [PATCH v2 06/20] drivers: dma: Add support for J721S2 Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 07/20] clk: clk-k3: Add support for J721S2 SoC Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 08/20] power: domain: ti: " Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 09/20] ram: k3-ddrss: " Aswath Govindraju
2022-01-13 14:15   ` Tom Rini
2022-01-17  6:31     ` Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 10/20] soc: ti: k3-socinfo: Add entry " Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 11/20] board: ti: j721s2: Add board support for J721S2 Aswath Govindraju
2022-01-13 14:16   ` Tom Rini
2022-01-17  6:42     ` Aswath Govindraju
2022-01-17 13:54       ` Tom Rini
2022-01-11  7:55 ` [PATCH v2 12/20] dt-bindings: ti-serdes-mux: Add defines for J721S2 SoC Aswath Govindraju
2022-01-13 14:17   ` Tom Rini
2022-01-17  5:41     ` Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 13/20] dt-bindings: pinctrl: k3: Introduce pinmux definitions for J721S2 Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 14/20] arm: dts: Add initial support for J721S2 SoC Aswath Govindraju
2022-01-13 14:08   ` Tom Rini
2022-01-13 14:16     ` Aswath Govindraju
2022-01-13 14:23       ` Tom Rini
2022-01-11  7:55 ` [PATCH v2 15/20] arm: dts: Add initial support for J721S2 System on Module Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 16/20] arm: dts: Add support for A72 specific J721S2 Common Processor Board Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 17/20] arm: dts: k3-j721s2: Add r5 specific dt support Aswath Govindraju
2022-01-13 14:11   ` Tom Rini
2022-01-11  7:55 ` [PATCH v2 18/20] arm: dts: k3-j721s2-ddr: Add DDR support Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 19/20] configs: j721s2_evm_r5_defconfig: Add R5 SPL specific defconfig Aswath Govindraju
2022-01-11  7:55 ` [PATCH v2 20/20] configs: j721s2_evm_a72_defconfig: Add A72 " Aswath Govindraju
2022-01-18  7:30 ` [PATCH v2 00/20] J721S2: Add initial support Aswath Govindraju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220111075545.1880-5-a-govindraju@ti.com \
    --to=a-govindraju@ti.com \
    --cc=andre.przywara@arm.com \
    --cc=christianshewitt@gmail.com \
    --cc=d-gerlach@ti.com \
    --cc=d-huang@ti.com \
    --cc=festevam@denx.de \
    --cc=hnagalla@ti.com \
    --cc=j-keerthy@ti.com \
    --cc=jh80.chung@samsung.com \
    --cc=kever.yang@rock-chips.com \
    --cc=kishon@ti.com \
    --cc=kristo@kernel.org \
    --cc=lukma@denx.de \
    --cc=narmstrong@baylibre.com \
    --cc=nm@ti.com \
    --cc=pbrobinson@gmail.com \
    --cc=s-anna@ti.com \
    --cc=seanga2@gmail.com \
    --cc=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.com \
    --cc=wd@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.