mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: Roland Hieber <r.hieber@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 06/14] ARM: i.MX23: Add memory size detection
Date: Fri, 10 Aug 2018 12:14:42 -0700	[thread overview]
Message-ID: <CAHQ1cqH2deM6x3TqDcOdAOqscqGbv5uVAC=KbFgcp7vt6rqrcQ@mail.gmail.com> (raw)
In-Reply-To: <20180810163500.12042-7-r.hieber@pengutronix.de>

On Fri, Aug 10, 2018 at 9:35 AM Roland Hieber <r.hieber@pengutronix.de> wrote:
>
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> No need for the boards to manually add memory, we can do this
> automatically by reading back the memory size from the SDRAM
> controller.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
>  .../arm/boards/chumby_falconwing/falconwing.c |  8 -----
>  arch/arm/boards/freescale-mx23-evk/mx23-evk.c |  8 -----
>  .../boards/imx233-olinuxino/imx23-olinuxino.c |  8 -----
>  arch/arm/mach-mxs/include/mach/imx23.h        | 29 +++++++++++++++++++
>  arch/arm/mach-mxs/soc-imx23.c                 |  4 +++
>  5 files changed, 33 insertions(+), 24 deletions(-)
>  create mode 100644 arch/arm/mach-mxs/include/mach/imx23.h
>
> diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c
> index c866043e8b..5554b78d6d 100644
> --- a/arch/arm/boards/chumby_falconwing/falconwing.c
> +++ b/arch/arm/boards/chumby_falconwing/falconwing.c
> @@ -258,14 +258,6 @@ static const uint32_t pad_setup[] = {
>         GPMI_RDY3_GPIO | GPIO_IN | PULLUP(1),
>  };
>
> -static int falconwing_mem_init(void)
> -{
> -       arm_add_mem_device("ram0", IMX_MEMORY_BASE, 64 * 1024 * 1024);
> -
> -       return 0;
> -}
> -mem_initcall(falconwing_mem_init);
> -
>  #define GPIO_USB_HUB_RESET     29
>  #define GPIO_USB_HUB_POWER     26
>
> diff --git a/arch/arm/boards/freescale-mx23-evk/mx23-evk.c b/arch/arm/boards/freescale-mx23-evk/mx23-evk.c
> index dd8048851b..a3587db063 100644
> --- a/arch/arm/boards/freescale-mx23-evk/mx23-evk.c
> +++ b/arch/arm/boards/freescale-mx23-evk/mx23-evk.c
> @@ -53,14 +53,6 @@ static struct fsl_usb2_platform_data usb_pdata = {
>  };
>  #endif
>
> -static int mx23_evk_mem_init(void)
> -{
> -       arm_add_mem_device("ram0", IMX_MEMORY_BASE, 32 * 1024 * 1024);
> -
> -       return 0;
> -}
> -mem_initcall(mx23_evk_mem_init);
> -
>  /**
>   * Try to register an environment storage on the attached MCI card
>   * @return 0 on success
> diff --git a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
> index b87a6764f3..c06779ddf6 100644
> --- a/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
> +++ b/arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
> @@ -40,14 +40,6 @@ static struct mxs_mci_platform_data mci_pdata = {
>         .f_min = 400000,
>  };
>
> -static int imx23_olinuxino_mem_init(void)
> -{
> -       arm_add_mem_device("ram0", IMX_MEMORY_BASE, 64 * 1024 * 1024);
> -
> -       return 0;
> -}
> -mem_initcall(imx23_olinuxino_mem_init);
> -
>  static void olinuxino_init_usb(void)
>  {
>         imx23_usb_phy_enable();
> diff --git a/arch/arm/mach-mxs/include/mach/imx23.h b/arch/arm/mach-mxs/include/mach/imx23.h
> new file mode 100644
> index 0000000000..56e76d5f50
> --- /dev/null
> +++ b/arch/arm/mach-mxs/include/mach/imx23.h
> @@ -0,0 +1,29 @@
> +#ifndef __MACH_IMX23_H
> +#define __MACH_IMX23_H
> +
> +#include <linux/bitfield.h>
> +#include <io.h>
> +
> +#define DRAM_CTL14_CS0_EN      BIT(0)
> +#define DRAM_CTL14_CS1_EN      BIT(1)
> +#define DRAM_CTL11_COLUMNS_DIFF        GENMASK(10, 8)
> +#define DRAM_CTL10_ROWS_DIFF   GENMASK(18, 16)
> +
> +#define DRAM_CTL(n)    (IMX_SDRAMC_BASE + 4 * (n))
> +
> +static inline u32 imx23_get_memsize(void)
> +{
> +       u32 ctl10 = readl(DRAM_CTL(10));
> +       u32 ctl11 = readl(DRAM_CTL(11));
> +       u32 ctl14 = readl(DRAM_CTL(14));
> +       int rows, columns, banks = 4, cs0, cs1;
> +
> +       columns = 12 - FIELD_GET(DRAM_CTL11_COLUMNS_DIFF, ctl11);
> +       rows = 13 - FIELD_GET(DRAM_CTL10_ROWS_DIFF, ctl10);
> +       cs0 = FIELD_GET(DRAM_CTL14_CS0_EN, ctl14);
> +       cs1 = FIELD_GET(DRAM_CTL14_CS1_EN, ctl14);
> +
> +       return (1 << columns) * (1 << rows) * banks * (cs0 + cs1);

Just as an optional suggestion, you can use memory_sdram_size() from
<memory.h> to calculate that (except multiple chip select part).

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-08-10 19:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-10 16:34 [PATCH v2 00/14] MXS low-level improvements Roland Hieber
2018-08-10 16:34 ` [PATCH v2 01/14] scripts: mxsimage: Allow unencrypted images Roland Hieber
2018-08-10 16:34 ` [PATCH v2 02/14] images: MXS: allow generation of unencrypted bootstreams Roland Hieber
2018-08-10 16:34 ` [PATCH v2 03/14] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM Roland Hieber
2018-08-10 16:34 ` [PATCH v2 04/14] ARM: MXS: allow configuration of EMI clock prescaler Roland Hieber
2018-08-10 16:34 ` [PATCH v2 05/14] ARM: i.MX28: Add memory size detection Roland Hieber
2018-08-10 16:34 ` [PATCH v2 06/14] ARM: i.MX23: " Roland Hieber
2018-08-10 19:14   ` Andrey Smirnov [this message]
2018-08-10 16:34 ` [PATCH v2 07/14] ARM: MXS: refactor mx2*_power_init source configuration Roland Hieber
2018-08-10 19:29   ` Andrey Smirnov
2018-08-13 13:04     ` Roland Hieber
2018-08-10 16:34 ` [PATCH v2 08/14] ARM: MXS: allow starting from battery input without 4P2 source enabled Roland Hieber
2018-08-10 16:34 ` [PATCH v2 09/14] ARM: MXS: make power levels configurable in mx2*_power_init Roland Hieber
2018-08-10 16:34 ` [PATCH v2 10/14] ARM: MXS: fix VDDx brownout setup logic Roland Hieber
2018-08-10 16:34 ` [PATCH v2 11/14] ARM: MXS: make VDDx brownout setup more understandable Roland Hieber
2018-08-10 16:34 ` [PATCH v2 12/14] ARM: MXS: mxs_power_status: use less magic values Roland Hieber
2018-08-10 16:34 ` [PATCH v2 13/14] ARM: MXS: mxs_power_status: align output Roland Hieber
2018-08-10 16:35 ` [PATCH v2 14/14] Documentation: MXS: general update and improvements Roland Hieber

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='CAHQ1cqH2deM6x3TqDcOdAOqscqGbv5uVAC=KbFgcp7vt6rqrcQ@mail.gmail.com' \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=r.hieber@pengutronix.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