From: Kever Yang <kever.yang-TNX95d0MmH7DzftRWevZcw@public.gmane.org> To: Jagan Teki <jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org>, Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>, Philipp Tomsich <philipp.tomsich-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org>, YouMin Chen <cym-TNX95d0MmH7DzftRWevZcw@public.gmane.org>, u-boot-0aAXYlwwYIKGBzrmiIFOJg@public.gmane.org Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, gajjar04akash-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, linux-amarula-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org, Manivannan Sadhasivam <manivannan.sadhasivam-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Subject: Re: [PATCH v3 14/18] ram: rk3399: Compute stride for 2 channels Date: Tue, 16 Jul 2019 15:44:15 +0800 [thread overview] Message-ID: <9bd3ed0a-9e17-f50a-100a-858b2980a7ea@rock-chips.com> (raw) In-Reply-To: <20190715182856.21688-15-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> On 2019/7/16 上午2:28, Jagan Teki wrote: > stride value from sdram timings can be computed dynamically > based on the determined capacity for the given channel. > > Right now these stride values are taken as part of sdram timings > via dtsi, but it possible to use same timings dtsi for given > frequency even though the configured board sdram do support > single channel with different size by dynamically detect the > stride value. > > Example, NanoPi NEO4 do have DDR3-1866, but with single channel > and 1GB size with dynamic stride detection it is possible to > use existing rk3399-sdram-ddr3-1866.dtsi whose stride, > number of channels and capacity it support is d efferent. > > So, add initial support to calculate the stride value for > 2 channels sdram, which is available by default on existing > boards. > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> > Signed-off-by: YouMin Chen <cym@rock-chips.com> Reviewed-by: Kever Yang <Kever.yang@rock-chips.com> Thanks, - Kever > --- > drivers/ram/rockchip/sdram_rk3399.c | 71 ++++++++++++++++++++++++++++- > 1 file changed, 70 insertions(+), 1 deletion(-) > > diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c > index 084c949728..c626ef602c 100644 > --- a/drivers/ram/rockchip/sdram_rk3399.c > +++ b/drivers/ram/rockchip/sdram_rk3399.c > @@ -1183,8 +1183,75 @@ static int switch_to_phy_index1(struct dram_info *dram, > return 0; > } > > +static unsigned char calculate_stride(struct rk3399_sdram_params *params) > +{ > + unsigned int stride = params->base.stride; > + unsigned int channel, chinfo = 0; > + unsigned int ch_cap[2] = {0, 0}; > + u64 cap; > + > + for (channel = 0; channel < 2; channel++) { > + unsigned int cs0_cap = 0; > + unsigned int cs1_cap = 0; > + struct sdram_cap_info *cap_info = ¶ms->ch[channel].cap_info; > + > + if (cap_info->col == 0) > + continue; > + > + cs0_cap = (1 << (cap_info->cs0_row + cap_info->col + > + cap_info->bk + cap_info->bw - 20)); > + if (cap_info->rank > 1) > + cs1_cap = cs0_cap >> (cap_info->cs0_row > + - cap_info->cs1_row); > + if (cap_info->row_3_4) { > + cs0_cap = cs0_cap * 3 / 4; > + cs1_cap = cs1_cap * 3 / 4; > + } > + ch_cap[channel] = cs0_cap + cs1_cap; > + chinfo |= 1 << channel; > + } > + > + /* stride calculation for 2 channels, default gstride type is 256B */ > + if (ch_cap[0] == ch_cap[1]) { > + cap = ch_cap[0] + ch_cap[1]; > + switch (cap) { > + /* 512MB */ > + case 512: > + stride = 0; > + break; > + /* 1GB */ > + case 1024: > + stride = 0x5; > + break; > + /* > + * 768MB + 768MB same as total 2GB memory > + * useful space: 0-768MB 1GB-1792MB > + */ > + case 1536: > + /* 2GB */ > + case 2048: > + stride = 0x9; > + break; > + /* 1536MB + 1536MB */ > + case 3072: > + stride = 0x11; > + break; > + /* 4GB */ > + case 4096: > + stride = 0xD; > + break; > + default: > + printf("%s: Unable to calculate stride for ", __func__); > + print_size((cap * (1 << 20)), " capacity\n"); > + break; > + } > + } > + > + return stride; > +} > + > static int sdram_init(struct dram_info *dram, > - const struct rk3399_sdram_params *params) > + struct rk3399_sdram_params *params) > { > unsigned char dramtype = params->base.dramtype; > unsigned int ddr_freq = params->base.ddr_freq; > @@ -1232,6 +1299,8 @@ static int sdram_init(struct dram_info *dram, > set_ddrconfig(chan, params, channel, > params->ch[channel].cap_info.ddrconfig); > } > + > + params->base.stride = calculate_stride(params); > dram_all_config(dram, params); > switch_to_phy_index1(dram, params); > _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: Kever Yang <kever.yang@rock-chips.com> To: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 14/18] ram: rk3399: Compute stride for 2 channels Date: Tue, 16 Jul 2019 15:44:15 +0800 [thread overview] Message-ID: <9bd3ed0a-9e17-f50a-100a-858b2980a7ea@rock-chips.com> (raw) In-Reply-To: <20190715182856.21688-15-jagan@amarulasolutions.com> On 2019/7/16 上午2:28, Jagan Teki wrote: > stride value from sdram timings can be computed dynamically > based on the determined capacity for the given channel. > > Right now these stride values are taken as part of sdram timings > via dtsi, but it possible to use same timings dtsi for given > frequency even though the configured board sdram do support > single channel with different size by dynamically detect the > stride value. > > Example, NanoPi NEO4 do have DDR3-1866, but with single channel > and 1GB size with dynamic stride detection it is possible to > use existing rk3399-sdram-ddr3-1866.dtsi whose stride, > number of channels and capacity it support is d efferent. > > So, add initial support to calculate the stride value for > 2 channels sdram, which is available by default on existing > boards. > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> > Signed-off-by: YouMin Chen <cym@rock-chips.com> Reviewed-by: Kever Yang <Kever.yang@rock-chips.com> Thanks, - Kever > --- > drivers/ram/rockchip/sdram_rk3399.c | 71 ++++++++++++++++++++++++++++- > 1 file changed, 70 insertions(+), 1 deletion(-) > > diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c > index 084c949728..c626ef602c 100644 > --- a/drivers/ram/rockchip/sdram_rk3399.c > +++ b/drivers/ram/rockchip/sdram_rk3399.c > @@ -1183,8 +1183,75 @@ static int switch_to_phy_index1(struct dram_info *dram, > return 0; > } > > +static unsigned char calculate_stride(struct rk3399_sdram_params *params) > +{ > + unsigned int stride = params->base.stride; > + unsigned int channel, chinfo = 0; > + unsigned int ch_cap[2] = {0, 0}; > + u64 cap; > + > + for (channel = 0; channel < 2; channel++) { > + unsigned int cs0_cap = 0; > + unsigned int cs1_cap = 0; > + struct sdram_cap_info *cap_info = ¶ms->ch[channel].cap_info; > + > + if (cap_info->col == 0) > + continue; > + > + cs0_cap = (1 << (cap_info->cs0_row + cap_info->col + > + cap_info->bk + cap_info->bw - 20)); > + if (cap_info->rank > 1) > + cs1_cap = cs0_cap >> (cap_info->cs0_row > + - cap_info->cs1_row); > + if (cap_info->row_3_4) { > + cs0_cap = cs0_cap * 3 / 4; > + cs1_cap = cs1_cap * 3 / 4; > + } > + ch_cap[channel] = cs0_cap + cs1_cap; > + chinfo |= 1 << channel; > + } > + > + /* stride calculation for 2 channels, default gstride type is 256B */ > + if (ch_cap[0] == ch_cap[1]) { > + cap = ch_cap[0] + ch_cap[1]; > + switch (cap) { > + /* 512MB */ > + case 512: > + stride = 0; > + break; > + /* 1GB */ > + case 1024: > + stride = 0x5; > + break; > + /* > + * 768MB + 768MB same as total 2GB memory > + * useful space: 0-768MB 1GB-1792MB > + */ > + case 1536: > + /* 2GB */ > + case 2048: > + stride = 0x9; > + break; > + /* 1536MB + 1536MB */ > + case 3072: > + stride = 0x11; > + break; > + /* 4GB */ > + case 4096: > + stride = 0xD; > + break; > + default: > + printf("%s: Unable to calculate stride for ", __func__); > + print_size((cap * (1 << 20)), " capacity\n"); > + break; > + } > + } > + > + return stride; > +} > + > static int sdram_init(struct dram_info *dram, > - const struct rk3399_sdram_params *params) > + struct rk3399_sdram_params *params) > { > unsigned char dramtype = params->base.dramtype; > unsigned int ddr_freq = params->base.ddr_freq; > @@ -1232,6 +1299,8 @@ static int sdram_init(struct dram_info *dram, > set_ddrconfig(chan, params, channel, > params->ch[channel].cap_info.ddrconfig); > } > + > + params->base.stride = calculate_stride(params); > dram_all_config(dram, params); > switch_to_phy_index1(dram, params); >
next prev parent reply other threads:[~2019-07-16 7:44 UTC|newest] Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-15 18:28 [PATCH v3 00/18] ram: rk3399: Add rank detection Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-1-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-15 18:28 ` [PATCH v3 01/18] ram: rk3399: Handle data training return types Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-2-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:36 ` Kever Yang 2019-07-16 7:36 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 02/18] ram: rk3399: Clear PI_175 interrupts in data training Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-3-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:36 ` Kever Yang 2019-07-16 7:36 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 03/18] ram: rk3399: Use rank mask in ca " Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-4-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:38 ` Kever Yang 2019-07-16 7:38 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 04/18] ram: rk3399: Use rank mask in wdql " Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-5-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:38 ` Kever Yang 2019-07-16 7:38 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 05/18] ram: rk3399: Add phy pctrl reset support Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-6-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:39 ` Kever Yang 2019-07-16 7:39 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 06/18] ram: rk3399: Move pwrup_srefresh_exit to dram_info Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-7-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:39 ` Kever Yang 2019-07-16 7:39 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 07/18] ram: rk3399: Add pctl start support Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-8-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:40 ` Kever Yang 2019-07-16 7:40 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 08/18] ram: rockchip: Add initial Kconfig Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-9-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:41 ` Kever Yang 2019-07-16 7:41 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 09/18] debug_uart: Add printdec Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-10-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:41 ` Kever Yang 2019-07-16 7:41 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 10/18] ram: rockchip: Add debug sdram driver Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-11-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:42 ` Kever Yang 2019-07-16 7:42 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 11/18] ram: rockchip: debug: Add sdram_print_ddr_info Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-12-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:42 ` Kever Yang 2019-07-16 7:42 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 12/18] ram: rockchip: debug: Get the cs capacity Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-13-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:43 ` Kever Yang 2019-07-16 7:43 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 13/18] ram: rk3399: debug: Add sdram_print_stride Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-14-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:43 ` Kever Yang 2019-07-16 7:43 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 14/18] ram: rk3399: Compute stride for 2 channels Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-15-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:44 ` Kever Yang [this message] 2019-07-16 7:44 ` Kever Yang 2019-07-15 18:28 ` [PATCH v3 15/18] ram: rk3399: Compute stride for 1 channel a Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-16-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:44 ` Kever Yang 2019-07-16 7:44 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 16/18] ram: rk3399: Add rank detection support Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-17-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:45 ` Kever Yang 2019-07-16 7:45 ` [U-Boot] " Kever Yang 2019-07-17 12:53 ` Kever Yang 2019-07-17 12:53 ` [U-Boot] " Kever Yang 2019-07-18 9:30 ` Jagan Teki 2019-07-18 9:30 ` [U-Boot] " Jagan Teki 2019-07-15 18:28 ` [PATCH v3 17/18] ram: rk3399: Enable sdram debug functions Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-18-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:49 ` Kever Yang 2019-07-16 7:49 ` [U-Boot] " Kever Yang 2019-07-15 18:28 ` [PATCH v3 18/18] rockchip: dts: rk3399: nanopi-neo4: Use DDR3-1866 dtsi Jagan Teki 2019-07-15 18:28 ` [U-Boot] " Jagan Teki [not found] ` <20190715182856.21688-19-jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org> 2019-07-16 7:47 ` Kever Yang 2019-07-16 7:47 ` [U-Boot] " Kever Yang
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=9bd3ed0a-9e17-f50a-100a-858b2980a7ea@rock-chips.com \ --to=kever.yang-tnx95d0mmh7dzftrwevzcw@public.gmane.org \ --cc=cym-TNX95d0MmH7DzftRWevZcw@public.gmane.org \ --cc=gajjar04akash-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \ --cc=jagan-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org \ --cc=linux-amarula-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org \ --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=manivannan.sadhasivam-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \ --cc=philipp.tomsich-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org \ --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \ --cc=u-boot-0aAXYlwwYIKGBzrmiIFOJg@public.gmane.org \ /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: linkBe 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.