All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver
@ 2017-03-27 13:37 Stefan Wahren
  2017-03-27 13:37   ` Stefan Wahren
                   ` (9 more replies)
  0 siblings, 10 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

The Qualcomm QCA7000 HomePlug GreenPHY supports two interfaces:
UART and SPI. This patch series adds the missing support for UART.

This driver based on the Qualcomm code [1], but contains some changes:
* use random MAC address per default
* use net_device_stats from device
* share frame decoding between SPI and UART driver
* improve error handling
* reimplement tty_wakeup with work queue (based on slcan)
* use new serial device bus instead of ldisc

The patches 1 - 3 are just for clean up and are not related to
the UART support. Patches 4 - 7 prepare the existing QCA7000
code for UART support. Patch 8 contains the new driver. The last
two patches are suggested improvements for serial device bus.

The code itself has been tested on a Freescale i.MX28 board and
a Raspberry Pi Zero.

Changes in v4:
  * rebase to current linux-next
  * use parameter -M for git format-patch
  * change order of local variables where possible
  * implement basic serdev support (without hardware flow control)

Changes in v3:
  * rebase to current net-next

Changes in v2:
  * fix build issue by using netif_trans_update() and dev_trans_start()

[1] - https://github.com/IoE/qca7000

Stefan Wahren (10):
  net: qualcomm: remove unnecessary includes
  net: qca_debug: use net_device_ops instead of direct call
  net: qualcomm: move qcaspi_tx_cmd to qca_spi.c
  net: qualcomm: rename qca_framing.c to qca_common.c
  net: qualcomm: prepare frame decoding for UART driver
  net: qualcomm: make qca_common a separate kernel module
  dt-bindings: net: add binding for QCA7000 UART
  net: qualcomm: add QCA7000 UART driver
  tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate
  tty: serdev: add functions to retrieve common UART settings

 .../devicetree/bindings/net/qca-qca7000-uart.txt   |  31 ++
 drivers/net/ethernet/qualcomm/Kconfig              |  18 +-
 drivers/net/ethernet/qualcomm/Makefile             |   7 +-
 drivers/net/ethernet/qualcomm/qca_7k.c             |  28 --
 drivers/net/ethernet/qualcomm/qca_7k.h             |   1 -
 .../qualcomm/{qca_framing.c => qca_common.c}       |  24 +-
 .../qualcomm/{qca_framing.h => qca_common.h}       |  14 +-
 drivers/net/ethernet/qualcomm/qca_debug.c          |   5 +-
 drivers/net/ethernet/qualcomm/qca_spi.c            |  28 +-
 drivers/net/ethernet/qualcomm/qca_spi.h            |   5 +-
 drivers/net/ethernet/qualcomm/qca_uart.c           | 419 +++++++++++++++++++++
 drivers/tty/serdev/core.c                          |  33 ++
 drivers/tty/serdev/serdev-ttyport.c                |  49 ++-
 include/linux/serdev.h                             |  22 ++
 14 files changed, 634 insertions(+), 50 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
 rename drivers/net/ethernet/qualcomm/{qca_framing.c => qca_common.c} (86%)
 rename drivers/net/ethernet/qualcomm/{qca_framing.h => qca_common.h} (90%)
 create mode 100644 drivers/net/ethernet/qualcomm/qca_uart.c

-- 
2.1.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 01/10] net: qualcomm: remove unnecessary includes
@ 2017-03-27 13:37   ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

Most of the includes in qca_7k.c are unnecessary so we better remove them.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/qca_7k.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c
index f0066fb..557d53c 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.c
+++ b/drivers/net/ethernet/qualcomm/qca_7k.c
@@ -23,11 +23,7 @@
  *   kernel-based SPI device.
  */
 
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/spi/spi.h>
-#include <linux/version.h>
 
 #include "qca_7k.h"
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 01/10] net: qualcomm: remove unnecessary includes
@ 2017-03-27 13:37   ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren

Most of the includes in qca_7k.c are unnecessary so we better remove them.

Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
 drivers/net/ethernet/qualcomm/qca_7k.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c
index f0066fb..557d53c 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.c
+++ b/drivers/net/ethernet/qualcomm/qca_7k.c
@@ -23,11 +23,7 @@
  *   kernel-based SPI device.
  */
 
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/spi/spi.h>
-#include <linux/version.h>
 
 #include "qca_7k.h"
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 02/10] net: qca_debug: use net_device_ops instead of direct call
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
  2017-03-27 13:37   ` Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 13:37 ` [PATCH RFC v4 03/10] net: qualcomm: move qcaspi_tx_cmd to qca_spi.c Stefan Wahren
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

There is no need to export qcaspi_netdev_open and qcaspi_netdev_close
because they are also accessible via the net_device_ops.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/qca_debug.c | 5 +++--
 drivers/net/ethernet/qualcomm/qca_spi.h   | 3 ---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index d145df9..92b6be9 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -275,6 +275,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 static int
 qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
+	const struct net_device_ops *ops = dev->netdev_ops;
 	struct qcaspi *qca = netdev_priv(dev);
 
 	if ((ring->rx_pending) ||
@@ -283,13 +284,13 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 		return -EINVAL;
 
 	if (netif_running(dev))
-		qcaspi_netdev_close(dev);
+		ops->ndo_stop(dev);
 
 	qca->txr.count = max_t(u32, ring->tx_pending, TX_RING_MIN_LEN);
 	qca->txr.count = min_t(u16, qca->txr.count, TX_RING_MAX_LEN);
 
 	if (netif_running(dev))
-		qcaspi_netdev_open(dev);
+		ops->ndo_open(dev);
 
 	return 0;
 }
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index 6e31a0e..064853d 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -108,7 +108,4 @@ struct qcaspi {
 	u16 burst_len;
 };
 
-int qcaspi_netdev_open(struct net_device *dev);
-int qcaspi_netdev_close(struct net_device *dev);
-
 #endif /* _QCA_SPI_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 03/10] net: qualcomm: move qcaspi_tx_cmd to qca_spi.c
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
  2017-03-27 13:37   ` Stefan Wahren
  2017-03-27 13:37 ` [PATCH RFC v4 02/10] net: qca_debug: use net_device_ops instead of direct call Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 13:37 ` [PATCH RFC v4 04/10] net: qualcomm: rename qca_framing.c to qca_common.c Stefan Wahren
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

The function qcaspi_tx_cmd() is only called from qca_spi.c. So we better
move it there.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/qca_7k.c  | 24 ------------------------
 drivers/net/ethernet/qualcomm/qca_7k.h  |  1 -
 drivers/net/ethernet/qualcomm/qca_spi.c | 24 ++++++++++++++++++++++++
 3 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c
index 557d53c..aa90a1d 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.c
+++ b/drivers/net/ethernet/qualcomm/qca_7k.c
@@ -119,27 +119,3 @@ qcaspi_write_register(struct qcaspi *qca, u16 reg, u16 value)
 
 	return ret;
 }
-
-int
-qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd)
-{
-	__be16 tx_data;
-	struct spi_message *msg = &qca->spi_msg1;
-	struct spi_transfer *transfer = &qca->spi_xfer1;
-	int ret;
-
-	tx_data = cpu_to_be16(cmd);
-	transfer->len = sizeof(tx_data);
-	transfer->tx_buf = &tx_data;
-	transfer->rx_buf = NULL;
-
-	ret = spi_sync(qca->spi_dev, msg);
-
-	if (!ret)
-		ret = msg->status;
-
-	if (ret)
-		qcaspi_spi_error(qca);
-
-	return ret;
-}
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.h b/drivers/net/ethernet/qualcomm/qca_7k.h
index 1cad851..b390b1f 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.h
+++ b/drivers/net/ethernet/qualcomm/qca_7k.h
@@ -67,6 +67,5 @@
 void qcaspi_spi_error(struct qcaspi *qca);
 int qcaspi_read_register(struct qcaspi *qca, u16 reg, u16 *result);
 int qcaspi_write_register(struct qcaspi *qca, u16 reg, u16 value);
-int qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd);
 
 #endif /* _QCA_7K_H */
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 513e6c7..4f431bc 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -193,6 +193,30 @@ qcaspi_read_legacy(struct qcaspi *qca, u8 *dst, u32 len)
 }
 
 static int
+qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd)
+{
+	__be16 tx_data;
+	struct spi_message *msg = &qca->spi_msg1;
+	struct spi_transfer *transfer = &qca->spi_xfer1;
+	int ret;
+
+	tx_data = cpu_to_be16(cmd);
+	transfer->len = sizeof(tx_data);
+	transfer->tx_buf = &tx_data;
+	transfer->rx_buf = NULL;
+
+	ret = spi_sync(qca->spi_dev, msg);
+
+	if (!ret)
+		ret = msg->status;
+
+	if (ret)
+		qcaspi_spi_error(qca);
+
+	return ret;
+}
+
+static int
 qcaspi_tx_frame(struct qcaspi *qca, struct sk_buff *skb)
 {
 	u32 count;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 04/10] net: qualcomm: rename qca_framing.c to qca_common.c
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
                   ` (2 preceding siblings ...)
  2017-03-27 13:37 ` [PATCH RFC v4 03/10] net: qualcomm: move qcaspi_tx_cmd to qca_spi.c Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 13:37   ` Stefan Wahren
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

As preparation for the upcoming UART driver we need a module
which contains common functions for both interfaces. The module
qca_framing is a good candidate but renaming to qca_common would
make it clear.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/Makefile                        | 2 +-
 drivers/net/ethernet/qualcomm/{qca_framing.c => qca_common.c} | 2 +-
 drivers/net/ethernet/qualcomm/{qca_framing.h => qca_common.h} | 0
 drivers/net/ethernet/qualcomm/qca_spi.c                       | 2 +-
 drivers/net/ethernet/qualcomm/qca_spi.h                       | 2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename drivers/net/ethernet/qualcomm/{qca_framing.c => qca_common.c} (99%)
 rename drivers/net/ethernet/qualcomm/{qca_framing.h => qca_common.h} (100%)

diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index aacb0a5..8080570 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -3,6 +3,6 @@
 #
 
 obj-$(CONFIG_QCA7000) += qcaspi.o
-qcaspi-objs := qca_spi.o qca_framing.o qca_7k.o qca_debug.o
+qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
 
 obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.c b/drivers/net/ethernet/qualcomm/qca_common.c
similarity index 99%
rename from drivers/net/ethernet/qualcomm/qca_framing.c
rename to drivers/net/ethernet/qualcomm/qca_common.c
index faa924c..26453a9 100644
--- a/drivers/net/ethernet/qualcomm/qca_framing.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -23,7 +23,7 @@
 
 #include <linux/kernel.h>
 
-#include "qca_framing.h"
+#include "qca_common.h"
 
 u16
 qcafrm_create_header(u8 *buf, u16 length)
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.h b/drivers/net/ethernet/qualcomm/qca_common.h
similarity index 100%
rename from drivers/net/ethernet/qualcomm/qca_framing.h
rename to drivers/net/ethernet/qualcomm/qca_common.h
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 4f431bc..65adc10 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -43,8 +43,8 @@
 #include <linux/types.h>
 
 #include "qca_7k.h"
+#include "qca_common.h"
 #include "qca_debug.h"
-#include "qca_framing.h"
 #include "qca_spi.h"
 
 #define MAX_DMA_BURST_LEN 5000
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index 064853d..cce4802 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -32,7 +32,7 @@
 #include <linux/spi/spi.h>
 #include <linux/types.h>
 
-#include "qca_framing.h"
+#include "qca_common.h"
 
 #define QCASPI_DRV_VERSION "0.2.7-i"
 #define QCASPI_DRV_NAME    "qcaspi"
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 05/10] net: qualcomm: prepare frame decoding for UART driver
@ 2017-03-27 13:37   ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

Unfortunately the frame format is not exactly identical between SPI
and UART. In case of SPI there is an additional HW length at the
beginning. So store the initial state to make the decoding state machine
more flexible and easy to extend for UART support.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/qca_common.c | 12 ++++++------
 drivers/net/ethernet/qualcomm/qca_common.h |  8 ++++++--
 drivers/net/ethernet/qualcomm/qca_spi.c    |  2 +-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index 26453a9..d930524 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -83,7 +83,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 
 		if (recv_byte != 0x00) {
 			/* first two bytes of length must be 0 */
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		}
 		break;
 	case QCAFRM_HW_LEN2:
@@ -97,7 +97,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 	case QCAFRM_WAIT_AA4:
 		if (recv_byte != 0xAA) {
 			ret = QCAFRM_NOHEAD;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			handle->state--;
 		}
@@ -119,7 +119,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 		len = handle->offset;
 		if (len > buf_len || len < QCAFRM_ETHMINLEN) {
 			ret = QCAFRM_INVLEN;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			handle->state = (enum qcafrm_state)(len + 1);
 			/* Remaining number of bytes. */
@@ -135,7 +135,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 	case QCAFRM_WAIT_551:
 		if (recv_byte != 0x55) {
 			ret = QCAFRM_NOTAIL;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			handle->state = QCAFRM_WAIT_552;
 		}
@@ -143,11 +143,11 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 	case QCAFRM_WAIT_552:
 		if (recv_byte != 0x55) {
 			ret = QCAFRM_NOTAIL;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			ret = handle->offset;
 			/* Frame is fully received. */
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		}
 		break;
 	}
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
index d5e795d..431f99d 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -61,6 +61,7 @@
 #define QCAFRM_ERR_BASE -1000
 
 enum qcafrm_state {
+	/* HW length is only available on SPI */
 	QCAFRM_HW_LEN0 = 0x8000,
 	QCAFRM_HW_LEN1 = QCAFRM_HW_LEN0 - 1,
 	QCAFRM_HW_LEN2 = QCAFRM_HW_LEN1 - 1,
@@ -101,6 +102,8 @@ enum qcafrm_state {
 struct qcafrm_handle {
 	/*  Current decoding state */
 	enum qcafrm_state state;
+	/* Initial state depends on connection type */
+	enum qcafrm_state init;
 
 	/* Offset in buffer (borrowed for length too) */
 	s16 offset;
@@ -113,9 +116,10 @@ u16 qcafrm_create_header(u8 *buf, u16 len);
 
 u16 qcafrm_create_footer(u8 *buf);
 
-static inline void qcafrm_fsm_init(struct qcafrm_handle *handle)
+static inline void qcafrm_fsm_init_spi(struct qcafrm_handle *handle)
 {
-	handle->state = QCAFRM_HW_LEN0;
+	handle->init = QCAFRM_HW_LEN0;
+	handle->state = handle->init;
 }
 
 /*   Gather received bytes and try to extract a full Ethernet frame
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 65adc10..3617bde 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -638,7 +638,7 @@ qcaspi_netdev_open(struct net_device *dev)
 	qca->intr_req = 1;
 	qca->intr_svc = 0;
 	qca->sync = QCASPI_SYNC_UNKNOWN;
-	qcafrm_fsm_init(&qca->frm_handle);
+	qcafrm_fsm_init_spi(&qca->frm_handle);
 
 	qca->spi_thread = kthread_run((void *)qcaspi_spi_thread,
 				      qca, "%s", dev->name);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 05/10] net: qualcomm: prepare frame decoding for UART driver
@ 2017-03-27 13:37   ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren

Unfortunately the frame format is not exactly identical between SPI
and UART. In case of SPI there is an additional HW length at the
beginning. So store the initial state to make the decoding state machine
more flexible and easy to extend for UART support.

Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
 drivers/net/ethernet/qualcomm/qca_common.c | 12 ++++++------
 drivers/net/ethernet/qualcomm/qca_common.h |  8 ++++++--
 drivers/net/ethernet/qualcomm/qca_spi.c    |  2 +-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index 26453a9..d930524 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -83,7 +83,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 
 		if (recv_byte != 0x00) {
 			/* first two bytes of length must be 0 */
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		}
 		break;
 	case QCAFRM_HW_LEN2:
@@ -97,7 +97,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 	case QCAFRM_WAIT_AA4:
 		if (recv_byte != 0xAA) {
 			ret = QCAFRM_NOHEAD;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			handle->state--;
 		}
@@ -119,7 +119,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 		len = handle->offset;
 		if (len > buf_len || len < QCAFRM_ETHMINLEN) {
 			ret = QCAFRM_INVLEN;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			handle->state = (enum qcafrm_state)(len + 1);
 			/* Remaining number of bytes. */
@@ -135,7 +135,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 	case QCAFRM_WAIT_551:
 		if (recv_byte != 0x55) {
 			ret = QCAFRM_NOTAIL;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			handle->state = QCAFRM_WAIT_552;
 		}
@@ -143,11 +143,11 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 	case QCAFRM_WAIT_552:
 		if (recv_byte != 0x55) {
 			ret = QCAFRM_NOTAIL;
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		} else {
 			ret = handle->offset;
 			/* Frame is fully received. */
-			handle->state = QCAFRM_HW_LEN0;
+			handle->state = handle->init;
 		}
 		break;
 	}
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
index d5e795d..431f99d 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -61,6 +61,7 @@
 #define QCAFRM_ERR_BASE -1000
 
 enum qcafrm_state {
+	/* HW length is only available on SPI */
 	QCAFRM_HW_LEN0 = 0x8000,
 	QCAFRM_HW_LEN1 = QCAFRM_HW_LEN0 - 1,
 	QCAFRM_HW_LEN2 = QCAFRM_HW_LEN1 - 1,
@@ -101,6 +102,8 @@ enum qcafrm_state {
 struct qcafrm_handle {
 	/*  Current decoding state */
 	enum qcafrm_state state;
+	/* Initial state depends on connection type */
+	enum qcafrm_state init;
 
 	/* Offset in buffer (borrowed for length too) */
 	s16 offset;
@@ -113,9 +116,10 @@ u16 qcafrm_create_header(u8 *buf, u16 len);
 
 u16 qcafrm_create_footer(u8 *buf);
 
-static inline void qcafrm_fsm_init(struct qcafrm_handle *handle)
+static inline void qcafrm_fsm_init_spi(struct qcafrm_handle *handle)
 {
-	handle->state = QCAFRM_HW_LEN0;
+	handle->init = QCAFRM_HW_LEN0;
+	handle->state = handle->init;
 }
 
 /*   Gather received bytes and try to extract a full Ethernet frame
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 65adc10..3617bde 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -638,7 +638,7 @@ qcaspi_netdev_open(struct net_device *dev)
 	qca->intr_req = 1;
 	qca->intr_svc = 0;
 	qca->sync = QCASPI_SYNC_UNKNOWN;
-	qcafrm_fsm_init(&qca->frm_handle);
+	qcafrm_fsm_init_spi(&qca->frm_handle);
 
 	qca->spi_thread = kthread_run((void *)qcaspi_spi_thread,
 				      qca, "%s", dev->name);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 06/10] net: qualcomm: make qca_common a separate kernel module
@ 2017-03-27 13:37   ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

In order to share common functions between QCA7000 SPI and UART protocol
driver the qca_common needs to be a separate kernel module.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/Kconfig      |  8 +++++++-
 drivers/net/ethernet/qualcomm/Makefile     |  5 +++--
 drivers/net/ethernet/qualcomm/qca_common.c | 10 ++++++++++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index d7720bf..b4c369d 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -16,7 +16,13 @@ config NET_VENDOR_QUALCOMM
 if NET_VENDOR_QUALCOMM
 
 config QCA7000
-	tristate "Qualcomm Atheros QCA7000 support"
+	tristate
+	help
+	  This enables support for the Qualcomm Atheros QCA7000.
+
+config QCA7000_SPI
+	tristate "Qualcomm Atheros QCA7000 SPI support"
+	select QCA7000
 	depends on SPI_MASTER && OF
 	---help---
 	  This SPI protocol driver supports the Qualcomm Atheros QCA7000.
diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index 8080570..00d8729 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -2,7 +2,8 @@
 # Makefile for the Qualcomm network device drivers.
 #
 
-obj-$(CONFIG_QCA7000) += qcaspi.o
-qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
+obj-$(CONFIG_QCA7000) += qca_common.o
+obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
+qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
 
 obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index d930524..f2c9e76 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -21,7 +21,9 @@
  *   by an atheros frame while transmitted over a serial channel;
  */
 
+#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 
 #include "qca_common.h"
 
@@ -46,6 +48,7 @@ qcafrm_create_header(u8 *buf, u16 length)
 
 	return QCAFRM_HEADER_LEN;
 }
+EXPORT_SYMBOL_GPL(qcafrm_create_header);
 
 u16
 qcafrm_create_footer(u8 *buf)
@@ -57,6 +60,7 @@ qcafrm_create_footer(u8 *buf)
 	buf[1] = 0x55;
 	return QCAFRM_FOOTER_LEN;
 }
+EXPORT_SYMBOL_GPL(qcafrm_create_footer);
 
 /*   Gather received bytes and try to extract a full ethernet frame by
  *   following a simple state machine.
@@ -154,3 +158,9 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
+
+MODULE_DESCRIPTION("Qualcomm Atheros Common");
+MODULE_AUTHOR("Qualcomm Atheros Communications");
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
+MODULE_LICENSE("Dual BSD/GPL");
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 06/10] net: qualcomm: make qca_common a separate kernel module
@ 2017-03-27 13:37   ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren

In order to share common functions between QCA7000 SPI and UART protocol
driver the qca_common needs to be a separate kernel module.

Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
 drivers/net/ethernet/qualcomm/Kconfig      |  8 +++++++-
 drivers/net/ethernet/qualcomm/Makefile     |  5 +++--
 drivers/net/ethernet/qualcomm/qca_common.c | 10 ++++++++++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index d7720bf..b4c369d 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -16,7 +16,13 @@ config NET_VENDOR_QUALCOMM
 if NET_VENDOR_QUALCOMM
 
 config QCA7000
-	tristate "Qualcomm Atheros QCA7000 support"
+	tristate
+	help
+	  This enables support for the Qualcomm Atheros QCA7000.
+
+config QCA7000_SPI
+	tristate "Qualcomm Atheros QCA7000 SPI support"
+	select QCA7000
 	depends on SPI_MASTER && OF
 	---help---
 	  This SPI protocol driver supports the Qualcomm Atheros QCA7000.
diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index 8080570..00d8729 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -2,7 +2,8 @@
 # Makefile for the Qualcomm network device drivers.
 #
 
-obj-$(CONFIG_QCA7000) += qcaspi.o
-qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
+obj-$(CONFIG_QCA7000) += qca_common.o
+obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
+qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
 
 obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index d930524..f2c9e76 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -21,7 +21,9 @@
  *   by an atheros frame while transmitted over a serial channel;
  */
 
+#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 
 #include "qca_common.h"
 
@@ -46,6 +48,7 @@ qcafrm_create_header(u8 *buf, u16 length)
 
 	return QCAFRM_HEADER_LEN;
 }
+EXPORT_SYMBOL_GPL(qcafrm_create_header);
 
 u16
 qcafrm_create_footer(u8 *buf)
@@ -57,6 +60,7 @@ qcafrm_create_footer(u8 *buf)
 	buf[1] = 0x55;
 	return QCAFRM_FOOTER_LEN;
 }
+EXPORT_SYMBOL_GPL(qcafrm_create_footer);
 
 /*   Gather received bytes and try to extract a full ethernet frame by
  *   following a simple state machine.
@@ -154,3 +158,9 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
+
+MODULE_DESCRIPTION("Qualcomm Atheros Common");
+MODULE_AUTHOR("Qualcomm Atheros Communications");
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>");
+MODULE_LICENSE("Dual BSD/GPL");
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
                   ` (5 preceding siblings ...)
  2017-03-27 13:37   ` Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 20:30     ` Rob Herring
  2017-03-27 13:37 ` [PATCH RFC v4 08/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---

According to this binding are still some questions:

Where should be the optional hardware flow control defined (at master or slave side)?

Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?


 .../devicetree/bindings/net/qca-qca7000-uart.txt   | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-uart.txt

diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
new file mode 100644
index 0000000..f2e0450
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
@@ -0,0 +1,31 @@
+* Qualcomm QCA7000 (Ethernet over UART protocol)
+
+Note: This binding applies in case the QCA7000 is configured as a
+UART slave device. It is possible to preconfigure the UART settings
+of the QCA7000 firmware, which can't be changed during runtime.
+
+Required properties:
+- compatible        : Should be "qca,qca7000-uart"
+
+Optional properties:
+- local-mac-address : 6 bytes, Specifies MAC address
+- current-speed     : Specifies the serial device speed in
+		      bits per second (default = 115200), which is
+		      predefined by the QCA7000 firmware configuration
+
+Example:
+
+/* Freescale i.MX28 UART */
+auart0: serial@8006a000 {
+	compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+	reg = <0x8006a000 0x2000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&auart0_2pins_a>;
+	status = "okay";
+
+	qca7000: ethernet {
+		compatible = "qca,qca7000-uart";
+		local-mac-address = [ A0 B0 C0 D0 E0 F0 ];
+		current-speed = <38400>;
+	};
+};
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 08/10] net: qualcomm: add QCA7000 UART driver
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
                   ` (6 preceding siblings ...)
  2017-03-27 13:37 ` [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 13:37 ` [PATCH RFC v4 09/10] tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate Stefan Wahren
  2017-03-27 13:37 ` [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings Stefan Wahren
  9 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

This patch adds the Ethernet over UART driver for the
Qualcomm QCA7000 HomePlug GreenPHY.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/net/ethernet/qualcomm/Kconfig      |  10 +
 drivers/net/ethernet/qualcomm/Makefile     |   2 +
 drivers/net/ethernet/qualcomm/qca_common.h |   6 +
 drivers/net/ethernet/qualcomm/qca_uart.c   | 419 +++++++++++++++++++++++++++++
 4 files changed, 437 insertions(+)
 create mode 100644 drivers/net/ethernet/qualcomm/qca_uart.c

diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index b4c369d..ad6b5a4 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -30,6 +30,16 @@ config QCA7000_SPI
 	  To compile this driver as a module, choose M here. The module
 	  will be called qcaspi.
 
+config QCA7000_UART
+	tristate "Qualcomm Atheros QCA7000 UART support"
+	select QCA7000
+	depends on SERIAL_DEV_BUS && OF
+	---help---
+	  This UART protocol driver supports the Qualcomm Atheros QCA7000.
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called qcauart.
+
 config QCOM_EMAC
 	tristate "Qualcomm Technologies, Inc. EMAC Gigabit Ethernet support"
 	depends on HAS_DMA && HAS_IOMEM
diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index 00d8729..8847db7 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -5,5 +5,7 @@
 obj-$(CONFIG_QCA7000) += qca_common.o
 obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
 qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
+obj-$(CONFIG_QCA7000_UART) += qcauart.o
+qcauart-objs := qca_uart.o
 
 obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
index 431f99d..539399e 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -122,6 +122,12 @@ static inline void qcafrm_fsm_init_spi(struct qcafrm_handle *handle)
 	handle->state = handle->init;
 }
 
+static inline void qcafrm_fsm_init_uart(struct qcafrm_handle *handle)
+{
+	handle->init = QCAFRM_WAIT_AA1;
+	handle->state = handle->init;
+}
+
 /*   Gather received bytes and try to extract a full Ethernet frame
  *   by following a simple state machine.
  *
diff --git a/drivers/net/ethernet/qualcomm/qca_uart.c b/drivers/net/ethernet/qualcomm/qca_uart.c
new file mode 100644
index 0000000..81a0353
--- /dev/null
+++ b/drivers/net/ethernet/qualcomm/qca_uart.c
@@ -0,0 +1,419 @@
+/*
+ *   Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
+ *   Copyright (c) 2017, I2SE GmbH
+ *
+ *   Permission to use, copy, modify, and/or distribute this software
+ *   for any purpose with or without fee is hereby granted, provided
+ *   that the above copyright notice and this permission notice appear
+ *   in all copies.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ *   WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ *   WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ *   THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ *   LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ *   NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ *   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*   This module implements the Qualcomm Atheros UART protocol for
+ *   kernel-based UART device; it is essentially an Ethernet-to-UART
+ *   serial converter;
+ */
+
+#include <linux/errno.h>
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_net.h>
+#include <linux/sched.h>
+#include <linux/serdev.h>
+#include <linux/skbuff.h>
+#include <linux/types.h>
+
+#include "qca_common.h"
+
+#define QCAUART_DRV_VERSION "0.1.0"
+#define QCAUART_DRV_NAME "qcauart"
+#define QCAUART_TX_TIMEOUT (1 * HZ)
+
+struct qcauart {
+	struct net_device *net_dev;
+	spinlock_t lock;			/* transmit lock */
+	struct work_struct tx_work;		/* Flushes transmit buffer   */
+
+	struct serdev_device *serdev;
+
+	unsigned char xbuff[QCAFRM_ETHMAXMTU];	/* transmitter buffer        */
+	unsigned char *xhead;			/* pointer to next XMIT byte */
+	int xleft;				/* bytes left in XMIT queue  */
+
+	struct qcafrm_handle frm_handle;
+
+	struct sk_buff *rx_skb;
+};
+
+static int
+qca_tty_receive(struct serdev_device *serdev, const unsigned char *data,
+		size_t count)
+{
+	struct qcauart *qca = serdev_device_get_drvdata(serdev);
+	struct net_device_stats *n_stats = &qca->net_dev->stats;
+	size_t i;
+
+	if (!qca->rx_skb) {
+		qca->rx_skb = netdev_alloc_skb(qca->net_dev, qca->net_dev->mtu +
+					       VLAN_ETH_HLEN);
+		if (!qca->rx_skb) {
+			n_stats->rx_errors++;
+			n_stats->rx_dropped++;
+			return 0;
+		}
+	}
+
+	for (i = 0; i < count; i++) {
+		s32 retcode;
+
+		retcode = qcafrm_fsm_decode(&qca->frm_handle,
+					    qca->rx_skb->data,
+					    skb_tailroom(qca->rx_skb),
+					    data[i]);
+
+		switch (retcode) {
+		case QCAFRM_GATHER:
+		case QCAFRM_NOHEAD:
+			break;
+		case QCAFRM_NOTAIL:
+			netdev_dbg(qca->net_dev, "recv: no RX tail\n");
+			n_stats->rx_errors++;
+			n_stats->rx_dropped++;
+			break;
+		case QCAFRM_INVLEN:
+			netdev_dbg(qca->net_dev, "recv: invalid RX length\n");
+			n_stats->rx_errors++;
+			n_stats->rx_dropped++;
+			break;
+		default:
+			qca->rx_skb->dev = qca->net_dev;
+			n_stats->rx_packets++;
+			n_stats->rx_bytes += retcode;
+			skb_put(qca->rx_skb, retcode);
+			qca->rx_skb->protocol = eth_type_trans(
+						qca->rx_skb, qca->rx_skb->dev);
+			qca->rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
+			netif_rx_ni(qca->rx_skb);
+			qca->rx_skb = netdev_alloc_skb(qca->net_dev,
+						       qca->net_dev->mtu +
+						       VLAN_ETH_HLEN);
+			if (!qca->rx_skb) {
+				netdev_dbg(qca->net_dev, "recv: out of RX resources\n");
+				n_stats->rx_errors++;
+				break;
+			}
+		}
+	}
+
+	return i;
+}
+
+/* Write out any remaining transmit buffer. Scheduled when tty is writable */
+static void qcauart_transmit(struct work_struct *work)
+{
+	struct qcauart *qca = container_of(work, struct qcauart, tx_work);
+	struct net_device_stats *n_stats = &qca->net_dev->stats;
+	int written;
+
+	spin_lock_bh(&qca->lock);
+
+	/* First make sure we're connected. */
+	if (!netif_running(qca->net_dev)) {
+		spin_unlock_bh(&qca->lock);
+		return;
+	}
+
+	if (qca->xleft <= 0)  {
+		/* Now serial buffer is almost free & we can start
+		 * transmission of another packet
+		 */
+		n_stats->tx_packets++;
+		spin_unlock_bh(&qca->lock);
+		netif_wake_queue(qca->net_dev);
+		return;
+	}
+
+	written = serdev_device_write_buf(qca->serdev, qca->xhead, qca->xleft);
+	if (written > 0) {
+		qca->xleft -= written;
+		qca->xhead += written;
+	}
+	spin_unlock_bh(&qca->lock);
+}
+
+/* Called by the driver when there's room for more data.
+ * Schedule the transmit.
+ */
+static void qca_tty_wakeup(struct serdev_device *serdev)
+{
+	struct qcauart *qca = serdev_device_get_drvdata(serdev);
+
+	schedule_work(&qca->tx_work);
+}
+
+static struct serdev_device_ops qca_serdev_ops = {
+	.receive_buf = qca_tty_receive,
+	.write_wakeup = qca_tty_wakeup,
+};
+
+int
+qcauart_netdev_open(struct net_device *dev)
+{
+	struct qcauart *qca = netdev_priv(dev);
+
+	qcafrm_fsm_init_uart(&qca->frm_handle);
+	netif_start_queue(qca->net_dev);
+
+	return 0;
+}
+
+int
+qcauart_netdev_close(struct net_device *dev)
+{
+	struct qcauart *qca = netdev_priv(dev);
+
+	spin_lock_bh(&qca->lock);
+	netif_stop_queue(dev);
+	qca->xleft = 0;
+	spin_unlock_bh(&qca->lock);
+
+	return 0;
+}
+
+netdev_tx_t
+qcauart_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct net_device_stats *n_stats = &dev->stats;
+	struct qcauart *qca = netdev_priv(dev);
+	u8 pad_len = 0;
+	int written;
+	u8 *pos;
+
+	spin_lock(&qca->lock);
+
+	if (!netif_running(dev))  {
+		spin_unlock(&qca->lock);
+		netdev_warn(qca->net_dev, "xmit: iface is down\n");
+		goto out;
+	}
+
+	pos = qca->xbuff;
+
+	if (skb->len < QCAFRM_ETHMINLEN)
+		pad_len = QCAFRM_ETHMINLEN - skb->len;
+
+	pos += qcafrm_create_header(pos, skb->len + pad_len);
+
+	memcpy(pos, skb->data, skb->len);
+	pos += skb->len;
+
+	if (pad_len) {
+		memset(pos, 0, pad_len);
+		pos += pad_len;
+	}
+
+	pos += qcafrm_create_footer(pos);
+
+	netif_stop_queue(qca->net_dev);
+
+	written = serdev_device_write_buf(qca->serdev, qca->xbuff,
+					  pos - qca->xbuff);
+	if (written > 0) {
+		qca->xleft = (pos - qca->xbuff) - written;
+		qca->xhead = qca->xbuff + written;
+		n_stats->tx_bytes += written;
+	}
+	spin_unlock(&qca->lock);
+
+	netif_trans_update(dev);
+out:
+	kfree_skb(skb);
+	return NETDEV_TX_OK;
+}
+
+void
+qcauart_netdev_tx_timeout(struct net_device *dev)
+{
+	struct qcauart *qca = netdev_priv(dev);
+
+	netdev_info(qca->net_dev, "Transmit timeout at %ld, latency %ld\n",
+		    jiffies, dev_trans_start(dev));
+	dev->stats.tx_errors++;
+	dev->stats.tx_dropped++;
+}
+
+static int
+qcauart_netdev_init(struct net_device *dev)
+{
+	struct qcauart *qca = netdev_priv(dev);
+
+	/* Finish setting up the device info. */
+	dev->mtu = QCAFRM_ETHMAXMTU;
+	dev->type = ARPHRD_ETHER;
+
+	qca->rx_skb = netdev_alloc_skb(qca->net_dev,
+				       qca->net_dev->mtu + VLAN_ETH_HLEN);
+	if (!qca->rx_skb)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void
+qcauart_netdev_uninit(struct net_device *dev)
+{
+	struct qcauart *qca = netdev_priv(dev);
+
+	if (qca->rx_skb)
+		dev_kfree_skb(qca->rx_skb);
+}
+
+static const struct net_device_ops qcauart_netdev_ops = {
+	.ndo_init = qcauart_netdev_init,
+	.ndo_uninit = qcauart_netdev_uninit,
+	.ndo_open = qcauart_netdev_open,
+	.ndo_stop = qcauart_netdev_close,
+	.ndo_start_xmit = qcauart_netdev_xmit,
+	.ndo_set_mac_address = eth_mac_addr,
+	.ndo_tx_timeout = qcauart_netdev_tx_timeout,
+	.ndo_validate_addr = eth_validate_addr,
+};
+
+static void
+qcauart_netdev_setup(struct net_device *dev)
+{
+	struct qcauart *qca;
+
+	dev->netdev_ops = &qcauart_netdev_ops;
+	dev->watchdog_timeo = QCAUART_TX_TIMEOUT;
+	dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+	dev->tx_queue_len = 100;
+
+	/* MTU range: 46 - 1500 */
+	dev->min_mtu = QCAFRM_ETHMINMTU;
+	dev->max_mtu = QCAFRM_ETHMAXMTU;
+
+	qca = netdev_priv(dev);
+	memset(qca, 0, sizeof(struct qcauart));
+}
+
+static const struct of_device_id qca_uart_of_match[] = {
+	{
+	 .compatible = "qca,qca7000-uart",
+	},
+	{}
+};
+MODULE_DEVICE_TABLE(of, qca_uart_of_match);
+
+static int qca_uart_probe(struct serdev_device *serdev)
+{
+	struct net_device *qcauart_dev = alloc_etherdev(sizeof(struct qcauart));
+	struct qcauart *qca;
+	const char *mac;
+	u32 speed = 115200;
+	int ret;
+
+	if (!qcauart_dev)
+		return -ENOMEM;
+
+	qcauart_netdev_setup(qcauart_dev);
+
+	qca = netdev_priv(qcauart_dev);
+	if (!qca) {
+		pr_err("qca_uart: Fail to retrieve private structure\n");
+		ret = -ENOMEM;
+		goto free;
+	}
+	qca->net_dev = qcauart_dev;
+	qca->serdev = serdev;
+
+	spin_lock_init(&qca->lock);
+	INIT_WORK(&qca->tx_work, qcauart_transmit);
+
+	of_property_read_u32(serdev->dev.of_node, "current-speed", &speed);
+
+	mac = of_get_mac_address(serdev->dev.of_node);
+
+	if (mac)
+		ether_addr_copy(qca->net_dev->dev_addr, mac);
+
+	if (!is_valid_ether_addr(qca->net_dev->dev_addr)) {
+		eth_hw_addr_random(qca->net_dev);
+		dev_info(&serdev->dev, "Using random MAC address: %pM\n",
+			 qca->net_dev->dev_addr);
+	}
+
+	netif_carrier_on(qca->net_dev);
+	serdev_device_set_drvdata(serdev, qca);
+	serdev_device_set_client_ops(serdev, &qca_serdev_ops);
+
+	ret = serdev_device_open(serdev);
+	if (ret) {
+		dev_err(&serdev->dev, "Unable to open device %s\n",
+			qcauart_dev->name);
+		goto free;
+	}
+
+	speed = serdev_device_set_baudrate(serdev, speed);
+	dev_info(&serdev->dev, "Using baudrate: %u\n", speed);
+
+	serdev_device_set_flow_control(serdev, false);
+
+	ret = register_netdev(qcauart_dev);
+	if (ret) {
+		dev_err(&serdev->dev, "Unable to register net device %s\n",
+			qcauart_dev->name);
+		goto free;
+	}
+
+	return 0;
+
+free:
+	free_netdev(qcauart_dev);
+	return ret;
+}
+
+static void qca_uart_remove(struct serdev_device *serdev)
+{
+	struct qcauart *qca = serdev_device_get_drvdata(serdev);
+
+	/* Flush any pending characters in the driver. */
+	serdev_device_close(serdev);
+
+	netif_carrier_off(qca->net_dev);
+	unregister_netdev(qca->net_dev);
+	free_netdev(qca->net_dev);
+}
+
+static struct serdev_device_driver qca_uart_driver = {
+	.probe = qca_uart_probe,
+	.remove = qca_uart_remove,
+	.driver = {
+		.name = QCAUART_DRV_NAME,
+		.of_match_table = of_match_ptr(qca_uart_of_match),
+	},
+};
+
+module_serdev_device_driver(qca_uart_driver);
+
+MODULE_DESCRIPTION("Qualcomm Atheros UART Driver");
+MODULE_AUTHOR("Qualcomm Atheros Communications");
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(QCAUART_DRV_VERSION);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 09/10] tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
                   ` (7 preceding siblings ...)
  2017-03-27 13:37 ` [PATCH RFC v4 08/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 19:50   ` Rob Herring
  2017-03-27 13:37 ` [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings Stefan Wahren
  9 siblings, 1 reply; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

Instead of returning the requested baudrate, we better return the
actual one because it isn't always the same.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/tty/serdev/serdev-ttyport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index d053935..8a30abe 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -150,7 +150,7 @@ static unsigned int ttyport_set_baudrate(struct serdev_controller *ctrl, unsigne
 
 	/* tty_set_termios() return not checked as it is always 0 */
 	tty_set_termios(tty, &ktermios);
-	return speed;
+	return ktermios.c_ospeed;
 }
 
 static void ttyport_set_flow_control(struct serdev_controller *ctrl, bool enable)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings
  2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
                   ` (8 preceding siblings ...)
  2017-03-27 13:37 ` [PATCH RFC v4 09/10] tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate Stefan Wahren
@ 2017-03-27 13:37 ` Stefan Wahren
  2017-03-27 20:00   ` Rob Herring
  9 siblings, 1 reply; 26+ messages in thread
From: Stefan Wahren @ 2017-03-27 13:37 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel, Stefan Wahren

Currently serdev core doesn't provide functions to retrieve common
UART settings like data bits, stop bits or parity. This patch adds
the interface to the core and the necessary implementation for
serdev-ttyport.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/tty/serdev/core.c           | 33 ++++++++++++++++++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 47 +++++++++++++++++++++++++++++++++++++
 include/linux/serdev.h              | 22 +++++++++++++++++
 3 files changed, 102 insertions(+)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 531aa89..7b1e5bf 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -173,6 +173,39 @@ void serdev_device_set_flow_control(struct serdev_device *serdev, bool enable)
 }
 EXPORT_SYMBOL_GPL(serdev_device_set_flow_control);
 
+int serdev_device_get_data_bits(struct serdev_device *serdev)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->get_data_bits)
+		return -EINVAL;
+
+	return ctrl->ops->get_data_bits(ctrl);
+}
+EXPORT_SYMBOL_GPL(serdev_device_get_data_bits);
+
+int serdev_device_get_parity(struct serdev_device *serdev)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->get_parity)
+		return -EINVAL;
+
+	return ctrl->ops->get_parity(ctrl);
+}
+EXPORT_SYMBOL_GPL(serdev_device_get_parity);
+
+int serdev_device_get_stop_bits(struct serdev_device *serdev)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->get_stop_bits)
+		return -EINVAL;
+
+	return ctrl->ops->get_stop_bits(ctrl);
+}
+EXPORT_SYMBOL_GPL(serdev_device_get_stop_bits);
+
 static int serdev_drv_probe(struct device *dev)
 {
 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index 8a30abe..5698682 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -167,6 +167,50 @@ static void ttyport_set_flow_control(struct serdev_controller *ctrl, bool enable
 	tty_set_termios(tty, &ktermios);
 }
 
+static int ttyport_get_data_bits(struct serdev_controller *ctrl)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+	struct ktermios ktermios = tty->termios;
+
+	switch (ktermios.c_cflag & CSIZE) {
+	case CS5:
+		return 5;
+	case CS6:
+		return 6;
+	case CS7:
+		return 7;
+	case CS8:
+		return 8;
+	}
+
+	return 0;
+}
+
+static int ttyport_get_parity(struct serdev_controller *ctrl)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+	struct ktermios ktermios = tty->termios;
+
+	if (!(ktermios.c_cflag & PARENB))
+		return SERDEV_PARITY_NONE;
+
+	if (ktermios.c_cflag & PARODD)
+		return SERDEV_PARITY_ODD;
+
+	return SERDEV_PARITY_EVEN;
+}
+
+static int ttyport_get_stop_bits(struct serdev_controller *ctrl)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+	struct ktermios ktermios = tty->termios;
+
+	return (ktermios.c_cflag & CSTOPB) ? 2 : 1;
+}
+
 static const struct serdev_controller_ops ctrl_ops = {
 	.write_buf = ttyport_write_buf,
 	.write_flush = ttyport_write_flush,
@@ -175,6 +219,9 @@ static const struct serdev_controller_ops ctrl_ops = {
 	.close = ttyport_close,
 	.set_flow_control = ttyport_set_flow_control,
 	.set_baudrate = ttyport_set_baudrate,
+	.get_data_bits = ttyport_get_data_bits,
+	.get_parity = ttyport_get_parity,
+	.get_stop_bits = ttyport_get_stop_bits,
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 5176cdc..6180aa2 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -16,6 +16,10 @@
 #include <linux/types.h>
 #include <linux/device.h>
 
+#define SERDEV_PARITY_NONE	0
+#define SERDEV_PARITY_ODD	1
+#define SERDEV_PARITY_EVEN	2
+
 struct serdev_controller;
 struct serdev_device;
 
@@ -81,6 +85,9 @@ struct serdev_controller_ops {
 	void (*close)(struct serdev_controller *);
 	void (*set_flow_control)(struct serdev_controller *, bool);
 	unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int);
+	int (*get_data_bits)(struct serdev_controller *);
+	int (*get_parity)(struct serdev_controller *);
+	int (*get_stop_bits)(struct serdev_controller *);
 };
 
 /**
@@ -189,6 +196,9 @@ void serdev_device_set_flow_control(struct serdev_device *, bool);
 int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
 void serdev_device_write_flush(struct serdev_device *);
 int serdev_device_write_room(struct serdev_device *);
+int serdev_device_get_data_bits(struct serdev_device *);
+int serdev_device_get_parity(struct serdev_device *);
+int serdev_device_get_stop_bits(struct serdev_device *);
 
 /*
  * serdev device driver functions
@@ -232,6 +242,18 @@ static inline int serdev_device_write_room(struct serdev_device *sdev)
 {
 	return 0;
 }
+static inline int serdev_device_get_data_bits(struct serdev_device *sdev)
+{
+	return -ENODEV;
+}
+static inline int serdev_device_get_parity(struct serdev_device *sdev)
+{
+	return -ENODEV;
+}
+static inline int serdev_device_get_stop_bits(struct serdev_device *sdev)
+{
+	return -ENODEV;
+}
 
 #define serdev_device_driver_register(x)
 #define serdev_device_driver_unregister(x)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 06/10] net: qualcomm: make qca_common a separate kernel module
  2017-03-27 13:37   ` Stefan Wahren
  (?)
@ 2017-03-27 15:44   ` Dan Williams
  2017-03-28 16:24     ` Stefan Wahren
  -1 siblings, 1 reply; 26+ messages in thread
From: Dan Williams @ 2017-03-27 15:44 UTC (permalink / raw)
  To: Stefan Wahren, Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel

On Mon, 2017-03-27 at 15:37 +0200, Stefan Wahren wrote:
> In order to share common functions between QCA7000 SPI and UART
> protocol
> driver the qca_common needs to be a separate kernel module.

Maybe "qca_eth_common"?  There are many things Qualcomm, slightly fewer
things Qualcomm Atheros, and "qca_common" isn't very descriptive.

Dan

> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/net/ethernet/qualcomm/Kconfig      |  8 +++++++-
>  drivers/net/ethernet/qualcomm/Makefile     |  5 +++--
>  drivers/net/ethernet/qualcomm/qca_common.c | 10 ++++++++++
>  3 files changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/qualcomm/Kconfig
> b/drivers/net/ethernet/qualcomm/Kconfig
> index d7720bf..b4c369d 100644
> --- a/drivers/net/ethernet/qualcomm/Kconfig
> +++ b/drivers/net/ethernet/qualcomm/Kconfig
> @@ -16,7 +16,13 @@ config NET_VENDOR_QUALCOMM
>  if NET_VENDOR_QUALCOMM
>  
>  config QCA7000
> -	tristate "Qualcomm Atheros QCA7000 support"
> +	tristate
> +	help
> +	  This enables support for the Qualcomm Atheros QCA7000.
> +
> +config QCA7000_SPI
> +	tristate "Qualcomm Atheros QCA7000 SPI support"
> +	select QCA7000
>  	depends on SPI_MASTER && OF
>  	---help---
>  	  This SPI protocol driver supports the Qualcomm Atheros
> QCA7000.
> diff --git a/drivers/net/ethernet/qualcomm/Makefile
> b/drivers/net/ethernet/qualcomm/Makefile
> index 8080570..00d8729 100644
> --- a/drivers/net/ethernet/qualcomm/Makefile
> +++ b/drivers/net/ethernet/qualcomm/Makefile
> @@ -2,7 +2,8 @@
>  # Makefile for the Qualcomm network device drivers.
>  #
>  
> -obj-$(CONFIG_QCA7000) += qcaspi.o
> -qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
> +obj-$(CONFIG_QCA7000) += qca_common.o
> +obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
> +qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
>  
>  obj-y += emac/
> diff --git a/drivers/net/ethernet/qualcomm/qca_common.c
> b/drivers/net/ethernet/qualcomm/qca_common.c
> index d930524..f2c9e76 100644
> --- a/drivers/net/ethernet/qualcomm/qca_common.c
> +++ b/drivers/net/ethernet/qualcomm/qca_common.c
> @@ -21,7 +21,9 @@
>   *   by an atheros frame while transmitted over a serial channel;
>   */
>  
> +#include <linux/init.h>
>  #include <linux/kernel.h>
> +#include <linux/module.h>
>  
>  #include "qca_common.h"
>  
> @@ -46,6 +48,7 @@ qcafrm_create_header(u8 *buf, u16 length)
>  
>  	return QCAFRM_HEADER_LEN;
>  }
> +EXPORT_SYMBOL_GPL(qcafrm_create_header);
>  
>  u16
>  qcafrm_create_footer(u8 *buf)
> @@ -57,6 +60,7 @@ qcafrm_create_footer(u8 *buf)
>  	buf[1] = 0x55;
>  	return QCAFRM_FOOTER_LEN;
>  }
> +EXPORT_SYMBOL_GPL(qcafrm_create_footer);
>  
>  /*   Gather received bytes and try to extract a full ethernet frame
> by
>   *   following a simple state machine.
> @@ -154,3 +158,9 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle,
> u8 *buf, u16 buf_len, u8 recv_by
>  
>  	return ret;
>  }
> +EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
> +
> +MODULE_DESCRIPTION("Qualcomm Atheros Common");
> +MODULE_AUTHOR("Qualcomm Atheros Communications");
> +MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
> +MODULE_LICENSE("Dual BSD/GPL");

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 09/10] tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate
  2017-03-27 13:37 ` [PATCH RFC v4 09/10] tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate Stefan Wahren
@ 2017-03-27 19:50   ` Rob Herring
  0 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2017-03-27 19:50 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev, devicetree,
	linux-serial, linux-kernel

On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> Instead of returning the requested baudrate, we better return the
> actual one because it isn't always the same.
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  drivers/tty/serdev/serdev-ttyport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings
  2017-03-27 13:37 ` [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings Stefan Wahren
@ 2017-03-27 20:00   ` Rob Herring
  2017-03-28 16:33     ` Stefan Wahren
  0 siblings, 1 reply; 26+ messages in thread
From: Rob Herring @ 2017-03-27 20:00 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev, devicetree,
	linux-serial, linux-kernel

On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> Currently serdev core doesn't provide functions to retrieve common
> UART settings like data bits, stop bits or parity. This patch adds
> the interface to the core and the necessary implementation for
> serdev-ttyport.

It doesn't provide them because why do you need to know? The attached
device should request the settings it needs and be done with it. Maybe
some devices can support a number of settings and you could want
negotiate the settings with the UART, though surely 8N1 is in that
list. It's rare to see something that's not 8N1 from what I've seen.

Rob

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
@ 2017-03-27 20:30     ` Rob Herring
  0 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2017-03-27 20:30 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev, devicetree,
	linux-serial, linux-kernel

On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).
>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>
> According to this binding are still some questions:
>
> Where should be the optional hardware flow control defined (at master or slave side)?

Probably should be in the slave side. We already have uart-has-rtscts
and rts/cts-gpios for the UART. Those mean we have RTS/CTS, but not
necessarily that we want to enable them.

In many cases, the driver may know what it needs.

> Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?

Are they mutually-exclusive or both are used at the same time? What
are the dependencies between the interfaces?

>
>
>  .../devicetree/bindings/net/qca-qca7000-uart.txt   | 31 ++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>
> diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
> new file mode 100644
> index 0000000..f2e0450
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
> @@ -0,0 +1,31 @@
> +* Qualcomm QCA7000 (Ethernet over UART protocol)
> +
> +Note: This binding applies in case the QCA7000 is configured as a
> +UART slave device. It is possible to preconfigure the UART settings
> +of the QCA7000 firmware, which can't be changed during runtime.
> +
> +Required properties:
> +- compatible        : Should be "qca,qca7000-uart"
> +
> +Optional properties:
> +- local-mac-address : 6 bytes, Specifies MAC address

The description can be "see ./ethernet.txt"

> +- current-speed     : Specifies the serial device speed in
> +                     bits per second (default = 115200), which is
> +                     predefined by the QCA7000 firmware configuration

Add this to the slave binding doc with some caveats as to when this
should or should not be used as we discussed.

Rob

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
@ 2017-03-27 20:30     ` Rob Herring
  0 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2017-03-27 20:30 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> wrote:
> This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).
>
> Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
> ---
>
> According to this binding are still some questions:
>
> Where should be the optional hardware flow control defined (at master or slave side)?

Probably should be in the slave side. We already have uart-has-rtscts
and rts/cts-gpios for the UART. Those mean we have RTS/CTS, but not
necessarily that we want to enable them.

In many cases, the driver may know what it needs.

> Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?

Are they mutually-exclusive or both are used at the same time? What
are the dependencies between the interfaces?

>
>
>  .../devicetree/bindings/net/qca-qca7000-uart.txt   | 31 ++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>
> diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
> new file mode 100644
> index 0000000..f2e0450
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
> @@ -0,0 +1,31 @@
> +* Qualcomm QCA7000 (Ethernet over UART protocol)
> +
> +Note: This binding applies in case the QCA7000 is configured as a
> +UART slave device. It is possible to preconfigure the UART settings
> +of the QCA7000 firmware, which can't be changed during runtime.
> +
> +Required properties:
> +- compatible        : Should be "qca,qca7000-uart"
> +
> +Optional properties:
> +- local-mac-address : 6 bytes, Specifies MAC address

The description can be "see ./ethernet.txt"

> +- current-speed     : Specifies the serial device speed in
> +                     bits per second (default = 115200), which is
> +                     predefined by the QCA7000 firmware configuration

Add this to the slave binding doc with some caveats as to when this
should or should not be used as we discussed.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
@ 2017-03-28 16:18       ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-28 16:18 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev, devicetree,
	linux-serial, linux-kernel

Am 27.03.2017 um 22:30 schrieb Rob Herring:
> On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>
>> According to this binding are still some questions:
>>
>> Where should be the optional hardware flow control defined (at master or slave side)?
> Probably should be in the slave side. We already have uart-has-rtscts
> and rts/cts-gpios for the UART. Those mean we have RTS/CTS, but not
> necessarily that we want to enable them.
>
> In many cases, the driver may know what it needs.

Like all the other UART settings the hardware flow control can be
configured in the QCA7000 firmware and the driver can't detect it.

Property suggestion for the slave side:

use-rtscts


>
>> Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?
> Are they mutually-exclusive or both are used at the same time?

They are mutually-exclusive because they use the same pins.

>  What
> are the dependencies between the interfaces?

Except they uses the same pins of the QCA7000, i can't see any dependency.

>
>>
>>  .../devicetree/bindings/net/qca-qca7000-uart.txt   | 31 ++++++++++++++++++++++
>>  1 file changed, 31 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>>
>> diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>> new file mode 100644
>> index 0000000..f2e0450
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>> @@ -0,0 +1,31 @@
>> +* Qualcomm QCA7000 (Ethernet over UART protocol)
>> +
>> +Note: This binding applies in case the QCA7000 is configured as a
>> +UART slave device. It is possible to preconfigure the UART settings
>> +of the QCA7000 firmware, which can't be changed during runtime.
>> +
>> +Required properties:
>> +- compatible        : Should be "qca,qca7000-uart"
>> +
>> +Optional properties:
>> +- local-mac-address : 6 bytes, Specifies MAC address
> The description can be "see ./ethernet.txt"
>
>> +- current-speed     : Specifies the serial device speed in
>> +                     bits per second (default = 115200), which is
>> +                     predefined by the QCA7000 firmware configuration
> Add this to the slave binding doc with some caveats as to when this
> should or should not be used as we discussed.
>
> Rob

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
@ 2017-03-28 16:18       ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-28 16:18 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Am 27.03.2017 um 22:30 schrieb Rob Herring:
> On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> wrote:
>> This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
>> ---
>>
>> According to this binding are still some questions:
>>
>> Where should be the optional hardware flow control defined (at master or slave side)?
> Probably should be in the slave side. We already have uart-has-rtscts
> and rts/cts-gpios for the UART. Those mean we have RTS/CTS, but not
> necessarily that we want to enable them.
>
> In many cases, the driver may know what it needs.

Like all the other UART settings the hardware flow control can be
configured in the QCA7000 firmware and the driver can't detect it.

Property suggestion for the slave side:

use-rtscts


>
>> Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?
> Are they mutually-exclusive or both are used at the same time?

They are mutually-exclusive because they use the same pins.

>  What
> are the dependencies between the interfaces?

Except they uses the same pins of the QCA7000, i can't see any dependency.

>
>>
>>  .../devicetree/bindings/net/qca-qca7000-uart.txt   | 31 ++++++++++++++++++++++
>>  1 file changed, 31 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>>
>> diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>> new file mode 100644
>> index 0000000..f2e0450
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/qca-qca7000-uart.txt
>> @@ -0,0 +1,31 @@
>> +* Qualcomm QCA7000 (Ethernet over UART protocol)
>> +
>> +Note: This binding applies in case the QCA7000 is configured as a
>> +UART slave device. It is possible to preconfigure the UART settings
>> +of the QCA7000 firmware, which can't be changed during runtime.
>> +
>> +Required properties:
>> +- compatible        : Should be "qca,qca7000-uart"
>> +
>> +Optional properties:
>> +- local-mac-address : 6 bytes, Specifies MAC address
> The description can be "see ./ethernet.txt"
>
>> +- current-speed     : Specifies the serial device speed in
>> +                     bits per second (default = 115200), which is
>> +                     predefined by the QCA7000 firmware configuration
> Add this to the slave binding doc with some caveats as to when this
> should or should not be used as we discussed.
>
> Rob

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 06/10] net: qualcomm: make qca_common a separate kernel module
  2017-03-27 15:44   ` Dan Williams
@ 2017-03-28 16:24     ` Stefan Wahren
  2017-03-28 17:18       ` Dan Williams
  0 siblings, 1 reply; 26+ messages in thread
From: Stefan Wahren @ 2017-03-28 16:24 UTC (permalink / raw)
  To: Dan Williams, Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel

Am 27.03.2017 um 17:44 schrieb Dan Williams:
> On Mon, 2017-03-27 at 15:37 +0200, Stefan Wahren wrote:
>> In order to share common functions between QCA7000 SPI and UART
>> protocol
>> driver the qca_common needs to be a separate kernel module.
> Maybe "qca_eth_common"?  There are many things Qualcomm, slightly fewer
> things Qualcomm Atheros, and "qca_common" isn't very descriptive.

Since it is a Homeplug powerline chip which doesn't have any physical
connection to Ethernet only on protocol level, i wouldn't use eth in the
module name.

The code is very specific to the QCA7000, so how about "qca_7k_common"?

>
> Dan
>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> ---
>>  drivers/net/ethernet/qualcomm/Kconfig      |  8 +++++++-
>>  drivers/net/ethernet/qualcomm/Makefile     |  5 +++--
>>  drivers/net/ethernet/qualcomm/qca_common.c | 10 ++++++++++
>>  3 files changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/qualcomm/Kconfig
>> b/drivers/net/ethernet/qualcomm/Kconfig
>> index d7720bf..b4c369d 100644
>> --- a/drivers/net/ethernet/qualcomm/Kconfig
>> +++ b/drivers/net/ethernet/qualcomm/Kconfig
>> @@ -16,7 +16,13 @@ config NET_VENDOR_QUALCOMM
>>  if NET_VENDOR_QUALCOMM
>>  
>>  config QCA7000
>> -	tristate "Qualcomm Atheros QCA7000 support"
>> +	tristate
>> +	help
>> +	  This enables support for the Qualcomm Atheros QCA7000.
>> +
>> +config QCA7000_SPI
>> +	tristate "Qualcomm Atheros QCA7000 SPI support"
>> +	select QCA7000
>>  	depends on SPI_MASTER && OF
>>  	---help---
>>  	  This SPI protocol driver supports the Qualcomm Atheros
>> QCA7000.
>> diff --git a/drivers/net/ethernet/qualcomm/Makefile
>> b/drivers/net/ethernet/qualcomm/Makefile
>> index 8080570..00d8729 100644
>> --- a/drivers/net/ethernet/qualcomm/Makefile
>> +++ b/drivers/net/ethernet/qualcomm/Makefile
>> @@ -2,7 +2,8 @@
>>  # Makefile for the Qualcomm network device drivers.
>>  #
>>  
>> -obj-$(CONFIG_QCA7000) += qcaspi.o
>> -qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
>> +obj-$(CONFIG_QCA7000) += qca_common.o
>> +obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
>> +qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
>>  
>>  obj-y += emac/
>> diff --git a/drivers/net/ethernet/qualcomm/qca_common.c
>> b/drivers/net/ethernet/qualcomm/qca_common.c
>> index d930524..f2c9e76 100644
>> --- a/drivers/net/ethernet/qualcomm/qca_common.c
>> +++ b/drivers/net/ethernet/qualcomm/qca_common.c
>> @@ -21,7 +21,9 @@
>>   *   by an atheros frame while transmitted over a serial channel;
>>   */
>>  
>> +#include <linux/init.h>
>>  #include <linux/kernel.h>
>> +#include <linux/module.h>
>>  
>>  #include "qca_common.h"
>>  
>> @@ -46,6 +48,7 @@ qcafrm_create_header(u8 *buf, u16 length)
>>  
>>  	return QCAFRM_HEADER_LEN;
>>  }
>> +EXPORT_SYMBOL_GPL(qcafrm_create_header);
>>  
>>  u16
>>  qcafrm_create_footer(u8 *buf)
>> @@ -57,6 +60,7 @@ qcafrm_create_footer(u8 *buf)
>>  	buf[1] = 0x55;
>>  	return QCAFRM_FOOTER_LEN;
>>  }
>> +EXPORT_SYMBOL_GPL(qcafrm_create_footer);
>>  
>>  /*   Gather received bytes and try to extract a full ethernet frame
>> by
>>   *   following a simple state machine.
>> @@ -154,3 +158,9 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle,
>> u8 *buf, u16 buf_len, u8 recv_by
>>  
>>  	return ret;
>>  }
>> +EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
>> +
>> +MODULE_DESCRIPTION("Qualcomm Atheros Common");
>> +MODULE_AUTHOR("Qualcomm Atheros Communications");
>> +MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
>> +MODULE_LICENSE("Dual BSD/GPL");


*** Diese E-Mail ist allein für den bezeichneten Adressaten bestimmt. Sie kann rechtlich vertrauliche Informationen enthalten. Wenn Sie diese E-Mail irrtümlich erhalten haben, informieren Sie bitte unverzüglich den Absender per E-Mail und löschen Sie diese E-Mail von Ihrem Computer, ohne Kopien anzufertigen.
Vielen Dank. ***

*** This email is for the exclusive use of the addressee. It may contain legally privileged information. If you have received this message in error, please notify the sender by email immediately and delete the message from your computer without making any copies.
Thank you. ***

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings
  2017-03-27 20:00   ` Rob Herring
@ 2017-03-28 16:33     ` Stefan Wahren
  0 siblings, 0 replies; 26+ messages in thread
From: Stefan Wahren @ 2017-03-28 16:33 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev, devicetree,
	linux-serial, linux-kernel

Am 27.03.2017 um 22:00 schrieb Rob Herring:
> On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:
>> Currently serdev core doesn't provide functions to retrieve common
>> UART settings like data bits, stop bits or parity. This patch adds
>> the interface to the core and the necessary implementation for
>> serdev-ttyport.
> It doesn't provide them because why do you need to know? The attached
> device should request the settings it needs and be done with it. Maybe
> some devices can support a number of settings and you could want
> negotiate the settings with the UART, though surely 8N1 is in that
> list. It's rare to see something that's not 8N1 from what I've seen.

During development it's very helpful to check the current UART settings
and error counter. Currently i can't see a replacement for
/sys/class/tty/ttyXYZ .

Are there any plans about it?

>
> Rob

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 06/10] net: qualcomm: make qca_common a separate kernel module
  2017-03-28 16:24     ` Stefan Wahren
@ 2017-03-28 17:18       ` Dan Williams
  0 siblings, 0 replies; 26+ messages in thread
From: Dan Williams @ 2017-03-28 17:18 UTC (permalink / raw)
  To: Stefan Wahren, Rob Herring, Mark Rutland, David S. Miller
  Cc: Greg Kroah-Hartman, Jiri Slaby, Marcel Holtmann,
	Sebastian Reichel, netdev, devicetree, linux-serial,
	linux-kernel

On Tue, 2017-03-28 at 18:24 +0200, Stefan Wahren wrote:
> Am 27.03.2017 um 17:44 schrieb Dan Williams:
> > On Mon, 2017-03-27 at 15:37 +0200, Stefan Wahren wrote:
> > > In order to share common functions between QCA7000 SPI and UART
> > > protocol
> > > driver the qca_common needs to be a separate kernel module.
> > 
> > Maybe "qca_eth_common"?  There are many things Qualcomm, slightly
> > fewer
> > things Qualcomm Atheros, and "qca_common" isn't very descriptive.
> 
> Since it is a Homeplug powerline chip which doesn't have any physical
> connection to Ethernet only on protocol level, i wouldn't use eth in
> the
> module name.
> 
> The code is very specific to the QCA7000, so how about
> "qca_7k_common"?

Sure; I just saw it was under drivers/net/ethernet, which kinda means
it's ethernet-related...  But 7k common is fine.

Dan

> > 
> > Dan
> > 
> > > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> > > ---
> > >  drivers/net/ethernet/qualcomm/Kconfig      |  8 +++++++-
> > >  drivers/net/ethernet/qualcomm/Makefile     |  5 +++--
> > >  drivers/net/ethernet/qualcomm/qca_common.c | 10 ++++++++++
> > >  3 files changed, 20 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/qualcomm/Kconfig
> > > b/drivers/net/ethernet/qualcomm/Kconfig
> > > index d7720bf..b4c369d 100644
> > > --- a/drivers/net/ethernet/qualcomm/Kconfig
> > > +++ b/drivers/net/ethernet/qualcomm/Kconfig
> > > @@ -16,7 +16,13 @@ config NET_VENDOR_QUALCOMM
> > >  if NET_VENDOR_QUALCOMM
> > >  
> > >  config QCA7000
> > > -	tristate "Qualcomm Atheros QCA7000 support"
> > > +	tristate
> > > +	help
> > > +	  This enables support for the Qualcomm Atheros QCA7000.
> > > +
> > > +config QCA7000_SPI
> > > +	tristate "Qualcomm Atheros QCA7000 SPI support"
> > > +	select QCA7000
> > >  	depends on SPI_MASTER && OF
> > >  	---help---
> > >  	  This SPI protocol driver supports the Qualcomm Atheros
> > > QCA7000.
> > > diff --git a/drivers/net/ethernet/qualcomm/Makefile
> > > b/drivers/net/ethernet/qualcomm/Makefile
> > > index 8080570..00d8729 100644
> > > --- a/drivers/net/ethernet/qualcomm/Makefile
> > > +++ b/drivers/net/ethernet/qualcomm/Makefile
> > > @@ -2,7 +2,8 @@
> > >  # Makefile for the Qualcomm network device drivers.
> > >  #
> > >  
> > > -obj-$(CONFIG_QCA7000) += qcaspi.o
> > > -qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
> > > +obj-$(CONFIG_QCA7000) += qca_common.o
> > > +obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
> > > +qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
> > >  
> > >  obj-y += emac/
> > > diff --git a/drivers/net/ethernet/qualcomm/qca_common.c
> > > b/drivers/net/ethernet/qualcomm/qca_common.c
> > > index d930524..f2c9e76 100644
> > > --- a/drivers/net/ethernet/qualcomm/qca_common.c
> > > +++ b/drivers/net/ethernet/qualcomm/qca_common.c
> > > @@ -21,7 +21,9 @@
> > >   *   by an atheros frame while transmitted over a serial
> > > channel;
> > >   */
> > >  
> > > +#include <linux/init.h>
> > >  #include <linux/kernel.h>
> > > +#include <linux/module.h>
> > >  
> > >  #include "qca_common.h"
> > >  
> > > @@ -46,6 +48,7 @@ qcafrm_create_header(u8 *buf, u16 length)
> > >  
> > >  	return QCAFRM_HEADER_LEN;
> > >  }
> > > +EXPORT_SYMBOL_GPL(qcafrm_create_header);
> > >  
> > >  u16
> > >  qcafrm_create_footer(u8 *buf)
> > > @@ -57,6 +60,7 @@ qcafrm_create_footer(u8 *buf)
> > >  	buf[1] = 0x55;
> > >  	return QCAFRM_FOOTER_LEN;
> > >  }
> > > +EXPORT_SYMBOL_GPL(qcafrm_create_footer);
> > >  
> > >  /*   Gather received bytes and try to extract a full ethernet
> > > frame
> > > by
> > >   *   following a simple state machine.
> > > @@ -154,3 +158,9 @@ qcafrm_fsm_decode(struct qcafrm_handle
> > > *handle,
> > > u8 *buf, u16 buf_len, u8 recv_by
> > >  
> > >  	return ret;
> > >  }
> > > +EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
> > > +
> > > +MODULE_DESCRIPTION("Qualcomm Atheros Common");
> > > +MODULE_AUTHOR("Qualcomm Atheros Communications");
> > > +MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
> > > +MODULE_LICENSE("Dual BSD/GPL");
> 
> 
> *** Diese E-Mail ist allein für den bezeichneten Adressaten bestimmt.
> Sie kann rechtlich vertrauliche Informationen enthalten. Wenn Sie
> diese E-Mail irrtümlich erhalten haben, informieren Sie bitte
> unverzüglich den Absender per E-Mail und löschen Sie diese E-Mail von
> Ihrem Computer, ohne Kopien anzufertigen.
> Vielen Dank. ***
> 
> *** This email is for the exclusive use of the addressee. It may
> contain legally privileged information. If you have received this
> message in error, please notify the sender by email immediately and
> delete the message from your computer without making any copies.
> Thank you. ***
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
@ 2017-04-03 13:23         ` Rob Herring
  0 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2017-04-03 13:23 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev, devicetree,
	linux-serial, linux-kernel

On Tue, Mar 28, 2017 at 06:18:03PM +0200, Stefan Wahren wrote:
> Am 27.03.2017 um 22:30 schrieb Rob Herring:
> > On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren@i2se.com> wrote:
> >> This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).
> >>
> >> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> >> ---
> >>
> >> According to this binding are still some questions:
> >>
> >> Where should be the optional hardware flow control defined (at master or slave side)?
> > Probably should be in the slave side. We already have uart-has-rtscts
> > and rts/cts-gpios for the UART. Those mean we have RTS/CTS, but not
> > necessarily that we want to enable them.
> >
> > In many cases, the driver may know what it needs.
> 
> Like all the other UART settings the hardware flow control can be
> configured in the QCA7000 firmware and the driver can't detect it.
> 
> Property suggestion for the slave side:
> 
> use-rtscts

Okay.

> >> Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?
> > Are they mutually-exclusive or both are used at the same time?
> 
> They are mutually-exclusive because they use the same pins.
> 
> >  What
> > are the dependencies between the interfaces?
> 
> Except they uses the same pins of the QCA7000, i can't see any dependency.

I think they should be a single doc.

Rob

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART
@ 2017-04-03 13:23         ` Rob Herring
  0 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2017-04-03 13:23 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Mark Rutland, David S. Miller, Greg Kroah-Hartman, Jiri Slaby,
	Marcel Holtmann, Sebastian Reichel, netdev,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, Mar 28, 2017 at 06:18:03PM +0200, Stefan Wahren wrote:
> Am 27.03.2017 um 22:30 schrieb Rob Herring:
> > On Mon, Mar 27, 2017 at 8:37 AM, Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org> wrote:
> >> This is the serdev binding for the QCA7000 UART driver (Ethernet over UART).
> >>
> >> Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
> >> ---
> >>
> >> According to this binding are still some questions:
> >>
> >> Where should be the optional hardware flow control defined (at master or slave side)?
> > Probably should be in the slave side. We already have uart-has-rtscts
> > and rts/cts-gpios for the UART. Those mean we have RTS/CTS, but not
> > necessarily that we want to enable them.
> >
> > In many cases, the driver may know what it needs.
> 
> Like all the other UART settings the hardware flow control can be
> configured in the QCA7000 firmware and the driver can't detect it.
> 
> Property suggestion for the slave side:
> 
> use-rtscts

Okay.

> >> Is it okay to have two bindings (qca-qca7000-spi and qca-qca7000-uart) or should they be merged?
> > Are they mutually-exclusive or both are used at the same time?
> 
> They are mutually-exclusive because they use the same pins.
> 
> >  What
> > are the dependencies between the interfaces?
> 
> Except they uses the same pins of the QCA7000, i can't see any dependency.

I think they should be a single doc.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2017-04-03 13:23 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 13:37 [PATCH RFC v4 00/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 01/10] net: qualcomm: remove unnecessary includes Stefan Wahren
2017-03-27 13:37   ` Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 02/10] net: qca_debug: use net_device_ops instead of direct call Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 03/10] net: qualcomm: move qcaspi_tx_cmd to qca_spi.c Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 04/10] net: qualcomm: rename qca_framing.c to qca_common.c Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 05/10] net: qualcomm: prepare frame decoding for UART driver Stefan Wahren
2017-03-27 13:37   ` Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 06/10] net: qualcomm: make qca_common a separate kernel module Stefan Wahren
2017-03-27 13:37   ` Stefan Wahren
2017-03-27 15:44   ` Dan Williams
2017-03-28 16:24     ` Stefan Wahren
2017-03-28 17:18       ` Dan Williams
2017-03-27 13:37 ` [PATCH RFC v4 07/10] dt-bindings: net: add binding for QCA7000 UART Stefan Wahren
2017-03-27 20:30   ` Rob Herring
2017-03-27 20:30     ` Rob Herring
2017-03-28 16:18     ` Stefan Wahren
2017-03-28 16:18       ` Stefan Wahren
2017-04-03 13:23       ` Rob Herring
2017-04-03 13:23         ` Rob Herring
2017-03-27 13:37 ` [PATCH RFC v4 08/10] net: qualcomm: add QCA7000 UART driver Stefan Wahren
2017-03-27 13:37 ` [PATCH RFC v4 09/10] tty: serdev-ttyport: return actual baudrate from ttyport_set_baudrate Stefan Wahren
2017-03-27 19:50   ` Rob Herring
2017-03-27 13:37 ` [PATCH RFC v4 10/10] tty: serdev: add functions to retrieve common UART settings Stefan Wahren
2017-03-27 20:00   ` Rob Herring
2017-03-28 16:33     ` Stefan Wahren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.