All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Kuske <jenskuske@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 2/6] sunxi: Rename bus-width related macros in H3 DRAM code
Date: Sat, 11 Feb 2017 17:38:06 +0100	[thread overview]
Message-ID: <95490560-6c3b-dde2-c7a2-b4c74f448811@gmail.com> (raw)
In-Reply-To: <20170211150843.47865-2-icenowy@aosc.xyz>

Hi,

renaming is not quite enough, see the comments below.

On 11.02.2017 16:08, Icenowy Zheng wrote:
> The DesignWare DRAM controller used by H3 and newer SoCs use a bit to
> identify whether the DRAM is half-width.
> 
> As H3 itself come with 32-bit DRAM, the two modes of the bit used to be
> named "MCTL_CR_32BIT" and "MCTL_CR_16BIT", but for SoCs with 16-bit DRAM
> they're really 8-bit and 16-bit.
> 
> Rename the bit's macro, and also rename the variable name in
> dram_sun8i_h3.c.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
> ---
>  arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h |  6 +++---
>  arch/arm/mach-sunxi/dram_sunxi_dw.c             | 11 ++++++-----
>  2 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h b/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h
> index 25d07d9863..48bd6f7c0f 100644
> --- a/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h
> +++ b/arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h
> @@ -52,9 +52,9 @@ struct sunxi_mctl_com_reg {
>  #define MCTL_CR_SEQUENTIAL	(0x1 << 15)
>  #define MCTL_CR_INTERLEAVED	(0x0 << 15)
>  
> -#define MCTL_CR_32BIT		(0x1 << 12)
> -#define MCTL_CR_16BIT		(0x0 << 12)
> -#define MCTL_CR_BUS_WIDTH(x)	((x) == 32 ? MCTL_CR_32BIT : MCTL_CR_16BIT)
> +#define MCTL_CR_FULL_WIDTH	(0x1 << 12)
> +#define MCTL_CR_HALF_WIDTH	(0x0 << 12)
> +#define MCTL_CR_BUS_FULL_WIDTH(x)	((x) << 12)
>  
>  #define MCTL_CR_PAGE_SIZE(x)	((fls(x) - 4) << 8)
>  #define MCTL_CR_ROW_BITS(x)	(((x) - 1) << 4)
> diff --git a/arch/arm/mach-sunxi/dram_sunxi_dw.c b/arch/arm/mach-sunxi/dram_sunxi_dw.c
> index 9f7cc7fd4c..0c73a43075 100644
> --- a/arch/arm/mach-sunxi/dram_sunxi_dw.c
> +++ b/arch/arm/mach-sunxi/dram_sunxi_dw.c
> @@ -28,7 +28,7 @@
>  #define LINES_PER_BYTE_LANE	(BITS_PER_BYTE + 3)
>  struct dram_para {
>  	u16 page_size;
> -	u8 bus_width;
> +	u8 bus_full_width;
>  	u8 dual_rank;
>  	u8 row_bits;
>  	const u8 dx_read_delays[NR_OF_BYTE_LANES][LINES_PER_BYTE_LANE];
> @@ -358,7 +358,8 @@ static void mctl_set_cr(struct dram_para *para)
>  			(struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
>  
>  	writel(MCTL_CR_BL8 | MCTL_CR_2T | MCTL_CR_DDR3 | MCTL_CR_INTERLEAVED |
> -	       MCTL_CR_EIGHT_BANKS | MCTL_CR_BUS_WIDTH(para->bus_width) |
> +	       MCTL_CR_EIGHT_BANKS |
> +	       MCTL_CR_BUS_FULL_WIDTH(para->bus_full_width) |
>  	       (para->dual_rank ? MCTL_CR_DUAL_RANK : MCTL_CR_SINGLE_RANK) |
>  	       MCTL_CR_PAGE_SIZE(para->page_size) |
>  	       MCTL_CR_ROW_BITS(para->row_bits), &mctl_com->cr);
> @@ -471,7 +472,7 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
>  	}
>  
>  	/* set half DQ */
> -	if (para->bus_width != 32) {
> +	if (!para->bus_full_width) {
>  		writel(0x0, &mctl_ctl->dx[2].gcr);
>  		writel(0x0, &mctl_ctl->dx[3].gcr);

This is not correct, it still disables byte 2 and 3, which don't even
exist on 16bit bus devices. On a 16bit device dx[1] would have do be
disabled for half width.

>  	}
> @@ -509,7 +510,7 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
>  		    ((readl(&mctl_ctl->dx[3].gsr[0]) >> 24) & 0x1)) {
>  			writel(0x0, &mctl_ctl->dx[2].gcr);
>  			writel(0x0, &mctl_ctl->dx[3].gcr);
> -			para->bus_width = 16;
> +			para->bus_full_width = 0;

Same here, it only detects that byte 2 and 3 are missing, to detect half
width on 16bit devices byte 1 would have to be checked in the if above.
Also, the rank detection above must not check byte 1 on 16bit devices.

>  		}
>  
>  		mctl_set_cr(para);
> @@ -613,7 +614,7 @@ unsigned long sunxi_dram_init(void)
>  
>  	struct dram_para para = {
>  		.dual_rank = 0,
> -		.bus_width = 32,
> +		.bus_full_width = 1,
>  		.row_bits = 15,
>  		.page_size = 4096,
>  
> 

  reply	other threads:[~2017-02-11 16:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-11 15:08 [U-Boot] [RFC PATCH 1/6] sunxi: makes an invisible option for H3-like DRAM controllers Icenowy Zheng
2017-02-11 15:08 ` [U-Boot] [RFC PATCH 2/6] sunxi: Rename bus-width related macros in H3 DRAM code Icenowy Zheng
2017-02-11 16:38   ` Jens Kuske [this message]
2017-02-12  4:09     ` [U-Boot] [linux-sunxi] " Icenowy Zheng
2017-02-11 15:08 ` [U-Boot] [RFC PATCH 3/6] sunxi: add bank detection code to H3 DRAM initialization code Icenowy Zheng
2017-02-11 15:08 ` [U-Boot] [RFC PATCH 4/6] sunxi: Add selective DRAM type and timing Icenowy Zheng
2017-02-11 16:59   ` Jens Kuske
2017-02-12  4:05     ` [U-Boot] [linux-sunxi] " Icenowy Zheng
2017-02-11 15:08 ` [U-Boot] [RFC PATCH 5/6] sunxi: add support for the DDR2 in V3s SoC Icenowy Zheng
2017-02-11 15:08 ` [U-Boot] [RFC PATCH 6/6] sunxi: add support for V3s DRAM controller Icenowy Zheng
2017-02-13  7:49 ` [U-Boot] [RFC PATCH 1/6] sunxi: makes an invisible option for H3-like DRAM controllers Maxime Ripard

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=95490560-6c3b-dde2-c7a2-b4c74f448811@gmail.com \
    --to=jenskuske@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 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.