mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Wadim Egorov <w.egorov@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC] serial: ns16550: Set read/write functions depending on reg-io-width
Date: Tue, 28 Feb 2017 08:53:57 +0100	[thread overview]
Message-ID: <20170228075357.j2r5nprcbswhjewb@pengutronix.de> (raw)
In-Reply-To: <49f8f06d-ed61-fb14-fb80-aff250676b0d@phytec.de>

On Mon, Feb 20, 2017 at 02:12:21PM +0100, Wadim Egorov wrote:
> Is this patch okay?

I hope so, it's already applied ;)

Sascha

> 
> 
> Am 09.02.2017 um 10:36 schrieb Wadim Egorov:
> > Set proper register read/write functions depending on reg-io-width
> > device tree property.
> >
> > Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> > ---
> >
> > of_platform_device_create() creates resources in the device_d struct.
> > ns16550_init_iomem() and ns16550_init_ioport() are reading the resources
> > and it's flags (register width).
> > So both functions are not failing, because there is a valid resource.
> > The res->flags might be not set at all. And if it is not set, the driver
> > will use always IORESOURCE_MEM_8BIT.
> >
> > With this patch the probe_dt() func will override the read/write funcs,
> > if there is a valid reg-io-width property.
> > ---
> >  drivers/serial/serial_ns16550.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
> > index c6548e3..752e77b 100644
> > --- a/drivers/serial/serial_ns16550.c
> > +++ b/drivers/serial/serial_ns16550.c
> > @@ -287,12 +287,31 @@ static int ns16550_tstc(struct console_device *cdev)
> >  static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
> >  {
> >  	struct device_node *np = dev->device_node;
> > +	u32 width;
> >  
> >  	if (!IS_ENABLED(CONFIG_OFDEVICE))
> >  		return;
> >  
> >  	of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
> >  	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
> > +	if (!of_property_read_u32(np, "reg-io-width", &width))
> > +		switch (width) {
> > +		case 1:
> > +			priv->read_reg = ns16550_read_reg_mmio_8;
> > +			priv->write_reg = ns16550_write_reg_mmio_8;
> > +			break;
> > +		case 2:
> > +			priv->read_reg = ns16550_read_reg_mmio_16;
> > +			priv->write_reg = ns16550_write_reg_mmio_16;
> > +			break;
> > +		case 4:
> > +			priv->read_reg = ns16550_read_reg_mmio_32;
> > +			priv->write_reg = ns16550_write_reg_mmio_32;
> > +			break;
> > +		default:
> > +			dev_err(dev, "unsupported reg-io-width (%d)\n",
> > +				width);
> > +		}
> >  }
> >  
> >  static struct ns16550_drvdata ns16450_drvdata = {
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

  reply	other threads:[~2017-02-28  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-09  9:36 [PATCH 1/2] ARM: phycore-rk3288: Use UART2 as debug output Wadim Egorov
2017-02-09  9:36 ` [RFC] serial: ns16550: Set read/write functions depending on reg-io-width Wadim Egorov
2017-02-20 13:12   ` Wadim Egorov
2017-02-28  7:53     ` Sascha Hauer [this message]
2017-02-09  9:36 ` [PATCH 2/2] config: Set UART port 2 as debug port Wadim Egorov
2017-02-10  7:19 ` [PATCH 1/2] ARM: phycore-rk3288: Use UART2 as debug output Sascha Hauer

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=20170228075357.j2r5nprcbswhjewb@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=w.egorov@phytec.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