Lines Matching +full:in +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0+
46 * mctrl_gpio_set - set gpios according to mctrl state
47 * @gpios: gpios to set
50 * Set the gpios according to the mctrl state.
52 void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl) in mctrl_gpio_set() argument
59 if (gpios == NULL) in mctrl_gpio_set()
63 if (gpios->gpio[i] && mctrl_gpio_flags_is_dir_out(i)) { in mctrl_gpio_set()
64 desc_array[count] = gpios->gpio[i]; in mctrl_gpio_set()
74 * mctrl_gpio_to_gpiod - obtain gpio_desc of modem line index
75 * @gpios: gpios to look into
79 struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios, in mctrl_gpio_to_gpiod() argument
82 if (gpios == NULL) in mctrl_gpio_to_gpiod()
85 return gpios->gpio[gidx]; in mctrl_gpio_to_gpiod()
90 * mctrl_gpio_get - update mctrl with the gpios values.
91 * @gpios: gpios to get the info from
93 * Returns: modified mctrl (the same value as in @mctrl)
95 * Update mctrl with the gpios values.
97 unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl) in mctrl_gpio_get() argument
101 if (gpios == NULL) in mctrl_gpio_get()
105 if (gpios->gpio[i] && !mctrl_gpio_flags_is_dir_out(i)) { in mctrl_gpio_get()
106 if (gpiod_get_value(gpios->gpio[i])) in mctrl_gpio_get()
118 mctrl_gpio_get_outputs(struct mctrl_gpios *gpios, unsigned int *mctrl) in mctrl_gpio_get_outputs() argument
122 if (gpios == NULL) in mctrl_gpio_get_outputs()
126 if (gpios->gpio[i] && mctrl_gpio_flags_is_dir_out(i)) { in mctrl_gpio_get_outputs()
127 if (gpiod_get_value(gpios->gpio[i])) in mctrl_gpio_get_outputs()
140 struct mctrl_gpios *gpios; in mctrl_gpio_init_noauto() local
143 gpios = devm_kzalloc(dev, sizeof(*gpios), GFP_KERNEL); in mctrl_gpio_init_noauto()
144 if (!gpios) in mctrl_gpio_init_noauto()
145 return ERR_PTR(-ENOMEM); in mctrl_gpio_init_noauto()
152 gpio_str = kasprintf(GFP_KERNEL, "%s-gpios", in mctrl_gpio_init_noauto()
162 gpios->gpio[i] = in mctrl_gpio_init_noauto()
168 if (IS_ERR(gpios->gpio[i])) in mctrl_gpio_init_noauto()
169 return ERR_CAST(gpios->gpio[i]); in mctrl_gpio_init_noauto()
172 return gpios; in mctrl_gpio_init_noauto()
179 struct mctrl_gpios *gpios = context; in mctrl_gpio_irq_handle() local
180 struct uart_port *port = gpios->port; in mctrl_gpio_irq_handle()
181 u32 mctrl = gpios->mctrl_prev; in mctrl_gpio_irq_handle()
185 mctrl_gpio_get(gpios, &mctrl); in mctrl_gpio_irq_handle()
189 mctrl_diff = mctrl ^ gpios->mctrl_prev; in mctrl_gpio_irq_handle()
190 gpios->mctrl_prev = mctrl; in mctrl_gpio_irq_handle()
192 if (mctrl_diff & MCTRL_ANY_DELTA && port->state != NULL) { in mctrl_gpio_irq_handle()
194 port->icount.rng++; in mctrl_gpio_irq_handle()
197 port->icount.dsr++; in mctrl_gpio_irq_handle()
205 wake_up_interruptible(&port->state->port.delta_msr_wait); in mctrl_gpio_irq_handle()
214 * mctrl_gpio_init - initialize uart gpios
215 * @port: port to initialize gpios for
216 * @idx: index of the gpio in the @port's device
218 * This will get the {cts,rts,...}-gpios from device tree if they are present
222 * gpio input lines in your driver, too.
226 struct mctrl_gpios *gpios; in mctrl_gpio_init() local
229 gpios = mctrl_gpio_init_noauto(port->dev, idx); in mctrl_gpio_init()
230 if (IS_ERR(gpios)) in mctrl_gpio_init()
231 return gpios; in mctrl_gpio_init()
233 gpios->port = port; in mctrl_gpio_init()
238 if (!gpios->gpio[i] || mctrl_gpio_flags_is_dir_out(i)) in mctrl_gpio_init()
241 ret = gpiod_to_irq(gpios->gpio[i]); in mctrl_gpio_init()
243 dev_err(port->dev, in mctrl_gpio_init()
248 gpios->irq[i] = ret; in mctrl_gpio_init()
250 /* irqs should only be enabled in .enable_ms */ in mctrl_gpio_init()
251 irq_set_status_flags(gpios->irq[i], IRQ_NOAUTOEN); in mctrl_gpio_init()
253 ret = devm_request_irq(port->dev, gpios->irq[i], in mctrl_gpio_init()
255 IRQ_TYPE_EDGE_BOTH, dev_name(port->dev), in mctrl_gpio_init()
256 gpios); in mctrl_gpio_init()
259 dev_err(port->dev, in mctrl_gpio_init()
266 return gpios; in mctrl_gpio_init()
271 * mctrl_gpio_free - explicitly free uart gpios
273 * @gpios: gpios structure to be freed
275 * This will free the requested gpios in mctrl_gpio_init(). As `devm_*`
278 void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios) in mctrl_gpio_free() argument
282 if (gpios == NULL) in mctrl_gpio_free()
286 if (gpios->irq[i]) in mctrl_gpio_free()
287 devm_free_irq(gpios->port->dev, gpios->irq[i], gpios); in mctrl_gpio_free()
289 if (gpios->gpio[i]) in mctrl_gpio_free()
290 devm_gpiod_put(dev, gpios->gpio[i]); in mctrl_gpio_free()
292 devm_kfree(dev, gpios); in mctrl_gpio_free()
297 * mctrl_gpio_enable_ms - enable irqs and handling of changes to the ms lines
298 * @gpios: gpios to enable
300 void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios) in mctrl_gpio_enable_ms() argument
304 if (gpios == NULL) in mctrl_gpio_enable_ms()
308 if (gpios->mctrl_on) in mctrl_gpio_enable_ms()
311 gpios->mctrl_on = true; in mctrl_gpio_enable_ms()
313 /* get initial status of modem lines GPIOs */ in mctrl_gpio_enable_ms()
314 mctrl_gpio_get(gpios, &gpios->mctrl_prev); in mctrl_gpio_enable_ms()
317 if (!gpios->irq[i]) in mctrl_gpio_enable_ms()
320 enable_irq(gpios->irq[i]); in mctrl_gpio_enable_ms()
326 * mctrl_gpio_disable_ms - disable irqs and handling of changes to the ms lines
327 * @gpios: gpios to disable
329 void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios) in mctrl_gpio_disable_ms() argument
333 if (gpios == NULL) in mctrl_gpio_disable_ms()
336 if (!gpios->mctrl_on) in mctrl_gpio_disable_ms()
339 gpios->mctrl_on = false; in mctrl_gpio_disable_ms()
342 if (!gpios->irq[i]) in mctrl_gpio_disable_ms()
345 disable_irq(gpios->irq[i]); in mctrl_gpio_disable_ms()
350 void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios) in mctrl_gpio_enable_irq_wake() argument
354 if (!gpios) in mctrl_gpio_enable_irq_wake()
357 if (!gpios->mctrl_on) in mctrl_gpio_enable_irq_wake()
361 if (!gpios->irq[i]) in mctrl_gpio_enable_irq_wake()
364 enable_irq_wake(gpios->irq[i]); in mctrl_gpio_enable_irq_wake()
369 void mctrl_gpio_disable_irq_wake(struct mctrl_gpios *gpios) in mctrl_gpio_disable_irq_wake() argument
373 if (!gpios) in mctrl_gpio_disable_irq_wake()
376 if (!gpios->mctrl_on) in mctrl_gpio_disable_irq_wake()
380 if (!gpios->irq[i]) in mctrl_gpio_disable_irq_wake()
383 disable_irq_wake(gpios->irq[i]); in mctrl_gpio_disable_irq_wake()