|
@@ -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;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -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) {
|
|
@@ -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:
|