From patchwork Mon Feb 13 11:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aradhya Bhatia X-Patchwork-Id: 56224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2301509wrn; Mon, 13 Feb 2023 04:01:01 -0800 (PST) X-Google-Smtp-Source: AK7set+x0ggYbvHTByXduDx3p1gb6EJBf/qjOORaBHOJK1et0IrDpk1kFj8FUs0pV/7ZriS2UuSS X-Received: by 2002:a17:90b:4c88:b0:234:dd7:c27a with SMTP id my8-20020a17090b4c8800b002340dd7c27amr1703581pjb.17.1676289661041; Mon, 13 Feb 2023 04:01:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676289661; cv=none; d=google.com; s=arc-20160816; b=FDO+qMcYzpy9L2Fvgdr8+2aG8Z+u61YuAfOmDDQs0I+MS+XohNu1S4KRJCVn9Rt5fb z8VfNKKSIm8RTfmgZ/fcxUcF+w5EMz09R8GylyHbl3R5py3uBLZVXK2IyY+fKe/l548i jV4mp81TBILECZFSUEzex+PCFeVGobdyMHiXoYba9H4veYUWnwUPXoLojlI4uVQYmlr4 bCTJgnwNR3DeOzzQuhGG/mXrMA7d7noWwb+pU9jp8WD/855s5bMspvHA18urAgyLtCQV QDTlt/n72iBDk84N0VDPZ96TWFf8biYT1GQY3AVzqdSBXNmuS1IWp+hhiU6Im3AZGaM+ lQww== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ck7HKCzkxTJ+xWcXSAQH2Jrn57umtVcCN89jVyNIzq8=; b=zMmr5Ukd1ttKoKPSjv9wAfQ2/lOaxe8mRdDpiJxqU5xlRDmbeiF2z5D26SoEa8MqQy 40m95SO/q8ktK1mFtCXx1/2ppT/NrvFORdiMwv5Q+w6X4IFniAzogusBTlo4+zrAM8C2 l4HMZerUpSPqUUe2RxTGQYS5BU50GFhNYGGqCCqMmvOOiW3Ra/6Ncya9rzHvJp0cwTO/ c1OUsnLyRlNpq9RvUxDNvaIu47bblqTSaJ9rFG3SXGWV8Oh/Q19zFOIF9oqI/c202wDq OYx/powV9zsi1rpjNBPgfOQihOwgxO41JDuJq76xSBXa22KvSKuAMtbiRpOFLrcW4ao4 M5tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YTelJ6ZK; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v16-20020a637a10000000b004fb9579eefcsi4471802pgc.766.2023.02.13.04.00.46; Mon, 13 Feb 2023 04:01:01 -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=@ti.com header.s=ti-com-17Q1 header.b=YTelJ6ZK; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbjBMMAR (ORCPT + 99 others); Mon, 13 Feb 2023 07:00:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbjBMMAH (ORCPT ); Mon, 13 Feb 2023 07:00:07 -0500 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DE518AAF; Mon, 13 Feb 2023 04:00:04 -0800 (PST) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 31DBxvaI124227; Mon, 13 Feb 2023 05:59:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1676289597; bh=Ck7HKCzkxTJ+xWcXSAQH2Jrn57umtVcCN89jVyNIzq8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YTelJ6ZKU/cXiS/K+T7de6q/YzYda5uoPSoJ1FVAejwCZ2n2r7cDDAuk0b+GwWhOp RCCfSPRYj6NDOnERpAI7woUbivBJ1HcOUnvtYAVAth3sSPG5nhA2AUavVb6whrYuhB PJ0As/3we64iAdHFJEO4yuMr2sq6TgVMX3gCkc6Y= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 31DBxv4T126096 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Feb 2023 05:59:57 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 13 Feb 2023 05:59:56 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 13 Feb 2023 05:59:56 -0600 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 31DBxtJp056756; Mon, 13 Feb 2023 05:59:56 -0600 From: Aradhya Bhatia To: Michael Turquette , Stephen Boyd , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski CC: Tomi Valkeinen , Samuel Holland , Linux Clock List , Devicetree List , Linux Kernel List , Nishanth Menon , Vignesh Raghavendra , Devarsh Thakkar , Jai Luthra , Aradhya Bhatia Subject: [PATCH v2 1/2] dt-bindings: clock: Add binding documentation for TI AM62 DSS Clock Date: Mon, 13 Feb 2023 17:29:53 +0530 Message-ID: <20230213115954.553-2-a-bhatia1@ti.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213115954.553-1-a-bhatia1@ti.com> References: <20230213115954.553-1-a-bhatia1@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1757717107534029641?= X-GMAIL-MSGID: =?utf-8?q?1757717107534029641?= Add DT bindings for DSS clock divider of TI's AM62 family of SoCs. Signed-off-by: Aradhya Bhatia --- .../clock/ti,am62-dss-vp0-div-clk.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/ti,am62-dss-vp0-div-clk.yaml diff --git a/Documentation/devicetree/bindings/clock/ti,am62-dss-vp0-div-clk.yaml b/Documentation/devicetree/bindings/clock/ti,am62-dss-vp0-div-clk.yaml new file mode 100644 index 000000000000..310d2a989d5b --- /dev/null +++ b/Documentation/devicetree/bindings/clock/ti,am62-dss-vp0-div-clk.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/ti,am62-dss-vp0-div-clk.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI AM62 DSS - OLDI Divider Clock + +maintainers: + - Aradhya Bhatia + +properties: + compatible: + items: + - const: ti,am62-dss-vp0-div-clk + + "#clock-cells": + const: 0 + + clocks: + maxItems: 1 + + clock-div: + description: Fixed divider + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 1 + +required: + - compatible + - clocks + - "#clock-cells" + - clock-div + +additionalProperties: false + +examples: + - | + clock { + compatible = "ti,am62-dss-vp0-div-clk"; + clocks = <&parent_clock>; + #clock-cells = <0>; + clock-div = <7>; + }; +... From patchwork Mon Feb 13 11:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aradhya Bhatia X-Patchwork-Id: 56225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2301618wrn; Mon, 13 Feb 2023 04:01:10 -0800 (PST) X-Google-Smtp-Source: AK7set/C9Iz4I5xxZvSTJPS6uWGKbLWmgSC5MTV4vouN9ddtOLALUAdors6jDuVhh6LZvgquz2Zu X-Received: by 2002:a05:6a20:394e:b0:bc:5fc6:6894 with SMTP id r14-20020a056a20394e00b000bc5fc66894mr30170630pzg.53.1676289669874; Mon, 13 Feb 2023 04:01:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676289669; cv=none; d=google.com; s=arc-20160816; b=TKOlxqIAnZEv+nZE8jkZJrHDq+Pu35W2wSw58LuEKREY8akkEdsRO9A44yQ385MMt3 y6o5xDdB4SS7frsj9pDZ3zBWQBuV0rMjffstOU/2ISAyGoYEL6mStopIM/8HyWZCAAVs t0eZjobveLMV/NViLpSnonj304Pbo+2przUCMChagjOBOxvlSdhAHQJ8Qo/pbZLmXO55 3oMJUjV5hg/fXjFjaBKXwdPzH8hIO6Byzchmuj2JjMDhfTTOF80GmMySfflZt97FL6cP XKC0bI5o3sL1hHcWYtfOqHtIIwZucZteR0EVyuL2kYPG4xNMrVAGh1m/oCLf7PIms6I7 UKGw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+HZAOdrDmkXz7cerDG2MTsBjz2lXq2xdUsMnIIjLfRM=; b=PXF2YVdwzl45N8TBtZ6Ewd47nunazFJ0pBd8DlAq9u+m8QsgbbWN+i1qZkcJU1I83P tsUmjFiq0WZtlduK6YUdyPNtKKVo1Ip6h5YqmBvYDLczoBQQ4DERp+kTcoT24ufbsJ4/ MADOow1NuXkN+niVUaXg4Hz11rkdu0/5RztfkZrD5WK0uPObM5N9bTLzgTtpWU/7oS28 8qaYgX9oGUNdP3HPxJFTBPpprrec6CEoGNpwi67Yvlv1MwaHGlGpojOW68JhvmsjNzY+ 8k46xfwdA+8SBaBsYZbpjJnTtO/TQdA02jjwV+VyYvIrS8E3DwRSNg6MEZzLtb9fqavl BE8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=iVKcruqy; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j66-20020a625545000000b00590569bc56esi11403322pfb.298.2023.02.13.04.00.57; Mon, 13 Feb 2023 04:01:09 -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=@ti.com header.s=ti-com-17Q1 header.b=iVKcruqy; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbjBMMAV (ORCPT + 99 others); Mon, 13 Feb 2023 07:00:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjBMMAI (ORCPT ); Mon, 13 Feb 2023 07:00:08 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB76118AA6; Mon, 13 Feb 2023 04:00:04 -0800 (PST) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 31DBxwCZ124580; Mon, 13 Feb 2023 05:59:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1676289598; bh=+HZAOdrDmkXz7cerDG2MTsBjz2lXq2xdUsMnIIjLfRM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=iVKcruqycmOrnZvhKu+jV8pRCGdy2cZMfN5SS85bBP0a6vffik3KFKFzRXLjX2rno VhOV07vIp327qSkQwC63dRxSkzDCpmY8yKlYNqrHpQcs9Iee+qB0IyI0MJ9pRSmEZp dIiibafHJ9RM0A+R/r5DZLBLI5ZdYYSk51MVDn7Q= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 31DBxwQa021365 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Feb 2023 05:59:58 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 13 Feb 2023 05:59:58 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 13 Feb 2023 05:59:58 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 31DBxvfa056766; Mon, 13 Feb 2023 05:59:57 -0600 From: Aradhya Bhatia To: Michael Turquette , Stephen Boyd , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski CC: Tomi Valkeinen , Samuel Holland , Linux Clock List , Devicetree List , Linux Kernel List , Nishanth Menon , Vignesh Raghavendra , Devarsh Thakkar , Jai Luthra , Aradhya Bhatia Subject: [PATCH v2 2/2] clk: keystone: Add support AM62 DSS clock divider Date: Mon, 13 Feb 2023 17:29:54 +0530 Message-ID: <20230213115954.553-3-a-bhatia1@ti.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213115954.553-1-a-bhatia1@ti.com> References: <20230213115954.553-1-a-bhatia1@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1757717116650113043?= X-GMAIL-MSGID: =?utf-8?q?1757717116650113043?= On TI's AM62 Family of SoCs, the pixel frequency of the DSS Video Port 0 comes from a by-7 clock divider. This is done to support the clock for OLDI transmitters that need serial clock 7 times the pixel frequency. A clock set request on this clock, is forwarded to its parent clock by default, using the SET_RATE_PARENT flag. The PLL (in this case the parent) generates serial clock for OLDI, which is then also fed to DSS using this clock divider. Signed-off-by: Aradhya Bhatia --- drivers/clk/keystone/Kconfig | 9 ++ drivers/clk/keystone/Makefile | 1 + drivers/clk/keystone/clk-am62-dss.c | 164 ++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 drivers/clk/keystone/clk-am62-dss.c diff --git a/drivers/clk/keystone/Kconfig b/drivers/clk/keystone/Kconfig index e64d6726048f..543314ddfd2c 100644 --- a/drivers/clk/keystone/Kconfig +++ b/drivers/clk/keystone/Kconfig @@ -34,3 +34,12 @@ config TI_SYSCON_CLK help This adds clock driver support for syscon based gate clocks on TI's K2 and K3 SoCs. + +config TI_AM62_DSS_CLK + tristate "Clock Divider for DSS VP0 of AM62 Family of SoCs" + depends on ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST + default TI_SCI_CLK + help + This adds clock divider driver support for Video Port 0 of Display + SubSystems (DSS) under AM62 Family of SoCs. This clock divider + forwards a seventh (1/7) of the incoming clock. diff --git a/drivers/clk/keystone/Makefile b/drivers/clk/keystone/Makefile index 0e426e648f7c..3a683d622a60 100644 --- a/drivers/clk/keystone/Makefile +++ b/drivers/clk/keystone/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_COMMON_CLK_KEYSTONE) += pll.o gate.o obj-$(CONFIG_TI_SCI_CLK) += sci-clk.o obj-$(CONFIG_TI_SYSCON_CLK) += syscon-clk.o +obj-$(CONFIG_TI_AM62_DSS_CLK) += clk-am62-dss.o diff --git a/drivers/clk/keystone/clk-am62-dss.c b/drivers/clk/keystone/clk-am62-dss.c new file mode 100644 index 000000000000..2c9fc4bc89e3 --- /dev/null +++ b/drivers/clk/keystone/clk-am62-dss.c @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/ + */ +#include +#include +#include + +struct ti_am62_dss_clk { + struct clk_hw hw; + unsigned int div; +}; + +#define to_ti_am62_dss_clk(_hw) \ + container_of(_hw, struct ti_am62_dss_clk, hw) + +static unsigned long ti_am62_dss_clk_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct ti_am62_dss_clk *priv = to_ti_am62_dss_clk(hw); + unsigned long rate; + + rate = parent_rate; + do_div(rate, priv->div); + return (unsigned long)rate; +} + +static long ti_am62_dss_clk_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *prate) +{ + struct ti_am62_dss_clk *priv = to_ti_am62_dss_clk(hw); + + if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { + unsigned long best_parent; + + best_parent = rate * priv->div; + *prate = clk_hw_round_rate(clk_hw_get_parent(hw), best_parent); + } + + return (*prate / priv->div); +} + +static int ti_am62_dss_clk_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + /* + * We must report success but we can do so unconditionally because + * ti_am62_dss_clk_round_rate returns values that ensure this call is a + * nop. + */ + + return 0; +} + +static const struct clk_ops ti_am62_dss_clk_ops = { + .round_rate = ti_am62_dss_clk_round_rate, + .set_rate = ti_am62_dss_clk_set_rate, + .recalc_rate = ti_am62_dss_clk_recalc_rate, +}; + +static struct clk_hw * +clk_hw_register_am62_dss_clk(struct device *dev, const char *name, + unsigned long flags, unsigned int div) +{ + struct ti_am62_dss_clk *priv; + struct clk_init_data init = { }; + struct clk_parent_data pdata = { .index = 0 }; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return ERR_PTR(-ENOMEM); + + /* struct ti_am62_dss_clk assignments */ + priv->div = div; + priv->hw.init = &init; + + init.name = name; + init.ops = &ti_am62_dss_clk_ops; + init.flags = flags; + init.parent_names = NULL; + init.parent_data = &pdata; + init.num_parents = 1; + + ret = devm_clk_hw_register(dev, &priv->hw); + if (ret) + return ERR_PTR(ret); + + return &priv->hw; +} + +static void clk_hw_unregister_am62_dss_clk(struct clk_hw *hw) +{ + struct ti_am62_dss_clk *priv; + + priv = to_ti_am62_dss_clk(hw); + + clk_hw_unregister(hw); + kfree(priv); +} + +static int ti_am62_dss_clk_remove(struct platform_device *pdev) +{ + struct clk_hw *hw = platform_get_drvdata(pdev); + + of_clk_del_provider(pdev->dev.of_node); + clk_hw_unregister_am62_dss_clk(hw); + + return 0; +} + +static int ti_am62_dss_clk_probe(struct platform_device *pdev) +{ + struct clk_hw *hw; + const char *clk_name = pdev->name; + struct device *dev = &pdev->dev; + unsigned long flags = 0; + u32 div; + int ret; + + if (of_property_read_u32(dev->of_node, "clock-div", &div)) { + dev_err(dev, "%s: TI AM62 DSS clock must have a clock-div property.\n", + __func__); + return -EIO; + } + + flags |= CLK_SET_RATE_PARENT; + + hw = clk_hw_register_am62_dss_clk(dev, clk_name, flags, div); + if (IS_ERR(hw)) { + dev_err(dev, "%s: failed to register %s\n", __func__, clk_name); + return PTR_ERR(hw); + } + + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); + if (ret) { + clk_hw_unregister_am62_dss_clk(hw); + return ret; + } + + platform_set_drvdata(pdev, hw); + + return 0; +} + +static const struct of_device_id ti_am62_dss_clk_ids[] = { + { .compatible = "ti,am62-dss-vp0-div-clk" }, + { } +}; +MODULE_DEVICE_TABLE(of, ti_am62_dss_clk_ids); + +static struct platform_driver ti_am62_dss_clk_driver = { + .driver = { + .name = "ti_am62_dss_clk", + .of_match_table = ti_am62_dss_clk_ids, + }, + .probe = ti_am62_dss_clk_probe, + .remove = ti_am62_dss_clk_remove, +}; +module_platform_driver(ti_am62_dss_clk_driver); + +MODULE_AUTHOR("Aradhya Bhatia "); +MODULE_DESCRIPTION("TI AM62 DSS - OLDI Fixed Clock Divider driver"); +MODULE_LICENSE("GPL");