All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	linux-serial@vger.kernel.org, linux-sh@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 01/16] serial: sh-sci: Drop the interface clock
Date: Fri, 20 Nov 2015 16:27:54 +0000	[thread overview]
Message-ID: <20151120162754.GA692@rob-hp-laptop> (raw)
In-Reply-To: <1447958173-543-2-git-send-email-geert+renesas@glider.be>

On Thu, Nov 19, 2015 at 07:35:58PM +0100, Geert Uytterhoeven wrote:
> From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> As no platform defines an interface clock the SCI driver always falls
> back to a clock named "peripheral_clk".
>   - On SH platforms that clock is the base clock for the SCI functional
>     clock and has the same frequency,
>   - On ARM platforms that clock doesn't exist, and clk_get() will return
>     the default clock for the device.
> We can thus make the functional clock mandatory and drop the interface
> clock.
> 
> EPROBE_DEFER is handled for clocks that may be referenced from DT (i.e.
> "fck" and deprecated "sci_ick").
> 
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Acked-by: Simon Horman <horms+renesas@verge.net.au>
> [geert: Handle EPROBE_DEFER, reformat description, break long comment line]
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

This could break users that care about the clock name. A new dtb with 
old kernel would be one example. I guess you are okay with that, so:

Acked-by: Rob Herring <robh@kernel.org>


> ---
> v2:
>   - Add Acked-by,
>   - Amendment by geert.
> ---
>  .../bindings/serial/renesas,sci-serial.txt         |  4 +-
>  drivers/tty/serial/sh-sci.c                        | 64 ++++++++++++++--------
>  2 files changed, 43 insertions(+), 25 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
> index 73f825e5e6448815..2c9e6b8477e92792 100644
> --- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
> +++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
> @@ -42,7 +42,7 @@ Required properties:
>  
>    - clocks: Must contain a phandle and clock-specifier pair for each entry
>      in clock-names.
> -  - clock-names: Must contain "sci_ick" for the SCIx UART interface clock.
> +  - clock-names: Must contain "fck" for the SCIx UART functional clock.
>  
>  Note: Each enabled SCIx UART should have an alias correctly numbered in the
>  "aliases" node.
> @@ -63,7 +63,7 @@ Example:
>  		interrupt-parent = <&gic>;
>  		interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
>  		clocks = <&mstp2_clks R8A7790_CLK_SCIFA0>;
> -		clock-names = "sci_ick";
> +		clock-names = "fck";
>  		dmas = <&dmac0 0x21>, <&dmac0 0x22>;
>  		dma-names = "tx", "rx";
>  	};
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 51c7507b0444957b..3c908804cab1c88c 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -92,8 +92,6 @@ struct sci_port {
>  	struct timer_list	break_timer;
>  	int			break_flag;
>  
> -	/* Interface clock */
> -	struct clk		*iclk;
>  	/* Function clock */
>  	struct clk		*fclk;
>  
> @@ -457,9 +455,8 @@ static void sci_port_enable(struct sci_port *sci_port)
>  
>  	pm_runtime_get_sync(sci_port->port.dev);
>  
> -	clk_prepare_enable(sci_port->iclk);
> -	sci_port->port.uartclk = clk_get_rate(sci_port->iclk);
>  	clk_prepare_enable(sci_port->fclk);
> +	sci_port->port.uartclk = clk_get_rate(sci_port->fclk);
>  }
>  
>  static void sci_port_disable(struct sci_port *sci_port)
> @@ -476,7 +473,6 @@ static void sci_port_disable(struct sci_port *sci_port)
>  	sci_port->break_flag = 0;
>  
>  	clk_disable_unprepare(sci_port->fclk);
> -	clk_disable_unprepare(sci_port->iclk);
>  
>  	pm_runtime_put_sync(sci_port->port.dev);
>  }
> @@ -1622,7 +1618,7 @@ static int sci_notifier(struct notifier_block *self,
>  		struct uart_port *port = &sci_port->port;
>  
>  		spin_lock_irqsave(&port->lock, flags);
> -		port->uartclk = clk_get_rate(sci_port->iclk);
> +		port->uartclk = clk_get_rate(sci_port->fclk);
>  		spin_unlock_irqrestore(&port->lock, flags);
>  	}
>  
> @@ -2241,6 +2237,42 @@ static struct uart_ops sci_uart_ops = {
>  #endif
>  };
>  
> +static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
> +{
> +	/* Get the SCI functional clock. It's called "fck" on ARM. */
> +	sci_port->fclk = clk_get(dev, "fck");
> +	if (PTR_ERR(sci_port->fclk) = -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	/*
> +	 * But it used to be called "sci_ick", and we need to maintain DT
> +	 * backward compatibility.
> +	 */
> +	sci_port->fclk = clk_get(dev, "sci_ick");
> +	if (PTR_ERR(sci_port->fclk) = -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	/* SH has historically named the clock "sci_fck". */
> +	sci_port->fclk = clk_get(dev, "sci_fck");
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	/*
> +	 * Not all SH platforms declare a clock lookup entry for SCI devices,
> +	 * in which case we need to get the global "peripheral_clk" clock.
> +	 */
> +	sci_port->fclk = clk_get(dev, "peripheral_clk");
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	dev_err(dev, "failed to get functional clock\n");
> +	return PTR_ERR(sci_port->fclk);
> +}
> +
>  static int sci_init_single(struct platform_device *dev,
>  			   struct sci_port *sci_port, unsigned int index,
>  			   struct plat_sci_port *p, bool early)
> @@ -2333,22 +2365,9 @@ static int sci_init_single(struct platform_device *dev,
>  		sci_port->sampling_rate = p->sampling_rate;
>  
>  	if (!early) {
> -		sci_port->iclk = clk_get(&dev->dev, "sci_ick");
> -		if (IS_ERR(sci_port->iclk)) {
> -			sci_port->iclk = clk_get(&dev->dev, "peripheral_clk");
> -			if (IS_ERR(sci_port->iclk)) {
> -				dev_err(&dev->dev, "can't get iclk\n");
> -				return PTR_ERR(sci_port->iclk);
> -			}
> -		}
> -
> -		/*
> -		 * The function clock is optional, ignore it if we can't
> -		 * find it.
> -		 */
> -		sci_port->fclk = clk_get(&dev->dev, "sci_fck");
> -		if (IS_ERR(sci_port->fclk))
> -			sci_port->fclk = NULL;
> +		ret = sci_init_clocks(sci_port, &dev->dev);
> +		if (ret < 0)
> +			return ret;
>  
>  		port->dev = &dev->dev;
>  
> @@ -2405,7 +2424,6 @@ static int sci_init_single(struct platform_device *dev,
>  
>  static void sci_cleanup_single(struct sci_port *port)
>  {
> -	clk_put(port->iclk);
>  	clk_put(port->fclk);
>  
>  	pm_runtime_disable(port->port.dev);
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Rob Herring <robh@kernel.org>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	linux-serial@vger.kernel.org, linux-sh@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 01/16] serial: sh-sci: Drop the interface clock
Date: Fri, 20 Nov 2015 10:27:54 -0600	[thread overview]
Message-ID: <20151120162754.GA692@rob-hp-laptop> (raw)
In-Reply-To: <1447958173-543-2-git-send-email-geert+renesas@glider.be>

On Thu, Nov 19, 2015 at 07:35:58PM +0100, Geert Uytterhoeven wrote:
> From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> As no platform defines an interface clock the SCI driver always falls
> back to a clock named "peripheral_clk".
>   - On SH platforms that clock is the base clock for the SCI functional
>     clock and has the same frequency,
>   - On ARM platforms that clock doesn't exist, and clk_get() will return
>     the default clock for the device.
> We can thus make the functional clock mandatory and drop the interface
> clock.
> 
> EPROBE_DEFER is handled for clocks that may be referenced from DT (i.e.
> "fck" and deprecated "sci_ick").
> 
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Acked-by: Simon Horman <horms+renesas@verge.net.au>
> [geert: Handle EPROBE_DEFER, reformat description, break long comment line]
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

This could break users that care about the clock name. A new dtb with 
old kernel would be one example. I guess you are okay with that, so:

Acked-by: Rob Herring <robh@kernel.org>


> ---
> v2:
>   - Add Acked-by,
>   - Amendment by geert.
> ---
>  .../bindings/serial/renesas,sci-serial.txt         |  4 +-
>  drivers/tty/serial/sh-sci.c                        | 64 ++++++++++++++--------
>  2 files changed, 43 insertions(+), 25 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
> index 73f825e5e6448815..2c9e6b8477e92792 100644
> --- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
> +++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
> @@ -42,7 +42,7 @@ Required properties:
>  
>    - clocks: Must contain a phandle and clock-specifier pair for each entry
>      in clock-names.
> -  - clock-names: Must contain "sci_ick" for the SCIx UART interface clock.
> +  - clock-names: Must contain "fck" for the SCIx UART functional clock.
>  
>  Note: Each enabled SCIx UART should have an alias correctly numbered in the
>  "aliases" node.
> @@ -63,7 +63,7 @@ Example:
>  		interrupt-parent = <&gic>;
>  		interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
>  		clocks = <&mstp2_clks R8A7790_CLK_SCIFA0>;
> -		clock-names = "sci_ick";
> +		clock-names = "fck";
>  		dmas = <&dmac0 0x21>, <&dmac0 0x22>;
>  		dma-names = "tx", "rx";
>  	};
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 51c7507b0444957b..3c908804cab1c88c 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -92,8 +92,6 @@ struct sci_port {
>  	struct timer_list	break_timer;
>  	int			break_flag;
>  
> -	/* Interface clock */
> -	struct clk		*iclk;
>  	/* Function clock */
>  	struct clk		*fclk;
>  
> @@ -457,9 +455,8 @@ static void sci_port_enable(struct sci_port *sci_port)
>  
>  	pm_runtime_get_sync(sci_port->port.dev);
>  
> -	clk_prepare_enable(sci_port->iclk);
> -	sci_port->port.uartclk = clk_get_rate(sci_port->iclk);
>  	clk_prepare_enable(sci_port->fclk);
> +	sci_port->port.uartclk = clk_get_rate(sci_port->fclk);
>  }
>  
>  static void sci_port_disable(struct sci_port *sci_port)
> @@ -476,7 +473,6 @@ static void sci_port_disable(struct sci_port *sci_port)
>  	sci_port->break_flag = 0;
>  
>  	clk_disable_unprepare(sci_port->fclk);
> -	clk_disable_unprepare(sci_port->iclk);
>  
>  	pm_runtime_put_sync(sci_port->port.dev);
>  }
> @@ -1622,7 +1618,7 @@ static int sci_notifier(struct notifier_block *self,
>  		struct uart_port *port = &sci_port->port;
>  
>  		spin_lock_irqsave(&port->lock, flags);
> -		port->uartclk = clk_get_rate(sci_port->iclk);
> +		port->uartclk = clk_get_rate(sci_port->fclk);
>  		spin_unlock_irqrestore(&port->lock, flags);
>  	}
>  
> @@ -2241,6 +2237,42 @@ static struct uart_ops sci_uart_ops = {
>  #endif
>  };
>  
> +static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
> +{
> +	/* Get the SCI functional clock. It's called "fck" on ARM. */
> +	sci_port->fclk = clk_get(dev, "fck");
> +	if (PTR_ERR(sci_port->fclk) == -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	/*
> +	 * But it used to be called "sci_ick", and we need to maintain DT
> +	 * backward compatibility.
> +	 */
> +	sci_port->fclk = clk_get(dev, "sci_ick");
> +	if (PTR_ERR(sci_port->fclk) == -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	/* SH has historically named the clock "sci_fck". */
> +	sci_port->fclk = clk_get(dev, "sci_fck");
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	/*
> +	 * Not all SH platforms declare a clock lookup entry for SCI devices,
> +	 * in which case we need to get the global "peripheral_clk" clock.
> +	 */
> +	sci_port->fclk = clk_get(dev, "peripheral_clk");
> +	if (!IS_ERR(sci_port->fclk))
> +		return 0;
> +
> +	dev_err(dev, "failed to get functional clock\n");
> +	return PTR_ERR(sci_port->fclk);
> +}
> +
>  static int sci_init_single(struct platform_device *dev,
>  			   struct sci_port *sci_port, unsigned int index,
>  			   struct plat_sci_port *p, bool early)
> @@ -2333,22 +2365,9 @@ static int sci_init_single(struct platform_device *dev,
>  		sci_port->sampling_rate = p->sampling_rate;
>  
>  	if (!early) {
> -		sci_port->iclk = clk_get(&dev->dev, "sci_ick");
> -		if (IS_ERR(sci_port->iclk)) {
> -			sci_port->iclk = clk_get(&dev->dev, "peripheral_clk");
> -			if (IS_ERR(sci_port->iclk)) {
> -				dev_err(&dev->dev, "can't get iclk\n");
> -				return PTR_ERR(sci_port->iclk);
> -			}
> -		}
> -
> -		/*
> -		 * The function clock is optional, ignore it if we can't
> -		 * find it.
> -		 */
> -		sci_port->fclk = clk_get(&dev->dev, "sci_fck");
> -		if (IS_ERR(sci_port->fclk))
> -			sci_port->fclk = NULL;
> +		ret = sci_init_clocks(sci_port, &dev->dev);
> +		if (ret < 0)
> +			return ret;
>  
>  		port->dev = &dev->dev;
>  
> @@ -2405,7 +2424,6 @@ static int sci_init_single(struct platform_device *dev,
>  
>  static void sci_cleanup_single(struct sci_port *port)
>  {
> -	clk_put(port->iclk);
>  	clk_put(port->fclk);
>  
>  	pm_runtime_disable(port->port.dev);
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-11-20 16:27 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-19 18:35 [PATCH v2 00/16] serial: sh-sci: Clock Cleanups Geert Uytterhoeven
2015-11-19 18:35 ` Geert Uytterhoeven
     [not found] ` <1447958173-543-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2015-11-19 18:35   ` [PATCH v2 01/16] serial: sh-sci: Drop the interface clock Geert Uytterhoeven
2015-11-19 18:35     ` Geert Uytterhoeven
2015-11-20 16:27     ` Rob Herring [this message]
2015-11-20 16:27       ` Rob Herring
2015-12-13  6:42     ` Greg Kroah-Hartman
2015-12-13  6:42       ` Greg Kroah-Hartman
2015-12-14  8:15       ` Simon Horman
2015-12-14  8:15         ` Simon Horman
     [not found]         ` <20151214081540.GD9929-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2015-12-14  8:16           ` Simon Horman
2015-12-14  8:16             ` Simon Horman
2015-11-19 18:35 ` [PATCH v2 02/16] sh: Rename sci_ick and sci_fck clock to fck Geert Uytterhoeven
2015-11-19 18:35   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 03/16] sh: Remove sci_ick clock alias Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 04/16] ARM: shmobile: sh73a0 dtsi: Rename the serial port clock to fck Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 05/16] ARM: shmobile: r7s72100 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 06/16] ARM: shmobile: r8a73a4 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 07/16] ARM: shmobile: r8a7740 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 08/16] ARM: shmobile: r8a7778 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 09/16] ARM: shmobile: r8a7779 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 10/16] ARM: shmobile: r8a7790 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 11/16] ARM: shmobile: r8a7791 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 12/16] ARM: shmobile: r8a7793 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-12-14  8:15   ` Simon Horman
2015-12-14  8:15     ` Simon Horman
2015-11-19 18:36 ` [PATCH v2 13/16] ARM: shmobile: r8a7794 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:36 ` [PATCH v2 14/16] arm64: renesas: r8a7795 " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:43   ` Laurent Pinchart
2015-11-19 18:43     ` Laurent Pinchart
2015-11-19 18:36 ` [PATCH v2 15/16] h8300: dts: " Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-11-19 18:43   ` Laurent Pinchart
2015-11-19 18:43     ` Laurent Pinchart
2015-11-19 18:36 ` [PATCH v2 16/16] serial: sh-sci: Drop the sci_fck clock fallback Geert Uytterhoeven
2015-11-19 18:36   ` Geert Uytterhoeven
2015-12-13  6:42   ` Greg Kroah-Hartman
2015-12-13  6:42     ` Greg Kroah-Hartman
2015-11-24  2:44 ` [PATCH v2 00/16] serial: sh-sci: Clock Cleanups Simon Horman
2015-11-24  2:44   ` Simon Horman
2015-12-14  8:15 ` Simon Horman
2015-12-14  8:15   ` Simon Horman
2015-12-14  8:31   ` Geert Uytterhoeven
2015-12-14  8:31     ` Geert Uytterhoeven
2015-12-14  9:11     ` Simon Horman
2015-12-14  9:11       ` Simon Horman

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=20151120162754.GA692@rob-hp-laptop \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=ysato@users.sourceforge.jp \
    /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.