From abe252ae2cadba1c8eafb00e02b318993b22f0c2 Mon Sep 17 00:00:00 2001 From: Teknoman117 Date: Wed, 24 Jul 2013 02:57:08 -0700 Subject: [PATCH 1/4] Added the Texas Instruments OMAP Clock driver originally found here: http://lkml.indiana.edu/hypermail/linux/kernel/1304.1/04079.html --- drivers/clk/Makefile | 1 + drivers/clk/omap/Makefile | 1 + drivers/clk/omap/clk.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 drivers/clk/omap/Makefile create mode 100644 drivers/clk/omap/clk.c diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 7b11106..e6a0195 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_ARCH_ZYNQ) += zynq/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ +obj-$(CONFIG_ARCH_OMAP) += omap/ obj-$(CONFIG_PLAT_SAMSUNG) += samsung/ obj-$(CONFIG_X86) += x86/ diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile new file mode 100644 index 0000000..0303c0b --- /dev/null +++ b/drivers/clk/omap/Makefile @@ -0,0 +1 @@ +obj-y += clk.o diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c new file mode 100644 index 0000000..f7f432d --- /dev/null +++ b/drivers/clk/omap/clk.c @@ -0,0 +1,100 @@ +/* + * Texas Instruments OMAP Clock driver + * + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/ + * Nishanth Menon + * Tony Lindgren + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include + +static const struct of_device_id omap_clk_of_match[] = { + {.compatible = "ti,omap-clock",}, + {}, +}; + +/** + * omap_clk_src_get() - Get OMAP clock from node name when needed + * @clkspec: clkspec argument + * @data: unused + * + * REVISIT: We assume the following: + * 1. omap clock names end with _ck + * 2. omap clock names are under 32 characters in length + */ +static struct clk *omap_clk_src_get(struct of_phandle_args *clkspec, void *data) +{ + struct clk *clk; + char clk_name[32]; + struct device_node *np = clkspec->np; + + /* Set up things so consumer can call clk_get() with name */ + snprintf(clk_name, 32, "%s_ck", np->name); + clk = clk_get(NULL, clk_name); + if (IS_ERR(clk)) + { + pr_err("%s: could not get clock %s(%ld)\n", __func__, + clk_name, PTR_ERR(clk)); + goto out; + } + clk_put(clk); + +out: + return clk; +} + +/** + * omap_clk_probe() - create link from DT definition to clock data + * @pdev: device node + * + * NOTE: We assume that omap clocks are not removed. + */ +static int omap_clk_probe(struct platform_device *pdev) +{ + int res; + struct device_node *np = pdev->dev.of_node; + + /* This allows the driver to of_clk_get() */ + res = of_clk_add_provider(np, omap_clk_src_get, NULL); + if (res) + dev_err(&pdev->dev, "could not add provider(%d)\n", res); + + return res; +} + +/* We assume here that OMAP clocks will not be removed */ +static struct platform_driver omap_clk_driver = +{ + .probe = omap_clk_probe, + .driver = + { + .name = "omap_clk", + .of_match_table = of_match_ptr(omap_clk_of_match), + }, +}; + +static int __init omap_clk_init(void) +{ + return platform_driver_register(&omap_clk_driver); +} + +arch_initcall(omap_clk_init); + +MODULE_DESCRIPTION("OMAP Clock driver"); +MODULE_AUTHOR("Texas Instruments Inc."); +MODULE_LICENSE("GPL v2"); -- 1.8.4.rc3