* Re: [RESEND PATCH 1/2] of serial port driver - add clk_get_rate() support
[not found] <1350401051-8254-1-git-send-email-m-karicheri2@ti.com>
@ 2012-10-16 15:32 ` Murali Karicheri
[not found] ` <1350401051-8254-2-git-send-email-m-karicheri2@ti.com>
1 sibling, 0 replies; 3+ messages in thread
From: Murali Karicheri @ 2012-10-16 15:32 UTC (permalink / raw)
To: Murali Karicheri; +Cc: alan, gregkh, linux-serial, linux-kernel, linux-keystone
On 10/16/2012 11:24 AM, Murali Karicheri wrote:
> Currently this driver expects the clock-frequency attribute. This
> patch allows getting clock-frequency through clk driver API
> clk_get_rate() if clock-frequency attribute is not defined.
>
> So in the device bindings for serial device, one can add clocks
> phandle to refer to the clk device to get the rate.
>
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>
> diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
> index 34e7187..6f64f02 100644
> --- a/drivers/tty/serial/of_serial.c
> +++ b/drivers/tty/serial/of_serial.c
> @@ -21,8 +21,10 @@
> #include <linux/of_serial.h>
> #include <linux/of_platform.h>
> #include <linux/nwpserial.h>
> +#include <linux/clk.h>
>
> struct of_serial_info {
> + struct clk *clk;
> int type;
> int line;
> };
> @@ -51,7 +53,8 @@ EXPORT_SYMBOL_GPL(tegra_serial_handle_break);
> * Fill a struct uart_port for a given device node
> */
> static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
> - int type, struct uart_port *port)
> + int type, struct uart_port *port,
> + struct of_serial_info *info)
> {
> struct resource resource;
> struct device_node *np = ofdev->dev.of_node;
> @@ -60,8 +63,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
>
> memset(port, 0, sizeof *port);
> if (of_property_read_u32(np, "clock-frequency", &clk)) {
> - dev_warn(&ofdev->dev, "no clock-frequency property set\n");
> - return -ENODEV;
> +
> + /* Get clk rate through clk driver if present */
> + info->clk = clk_get(&ofdev->dev, NULL);
> + if (info->clk == NULL) {
> + dev_warn(&ofdev->dev,
> + "clk or clock-frequency not defined\n");
> + return -ENODEV;
> + }
> +
> + clk_prepare_enable(info->clk);
> + clk = clk_get_rate(info->clk);
> }
> /* If current-speed was set, then try not to change it. */
> if (of_property_read_u32(np, "current-speed", &spd) == 0)
> @@ -70,7 +82,7 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
> ret = of_address_to_resource(np, 0, &resource);
> if (ret) {
> dev_warn(&ofdev->dev, "invalid address\n");
> - return ret;
> + goto out;
> }
>
> spin_lock_init(&port->lock);
> @@ -97,7 +109,8 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
> default:
> dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
> prop);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto out;
> }
> }
>
> @@ -111,6 +124,10 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
> port->handle_break = tegra_serial_handle_break;
>
> return 0;
> +out:
> + if (info->clk)
> + clk_disable_unprepare(info->clk);
> + return ret;
> }
>
> /*
> @@ -137,7 +154,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
> return -ENOMEM;
>
> port_type = (unsigned long)match->data;
> - ret = of_platform_serial_setup(ofdev, port_type, &port);
> + ret = of_platform_serial_setup(ofdev, port_type, &port, info);
> if (ret)
> goto out;
>
> @@ -193,6 +210,9 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
> /* need to add code for these */
> break;
> }
> +
> + if (info->clk)
> + clk_disable_unprepare(info->clk);
> kfree(info);
> return 0;
> }
For some reason, I can't see the two patches in this series at the
linux-serial server at http://marc.info/?l=linux-serial
Can someone tell me what could be wrong? My email seems to reach.. So trying
to reply and get this onto the mailing list.
Murali
^ permalink raw reply [flat|nested] 3+ messages in thread[parent not found: <1350401051-8254-2-git-send-email-m-karicheri2@ti.com>]
* Re: [RESEND PATCH 2/2] Documentation: of-serial.txt - update for clocks phandle for clk
[not found] ` <1350401051-8254-2-git-send-email-m-karicheri2@ti.com>
@ 2012-10-16 15:33 ` Murali Karicheri
0 siblings, 0 replies; 3+ messages in thread
From: Murali Karicheri @ 2012-10-16 15:33 UTC (permalink / raw)
To: Murali Karicheri; +Cc: alan, gregkh, linux-serial, linux-kernel, linux-keystone
On 10/16/2012 11:24 AM, Murali Karicheri wrote:
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>
> diff --git a/Documentation/devicetree/bindings/tty/serial/of-serial.txt b/Documentation/devicetree/bindings/tty/serial/of-serial.txt
> index 0847fde..423b7ff 100644
> --- a/Documentation/devicetree/bindings/tty/serial/of-serial.txt
> +++ b/Documentation/devicetree/bindings/tty/serial/of-serial.txt
> @@ -14,7 +14,10 @@ Required properties:
> - "serial" if the port type is unknown.
> - reg : offset and length of the register set for the device.
> - interrupts : should contain uart interrupt.
> -- clock-frequency : the input clock frequency for the UART.
> +- clock-frequency : the input clock frequency for the UART
> + or
> + clocks phandle to refer to the clk used as per Documentation/devicetree
> + /bindings/clock/clock-bindings.txt
>
> Optional properties:
> - current-speed : the current active speed of the UART.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [RESEND PATCH 1/2] of serial port driver - add clk_get_rate() support
@ 2012-10-22 15:58 Murali Karicheri
2012-10-22 15:58 ` [RESEND PATCH 2/2] Documentation: of-serial.txt - update for clocks phandle for clk Murali Karicheri
0 siblings, 1 reply; 3+ messages in thread
From: Murali Karicheri @ 2012-10-22 15:58 UTC (permalink / raw)
To: alan, gregkh, linux-serial, linux-kernel; +Cc: Murali Karicheri
Currently this driver expects the clock-frequency attribute. This
patch allows getting clock-frequency through clk driver API
clk_get_rate() if clock-frequency attribute is not defined.
So in the device bindings for serial device, one can add clocks
phandle to refer to the clk device to get the rate.
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 34e7187..6f64f02 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -21,8 +21,10 @@
#include <linux/of_serial.h>
#include <linux/of_platform.h>
#include <linux/nwpserial.h>
+#include <linux/clk.h>
struct of_serial_info {
+ struct clk *clk;
int type;
int line;
};
@@ -51,7 +53,8 @@ EXPORT_SYMBOL_GPL(tegra_serial_handle_break);
* Fill a struct uart_port for a given device node
*/
static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
- int type, struct uart_port *port)
+ int type, struct uart_port *port,
+ struct of_serial_info *info)
{
struct resource resource;
struct device_node *np = ofdev->dev.of_node;
@@ -60,8 +63,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
memset(port, 0, sizeof *port);
if (of_property_read_u32(np, "clock-frequency", &clk)) {
- dev_warn(&ofdev->dev, "no clock-frequency property set\n");
- return -ENODEV;
+
+ /* Get clk rate through clk driver if present */
+ info->clk = clk_get(&ofdev->dev, NULL);
+ if (info->clk == NULL) {
+ dev_warn(&ofdev->dev,
+ "clk or clock-frequency not defined\n");
+ return -ENODEV;
+ }
+
+ clk_prepare_enable(info->clk);
+ clk = clk_get_rate(info->clk);
}
/* If current-speed was set, then try not to change it. */
if (of_property_read_u32(np, "current-speed", &spd) == 0)
@@ -70,7 +82,7 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
ret = of_address_to_resource(np, 0, &resource);
if (ret) {
dev_warn(&ofdev->dev, "invalid address\n");
- return ret;
+ goto out;
}
spin_lock_init(&port->lock);
@@ -97,7 +109,8 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
default:
dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
prop);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
}
@@ -111,6 +124,10 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
port->handle_break = tegra_serial_handle_break;
return 0;
+out:
+ if (info->clk)
+ clk_disable_unprepare(info->clk);
+ return ret;
}
/*
@@ -137,7 +154,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
return -ENOMEM;
port_type = (unsigned long)match->data;
- ret = of_platform_serial_setup(ofdev, port_type, &port);
+ ret = of_platform_serial_setup(ofdev, port_type, &port, info);
if (ret)
goto out;
@@ -193,6 +210,9 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
/* need to add code for these */
break;
}
+
+ if (info->clk)
+ clk_disable_unprepare(info->clk);
kfree(info);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* [RESEND PATCH 2/2] Documentation: of-serial.txt - update for clocks phandle for clk
2012-10-22 15:58 [RESEND PATCH 1/2] of serial port driver - add clk_get_rate() support Murali Karicheri
@ 2012-10-22 15:58 ` Murali Karicheri
0 siblings, 0 replies; 3+ messages in thread
From: Murali Karicheri @ 2012-10-22 15:58 UTC (permalink / raw)
To: alan, gregkh, linux-serial, linux-kernel; +Cc: Murali Karicheri
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
diff --git a/Documentation/devicetree/bindings/tty/serial/of-serial.txt b/Documentation/devicetree/bindings/tty/serial/of-serial.txt
index 0847fde..423b7ff 100644
--- a/Documentation/devicetree/bindings/tty/serial/of-serial.txt
+++ b/Documentation/devicetree/bindings/tty/serial/of-serial.txt
@@ -14,7 +14,10 @@ Required properties:
- "serial" if the port type is unknown.
- reg : offset and length of the register set for the device.
- interrupts : should contain uart interrupt.
-- clock-frequency : the input clock frequency for the UART.
+- clock-frequency : the input clock frequency for the UART
+ or
+ clocks phandle to refer to the clk used as per Documentation/devicetree
+ /bindings/clock/clock-bindings.txt
Optional properties:
- current-speed : the current active speed of the UART.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-22 15:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1350401051-8254-1-git-send-email-m-karicheri2@ti.com>
2012-10-16 15:32 ` [RESEND PATCH 1/2] of serial port driver - add clk_get_rate() support Murali Karicheri
[not found] ` <1350401051-8254-2-git-send-email-m-karicheri2@ti.com>
2012-10-16 15:33 ` [RESEND PATCH 2/2] Documentation: of-serial.txt - update for clocks phandle for clk Murali Karicheri
2012-10-22 15:58 [RESEND PATCH 1/2] of serial port driver - add clk_get_rate() support Murali Karicheri
2012-10-22 15:58 ` [RESEND PATCH 2/2] Documentation: of-serial.txt - update for clocks phandle for clk Murali Karicheri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox