Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D620EC433EF for ; Fri, 22 Apr 2022 00:11:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE75B83D7A; Fri, 22 Apr 2022 02:11:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YYhZKwiK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23F6A83DB6; Fri, 22 Apr 2022 02:11:01 +0200 (CEST) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5311E83D7A for ; Fri, 22 Apr 2022 02:10:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x72f.google.com with SMTP id b189so4772389qkf.11 for ; Thu, 21 Apr 2022 17:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=RcFW1BpCi7DOkVPVU8WZNSL2+V2u7I1vvF5JeGSMv9w=; b=YYhZKwiK5X96kZnkY0gMRbXtemb4YL6c1Vjh3GXDA+nsi1trXnD4YBEwyweSPjgEsA kKJwiCIaaIax27qimbZlVVwwnlDdBPblV5CAB1OGAJiiKca6HtAefvWQ2G/9ncLAwGTo XRlLI5bc4Kx93UmToDBjhLGTg5QUAwVJ78xI93tEvthPD7GzvtlN6qv0Fqe3uOSCUDuU RjYdSHBIKkwTDWG3sc8BfxR60A6hnHf/mqjahO6JW5F0Z5aejMxIIkZnNPLmG15s0AB4 c3qYoDKhdHhFaM5Qai9v6tnVGa6hiVkeJqGe7zw2rG8YjP7ds5A62KZq/fOGHeFvDvJi 0+Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=RcFW1BpCi7DOkVPVU8WZNSL2+V2u7I1vvF5JeGSMv9w=; b=nadaHvE3vD8DStpn1KNDe7cvXa1lePuWvg1hvtyM1BXBuf64spOKfQjMy1kkM+WhLY +tEpKcTVFCuvA9MKiNw/o5kmvjZolMFCvklcPkw9QB9X/d+QLdjUod/XwXK3erVgstN7 IXQxpji088pnGOefYKSwVI3k7IlKKRMZ2FLxUQHTFVTofNwEF8dhXqtX0MLa8VOLqpz9 Pp3gIcAdmXFv/xkEs80Tk4VGhFjQT++j4ASHrmAzaigzl1UuudsYqhYOMu78BUPsm6NN Ikuaz6+vpxff99R1ekLG/HjrMrHoincMJyMFvKxwu8ddObTGKV1iw25jLcek0zyJPQ5e Rr8Q== X-Gm-Message-State: AOAM530i3PxdrHeaBPguVeWXoI+hR9nVuTTTA+PGGU/iZBy/zZLidKiq ZONu3sYjZ0GpxH+yzgNySKawegc8eLQ= X-Google-Smtp-Source: ABdhPJyGaeKqmCdtPgEfpY0ARgUFiYXhKzafAOLS6QLb+cB7mksYi/ceYKGPAc/QY+nu7Z1YhwyOqA== X-Received: by 2002:a05:620a:4489:b0:69e:d399:9ca7 with SMTP id x9-20020a05620a448900b0069ed3999ca7mr1187177qkp.47.1650586256224; Thu, 21 Apr 2022 17:10:56 -0700 (PDT) Received: from [192.168.1.201] (pool-108-18-137-133.washdc.fios.verizon.net. [108.18.137.133]) by smtp.googlemail.com with ESMTPSA id 22-20020ac85756000000b002e1cabad999sm333673qtx.89.2022.04.21.17.10.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Apr 2022 17:10:55 -0700 (PDT) Subject: Re: [PATCH 1/5] clk: meson: add minimal driver for axg-ao clocks To: Vyacheslav , Neil Armstrong , Lukasz Majewski , u-boot@lists.denx.de, u-boot-amlogic@groups.io References: <20220420175502.2449249-1-adeep@lexina.in> <20220420175502.2449249-2-adeep@lexina.in> <2cfa21b7-5ace-422e-f0ad-8b5c322a65b6@gmail.com> From: Sean Anderson Message-ID: Date: Thu, 21 Apr 2022 20:10:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 4/21/22 1:57 AM, Vyacheslav wrote: > 20.04.2022 23:12, Sean Anderson =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> On 4/20/22 1:54 PM, Vyacheslav Bocharov wrote: >>> Add minimal driver AO clocks on meson AXG family. Only ADC related cl= ocks >>> are supported. >>> >>> Signed-off-by: Vyacheslav Bocharov >>> --- >>> =C2=A0 drivers/clk/meson/Makefile |=C2=A0 1 + >>> =C2=A0 drivers/clk/meson/axg-ao.c | 83 ++++++++++++++++++++++++++++++= ++++++++ >>> =C2=A0 2 files changed, 84 insertions(+) >>> =C2=A0 create mode 100644 drivers/clk/meson/axg-ao.c >>> >>> diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile >>> index b9c6bd66cf..a486b13e9c 100644 >>> --- a/drivers/clk/meson/Makefile >>> +++ b/drivers/clk/meson/Makefile >>> @@ -5,5 +5,6 @@ >>> =C2=A0 obj-$(CONFIG_CLK_MESON_GX) +=3D gxbb.o >>> =C2=A0 obj-$(CONFIG_CLK_MESON_AXG) +=3D axg.o >>> +obj-$(CONFIG_CLK_MESON_AXG) +=3D axg-ao.o >>> =C2=A0 obj-$(CONFIG_CLK_MESON_G12A) +=3D g12a.o >>> =C2=A0 obj-$(CONFIG_CLK_MESON_G12A) +=3D g12a-ao.o >>> diff --git a/drivers/clk/meson/axg-ao.c b/drivers/clk/meson/axg-ao.c >>> new file mode 100644 >>> index 0000000000..264ec6f0d3 >>> --- /dev/null >>> +++ b/drivers/clk/meson/axg-ao.c >>> @@ -0,0 +1,83 @@ >>> +// SPDX-License-Identifier: GPL-2.0+ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "clk_meson.h" >>> + >>> +struct meson_clk { >>> +=C2=A0=C2=A0=C2=A0 struct regmap *map; >>> +}; >>> + >>> +#define AO_CLK_GATE0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x40 >>> +#define AO_SAR_CLK=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x90 >>> + >>> +static struct meson_gate gates[] =3D { >>> +=C2=A0=C2=A0=C2=A0 MESON_GATE(CLKID_AO_SAR_ADC, AO_CLK_GATE0, 7), >>> +=C2=A0=C2=A0=C2=A0 MESON_GATE(CLKID_AO_SAR_ADC_CLK, AO_SAR_CLK, 7), >>> +}; >>> + >>> +static int meson_set_gate(struct clk *clk, bool on) >>> +{ >>> +=C2=A0=C2=A0=C2=A0 struct meson_clk *priv =3D dev_get_priv(clk->dev)= ; >>> +=C2=A0=C2=A0=C2=A0 struct meson_gate *gate; >>> + >>> +=C2=A0=C2=A0=C2=A0 if (clk->id >=3D ARRAY_SIZE(gates)) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -ENOENT; >> Do this check in request(). >=20 > Do you mean remove this check from meson_set_gate and add request funct= ion like this: >=20 > static int meson_clk_request(struct clk *clk) > { > =C2=A0=C2=A0=C2=A0=C2=A0struct npcm_clk_priv *priv =3D dev_get_priv(cl= k->dev); >=20 > =C2=A0=C2=A0=C2=A0=C2=A0if (clk->id >=3D ARRAY_SIZE(gates)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -ENOENT; >=20 > =C2=A0=C2=A0=C2=A0=C2=A0return 0; > } >=20 > static struct clk_ops meson_clk_ops =3D { > =C2=A0=C2=A0=C2=A0=C2=A0.disable=C2=A0=C2=A0=C2=A0 =3D meson_clk_disab= le, > =C2=A0=C2=A0=C2=A0=C2=A0.enable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 =3D meson_clk_enable, > =C2=A0=C2=A0=C2=A0=C2=A0.request=C2=A0=C2=A0=C2=A0 =3D meson_clk_reque= st, > }; Yes. --Sean >> >>> +=C2=A0=C2=A0=C2=A0 gate =3D &gates[clk->id]; >>> + >>> +=C2=A0=C2=A0=C2=A0 if (gate->reg =3D=3D 0) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; >>> + >>> +=C2=A0=C2=A0=C2=A0 regmap_update_bits(priv->map, gate->reg, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 BIT(gate->bit), on ? BIT(gate->bit) : 0); >>> + >>> +=C2=A0=C2=A0=C2=A0 return 0; >>> +} >>> + >>> +static int meson_clk_enable(struct clk *clk) >>> +{ >>> +=C2=A0=C2=A0=C2=A0 return meson_set_gate(clk, true); >>> +} >>> + >>> +static int meson_clk_disable(struct clk *clk) >>> +{ >>> +=C2=A0=C2=A0=C2=A0 return meson_set_gate(clk, false); >>> +} >>> + >>> +static int meson_clk_probe(struct udevice *dev) >>> +{ >>> +=C2=A0=C2=A0=C2=A0 struct meson_clk *priv =3D dev_get_priv(dev); >>> + >>> +=C2=A0=C2=A0=C2=A0 priv->map =3D syscon_node_to_regmap(dev_ofnode(de= v_get_parent(dev))); >>> +=C2=A0=C2=A0=C2=A0 if (IS_ERR(priv->map)) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return PTR_ERR(priv->map)= ; >>> + >>> +=C2=A0=C2=A0=C2=A0 return 0; >>> +} >>> + >>> +static struct clk_ops meson_clk_ops =3D { >>> +=C2=A0=C2=A0=C2=A0 .disable=C2=A0=C2=A0=C2=A0 =3D meson_clk_disable,= >>> +=C2=A0=C2=A0=C2=A0 .enable=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =3D meson_clk_enable, >>> +}; >>> + >>> +static const struct udevice_id meson_clk_ids[] =3D { >>> +=C2=A0=C2=A0=C2=A0 { .compatible =3D "amlogic,meson-axg-aoclkc" }, >>> +=C2=A0=C2=A0=C2=A0 { } >>> +}; >>> + >>> +U_BOOT_DRIVER(meson_clk_axg_ao) =3D { >>> +=C2=A0=C2=A0=C2=A0 .name=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D= "meson_clk_axg_ao", >>> +=C2=A0=C2=A0=C2=A0 .id=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D= UCLASS_CLK, >>> +=C2=A0=C2=A0=C2=A0 .of_match=C2=A0=C2=A0=C2=A0 =3D meson_clk_ids, >>> +=C2=A0=C2=A0=C2=A0 .priv_auto=C2=A0=C2=A0=C2=A0 =3D sizeof(struct me= son_clk), >>> +=C2=A0=C2=A0=C2=A0 .ops=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D= &meson_clk_ops, >>> +=C2=A0=C2=A0=C2=A0 .probe=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = =3D meson_clk_probe, >>> +}; >>> >> >> Otherwise LGTM >=20 > Thanks >=20 >> --Sean >=20