aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorThomas Abraham <thomas.abraham@linaro.org>2011-11-06 11:40:44 -0500
committerKukjin Kim <kgene.kim@samsung.com>2011-12-22 20:07:01 -0500
commit26c919e1d3f4dff87ad50e104670f048cbc69b17 (patch)
tree7ad7222cb616409257e414b403e9b5ea2c488a07 /drivers
parentda121506eb03ee5daea55404709110b798bd61d9 (diff)
serial: samsung: add device tree support
Add device tree based discovery support for Samsung's uart controller. Cc: Ben Dooks <ben-linux@fluff.org> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/serial/samsung.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index c89987b64c15..efe3756b53f9 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -42,6 +42,7 @@
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/clk.h> 43#include <linux/clk.h>
44#include <linux/cpufreq.h> 44#include <linux/cpufreq.h>
45#include <linux/of.h>
45 46
46#include <asm/irq.h> 47#include <asm/irq.h>
47 48
@@ -1163,10 +1164,26 @@ static ssize_t s3c24xx_serial_show_clksrc(struct device *dev,
1163 1164
1164static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL); 1165static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL);
1165 1166
1167
1166/* Device driver serial port probe */ 1168/* Device driver serial port probe */
1167 1169
1170static const struct of_device_id s3c24xx_uart_dt_match[];
1168static int probe_index; 1171static int probe_index;
1169 1172
1173static inline struct s3c24xx_serial_drv_data *s3c24xx_get_driver_data(
1174 struct platform_device *pdev)
1175{
1176#ifdef CONFIG_OF
1177 if (pdev->dev.of_node) {
1178 const struct of_device_id *match;
1179 match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node);
1180 return (struct s3c24xx_serial_drv_data *)match->data;
1181 }
1182#endif
1183 return (struct s3c24xx_serial_drv_data *)
1184 platform_get_device_id(pdev)->driver_data;
1185}
1186
1170static int s3c24xx_serial_probe(struct platform_device *pdev) 1187static int s3c24xx_serial_probe(struct platform_device *pdev)
1171{ 1188{
1172 struct s3c24xx_uart_port *ourport; 1189 struct s3c24xx_uart_port *ourport;
@@ -1176,8 +1193,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
1176 1193
1177 ourport = &s3c24xx_serial_ports[probe_index]; 1194 ourport = &s3c24xx_serial_ports[probe_index];
1178 1195
1179 ourport->drv_data = (struct s3c24xx_serial_drv_data *) 1196 ourport->drv_data = s3c24xx_get_driver_data(pdev);
1180 platform_get_device_id(pdev)->driver_data; 1197 if (!ourport->drv_data) {
1198 dev_err(&pdev->dev, "could not find driver data\n");
1199 return -ENODEV;
1200 }
1181 1201
1182 ourport->info = ourport->drv_data->info; 1202 ourport->info = ourport->drv_data->info;
1183 ourport->cfg = (pdev->dev.platform_data) ? 1203 ourport->cfg = (pdev->dev.platform_data) ?
@@ -1626,6 +1646,17 @@ static struct platform_device_id s3c24xx_serial_driver_ids[] = {
1626}; 1646};
1627MODULE_DEVICE_TABLE(platform, s3c24xx_serial_driver_ids); 1647MODULE_DEVICE_TABLE(platform, s3c24xx_serial_driver_ids);
1628 1648
1649#ifdef CONFIG_OF
1650static const struct of_device_id s3c24xx_uart_dt_match[] = {
1651 { .compatible = "samsung,exynos4210-uart",
1652 .data = &exynos4210_serial_drv_data },
1653 {},
1654};
1655MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match);
1656#else
1657#define s3c24xx_uart_dt_match NULL
1658#endif
1659
1629static struct platform_driver samsung_serial_driver = { 1660static struct platform_driver samsung_serial_driver = {
1630 .probe = s3c24xx_serial_probe, 1661 .probe = s3c24xx_serial_probe,
1631 .remove = __devexit_p(s3c24xx_serial_remove), 1662 .remove = __devexit_p(s3c24xx_serial_remove),
@@ -1634,6 +1665,7 @@ static struct platform_driver samsung_serial_driver = {
1634 .name = "samsung-uart", 1665 .name = "samsung-uart",
1635 .owner = THIS_MODULE, 1666 .owner = THIS_MODULE,
1636 .pm = SERIAL_SAMSUNG_PM_OPS, 1667 .pm = SERIAL_SAMSUNG_PM_OPS,
1668 .of_match_table = s3c24xx_uart_dt_match,
1637 }, 1669 },
1638}; 1670};
1639 1671