Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7328179ybl; Tue, 24 Dec 2019 00:06:31 -0800 (PST) X-Google-Smtp-Source: APXvYqxMf3FwbR+vlTUUyQ7DgkaLGIbq/KAcYZSeraZxyh99aQV33F5zflXYNwpT4bzqEmqjnYhm X-Received: by 2002:a9d:6502:: with SMTP id i2mr8617721otl.206.1577174791652; Tue, 24 Dec 2019 00:06:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577174791; cv=none; d=google.com; s=arc-20160816; b=HfdRSNFUcxZyRf2znL158DkgdA16E0HBb8u8yvTUd88DM9Ac9PessDA7wckrju7rqD 6uHLnc8zeHaMuIe/POclx85ha7ysTvJWPWHC6EanwtBq6aLSIADfMoZK+8j+5P+3cVMP cCn5wxkcYpPm8u1NV6fldJJun6o/0A7s53QUg7UGcQ071vLFBrRgR+l2Q+N+H8dYoev9 vkJCBqWwCeRx2WUzJbcJTbaRXYQRbCJqJ3y5W2JEv1f7r+7w48ZJKyVu4gPS8IvRy8lZ ryTQj5xF+irfzvsl6KpKcOEmPUuNaBkwR318S6mcITvZtYANrqJ9LC9UlxgSThmYrXQY s46w== 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 :from:cc:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=3tQrZHw+39Coj/3V5DtY7UEx3+XyQMi/qNIDtLxvle4=; b=ABrnezoc+Z93njNvHhhQBo8ik9+LFz0Lx08+zuVdDdC8R10eVscR+nOQgxPiYXYk7u Cbo48vWa18sZ8aL1l3CqwmvdKp1r243DK8O4FgpC466AeO9lOHW3v/I1mH/i71QLCtGw TmjWxSN0uMc/Z8HTmazXEoURWerDKJKIBwebYwbZLB8VZZibjWUcp5+vPQJ4vC0M3S+C SO0srdm8qGqdFq4mD5ntBCvbtUY7LburMzVa6WeMxjlL4bDBgCsPnsC4l/jh6WnHhipX Tq1Tqh0pNnpuF/40NItXUgwRr0DleXgwj6G+XpJHhUoOV8KsoZggYRJM9lP+xhU3nEZ7 ndhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pPvzsbBb; 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 k7si10161575otp.22.2019.12.24.00.06.20; Tue, 24 Dec 2019 00:06:31 -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=pPvzsbBb; 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 S1726225AbfLXIFi (ORCPT + 99 others); Tue, 24 Dec 2019 03:05:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:53504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbfLXIFi (ORCPT ); Tue, 24 Dec 2019 03:05:38 -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 B0C99206CB; Tue, 24 Dec 2019 08:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577174736; bh=q+4fNfvxwFfvm6ehxq3tf+yjKjbLqy3OGlMpvibfKhE=; h=In-Reply-To:References:Cc:From:To:Subject:Date:From; b=pPvzsbBbP6MR6SnA/5X0FeGfkVY4CZ8izcoN8yDgHPCIZ8eCCPaoRCSPYhysvW6Pj rrnvi6eQuNIpLyKF8r6SaTuPP8sI5VJLaO6ycV27jLxP02Mqmnj+kZY5u3hC+fxZAY DaslL24dbHa06DyBXjvuKwkCPMl+7xcxIV0LkOVo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20191209233305.18619-2-michael@walle.cc> References: <20191209233305.18619-1-michael@walle.cc> <20191209233305.18619-2-michael@walle.cc> Cc: Michael Turquette , Rob Herring , Mark Rutland , Michael Walle From: Stephen Boyd To: Michael Walle , devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] clk: fsl-sai: new driver User-Agent: alot/0.8.1 Date: Tue, 24 Dec 2019 00:05:35 -0800 Message-Id: <20191224080536.B0C99206CB@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 (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); 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? > + > + 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 */ Should this configuration come from DT somehow? > + writel(CR2_BCD, base + I2S_CR2); > + > + hw =3D clk_hw_register_composite(NULL, clk_name, &parent_name, 1, > + NULL, NULL, > + &sai_clk->div.hw, &clk_divider_ops, > + &sai_clk->gate.hw, &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", fsl_sai_clk_setup); Is there a reason this can't be a platform device driver?