linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] sc16is7xx: IrDA mode and threaded IRQs
@ 2020-05-29  5:50 Daniel Mack
  2020-05-29  5:50 ` [PATCH v4 1/2] dt-bindings: sc16is7xx: Add flag to activate IrDA mode Daniel Mack
  2020-05-29  5:50 ` [PATCH v4 2/2] " Daniel Mack
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Mack @ 2020-05-29  5:50 UTC (permalink / raw)
  To: devicetree, linux-serial
  Cc: gregkh, robh+dt, jslaby, jringle, m.brock, pascal.huerst, Daniel Mack

This is a resend of the first two patches of the series to bring IrDA
support to the sc16is7xx driver.

The "linux," prefix is now dropped from the DT property.

The patches are rebased on top of the other 4 that have already been
merged.

Pascal Huerst (2):
  dt-bindings: sc16is7xx: Add flag to activate IrDA mode
  sc16is7xx: Add flag to activate IrDA mode

 .../bindings/serial/nxp,sc16is7xx.txt         |  4 ++++
 drivers/tty/serial/sc16is7xx.c                | 20 +++++++++++++++++++
 2 files changed, 24 insertions(+)

-- 
2.26.2


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

* [PATCH v4 1/2] dt-bindings: sc16is7xx: Add flag to activate IrDA mode
  2020-05-29  5:50 [PATCH v4 0/2] sc16is7xx: IrDA mode and threaded IRQs Daniel Mack
@ 2020-05-29  5:50 ` Daniel Mack
  2020-05-29  5:50 ` [PATCH v4 2/2] " Daniel Mack
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Mack @ 2020-05-29  5:50 UTC (permalink / raw)
  To: devicetree, linux-serial
  Cc: gregkh, robh+dt, jslaby, jringle, m.brock, pascal.huerst,
	Daniel Mack, Rob Herring

From: Pascal Huerst <pascal.huerst@gmail.com>

This series of uart controllers is able to work in IrDA mode.
This adds a property to the device tree to enable that feature on
selected ports if needed.

Signed-off-by: Pascal Huerst <pascal.huerst@gmail.com>
Signed-off-by: Daniel Mack <daniel@zonque.org>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt b/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt
index c1091a923a89..0fa8e3e43bf8 100644
--- a/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt
+++ b/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt
@@ -21,6 +21,8 @@ Optional properties:
   the second cell is used to specify the GPIO polarity:
     0 = active high,
     1 = active low.
+- irda-mode-ports: An array that lists the indices of the port that
+		   should operate in IrDA mode.
 
 Example:
         sc16is750: sc16is750@51 {
@@ -55,6 +57,8 @@ Optional properties:
   the second cell is used to specify the GPIO polarity:
     0 = active high,
     1 = active low.
+- irda-mode-ports: An array that lists the indices of the port that
+		   should operate in IrDA mode.
 
 Example:
 	sc16is750: sc16is750@0 {
-- 
2.26.2


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

* [PATCH v4 2/2] sc16is7xx: Add flag to activate IrDA mode
  2020-05-29  5:50 [PATCH v4 0/2] sc16is7xx: IrDA mode and threaded IRQs Daniel Mack
  2020-05-29  5:50 ` [PATCH v4 1/2] dt-bindings: sc16is7xx: Add flag to activate IrDA mode Daniel Mack
@ 2020-05-29  5:50 ` Daniel Mack
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Mack @ 2020-05-29  5:50 UTC (permalink / raw)
  To: devicetree, linux-serial
  Cc: gregkh, robh+dt, jslaby, jringle, m.brock, pascal.huerst, Daniel Mack

From: Pascal Huerst <pascal.huerst@gmail.com>

This series of uart controllers is able to work in IrDA mode.
Add per-port flag to the device-tree to enable that feature if needed.

Signed-off-by: Pascal Huerst <pascal.huerst@gmail.com>
Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 drivers/tty/serial/sc16is7xx.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 56508e63f9a0..deb55e2ad169 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -315,6 +315,7 @@ struct sc16is7xx_one {
 	struct kthread_work		tx_work;
 	struct kthread_work		reg_work;
 	struct sc16is7xx_one_config	config;
+	bool				irda_mode;
 };
 
 struct sc16is7xx_port {
@@ -986,6 +987,7 @@ static int sc16is7xx_config_rs485(struct uart_port *port,
 
 static int sc16is7xx_startup(struct uart_port *port)
 {
+	struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
 	struct sc16is7xx_port *s = dev_get_drvdata(port->dev);
 	unsigned int val;
 
@@ -1024,6 +1026,13 @@ static int sc16is7xx_startup(struct uart_port *port)
 	/* Now, initialize the UART */
 	sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_WORD_LEN_8);
 
+	/* Enable IrDA mode if requested in DT */
+	/* This bit must be written with LCR[7] = 0 */
+	sc16is7xx_port_update(port, SC16IS7XX_MCR_REG,
+			      SC16IS7XX_MCR_IRDA_BIT,
+			      one->irda_mode ?
+				SC16IS7XX_MCR_IRDA_BIT : 0);
+
 	/* Enable the Rx and Tx FIFO */
 	sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG,
 			      SC16IS7XX_EFCR_RXDISABLE_BIT |
@@ -1304,6 +1313,17 @@ static int sc16is7xx_probe(struct device *dev,
 		sc16is7xx_power(&s->p[i].port, 0);
 	}
 
+	if (dev->of_node) {
+		struct property *prop;
+		const __be32 *p;
+		u32 u;
+
+		of_property_for_each_u32(dev->of_node, "irda-mode-ports",
+					 prop, p, u)
+			if (u < devtype->nr_uart)
+				s->p[u].irda_mode = true;
+	}
+
 	/*
 	 * Setup interrupt. We first try to acquire the IRQ line as level IRQ.
 	 * If that succeeds, we can allow sharing the interrupt as well.
-- 
2.26.2


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

end of thread, other threads:[~2020-05-29  5:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29  5:50 [PATCH v4 0/2] sc16is7xx: IrDA mode and threaded IRQs Daniel Mack
2020-05-29  5:50 ` [PATCH v4 1/2] dt-bindings: sc16is7xx: Add flag to activate IrDA mode Daniel Mack
2020-05-29  5:50 ` [PATCH v4 2/2] " Daniel Mack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).