From: Samuel Holland <samuel@sholland.org>
To: Icenowy Zheng <icenowy@sipeed.com>,
Jagan Teki <jagan@amarulasolutions.com>,
Andre Przywara <andre.przywara@arm.com>,
Jernej Skrabec <jernej.skrabec@siol.net>
Cc: u-boot@lists.denx.de, linux-sunxi@lists.linux.dev
Subject: Re: [RFC PATCH 07/13] sunxi: add support for R329 DRAM controller
Date: Fri, 5 Nov 2021 22:06:12 -0500 [thread overview]
Message-ID: <28efdf36-e1a3-6acd-c18e-2d68eca13aaf@sholland.org> (raw)
In-Reply-To: <20210722063015.421923-8-icenowy@sipeed.com>
On 7/22/21 1:30 AM, Icenowy Zheng wrote:
> R329 has a new DRAM controller, which looks like a combination of the
> H6/H616 MCTL_COM part and the SUNXI_DW MCTL_CTL part. This design has
> already got reused by Allwinner, and V831/V833 SoCs have similar
> memory controller.
>
> Add support for it. To prepare for further support of other SoCs,
> routines with socid parameter are added, although not checked now.
>
> Signed-off-by: Icenowy Zheng <icenowy@sipeed.com>
I cannot really review the DRAM init part. But it works, so that's
probably good enough.
Tested-by: Samuel Holland <samuel@sholland.org>
There are a couple of magic values I happen to have an explanation for:
> diff --git a/arch/arm/mach-sunxi/dram_sun50i_r329.c b/arch/arm/mach-sunxi/dram_sun50i_r329.c
> new file mode 100644
> index 0000000000..730883999c
> --- /dev/null
> +++ b/arch/arm/mach-sunxi/dram_sun50i_r329.c
> ...> +unsigned long sunxi_dram_init(void)
> +{
> + struct sunxi_mctl_com_reg * const mctl_com =
> + (struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
> + struct sunxi_mctl_ctl_reg * const mctl_ctl =
> + (struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
> +
> + struct dram_para para = {
> + .dual_rank = 0,
> + .bus_full_width = 1,
> + .row_bits = 16,
> + .bank_bits = 3,
> + .page_size = 8192,
> +
> + .dx_read_delays = SUN50I_R329_DX_READ_DELAYS,
> + .dx_write_delays = SUN50I_R329_DX_WRITE_DELAYS,
> + .ac_delays = SUN50I_R329_AC_DELAYS,
> + };
> +
> + /* Unknown magic */
> + writel(0x10, 0x07010250);
This is VDD_SYS_POWEROFF_GATING_REG, presumably disabling pad hold.
> + writel(0x330000, 0x07010310);
> + writel(0x330003, 0x07010310);
This is a resistor calibration process. See here:
https://github.com/smaeul/sun20i_d1_spl/blob/342cb1d8/include/arch/cpu_ncat.h#L172
https://github.com/smaeul/sun20i_d1_spl/blob/342cb1d8/board/sun20iw1p1/clock.c#L186
Some other BSP code has:
#define REG_CALIB_CONTROL_REG 0x0310
#define OHMS200_REG 0x0314
#define OHMS240_REG 0x0318
#define REG_CALIB_STATUS_REG 0x031c
So this suggests we are calibrating the termination resistors.
Regards,
Samuel
> +
> +#if defined(CONFIG_MACH_SUN50I_R329)
> + uint16_t socid = SOCID_R329;
> +#endif
> +
> + mctl_sys_init(¶);
> + if (mctl_channel_init(socid, ¶))
> + return 0;
> +
> + udelay(1);
> +
> + clrbits_le32(&mctl_ctl->unk_0x0a0, 0xffff);
> + clrbits_le32(&mctl_ctl->pwrctl, 0x1);
> +
> + /* HDR/DDR dynamic mode */
> + clrbits_le32(&mctl_ctl->pgcr[0], 0xf000);
> +
> + /* power down zq calibration module for power save */
> + setbits_le32(&mctl_ctl->zqcr, ZQCR_PWRDOWN);
> +
> + /* DQ hold disable (tpr13[26] == 1) */
> + clrbits_le32(&mctl_ctl->pgcr[2], (1 << 13));
> +
> + mctl_auto_detect_dram_size(¶);
> + mctl_apply_para(¶);
> +
> + /* enable master access */
> + writel(0xffffffff, &mctl_com->maer0);
> + writel(0x7f, &mctl_com->maer1);
> + writel(0xffff, &mctl_com->maer2);
> +
> + return (1UL << (para.row_bits + para.bank_bits)) * para.page_size *
> + (para.dual_rank ? 2 : 1);
> +}
next prev parent reply other threads:[~2021-11-06 3:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 6:30 [RFC PATCH 00/13] Add support for Allwinner R329 Icenowy Zheng
2021-07-22 6:30 ` [RFC PATCH 01/13] sunxi: decide the inclusion of SCP by SCP_ADDR existence Icenowy Zheng
2021-07-22 13:35 ` Andre Przywara
2021-07-22 6:30 ` [RFC PATCH 02/13] sunxi: only include alias for eMMC when mmc2 used Icenowy Zheng
2021-07-22 13:46 ` Andre Przywara
2021-07-22 6:30 ` [RFC PATCH 03/13] mmc: sunxi: conditionally include MMC2 initialization code Icenowy Zheng
2021-07-22 13:48 ` Andre Przywara
2021-07-22 6:30 ` [RFC PATCH 04/13] sunxi: add memory addresses for R329 SoC Icenowy Zheng
2021-11-06 2:58 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 05/13] sunxi: add support for R329 clocks Icenowy Zheng
2021-11-06 2:59 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 06/13] sunxi: add support for basical pinmux setup on R329 Icenowy Zheng
2021-11-06 3:01 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 07/13] sunxi: add support for R329 DRAM controller Icenowy Zheng
2021-11-06 3:06 ` Samuel Holland [this message]
2021-07-22 6:30 ` [RFC PATCH 08/13] sunxi: add Kconfig option for R329 Icenowy Zheng
2021-11-06 3:07 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 09/13] sunxi: sync R329 CCU binding headers from internal WIP kernel tree Icenowy Zheng
2021-07-22 6:30 ` [RFC PATCH 10/13] clk: sunxi: add support for R329 in sunxi DM clock driver Icenowy Zheng
2021-11-06 3:08 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 11/13] mmc: sunxi: add support for R329 MMC controller Icenowy Zheng
2021-11-06 3:10 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 12/13] sunxi: sync R329 DTs from internal WIP kernel tree Icenowy Zheng
2021-11-06 3:12 ` Samuel Holland
2021-07-22 6:30 ` [RFC PATCH 13/13] sunxi: add support for Sipeed Maix IIA Dock board Icenowy Zheng
2021-11-06 3:22 ` [RFC PATCH 00/13] Add support for Allwinner R329 Samuel Holland
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=28efdf36-e1a3-6acd-c18e-2d68eca13aaf@sholland.org \
--to=samuel@sholland.org \
--cc=andre.przywara@arm.com \
--cc=icenowy@sipeed.com \
--cc=jagan@amarulasolutions.com \
--cc=jernej.skrabec@siol.net \
--cc=linux-sunxi@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).