Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7265613imu; Wed, 14 Nov 2018 14:30:45 -0800 (PST) X-Google-Smtp-Source: AJdET5d9eCcJoahqt6/SE7ZqpH2GfOnzTmJGFI0MzKBIZ5GDoCBmJu6bKMIV+LgFdGxyT3WYDnhY X-Received: by 2002:a63:b34f:: with SMTP id x15mr3492561pgt.243.1542234645933; Wed, 14 Nov 2018 14:30:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542234645; cv=none; d=google.com; s=arc-20160816; b=I13RPU8qvdKl+JvUQbCdrbn/58yMsDwaTKecqEru5zh5fa2mGl1x9kAFFfsus37RuY S61AMlgUajWbgC4ezMOcYmTo6ADTNdK5FG3CPitZpU+j2yI2e3dciIjeQcKV9ibdCsB6 50wna4r7fOxP9j/DaRi06bSCCzGGT3Nb2OVPAjeSXVxwFJkEZSBuoB1qz1GiDwZoSO9J iAuGehVJIt4u3T3R+isYNiUisnTd2Hm2DTSrpjt0SNXXqvrPEbDM934dh94EWRHSQMTJ oAmDROQkmxUiwZl+9HR6XLVbjh0oz2w0YRBXjsmT033QEc4TB1oiQObJPdaz4+PTisKB u95g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature; bh=kJ78GpwS+eCFzeZTkyuFE7gKeRxE65omVcYqplWMDtE=; b=QfXPKJH2FSsFBOs9q32+dcvVSvIvEs2dwozzb6FukZw/Tdscd9ip4JcxVZRMdcgH0t E7buGY1YGi/X4FxMPG9zqxc+mFOc+rv5maIWvSV9nJieEtca3MEDRHFqxIFk76CkcqdR J8Gpbh1jtwyXDu9PUenbiHm0WkOrE7COHtzB6oHfjLcfiIme6OdtaqsdWRhMUqoJPaW9 R1FVRw5kOFg0yJncql/xTqofDYqY2mTtMLSyffiMef/QdP1gybV7+sILnTPwlmAYEr12 7JlPLOlQR0GEYgkapigkscN03290i3NroD93AbT43yWC/oYnSjze67jScCLCfNBxjLzL CZLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mKqxHBDy; 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 a6si5381907plz.316.2018.11.14.14.30.31; Wed, 14 Nov 2018 14:30:45 -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=mKqxHBDy; 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 S2389375AbeKOIdl (ORCPT + 99 others); Thu, 15 Nov 2018 03:33:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:39372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388801AbeKOIcj (ORCPT ); Thu, 15 Nov 2018 03:32:39 -0500 Received: from localhost (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 1C25920825; Wed, 14 Nov 2018 22:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542233950; bh=e+1g8ysiEmeAd46GphoqR4QLHNGpE9RlDgMbIMi8VXw=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=mKqxHBDyvEODUVWVNH/2H4qAYms0jlvhyFFauW3dtwTdzy+99NQRK0Zr3puRUob4y 8tEJmCo/LXOApiT8XCjqAL0w3PXTJN7iypzxxLG2i2uUqNUfCY0V/0c6TOcdQq7RJv sT2dgajTDb6lQk+UgMbPbE4h0qWPbLAbASOJlbfA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: "mark.rutland@arm.com" , "mturquette@baylibre.com" , "robh+dt@kernel.org" , Janek Kotas From: Stephen Boyd In-Reply-To: Cc: "linux-clk@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: Message-ID: <154223394933.88331.14659021245427374668@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH 2/2] clk: Add Fixed MMIO clock driver Date: Wed, 14 Nov 2018 14:19:09 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Janek Kotas (2018-11-14 07:24:39) > This patch adds a driver for Fixed MMIO clock. > The driver reads a clock frequency value from a single 32-bit memory > mapped register and registers it as a fixed rate clock. > = > It can be enabled with COMMON_CLK_FIXED_MMIO Kconfig option. > = > Signed-off-by: Jan Kotas Sounds like a fine idea. Except I can see how it will be abused if there are a handful of these fixed rate "clks" somewhere in memory that all get populated. = Do you really have a fixed rate clk in hardware that exposes a single register, or do you have a set of them that some firmware is populating into an I/O memory space that we can read the fixed rates from? If it's the latter, I wonder why we can't just have the firmware populate the fixed rate clks into DT itself? > diff --git a/drivers/clk/clk-fixed-mmio.c b/drivers/clk/clk-fixed-mmio.c > new file mode 100644 > index 0000000000..bbcadab345 > --- /dev/null > +++ b/drivers/clk/clk-fixed-mmio.c > @@ -0,0 +1,49 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +/* > + * Memory Mapped IO Fixed Clock driver > + * > + * Copyright (C) 2018 Cadence Design Systems, Inc. > + * > + * Authors: > + * Jan Kotas > + */ > + > +#include Is this include used? > +#include > +#include > +#include Is this include used? > + > +static void __init of_fixed_mmio_clk_setup(struct device_node *node) > +{ > + struct clk *clk; > + const char *clk_name =3D node->name; > + void __iomem *base; > + u32 clk_freq; > + > + base =3D of_iomap(node, 0); > + if (!base) { > + pr_err("%pOFn: failed to map address\n", node); > + return; > + } > + > + clk_freq =3D readl(base); > + iounmap(base); > + of_property_read_string(node, "clock-output-names", &clk_name); > + > + clk =3D clk_register_fixed_rate(NULL, clk_name, NULL, 0, clk_freq= ); > + if (IS_ERR(clk)) { > + pr_err("%pOFn: failed to register fixed rate clock\n", no= de); > + return; > + } > + > + if (of_clk_add_provider(node, of_clk_src_simple_get, clk)) { > + pr_err("%pOFn: failed to add clock provider\n", node); > + return; > + } > + > + pr_info("%pOFn: registered fixed-mmio-clock at %u Hz\n", > + node, clk_freq); Please no "I'm alive!" messages. > +} > + > +CLK_OF_DECLARE(fixed_mmio_clk, "fixed-mmio-clock", of_fixed_mmio_clk_set= up); Any reason why this can't be a platform driver? It would make this much less DT specific and usable on other firmwares/platforms if we used a platform driver here.