From patchwork Tue Apr 30 11:16:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Belisko Marek X-Patchwork-Id: 2504141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 04775DF2F2 for ; Tue, 30 Apr 2013 11:17:36 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UX8Yu-0005En-Dq; Tue, 30 Apr 2013 11:17:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UX8Yr-0007PD-SZ; Tue, 30 Apr 2013 11:17:29 +0000 Received: from mail-bk0-x236.google.com ([2a00:1450:4008:c01::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UX8Yo-0007OR-Oo for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2013 11:17:27 +0000 Received: by mail-bk0-f54.google.com with SMTP id q11so172027bkw.41 for ; Tue, 30 Apr 2013 04:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=cpI1pOZpfxOdDcVf6oH2i+t6JR0/ANl3IJZ1LG1FDhA=; b=gf/3vkBCoWafO818t98oU9iwkBeN1QAzu0KYMi8XFkUrPTa4VYEFJqVbhm9CNE8j+l 1YzQfRWov4ty47op2W7UW9hc+SkGJmfEQN8eJA0l0eW0HknxauQ09VcmAl+N5SjRCWnp 1/asfWK9fPq7nv+3zuaklHGX84jKJFO7JeeeMHa+4v7fVTigWzeAPU3ehu1Fs8aymUVc BZsSklD11ZTbwIOTUQm5r5Us9eeqn6bONX21sNSx42COzTIyowARyf9Nt6tObMLveEXp H/bdY6o1MK+Y4CHUp878K3g8vCqnDZFk55YVqWAyPjS1wucPAc8NfkfrdqjgVgafwX1D 4CaA== X-Received: by 10.204.170.202 with SMTP id e10mr22272962bkz.73.1367320624091; Tue, 30 Apr 2013 04:17:04 -0700 (PDT) Received: from localhost.localdomain (81.89.61.168.vnet.sk. [81.89.61.168]) by mx.google.com with ESMTPSA id cv9sm7991834bkb.5.2013.04.30.04.17.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 04:17:03 -0700 (PDT) From: Marek Belisko To: mturquette@linaro.org Subject: [PATCH] clk: si5351: Allow user to define disabled state for every clock output. Date: Tue, 30 Apr 2013 13:16:47 +0200 Message-Id: <1367320607-25657-1-git-send-email-marek.belisko@streamunlimited.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130430_071726_953667_76EAD0DB X-CRM114-Status: GOOD ( 13.20 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (marek.belisko[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, rob.herring@calxeda.com, grant.likely@secretlab.ca, linux-arm-kernel@lists.infradead.org, rob@landley.net, Marek Belisko , daniel@zonque.org, sebastian.hesselbarth@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add platform data and dt bindings to allow user override disabled state. Signed-off-by: Marek Belisko --- .../devicetree/bindings/clock/silabs,si5351.txt | 5 +++ drivers/clk/clk-si5351.c | 36 +++++++++++++++++--- include/linux/platform_data/si5351.h | 16 +++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/clock/silabs,si5351.txt b/Documentation/devicetree/bindings/clock/silabs,si5351.txt index cc37465..2f24c12 100644 --- a/Documentation/devicetree/bindings/clock/silabs,si5351.txt +++ b/Documentation/devicetree/bindings/clock/silabs,si5351.txt @@ -44,6 +44,11 @@ Optional child node properties: - silabs,multisynth-source: source pll A(0) or B(1) of corresponding multisynth divider. - silabs,pll-master: boolean, multisynth can change pll frequency. +- silabs,disable-state : clock disable state (default 0) shall be + 0 = CLKx is set to a LOW state when disabled + 1 = CLKx is set to a HIGH state when disabled + 2 = CLKx is set to a HIGH IMPEDANCE state when disabled + 3 = CLKx is NEVER DISABLED ==Example== diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c index 8323c31..bfe92b8 100644 --- a/drivers/clk/clk-si5351.c +++ b/drivers/clk/clk-si5351.c @@ -1230,6 +1230,21 @@ static int si5351_dt_parse(struct i2c_client *client) pdata->clkout[num].pll_master = of_property_read_bool(child, "silabs,pll-master"); + + if (!of_property_read_u32(child, "silabs,disable-state", + &val)) { + switch (val) { + case SI5351_DISABLE_LOW: + case SI5351_DISABLE_HIGH: + case SI5351_DISABLE_HIGH_IMPEDANCE: + case SI5351_NEVER_DISABLED: + pdata->clkout[num].disable_state = val; + break; + default: + pdata->clkout[num].disable_state = 0; + } + } + } client->dev.platform_data = pdata; @@ -1250,7 +1265,7 @@ static int si5351_i2c_probe(struct i2c_client *client, struct clk_init_data init; struct clk *clk; const char *parent_names[4]; - u8 num_parents, num_clocks; + u8 num_parents, num_clocks, disabled; int ret, n; ret = si5351_dt_parse(client); @@ -1281,9 +1296,22 @@ static int si5351_i2c_probe(struct i2c_client *client, /* Disable interrupts */ si5351_reg_write(drvdata, SI5351_INTERRUPT_MASK, 0xf0); - /* Set disabled output drivers to drive low */ - si5351_reg_write(drvdata, SI5351_CLK3_0_DISABLE_STATE, 0x00); - si5351_reg_write(drvdata, SI5351_CLK7_4_DISABLE_STATE, 0x00); + + /* Set disabled output states */ + disabled = (pdata->clkout[0].disable_state & 0x03) | + ((pdata->clkout[1].disable_state << 2) & 0x0C) | + ((pdata->clkout[2].disable_state << 4) & 0x30) | + ((pdata->clkout[3].disable_state << 6) & 0xC0); + + si5351_reg_write(drvdata, SI5351_CLK3_0_DISABLE_STATE, disabled); + + disabled = (pdata->clkout[4].disable_state & 0x03) | + ((pdata->clkout[5].disable_state << 2) & 0x0C) | + ((pdata->clkout[6].disable_state << 4) & 0x30) | + ((pdata->clkout[7].disable_state << 6) & 0xC0); + + si5351_reg_write(drvdata, SI5351_CLK7_4_DISABLE_STATE, disabled); + /* Ensure pll select is on XTAL for Si5351A/B */ if (drvdata->variant != SI5351_VARIANT_C) si5351_set_bits(drvdata, SI5351_PLL_INPUT_SOURCE, diff --git a/include/linux/platform_data/si5351.h b/include/linux/platform_data/si5351.h index 92dabca..6702991 100644 --- a/include/linux/platform_data/si5351.h +++ b/include/linux/platform_data/si5351.h @@ -79,6 +79,21 @@ enum si5351_drive_strength { }; /** + * enum si5351_disable_state - Si5351 clock output disable state + * @SI5351_DISABLE_LOW: CLKx is set to a LOW state when disabled + * @SI5351_DISABLE_HIGH: CLKx is set to a HIGH state when disabled + * @SI5351_DISABLE_HIGH_IMPEDANCE: CLKx is set to a HIGH IMPEDANCE state + * when disabled + * @SI5351_NEVER_DISABLED: CLKx is NEVER DISABLED + */ +enum si5351_disable_state { + SI5351_DISABLE_LOW = 0, + SI5351_DISABLE_HIGH, + SI5351_DISABLE_HIGH_IMPEDANCE, + SI5351_NEVER_DISABLED, +}; + +/** * struct si5351_clkout_config - Si5351 clock output configuration * @clkout: clkout number * @multisynth_src: multisynth source clock @@ -93,6 +108,7 @@ struct si5351_clkout_config { enum si5351_drive_strength drive; bool pll_master; unsigned long rate; + enum si5351_disable_state disable_state; }; /**