All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryder Lee <ryder.lee@mediatek.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 15/18] ram: MediaTek: add DDR3 driver for MT7629 SoC
Date: Thu, 25 Oct 2018 17:38:55 +0800	[thread overview]
Message-ID: <1540460335.8092.20.camel@mtkswgap22> (raw)
In-Reply-To: <CAPnjgZ121_vn6=2eKc2JSGRboFvD0xnshWerRp-6XXTShdoR3A@mail.gmail.com>

On Wed, 2018-10-24 at 21:30 -0600, Simon Glass wrote:
> On 12 October 2018 at 01:01, Ryder Lee <ryder.lee@mediatek.com> wrote:
> > This patch adds a DDR3 driver for MT7629 SoC.
> >
> > Signed-off-by: Wu Zou <wu.zou@mediatek.com>
> > Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
> > ---
> >  drivers/ram/Makefile               |   1 +
> >  drivers/ram/mediatek/Makefile      |   7 +
> >  drivers/ram/mediatek/ddr3-mt7629.c | 766 +++++++++++++++++++++++++++++++++++++
> >  3 files changed, 774 insertions(+)
> >  create mode 100644 drivers/ram/mediatek/Makefile
> >  create mode 100644 drivers/ram/mediatek/ddr3-mt7629.c
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Thoughts below.
> 
> [..]
> 
> > +#define DDRPHY_PLL1                    0x0000
> > +#define DDRPHY_PLL2                    0x0004
> 
> Why not use a C struct for these registers?

These are copy-n-paste from our SDK. I've considered converting these
into C struct but it will take me a while. Just let it be.

But, I could do that if you insist.

> [..]
> 
> > +       writel(0x400, priv->dramc_ao + DRAMC_MRS);
> > +       writel(0x1d7000, priv->dramc_ao + DRAMC_MRS);
> > +       writel(0x1, priv->dramc_ao + DRAMC_SPCMD);
> > +       writel(0x0, priv->dramc_ao + DRAMC_SPCMD);
> > +       udelay(100);
> 
> Are these delays specified in a datasheet? Why did you chose 100?
> Perhaps add an enum for this value? Is there a way to check for when
> the hardware is ready, e.g. by reading a registers in a loop?

Rule of thumb. There is no registers to read here, but I can try to
reduce the delay time.

> [..]
> 
> > +static int mtk_ddr3_probe(struct udevice *dev)
> > +{
> > +       struct mtk_ddr3_priv *priv = dev_get_priv(dev);
> > +
> > +       priv->emi = dev_read_addr_index(dev, 0);
> > +       if (priv->emi == FDT_ADDR_T_NONE)
> > +               return -EINVAL;
> > +
> > +       priv->ddrphy = dev_read_addr_index(dev, 1);
> > +       if (priv->ddrphy == FDT_ADDR_T_NONE)
> > +               return -EINVAL;
> > +
> > +       priv->dramc_ao = dev_read_addr_index(dev, 2);
> > +       if (priv->dramc_ao == FDT_ADDR_T_NONE)
> > +               return -EINVAL;
> > +
> > +#ifdef CONFIG_SPL_BUILD
> > +       int ret;
> > +
> > +       ret = clk_get_by_index(dev, 0, &priv->phy);
> > +       if (ret)
> > +               return ret;
> > +
> > +       ret = clk_get_by_index(dev, 1, &priv->phy_mux);
> > +       if (ret)
> > +               return ret;
> > +
> > +       ret = clk_get_by_index(dev, 2, &priv->mem);
> > +       if (ret)
> > +               return ret;
> > +
> > +       ret = clk_get_by_index(dev, 3, &priv->mem_mux);
> > +       if (ret)
> > +               return ret;
> 
> Do you have phandles for these clocks? I only worry that it is a bit
> brittle to have them numbered.

Yes. I choose clk_get_by_index() here as I stripped the 'clock-names'
via CONFIG_OF_SPL_REMOVE_PROPS to reduce the size .

Also I don't understand why we cannot use clk_set_defaults() in
pre-relocate state?


Ryder

> > +
> > +       ret = mtk_ddr3_init(dev);
> > +       if (ret)
> > +               return ret;
> > +#endif
> > +       return 0;
> > +}
> > +
> 
> Regards,
> Simon

  reply	other threads:[~2018-10-25  9:38 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  7:00 [U-Boot] [PATCH v2 00/18] Add U-Boot support for MediaTek SoCs - MT7623n & MT7629 Ryder Lee
2018-10-12  7:00 ` [U-Boot] [PATCH v2 01/18] tools: MediaTek: add MTK boot header generation to mkimage Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-25 13:11     ` Ryder Lee
2018-10-12  7:00 ` [U-Boot] [PATCH v2 02/18] arm: dts: MediaTek: add device tree for MT7629 Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-12  7:00 ` [U-Boot] [PATCH v2 03/18] arm: dts: MediaTek: add device tree for MT7623 Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-12  7:00 ` [U-Boot] [PATCH v2 04/18] arm: MediaTek: add basic support for MT7629 boards Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-25  6:44     ` Ryder Lee
2018-10-12  7:00 ` [U-Boot] [PATCH v2 05/18] arm: MediaTek: add basic support for MT7623 boards Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-25  6:40     ` Ryder Lee
2018-10-12  7:00 ` [U-Boot] [PATCH v2 06/18] clk: MediaTek: add clock driver for MT7629 SoC Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-25  6:37     ` Ryder Lee
2018-11-03  6:08       ` Simon Glass
2018-10-12  7:00 ` [U-Boot] [PATCH v2 07/18] clk: MediaTek: add clock driver for MT7623 SoC Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-12  7:00 ` [U-Boot] [PATCH v2 08/18] timer: MediaTek: add timer driver for MediaTek SoCs Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-12  7:00 ` [U-Boot] [PATCH v2 09/18] watchdog: MediaTek: add watchdog " Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-12  7:00 ` [U-Boot] [PATCH v2 10/18] pinctrl: MediaTek: add pinctrl driver for MT7629 SoC Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-25  6:08     ` Ryder Lee
2018-11-03  6:08       ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 11/18] pinctrl: MediaTek: add pinctrl driver for MT7623 SoC Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-25  6:13     ` Ryder Lee
2018-11-03  6:08       ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 12/18] power domain: MediaTek: add power domain driver for MT7629 SoC Ryder Lee
2018-10-25  3:29   ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 13/18] power domain: MediaTek: add power domain driver for MT7623 SoC Ryder Lee
2018-10-25  3:30   ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 14/18] serial: 16550: allow the driver to support MediaTek serial Ryder Lee
2018-10-25  3:30   ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 15/18] ram: MediaTek: add DDR3 driver for MT7629 SoC Ryder Lee
2018-10-25  3:30   ` Simon Glass
2018-10-25  9:38     ` Ryder Lee [this message]
2018-10-26 16:53       ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 16/18] mmc: mtk-sd: add SD/MMC host controller driver for MT7623 SoC Ryder Lee
2018-10-25  3:30   ` Simon Glass
2018-10-12  7:01 ` [U-Boot] [PATCH v2 17/18] spi: mtk_qspi: add qspi driver for MT7629 SoC Ryder Lee
2018-10-25  3:30   ` Simon Glass
2018-10-26  6:33   ` Jagan Teki
2018-11-14  9:04   ` Jagan Teki
2018-11-14 12:53     ` Guochun Mao
2018-11-21  9:38       ` Jagan Teki
2018-11-21 11:46         ` Guochun Mao
2018-11-22  6:21           ` Jagan Teki
2018-11-22  8:58             ` Guochun Mao
2018-11-23  5:43               ` Jagan Teki
2018-11-23  8:24                 ` Guochun Mao
2018-10-12  7:01 ` [U-Boot] [PATCH v2 18/18] MAINTAINERS: add an entry for MediaTek Ryder Lee
2018-10-25  3:30   ` Simon Glass

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=1540460335.8092.20.camel@mtkswgap22 \
    --to=ryder.lee@mediatek.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.