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 v3 4/5] ARM: imx: pinctrl: Add support for i.MX28 mxs pinctrl driver
Date: Mon, 17 Jun 2019 09:43:46 +0200	[thread overview]
Message-ID: <20190617094346.2932b82a@jawa> (raw)
In-Reply-To: <fd77c382-7f45-9f68-b1a7-8d812f550c21@denx.de>

Hi Marek,

> On 6/16/19 12:34 AM, Lukasz Majewski wrote:
> > The code responsible for setting proper values in the MUX registers
> > (in the mxs_pinctrl_set_state()) has been ported from Barebox
> > project (branch: master, SHA1:
> > eb3b0f7414cd8102844dd16b1c789e445e8947f8, file:
> > drivers/pinctrl/pinctrl-mxs.c).  
> 
> The format of a commit, when referenced, is documented here:
> https://www.kernel.org/doc/html/v4.12/process/submitting-patches.html
> e.g. e21d2170f366 ("video: remove unnecessary platform_set_drvdata()")
> 
> Although. maybe you should port this from Linux instead ?

The code from linux is a bit more convoluted and verbose. I may re-look
into the kernel version.

> 
> > As the pinctrl node in the imx28.dtsi file has gpio pins nodes as
> > subnodes, it was necessary to use 'dm_scan_fdt_dev()' (as a .bind
> > method) to also make them 'visible' by the DM's "gpio_mxs" driver.  
> 
> Look at drivers/pinctrl/renesas/pfc-r7s72100.c r7s72100_pfc_probe() ,
> I think that one deals with the exact same problem .

It looks like this is the same problem.

However, the dm_scan_fdt_dev() is exactly for that, when combined
with .bind method from DM.

> 
> > Signed-off-by: Lukasz Majewski <lukma@denx.de>
> > 
> > ---
> > 
> > Changes in v3:
> > - Set more apropriate tags
> > 
> > Changes in v2: None
> > 
> >  drivers/pinctrl/nxp/Kconfig       |  10 +++
> >  drivers/pinctrl/nxp/Makefile      |   1 +
> >  drivers/pinctrl/nxp/pinctrl-mxs.c | 164
> > ++++++++++++++++++++++++++++++++++++++ 3 files changed, 175
> > insertions(+) create mode 100644 drivers/pinctrl/nxp/pinctrl-mxs.c
> > 
> > diff --git a/drivers/pinctrl/nxp/Kconfig
> > b/drivers/pinctrl/nxp/Kconfig index 61f93be42d..f2e67ca231 100644
> > --- a/drivers/pinctrl/nxp/Kconfig
> > +++ b/drivers/pinctrl/nxp/Kconfig
> > @@ -89,6 +89,16 @@ config PINCTRL_IMX8M
> >  	  only parses the 'fsl,pins' property and configure related
> >  	  registers.
> >  
> > +config PINCTRL_MXS
> > +	bool "NXP MXS pinctrl driver"
> > +	depends on ARCH_MX28 && PINCTRL_FULL
> > +	help
> > +	  Say Y here to enable the i.MX mxs pinctrl driver
> > +
> > +	  This option provides a simple pinctrl driver for i.MX
> > mxs SoC
> > +	  familiy, e.g. i.MX28. This feature depends on device tree
> > +	  configuration.
> > +
> >  config PINCTRL_VYBRID
> >  	bool "Vybrid (vf610) pinctrl driver"
> >  	depends on ARCH_VF610 && PINCTRL_FULL
> > diff --git a/drivers/pinctrl/nxp/Makefile
> > b/drivers/pinctrl/nxp/Makefile index b340d9448a..b86448aac9 100644
> > --- a/drivers/pinctrl/nxp/Makefile
> > +++ b/drivers/pinctrl/nxp/Makefile
> > @@ -6,4 +6,5 @@ obj-$(CONFIG_PINCTRL_IMX7ULP)		+=
> > pinctrl-imx7ulp.o obj-$(CONFIG_PINCTRL_IMX_SCU)		+=
> > pinctrl-scu.o obj-$(CONFIG_PINCTRL_IMX8)		+=
> > pinctrl-imx8.o obj-$(CONFIG_PINCTRL_IMX8M)		+=
> > pinctrl-imx8m.o +obj-$(CONFIG_PINCTRL_MXS)		+=
> > pinctrl-mxs.o obj-$(CONFIG_PINCTRL_VYBRID)		+=
> > pinctrl-vf610.o diff --git a/drivers/pinctrl/nxp/pinctrl-mxs.c
> > b/drivers/pinctrl/nxp/pinctrl-mxs.c new file mode 100644
> > index 0000000000..42b1b7998b
> > --- /dev/null
> > +++ b/drivers/pinctrl/nxp/pinctrl-mxs.c
> > @@ -0,0 +1,164 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2019 DENX Software Engineering
> > + * Lukasz Majewski, DENX Software Engineering, lukma at denx.de
> > + *
> > + * This work is based on drivers/pinctrl/pinctrl-mxs.c
> > + * SHA1: eb3b0f7414cd8102844dd16b1c789e445e8947f8
> > + * from Barebox project.
> > + *
> > + * Author of original Barebox pinctrl-mxs.c:
> > + * Copyright (c) 2015 Sascha Hauer <s.hauer@pengutronix.de>
> > + */
> > +
> > +#include <common.h>
> > +#include <linux/io.h>
> > +#include <linux/err.h>
> > +#include <dm.h>
> > +#include <dm/pinctrl.h>
> > +#include <dm/read.h>
> > +
> > +DECLARE_GLOBAL_DATA_PTR;
> > +
> > +#define PINID(bank, pin)	((bank) * 32 + (pin))
> > +#define MUXID_TO_PINID(m)	PINID((m) >> 12 & 0xf, (m) >> 4 &
> > 0xff) +#define MUXID_TO_MUXSEL(m)	((m) & 0xf)
> > +#define PINID_TO_BANK(p)	((p) >> 5)
> > +#define PINID_TO_PIN(p)	((p) % 32)
> > +
> > +#define STMP_OFFSET_REG_SET     0x4
> > +#define STMP_OFFSET_REG_CLR     0x8
> > +#define STMP_OFFSET_REG_TOG     0xc
> > +
> > +struct mxs_pinctrl_priv {
> > +	void __iomem *base;
> > +};
> > +
> > +static int mxs_pinctrl_set_state(struct udevice *dev, struct
> > udevice *config) +{
> > +	int ma_present = 0, vol_present = 0, pull_present = 0;
> > +	struct mxs_pinctrl_priv *iomux = dev_get_priv(dev);
> > +	u32 *pin_data, val, ma, vol, pull;
> > +	int npins, size, i, ret;
> > +
> > +	debug("\n%s: set state: %s\n", __func__, config->name);
> > +
> > +	size = dev_read_size(config, "fsl,pinmux-ids");
> > +	if (size < 0)
> > +		return size;
> > +
> > +	if (!size || size % 4) {
> > +		dev_err(dev, "Invalid fsl,pinmux-ids property in
> > %s\n",
> > +			config->name);
> > +		return -EINVAL;
> > +	}
> > +
> > +	npins = size / 4;
> > +
> > +	pin_data = devm_kzalloc(dev, size, 0);  
> 
> Is this ever free'd() ?
> 

Ach... right the devm_kfree() shall be used on the exit from the
function.

> [...]
> 




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/20190617/91817d89/attachment.sig>

  reply	other threads:[~2019-06-17  7:43 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-15 22:34 [U-Boot] [PATCH v3 0/5] DM: Convert i.MX28 gpio, pinmux, spi and eth drivers to DM/DTS Lukasz Majewski
2019-06-15 22:34 ` [U-Boot] [PATCH v3 1/5] ARM: dts: imx: Copy imx28 device tree related files from Linux kernel (v5.1.9) Lukasz Majewski
2019-06-15 22:43   ` Marek Vasut
2019-06-17  6:57     ` Lukasz Majewski
2019-06-17 10:13       ` Marek Vasut
2019-06-15 22:34 ` [U-Boot] [PATCH v3 2/5] ARM: imx: net: Enable support for i.MX28 DM_ETH in the fec_mxc.c driver Lukasz Majewski
2019-06-15 22:43   ` Marek Vasut
2019-06-17  6:57     ` Lukasz Majewski
2019-06-15 22:34 ` [U-Boot] [PATCH v3 3/5] ARM: dm: mxs: gpio: Add support for DM/DTS in the mxs_gpio.c driver (DM_GPIO) Lukasz Majewski
2019-06-15 22:53   ` Marek Vasut
2019-06-17  8:37     ` Lukasz Majewski
2019-06-17 10:20       ` Marek Vasut
2019-06-17 13:01         ` Lukasz Majewski
2019-06-17 13:34           ` Marek Vasut
2019-06-18  6:57             ` Lukasz Majewski
2019-06-18 10:33               ` Marek Vasut
2019-06-18 10:56                 ` Lukasz Majewski
2019-06-18 11:04                   ` Marek Vasut
2019-06-15 22:34 ` [U-Boot] [PATCH v3 4/5] ARM: imx: pinctrl: Add support for i.MX28 mxs pinctrl driver Lukasz Majewski
2019-06-15 23:00   ` Marek Vasut
2019-06-17  7:43     ` Lukasz Majewski [this message]
2019-06-17 10:23       ` Marek Vasut
2019-06-15 22:34 ` [U-Boot] [PATCH v3 5/5] ARM: dm: spi: Add support DM/DTS for i.MX28 mxs SPI driver (DM_SPI conversion) Lukasz Majewski
2019-06-15 23:02   ` Marek Vasut
2019-06-17  6:49     ` Lukasz Majewski
2019-06-17 10:06       ` Marek Vasut
2019-06-17 12:27         ` Lukasz Majewski
2019-06-17 13:23           ` Marek Vasut
2019-06-17 13:41             ` Lukasz Majewski
2019-06-17 13:46               ` Marek Vasut
2019-06-17 14:57                 ` Lukasz Majewski
2019-06-17 15:00                   ` Marek Vasut

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=20190617094346.2932b82a@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