public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 07/14] pinctrl: imx: Replace static soc info definitions with run time allocations
Date: Wed, 2 Jan 2019 09:26:11 +0100	[thread overview]
Message-ID: <20190102092611.2fb79b77@jawa> (raw)
In-Reply-To: <85c14f34-db7a-3356-f28c-557e80ddc661@denx.de>

Hi Marek,

> On 1/2/19 12:37 AM, Lukasz Majewski wrote:
> > This commit is necessary to be able to re-use the pinctrl code in
> > early SPL to properly configure pins.
> > 
> > The problem is that those "static" structures are placed in the
> > SDRAM area, which corresponds to u-boot proper (not even SPL).
> > Hence, when one wants to configure pins before relocation via
> > DTS/DM, the board hangs (imx6q SoC powered one) as only OCRAM area
> > is available (0x009xxxxx).
> > 
> > It is also safe to use calloc in this case, as the early SPL code
> > provides it - either full or trimmed version. The allocated memory
> > is also correct in respect to the memory area in which the SoC is
> > currently running (OCRAM vs. SDRAM).  
> 
> You should be able to access static data in early environment, many
> other drivers have no problem with it. 

Have you used pinctrl IMX6Q driver with early DM at SPL?

> I believe there is some more
> fundamental problem that needs to be fixed, 

With the current code - which was not used in OCRAM only available
memory - the statics are placed in the SDRAM area (0x178x xxxx).

Instead of changing linker script (and validate it for all drivers and
boards for SPL and u-boot proper) - the code has been rewritten to use
malloc (which is available in the early code - either full blown or
simple version).

> hacking around it like
> this is just hiding the real issue.

The real issue is that IMX6Q uses SDRAM memory for statics/globals from
the very beginning.

> 
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > ---
> > 
> >  drivers/pinctrl/nxp/pinctrl-imx6.c | 39
> > +++++++++++++++++++------------------- 1 file changed, 19
> > insertions(+), 20 deletions(-)
> > 
> > diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c
> > b/drivers/pinctrl/nxp/pinctrl-imx6.c index d7c95bb738..876049b39b
> > 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx6.c
> > +++ b/drivers/pinctrl/nxp/pinctrl-imx6.c
> > @@ -10,34 +10,33 @@
> >  
> >  #include "pinctrl-imx.h"
> >  
> > -static struct imx_pinctrl_soc_info imx6_pinctrl_soc_info;
> > -
> > -/* FIXME Before reloaction, BSS is overlapped with DT area */
> > -static struct imx_pinctrl_soc_info imx6ul_pinctrl_soc_info = {
> > -	.flags = ZERO_OFFSET_VALID,
> > -};
> > -
> > -static struct imx_pinctrl_soc_info imx6_snvs_pinctrl_soc_info = {
> > -	.flags = ZERO_OFFSET_VALID,
> > -};
> > -
> >  static int imx6_pinctrl_probe(struct udevice *dev)
> >  {
> >  	struct imx_pinctrl_soc_info *info =
> > -		(struct imx_pinctrl_soc_info
> > *)dev_get_driver_data(dev);
> > +		calloc(1, sizeof(struct imx_pinctrl_soc_info));
> > +
> > +	if (!info) {
> > +		printf("%s: Not enough memory!\n", __func__);
> > +		return -ENOMEM;
> > +	}
> > +
> > +	if (device_is_compatible(dev, "fsl,imx6sll-iomuxc-snvs") ||
> > +	    device_is_compatible(dev, "fsl,imx6ull-iomuxc-snvs") ||
> > +	    device_is_compatible(dev, "fsl,imx6ul-iomuxc"))
> > +		info->flags = ZERO_OFFSET_VALID;
> >  
> >  	return imx_pinctrl_probe(dev, info);
> >  }
> >  
> >  static const struct udevice_id imx6_pinctrl_match[] = {
> > -	{ .compatible = "fsl,imx6q-iomuxc", .data =
> > (ulong)&imx6_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6dl-iomuxc", .data =
> > (ulong)&imx6_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6sl-iomuxc", .data =
> > (ulong)&imx6_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6sll-iomuxc-snvs", .data =
> > (ulong)&imx6_snvs_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6sll-iomuxc", .data =
> > (ulong)&imx6_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6sx-iomuxc", .data =
> > (ulong)&imx6_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6ul-iomuxc", .data =
> > (ulong)&imx6ul_pinctrl_soc_info },
> > -	{ .compatible = "fsl,imx6ull-iomuxc-snvs", .data =
> > (ulong)&imx6_snvs_pinctrl_soc_info },
> > +	{ .compatible = "fsl,imx6q-iomuxc" },
> > +	{ .compatible = "fsl,imx6dl-iomuxc" },
> > +	{ .compatible = "fsl,imx6sl-iomuxc" },
> > +	{ .compatible = "fsl,imx6sll-iomuxc-snvs" },
> > +	{ .compatible = "fsl,imx6sll-iomuxc" },
> > +	{ .compatible = "fsl,imx6sx-iomuxc" },
> > +	{ .compatible = "fsl,imx6ul-iomuxc" },
> > +	{ .compatible = "fsl,imx6ull-iomuxc-snvs" },
> >  	{ /* sentinel */ }
> >  };
> >  
> >   
> 
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190102/977e3539/attachment.sig>

  reply	other threads:[~2019-01-02  8:26 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01 23:37 [U-Boot] [PATCH v1 00/14] dm: Convert TPC70 to use DM and DTS in SPL and u-boot proper Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 01/14] tpc70: config: Add script commands to update u-boot and OE's wic Lukasz Majewski
2019-01-02  1:07   ` Marek Vasut
2019-01-02  9:50     ` Lukasz Majewski
2019-01-02 14:09       ` Marek Vasut
2019-01-01 23:37 ` [U-Boot] [PATCH v1 02/14] tpc70: config: Update TPC70 config to support eMMC's boot0 SPL update Lukasz Majewski
2019-01-02  1:08   ` Marek Vasut
2019-01-02  9:47     ` Lukasz Majewski
2019-01-02 14:09       ` Marek Vasut
2019-01-01 23:37 ` [U-Boot] [PATCH v1 03/14] tpc70: Provide board_boot_order() function to distinct between eMMC and SD boot Lukasz Majewski
2019-01-05  1:57   ` Simon Glass
2019-01-01 23:37 ` [U-Boot] [PATCH v1 04/14] DTS: imx: Remove not needed '#address-cells' and '#size-cells' properties Lukasz Majewski
2019-01-02  1:09   ` Marek Vasut
2019-01-02  9:43     ` Lukasz Majewski
2019-01-02 14:10       ` Marek Vasut
2019-01-02 14:34         ` Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 05/14] board: cosmetic: Use define to set ENET clock selection mask on TPC70 Lukasz Majewski
2019-01-02  1:09   ` Marek Vasut
2019-01-02 10:06     ` Lukasz Majewski
2019-01-02 14:12       ` Marek Vasut
2019-01-02 14:37         ` Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 06/14] DM: tpc70: led: Enable LED default state Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 07/14] pinctrl: imx: Replace static soc info definitions with run time allocations Lukasz Majewski
2019-01-02  1:13   ` Marek Vasut
2019-01-02  8:26     ` Lukasz Majewski [this message]
2019-01-02 14:14       ` Marek Vasut
2019-01-03  7:22         ` Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 08/14] DTS: imx: Add "u-boot, dm-pre-reloc" property to relevant imx6qdl nodes Lukasz Majewski
2019-01-02  1:13   ` Marek Vasut
2019-01-02  9:23     ` Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 09/14] imx: serial: dm: Enable DM_FLAG_PRE_RELOC in the IMX uart driver Lukasz Majewski
2019-01-02  1:14   ` Marek Vasut
2019-01-02  8:42     ` Lukasz Majewski
2019-01-02 14:15       ` Marek Vasut
2019-01-01 23:37 ` [U-Boot] [PATCH v1 10/14] imx: clock: Introduce set_fec_clock() to configure ETH clock (imx6) Lukasz Majewski
2019-01-02  1:16   ` Marek Vasut
2019-01-02  9:00     ` Lukasz Majewski
2019-01-02 14:18       ` Marek Vasut
2019-01-01 23:37 ` [U-Boot] [PATCH v1 11/14] DM: net: imx: Provide weak function to initialize fec clocks Lukasz Majewski
2019-01-02  1:17   ` Marek Vasut
2019-01-02  8:47     ` Lukasz Majewski
2019-01-01 23:37 ` [U-Boot] [PATCH v1 12/14] imx: mmc: Use 'fsl, usdhc-index' property to provide esdhc controller number Lukasz Majewski
2019-01-02  1:18   ` Marek Vasut
2019-01-02 10:31     ` Lukasz Majewski
2019-01-02 14:17       ` Marek Vasut
2019-01-01 23:37 ` [U-Boot] [PATCH v1 13/14] DTS: imx: tpc70: Add TPC70 board (imx6q based) device tree description Lukasz Majewski
2019-01-02  1:19   ` Marek Vasut
2019-01-02  8:49     ` Lukasz Majewski
2019-01-02 14:17       ` Marek Vasut
2019-01-01 23:37 ` [U-Boot] [PATCH v1 14/14] imx: tpc70: Convert TPC70 (imx6q based) board to use DM/DTS in SPL and u-boot Lukasz Majewski
2019-01-05  1:57   ` 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=20190102092611.2fb79b77@jawa \
    --to=lukma@denx.de \
    --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