From patchwork Thu Aug 18 17:34:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9289059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5DD00607FD for ; Fri, 19 Aug 2016 01:38:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FEF629072 for ; Fri, 19 Aug 2016 01:38:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 442DD29109; Fri, 19 Aug 2016 01:38:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B37AF29072 for ; Fri, 19 Aug 2016 01:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbcHSA4J (ORCPT ); Thu, 18 Aug 2016 20:56:09 -0400 Received: from leibniz.telenet-ops.be ([195.130.137.77]:58202 "EHLO leibniz.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754306AbcHSAyb (ORCPT ); Thu, 18 Aug 2016 20:54:31 -0400 X-Greylist: delayed 20651 seconds by postgrey-1.27 at vger.kernel.org; Thu, 18 Aug 2016 20:54:31 EDT Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by leibniz.telenet-ops.be (Postfix) with ESMTP id 3sFYBq6yHXzMqvgk for ; Thu, 18 Aug 2016 19:34:59 +0200 (CEST) Received: from ayla.of.borg ([84.193.137.253]) by albert.telenet-ops.be with bizsmtp id Yhaa1t00S5UCtCs06haa8U; Thu, 18 Aug 2016 19:34:36 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1baRD8-0002hY-L6; Thu, 18 Aug 2016 19:34:34 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1baRDA-0007zv-MU; Thu, 18 Aug 2016 19:34:36 +0200 From: Geert Uytterhoeven To: Ralf Baechle , Atsushi Nemoto , Mark Brown , Wim Van Sebroeck , Guenter Roeck Cc: linux-clk@vger.kernel.org, linux-mips@linux-mips.org, linux-spi@vger.kernel.org, linux-watchdog@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/3] MIPS: TXx9: Convert to Common Clock Framework Date: Thu, 18 Aug 2016 19:34:27 +0200 Message-Id: <1471541667-30689-4-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471541667-30689-1-git-send-email-geert@linux-m68k.org> References: <1471541667-30689-1-git-send-email-geert@linux-m68k.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include -#include +#include +#include #include #include #include @@ -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 #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;