All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Modem control lines support for the cpm_uart driver
@ 2008-04-16  9:10 Laurent Pinchart
  2008-05-26  9:58 ` Laurent Pinchart
       [not found] ` <200807241705.03340.laurentp@cse-semaphore.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Laurent Pinchart @ 2008-04-16  9:10 UTC (permalink / raw)
  To: linux-ppc list

This patch replaces the get_mctrl/set_mctrl stubs with modem control line
read/write access through the GPIO lib.

Available modem control lines are described in the device tree using GPIO
bindings.

Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
---
 Documentation/powerpc/booting-without-of.txt |   10 ++++++
 drivers/serial/cpm_uart/cpm_uart.h           |   10 ++++++
 drivers/serial/cpm_uart/cpm_uart_core.c      |   40 ++++++++++++++++++++++++--
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index 1e5572a..012f231 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1976,6 +1976,14 @@ platforms are moved over to use the flattened-device-tree model.
    - fsl,cpm2-scc-uart
    - fsl,qe-uart
 
+   Modem control lines connected to GPIO controllers are listed in the
+   gpios property as described in section VIII.1 in the following order:
+
+   CTS, RTS, DCD, DSR, DTR, and RI.
+
+   The gpios property is optional and can be left out when control lines are
+   not used.
+
    Example:
 
 	serial@11a00 {
@@ -1987,6 +1995,8 @@ platforms are moved over to use the flattened-device-tree model.
 		interrupt-parent = <&PIC>;
 		fsl,cpm-brg = <1>;
 		fsl,cpm-command = <00800000>;
+		gpios = <&gpio_c 15 0
+			 &gpio_d 29 0>;
 	};
 
    iii) Network
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index 0cc39f8..d0c55e2 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -50,6 +50,15 @@
 
 #define SCC_WAIT_CLOSING 100
 
+#define GPIO_CTS	0
+#define GPIO_RTS	1
+#define GPIO_DCD	2
+#define GPIO_DSR	3
+#define GPIO_DTR	4
+#define GPIO_RI		5
+
+#define NUM_GPIOS	(GPIO_RI+1)
+
 struct uart_cpm_port {
 	struct uart_port	port;
 	u16			rx_nrfifos;
@@ -82,6 +91,7 @@ struct uart_cpm_port {
 	int 			wait_closing;
 	/* value to combine with opcode to form cpm command */
 	u32			command;
+	int			gpios[NUM_GPIOS];
 };
 
 #ifndef CONFIG_PPC_CPM_NEW_BINDING
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 7a704ff..0f08071 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -42,6 +42,8 @@
 #include <linux/bootmem.h>
 #include <linux/dma-mapping.h>
 #include <linux/fs_uart_pd.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -152,13 +154,41 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)
 
 static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
-	/* Whee. Do nothing. */
+	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+
+	if (pinfo->gpios[GPIO_RTS] >= 0)
+		gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS));
+
+	if (pinfo->gpios[GPIO_DTR] >= 0)
+		gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR));
 }
 
 static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
 {
-	/* Whee. Do nothing. */
-	return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
+	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+	unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+
+	if (pinfo->gpios[GPIO_CTS] >= 0) {
+		if (gpio_get_value(pinfo->gpios[GPIO_CTS]))
+			mctrl &= ~TIOCM_CTS;
+	}
+
+	if (pinfo->gpios[GPIO_DSR] >= 0) {
+		if (gpio_get_value(pinfo->gpios[GPIO_DSR]))
+			mctrl &= ~TIOCM_DSR;
+	}
+
+	if (pinfo->gpios[GPIO_DCD] >= 0) {
+		if (gpio_get_value(pinfo->gpios[GPIO_DCD]))
+			mctrl &= ~TIOCM_CAR;
+	}
+
+	if (pinfo->gpios[GPIO_RI] >= 0) {
+		if (!gpio_get_value(pinfo->gpios[GPIO_RI]))
+			mctrl |= TIOCM_RNG;
+	}
+
+	return mctrl;
 }
 
 /*
@@ -959,6 +989,7 @@ static int cpm_uart_init_port(struct device_node *np,
 	void __iomem *mem, *pram;
 	int len;
 	int ret;
+	int i;
 
 	data = of_get_property(np, "fsl,cpm-brg", &len);
 	if (!data || len != 4) {
@@ -1017,6 +1048,9 @@ static int cpm_uart_init_port(struct device_node *np,
 		goto out_pram;
 	}
 
+	for (i = 0; i < NUM_GPIOS; i++)
+		pinfo->gpios[i] = of_get_gpio(np, i);
+
 	return cpm_uart_request_port(&pinfo->port);
 
 out_pram:
-- 
1.5.0


-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

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

* Re: [PATCH] powerpc: Modem control lines support for the cpm_uart driver
  2008-04-16  9:10 [PATCH] powerpc: Modem control lines support for the cpm_uart driver Laurent Pinchart
@ 2008-05-26  9:58 ` Laurent Pinchart
  2008-06-26 11:18   ` Laurent Pinchart
       [not found] ` <200807241705.03340.laurentp@cse-semaphore.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2008-05-26  9:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Scott Wood

[-- Attachment #1: Type: text/plain, Size: 4931 bytes --]

On Wednesday 16 April 2008 11:10, Laurent Pinchart wrote:
> This patch replaces the get_mctrl/set_mctrl stubs with modem control line
> read/write access through the GPIO lib.
> 
> Available modem control lines are described in the device tree using GPIO
> bindings.

Any show stopper on this patch ? Could it get into powerpc-next ?

> Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
> ---
>  Documentation/powerpc/booting-without-of.txt |   10 ++++++
>  drivers/serial/cpm_uart/cpm_uart.h           |   10 ++++++
>  drivers/serial/cpm_uart/cpm_uart_core.c      |   40 ++++++++++++++++++++++++--
>  3 files changed, 57 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
> index 1e5572a..012f231 100644
> --- a/Documentation/powerpc/booting-without-of.txt
> +++ b/Documentation/powerpc/booting-without-of.txt
> @@ -1976,6 +1976,14 @@ platforms are moved over to use the flattened-device-tree model.
>     - fsl,cpm2-scc-uart
>     - fsl,qe-uart
>  
> +   Modem control lines connected to GPIO controllers are listed in the
> +   gpios property as described in section VIII.1 in the following order:
> +
> +   CTS, RTS, DCD, DSR, DTR, and RI.
> +
> +   The gpios property is optional and can be left out when control lines are
> +   not used.
> +
>     Example:
>  
>  	serial@11a00 {
> @@ -1987,6 +1995,8 @@ platforms are moved over to use the flattened-device-tree model.
>  		interrupt-parent = <&PIC>;
>  		fsl,cpm-brg = <1>;
>  		fsl,cpm-command = <00800000>;
> +		gpios = <&gpio_c 15 0
> +			 &gpio_d 29 0>;
>  	};
>  
>     iii) Network
> diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
> index 0cc39f8..d0c55e2 100644
> --- a/drivers/serial/cpm_uart/cpm_uart.h
> +++ b/drivers/serial/cpm_uart/cpm_uart.h
> @@ -50,6 +50,15 @@
>  
>  #define SCC_WAIT_CLOSING 100
>  
> +#define GPIO_CTS	0
> +#define GPIO_RTS	1
> +#define GPIO_DCD	2
> +#define GPIO_DSR	3
> +#define GPIO_DTR	4
> +#define GPIO_RI		5
> +
> +#define NUM_GPIOS	(GPIO_RI+1)
> +
>  struct uart_cpm_port {
>  	struct uart_port	port;
>  	u16			rx_nrfifos;
> @@ -82,6 +91,7 @@ struct uart_cpm_port {
>  	int 			wait_closing;
>  	/* value to combine with opcode to form cpm command */
>  	u32			command;
> +	int			gpios[NUM_GPIOS];
>  };
>  
>  #ifndef CONFIG_PPC_CPM_NEW_BINDING
> diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
> index 7a704ff..0f08071 100644
> --- a/drivers/serial/cpm_uart/cpm_uart_core.c
> +++ b/drivers/serial/cpm_uart/cpm_uart_core.c
> @@ -42,6 +42,8 @@
>  #include <linux/bootmem.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/fs_uart_pd.h>
> +#include <linux/gpio.h>
> +#include <linux/of_gpio.h>
>  
>  #include <asm/io.h>
>  #include <asm/irq.h>
> @@ -152,13 +154,41 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)
>  
>  static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
>  {
> -	/* Whee. Do nothing. */
> +	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
> +
> +	if (pinfo->gpios[GPIO_RTS] >= 0)
> +		gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS));
> +
> +	if (pinfo->gpios[GPIO_DTR] >= 0)
> +		gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR));
>  }
>  
>  static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
>  {
> -	/* Whee. Do nothing. */
> -	return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
> +	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
> +	unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> +
> +	if (pinfo->gpios[GPIO_CTS] >= 0) {
> +		if (gpio_get_value(pinfo->gpios[GPIO_CTS]))
> +			mctrl &= ~TIOCM_CTS;
> +	}
> +
> +	if (pinfo->gpios[GPIO_DSR] >= 0) {
> +		if (gpio_get_value(pinfo->gpios[GPIO_DSR]))
> +			mctrl &= ~TIOCM_DSR;
> +	}
> +
> +	if (pinfo->gpios[GPIO_DCD] >= 0) {
> +		if (gpio_get_value(pinfo->gpios[GPIO_DCD]))
> +			mctrl &= ~TIOCM_CAR;
> +	}
> +
> +	if (pinfo->gpios[GPIO_RI] >= 0) {
> +		if (!gpio_get_value(pinfo->gpios[GPIO_RI]))
> +			mctrl |= TIOCM_RNG;
> +	}
> +
> +	return mctrl;
>  }
>  
>  /*
> @@ -959,6 +989,7 @@ static int cpm_uart_init_port(struct device_node *np,
>  	void __iomem *mem, *pram;
>  	int len;
>  	int ret;
> +	int i;
>  
>  	data = of_get_property(np, "fsl,cpm-brg", &len);
>  	if (!data || len != 4) {
> @@ -1017,6 +1048,9 @@ static int cpm_uart_init_port(struct device_node *np,
>  		goto out_pram;
>  	}
>  
> +	for (i = 0; i < NUM_GPIOS; i++)
> +		pinfo->gpios[i] = of_get_gpio(np, i);
> +
>  	return cpm_uart_request_port(&pinfo->port);
>  
>  out_pram:
> -- 
> 1.5.0
> 
> 

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] powerpc: Modem control lines support for the cpm_uart driver
  2008-05-26  9:58 ` Laurent Pinchart
@ 2008-06-26 11:18   ` Laurent Pinchart
  0 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2008-06-26 11:18 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Scott Wood, panto

[-- Attachment #1: Type: text/plain, Size: 5561 bytes --]

On Monday 26 May 2008 11:58, Laurent Pinchart wrote:
> On Wednesday 16 April 2008 11:10, Laurent Pinchart wrote:
> > This patch replaces the get_mctrl/set_mctrl stubs with modem control line
> > read/write access through the GPIO lib.
> > 
> > Available modem control lines are described in the device tree using GPIO
> > bindings.
> 
> Any show stopper on this patch ? Could it get into powerpc-next ?

Sorry to bother everybody again, but I'd like this patch to go in 2.6.27. Is 
there any pending issue ? Platforms without GPIO support shouldn't be 
affected and get_mctrl()/set_mctrl() behaviour is backward compatible for 
existing platforms.

> > Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
> > ---
> >  Documentation/powerpc/booting-without-of.txt |   10 ++++++
> >  drivers/serial/cpm_uart/cpm_uart.h           |   10 ++++++
> >  drivers/serial/cpm_uart/cpm_uart_core.c      |   40 
++++++++++++++++++++++++--
> >  3 files changed, 57 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
> > index 1e5572a..012f231 100644
> > --- a/Documentation/powerpc/booting-without-of.txt
> > +++ b/Documentation/powerpc/booting-without-of.txt
> > @@ -1976,6 +1976,14 @@ platforms are moved over to use the 
flattened-device-tree model.
> >     - fsl,cpm2-scc-uart
> >     - fsl,qe-uart
> >  
> > +   Modem control lines connected to GPIO controllers are listed in the
> > +   gpios property as described in section VIII.1 in the following order:
> > +
> > +   CTS, RTS, DCD, DSR, DTR, and RI.
> > +
> > +   The gpios property is optional and can be left out when control lines 
are
> > +   not used.
> > +
> >     Example:
> >  
> >  	serial@11a00 {
> > @@ -1987,6 +1995,8 @@ platforms are moved over to use the 
flattened-device-tree model.
> >  		interrupt-parent = <&PIC>;
> >  		fsl,cpm-brg = <1>;
> >  		fsl,cpm-command = <00800000>;
> > +		gpios = <&gpio_c 15 0
> > +			 &gpio_d 29 0>;
> >  	};
> >  
> >     iii) Network
> > diff --git a/drivers/serial/cpm_uart/cpm_uart.h 
b/drivers/serial/cpm_uart/cpm_uart.h
> > index 0cc39f8..d0c55e2 100644
> > --- a/drivers/serial/cpm_uart/cpm_uart.h
> > +++ b/drivers/serial/cpm_uart/cpm_uart.h
> > @@ -50,6 +50,15 @@
> >  
> >  #define SCC_WAIT_CLOSING 100
> >  
> > +#define GPIO_CTS	0
> > +#define GPIO_RTS	1
> > +#define GPIO_DCD	2
> > +#define GPIO_DSR	3
> > +#define GPIO_DTR	4
> > +#define GPIO_RI		5
> > +
> > +#define NUM_GPIOS	(GPIO_RI+1)
> > +
> >  struct uart_cpm_port {
> >  	struct uart_port	port;
> >  	u16			rx_nrfifos;
> > @@ -82,6 +91,7 @@ struct uart_cpm_port {
> >  	int 			wait_closing;
> >  	/* value to combine with opcode to form cpm command */
> >  	u32			command;
> > +	int			gpios[NUM_GPIOS];
> >  };
> >  
> >  #ifndef CONFIG_PPC_CPM_NEW_BINDING
> > diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c 
b/drivers/serial/cpm_uart/cpm_uart_core.c
> > index 7a704ff..0f08071 100644
> > --- a/drivers/serial/cpm_uart/cpm_uart_core.c
> > +++ b/drivers/serial/cpm_uart/cpm_uart_core.c
> > @@ -42,6 +42,8 @@
> >  #include <linux/bootmem.h>
> >  #include <linux/dma-mapping.h>
> >  #include <linux/fs_uart_pd.h>
> > +#include <linux/gpio.h>
> > +#include <linux/of_gpio.h>
> >  
> >  #include <asm/io.h>
> >  #include <asm/irq.h>
> > @@ -152,13 +154,41 @@ static unsigned int cpm_uart_tx_empty(struct 
uart_port *port)
> >  
> >  static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int 
mctrl)
> >  {
> > -	/* Whee. Do nothing. */
> > +	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
> > +
> > +	if (pinfo->gpios[GPIO_RTS] >= 0)
> > +		gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS));
> > +
> > +	if (pinfo->gpios[GPIO_DTR] >= 0)
> > +		gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR));
> >  }
> >  
> >  static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
> >  {
> > -	/* Whee. Do nothing. */
> > -	return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
> > +	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
> > +	unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
> > +
> > +	if (pinfo->gpios[GPIO_CTS] >= 0) {
> > +		if (gpio_get_value(pinfo->gpios[GPIO_CTS]))
> > +			mctrl &= ~TIOCM_CTS;
> > +	}
> > +
> > +	if (pinfo->gpios[GPIO_DSR] >= 0) {
> > +		if (gpio_get_value(pinfo->gpios[GPIO_DSR]))
> > +			mctrl &= ~TIOCM_DSR;
> > +	}
> > +
> > +	if (pinfo->gpios[GPIO_DCD] >= 0) {
> > +		if (gpio_get_value(pinfo->gpios[GPIO_DCD]))
> > +			mctrl &= ~TIOCM_CAR;
> > +	}
> > +
> > +	if (pinfo->gpios[GPIO_RI] >= 0) {
> > +		if (!gpio_get_value(pinfo->gpios[GPIO_RI]))
> > +			mctrl |= TIOCM_RNG;
> > +	}
> > +
> > +	return mctrl;
> >  }
> >  
> >  /*
> > @@ -959,6 +989,7 @@ static int cpm_uart_init_port(struct device_node *np,
> >  	void __iomem *mem, *pram;
> >  	int len;
> >  	int ret;
> > +	int i;
> >  
> >  	data = of_get_property(np, "fsl,cpm-brg", &len);
> >  	if (!data || len != 4) {
> > @@ -1017,6 +1048,9 @@ static int cpm_uart_init_port(struct device_node 
*np,
> >  		goto out_pram;
> >  	}
> >  
> > +	for (i = 0; i < NUM_GPIOS; i++)
> > +		pinfo->gpios[i] = of_get_gpio(np, i);
> > +
> >  	return cpm_uart_request_port(&pinfo->port);
> >  
> >  out_pram:
> > -- 
> > 1.5.0
> > 
> > 
> 

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* [PATCHv2] cpm_uart: Modem control lines support
       [not found]   ` <2F3F000A-AC69-4C15-A535-F93B60BA191E@kernel.crashing.org>
@ 2008-07-24 16:36     ` Laurent Pinchart
  2008-07-28 12:49       ` Kumar Gala
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2008-07-24 16:36 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev list

This patch replaces the get_mctrl/set_mctrl stubs with modem control line
read/write access through the GPIO lib.

Available modem control lines are described in the device tree using GPIO
bindings. The driver expect a GPIO pin for each of the CTS, RTS, DCD, DSR,
DTR and RI signals. Unused control lines can be left out.

Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
---
 Documentation/powerpc/booting-without-of.txt |   10 ++++++
 drivers/serial/cpm_uart/cpm_uart.h           |   10 ++++++
 drivers/serial/cpm_uart/cpm_uart_core.c      |   40 ++++++++++++++++++++++++--
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/Documentation/powerpc/dts-bindings/fsl/cpm_qe/serial.txt b/Documentation/powerpc/dts-bindings/fsl/cpm_qe/serial.txt
index 1d2a772..21a3484 100644
--- a/Documentation/powerpc/dts-bindings/fsl/cpm_qe/serial.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/cpm_qe/serial.txt
@@ -7,6 +7,15 @@
 - fsl,cpm2-scc-uart
 - fsl,qe-uart
 
+Modem control lines connected to GPIO controllers are listed in the gpios
+property as described in booting-without-of.txt, section IX.1 in the following
+order:
+
+CTS, RTS, DCD, DSR, DTR, and RI.
+
+The gpios property is optional and can be left out when control lines are
+not used.
+
 Example:
 
 	serial@11a00 {
@@ -18,4 +27,6 @@
 		interrupt-parent = <&PIC>;
 		fsl,cpm-brg = <1>;
 		fsl,cpm-command = <00800000>;
+		gpios = <&gpio_c 15 0
+			 &gpio_d 29 0>;
 	};
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index 0cc39f8..d0c55e2 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -50,6 +50,15 @@
 
 #define SCC_WAIT_CLOSING 100
 
+#define GPIO_CTS	0
+#define GPIO_RTS	1
+#define GPIO_DCD	2
+#define GPIO_DSR	3
+#define GPIO_DTR	4
+#define GPIO_RI		5
+
+#define NUM_GPIOS	(GPIO_RI+1)
+
 struct uart_cpm_port {
 	struct uart_port	port;
 	u16			rx_nrfifos;
@@ -82,6 +91,7 @@ struct uart_cpm_port {
 	int			wait_closing;
 	/* value to combine with opcode to form cpm command */
 	u32			command;
+	int			gpios[NUM_GPIOS];
 };
 
 extern int cpm_uart_nr;
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index d10a16e..d3c19e5 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -43,6 +43,8 @@
 #include <linux/dma-mapping.h>
 #include <linux/fs_uart_pd.h>
 #include <linux/of_platform.h>
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -96,13 +98,41 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port)
 
 static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
-	/* Whee. Do nothing. */
+	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+
+	if (pinfo->gpios[GPIO_RTS] >= 0)
+		gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS));
+
+	if (pinfo->gpios[GPIO_DTR] >= 0)
+		gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR));
 }
 
 static unsigned int cpm_uart_get_mctrl(struct uart_port *port)
 {
-	/* Whee. Do nothing. */
-	return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
+	struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
+	unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+
+	if (pinfo->gpios[GPIO_CTS] >= 0) {
+		if (gpio_get_value(pinfo->gpios[GPIO_CTS]))
+			mctrl &= ~TIOCM_CTS;
+	}
+
+	if (pinfo->gpios[GPIO_DSR] >= 0) {
+		if (gpio_get_value(pinfo->gpios[GPIO_DSR]))
+			mctrl &= ~TIOCM_DSR;
+	}
+
+	if (pinfo->gpios[GPIO_DCD] >= 0) {
+		if (gpio_get_value(pinfo->gpios[GPIO_DCD]))
+			mctrl &= ~TIOCM_CAR;
+	}
+
+	if (pinfo->gpios[GPIO_RI] >= 0) {
+		if (!gpio_get_value(pinfo->gpios[GPIO_RI]))
+			mctrl |= TIOCM_RNG;
+	}
+
+	return mctrl;
 }
 
 /*
@@ -893,6 +923,7 @@ static int cpm_uart_init_port(struct device_node *np,
 	void __iomem *mem, *pram;
 	int len;
 	int ret;
+	int i;
 
 	data = of_get_property(np, "fsl,cpm-brg", &len);
 	if (!data || len != 4) {
@@ -952,6 +983,9 @@ static int cpm_uart_init_port(struct device_node *np,
 		goto out_pram;
 	}
 
+	for (i = 0; i < NUM_GPIOS; i++)
+		pinfo->gpios[i] = of_get_gpio(np, i);
+
 	return cpm_uart_request_port(&pinfo->port);
 
 out_pram:
-- 
1.5.0


-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

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

* Re: [PATCHv2] cpm_uart: Modem control lines support
  2008-07-24 16:36     ` [PATCHv2] cpm_uart: Modem control lines support Laurent Pinchart
@ 2008-07-28 12:49       ` Kumar Gala
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2008-07-28 12:49 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linuxppc-dev list


On Jul 24, 2008, at 11:36 AM, Laurent Pinchart wrote:

> This patch replaces the get_mctrl/set_mctrl stubs with modem control  
> line
> read/write access through the GPIO lib.
>
> Available modem control lines are described in the device tree using  
> GPIO
> bindings. The driver expect a GPIO pin for each of the CTS, RTS,  
> DCD, DSR,
> DTR and RI signals. Unused control lines can be left out.
>
> Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
> ---
> Documentation/powerpc/booting-without-of.txt |   10 ++++++
> drivers/serial/cpm_uart/cpm_uart.h           |   10 ++++++
> drivers/serial/cpm_uart/cpm_uart_core.c      |   40 +++++++++++++++++ 
> +++++++--
> 3 files changed, 57 insertions(+), 3 deletions(-)

applied.

- k

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

end of thread, other threads:[~2008-07-28 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-16  9:10 [PATCH] powerpc: Modem control lines support for the cpm_uart driver Laurent Pinchart
2008-05-26  9:58 ` Laurent Pinchart
2008-06-26 11:18   ` Laurent Pinchart
     [not found] ` <200807241705.03340.laurentp@cse-semaphore.com>
     [not found]   ` <2F3F000A-AC69-4C15-A535-F93B60BA191E@kernel.crashing.org>
2008-07-24 16:36     ` [PATCHv2] cpm_uart: Modem control lines support Laurent Pinchart
2008-07-28 12:49       ` Kumar Gala

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.