From: Chris Morgan <macroalpha82@gmail.com>
To: u-boot@lists.denx.de
Cc: sjg@chromium.org, jernej.skrabec@gmail.com,
neil.armstrong@linaro.org, hdegoede@redhat.com,
andre.przywara@arm.com, jagan@amarulasolutions.com,
trini@konsulko.com, ryan@testtoast.com,
Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH 4/9] sunxi: H616: DRAM: Add alternative pin mapping
Date: Thu, 1 Aug 2024 17:55:14 -0500 [thread overview]
Message-ID: <20240801225519.336667-5-macroalpha82@gmail.com> (raw)
In-Reply-To: <20240801225519.336667-1-macroalpha82@gmail.com>
From: Jernej Skrabec <jernej.skrabec@gmail.com>
It seems that different dies need different PHY pin mapping. Select
alternatives based on "bond ID".
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Tested-by: Chris Morgan <macromorgan@hotmail.com>
---
arch/arm/mach-sunxi/dram_sun50i_h616.c | 59 +++++++++++++++++++-------
1 file changed, 44 insertions(+), 15 deletions(-)
diff --git a/arch/arm/mach-sunxi/dram_sun50i_h616.c b/arch/arm/mach-sunxi/dram_sun50i_h616.c
index b6638c519e..abb8ee760b 100644
--- a/arch/arm/mach-sunxi/dram_sun50i_h616.c
+++ b/arch/arm/mach-sunxi/dram_sun50i_h616.c
@@ -225,22 +225,43 @@ static void mctl_set_addrmap(const struct dram_config *config)
mctl_ctl->addrmap[8] = 0x3F3F;
}
-static const u8 phy_init[] = {
+static const u8 phy_addr_maps[2][27] = {
#ifdef CONFIG_SUNXI_DRAM_H616_DDR3_1333
- 0x07, 0x0b, 0x02, 0x16, 0x0d, 0x0e, 0x14, 0x19,
- 0x0a, 0x15, 0x03, 0x13, 0x04, 0x0c, 0x10, 0x06,
- 0x0f, 0x11, 0x1a, 0x01, 0x12, 0x17, 0x00, 0x08,
- 0x09, 0x05, 0x18
+ {
+ 0x07, 0x0b, 0x02, 0x16, 0x0d, 0x0e, 0x14, 0x19,
+ 0x0a, 0x15, 0x03, 0x13, 0x04, 0x0c, 0x10, 0x06,
+ 0x0f, 0x11, 0x1a, 0x01, 0x12, 0x17, 0x00, 0x08,
+ 0x09, 0x05, 0x18
+ }, {
+ 0x08, 0x02, 0x12, 0x05, 0x15, 0x17, 0x18, 0x0b,
+ 0x14, 0x07, 0x04, 0x13, 0x0c, 0x00, 0x16, 0x1a,
+ 0x0a, 0x11, 0x03, 0x10, 0x0e, 0x01, 0x0d, 0x19,
+ 0x06, 0x09, 0x0f
+ }
#elif defined(CONFIG_SUNXI_DRAM_H616_LPDDR3)
- 0x18, 0x06, 0x00, 0x05, 0x04, 0x03, 0x09, 0x02,
- 0x08, 0x01, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x07,
- 0x17, 0x19, 0x1a
+ {
+ 0x18, 0x06, 0x00, 0x05, 0x04, 0x03, 0x09, 0x02,
+ 0x08, 0x01, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x07,
+ 0x17, 0x19, 0x1a
+ }, {
+ 0x18, 0x00, 0x04, 0x09, 0x06, 0x05, 0x02, 0x19,
+ 0x17, 0x03, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x07,
+ 0x08, 0x01, 0x1a
+ }
#elif defined(CONFIG_SUNXI_DRAM_H616_LPDDR4)
- 0x02, 0x00, 0x17, 0x05, 0x04, 0x19, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x01,
- 0x18, 0x03, 0x1a
+ {
+ 0x02, 0x00, 0x17, 0x05, 0x04, 0x19, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x01,
+ 0x18, 0x03, 0x1a
+ }, {
+ 0x03, 0x00, 0x17, 0x05, 0x02, 0x19, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x01,
+ 0x18, 0x04, 0x1a
+ }
#endif
};
@@ -887,6 +908,7 @@ static bool mctl_phy_init(const struct dram_para *para,
struct sunxi_mctl_ctl_reg * const mctl_ctl =
(struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
u32 val, val2, *ptr, mr0, mr2;
+ const u8 *map;
int i;
if (para->type == SUNXI_DRAM_TYPE_LPDDR4)
@@ -942,8 +964,15 @@ static bool mctl_phy_init(const struct dram_para *para,
writel(val2, SUNXI_DRAM_PHY0_BASE + 0x37c);
ptr = (u32 *)(SUNXI_DRAM_PHY0_BASE + 0xc0);
- for (i = 0; i < ARRAY_SIZE(phy_init); i++)
- writel(phy_init[i], &ptr[i]);
+ val = readl(SUNXI_SID_BASE);
+ if (((val & 0xfbff) == 0x5000) ||
+ ((val & 0xfeff) == 0x5c00) ||
+ ((val & 0xf7ff) == 0x2000))
+ map = phy_addr_maps[0];
+ else
+ map = phy_addr_maps[1];
+ for (i = 0; i < ARRAY_SIZE(phy_addr_maps[0]); i++)
+ writel(map[i], &ptr[i]);
if (para->tpr10 & TPR10_CA_BIT_DELAY)
mctl_phy_ca_bit_delay_compensation(para, config);
--
2.34.1
next prev parent reply other threads:[~2024-08-01 22:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 22:55 [PATCH 0/9] Add Anbernic RG35XX-2024 Chris Morgan
2024-08-01 22:55 ` [PATCH 1/9] sunxi: H616: dram: DDR3: adjust settings Chris Morgan
2024-09-04 23:38 ` Andre Przywara
2024-08-01 22:55 ` [PATCH 2/9] sunxi: H616: dram: LPDDR3: " Chris Morgan
2024-08-03 13:17 ` Mikhail Kalashnikov
2024-09-04 23:07 ` Andre Przywara
2024-08-01 22:55 ` [PATCH 3/9] sunxi: H616: dram: LPDDR4: " Chris Morgan
2024-08-03 12:29 ` Mikhail Kalashnikov
2024-08-14 21:06 ` Chris Morgan
2024-08-15 22:03 ` Chris Morgan
2024-08-16 16:39 ` Mikhail Kalashnikov
2024-08-01 22:55 ` Chris Morgan [this message]
2024-08-01 22:55 ` [PATCH 5/9] sunxi: H616: DRAM: Adjust configuration procedure Chris Morgan
2024-08-01 22:55 ` [PATCH 6/9] sunxi: H616: DRAM: Adjust size scan procedure Chris Morgan
2024-08-01 22:55 ` [PATCH 7/9] sunxi: H616: dram: Update mbus priorities Chris Morgan
2024-08-01 22:55 ` [PATCH 8/9] sunxi: dts: arm/arm64: update sun50i-h616.dtsi from Linux-v6.11-rc1 Chris Morgan
2024-08-01 22:55 ` [PATCH 9/9] sunxi: Add support for Anbernic RG35XX-2024 Chris Morgan
2024-08-02 6:54 ` Sumit Garg
2024-08-02 9:57 ` Andre Przywara
2024-08-02 10:38 ` Sumit Garg
2024-08-02 15:04 ` Chris Morgan
2024-08-03 13:28 ` Mikhail Kalashnikov
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=20240801225519.336667-5-macroalpha82@gmail.com \
--to=macroalpha82@gmail.com \
--cc=andre.przywara@arm.com \
--cc=hdegoede@redhat.com \
--cc=jagan@amarulasolutions.com \
--cc=jernej.skrabec@gmail.com \
--cc=macromorgan@hotmail.com \
--cc=neil.armstrong@linaro.org \
--cc=ryan@testtoast.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.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.