From patchwork Sun Nov 6 15:46:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 16153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1556620wru; Sun, 6 Nov 2022 07:50:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4L1rDfjDHnduuZJbxaWXLkBecd+ehlln44TM7nmQr7F0jisjOC8GrsBm5NxvqJA489i5vr X-Received: by 2002:a17:903:442:b0:188:69e3:23e0 with SMTP id iw2-20020a170903044200b0018869e323e0mr11866752plb.100.1667749830066; Sun, 06 Nov 2022 07:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667749830; cv=none; d=google.com; s=arc-20160816; b=BKzrhnnvfI27zkTxXqkbVQSCjYIHXQOWevBMYnfePhjwpV4af81QLHdUf0/qSf49bL bgzafGGPiNL3iByQA4Y2TPqyi1WNIQurg6ClZoDNoiRiAmBeZauc7yY+yG3itCoPG+al CbWNSeJDeEr/5DSuoFeQnbMIDetbEZxZzlPXDa706PO0NvG6c/KtC4CVBM+1jUmdKb/5 KZav6rSnWMR1sB4gop/+L0I3souUpQnZZZbIO06JYGK5YncD1LzmAKFNLovjd5H4oXUm AKGa2YXqjQAA7qhZopR8KNZggFtqiE91NRmonHlVvBV3VzX6accMWaodB3Sb6o+LbuMb NGaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=IESrdIGOIZAm+SZQoTxRhJ5XsZQ5NE5GBRmcNiJagyU=; b=bnjv60+IayiLx5y48FW3rbBxY5JXsEI3PAo19X5mb4kNjKp+qzpy/BHMB0Zw+hDxrN EdJ6vzNnxs7/9mZAbfF8lWHPe1RvInL7leYjEQSXf/MXt91kxjtbPo7b5C96gp0GmNcN YZJx5mz4iqlrUV881Gg6kYe7t0D7T53yaQLOH1BZdRxZFkqEVec0yykM4pOC2jA2jRPu x3nSyuhiLxEzqeDa1TgxqCCDjtJsFLmEM5O/UeJ3Ge9irXh8MN6oXyJrS9M/JNdVTqMt rxqAvtu3CpcSg7x21BWRp+q2Q5xaefnQbhGKU2xSmwPbjZxVbQnpC/TA0wZm01u8cwpH IDOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F2cbbEOv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a170902744400b0017eae5cc961si6351926plt.306.2022.11.06.07.50.11; Sun, 06 Nov 2022 07:50:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F2cbbEOv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbiKFPqU (ORCPT + 99 others); Sun, 6 Nov 2022 10:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbiKFPqT (ORCPT ); Sun, 6 Nov 2022 10:46:19 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF96DD2F1 for ; Sun, 6 Nov 2022 07:46:17 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id b2so24375613eja.6 for ; Sun, 06 Nov 2022 07:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IESrdIGOIZAm+SZQoTxRhJ5XsZQ5NE5GBRmcNiJagyU=; b=F2cbbEOvg/pHLRp+l7YZGXVwAhe6m49SvHaqxvpPII2/ZU/hnCFzeTyOcT4rjzfRjC 5Sufm6GvLr1SU6ugGLBIobRlxXsGPdKq5Fo/7HTy3oThl7o0HsUnCy7zv19liqqVz/LQ tt9CiBfEZIVR/6fuKdwAXIIj3lK2g8XuAqIYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IESrdIGOIZAm+SZQoTxRhJ5XsZQ5NE5GBRmcNiJagyU=; b=P/BO10KE5K8wPAnNTthJUvL4/z5boebfXcmBmXfqFRpzwkVGubbVu6rEA2VLZvj58k snWz4YzOHogGDiCC8nNKXu4T37Ixy2SgW/ygbhuXZgxlnYmYCYIsdMcspfi/3z6FQD4/ 9L7vS+5pTgiXscETxcX5nLp1Uxf8+vWhi63c7QgFWAu0UsRAD+4qMc7J/4x6M9f2ubRS Mk7FvrDxXgBb8VCcYCnJdZOIpNISa4CWZs5sArR7bZk2jX+rGSKch+2iILLXZXDcAPUP f701MT9BAmf6fpuEnIkOVaAz85OiRVjXJOnyagC+/l52otkiNfXEEAO5YaQpscTt7Ekf KHKg== X-Gm-Message-State: ACrzQf1lY2c0xeU+QGEvmbhf8lHOFtstp8iKy539HwcGJ/A8wQto1jB8 ioBh04Bo6AQKvnpyxhO4hzT66aucMSPvig== X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr8027170ejn.598.1667749576127; Sun, 06 Nov 2022 07:46:16 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-76-31.retail.telecomitalia.it. [95.232.76.31]) by smtp.gmail.com with ESMTPSA id kz20-20020a17090777d400b00772061034dbsm2204139ejc.182.2022.11.06.07.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Nov 2022 07:46:15 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , Dario Binacchi , Allison Randal , Greg Kroah-Hartman , Liang He , Michael Turquette , Stephen Boyd , Tero Kristo , Thomas Gleixner , Tony Lindgren , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v3 1/2] clk: ti: add of_ti_clk_register() helper Date: Sun, 6 Nov 2022 16:46:11 +0100 Message-Id: <20221106154612.3474940-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748762445883270709?= X-GMAIL-MSGID: =?utf-8?q?1748762445883270709?= The ti_clk_register() function is always called with the parameter of type struct device set to NULL, since the functions from which it is called always have a parameter of type struct device_node. Adding this helper will allow you to register a TI clock to the common clock framework by taking advantage of the facilities provided by the struct device_node type. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/clk/ti/clk.c | 30 ++++++++++++++++++++++++++++++ drivers/clk/ti/clock.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 1dc2f15fb75b..e29b5c7c0dc8 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -560,6 +560,36 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con) return 0; } +/** + * of_ti_clk_register - register a TI clock to the common clock framework + * @node: device node for the clock + * @hw: hardware clock handle + * @con: connection ID for this clock + * + * Registers a TI clock to the common clock framework, and adds a clock + * alias for it. Returns a handle to the registered clock if successful, + * ERR_PTR value in failure. + */ +struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, + const char *con) +{ + struct clk *clk; + int ret; + + ret = of_clk_hw_register(node, hw); + if (ret) + return ERR_PTR(ret); + + clk = hw->clk; + ret = ti_clk_add_alias(NULL, clk, con); + if (ret) { + clk_unregister(clk); + return ERR_PTR(ret); + } + + return clk; +} + /** * ti_clk_register - register a TI clock to the common clock framework * @dev: device for this clock diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h index 37ab53339a9b..a75fcf775de0 100644 --- a/drivers/clk/ti/clock.h +++ b/drivers/clk/ti/clock.h @@ -199,6 +199,8 @@ extern const struct omap_clkctrl_data dm816_clkctrl_data[]; typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *); +struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, + const char *con); struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw, const char *con); struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,