From patchwork Tue Jul 23 07:20:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2831864 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 193E9C0319 for ; Tue, 23 Jul 2013 08:37:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB624201BC for ; Tue, 23 Jul 2013 08:37:00 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1ED9E201BB for ; Tue, 23 Jul 2013 08:36:59 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1X3T-0007tB-Q9; Tue, 23 Jul 2013 07:30:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1Wy7-0000yX-CD; Tue, 23 Jul 2013 07:25:11 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1Wvh-0000ig-5L for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2013 07:22:56 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6N7MKRa011468; Tue, 23 Jul 2013 02:22:20 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6N7MKAH026635; Tue, 23 Jul 2013 02:22:20 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Tue, 23 Jul 2013 02:22:20 -0500 Received: from sokoban.tieu.ti.com (h79-8.vpn.ti.com [172.24.79.8]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6N7LQtp027090; Tue, 23 Jul 2013 02:22:18 -0500 From: Tero Kristo To: , , , , , , Subject: [PATCHv4 21/33] CLK: OMAP: DPLL: add omap3 dpll support Date: Tue, 23 Jul 2013 10:20:16 +0300 Message-ID: <1374564028-11352-22-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374564028-11352-1-git-send-email-t-kristo@ti.com> References: <1374564028-11352-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130723_032241_375856_B4997339 X-CRM114-Status: GOOD ( 12.90 ) X-Spam-Score: -8.4 (--------) Cc: devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org 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: , 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 OMAP3 has slightly different DPLLs from those compared to OMAP4. Modified code for the same. Signed-off-by: Tero Kristo --- drivers/clk/omap/dpll.c | 96 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 11 deletions(-) diff --git a/drivers/clk/omap/dpll.c b/drivers/clk/omap/dpll.c index d8a958a..ecb1fbd 100644 --- a/drivers/clk/omap/dpll.c +++ b/drivers/clk/omap/dpll.c @@ -26,6 +26,11 @@ #include #include +enum { + SUBTYPE_OMAP3_DPLL, + SUBTYPE_OMAP4_DPLL, +}; + static const struct clk_ops dpll_m4xen_ck_ops = { .enable = &omap3_noncore_dpll_enable, .disable = &omap3_noncore_dpll_disable, @@ -40,6 +45,13 @@ static const struct clk_ops dpll_core_ck_ops = { .get_parent = &omap2_init_dpll_parent, }; +static const struct clk_ops omap3_dpll_core_ck_ops = { + .init = &omap2_init_clk_clkdm, + .get_parent = &omap2_init_dpll_parent, + .recalc_rate = &omap3_dpll_recalc, + .round_rate = &omap2_dpll_round_rate, +}; + static const struct clk_ops dpll_ck_ops = { .enable = &omap3_noncore_dpll_enable, .disable = &omap3_noncore_dpll_disable, @@ -50,6 +62,26 @@ static const struct clk_ops dpll_ck_ops = { .init = &omap2_init_clk_clkdm, }; +static const struct clk_ops omap3_dpll_ck_ops = { + .init = &omap2_init_clk_clkdm, + .enable = &omap3_noncore_dpll_enable, + .disable = &omap3_noncore_dpll_disable, + .get_parent = &omap2_init_dpll_parent, + .recalc_rate = &omap3_dpll_recalc, + .set_rate = &omap3_noncore_dpll_set_rate, + .round_rate = &omap2_dpll_round_rate, +}; + +static const struct clk_ops omap3_dpll_per_ck_ops = { + .init = &omap2_init_clk_clkdm, + .enable = &omap3_noncore_dpll_enable, + .disable = &omap3_noncore_dpll_disable, + .get_parent = &omap2_init_dpll_parent, + .recalc_rate = &omap3_dpll_recalc, + .set_rate = &omap3_dpll4_set_rate, + .round_rate = &omap2_dpll_round_rate, +}; + static const struct clk_ops dpll_x2_ck_ops = { .recalc_rate = &omap3_clkoutx2_recalc, }; @@ -144,7 +176,9 @@ struct clk *omap_clk_register_dpll_x2(struct device *dev, const char *name, * of_omap_dpll_setup() - Setup function for OMAP DPLL clocks */ static void __init of_omap_dpll_setup(struct device_node *node, - const struct clk_ops *ops) + const struct clk_ops *ops, u32 freqsel, + u32 modes, u8 mul_div_shift, + int subtype) { struct clk *clk; const char *clk_name = node->name; @@ -157,8 +191,8 @@ static void __init of_omap_dpll_setup(struct device_node *node, u32 idlest_mask = 0x1; u32 enable_mask = 0x7; u32 autoidle_mask = 0x7; - u32 mult_mask = 0x7ff << 8; - u32 div1_mask = 0x7f; + u32 mult_mask = 0x7ff << (8 + mul_div_shift); + u32 div1_mask = 0x7f << mul_div_shift; u32 max_multiplier = 2047; u32 max_divider = 128; u32 min_divider = 1; @@ -193,7 +227,7 @@ static void __init of_omap_dpll_setup(struct device_node *node, clkspec.np = of_parse_phandle(node, "ti,clk-ref", 0); dd->clk_ref = of_clk_get_from_provider(&clkspec); - if (!dd->clk_ref) { + if (IS_ERR(dd->clk_ref)) { pr_err("%s: ti,clk-ref for %s not found\n", __func__, clk_name); goto cleanup; @@ -201,7 +235,7 @@ static void __init of_omap_dpll_setup(struct device_node *node, clkspec.np = of_parse_phandle(node, "ti,clk-bypass", 0); dd->clk_bypass = of_clk_get_from_provider(&clkspec); - if (!dd->clk_bypass) { + if (IS_ERR(dd->clk_bypass)) { pr_err("%s: ti,clk-bypass for %s not found\n", __func__, clk_name); goto cleanup; @@ -225,14 +259,31 @@ static void __init of_omap_dpll_setup(struct device_node *node, dd->enable_mask = enable_mask; dd->autoidle_mask = autoidle_mask; - dd->modes = 0xa0; + if (!of_property_read_u32(node, "ti,recal-en-bit", &val)) + dd->recal_en_bit = val; + + if (!of_property_read_u32(node, "ti,recal-st-bit", &val)) + dd->recal_st_bit = val; + + if (!of_property_read_u32(node, "ti,auto-recal-bit", &val)) + dd->auto_recal_bit = val; + + of_property_read_u32(node, "ti,modes", &modes); + + dd->modes = modes; + + dd->freqsel_mask = freqsel; if (of_property_read_bool(node, "ti,dpll-j-type")) { dd->sddiv_mask = 0xff000000; - mult_mask = 0xfff << 8; - div1_mask = 0xff; + mult_mask = 0xfff << (8 + mul_div_shift); max_multiplier = 4095; - max_divider = 256; + if (subtype == SUBTYPE_OMAP3_DPLL) { + dd->dco_mask = 0xe00000; + } else { + div1_mask = 0xff << mul_div_shift; + max_divider = 256; + } } if (of_property_read_bool(node, "ti,dpll-regm4xen")) { @@ -281,7 +332,30 @@ static void __init of_omap_dpll_x2_setup(struct device_node *node) __init void of_omap3_dpll_setup(struct device_node *node) { - /* XXX: to be done */ + const struct clk_ops *ops; + u32 freqsel = 0xf0; + u32 modes = 0xa0; + u8 mul_div_shift = 0; + + ops = &omap3_dpll_ck_ops; + + if (of_property_read_bool(node, "ti,dpll-core")) { + ops = &omap3_dpll_core_ck_ops; + mul_div_shift = 8; + modes = 0x0; + } + + if (of_property_read_bool(node, "ti,dpll-peripheral")) { + ops = &omap3_dpll_per_ck_ops; + freqsel = 0xf00000; + } + + if (of_property_read_bool(node, "ti,dpll-j-type")) + freqsel = 0x0; + + of_omap_dpll_setup(node, ops, freqsel, modes, mul_div_shift, + SUBTYPE_OMAP3_DPLL); + } EXPORT_SYMBOL_GPL(of_omap3_dpll_setup); CLK_OF_DECLARE(omap3_dpll_clock, "ti,omap3-dpll-clock", of_omap3_dpll_setup); @@ -306,7 +380,7 @@ __init void of_omap4_dpll_setup(struct device_node *node) if (of_property_read_bool(node, "ti,dpll-no-gate")) ops = &dpll_no_gate_ck_ops; - of_omap_dpll_setup(node, ops); + of_omap_dpll_setup(node, ops, 0, 0xa0, 0, SUBTYPE_OMAP4_DPLL); } EXPORT_SYMBOL_GPL(of_omap4_dpll_setup); CLK_OF_DECLARE(omap4_dpll_clock, "ti,omap4-dpll-clock", of_omap4_dpll_setup);