|
@@ -1,19 +1,100 @@
|
|
|
-From 3c8dd9d0937a19f3f20f28ba0b0b64f448d50dd4 Mon Sep 17 00:00:00 2001
|
|
|
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <[email protected]>
|
|
|
-Date: Thu, 25 Feb 2021 19:54:04 +0100
|
|
|
-Subject: [PATCH 4/4] clk: bcm: Add BCM63268 timer clock and reset driver
|
|
|
+From patchwork Wed Mar 22 17:15:15 2023
|
|
|
+Content-Type: text/plain; charset="utf-8"
|
|
|
MIME-Version: 1.0
|
|
|
-Content-Type: text/plain; charset=UTF-8
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
+X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?=
|
|
|
+ <[email protected]>
|
|
|
+X-Patchwork-Id: 13184392
|
|
|
+Return-Path: <[email protected]>
|
|
|
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
|
|
|
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
|
|
|
+Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
|
|
|
+ by smtp.lore.kernel.org (Postfix) with ESMTP id 199D9C76196
|
|
|
+ for <[email protected]>; Wed, 22 Mar 2023 17:16:11 +0000 (UTC)
|
|
|
+Received: ([email protected]) by vger.kernel.org via listexpand
|
|
|
+ id S231512AbjCVRQJ (ORCPT <rfc822;[email protected]>);
|
|
|
+ Wed, 22 Mar 2023 13:16:09 -0400
|
|
|
+Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58942 "EHLO
|
|
|
+ lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
|
|
|
+ with ESMTP id S231442AbjCVRP5 (ORCPT
|
|
|
+ <rfc822;[email protected]>); Wed, 22 Mar 2023 13:15:57 -0400
|
|
|
+Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com
|
|
|
+ [IPv6:2a00:1450:4864:20::32c])
|
|
|
+ by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DDB36487D;
|
|
|
+ Wed, 22 Mar 2023 10:15:27 -0700 (PDT)
|
|
|
+Received: by mail-wm1-x32c.google.com with SMTP id
|
|
|
+ i5-20020a05600c354500b003edd24054e0so6717370wmq.4;
|
|
|
+ Wed, 22 Mar 2023 10:15:27 -0700 (PDT)
|
|
|
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
|
|
+ d=gmail.com; s=20210112; t=1679505325;
|
|
|
+ h=content-transfer-encoding:mime-version:references:in-reply-to
|
|
|
+ :message-id:date:subject:cc:to:from:from:to:cc:subject:date
|
|
|
+ :message-id:reply-to;
|
|
|
+ bh=rkv/eZYA1ncHp5FnV2ZWc3hgYnAx28S86QA9vmcXFCY=;
|
|
|
+ b=Y1mva2Bt3sUbKxLgEUS331CJbGxUc4z8kTQW8qiHWGhYlFKtm+d5z4sT40E5BeZAnU
|
|
|
+ zmTbCI7jbroe9NYBxGUmSli6LNVDPjND80ChbhWTqbqMQTmeQFWut9KmeBWK6Oze2lC/
|
|
|
+ XMSOorUzowjcU2xtHNrzoq2KH2pstW573lsB8WnzFVfhMaRkE9DfRr6WNyA7zC8DyxM5
|
|
|
+ ezxlCQtCmgPfCqlyksbIDKrgrRf3GiUR0yUd6xRU+MssyvH1FkYGDCerPctDto6lGHBz
|
|
|
+ 8Y15jT3l6OnQMT6dkekgpPF5/XrSUY93u9g0B4U8+0dhNj+K7vmDen+jqdess+tpLnq/
|
|
|
+ gFrA==
|
|
|
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
|
|
|
+ d=1e100.net; s=20210112; t=1679505325;
|
|
|
+ h=content-transfer-encoding:mime-version:references:in-reply-to
|
|
|
+ :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
|
|
|
+ :subject:date:message-id:reply-to;
|
|
|
+ bh=rkv/eZYA1ncHp5FnV2ZWc3hgYnAx28S86QA9vmcXFCY=;
|
|
|
+ b=Ym4+u8bbTQGNkewUBrLf+89vE0EFJBQp2f1crwUxZFboKTROF9ltZonY1CGepo7b0B
|
|
|
+ fkx3TbWQy5X65g3ScuieqtClCI8WanPeNBJ48+JipJYO3ODVNBxnVaTuW/0FOIcahfqe
|
|
|
+ sG5GvggHhzRz+Yeybsbnupmzxnw8Ez0BpMl3p7zcjHL7BGZDdOOX2Zbw3zfyYa5sg2nX
|
|
|
+ UXYJT36zy2h39gxUsy9QkhQ76CG3w6omniohZpYidpojpiDjbOy0nKFky4kUe+YyA1fF
|
|
|
+ 4IBhjAm6mH+uh6wHSG1qj+NAXHs0xDDJps16PbJwAgL7Qt9K5WW+R/UAYPmHFgaRIHOw
|
|
|
+ /seA==
|
|
|
+X-Gm-Message-State: AO0yUKXRtoYO8Nfus6Ca8lhM39P1Xn6TGkhatEfoISd1YNOkTJJN2hW+
|
|
|
+ xRphLgxlzNfCLcVPlpGK9dk=
|
|
|
+X-Google-Smtp-Source:
|
|
|
+ AK7set9VnMEykugk8ZYnkXuqK41bX1dzlvKsAXHEjr8i2NZBld0buKhQLcGYEcwxnBgVTtC7eRGfXw==
|
|
|
+X-Received: by 2002:a1c:7c0b:0:b0:3e2:1dac:b071 with SMTP id
|
|
|
+ x11-20020a1c7c0b000000b003e21dacb071mr178053wmc.13.1679505325582;
|
|
|
+ Wed, 22 Mar 2023 10:15:25 -0700 (PDT)
|
|
|
+Received: from atlantis.lan (255.red-79-146-124.dynamicip.rima-tde.net.
|
|
|
+ [79.146.124.255])
|
|
|
+ by smtp.gmail.com with ESMTPSA id
|
|
|
+ v10-20020a05600c470a00b003ee11ac2288sm8414333wmo.21.2023.03.22.10.15.24
|
|
|
+ (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
|
|
|
+ Wed, 22 Mar 2023 10:15:25 -0700 (PDT)
|
|
|
+From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= <[email protected]>
|
|
|
+To: [email protected], [email protected], [email protected],
|
|
|
+ [email protected], [email protected],
|
|
|
+ [email protected], [email protected],
|
|
|
+ [email protected], [email protected],
|
|
|
+ [email protected], [email protected]
|
|
|
+Cc: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= <[email protected]>
|
|
|
+Subject: [PATCH v4 4/4] clk: bcm: Add BCM63268 timer clock and reset driver
|
|
|
+Date: Wed, 22 Mar 2023 18:15:15 +0100
|
|
|
+Message-Id: <[email protected]>
|
|
|
+X-Mailer: git-send-email 2.30.2
|
|
|
+In-Reply-To: <[email protected]>
|
|
|
+References: <[email protected]>
|
|
|
+MIME-Version: 1.0
|
|
|
+Precedence: bulk
|
|
|
+List-ID: <linux-clk.vger.kernel.org>
|
|
|
+X-Mailing-List: [email protected]
|
|
|
|
|
|
Add driver for BCM63268 timer clock and reset controller.
|
|
|
|
|
|
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
|
|
|
---
|
|
|
+ v4: add changes suggested by Stephen Boyd:
|
|
|
+ - Usage of of_device_get_match_data() isn't needed.
|
|
|
+ - Use devm_clk_hw_register_gate().
|
|
|
+ - Drop clk_hw_unregister_gate().
|
|
|
+ v3: add missing <linux/io.h> include to fix build warning
|
|
|
+ v2: add changes suggested by Stephen Boyd
|
|
|
+
|
|
|
drivers/clk/bcm/Kconfig | 9 ++
|
|
|
drivers/clk/bcm/Makefile | 1 +
|
|
|
- drivers/clk/bcm/clk-bcm63268-timer.c | 232 +++++++++++++++++++++++++++
|
|
|
- 3 files changed, 242 insertions(+)
|
|
|
+ drivers/clk/bcm/clk-bcm63268-timer.c | 215 +++++++++++++++++++++++++++
|
|
|
+ 3 files changed, 225 insertions(+)
|
|
|
create mode 100644 drivers/clk/bcm/clk-bcm63268-timer.c
|
|
|
|
|
|
--- a/drivers/clk/bcm/Kconfig
|
|
@@ -46,17 +127,17 @@ Signed-off-by: Álvaro Fernández Rojas <[email protected]>
|
|
|
obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o
|
|
|
--- /dev/null
|
|
|
+++ b/drivers/clk/bcm/clk-bcm63268-timer.c
|
|
|
-@@ -0,0 +1,232 @@
|
|
|
+@@ -0,0 +1,215 @@
|
|
|
+// SPDX-License-Identifier: GPL-2.0
|
|
|
+/*
|
|
|
+ * BCM63268 Timer Clock and Reset Controller Driver
|
|
|
+ *
|
|
|
-+ * Copyright (C) 2021 Álvaro Fernández Rojas <[email protected]>
|
|
|
++ * Copyright (C) 2023 Álvaro Fernández Rojas <[email protected]>
|
|
|
+ */
|
|
|
+
|
|
|
+#include <linux/clk-provider.h>
|
|
|
+#include <linux/delay.h>
|
|
|
-+#include <linux/init.h>
|
|
|
++#include <linux/io.h>
|
|
|
+#include <linux/of.h>
|
|
|
+#include <linux/of_device.h>
|
|
|
+#include <linux/platform_device.h>
|
|
@@ -78,7 +159,6 @@ Signed-off-by: Álvaro Fernández Rojas <[email protected]>
|
|
|
+struct bcm63268_tclk_table_entry {
|
|
|
+ const char * const name;
|
|
|
+ u8 bit;
|
|
|
-+ unsigned long flags;
|
|
|
+};
|
|
|
+
|
|
|
+static const struct bcm63268_tclk_table_entry bcm63268_timer_clocks[] = {
|
|
@@ -197,17 +277,14 @@ Signed-off-by: Álvaro Fernández Rojas <[email protected]>
|
|
|
+static int bcm63268_tclk_probe(struct platform_device *pdev)
|
|
|
+{
|
|
|
+ struct device *dev = &pdev->dev;
|
|
|
-+ const struct bcm63268_tclk_table_entry *entry, *table;
|
|
|
++ const struct bcm63268_tclk_table_entry *entry;
|
|
|
+ struct bcm63268_tclkrst_hw *hw;
|
|
|
++ struct clk_hw *clk;
|
|
|
+ u8 maxbit = 0;
|
|
|
+ int i, ret;
|
|
|
+
|
|
|
-+ table = of_device_get_match_data(dev);
|
|
|
-+ if (!table)
|
|
|
-+ return -EINVAL;
|
|
|
-+
|
|
|
-+ for (entry = table; entry->name; entry++)
|
|
|
-+ maxbit = max_t(u8, maxbit, entry->bit);
|
|
|
++ for (entry = bcm63268_timer_clocks; entry->name; entry++)
|
|
|
++ maxbit = max(maxbit, entry->bit);
|
|
|
+ maxbit++;
|
|
|
+
|
|
|
+ hw = devm_kzalloc(&pdev->dev, struct_size(hw, data.hws, maxbit),
|
|
@@ -227,24 +304,21 @@ Signed-off-by: Álvaro Fernández Rojas <[email protected]>
|
|
|
+ if (IS_ERR(hw->regs))
|
|
|
+ return PTR_ERR(hw->regs);
|
|
|
+
|
|
|
-+ for (entry = table; entry->name; entry++) {
|
|
|
-+ struct clk_hw *clk;
|
|
|
-+
|
|
|
-+ clk = clk_hw_register_gate(dev, entry->name, NULL,
|
|
|
-+ entry->flags, hw->regs, entry->bit,
|
|
|
-+ CLK_GATE_BIG_ENDIAN, &hw->lock);
|
|
|
-+ if (IS_ERR(clk)) {
|
|
|
-+ ret = PTR_ERR(clk);
|
|
|
-+ goto out_err;
|
|
|
-+ }
|
|
|
++ for (entry = bcm63268_timer_clocks; entry->name; entry++) {
|
|
|
++ clk = devm_clk_hw_register_gate(dev, entry->name, NULL, 0,
|
|
|
++ hw->regs, entry->bit,
|
|
|
++ CLK_GATE_BIG_ENDIAN,
|
|
|
++ &hw->lock);
|
|
|
++ if (IS_ERR(clk))
|
|
|
++ return PTR_ERR(clk);
|
|
|
+
|
|
|
+ hw->data.hws[entry->bit] = clk;
|
|
|
+ }
|
|
|
+
|
|
|
-+ ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
|
|
|
-+ &hw->data);
|
|
|
-+ if (!ret)
|
|
|
-+ return 0;
|
|
|
++ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
|
|
|
++ &hw->data);
|
|
|
++ if (ret)
|
|
|
++ return ret;
|
|
|
+
|
|
|
+ hw->rcdev.of_node = dev->of_node;
|
|
|
+ hw->rcdev.ops = &bcm63268_timer_reset_ops;
|
|
@@ -253,22 +327,12 @@ Signed-off-by: Álvaro Fernández Rojas <[email protected]>
|
|
|
+ if (ret)
|
|
|
+ dev_err(dev, "Failed to register reset controller\n");
|
|
|
+
|
|
|
-+out_err:
|
|
|
-+ for (i = 0; i < hw->data.num; i++) {
|
|
|
-+ if (!IS_ERR(hw->data.hws[i]))
|
|
|
-+ clk_hw_unregister_gate(hw->data.hws[i]);
|
|
|
-+ }
|
|
|
-+
|
|
|
-+ return ret;
|
|
|
++ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static const struct of_device_id bcm63268_tclk_dt_ids[] = {
|
|
|
-+ {
|
|
|
-+ .compatible = "brcm,bcm63268-timer-clocks",
|
|
|
-+ .data = &bcm63268_timer_clocks,
|
|
|
-+ }, {
|
|
|
-+ /* sentinel */
|
|
|
-+ }
|
|
|
++ { .compatible = "brcm,bcm63268-timer-clocks" },
|
|
|
++ { /* sentinel */ }
|
|
|
+};
|
|
|
+
|
|
|
+static struct platform_driver bcm63268_tclk = {
|