Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753424AbdDKAgZ (ORCPT ); Mon, 10 Apr 2017 20:36:25 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:6901 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753165AbdDKAgW (ORCPT ); Mon, 10 Apr 2017 20:36:22 -0400 X-IronPort-AV: E=Sophos;i="5.37,184,1488812400"; d="scan'208";a="240168758" Authentication-Results: baylibre.com; dkim=none (message not signed) header.d=none;baylibre.com; dmarc=none action=none header.from=renesas.com; Message-ID: <87d1cjyeb4.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Michael Turquette , Stephen Boyd CC: , , In-Reply-To: <87fuhfyedq.wl%kuninori.morimoto.gx@renesas.com> References: <87fuhfyedq.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Date: Tue, 11 Apr 2017 00:36:17 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0117.jpnprd01.prod.outlook.com (10.167.154.35) To TY1PR06MB0830.apcprd06.prod.outlook.com (10.163.245.24) X-MS-Office365-Filtering-Correlation-Id: 4f964e9f-967c-44ea-89e0-08d48072c488 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:TY1PR06MB0830; X-Microsoft-Exchange-Diagnostics: 1;TY1PR06MB0830;3:2JDD4ww51mocWAMYp56cWUuMSDBbausc2KqT0oXc/9HiFw5kZHvVf3iTfy4n9Pm+DwHoBEet88QnhJcjT0r/KueFrzB89Sb384EZbgAig9ss5vDFMouTDv3lKtgz+tbVdhTg2xY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ZVzLbHJqWWHFAaXZ6vTZsNHBsRmJY4Or07InqXk3dTKp400n76zUIZy19rDrGbRm/CF6LdzOIh856P2+XA2Lnyn1UsBtGY/cYRoycCrF57qQ1ON136Gnq3G2T/dJ62XeoG+gIYGrYtfDi7BKak8XlfIazRoUih+mh8HEIPerHkQ8KgotOoTv340cCa1sg9bSwbbj9zSkbCvN0ZGQNBl0t4Rd/zSyWbe2cadHgC1n11ubI9rX9UjP3t/5rfCl0d71h2oQUhxfxK7YunA5gSQC61NiNCDO1FR0rjX4+QCHvuxXUdEr7I7NSe3lqyj++9HQLBIXt8vwZRCHMfJjdrvIk7KfG5YPt61Rjn1hAsMLLf4xIsD+10Z98h7WZUU+0LHEbnrnA8Xb9oSIARQR5ZN+L6IRnJ1HvfMo7PHq2X1OIL8OwOQr9DMZeqQDCb6sjw/JIlTS960vVJ60LQy8WAB5EUfMV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123560025)(20161123562025)(6072148);SRVR:TY1PR06MB0830;BCL:0;PCL:0;RULEID:;SRVR:TY1PR06MB0830; X-Microsoft-Exchange-Diagnostics: 1;TY1PR06MB0830;4:/lXhKXOP3kKu44BlKt8dRwyad2QA0n6dZZq0TQB+wqQyUf98WAGV9i00N+X/CqRx/Er83D7JEDa/gLM8rl4Rv50yyJKlLCXp5ennLXF85voNm82cNz9L87gnPbSWNg0vqXI6aortxmlHhqSJsW+RFUBfapN9IAkJCGSS6imaZn6wppS0iya69NleKZuoPK+R4+1RF7X5WpsjlS8up73I83juzdiKyHDxCgsR7knORO6qYX8dLYk/IyVNUJvk4gEhMhvfmmlg0tjRWzfTZGcaAkOcYj2G5PKS2Y94Qv1rgxOt2JKlG8KyoUnIgAXBan0/HL5YxtpO1lWdE/JozMFuVLbaIAynhFQSM0Rm4ScKuk5lzS4PUTnjgcbM6xQetL6uqMR7T5IJflaK10rTPvvkIIP0/FbveWgBDu6AFCyKjc0JWcb8o08LRpndHF8JaJ/ZEFi0rTxVj/bZQunYKml+bU+eJyqOHrd8gX7VX8NnF3OnlxzHM13LKhSRtbLWsGYqBOiFvxqpZJBABMm/SbpFgo5j6XTaBlm1u1rwd1rMeEQd9EIhF6B4ECiS1oKLvSOltqXFEHgJZT1LBkUJm4ElykSIdaBUSGOU1mY/3mQYQr5LcymuC3/RA/KJyXBanzO3JTXJc7RQY3bJ5ypKYyBBk6NdmTRrsAmZ8n3zRDjg7klYekegOwywVIpeSnHuiLS3WuscBe6Bo2lR9LP+XDLmDgfvJSZIYiY9zeb5ztEsZF0= X-Forefront-PRVS: 0274272F87 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(39850400002)(39410400002)(39860400002)(39840400002)(39400400002)(39450400003)(23726003)(42186005)(53416004)(189998001)(46406003)(54906002)(47776003)(6116002)(3846002)(6486002)(81166006)(8676002)(36756003)(83506001)(4001350100001)(4326008)(66066001)(25786009)(53936002)(2950100002)(33646002)(86362001)(305945005)(5660300001)(76176999)(7736002)(54356999)(50986999)(50466002)(38730400002)(16060500001);DIR:OUT;SFP:1102;SCL:1;SRVR:TY1PR06MB0830;H:morimoto-PC.renesas.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;TY1PR06MB0830;23:HSHS9KuONixM7q9a0ylNKJyU+nDp2uL5YIVCIWbYe?= =?us-ascii?Q?BEdOOw/D2aW6EKjAgzieq4eJlZq+KS59C3jiCr3zxuv9wb1Yi7VdvkhkFStX?= =?us-ascii?Q?qV0kDN3UuEdJtVgkaE43nwPifEWnv8FvPvKnwxLQv8mfC11i26EnawK0ynBc?= =?us-ascii?Q?stS5zE19eb6HM89xCqwVp+KkJWSmes0QSktUWW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FilGRlKMRtq0J2P1v2YgTy7H7LaL2ZsocQtNW34W2hdNiPdw2h+ggkvJx2ulg6R7g4dUfHDlk+y8Z/HTNuqvdQ3GXGZk0zJh/bFL5mYUBjeR+XwmpaCLsNflVJbgRFbYlUp2jGVfNXsJg==;20:YsvuZEuAx9pH6QRHJI3Qnm21A3SJ9lFSfbJe8pI1gw8lhyd3oSlQ6NQ242rdrdQ22s0FC4zvrmAKeHNXo/0dF0hIkXocG0cO6LrnHYMRfK+9tTk/oemMcKHzCfeUmtiAiw04UDKykqn4M7ZjDvNpnRIdsGcvXdo+5Cydtg3i7/o= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2017 00:36:17.6891 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR06MB0830 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4202 Lines: 164 From: Kuninori Morimoto Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama --- .../devicetree/bindings/clock/cs2000-cp.txt | 9 +++ drivers/clk/clk-cs2000-cp.c | 73 +++++++++++++++++++++- 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/clock/cs2000-cp.txt b/Documentation/devicetree/bindings/clock/cs2000-cp.txt index 54e6df0..4c2f9cb 100644 --- a/Documentation/devicetree/bindings/clock/cs2000-cp.txt +++ b/Documentation/devicetree/bindings/clock/cs2000-cp.txt @@ -8,6 +8,15 @@ Required properties: - clock-names: CLK_IN : clk_in, XTI/REF_CLK : ref_clk - #clock-cells: must be <0> +Option properties: + +- auxoutsrc: select AUX_OUT source from these. + refclk: Timing Reference Clock + clk_in: Frequency Reference Clock + pllclkout: PLL Clock Output + push-pull: PLL Lock/Unlock Indication + open-drain: PLL Lock/Unlock Indication + Example: &i2c2 { diff --git a/drivers/clk/clk-cs2000-cp.c b/drivers/clk/clk-cs2000-cp.c index 4df38c5..234e3b4 100644 --- a/drivers/clk/clk-cs2000-cp.c +++ b/drivers/clk/clk-cs2000-cp.c @@ -42,6 +42,8 @@ /* DEVICE_CFG1 */ #define RSEL(x) (((x) & 0x3) << 3) #define RSEL_MASK RSEL(0x3) +#define AUXOUTSRC(x) (((x) & 0x3) << 1) +#define AUXOUTSRC_MASK AUXOUTSRC(0x3) #define ENDEV1 (0x1) /* DEVICE_CFG2 */ @@ -54,6 +56,8 @@ #define ENDEV2 (0x1) /* FUNC_CFG1 */ +#define AUXLOCKCFG(x) (((x) & 0x1) << 6) +#define AUXLOCKCFG_MASK AUXLOCKCFG(1) #define REFCLKDIV(x) (((x) & 0x3) << 3) #define REFCLKDIV_MASK REFCLKDIV(0x3) @@ -66,11 +70,20 @@ #define REF_CLK 1 #define CLK_MAX 2 +enum auxoutsrc { + AUXSRC_REFCLK = 0, + AUXSRC_CLKIN, + AUXSRC_PLLCLKOUT, + AUXSRC_PUSHPULL, + AUXSRC_OPENDRAIN, +}; + struct cs2000_priv { struct clk_hw hw; struct i2c_client *client; struct clk *clk_in; struct clk *ref_clk; + enum auxoutsrc auxoutsrc; /* suspend/resume */ unsigned long saved_rate; @@ -111,9 +124,27 @@ static int cs2000_bset(struct cs2000_priv *priv, u8 addr, u8 mask, u8 val) static int cs2000_enable_dev_config(struct cs2000_priv *priv, bool enable) { int ret; + u8 dcfg1, fcfg1; + + dcfg1 = 0; + fcfg1 = 0; + if (enable) + dcfg1 |= ENDEV1; + switch (priv->auxoutsrc) { + case AUXSRC_REFCLK: + case AUXSRC_CLKIN: + case AUXSRC_PLLCLKOUT: + dcfg1 |= AUXOUTSRC(priv->auxoutsrc); + break; + case AUXSRC_OPENDRAIN: + fcfg1 |= AUXLOCKCFG(1); + /* fall though */ + case AUXSRC_PUSHPULL: + dcfg1 |= AUXOUTSRC(3); + break; + } - ret = cs2000_bset(priv, DEVICE_CFG1, ENDEV1, - enable ? ENDEV1 : 0); + ret = cs2000_bset(priv, DEVICE_CFG1, (AUXOUTSRC_MASK | ENDEV1), dcfg1); if (ret < 0) return ret; @@ -122,6 +153,10 @@ static int cs2000_enable_dev_config(struct cs2000_priv *priv, bool enable) if (ret < 0) return ret; + ret = cs2000_bset(priv, FUNC_CFG1, AUXLOCKCFG_MASK, fcfg1); + if (ret < 0) + return ret; + return 0; } @@ -479,6 +514,38 @@ static int cs2000_remove(struct i2c_client *client) return 0; } +static void cs2000_of_parse(struct cs2000_priv *priv) +{ + struct device *dev = priv_to_dev(priv); + struct device_node *np = dev->of_node; + const char *auxoutsrc; + + auxoutsrc = of_get_property(np, "auxoutsrc", NULL); + + if (auxoutsrc) { + int i; + struct { + char *name; + enum auxoutsrc val; + } of_table[] = { + {"refclk", AUXSRC_REFCLK}, + {"clk_in", AUXSRC_CLKIN}, + {"pllclkout", AUXSRC_PLLCLKOUT}, + {"push-pull", AUXSRC_PUSHPULL}, + {"open-drain", AUXSRC_OPENDRAIN}, + }; + + for (i = 0; i < ARRAY_SIZE(of_table); i++) { + if (strcmp(of_table[i].name, auxoutsrc) == 0) { + priv->auxoutsrc = of_table[i].val; + dev_dbg(dev, "%s was selected\n", + of_table[i].name); + break; + } + } + } +} + static int cs2000_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -493,6 +560,8 @@ static int cs2000_probe(struct i2c_client *client, priv->client = client; i2c_set_clientdata(client, priv); + cs2000_of_parse(priv); + ret = cs2000_clk_get(priv); if (ret < 0) return ret; -- 1.9.1