Skip to contentSkip to conversation

mwifiex: register platform specific driver

PATCH In review Amitkumar Karwar 3 participants 8 messages Feb 16, 2016 – Feb 29, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/3 mwifiex: register platform specific driver

From: Xinming Hu <[email protected]>

Platform device and driver provides easy way to interact with device-tree-enabled system.

This patch registers platform driver and reorganise existing device tree specific code. Corresponding device tree binding file is also created.

---
v3: Don't update adapter->dt_node if mwifiex_plt_dev is NULL
v4: Corrected the 'name' and 'compatible' property names.(Arnd Bergmann and Rob
Herring)
Patch description wraped in 72 columns(Rob Herring)
Moved DT binding file to bindings/net/wireless/(Rob Herring)

---
 .../bindings/net/wireless/marvell-sd8xxx.txt       | 29 +++++++++++
 drivers/net/wireless/marvell/mwifiex/Makefile      |  1 +
 drivers/net/wireless/marvell/mwifiex/main.c        |  2 +
 drivers/net/wireless/marvell/mwifiex/main.h        | 14 +++++
 .../net/wireless/marvell/mwifiex/platform_drv.c    | 59 ++++++++++++++++++++++
 drivers/net/wireless/marvell/mwifiex/sta_cmd.c     |  4 +-
 6 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt
 create mode 100644 drivers/net/wireless/marvell/mwifiex/platform_drv.c
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt new file +29 -0
new file mode 100644
index 0000000..f7671ae
@@ -0,0 +1,29 @@
+Marvell Sd8xxx Wireless devices
+------
+
+Required properties:
+
+  - name : must be "wlan"
+  - compatible : must be "marvell,sd8xxx"
+
+Optional properties:
+
+  - marvell,caldata* : A series of properties with marvell,caldata prefix,
+  		      represent Calibration data downloaded to the device during
+		      initialization. This is an array of unsigned values.
+
+
+Example:
+
+Tx power limit calibration data is configured in below example.
+The calibration data is an array of unsigned values, the length
+can vary between hw versions.
+
+wlan {
+	compatible = "marvell,sd8xxx";
+
+	marvell,caldata_00_txpwrlimit_2g_cfg_set = /bits/ 8 <
+0x01 0x00 0x06 0x00 0x08 0x02 0x89 0x01 ...>;
+
+};
+
drivers/net/wireless/marvell/mwifiex/Makefile +1 -0
index fdfd9bf..1444fd1 100644
@@ -42,6 +42,7 @@ mwifiex-y += cfg80211.o
 mwifiex-y += ethtool.o
 mwifiex-y += 11h.o
 mwifiex-y += tdls.o
+mwifiex-y += platform_drv.o
 mwifiex-$(CONFIG_DEBUG_FS) += debugfs.o
 obj-$(CONFIG_MWIFIEX) += mwifiex.o
 
drivers/net/wireless/marvell/mwifiex/main.c +2 -0
index 3cfa946..b93ae69 100644
@@ -1538,6 +1538,7 @@ EXPORT_SYMBOL_GPL(_mwifiex_dbg);
 static int
 mwifiex_init_module(void)
 {
+	mwifiex_platform_drv_init();
 #ifdef CONFIG_DEBUG_FS
 	mwifiex_debugfs_init();
 #endif
@@ -1552,6 +1553,7 @@ mwifiex_init_module(void)
 static void
 mwifiex_cleanup_module(void)
 {
+	mwifiex_platform_drv_exit();
 #ifdef CONFIG_DEBUG_FS
 	mwifiex_debugfs_remove();
 #endif
drivers/net/wireless/marvell/mwifiex/main.h +14 -0
index aea7aee..464d79f 100644
@@ -37,6 +37,16 @@
 #include <linux/idr.h>
 #include <linux/inetdevice.h>
 #include <linux/devcoredump.h>
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/gfp.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/of_gpio.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
 
 #include "decl.h"
 #include "ioctl.h"
@@ -47,6 +57,7 @@
 #include "sdio.h"
 
 extern const char driver_version[];
+extern struct platform_device *mwifiex_plt_dev;
 
 struct mwifiex_adapter;
 struct mwifiex_private;
@@ -1597,6 +1608,9 @@ void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
 				      struct sk_buff *event_skb);
 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter);
 
+int mwifiex_platform_drv_init(void);
+void mwifiex_platform_drv_exit(void);
+
 #ifdef CONFIG_DEBUG_FS
 void mwifiex_debugfs_init(void);
 void mwifiex_debugfs_remove(void);
drivers/net/wireless/marvell/mwifiex/platform_drv.c new file +59 -0

59 lines not on this page · raw message

drivers/net/wireless/marvell/mwifiex/sta_cmd.c +2 -2
index 30f1526..238fe4f 100644
@@ -2154,8 +2154,8 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
 		 * The cal-data can be read from device tree and/or
 		 * a configuration file and downloaded to firmware.
 		 */
-		adapter->dt_node =
-				of_find_node_by_name(NULL, "marvell_cfgdata");
+		adapter->dt_node = mwifiex_plt_dev ?
+				mwifiex_plt_dev->dev.of_node : NULL;
 		if (adapter->dt_node) {
 			ret = mwifiex_dnld_dt_cfgdata(priv, adapter->dt_node,
 						      "marvell,caldata");
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH v4 2/3 mwifiex: parse chip specific gpio from device tree

From: Xinming Hu <[email protected]>

This patch parse chip specific gpio parameter from device tree. Corresponding binding file is also updated.

---
v4: Renamed "mwifiex,chip-gpio" to "marvell,wakeup-gpios"(Rob Herring/
Arnd Bergmann)

---
 .../devicetree/bindings/net/wireless/marvell-sd8xxx.txt          | 6 ++++--
 drivers/net/wireless/marvell/mwifiex/sta_cmd.c                   | 9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +4 -2
index f7671ae..c337fab 100644
@@ -11,7 +11,9 @@ Optional properties:
   - marvell,caldata* : A series of properties with marvell,caldata prefix,
   		      represent Calibration data downloaded to the device during
 		      initialization. This is an array of unsigned values.
-
+  - marvell,wakeup-gpios : Chip's wakeup gpio pin number. This needs to be downloaded
+			to to firmware. Chip notifies wifi wakeup signal to SOC
+			through this pin.
 
 Example:
 
@@ -24,6 +26,6 @@ wlan {
 
 	marvell,caldata_00_txpwrlimit_2g_cfg_set = /bits/ 8 <
 0x01 0x00 0x06 0x00 0x08 0x02 0x89 0x01 ...>;
-
+	marvell,wakeup-gpios = <3>;
 };
 
drivers/net/wireless/marvell/mwifiex/sta_cmd.c +9 -0
index 238fe4f..fce3f98 100644
@@ -2134,6 +2134,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
 	enum state_11d_t state_11d;
 	struct mwifiex_ds_11n_tx_cfg tx_cfg;
 	u8 sdio_sp_rx_aggr_enable;
+	u32 data;
 
 	if (first_sta) {
 		if (priv->adapter->iface_type == MWIFIEX_PCIE) {
@@ -2157,6 +2158,14 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
 		adapter->dt_node = mwifiex_plt_dev ?
 				mwifiex_plt_dev->dev.of_node : NULL;
 		if (adapter->dt_node) {
+			if (of_property_read_u32(adapter->dt_node,
+						 "marvell,wakeup-gpios",
+						 &data) == 0) {
+				mwifiex_dbg(adapter, INFO,
+					    "Wakeup gpio = 0x%x\n", data);
+				adapter->hs_cfg.gpio = data;
+			}
+
 			ret = mwifiex_dnld_dt_cfgdata(priv, adapter->dt_node,
 						      "marvell,caldata");
 			if (ret)
Signature · 1 line
1.8.1.4
maintainer
#2 lore raw

Re: [PATCH v4 2/3] mwifiex: parse chip specific gpio from device tree

Quoted 5 lines · Amitkumar Karwar

From: Xinming Hu <[email protected]>

This patch parse chip specific gpio parameter from device tree. Corresponding binding file is also updated.

Quoted 7 lines

---
v4: Renamed "mwifiex,chip-gpio" to "marvell,wakeup-gpios"(Rob Herring/
Arnd Bergmann)

---
 .../devicetree/bindings/net/wireless/marvell-sd8xxx.txt          | 6 ++++--

Combine this with the DT change in the next patch.

Quoted 8 lines
 drivers/net/wireless/marvell/mwifiex/sta_cmd.c                   | 9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +0 -0
index f7671ae..c337fab 100644

Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt Optional properties: · line 16

Quoted 7 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +3 -1
@@ -11,7 +11,9 @@ Optional properties:
   - marvell,caldata* : A series of properties with marvell,caldata prefix,
   		      represent Calibration data downloaded to the device during
 		      initialization. This is an array of unsigned values.
-
+  - marvell,wakeup-gpios : Chip's wakeup gpio pin number. This needs to be downloaded
+			to to firmware. Chip notifies wifi wakeup signal to SOC
+			through this pin.

This is still confusing that it is not a GPIO from the host. I'd suggest "marvell,wakeup-pin"

#3 lore raw

PATCH v4 3/3 mwifiex: parse host wakeup configuration from device

In reply to Amitkumar Karwar

From: Xinming Hu <[email protected]>

This patch implement a framework for board specific wakeup. driver parse irq/gpio number from device tree, corresponding resources will be allocated, and used for host suspend/resume. driver private binding file is also updated in the patch.

---
v4: Replaced #ifdef with __maybe_unused(Arnd Bergmann)

---
 .../bindings/net/wireless/marvell-sd8xxx.txt       | 10 +++
 .../net/wireless/marvell/mwifiex/platform_drv.c    | 91 ++++++++++++++++++++++
 2 files changed, 101 insertions(+)
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +10 -0
index c337fab..50138fd 100644
@@ -14,6 +14,11 @@ Optional properties:
   - marvell,wakeup-gpios : Chip's wakeup gpio pin number. This needs to be downloaded
 			to to firmware. Chip notifies wifi wakeup signal to SOC
 			through this pin.
+  - interrupt-parent: phandle of the parent interrupt controller
+  - interrupts : interrupt number to the cpu
+  - gpios: specify SOC's wakeup GPIO
+  - pinctrl-names : a pinctrl state named "default" must be defined
+  - pinctrl-0 : pin control group to be used for this controller
 
 Example:
 
@@ -27,5 +32,10 @@ wlan {
 	marvell,caldata_00_txpwrlimit_2g_cfg_set = /bits/ 8 <
 0x01 0x00 0x06 0x00 0x08 0x02 0x89 0x01 ...>;
 	marvell,wakeup-gpios = <3>;
+	interrupt-parent = <&pio>;
+	interrupts = <38 IRQ_TYPE_LEVEL_LOW>;
+	gpios = <&pio 38 GPIO_ACTIVE_HIGH>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&wake_pins>;
 };
 
drivers/net/wireless/marvell/mwifiex/platform_drv.c +91 -0

112 lines not on this page · raw message

Signature · 1 line
1.8.1.4
maintainer
#4 lore raw

Re: [PATCH v4 3/3] mwifiex: parse host wakeup configuration from device

Quoted 21 lines · Amitkumar Karwar

From: Xinming Hu <[email protected]>

This patch implement a framework for board specific wakeup. driver parse irq/gpio number from device tree, corresponding resources will be allocated, and used for host suspend/resume. driver private binding file is also updated in the patch.

---
v4: Replaced #ifdef with __maybe_unused(Arnd Bergmann)

---
 .../bindings/net/wireless/marvell-sd8xxx.txt       | 10 +++
 .../net/wireless/marvell/mwifiex/platform_drv.c    | 91 ++++++++++++++++++++++
 2 files changed, 101 insertions(+)
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +0 -0
index c337fab..50138fd 100644

Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt Optional properties: · line 19

Quoted 6 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +3 -0
@@ -14,6 +14,11 @@ Optional properties:
   - marvell,wakeup-gpios : Chip's wakeup gpio pin number. This needs to be downloaded
 			to to firmware. Chip notifies wifi wakeup signal to SOC
 			through this pin.
+  - interrupt-parent: phandle of the parent interrupt controller
+  - interrupts : interrupt number to the cpu
+  - gpios: specify SOC's wakeup GPIO

If you define the GPIO line as an interrupt, you shouldn't need it to be as GPIO too. Same on the BT side.

Quoted 16 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt +7 -0
+  - pinctrl-names : a pinctrl state named "default" must be defined
+  - pinctrl-0 : pin control group to be used for this controller
 
 Example:
 
@@ -27,5 +32,10 @@ wlan {
 	marvell,caldata_00_txpwrlimit_2g_cfg_set = /bits/ 8 <
 0x01 0x00 0x06 0x00 0x08 0x02 0x89 0x01 ...>;
 	marvell,wakeup-gpios = <3>;
+	interrupt-parent = <&pio>;
+	interrupts = <38 IRQ_TYPE_LEVEL_LOW>;
+	gpios = <&pio 38 GPIO_ACTIVE_HIGH>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&wake_pins>;
 };
 
#5 lore raw
In reply to Amitkumar Karwar
Quoted 2 lines · On Tuesday 16 February 2016 01:14:37 Amitkumar Karwar wrote:

+ - compatible : must be "marvell,sd8xxx"

I think we mentioned it before, but a compatible string must not contain wildcards of any kind, as it is very possible that there are some future sd8xxx devices that are slightly incompatible with the first one.

Please use a specfic model name here, or a list of multiple models if they are actually different.

Arnd

maintainer
#6 lore raw
In reply to Amitkumar Karwar
Quoted 11 lines · Amitkumar Karwar

From: Xinming Hu <[email protected]>

Platform device and driver provides easy way to interact with device-tree-enabled system.

This patch registers platform driver and reorganise existing device tree specific code. Corresponding device tree binding file is also created.

Quoted 8 lines

---
v3: Don't update adapter->dt_node if mwifiex_plt_dev is NULL
v4: Corrected the 'name' and 'compatible' property names.(Arnd Bergmann and Rob
Herring)
Patch description wraped in 72 columns(Rob Herring)
Moved DT binding file to bindings/net/wireless/(Rob Herring)

---
 .../bindings/net/wireless/marvell-sd8xxx.txt       | 29 +++++++++++

Again, one patch for all the binding changes.

Quoted 15 lines
 drivers/net/wireless/marvell/mwifiex/Makefile      |  1 +
 drivers/net/wireless/marvell/mwifiex/main.c        |  2 +
 drivers/net/wireless/marvell/mwifiex/main.h        | 14 +++++
 .../net/wireless/marvell/mwifiex/platform_drv.c    | 59 ++++++++++++++++++++++
 drivers/net/wireless/marvell/mwifiex/sta_cmd.c     |  4 +-
 6 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt
 create mode 100644 drivers/net/wireless/marvell/mwifiex/platform_drv.c
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt new file +0 -0
new file mode 100644
index 0000000..f7671ae

Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt new file +7 -0
@@ -0,0 +1,29 @@
+Marvell Sd8xxx Wireless devices
+------
+
+Required properties:
+
+  - name : must be "wlan"
+  - compatible : must be "marvell,sd8xxx"

No wildcards as Arnd mentioned.

Quoted 5 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt new file +5 -0
+
+Optional properties:
+
+  - marvell,caldata* : A series of properties with marvell,caldata prefix,
+  		      represent Calibration data downloaded to the device during

Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt line 22

Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt new file +10 -0
+		      initialization. This is an array of unsigned values.
+
+
+Example:
+
+Tx power limit calibration data is configured in below example.
+The calibration data is an array of unsigned values, the length
+can vary between hw versions.
+
+wlan {

This also needs to be specified as a subnode of the SDIO controller.

Quoted 7 lines
Documentation/devicetree/bindings/net/wireless/marvell-sd8xxx.txt new file +7 -0
+	compatible = "marvell,sd8xxx";
+
+	marvell,caldata_00_txpwrlimit_2g_cfg_set = /bits/ 8 <
+0x01 0x00 0x06 0x00 0x08 0x02 0x89 0x01 ...>;
+
+};
+
#7 lore raw

Hi Rob,

Quoted 18 lines

From: Rob Herring [mailto:[email protected]]
Sent: Thursday, February 18, 2016 8:08 PM
To: Amitkumar Karwar
Cc: [email protected]; Nishant Sarmukadam; [email protected]; [email protected]; Cathy Luo; linux- [email protected]; Xinming Hu
Subject: Re: [PATCH v4 1/3] mwifiex: register platform specific driver

Quoted 9 lines · Amitkumar Karwar

From: Xinming Hu <[email protected]>

Platform device and driver provides easy way to interact with device-tree-enabled system.

This patch registers platform driver and reorganise existing device tree specific code. Corresponding device tree binding file is also created.

Quoted 10 lines
Quoted 5 lines

---
v3: Don't update adapter->dt_node if mwifiex_plt_dev is NULL
v4: Corrected the 'name' and 'compatible' property names.(Arnd

Bergmann and Rob

Quoted 4 lines

Herring)
Patch description wraped in 72 columns(Rob Herring) Moved DT binding file to bindings/net/wireless/(Rob Herring)
---

Thanks for reviewing mwifiex and btmrvl patch series.
We are working on a updated version which will address your review comments.

Regards,
Amitkumar