From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 09/14] sunxi: dram: Add a helper function 'mctl_get_number_of_lanes'
Date: Fri, 25 Jul 2014 07:26:32 +0300 [thread overview]
Message-ID: <20140725072632.26c0aba4@i7> (raw)
In-Reply-To: <1405971693.4100.21.camel@hastur.hellion.org.uk>
On Mon, 21 Jul 2014 20:41:33 +0100
Ian Campbell <ijc@hellion.org.uk> wrote:
> On Fri, 2014-07-18 at 19:23 +0300, Siarhei Siamashka wrote:
> > It is going to be useful in more than one place.
> >
> > Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
> > ---
> > arch/arm/cpu/armv7/sunxi/dram.c | 30 +++++++++++++++++++-----------
> > 1 file changed, 19 insertions(+), 11 deletions(-)
> >
> > diff --git a/arch/arm/cpu/armv7/sunxi/dram.c b/arch/arm/cpu/armv7/sunxi/dram.c
> > index 18a5c3b..49d1770 100644
> > --- a/arch/arm/cpu/armv7/sunxi/dram.c
> > +++ b/arch/arm/cpu/armv7/sunxi/dram.c
> > @@ -115,23 +115,31 @@ static void mctl_enable_dll0(u32 phase)
> > udelay(22);
> > }
> >
> > +/* Get the number of DDR byte lanes */
> > +static u32 mctl_get_number_of_lanes(void)
> > +{
> > + struct sunxi_dram_reg *dram = (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE;
> > + switch (readl(&dram->dcr) & DRAM_DCR_BUS_WIDTH_MASK) {
> > + case DRAM_DCR_BUS_WIDTH(DRAM_DCR_BUS_WIDTH_32BIT):
> > + return 4;
> > + case DRAM_DCR_BUS_WIDTH(DRAM_DCR_BUS_WIDTH_16BIT):
> > + return 2;
> > + default:
> > + return 1;
> > + }
> > +}
> > +
> > /*
> > * Note: This differs from pm/standby in that it checks the bus width
> > */
> > static void mctl_enable_dllx(u32 phase)
> > {
> > struct sunxi_dram_reg *dram = (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE;
> > - u32 i, n, bus_width;
> > -
> > - bus_width = readl(&dram->dcr);
> > + u32 i, number_of_lanes;
> >
> > - if ((bus_width & DRAM_DCR_BUS_WIDTH_MASK) ==
> > - DRAM_DCR_BUS_WIDTH(DRAM_DCR_BUS_WIDTH_32BIT))
> > - n = DRAM_DCR_NR_DLLCR_32BIT;
> > - else
> > - n = DRAM_DCR_NR_DLLCR_16BIT;
>
> Either DRAM_DCR_NR_DLLCR_??BIT are obsolete now and should be removed or
> they should be be adjusted and used in the new function.
>
> ISTM they don't add much so removing would be fine by me.
Agreed, I also think that they are better to be dropped.
> > + number_of_lanes = mctl_get_number_of_lanes();
>
> There is a subtle functional change here since number_of_lanes can be 1
> whereas n could never have been 2. Is that intended/ok? Please mention
> in the commit message.
I tried to experiment with setting the 8-bit bus width and it is
semi-workable (single byte access is OK, but accessing more than
one byte is broken). This part of the patch looks like a forgotten
leftover of these experiments. But it clearly has no practical
value and we only normally deal with the 16-bit or 32-bit bus width.
The most correct way of handling this unexpected code branch would
be to panic. But that's an unnecessarily increase of the code size.
So I think that the best solution is just to keep the old code
logic (expect only 16-bit or 32-bit bus width and 2 or 4 lanes).
--
Best regards,
Siarhei Siamashka
next prev parent reply other threads:[~2014-07-25 4:26 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-18 16:22 [U-Boot] [PATCH 00/14] sunxi: Allwinner A10/A13/A20 DRAM controller fixes Siarhei Siamashka
2014-07-18 16:22 ` [U-Boot] [PATCH 01/14] sunxi: dram: Remove useless 'dramc_scan_dll_para()' function Siarhei Siamashka
2014-07-21 18:42 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 02/14] sunxi: dram: Remove broken super-standby remnants Siarhei Siamashka
2014-07-21 18:45 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 03/14] sunxi: dram: Respect the DDR3 reset timing requirements Siarhei Siamashka
2014-07-21 18:46 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 04/14] sunxi: dram: Code cleanup and comments for the CKE delay handling Siarhei Siamashka
2014-07-21 18:51 ` Ian Campbell
2014-07-25 1:41 ` Siarhei Siamashka
2014-07-25 7:27 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 05/14] sunxi: dram: Code cleanup for the impedance calibration Siarhei Siamashka
2014-07-21 19:20 ` Ian Campbell
2014-07-25 3:44 ` [U-Boot] [linux-sunxi] " Siarhei Siamashka
2014-07-25 7:30 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 06/14] sunxi: dram: Configurable MBUS clock speed (use PLL5 or PLL6) Siarhei Siamashka
2014-07-21 19:31 ` Ian Campbell
2014-07-25 4:00 ` Siarhei Siamashka
2014-07-25 7:31 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 07/14] sunxi: dram: Use divisor P=1 for PLL5 Siarhei Siamashka
2014-07-21 19:35 ` Ian Campbell
2014-07-18 16:22 ` [U-Boot] [PATCH 08/14] sunxi: dram: Improve DQS gate data training error handling Siarhei Siamashka
2014-07-21 19:36 ` Ian Campbell
2014-07-18 16:23 ` [U-Boot] [PATCH 09/14] sunxi: dram: Add a helper function 'mctl_get_number_of_lanes' Siarhei Siamashka
2014-07-21 19:41 ` Ian Campbell
2014-07-25 4:26 ` Siarhei Siamashka [this message]
2014-07-25 7:33 ` Ian Campbell
2014-07-18 16:23 ` [U-Boot] [PATCH 10/14] sunxi: dram: Configurable DQS gating window mode and delay Siarhei Siamashka
2014-07-18 16:23 ` [U-Boot] [PATCH 11/14] sunxi: dram: Support sun4i (Allwinner A10) and sun5i (Allwinner A13) Siarhei Siamashka
2014-07-21 19:49 ` Ian Campbell
2014-07-18 16:23 ` [U-Boot] [PATCH 12/14] sunxi: dram: Drop DDR2 support and assume only single rank DDR3 memory Siarhei Siamashka
2014-07-21 19:51 ` Ian Campbell
2014-07-25 4:36 ` Siarhei Siamashka
2014-07-18 16:23 ` [U-Boot] [PATCH 13/14] sunxi: dram: Derive write recovery delay from DRAM clock speed Siarhei Siamashka
2014-07-21 19:52 ` Ian Campbell
2014-07-18 16:23 ` [U-Boot] [PATCH 14/14] sunxi: dram: Autodetect DDR3 bus width and density Siarhei Siamashka
2014-07-21 19:54 ` Ian Campbell
2014-07-19 10:59 ` [U-Boot] [PATCH 00/14] sunxi: Allwinner A10/A13/A20 DRAM controller fixes Hans de Goede
2014-07-21 19:58 ` Ian Campbell
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=20140725072632.26c0aba4@i7 \
--to=siarhei.siamashka@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox