mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 11:37:47 +07:00
8c7febe839
Here's the tty and serial driver patches for 4.2-rc1. A number of individual driver updates, some code cleanups, and other minor things, full details in the shortlog. All have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlWNoSAACgkQMUfUDdst+ymxNQCguSEmkAYNDdLyYhdcOqSxJt9u U1gAoMThUDoomkx6CTDMU1wn53hxgMk9 =eCUS -----END PGP SIGNATURE----- Merge tag 'tty-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty Pull tty/serial driver updates from Greg KH: "Here's the tty and serial driver patches for 4.2-rc1. A number of individual driver updates, some code cleanups, and other minor things, full details in the shortlog. All have been in linux-next for a while with no reported issues" * tag 'tty-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (152 commits) Doc: serial-rs485.txt: update RS485 driver interface Doc: tty.txt: remove mention of the BKL MAINTAINERS: tty: add serial docs directory serial: sprd: check for NULL after calling devm_clk_get serial: 8250_pci: Correct uartclk for xr17v35x expansion chips serial: 8250_pci: Add support for 12 port Exar boards serial: 8250_uniphier: add bindings document for UniPhier UART serial: core: cleanup in uart_get_baud_rate() serial: stm32-usart: Add STM32 USART Driver tty/serial: kill off set_irq_flags usage tty: move linux/gsmmux.h to uapi doc: dt: add documentation for nxp,lpc1850-uart serial: 8250: add LPC18xx/43xx UART driver serial: 8250_uniphier: add UniPhier serial driver serial: 8250_dw: support ACPI platforms with integrated DMA engine serial: of_serial: check the return value of clk_prepare_enable() serial: of_serial: use devm_clk_get() instead of clk_get() serial: earlycon: Add support for big-endian MMIO accesses serial: sirf: use hrtimer for data rx serial: sirf: correct the fifo empty_bit ...
125 lines
3.1 KiB
C
125 lines
3.1 KiB
C
/*
|
|
* Helpers for controlling modem lines via GPIO
|
|
*
|
|
* Copyright (C) 2014 Paratronic S.A.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/device.h>
|
|
#include <linux/gpio/consumer.h>
|
|
#include <linux/termios.h>
|
|
|
|
#include "serial_mctrl_gpio.h"
|
|
|
|
struct mctrl_gpios {
|
|
struct gpio_desc *gpio[UART_GPIO_MAX];
|
|
};
|
|
|
|
static const struct {
|
|
const char *name;
|
|
unsigned int mctrl;
|
|
bool dir_out;
|
|
} mctrl_gpios_desc[UART_GPIO_MAX] = {
|
|
{ "cts", TIOCM_CTS, false, },
|
|
{ "dsr", TIOCM_DSR, false, },
|
|
{ "dcd", TIOCM_CD, false, },
|
|
{ "rng", TIOCM_RNG, false, },
|
|
{ "rts", TIOCM_RTS, true, },
|
|
{ "dtr", TIOCM_DTR, true, },
|
|
{ "out1", TIOCM_OUT1, true, },
|
|
{ "out2", TIOCM_OUT2, true, },
|
|
};
|
|
|
|
void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl)
|
|
{
|
|
enum mctrl_gpio_idx i;
|
|
struct gpio_desc *desc_array[UART_GPIO_MAX];
|
|
int value_array[UART_GPIO_MAX];
|
|
unsigned int count = 0;
|
|
|
|
for (i = 0; i < UART_GPIO_MAX; i++)
|
|
if (gpios->gpio[i] && mctrl_gpios_desc[i].dir_out) {
|
|
desc_array[count] = gpios->gpio[i];
|
|
value_array[count] = !!(mctrl & mctrl_gpios_desc[i].mctrl);
|
|
count++;
|
|
}
|
|
gpiod_set_array_value(count, desc_array, value_array);
|
|
}
|
|
EXPORT_SYMBOL_GPL(mctrl_gpio_set);
|
|
|
|
struct gpio_desc *mctrl_gpio_to_gpiod(struct mctrl_gpios *gpios,
|
|
enum mctrl_gpio_idx gidx)
|
|
{
|
|
return gpios->gpio[gidx];
|
|
}
|
|
EXPORT_SYMBOL_GPL(mctrl_gpio_to_gpiod);
|
|
|
|
unsigned int mctrl_gpio_get(struct mctrl_gpios *gpios, unsigned int *mctrl)
|
|
{
|
|
enum mctrl_gpio_idx i;
|
|
|
|
for (i = 0; i < UART_GPIO_MAX; i++) {
|
|
if (gpios->gpio[i] && !mctrl_gpios_desc[i].dir_out) {
|
|
if (gpiod_get_value(gpios->gpio[i]))
|
|
*mctrl |= mctrl_gpios_desc[i].mctrl;
|
|
else
|
|
*mctrl &= ~mctrl_gpios_desc[i].mctrl;
|
|
}
|
|
}
|
|
|
|
return *mctrl;
|
|
}
|
|
EXPORT_SYMBOL_GPL(mctrl_gpio_get);
|
|
|
|
struct mctrl_gpios *mctrl_gpio_init(struct device *dev, unsigned int idx)
|
|
{
|
|
struct mctrl_gpios *gpios;
|
|
enum mctrl_gpio_idx i;
|
|
|
|
gpios = devm_kzalloc(dev, sizeof(*gpios), GFP_KERNEL);
|
|
if (!gpios)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
for (i = 0; i < UART_GPIO_MAX; i++) {
|
|
enum gpiod_flags flags;
|
|
|
|
if (mctrl_gpios_desc[i].dir_out)
|
|
flags = GPIOD_OUT_LOW;
|
|
else
|
|
flags = GPIOD_IN;
|
|
|
|
gpios->gpio[i] =
|
|
devm_gpiod_get_index_optional(dev,
|
|
mctrl_gpios_desc[i].name,
|
|
idx, flags);
|
|
|
|
if (IS_ERR(gpios->gpio[i]))
|
|
return ERR_CAST(gpios->gpio[i]);
|
|
}
|
|
|
|
return gpios;
|
|
}
|
|
EXPORT_SYMBOL_GPL(mctrl_gpio_init);
|
|
|
|
void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios)
|
|
{
|
|
enum mctrl_gpio_idx i;
|
|
|
|
for (i = 0; i < UART_GPIO_MAX; i++)
|
|
if (gpios->gpio[i])
|
|
devm_gpiod_put(dev, gpios->gpio[i]);
|
|
devm_kfree(dev, gpios);
|
|
}
|
|
EXPORT_SYMBOL_GPL(mctrl_gpio_free);
|