Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3118855ybx; Fri, 8 Nov 2019 14:20:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzoiNi2nYI8Kp/7yTivSxlOQ+CNplL0ZcZAPmCicP0doEFG57xZ7Osaaq0sBCtbyxHuzUEk X-Received: by 2002:a17:906:3e90:: with SMTP id a16mr9705507ejj.265.1573251627831; Fri, 08 Nov 2019 14:20:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573251627; cv=none; d=google.com; s=arc-20160816; b=yK5+WXZTqvIBc/+Qa+WLWUNfgVA9NH+0g8/97wd7UHFhU1Qv2f5KmVDR0ZeZ4hl8qi 7pyu8td/DsPHjEevAUVUGFlLufC/iZYV3N1Ua0RRtIXw/YWlASOQmXObRGBSFXS4lCGN LiC7tT3Y3LRJ6MrpzwUk7XUg4LBK3xNwyymcDYqp4UXdvyM0olMZ0xIoXCouLIkU0dpj m2R+u/UogrbYyBf46atFXnhBYLuPPwnXmZXhBti6TJJ2+Ovbg4xoS8eOKPW/dN15jjTY rSm0gKGC9xAWNSeVGcZ45e4gGt9dDZfvNNwhzCyTJJqK/HxB72mHkWhs6KK8o6w9Qe1v K9xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:user-agent:subject:cc:to :from:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=kkOYs6oKB2LcVDVNGWouBE83l8sD/hNrRiYhZjYn/mQ=; b=WMr3i6Zly/eu6Udanv0LjPTuYujEnbc9teI7rA7VK4E6xZtlIkRVBv8HHWcaSCRhZm Ty18CrF8723+QAqvvL5JUqq/EA9NKx3jSUld9nodUFtxiEHjtjGXGAB3DHp49fFKjsaV 8Wn7WydZClJYxFse9rn1HI5dpvhxrqNXl2oqyRZAn+j1dNXd+m7+ht29YMdEeISzH70u qSDXvLkMAcrl6jDMd89pHqeDykjIin4L/lB1rgz5LTfFzq2S+Itu9KBGPrs6PJ+OpixG B2KftTLFiSqikCMf9vkfxgbLDUU7bJ7vKzrwTagJULukYBeZElhVWo5BYi4ElG3oa0cm 6w/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CWhydIuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si5445871edh.14.2019.11.08.14.20.04; Fri, 08 Nov 2019 14:20:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CWhydIuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729986AbfKHWQy (ORCPT + 99 others); Fri, 8 Nov 2019 17:16:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:43960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726095AbfKHWQx (ORCPT ); Fri, 8 Nov 2019 17:16:53 -0500 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32FA2206C3; Fri, 8 Nov 2019 22:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573251412; bh=UMLMfzeZ5d6ns0l8n8EZL9EegR7c0Zs1zYDFdZD51UQ=; h=In-Reply-To:References:From:To:Cc:Subject:Date:From; b=CWhydIuLpiNkRC2e2o3hgvdyMWzOcF0tY4qbw/aO1IXhXo1X0X9QXzcckycwtajKz /K0jAR0/qbv8xYv8WsdeCIZV9+K8NwKZpEkndOJNA+TMu18fskDIvUHmE/shKvEnKO F1we+BDGjB7rjbvwOTHi9wTzB5ervodLflH6VfuE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20191027162328.1177402-3-martin.blumenstingl@googlemail.com> References: <20191027162328.1177402-1-martin.blumenstingl@googlemail.com> <20191027162328.1177402-3-martin.blumenstingl@googlemail.com> From: Stephen Boyd To: Martin Blumenstingl , jbrunet@baylibre.com, khilman@baylibre.com, linux-amlogic@lists.infradead.org, narmstrong@baylibre.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Martin Blumenstingl Subject: Re: [PATCH v2 2/5] clk: meson: add a driver for the Meson8/8b/8m2 DDR clock controller User-Agent: alot/0.8.1 Date: Fri, 08 Nov 2019 14:16:51 -0800 Message-Id: <20191108221652.32FA2206C3@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Martin Blumenstingl (2019-10-27 09:23:25) > diff --git a/drivers/clk/meson/meson8-ddr.c b/drivers/clk/meson/meson8-dd= r.c > new file mode 100644 > index 000000000000..4aefcc5bdaae > --- /dev/null > +++ b/drivers/clk/meson/meson8-ddr.c > @@ -0,0 +1,152 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Amlogic Meson8 DDR clock controller > + * > + * Copyright (C) 2019 Martin Blumenstingl > + */ > + > +#include > + > +#include > +#include > +#include Please include clk-provider.h as this is a clk provider driver. > + > +#include "clk-regmap.h" > +#include "clk-pll.h" > + > +#define AM_DDR_PLL_CNTL 0x00 > +#define AM_DDR_PLL_CNTL1 0x04 > +#define AM_DDR_PLL_CNTL2 0x08 > +#define AM_DDR_PLL_CNTL3 0x0c > +#define AM_DDR_PLL_CNTL4 0x10 > +#define AM_DDR_PLL_STS 0x14 > +#define DDR_CLK_CNTL 0x18 > +#define DDR_CLK_STS 0x1c > + > +static struct clk_regmap meson8_ddr_pll_dco =3D { > + .data =3D &(struct meson_clk_pll_data){ > + .en =3D { > + .reg_off =3D AM_DDR_PLL_CNTL, > + .shift =3D 30, > + .width =3D 1, > + }, > + .m =3D { > + .reg_off =3D AM_DDR_PLL_CNTL, > + .shift =3D 0, > + .width =3D 9, > + }, > + .n =3D { > + .reg_off =3D AM_DDR_PLL_CNTL, > + .shift =3D 9, > + .width =3D 5, > + }, > + .l =3D { > + .reg_off =3D AM_DDR_PLL_CNTL, > + .shift =3D 31, > + .width =3D 1, > + }, > + .rst =3D { > + .reg_off =3D AM_DDR_PLL_CNTL, > + .shift =3D 29, > + .width =3D 1, > + }, > + }, > + .hw.init =3D &(struct clk_init_data){ > + .name =3D "ddr_pll_dco", > + .ops =3D &meson_clk_pll_ro_ops, > + .parent_data =3D &(const struct clk_parent_data) { > + .fw_name =3D "xtal", > + }, > + .num_parents =3D 1, > + }, > +}; > + > +static struct clk_regmap meson8_ddr_pll =3D { > + .data =3D &(struct clk_regmap_div_data){ > + .offset =3D AM_DDR_PLL_CNTL, > + .shift =3D 16, > + .width =3D 2, > + .flags =3D CLK_DIVIDER_POWER_OF_TWO, > + }, > + .hw.init =3D &(struct clk_init_data){ > + .name =3D "ddr_pll", > + .ops =3D &clk_regmap_divider_ro_ops, > + .parent_hws =3D (const struct clk_hw *[]) { > + &meson8_ddr_pll_dco.hw > + }, > + .num_parents =3D 1, > + }, > +}; > + > +static struct clk_hw_onecell_data meson8_ddr_clk_hw_onecell_data =3D { > + .hws =3D { > + [DDR_CLKID_DDR_PLL_DCO] =3D &meson8_ddr_pll_dco.h= w, > + [DDR_CLKID_DDR_PLL] =3D &meson8_ddr_pll.hw, > + }, > + .num =3D 2, > +}; > + > +static struct clk_regmap *const meson8_ddr_clk_regmaps[] =3D { > + &meson8_ddr_pll_dco, > + &meson8_ddr_pll, > +}; > + > +static const struct regmap_config meson8_ddr_clkc_regmap_config =3D { > + .reg_bits =3D 8, > + .val_bits =3D 32, > + .reg_stride =3D 4, > + .max_register =3D DDR_CLK_STS, > +}; > + > +static int meson8_ddr_clkc_probe(struct platform_device *pdev) > +{ > + struct regmap *regmap; > + struct resource *res; > + void __iomem *base; > + struct clk_hw *hw; > + int ret, i; > + > + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); > + base =3D devm_ioremap_resource(&pdev->dev, res); We have a new function to combine the above two lines. Please use it so the janitors avoid this file. > + if (IS_ERR(base)) > + return PTR_ERR(base); > + > + regmap =3D devm_regmap_init_mmio(&pdev->dev, base, > + &meson8_ddr_clkc_regmap_config); > + if (IS_ERR(regmap)) > + return PTR_ERR(regmap); > + > + /* Populate regmap */ > + for (i =3D 0; i < ARRAY_SIZE(meson8_ddr_clk_regmaps); i++) > + meson8_ddr_clk_regmaps[i]->map =3D regmap; > + > + /* Register all clks */ > + for (i =3D 0; i < meson8_ddr_clk_hw_onecell_data.num; i++) { > + hw =3D meson8_ddr_clk_hw_onecell_data.hws[i]; > + > + ret =3D devm_clk_hw_register(&pdev->dev, hw); > + if (ret) { > + dev_err(&pdev->dev, "Clock registration failed\n"= ); > + return ret; > + } > + } > + > + return devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_= get, > + &meson8_ddr_clk_hw_onecell_dat= a); > +} > + > +static const struct of_device_id meson8_ddr_clkc_match_table[] =3D { > + { .compatible =3D "amlogic,meson8-ddr-clkc" }, > + { .compatible =3D "amlogic,meson8b-ddr-clkc" }, > + { /* sentinel */ }, Super nitpick, drop the comma above so that nothing can follow this. > +}; > + > +static struct platform_driver meson8_ddr_clkc_driver =3D { > + .probe =3D meson8_ddr_clkc_probe, > + .driver =3D { > + .name =3D "meson8-ddr-clkc", > + .of_match_table =3D meson8_ddr_clkc_match_table, > + }, > +}; > + > +builtin_platform_driver(meson8_ddr_clkc_driver); > --=20 > 2.23.0 >=20