All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Jiri Slaby <jslaby@suse.com>
Subject: Re: [PATCH 1/6] serial: sa1100: add support for mctrl gpios
Date: Fri, 31 May 2019 14:50:13 +0200	[thread overview]
Message-ID: <20190531125013.3gkexhmbqjpdvrtf@pengutronix.de> (raw)
In-Reply-To: <E1hWfTn-0003fP-Rl@rmk-PC.armlinux.org.uk>

On Fri, May 31, 2019 at 12:13:47PM +0100, Russell King wrote:
> Add support for the generic mctrl gpio helper.  This will allow us to
> convert several board files to use the gpiod tables to assign GPIOs to
> serial ports, rather than needing to have private function callbacks.
> 
> If the generic mctrl gpio helper fails, ignore the mctrl gpios rather
> than preventing the (possibly console) serial port from being created.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/tty/serial/Kconfig  |  1 +
>  drivers/tty/serial/sa1100.c | 42 ++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 72966bc0ac76..f4372ac1a774 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -511,6 +511,7 @@ config SERIAL_SA1100
>  	bool "SA1100 serial port support"
>  	depends on ARCH_SA1100
>  	select SERIAL_CORE
> +	select SERIAL_MCTRL_GPIO if GPIOLIB
>  	help
>  	  If you have a machine based on a SA1100/SA1110 StrongARM(R) CPU you
>  	  can enable its onboard serial port by enabling this option.
> diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
> index a399772be3fc..97bdfeccbea9 100644
> --- a/drivers/tty/serial/sa1100.c
> +++ b/drivers/tty/serial/sa1100.c
> @@ -28,6 +28,8 @@
>  #include <mach/hardware.h>
>  #include <mach/irqs.h>
>  
> +#include "serial_mctrl_gpio.h"
> +
>  /* We've been assigned a range on the "Low-density serial ports" major */
>  #define SERIAL_SA1100_MAJOR	204
>  #define MINOR_START		5
> @@ -77,6 +79,7 @@ struct sa1100_port {
>  	struct uart_port	port;
>  	struct timer_list	timer;
>  	unsigned int		old_status;
> +	struct mctrl_gpios	*gpios;
>  };
>  
>  /*
> @@ -174,6 +177,8 @@ static void sa1100_enable_ms(struct uart_port *port)
>  		container_of(port, struct sa1100_port, port);
>  
>  	mod_timer(&sport->timer, jiffies);
> +
> +	mctrl_gpio_enable_ms(sport->gpios);
>  }
>  
>  static void
> @@ -322,11 +327,21 @@ static unsigned int sa1100_tx_empty(struct uart_port *port)
>  
>  static unsigned int sa1100_get_mctrl(struct uart_port *port)
>  {
> -	return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> +	struct sa1100_port *sport =
> +		container_of(port, struct sa1100_port, port);
> +	int ret = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> +
> +	mctrl_gpio_get(sport->gpios, &ret);
> +
> +	return ret;
>  }
>  
>  static void sa1100_set_mctrl(struct uart_port *port, unsigned int mctrl)
>  {
> +	struct sa1100_port *sport =
> +		container_of(port, struct sa1100_port, port);
> +
> +	mctrl_gpio_set(sport->gpios, mctrl);
>  }
>  
>  /*
> @@ -842,6 +857,27 @@ static int sa1100_serial_resume(struct platform_device *dev)
>  	return 0;
>  }
>  
> +static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev)
> +{
> +	sport->port.dev = &dev->dev;
> +	sport->gpios = mctrl_gpio_init_noauto(sport->port.dev, 0);

the _noauto function was only introduced to ease a transition. I think
the driver would benefit to use mctrl_gpio_init() instead.

Getting rid of mctrl_gpio_init_noauto() was on my todo list for some
time, but it was pushed down too far :-|

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

WARNING: multiple messages have this Message-ID (diff)
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Jiri Slaby <jslaby@suse.com>
Subject: Re: [PATCH 1/6] serial: sa1100: add support for mctrl gpios
Date: Fri, 31 May 2019 14:50:13 +0200	[thread overview]
Message-ID: <20190531125013.3gkexhmbqjpdvrtf@pengutronix.de> (raw)
In-Reply-To: <E1hWfTn-0003fP-Rl@rmk-PC.armlinux.org.uk>

On Fri, May 31, 2019 at 12:13:47PM +0100, Russell King wrote:
> Add support for the generic mctrl gpio helper.  This will allow us to
> convert several board files to use the gpiod tables to assign GPIOs to
> serial ports, rather than needing to have private function callbacks.
> 
> If the generic mctrl gpio helper fails, ignore the mctrl gpios rather
> than preventing the (possibly console) serial port from being created.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/tty/serial/Kconfig  |  1 +
>  drivers/tty/serial/sa1100.c | 42 ++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 72966bc0ac76..f4372ac1a774 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -511,6 +511,7 @@ config SERIAL_SA1100
>  	bool "SA1100 serial port support"
>  	depends on ARCH_SA1100
>  	select SERIAL_CORE
> +	select SERIAL_MCTRL_GPIO if GPIOLIB
>  	help
>  	  If you have a machine based on a SA1100/SA1110 StrongARM(R) CPU you
>  	  can enable its onboard serial port by enabling this option.
> diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
> index a399772be3fc..97bdfeccbea9 100644
> --- a/drivers/tty/serial/sa1100.c
> +++ b/drivers/tty/serial/sa1100.c
> @@ -28,6 +28,8 @@
>  #include <mach/hardware.h>
>  #include <mach/irqs.h>
>  
> +#include "serial_mctrl_gpio.h"
> +
>  /* We've been assigned a range on the "Low-density serial ports" major */
>  #define SERIAL_SA1100_MAJOR	204
>  #define MINOR_START		5
> @@ -77,6 +79,7 @@ struct sa1100_port {
>  	struct uart_port	port;
>  	struct timer_list	timer;
>  	unsigned int		old_status;
> +	struct mctrl_gpios	*gpios;
>  };
>  
>  /*
> @@ -174,6 +177,8 @@ static void sa1100_enable_ms(struct uart_port *port)
>  		container_of(port, struct sa1100_port, port);
>  
>  	mod_timer(&sport->timer, jiffies);
> +
> +	mctrl_gpio_enable_ms(sport->gpios);
>  }
>  
>  static void
> @@ -322,11 +327,21 @@ static unsigned int sa1100_tx_empty(struct uart_port *port)
>  
>  static unsigned int sa1100_get_mctrl(struct uart_port *port)
>  {
> -	return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> +	struct sa1100_port *sport =
> +		container_of(port, struct sa1100_port, port);
> +	int ret = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> +
> +	mctrl_gpio_get(sport->gpios, &ret);
> +
> +	return ret;
>  }
>  
>  static void sa1100_set_mctrl(struct uart_port *port, unsigned int mctrl)
>  {
> +	struct sa1100_port *sport =
> +		container_of(port, struct sa1100_port, port);
> +
> +	mctrl_gpio_set(sport->gpios, mctrl);
>  }
>  
>  /*
> @@ -842,6 +857,27 @@ static int sa1100_serial_resume(struct platform_device *dev)
>  	return 0;
>  }
>  
> +static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev)
> +{
> +	sport->port.dev = &dev->dev;
> +	sport->gpios = mctrl_gpio_init_noauto(sport->port.dev, 0);

the _noauto function was only introduced to ease a transition. I think
the driver would benefit to use mctrl_gpio_init() instead.

Getting rid of mctrl_gpio_init_noauto() was on my todo list for some
time, but it was pushed down too far :-|

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-05-31 12:50 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 11:12 [PATCH 0/6] Convert sa1100 serial to use mctrl gpios Russell King - ARM Linux admin
2019-05-31 11:12 ` Russell King - ARM Linux admin
2019-05-31 11:13 ` [PATCH 1/6] serial: sa1100: add support for " Russell King
2019-05-31 11:13   ` Russell King
2019-05-31 12:50   ` Uwe Kleine-König [this message]
2019-05-31 12:50     ` Uwe Kleine-König
2019-05-31 13:23     ` Russell King - ARM Linux admin
2019-05-31 13:23       ` Russell King - ARM Linux admin
2019-05-31 13:56       ` Uwe Kleine-König
2019-05-31 13:56         ` Uwe Kleine-König
2019-05-31 14:01         ` Russell King - ARM Linux admin
2019-05-31 14:01           ` Russell King - ARM Linux admin
2019-05-31 15:10           ` Uwe Kleine-König
2019-05-31 15:10             ` Uwe Kleine-König
2019-05-31 15:24             ` [PATCH] serial: sa1100: add note about modem control signals Russell King
2019-05-31 15:24               ` Russell King
2019-05-31 15:31               ` Uwe Kleine-König
2019-05-31 15:31                 ` Uwe Kleine-König
2019-05-31 15:57                 ` Russell King - ARM Linux admin
2019-05-31 15:57                   ` Russell King - ARM Linux admin
2019-05-31 16:01                   ` [PATCH v2] " Russell King
2019-05-31 21:27                     ` Uwe Kleine-König
2019-05-31 21:27                       ` Uwe Kleine-König
2019-06-04 11:16                       ` Russell King - ARM Linux admin
2019-06-04 11:16                         ` Russell King - ARM Linux admin
2019-05-31 11:13 ` [PATCH 2/6] ARM: sa1100/assabet: convert serial to gpiod APIs Russell King
2019-05-31 11:13   ` Russell King
2019-05-31 11:13 ` [PATCH 3/6] ARM: sa1100/h3xxx: " Russell King
2019-05-31 11:13   ` Russell King
2019-05-31 11:14 ` [PATCH 4/6] ARM: sa1100/badge4: remove commented out modem control initialisers Russell King
2019-05-31 11:14   ` Russell King
2019-05-31 11:14 ` [PATCH 5/6] ARM: sa1100/hackkit: remove empty serial mctrl functions Russell King
2019-05-31 11:14   ` Russell King
2019-05-31 11:14 ` [PATCH 6/6] ARM: sa1100/neponset: convert serial to use gpiod APIs Russell King
2019-05-31 11:14   ` Russell King
  -- strict thread matches above, loose matches on Subject: below --
2016-08-29 12:05 [PATCH 0/6] SA11x0 serial updates Russell King - ARM Linux
2016-08-29 12:05 ` [PATCH 1/6] serial: sa1100: add support for mctrl gpios Russell King
2016-08-29 12:05   ` Russell King
2016-08-31 13:25   ` Greg Kroah-Hartman
2016-08-31 13:25     ` Greg Kroah-Hartman

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=20190531125013.3gkexhmbqjpdvrtf@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /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.