Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17189632ybl; Thu, 2 Jan 2020 00:10:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxdrQVFlQev+jlrkBHdlG2649jkj+TjkBDpg1x8bhbmYTmrt+UDTZ2aLqo0YlajTwpXoujj X-Received: by 2002:a05:6830:1bf2:: with SMTP id k18mr88423533otb.36.1577952623159; Thu, 02 Jan 2020 00:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577952623; cv=none; d=google.com; s=arc-20160816; b=jhqe/nqdkA3yLOW1g5Z1t3LRHaaWBhO6rbZGYachN2v2L9b0yywakjwkjL62BIMrjS LCYnvDsy1GCjpHMPIU/XDcuIO+9lHcfAuYINdLRZQfhjGI10lI0dF8C0EFHl9K7dsRhK iMehW2+7CDxFsgFKwLZcsrvbU/uCz56XVzSgVYa4aGVnVpPJat2ztV2WunLipJ/AVCre sT4m/lx7y3k1w/FGln4q+82diZbxCyB3rHzOHrQmWy6isZLYOI3qOX9HXKp3keU/9F81 fkwXBHykWqYrh5livOXBIJ5YTTYVRPEZdmlVxTx5/0whfR7gBIlutcOpMt2JDnx4UQi0 Noiw== 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:to:cc :from:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=b0JKUZmsfqEFk/MzDg9u0/8rTGgPXIPymNFpJN4N4Ns=; b=j4hYSjpvDLq5d3zCm7FEuz78ziWHf8h8g+7XQn6Q7IVH4qDcj6kRsJQdmE+7sK4HR8 cbeIXzYH4MrpIwyCFFaVYjM61m9+jRHsDsDebapzl9dmHYyV/GiKothLRzLjCIGrqifV Kem1RO+dfWuLNceVhJmsUFM1CY7qbo/1DPH8hhOVKMGznn+9ks1d7tM7kSi969wQI9G0 BEbIX5tN3E34mIY5HbS/8Q1LJJ+aEdBg47s7UlFKyD844pLG4oSo0XvC5z2344hkyXmP MmZ4NexSO4dphh1EFMN30ee9t/2gEVqfepuv4XTPeD0iM3wOgFiLmUX8nEtUN4NnaR4N CH1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nsBAoR7h; 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 n11si27391596otq.112.2020.01.02.00.10.11; Thu, 02 Jan 2020 00:10:23 -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=nsBAoR7h; 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 S1727812AbgABIJa (ORCPT + 99 others); Thu, 2 Jan 2020 03:09:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:33880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727714AbgABIJa (ORCPT ); Thu, 2 Jan 2020 03:09:30 -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 0EE2C215A4; Thu, 2 Jan 2020 08:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577952569; bh=yKk4Yxcs8PbwJF1fYpOt/+cGZY0MXBz9tOWOoJQKoDM=; h=In-Reply-To:References:From:Cc:To:Subject:Date:From; b=nsBAoR7hGS+zpj6oHxmL46hoZd5ZxIZJWuwShLiZjfIcQS+x0LObrojJVAd5yJiDp TYsrrNT0w2qKObbn4of2dK+/TgxmvbHdKPQB048voAuK474SI8iv/oInhXAZ37oU4z vUGgygKBlgwWUIosCB8XanFDY9Q9kpGan8ALu/nI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <91275d33d6a7c9978a2c70545fde38cd@walle.cc> References: <20191209233305.18619-1-michael@walle.cc> <20191209233305.18619-2-michael@walle.cc> <20191224080536.B0C99206CB@mail.kernel.org> <91275d33d6a7c9978a2c70545fde38cd@walle.cc> From: Stephen Boyd Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Turquette , Rob Herring , Mark Rutland To: Michael Walle Subject: Re: [PATCH v2 2/2] clk: fsl-sai: new driver User-Agent: alot/0.8.1 Date: Thu, 02 Jan 2020 00:09:28 -0800 Message-Id: <20200102080929.0EE2C215A4@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Michael Walle (2020-01-01 07:15:32) >=20 > Hi Stephen, >=20 > thanks for the review. >=20 > Am 2019-12-24 09:05, schrieb Stephen Boyd: > > Quoting Michael Walle (2019-12-09 15:33:05) > >> diff --git a/drivers/clk/clk-fsl-sai.c b/drivers/clk/clk-fsl-sai.c > >> new file mode 100644 > >> index 000000000000..b92054d15ab1 > >> --- /dev/null > >> +++ b/drivers/clk/clk-fsl-sai.c > >> @@ -0,0 +1,84 @@ > >> +// SPDX-License-Identifier: GPL-2.0 > >> +/* > >> + * Freescale SAI BCLK as a generic clock driver > >> + * > >> + * Copyright 2019 Kontron Europe GmbH > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> +#include > >> +#include > >> + > >> +#define I2S_CSR 0x00 > >> +#define I2S_CR2 0x08 > >> +#define CSR_BCE_BIT 28 > >> +#define CR2_BCD BIT(24) > >> +#define CR2_DIV_SHIFT 0 > >> +#define CR2_DIV_WIDTH 8 > >> + > >> +struct fsl_sai_clk { > >> + struct clk_divider div; > >> + struct clk_gate gate; > >> + spinlock_t lock; > >> +}; > >> + > >> +static void __init fsl_sai_clk_setup(struct device_node *node) > >> +{ > >> + const char *clk_name =3D node->name; > >> + struct fsl_sai_clk *sai_clk; > >> + unsigned int num_parents; > >> + const char *parent_name; > >> + void __iomem *base; > >> + struct clk_hw *hw; > >> + > >> + num_parents =3D of_clk_get_parent_count(node); > >> + if (!num_parents) { > >> + pr_err("%s: no parent found", clk_name); > >> + return; > >> + } > >> + > >> + parent_name =3D of_clk_get_parent_name(node, 0); > >=20 > > Could this use the new way of specifying clk parents so that we don't > > have to query DT for parent names and just let the core framework do it > > whenever it needs to? >=20 > you mean specifying parent_data with .index =3D 0? Seems like=20 > clk_composite > does not support this. The parent can only be specified by supplying the > clock names. >=20 > I could add that in a separate patch. What do you think about the > following new functions, where a driver can use parent_data instead > of parent_names. I started doing this in https://lkml.kernel.org/r/20190830150923.259497-1-sboyd@kernel.org but I never got around to the composite clks. Sounds fine to add this new API for your use case. >=20 > +struct clk *clk_register_composite_pdata(struct device *dev, const char = > *name, > + const struct clk_parent_data *parent_data, > + struct clk_hw *mux_hw, const struct clk_ops *mux_ops, > + struct clk_hw *rate_hw, const struct clk_ops *rate_ops, > + struct clk_hw *gate_hw, const struct clk_ops *gate_ops, > + unsigned long flags); >=20 > +struct clk_hw *clk_hw_register_composite_pdata(struct device *dev, > + const char *name, const struct clk_parent_data=20 > *parent_data, > + struct clk_hw *mux_hw, const struct clk_ops *mux_ops, > + struct clk_hw *rate_hw, const struct clk_ops *rate_ops, > + struct clk_hw *gate_hw, const struct clk_ops *gate_ops, > + unsigned long flags); >=20 >=20 > >> + > >> + sai_clk =3D kzalloc(sizeof(*sai_clk), GFP_KERNEL); > >> + if (!sai_clk) > >> + return; > >> + > >> + base =3D of_iomap(node, 0); > >> + if (base =3D=3D NULL) { > >> + pr_err("%s: failed to map register space", clk_name); > >> + goto err; > >> + } > >> + > >> + spin_lock_init(&sai_clk->lock); > >> + > >> + sai_clk->gate.reg =3D base + I2S_CSR; > >> + sai_clk->gate.bit_idx =3D CSR_BCE_BIT; > >> + sai_clk->gate.lock =3D &sai_clk->lock; > >> + > >> + sai_clk->div.reg =3D base + I2S_CR2; > >> + sai_clk->div.shift =3D CR2_DIV_SHIFT; > >> + sai_clk->div.width =3D CR2_DIV_WIDTH; > >> + sai_clk->div.lock =3D &sai_clk->lock; > >> + > >> + /* set clock direction, we are the BCLK master */ > >=20 > > Should this configuration come from DT somehow? >=20 > No, we are always master, because as a slave, there would be no clock > output ;) Got it. >=20 > >> + writel(CR2_BCD, base + I2S_CR2); > >> + > >> + hw =3D clk_hw_register_composite(NULL, clk_name, &parent_name,= =20 > >> 1, > >> + NULL, NULL, > >> + &sai_clk->div.hw,=20 > >> &clk_divider_ops, > >> + &sai_clk->gate.hw,=20 > >> &clk_gate_ops, > >> + CLK_SET_RATE_GATE); > >> + if (IS_ERR(hw)) > >> + goto err; > >> + > >> + of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw); > >> + > >> + return; > >> + > >> +err: > >> + kfree(sai_clk); > >> +} > >> + > >> +CLK_OF_DECLARE(fsl_sai_clk, "fsl,vf610-sai-clock",=20 > >> fsl_sai_clk_setup); > >=20 > > Is there a reason this can't be a platform device driver? >=20 > I don't think so, the user will be a sound codec for now. I'll convert=20 > it > to a platform device, in that case I could also use the devm_ variants. >=20 Awesome. Thanks!