devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luciano Coelho <coelho@ti.com>
To: linux-wireless@vger.kernel.org, tony@atomide.com, nsekhar@ti.com
Cc: mturquette@linaro.org, mark.rutland@arm.com, balbi@ti.com,
	grant.likely@linaro.org, rob.herring@calxeda.com,
	devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, coelho@ti.com
Subject: [PATCH v2 9/9] wlcore/wl12xx: check if we got correct clock data from DT
Date: Tue, 2 Jul 2013 17:55:48 +0300	[thread overview]
Message-ID: <1372776948-24840-10-git-send-email-coelho@ti.com> (raw)
In-Reply-To: <1372776948-24840-1-git-send-email-coelho@ti.com>

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 <coelho@ti.com>
---
 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 903dcb3..72d13e4 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,
 							pdata->tcxo_clock_xtal);
@@ -1796,7 +1808,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);
-- 
1.7.10.4

  parent reply	other threads:[~2013-07-02 14:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 14:55 [PATCH v2 0/9] wilink: add device tree support Luciano Coelho
     [not found] ` <1372776948-24840-1-git-send-email-coelho-l0cyMroinI0@public.gmane.org>
2013-07-02 14:55   ` [PATCH v2 1/9] wl1251: split wl251 platform data to a separate structure Luciano Coelho
2013-07-02 14:55   ` [PATCH v2 2/9] wlcore: use irq_flags in pdata instead of hiding it behind a quirk Luciano Coelho
2013-07-02 15:26     ` Felipe Balbi
2013-07-02 20:12       ` Luciano Coelho
2013-07-02 14:55   ` [PATCH v2 4/9] wl12xx: use frequency instead of enumerations for pdata clocks Luciano Coelho
2013-07-02 15:02     ` Nishanth Menon
2013-07-02 20:27       ` Luciano Coelho
2013-07-03 11:33         ` Tony Lindgren
2013-07-03 12:14           ` Luciano Coelho
     [not found]     ` <1372776948-24840-5-git-send-email-coelho-l0cyMroinI0@public.gmane.org>
2013-07-02 15:31       ` Felipe Balbi
2013-07-02 20:14         ` Luciano Coelho
2013-07-02 14:55   ` [PATCH v2 6/9] wlcore: add initial device tree support to the sdio module Luciano Coelho
2013-07-02 14:55 ` [PATCH v2 3/9] wlcore: remove pwr_in_suspend from platform data Luciano Coelho
2013-07-02 14:55 ` [PATCH v2 5/9] wlcore: always use one-shot IRQ Luciano Coelho
2013-07-02 15:32   ` Felipe Balbi
2013-07-02 20:16     ` Luciano Coelho
2013-07-02 14:55 ` [PATCH v2 7/9] wlcore: sdio: add wilink clock providers Luciano Coelho
2013-07-02 15:34   ` Felipe Balbi
2013-07-02 21:30     ` Felipe Balbi
2013-07-02 14:55 ` [PATCH v2 8/9] wlcore: sdio: get clocks from device tree Luciano Coelho
     [not found]   ` <1372776948-24840-9-git-send-email-coelho-l0cyMroinI0@public.gmane.org>
2013-07-02 15:35     ` Felipe Balbi
2013-07-02 20:19       ` Luciano Coelho
2013-07-02 21:32         ` Felipe Balbi
2013-07-02 21:38           ` Luciano Coelho
2013-07-02 14:55 ` Luciano Coelho [this message]
2013-07-03 10:13 ` [PATCH v2 0/9] wilink: add device tree support Grazvydas Ignotas
2013-07-03 13:45   ` Luciano Coelho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372776948-24840-10-git-send-email-coelho@ti.com \
    --to=coelho@ti.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@linaro.org \
    --cc=nsekhar@ti.com \
    --cc=rob.herring@calxeda.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).