From patchwork Tue Jan 11 07:55:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aswath Govindraju X-Patchwork-Id: 1578302 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256 header.s=ti-com-17Q1 header.b=vBCuXWhz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JY31t1FmTz9s1l for ; Tue, 11 Jan 2022 18:57:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D2FE58302C; Tue, 11 Jan 2022 08:56:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="vBCuXWhz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C5C98302C; Tue, 11 Jan 2022 08:56:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8DA1F83057 for ; Tue, 11 Jan 2022 08:56:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=a-govindraju@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 20B7uIrw051165; Tue, 11 Jan 2022 01:56:18 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1641887778; bh=DWnEUMVfpNaggGLyCBXyGtjT/GitbQwHycLr6wJCxyw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=vBCuXWhzoKuFX9wXP9H4DeLw6rQZIcdOnywbERPwAeCdHzrbqo8zpWYO/V9YgYACd y0z/s6eaKwDafeb9eWia4RIMlTudKLNxkuG7iRQg0OU+3ZLeO005pywjspfjYZdHkd eHBVSJxUmUWcuxRi7eNyqfxsjzGxsp15KQDQjYl0= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 20B7uIPv092699 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 11 Jan 2022 01:56:18 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Tue, 11 Jan 2022 01:56:17 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Tue, 11 Jan 2022 01:56:17 -0600 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 20B7tktH016512; Tue, 11 Jan 2022 01:56:12 -0600 From: Aswath Govindraju To: CC: , Wolfgang Denk , Hari Nagalla , David Huang , Keerthy , Dave Gerlach , Suman Anna , Nishanth Menon , Tero Kristo , Kishon Vijay Abraham I , Vignesh Raghavendra , Christian Hewitt , Tim Harvey , Peter Robinson , Kever Yang , Neil Armstrong , Fabio Estevam , Andre Przywara , Jaehoon Chung , Sean Anderson , Lukasz Majewski , Aswath Govindraju 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 Message-ID: <20220111075545.1880-5-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220111075545.1880-1-a-govindraju@ti.com> References: <20220111075545.1880-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- 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, +};