Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338389
b: refs/heads/master
c: 0bbeb3c
h: refs/heads/master
i:
  338387: 0f8b7a3
v: v3
  • Loading branch information
Murali Karicheri authored and Greg Kroah-Hartman committed Oct 25, 2012
1 parent c046fc3 commit 2b7d3e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cadf74869013dc309bde50ed446f56d33a6a9806
refs/heads/master: 0bbeb3c3e84bc963d1c66661e082d207023b0e5c
32 changes: 26 additions & 6 deletions trunk/drivers/tty/serial/of_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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;
}
}

Expand All @@ -115,6 +128,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;
}

/*
Expand All @@ -141,7 +158,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;

Expand Down Expand Up @@ -204,6 +221,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;
}
Expand Down

0 comments on commit 2b7d3e2

Please sign in to comment.