From patchwork Mon Dec 21 15:17:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 7896511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 450169F349 for ; Mon, 21 Dec 2015 15:19:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6008520524 for ; Mon, 21 Dec 2015 15:19:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77A5F20502 for ; Mon, 21 Dec 2015 15:19:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aB2DM-00079F-Hm; Mon, 21 Dec 2015 15:17:32 +0000 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163] helo=cgate.sperl.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aB2DH-00075R-S9; Mon, 21 Dec 2015 15:17:30 +0000 Received: from msmac.intern.sperl.org (account martin@sperl.org [10.10.10.11] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6390360; Mon, 21 Dec 2015 15:17:03 +0000 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: [PATCH 4/4] ARM: bcm2835: Switch to using the new clock driver support. From: Martin Sperl In-Reply-To: <5677F3C8.5000600@lategoodbye.de> Date: Mon, 21 Dec 2015 16:17:02 +0100 Message-Id: <03BE10FE-D743-4CD3-8825-112D0F6B2D43@martin.sperl.org> References: <1441562263-19888-1-git-send-email-eric@anholt.net> <1441562263-19888-5-git-send-email-eric@anholt.net> <5677E7BF.3020404@martin.sperl.org> <5677F3C8.5000600@lategoodbye.de> To: Stefan Wahren , Eric Anholt X-Mailer: Apple Mail (2.2104) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151221_071728_466077_60AD22D3 X-CRM114-Status: GOOD ( 14.71 ) X-Spam-Score: -0.9 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree , Mike Turquette , Stephen Boyd , linux-rpi-kernel , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > On 21.12.2015, at 13:42, Stefan Wahren wrote: > > Hi Martin, > >> here the corresponding section for i2s in /arch/arm/boot/dts/bcm2835.dtsi: >> i2s: i2s@7e203000 { >> compatible = "brcm,bcm2835-i2s"; >> reg = <0x7e203000 0x20>, >> <0x7e101098 0x02>; >> >> dmas = <&dma 2>, >> <&dma 3>; >> dma-names = "tx", "rx"; >> status = "disabled"; >> }; > > unfortunately i don't have a i2s interface, but thanks for the remark. I received one just today... > > It looks like the i2s driver programm the clock by itself instead of using the clock framework. So the second register entry should be removed from the i2s node. I started looking and found that drivers/clk/bcm/clk-bcm2835.c does not include the PWM clock either. Anyway - looking at: sound/soc/bcm/bcm2835-i2s.c it seems that right now this driver makes use of a different parent-clock depending of the requested clock I guess Eric needs to look into this portion to put it into the generic clock_codeā€¦ It is way more complicated than just using a fixed clock... >> >> Note that actually the PCM/I2S reg-range should be (off by 4): >> reg = <0x7e203000 0x24>; >> (see also: https://github.com/raspberrypi/linux/pull/1079) > > Any chance that Robert (patch author) can send a proper patch to linux-rpi-kernel for the of by 4 issue? as we need to remove the second register-set anyway we need to make modifications in the same location anyway. Looks probably something like this for the device-tree: And obviously many more changes to sound/soc/bcm/bcm2835-i2s.c to remove the clock code and use the clock framework instead. The biggest thing is the selection of the clock to use - the current code either uses the OSC or PLLD. @Eric: ist there some means to do that? Thanks, Martin diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi index aef64de..288d678 100644 --- a/arch/arm/boot/dts/bcm2835.dtsi +++ b/arch/arm/boot/dts/bcm2835.dtsi @@ -120,8 +120,9 @@ i2s: i2s@7e203000 { compatible = "brcm,bcm2835-i2s"; - reg = <0x7e203000 0x20>, - <0x7e101098 0x02>; + reg = <0x7e203000 0x24>; + clocks = <&clocks BCM2835_CLOCK_PWM>, + <&clocks BCM2835_CLOCK_VPU>; dmas = <&dma 2>, <&dma 3>; diff --git a/include/dt-bindings/clock/bcm2835.h b/include/dt-bindings/clock/bcm index d323efa..61f1d20 100644 --- a/include/dt-bindings/clock/bcm2835.h +++ b/include/dt-bindings/clock/bcm2835.h @@ -43,5 +43,6 @@ #define BCM2835_CLOCK_TSENS 27 #define BCM2835_CLOCK_EMMC 28 #define BCM2835_CLOCK_PERI_IMAGE 29 +#define BCM2835_CLOCK_PWM 30 -#define BCM2835_CLOCK_COUNT 30 +#define BCM2835_CLOCK_COUNT 31 And obviously more changes to the clock driver itself to support it: --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -807,6 +807,17 @@ static const struct bcm2835_clock_data bcm2835_clock_emmc_d .frac_bits = 8, }; +/* PWM/I2S clock */ +static const struct bcm2835_clock_data bcm2835_clock_pwm_data = { + .name = "pwm", + .num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents), + .parents = bcm2835_clock_per_parents, + .ctl_reg = CM_PWMCTL, + .div_reg = CM_PWMDIV, + .int_bits = 4, + .frac_bits = 8, +}; + struct bcm2835_pll { struct clk_hw hw; struct bcm2835_cprman *cprman; @@ -1537,6 +1548,8 @@ static int bcm2835_clk_probe(struct platform_device *pdev) bcm2835_register_clock(cprman, &bcm2835_clock_hsm_data); clks[BCM2835_CLOCK_EMMC] = bcm2835_register_clock(cprman, &bcm2835_clock_emmc_data); + clks[BCM2835_CLOCK_PWM] = + bcm2835_register_clock(cprman, &bcm2835_clock_pwm_data); /* * CM_PERIICTL (and CM_PERIACTL, CM_SYSCTL and CM_VPUCTL if