From patchwork Tue Sep 22 14:12:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 7239421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D5F789F443 for ; Tue, 22 Sep 2015 14:20:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD741207CC for ; Tue, 22 Sep 2015 14:20:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D684E207E8 for ; Tue, 22 Sep 2015 14:20:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeONh-0000FP-15; Tue, 22 Sep 2015 14:17:17 +0000 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeONE-0008MQ-KG for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2015 14:16:51 +0000 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id t8MEEWTT018018; Tue, 22 Sep 2015 07:16:19 -0700 Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 1x152hggs8-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 22 Sep 2015 07:16:19 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 22 Sep 2015 07:16:17 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1044.25 via Frontend Transport; Tue, 22 Sep 2015 07:16:17 -0700 Received: from xhacker.marvell.com (unknown [10.37.135.134]) by maili.marvell.com (Postfix) with ESMTP id DFA553F7048; Tue, 22 Sep 2015 07:16:15 -0700 (PDT) From: Jisheng Zhang To: , , , , , , , Subject: [PATCH 3/5] clk: berlin: add clk support for berlin4ct Date: Tue, 22 Sep 2015 22:12:34 +0800 Message-ID: <1442931156-5877-4-git-send-email-jszhang@marvell.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1442931156-5877-1-git-send-email-jszhang@marvell.com> References: <1442931156-5877-1-git-send-email-jszhang@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2015-09-22_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=inbound_notspam policy=inbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1507310000 definitions=main-1509220208 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150922_071648_813864_6F46B7A0 X-CRM114-Status: GOOD ( 17.79 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jisheng Zhang , devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch supports the gate-clk and berlin-clk in berlin4ct SoC. Signed-off-by: Jisheng Zhang --- drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/clk-berlin4ct.c | 164 +++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/berlin/clk-berlin4ct.c diff --git a/drivers/clk/berlin/Makefile b/drivers/clk/berlin/Makefile index 741ba22..fe29dd3 100644 --- a/drivers/clk/berlin/Makefile +++ b/drivers/clk/berlin/Makefile @@ -1,4 +1,4 @@ -obj-y += pll.o clk.o berlin2-avpll.o berlin2-pll.o berlin2-div.o +obj-y += pll.o clk.o clk-berlin4ct.o berlin2-avpll.o berlin2-pll.o berlin2-div.o obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2Q) += bg2q.o diff --git a/drivers/clk/berlin/clk-berlin4ct.c b/drivers/clk/berlin/clk-berlin4ct.c new file mode 100644 index 0000000..b9d4a9b --- /dev/null +++ b/drivers/clk/berlin/clk-berlin4ct.c @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2015 Marvell Technology Group Ltd. + * + * Author: Jisheng Zhang + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +#include +#include +#include +#include +#include +#include + +#include "clk.h" + +#define CLK_SOURCE_MAX 5 + +static struct clk_onecell_data gateclk_data; +static struct clk_onecell_data clk_data; + +static DEFINE_SPINLOCK(lock); + +static const struct gateclk_desc berlin4ct_gates[] __initconst = { + { "tspsysclk", "perifsysclk", 0 }, + { "usb0coreclk", "perifsysclk", 1 }, + { "zspsysclk", "perifsysclk", 2 }, + { "sdiosysclk", "perifsysclk", 3 }, + { "ethcoreclk", "perifsysclk", 4 }, + { "pcie0sys", "perifsysclk", 6 }, + { "sata0core", "perifsysclk", 7 }, + { "nfcsysclk", "perifsysclk", 8 }, + { "emmcsysclk", "perifsysclk", 9 }, + { "ihb0sysclk", "perifsysclk", 10 }, +}; + +static const struct clk_desc berlin4ct_descs[] __initconst = { + { "cpufastrefclk", 0x0 }, + { "memfastrefclk", 0x4 }, + { "cfgclk", 0x20, CLK_IGNORE_UNUSED }, + { "perifsysclk", 0x24, CLK_IGNORE_UNUSED }, + { "hbclk", 0x28 }, + { "atbclk", 0x2c }, + { "decoderclk", 0x40 }, + { "decoderm3clk", 0x44 }, + { "decoderpcubeclk", 0x48 }, + { "encoderclk", 0x4c }, + { "ovpcoreclk", 0x50 }, + { "gfx2dcoreclk", 0x60 }, + { "gfx3dcoreclk", 0x64 }, + { "gfx3dshclk", 0x68 }, + { "gfx3dsysclk", 0x6c }, + { "gfx2dsysclk", 0x70 }, + { "aviosysclk", 0x80 }, + { "vppsysclk", 0x84 }, + { "eddcclk", 0x88 }, + { "aviobiuclk", 0x8c }, + { "zspclk", 0xa0 }, + { "tspclk", 0xc0 }, + { "tsprefclk", 0xc4 }, + { "ndsclk", 0xc8 }, + { "nocsclk", 0xcc }, + { "apbcoreclk", 0xd0, CLK_IGNORE_UNUSED }, + { "emmcclk", 0xe0 }, + { "sd0clk", 0xe4 }, + { "sd1clk", 0xe8 }, + { "dllmstrefclk", 0xec }, + { "gethrgmiiclk", 0xf0 }, + { "gethrgmiisysclk", 0xf4 }, + { "usim0clk", 0x100 }, + { "pcietestclk", 0x110 }, + { "usb2testclk", 0x120 }, + { "usb3testclk", 0x124 }, + { "usb3coreclk", 0x128 }, + { "nfceccclk", 0x130 }, + { "bcmclk", 0x140 }, +}; + +static void __init berlin4ct_gateclk_setup(struct device_node *np) +{ + int i, n, ret; + void __iomem *base; + struct clk **clks; + + base = of_iomap(np, 0); + if (WARN_ON(!base)) + return; + + n = ARRAY_SIZE(berlin4ct_gates); + clks = kzalloc(n * sizeof(struct clk *), GFP_KERNEL); + if (WARN_ON(!clks)) + return; + + for (i = 0; i < n; i++) { + clks[i] = clk_register_gate(NULL, berlin4ct_gates[i].name, + berlin4ct_gates[i].parent_name, + berlin4ct_gates[i].flags, base, + berlin4ct_gates[i].bit_idx, 0, &lock); + WARN_ON(IS_ERR(clks[i])); + } + + gateclk_data.clks = clks; + gateclk_data.clk_num = i; + + ret = of_clk_add_provider(np, of_clk_src_onecell_get, + &gateclk_data); + if (WARN_ON(ret)) + return; + +} +CLK_OF_DECLARE(berlin4ct_gateclk, "marvell,berlin4ct-gateclk", + berlin4ct_gateclk_setup); + +static void __init berlin4ct_clk_setup(struct device_node *np) +{ + int i, n, ret, num_parents; + void __iomem *base; + struct clk **clks; + const char *parent_names[CLK_SOURCE_MAX]; + + num_parents = of_clk_get_parent_count(np); + if (num_parents <= 0 || num_parents > CLK_SOURCE_MAX) + return; + + of_clk_parent_fill(np, parent_names, num_parents); + + base = of_iomap(np, 0); + if (WARN_ON(!base)) + return; + + n = ARRAY_SIZE(berlin4ct_descs); + clks = kzalloc(n * sizeof(struct clk *), GFP_KERNEL); + if (WARN_ON(!clks)) + return; + + for (i = 0; i < n; i++) { + clks[i] = berlin_clk_register(berlin4ct_descs[i].name, + num_parents, parent_names, + berlin4ct_descs[i].flags, + base + berlin4ct_descs[i].offset); + WARN_ON(IS_ERR(clks[i])); + } + + clk_data.clks = clks; + clk_data.clk_num = i; + + ret = of_clk_add_provider(np, of_clk_src_onecell_get, + &clk_data); + if (WARN_ON(ret)) + return; + +} +CLK_OF_DECLARE(berlin4ct_clk, "marvell,berlin4ct-clk", + berlin4ct_clk_setup);