From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Ralf Baechle <ralf@linux-mips.org>,
Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
Mark Brown <broonie@kernel.org>, Wim Van Sebroeck <wim@iguana.be>,
Guenter Roeck <linux@roeck-us.net>
Cc: linux-clk@vger.kernel.org, linux-mips@linux-mips.org,
linux-spi@vger.kernel.org, linux-watchdog@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework
Date: Thu, 18 Aug 2016 19:34:27 +0200 [thread overview]
Message-ID: <1471541667-30689-4-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1471541667-30689-1-git-send-email-geert@linux-m68k.org>
Replace the custom minimal clock implementation for Toshiba TXx9 by a
basic implementation using the Common Clock Framework.
The only clocks that are provided are those needed by TXx9-specific
drivers ("imbus" and "spi" (TX4938 only)), and their common parent
clock "gbus". Other clocks can be added when needed.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Tested on RBTX4927.
---
arch/mips/txx9/Kconfig | 2 +-
arch/mips/txx9/generic/setup.c | 68 ++++++++++++++++++++----------------------
2 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/arch/mips/txx9/Kconfig b/arch/mips/txx9/Kconfig
index 8c337d60f790db9f..42923478d45ca363 100644
--- a/arch/mips/txx9/Kconfig
+++ b/arch/mips/txx9/Kconfig
@@ -20,7 +20,7 @@ config MACH_TXX9
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_LITTLE_ENDIAN
select SYS_SUPPORTS_BIG_ENDIAN
- select HAVE_CLK
+ select COMMON_CLK
config TOSHIBA_JMR3927
bool "Toshiba JMR-TX3927 board"
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index ada92db92f87d91a..2fdbcf91b2cc472c 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -15,7 +15,8 @@
#include <linux/interrupt.h>
#include <linux/string.h>
#include <linux/module.h>
-#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
#include <linux/err.h>
#include <linux/gpio/driver.h>
#include <linux/platform_device.h>
@@ -83,40 +84,6 @@ int txx9_ccfg_toeon __initdata;
int txx9_ccfg_toeon __initdata = 1;
#endif
-/* Minimum CLK support */
-
-struct clk *clk_get(struct device *dev, const char *id)
-{
- if (!strcmp(id, "spi-baseclk"))
- return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 2);
- if (!strcmp(id, "imbus_clk"))
- return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
- return ERR_PTR(-ENOENT);
-}
-EXPORT_SYMBOL(clk_get);
-
-int clk_enable(struct clk *clk)
-{
- return 0;
-}
-EXPORT_SYMBOL(clk_enable);
-
-void clk_disable(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_disable);
-
-unsigned long clk_get_rate(struct clk *clk)
-{
- return (unsigned long)clk;
-}
-EXPORT_SYMBOL(clk_get_rate);
-
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_put);
-
#define BOARD_VEC(board) extern struct txx9_board_vec board;
#include <asm/txx9/boards.h>
#undef BOARD_VEC
@@ -560,8 +527,39 @@ void __init plat_time_init(void)
txx9_board_vec->time_init();
}
+static void txx9_clk_init(void)
+{
+ struct clk *clk;
+ int error;
+
+ clk = clk_register_fixed_rate(NULL, "gbus", NULL, 0, txx9_gbus_clock);
+ if (IS_ERR(clk)) {
+ error = PTR_ERR(clk);
+ goto fail;
+ }
+
+ clk = clk_register_fixed_factor(NULL, "imbus", "gbus", 0, 1, 2);
+ error = clk_register_clkdev(clk, "imbus_clk", NULL);
+ if (error)
+ goto fail;
+
+ if (TX4938_REV_PCODE() == 0x4938) {
+ clk = clk_register_fixed_factor(NULL, "spi", "gbus", 0, 1, 4);
+ error = clk_register_clkdev(clk, "spi-baseclk", NULL);
+ if (error)
+ goto fail;
+ }
+
+ return;
+
+fail:
+ pr_err("Failed to register clocks: %d\n", error);
+}
+
static int __init _txx9_arch_init(void)
{
+ txx9_clk_init();
+
if (txx9_board_vec->arch_init)
txx9_board_vec->arch_init();
return 0;
--
1.9.1
next prev parent reply other threads:[~2016-08-18 17:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 17:34 [PATCH 0/3] MIPS: TXx9: Common Clock Framework Conversion Geert Uytterhoeven
2016-08-18 17:34 ` [PATCH 1/3] spi: spi-txx9: Add missing clock (un)prepare calls for CCF Geert Uytterhoeven
2016-08-18 17:34 ` [PATCH 2/3] watchdog: txx9wdt: " Geert Uytterhoeven
2016-08-18 18:58 ` Guenter Roeck
[not found] ` <1471541667-30689-3-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2016-08-20 8:36 ` Guenter Roeck
2016-08-18 17:34 ` Geert Uytterhoeven [this message]
2016-08-19 12:05 ` [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework Atsushi Nemoto
[not found] ` <1471541667-30689-4-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2016-08-19 19:17 ` Stephen Boyd
[not found] ` <20160819191750.GV361-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-08-22 8:46 ` Geert Uytterhoeven
2016-08-22 17:37 ` Stephen Boyd
2016-08-18 18:11 ` [PATCH 0/3] MIPS: TXx9: Common Clock Framework Conversion Mark Brown
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=1471541667-30689-4-git-send-email-geert@linux-m68k.org \
--to=geert@linux-m68k.org \
--cc=anemo@mba.ocn.ne.jp \
--cc=broonie@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=ralf@linux-mips.org \
--cc=wim@iguana.be \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).