From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 12/14] imx: mmc: Use 'fsl, usdhc-index' property to provide esdhc controller number
Date: Wed, 2 Jan 2019 11:31:56 +0100 [thread overview]
Message-ID: <20190102113156.6381972d@jawa> (raw)
In-Reply-To: <e1d806c9-8716-fc20-d315-ad3783fad8a5@denx.de>
On Wed, 2 Jan 2019 02:18:58 +0100
Marek Vasut <marex@denx.de> wrote:
> On 1/2/19 12:37 AM, Lukasz Majewski wrote:
> > With the current code, it is not possible to assign different than
> > default numbers for mmc controllers.
> >
> > Several in-tree boards depend on the pre-dm setup, corresponding to
> > following aliases:
> >
> > mmc0 = &usdhc2; --> fsl,usdhc-index = <1>
> > mmc1 = &usdhc4; --> fsl,usdhc-index = <3>
> >
> > Without this patch we are either forced to use default aliasing -
> > like:
> >
> > mmc0 = &usdhc1;
> > mmc1 = &usdhc2;
> > mmc2 = &usdhc3;
> > mmc3 = &usdhc4;
> >
> > to have the proper clocks setup for the controller. However, such
> > setup is not acceptable for some legacy scripts / code.
> >
> > With this patch - by introducing 'fsl,usdhc-index' - one can
> > configure (get) clock rate corresponding to used controller.
> >
> > Moreover, as this code is used in the SPL before relocation (and to
> > save space we strip the SPL DTS from clocks and its names) adding
> > separate properties seems to be the best approach here. One also
> > avoids adding clocks DM code to SPL.
> >
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > ---
> >
> > drivers/mmc/fsl_esdhc.c | 17 ++++++++++++++++-
> > 1 file changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
> > index 3cdfa7f5a6..49a6834a98 100644
> > --- a/drivers/mmc/fsl_esdhc.c
> > +++ b/drivers/mmc/fsl_esdhc.c
> > @@ -1401,6 +1401,7 @@ static int fsl_esdhc_probe(struct udevice
> > *dev) fdt_addr_t addr;
> > unsigned int val;
> > struct mmc *mmc;
> > + int usdhc_idx;
> > int ret;
> >
> > addr = dev_read_addr(dev);
> > @@ -1513,7 +1514,21 @@ static int fsl_esdhc_probe(struct udevice
> > *dev)
> > priv->sdhc_clk = clk_get_rate(&priv->per_clk);
> > } else {
> > - priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK +
> > dev->seq);
> > + /*
> > + * Check for 'fsl,index' DTS property - as one may
> > want to have
> > + * following mmc setup:
>
> NAK, DT is a hardware description. This is encoding a policy, which
> should not be in DT.
Please look a few lines up in this file:
mmc0 = &usdhc1;
mmc1 = &usdhc2;
mmc2 = &usdhc3;
mmc3 = &usdhc4;
The fsl_esdhc.c has hardcoded ordering for eMMC devices when
setting/getting clock.
If you change aliases on your dts (mmc0 -> usdhc2, etc). Then with a
bit of luck your second controller will be initialized with first's one
clock value :-). This of course works by chance with default ROM setup.
The problem is that many boards have different mmc ordering (starting
with mmc0, which in above scheme is usdhc2 controller. Also mmc1 is the
usdhc4 to which eMMC is connected in many boards). Of course this could
be changed, but please consider a lot of legacy code pilling up on the
customer's side.
The clock index @ (drivers/mmc/fsl_esdhc.c - L1517):
mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
Here the dev->seq is 0,1 (with SEQ_ALIAS), which will provide clock
values from usdhc1 and usdhc2. However, we use usdhc4 (eMMC) and usdhc2
(SD).
>
> This looks like some reimplementation of SEQ_ALIAS stuff.
No, this is a fix for hardcoded (assumed) clock setup in this driver.
The other option is to provide/port clock stuff from linux (and
implement CLK_DM in u-boot at least for this part). However, this will
not fix the problem described above (for other boards which use the
"legacy" approach).
>
> > + * mmc0 = &usdhc2; --> fsl,index = <1>
> > + * mmc1 = &usdhc4; --> fsl,index = <3>
> > + *
> > + * So we do have dev->seq = {0, 1}, which in the
> > below code
> > + * doesn't correspond to correct USDHC clocks.
> > + *
> > + * For that reason a new "fsl,index" property has
> > been
> > + * introduced.
> > + */
> > + usdhc_idx = dev_read_u32_default(dev,
> > "fsl,usdhc-index",
> > + dev->seq);
> > + priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK +
> > usdhc_idx); if (priv->sdhc_clk <= 0) {
> > dev_err(dev, "Unable to get clk for %s\n",
> > dev->name); return -EINVAL;
> >
>
>
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/c53a6fc5/attachment.sig>
next prev parent reply other threads:[~2019-01-02 10:31 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
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 [this message]
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=20190102113156.6381972d@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