Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 107131
b: refs/heads/master
c: 7485d26
h: refs/heads/master
i:
  107129: b978853
  107127: 75905be
v: v3
  • Loading branch information
Laurent Pinchart authored and Kumar Gala committed Jul 28, 2008
1 parent 771e7a4 commit feb71bb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc2380ec8572fcd7f7e9579afc9fb223300d922f
refs/heads/master: 7485d26b7e13ee8ff82adb271ac90a996c1fe830
11 changes: 11 additions & 0 deletions trunk/Documentation/powerpc/dts-bindings/fsl/cpm_qe/serial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ Currently defined compatibles:
- 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 {
Expand All @@ -18,4 +27,6 @@ Example:
interrupt-parent = <&PIC>;
fsl,cpm-brg = <1>;
fsl,cpm-command = <00800000>;
gpios = <&gpio_c 15 0
&gpio_d 29 0>;
};
10 changes: 10 additions & 0 deletions trunk/drivers/serial/cpm_uart/cpm_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
40 changes: 37 additions & 3 deletions trunk/drivers/serial/cpm_uart/cpm_uart_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}

/*
Expand Down Expand Up @@ -991,6 +1021,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) {
Expand Down Expand Up @@ -1050,6 +1081,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:
Expand Down

0 comments on commit feb71bb

Please sign in to comment.