From patchwork Wed Jul 3 14:03:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luciano Coelho X-Patchwork-Id: 2817481 Return-Path: X-Original-To: patchwork-linux-omap@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 8A24DBF4A1 for ; Wed, 3 Jul 2013 14:06:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DCF5201C7 for ; Wed, 3 Jul 2013 14:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 105AD201B8 for ; Wed, 3 Jul 2013 14:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932939Ab3GCOEn (ORCPT ); Wed, 3 Jul 2013 10:04:43 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:49944 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932929Ab3GCOEj (ORCPT ); Wed, 3 Jul 2013 10:04:39 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r63E45a8032066; Wed, 3 Jul 2013 09:04:05 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r63E45d4005614; Wed, 3 Jul 2013 09:04:05 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Wed, 3 Jul 2013 09:04:04 -0500 Received: from cumari.coelho.fi (h79-2.vpn.ti.com [172.24.79.2]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r63E3UJl015397; Wed, 3 Jul 2013 09:04:01 -0500 From: Luciano Coelho To: , , CC: , , , , , , , , , , , Subject: [PATCH v3 8/8] wlcore/wl12xx: check if we got correct clock data from DT Date: Wed, 3 Jul 2013 17:03:29 +0300 Message-ID: <1372860209-3504-9-git-send-email-coelho@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372860209-3504-1-git-send-email-coelho@ti.com> References: <1372860209-3504-1-git-send-email-coelho@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 The fref and the tcxo clocks settings are optional in some platforms. WiLink8 doesn't need either, so we don't check the values. WiLink 6 only needs the fref clock, so we check that it is valid or return with an error. WiLink7 needs both clocks, if either is not available we return with an error. Signed-off-by: Luciano Coelho Reviewed-by: Felipe Balbi --- drivers/net/wireless/ti/wl12xx/main.c | 20 +++++++++++++++++--- drivers/net/wireless/ti/wlcore/sdio.c | 4 ---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c index 216c2fd..1be0b51 100644 --- a/drivers/net/wireless/ti/wl12xx/main.c +++ b/drivers/net/wireless/ti/wl12xx/main.c @@ -927,6 +927,11 @@ static int wl128x_boot_clk(struct wl1271 *wl, int *selected_clock) u16 sys_clk_cfg; int ret; + if ((priv->ref_clock < 0) || (priv->tcxo_clock < 0)) { + wl1271_error("Missing fref and/or tcxo clock settings\n"); + return -EINVAL; + } + /* For XTAL-only modes, FREF will be used after switching from TCXO */ if (priv->ref_clock == WL12XX_REFCLOCK_26_XTAL || priv->ref_clock == WL12XX_REFCLOCK_38_XTAL) { @@ -976,6 +981,11 @@ static int wl127x_boot_clk(struct wl1271 *wl) u32 clk; int ret; + if (priv->ref_clock < 0) { + wl1271_error("Missing fref clock settings\n"); + return -EINVAL; + } + if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3) wl->quirks |= WLCORE_QUIRK_END_OF_TRANSACTION; @@ -1757,7 +1767,7 @@ static int wl12xx_setup(struct wl1271 *wl) wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, &wl12xx_ht_cap); wl12xx_conf_init(wl); - if (!fref_param) { + if (!fref_param && (pdata->ref_clock_freq > 0)) { priv->ref_clock = wl12xx_get_clock_idx(wl12xx_refclock_table, pdata->ref_clock_freq, pdata->ref_clock_xtal); @@ -1768,6 +1778,8 @@ static int wl12xx_setup(struct wl1271 *wl) return priv->ref_clock; } + } else if (!fref_param) { + priv->ref_clock = -EINVAL; } else { if (!strcmp(fref_param, "19.2")) priv->ref_clock = WL12XX_REFCLOCK_19; @@ -1785,7 +1797,7 @@ static int wl12xx_setup(struct wl1271 *wl) wl1271_error("Invalid fref parameter %s", fref_param); } - if (!tcxo_param) { + if (!fref_param && (pdata->tcxo_clock_freq > 0)) { priv->tcxo_clock = wl12xx_get_clock_idx(wl12xx_tcxoclock_table, pdata->tcxo_clock_freq, true); @@ -1795,7 +1807,9 @@ static int wl12xx_setup(struct wl1271 *wl) return priv->tcxo_clock; } - } else { + } else if (!fref_param) { + priv->tcxo_clock = -EINVAL; + }else { if (!strcmp(tcxo_param, "19.2")) priv->tcxo_clock = WL12XX_TCXOCLOCK_19_2; else if (!strcmp(tcxo_param, "26")) diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c index 60fce49..c76eb66 100644 --- a/drivers/net/wireless/ti/wlcore/sdio.c +++ b/drivers/net/wireless/ti/wlcore/sdio.c @@ -252,20 +252,16 @@ static struct wl12xx_platform_data *wlcore_get_pdata_from_of(struct device *dev) for_each_matching_node(clock_node, wlcore_sdio_of_clk_match_table) of_fixed_clk_setup(clock_node); - /* TODO: make sure we have this when needed (ie. for WL6 and WL7) */ glue->refclock = of_clk_get_by_name(np, "refclock"); if (IS_ERR(glue->refclock)) { - dev_err(dev, "couldn't find refclock on the device tree\n"); glue->refclock = NULL; } else { clk_prepare_enable(glue->refclock); pdata->ref_clock_freq = clk_get_rate(glue->refclock); } - /* TODO: make sure we have this when needed (ie. for WL7) */ glue->tcxoclock = of_clk_get_by_name(np, "tcxoclock"); if (IS_ERR(glue->tcxoclock)) { - dev_err(dev, "couldn't find tcxoclock on the device tree\n"); glue->tcxoclock = NULL; } else { clk_prepare_enable(glue->tcxoclock);