2 * Helpers for controlling modem lines via GPIO
4 * Copyright (C) 2014 Paratronic S.A.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #ifndef __SERIAL_MCTRL_GPIO__
19 #define __SERIAL_MCTRL_GPIO__
21 #include <linux/err.h>
22 #include <linux/device.h>
23 #include <linux/gpio/consumer.h>
32 UART_GPIO_RI
= UART_GPIO_RNG
,
39 * Opaque descriptor for modem lines controlled by GPIOs
46 * Set state of the modem control output lines via GPIOs.
48 void mctrl_gpio_set(struct mctrl_gpios
*gpios
, unsigned int mctrl
);
51 * Get state of the modem control input lines from GPIOs.
52 * The mctrl flags are updated and returned.
54 unsigned int mctrl_gpio_get(struct mctrl_gpios
*gpios
, unsigned int *mctrl
);
57 * Get state of the modem control output lines from GPIOs.
58 * The mctrl flags are updated and returned.
61 mctrl_gpio_get_outputs(struct mctrl_gpios
*gpios
, unsigned int *mctrl
);
64 * Returns the associated struct gpio_desc to the modem line gidx
66 struct gpio_desc
*mctrl_gpio_to_gpiod(struct mctrl_gpios
*gpios
,
67 enum mctrl_gpio_idx gidx
);
70 * Request and set direction of modem control line GPIOs and set up irq
72 * devm_* functions are used, so there's no need to call mctrl_gpio_free().
73 * Returns a pointer to the allocated mctrl structure if ok, -ENOMEM on
76 struct mctrl_gpios
*mctrl_gpio_init(struct uart_port
*port
, unsigned int idx
);
79 * Request and set direction of modem control line GPIOs.
80 * devm_* functions are used, so there's no need to call mctrl_gpio_free().
81 * Returns a pointer to the allocated mctrl structure if ok, -ENOMEM on
84 struct mctrl_gpios
*mctrl_gpio_init_noauto(struct device
*dev
,
88 * Free the mctrl_gpios structure.
89 * Normally, this function will not be called, as the GPIOs will
90 * be disposed of by the resource management code.
92 void mctrl_gpio_free(struct device
*dev
, struct mctrl_gpios
*gpios
);
95 * Enable gpio interrupts to report status line changes.
97 void mctrl_gpio_enable_ms(struct mctrl_gpios
*gpios
);
100 * Disable gpio interrupts to report status line changes.
102 void mctrl_gpio_disable_ms(struct mctrl_gpios
*gpios
);
107 void mctrl_gpio_set(struct mctrl_gpios
*gpios
, unsigned int mctrl
)
112 unsigned int mctrl_gpio_get(struct mctrl_gpios
*gpios
, unsigned int *mctrl
)
117 static inline unsigned int
118 mctrl_gpio_get_outputs(struct mctrl_gpios
*gpios
, unsigned int *mctrl
)
124 struct gpio_desc
*mctrl_gpio_to_gpiod(struct mctrl_gpios
*gpios
,
125 enum mctrl_gpio_idx gidx
)
127 return ERR_PTR(-ENOSYS
);
131 struct mctrl_gpios
*mctrl_gpio_init(struct uart_port
*port
, unsigned int idx
)
133 return ERR_PTR(-ENOSYS
);
137 struct mctrl_gpios
*mctrl_gpio_init_noauto(struct device
*dev
, unsigned int idx
)
139 return ERR_PTR(-ENOSYS
);
143 void mctrl_gpio_free(struct device
*dev
, struct mctrl_gpios
*gpios
)
147 static inline void mctrl_gpio_enable_ms(struct mctrl_gpios
*gpios
)
151 static inline void mctrl_gpio_disable_ms(struct mctrl_gpios
*gpios
)