powerpc/kprobes: Remove kretprobe_trampoline_holder.
[linux/fpc-iii.git] / drivers / tty / serial / serial_mctrl_gpio.h
blob332a33ab0647cbe3fe5d9b9b13dd1b8b78eb0b84
1 /*
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>
25 struct uart_port;
27 enum mctrl_gpio_idx {
28 UART_GPIO_CTS,
29 UART_GPIO_DSR,
30 UART_GPIO_DCD,
31 UART_GPIO_RNG,
32 UART_GPIO_RI = UART_GPIO_RNG,
33 UART_GPIO_RTS,
34 UART_GPIO_DTR,
35 UART_GPIO_MAX,
39 * Opaque descriptor for modem lines controlled by GPIOs
41 struct mctrl_gpios;
43 #ifdef CONFIG_GPIOLIB
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 output 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 * Returns the associated struct gpio_desc to the modem line gidx
59 struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
60 enum mctrl_gpio_idx gidx);
63 * Request and set direction of modem control line GPIOs and set up irq
64 * handling.
65 * devm_* functions are used, so there's no need to call mctrl_gpio_free().
66 * Returns a pointer to the allocated mctrl structure if ok, -ENOMEM on
67 * allocation error.
69 struct mctrl_gpios *mctrl_gpio_init(struct uart_port *port, unsigned int idx);
72 * Request and set direction of modem control line GPIOs.
73 * devm_* functions are used, so there's no need to call mctrl_gpio_free().
74 * Returns a pointer to the allocated mctrl structure if ok, -ENOMEM on
75 * allocation error.
77 struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev,
78 unsigned int idx);
81 * Free the mctrl_gpios structure.
82 * Normally, this function will not be called, as the GPIOs will
83 * be disposed of by the resource management code.
85 void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios);
88 * Enable gpio interrupts to report status line changes.
90 void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios);
93 * Disable gpio interrupts to report status line changes.
95 void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios);
97 #else /* GPIOLIB */
99 static inline
100 void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl)
104 static inline
105 unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl)
107 return *mctrl;
110 static inline
111 struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
112 enum mctrl_gpio_idx gidx)
114 return ERR_PTR(-ENOSYS);
117 static inline
118 struct mctrl_gpios *mctrl_gpio_init(struct uart_port *port, unsigned int idx)
120 return ERR_PTR(-ENOSYS);
123 static inline
124 struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev, unsigned int idx)
126 return ERR_PTR(-ENOSYS);
129 static inline
130 void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios)
134 static inline void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios)
138 static inline void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios)
142 #endif /* GPIOLIB */
144 #endif