All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Hurley <peter-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
To: NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/3] TTY: add support for "tty slave" devices.
Date: Thu, 11 Dec 2014 18:18:37 -0500	[thread overview]
Message-ID: <548A264D.8070103@hurleysoftware.com> (raw)
In-Reply-To: <20141211215943.4127.24792.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>

On 12/11/2014 04:59 PM, NeilBrown wrote:
> A "tty slave" is a device connected via UART.
> It may need a driver to, for example, power the device on
> when the tty is opened, and power it off when the tty
> is released.
> 
> A "tty slave" is a platform device which is declared as a
> child of the uart in device-tree:
> 
> &uart1 {
> 	bluetooth {
> 		compatible = "tty,regulator";
> 		vdd-supply = <&vaux4>;
> 	};
> };
> 
> runtime power management is used to power-up the device
> on tty_open() and  power-down on tty_release().

I have a couple of issues with this:
1) why does a child device imply power management and a platform
   device? iow, what happens when someone else wants to have a
   child device that does something different?
2) why is this tied to the tty core and not the serial core
   if this is only for UART?

Regards,
Peter Hurley

> Signed-off-by: NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>
> ---
>  .../devicetree/bindings/serial/of-serial.txt       |    4 ++++
>  drivers/tty/tty_io.c                               |   22 ++++++++++++++++++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/serial/of-serial.txt b/Documentation/devicetree/bindings/serial/of-serial.txt
> index 8c4fd0332028..b59501ee2f21 100644
> --- a/Documentation/devicetree/bindings/serial/of-serial.txt
> +++ b/Documentation/devicetree/bindings/serial/of-serial.txt
> @@ -39,6 +39,10 @@ Optional properties:
>    driver is allowed to detect support for the capability even without this
>    property.
>  
> +Optional child node:
> +- a platform device listed as a child node will be probed and
> +  powered-on whenever the tty is in use (open).
> +
>  Example:
>  
>  	uart@80230000 {
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 0508a1d8e4cd..7acdc6f093f4 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -95,6 +95,8 @@
>  #include <linux/seq_file.h>
>  #include <linux/serial.h>
>  #include <linux/ratelimit.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/of_platform.h>
>  
>  #include <linux/uaccess.h>
>  
> @@ -1683,6 +1685,17 @@ static int tty_release_checks(struct tty_struct *tty, struct tty_struct *o_tty,
>  	return 0;
>  }
>  
> +static int open_child(struct device *dev, void *data)
> +{
> +	pm_runtime_get_sync(dev);
> +	return 0;
> +}
> +static int release_child(struct device *dev, void *data)
> +{
> +	pm_runtime_put_autosuspend(dev);
> +	return 0;
> +}
> +
>  /**
>   *	tty_release		-	vfs callback for close
>   *	@inode: inode of tty
> @@ -1712,6 +1725,8 @@ int tty_release(struct inode *inode, struct file *filp)
>  	long	timeout = 0;
>  	int	once = 1;
>  
> +	if (tty->dev)
> +		device_for_each_child(tty->dev, NULL, release_child);
>  	if (tty_paranoia_check(tty, inode, __func__))
>  		return 0;
>  
> @@ -2118,6 +2133,8 @@ retry_open:
>  		__proc_set_tty(current, tty);
>  	spin_unlock_irq(&current->sighand->siglock);
>  	tty_unlock(tty);
> +	if (tty->dev)
> +		device_for_each_child(tty->dev, NULL, open_child);
>  	mutex_unlock(&tty_mutex);
>  	return 0;
>  err_unlock:
> @@ -3207,6 +3224,11 @@ struct device *tty_register_device_attr(struct tty_driver *driver,
>  	retval = device_register(dev);
>  	if (retval)
>  		goto error;
> +	if (device && device->of_node)
> +		/* Children are platform devices and will be
> +		 * runtime_pm managed by this tty.
> +		 */
> +		of_platform_populate(device->of_node, NULL, NULL, dev);
>  
>  	return dev;


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Peter Hurley <peter@hurleysoftware.com>
To: NeilBrown <neilb@suse.de>, Grant Likely <grant.likely@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mark Rutland <mark.rutland@arm.com>, Jiri Slaby <jslaby@suse.cz>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] TTY: add support for "tty slave" devices.
Date: Thu, 11 Dec 2014 18:18:37 -0500	[thread overview]
Message-ID: <548A264D.8070103@hurleysoftware.com> (raw)
In-Reply-To: <20141211215943.4127.24792.stgit@notabene.brown>

On 12/11/2014 04:59 PM, NeilBrown wrote:
> A "tty slave" is a device connected via UART.
> It may need a driver to, for example, power the device on
> when the tty is opened, and power it off when the tty
> is released.
> 
> A "tty slave" is a platform device which is declared as a
> child of the uart in device-tree:
> 
> &uart1 {
> 	bluetooth {
> 		compatible = "tty,regulator";
> 		vdd-supply = <&vaux4>;
> 	};
> };
> 
> runtime power management is used to power-up the device
> on tty_open() and  power-down on tty_release().

I have a couple of issues with this:
1) why does a child device imply power management and a platform
   device? iow, what happens when someone else wants to have a
   child device that does something different?
2) why is this tied to the tty core and not the serial core
   if this is only for UART?

Regards,
Peter Hurley

> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  .../devicetree/bindings/serial/of-serial.txt       |    4 ++++
>  drivers/tty/tty_io.c                               |   22 ++++++++++++++++++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/serial/of-serial.txt b/Documentation/devicetree/bindings/serial/of-serial.txt
> index 8c4fd0332028..b59501ee2f21 100644
> --- a/Documentation/devicetree/bindings/serial/of-serial.txt
> +++ b/Documentation/devicetree/bindings/serial/of-serial.txt
> @@ -39,6 +39,10 @@ Optional properties:
>    driver is allowed to detect support for the capability even without this
>    property.
>  
> +Optional child node:
> +- a platform device listed as a child node will be probed and
> +  powered-on whenever the tty is in use (open).
> +
>  Example:
>  
>  	uart@80230000 {
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 0508a1d8e4cd..7acdc6f093f4 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -95,6 +95,8 @@
>  #include <linux/seq_file.h>
>  #include <linux/serial.h>
>  #include <linux/ratelimit.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/of_platform.h>
>  
>  #include <linux/uaccess.h>
>  
> @@ -1683,6 +1685,17 @@ static int tty_release_checks(struct tty_struct *tty, struct tty_struct *o_tty,
>  	return 0;
>  }
>  
> +static int open_child(struct device *dev, void *data)
> +{
> +	pm_runtime_get_sync(dev);
> +	return 0;
> +}
> +static int release_child(struct device *dev, void *data)
> +{
> +	pm_runtime_put_autosuspend(dev);
> +	return 0;
> +}
> +
>  /**
>   *	tty_release		-	vfs callback for close
>   *	@inode: inode of tty
> @@ -1712,6 +1725,8 @@ int tty_release(struct inode *inode, struct file *filp)
>  	long	timeout = 0;
>  	int	once = 1;
>  
> +	if (tty->dev)
> +		device_for_each_child(tty->dev, NULL, release_child);
>  	if (tty_paranoia_check(tty, inode, __func__))
>  		return 0;
>  
> @@ -2118,6 +2133,8 @@ retry_open:
>  		__proc_set_tty(current, tty);
>  	spin_unlock_irq(&current->sighand->siglock);
>  	tty_unlock(tty);
> +	if (tty->dev)
> +		device_for_each_child(tty->dev, NULL, open_child);
>  	mutex_unlock(&tty_mutex);
>  	return 0;
>  err_unlock:
> @@ -3207,6 +3224,11 @@ struct device *tty_register_device_attr(struct tty_driver *driver,
>  	retval = device_register(dev);
>  	if (retval)
>  		goto error;
> +	if (device && device->of_node)
> +		/* Children are platform devices and will be
> +		 * runtime_pm managed by this tty.
> +		 */
> +		of_platform_populate(device->of_node, NULL, NULL, dev);
>  
>  	return dev;



  parent reply	other threads:[~2014-12-11 23:18 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11 21:59 [PATCH 0/3] Add support for 'tty-slaves' described by devicetree NeilBrown
2014-12-11 21:59 ` [PATCH 2/3] TTY: add slave driver to power-on device via a regulator NeilBrown
     [not found]   ` <20141211215944.4127.4186.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-12-11 22:58     ` Sebastian Reichel
2014-12-11 22:58       ` Sebastian Reichel
2014-12-12  0:46       ` Marcel Holtmann
2014-12-12  1:31         ` Sebastian Reichel
2014-12-12  5:01       ` NeilBrown
2014-12-11 23:32     ` Peter Hurley
2014-12-11 23:32       ` Peter Hurley
2014-12-12  5:27       ` NeilBrown
     [not found]         ` <20141212162714.3a2378df-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-12-12 11:59           ` Peter Hurley
2014-12-12 11:59             ` Peter Hurley
2014-12-12 12:05   ` Grant Likely
2014-12-11 21:59 ` [PATCH 3/3] TTY/slave: add driver for w2sg0004 GPS NeilBrown
     [not found]   ` <20141211215944.4127.57146.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-12-11 23:04     ` Sebastian Reichel
2014-12-11 23:04       ` Sebastian Reichel
2014-12-11 23:11     ` One Thousand Gnomes
2014-12-11 23:11       ` One Thousand Gnomes
     [not found]       ` <20141211231100.05782a30-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2014-12-12  5:06         ` NeilBrown
2014-12-12  5:06           ` NeilBrown
     [not found]           ` <20141212160607.361d20db-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-12-15 11:39             ` One Thousand Gnomes
2014-12-15 11:39               ` One Thousand Gnomes
2014-12-12 12:11   ` Grant Likely
2014-12-11 21:59 ` [PATCH 1/3] TTY: add support for "tty slave" devices NeilBrown
     [not found]   ` <20141211215943.4127.24792.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-12-11 22:41     ` Sebastian Reichel
2014-12-11 22:41       ` Sebastian Reichel
2014-12-11 23:18     ` Peter Hurley [this message]
2014-12-11 23:18       ` Peter Hurley
     [not found]       ` <548A264D.8070103-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2014-12-12  5:23         ` NeilBrown
2014-12-12  5:23           ` NeilBrown
     [not found]           ` <20141212162352.66be5b5e-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-12-12 13:02             ` Peter Hurley
2014-12-12 13:02               ` Peter Hurley
2014-12-13 14:23               ` One Thousand Gnomes
     [not found]                 ` <20141213142344.61372b92-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2014-12-16 16:14                   ` Peter Hurley
2014-12-16 16:14                     ` Peter Hurley
2014-12-13 14:12         ` One Thousand Gnomes
2014-12-13 14:12           ` One Thousand Gnomes
2014-12-12 11:59   ` Grant Likely
2014-12-13 17:46     ` Sebastian Reichel
2014-12-13 22:22       ` Grant Likely
2014-12-28 14:20   ` Pavel Machek
2015-01-02 21:33     ` NeilBrown
2015-01-04 10:18       ` Pavel Machek
2015-01-05  7:09         ` NeilBrown
2015-01-05  7:09           ` NeilBrown
     [not found]           ` <20150105200936.2ba8f596-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-01-05 13:43             ` Pavel Machek
2015-01-05 13:43               ` Pavel Machek
2015-01-05 15:41       ` One Thousand Gnomes
2015-01-05 16:28         ` Pavel Machek

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=548A264D.8070103@hurleysoftware.com \
    --to=peter-wagbzjegnqdsbiue7sb01tbpr1lh4cv8@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=jslaby-AlSwsSmVLrQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=neilb-l3A5Bk7waGM@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.