linux/drivers/tty/serial
Stefan Roese d99482673f serial: mctrl_gpio: Check if GPIO property exisits before requesting it
This patch adds a check for the GPIOs property existence, before the
GPIO is requested. This fixes an issue seen when the 8250 mctrl_gpio
support is added (2nd patch in this patch series) on x86 platforms using
ACPI.

Here Mika's comments from 2016-08-09:

"
I noticed that with v4.8-rc1 serial console of some of our Broxton
systems does not work properly anymore. I'm able to see output but input
does not work.

I bisected it down to commit 4ef03d3287
("tty/serial/8250: use mctrl_gpio helpers").

The reason why it fails is that in ACPI we do not have names for GPIOs
(except when _DSD is used) so we use the "idx" to index into _CRS GPIO
resources. Now mctrl_gpio_init_noauto() goes through a list of GPIOs
calling devm_gpiod_get_index_optional() passing "idx" of 0 for each. The
UART device in Broxton has following (simplified) ACPI description:

    Device (URT4)
    {
        ...
        Name (_CRS, ResourceTemplate () {
            GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.GPO0", 0x00, ResourceConsumer)
            {
                0x003A
            }
            GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.GPO0", 0x00, ResourceConsumer)
            {
                0x003D
            }
        })

In this case it finds the first GPIO (0x003A which happens to be RX pin
for that UART), turns it into GPIO which then breaks input for the UART
device. This also breaks systems with bluetooth connected to UART (those
typically have some GPIOs in their _CRS).

Any ideas how to fix this?

We cannot just drop the _CRS index lookup fallback because that would
break many existing machines out there so maybe we can limit this to
only DT enabled machines. Or alternatively probe if the property first
exists before trying to acquire the GPIOs (using
device_property_present()).
"

This patch implements the fix suggested by Mika in his statement above.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Giulio Benetti <giulio.benetti@micronovasrl.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-21 10:18:43 +02:00
..
8250 serial: 8250: pericom_do_set_divisor can be static 2019-06-18 13:37:57 +02:00
cpm_uart tty: cpm_uart: drop unused iflag macro 2019-05-24 10:09:16 +02:00
jsm tty: add SPDX identifiers to Kconfig and Makefiles 2019-04-04 18:48:43 +02:00
21285.c
altera_jtaguart.c
altera_uart.c
amba-pl010.c
amba-pl011.c tty: amba-pl011: allow shared interrupt 2019-05-21 12:12:03 +02:00
amba-pl011.h
apbuart.c
apbuart.h
ar933x_uart.c serial: ar933x_uart: Fix build failure with disabled console 2019-03-19 15:37:44 +01:00
arc_uart.c serial: arc_uart: Fix out-of-bounds access through DT alias 2018-02-28 15:29:59 +01:00
atmel_serial.c tty/serial: atmel: RS485 HD w/DMA: enable RX after TX is stopped 2019-03-28 00:27:48 +09:00
atmel_serial.h tty/serial: atmel: add ISO7816 support 2018-10-02 13:38:55 -07:00
bcm63xx_uart.c
clps711x.c serial: clps711x: Remove board support 2019-01-08 16:55:18 +01:00
digicolor-usart.c tty/serial: digicolor: Fix digicolor-usart already registered warning 2019-06-10 19:08:31 +02:00
dz.c
dz.h
earlycon-arm-semihost.c
earlycon-riscv-sbi.c tty/serial: use uart_console_write in the RISC-V SBL early console 2019-01-23 15:41:50 -08:00
earlycon.c earlycon: Remove hardcoded port->uartclk initialization in of_setup_earlycon 2018-05-14 13:41:05 +02:00
efm32-uart.c
fsl_lpuart.c serial: fsl_lpuart: Remove unneeded OOM error message 2019-06-18 09:34:28 +02:00
icom.c
icom.h
ifx6x60.c
ifx6x60.h
imx.c serial: imx: fix locking in set_termios() 2019-06-18 09:30:44 +02:00
ioc3_serial.c
ioc4_serial.c
ip22zilog.c
ip22zilog.h
Kconfig tty: serial: add driver for the SiFive UART 2019-04-29 16:30:59 +02:00
kgdb_nmi.c
kgdboc.c Disable kgdboc failed by echo space to /sys/module/kgdboc/parameters/kgdboc 2019-03-28 00:27:48 +09:00
lantiq.c serial: lantiq: Do not swap register read/writes 2019-01-08 16:53:36 +01:00
lpc32xx_hs.c tty: serial: lpc32xx_hs: fix missing console boot messages 2019-01-18 11:23:00 +01:00
Makefile tty: serial: add driver for the SiFive UART 2019-04-29 16:30:59 +02:00
max310x.c Merge 5.2-rc3 into tty-next 2019-06-03 13:53:20 +02:00
max3100.c
mcf.c
men_z135_uart.c drivers: Remove explicit invocations of mmiowb() 2019-04-08 12:01:02 +01:00
meson_uart.c tty: serial: meson: if no alias specified use an available id 2019-01-18 11:22:22 +01:00
milbeaut_usio.c serial: milbeaut_usio: Fix error handling in probe and remove 2019-04-29 16:20:24 +02:00
mpc52xx_uart.c
mps2-uart.c serial: mps2-uart: Add parentheses around conditional in mps2_uart_shutdown 2019-01-31 19:34:10 +01:00
mpsc.c
msm_serial.c tty: serial: msm_serial: avoid system lockup condition 2019-06-10 19:42:35 +02:00
mux.c
mvebu-uart.c serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference 2019-03-19 15:37:43 +01:00
mxs-auart.c tty: mxs-auart: fix a potential NULL pointer dereference 2019-03-19 15:37:43 +01:00
netx-serial.c
omap-serial.c
owl-uart.c
pch_uart.c PCI: Move Rohm Vendor ID to generic list 2019-02-01 17:24:52 -06:00
pic32_uart.c serial: set suppress_bind_attrs flag only if builtin 2018-11-09 09:07:17 -08:00
pic32_uart.h
pmac_zilog.c tty: Use of_node_name_{eq,prefix} for node name comparisons 2018-12-17 16:12:17 +01:00
pmac_zilog.h
pnx8xxx_uart.c
pxa.c serial: pxa: Fix an error handling path in 'serial_pxa_probe()' 2018-06-28 21:07:54 +09:00
qcom_geni_serial.c tty: serial: qcom_geni_serial: Initialize baud in qcom_geni_console_setup 2019-03-19 15:37:44 +01:00
rda-uart.c tty: serial: Add RDA8810PL UART driver 2018-12-31 13:10:01 -08:00
rp2.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
sa1100.c
samsung.c tty: serial: samsung: Enable baud clock during initialisation 2019-02-19 13:42:08 +01:00
samsung.h
sb1250-duart.c
sc16is7xx.c Merge 5.1-rc6 into tty-next 2019-04-21 23:20:08 +02:00
sccnxp.c serial: sccnxp: Allow to use non-standard baud rates 2018-12-20 16:26:59 +01:00
serial_core.c tty: serial_core: Set port active bit in uart_port_activate 2019-06-18 09:52:26 +02:00
serial_ks8695.c
serial_mctrl_gpio.c serial: mctrl_gpio: Check if GPIO property exisits before requesting it 2019-06-21 10:18:43 +02:00
serial_mctrl_gpio.h
serial_txx9.c drivers: Remove explicit invocations of mmiowb() 2019-04-08 12:01:02 +01:00
serial-tegra.c serial: tegra: fix some spelling mistakes 2018-11-09 08:58:18 -08:00
sh-sci.c serial: sh-sci: disable DMA for uart_console 2019-05-21 12:18:17 +02:00
sh-sci.h serial: sh-sci: Support for HSCIF RX sampling point adjustment 2018-04-23 10:08:18 +02:00
sifive.c tty: serial: add driver for the SiFive UART 2019-04-29 16:30:59 +02:00
sirfsoc_uart.c serial: sirf: Fix out-of-bounds access through DT alias 2018-02-28 15:30:00 +01:00
sirfsoc_uart.h
sn_console.c tty: fix up a few remaining files without SPDX identifiers 2019-04-04 18:48:43 +02:00
sprd_serial.c serial: sprd: Fix a copy-paste err in sprd_request_dma() 2019-04-16 15:21:33 +02:00
st-asc.c tty: serial: simplify getting .drvdata 2018-04-22 17:29:43 +02:00
stm32-usart.c Revert "serial: stm32: select pinctrl state in each suspend/resume function" 2019-06-13 08:10:45 +02:00
stm32-usart.h serial: stm32: fix rx data length when parity enabled 2019-05-24 09:58:29 +02:00
suncore.c tty: Use of_node_name_{eq,prefix} for node name comparisons 2018-12-17 16:12:17 +01:00
sunhv.c
sunsab.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
sunsab.h
sunsu.c TTY/Serial driver patches for 4.21-rc1 2018-12-28 20:33:54 -08:00
sunzilog.c
sunzilog.h
tegra-tcu.c serial: Add Tegra Combined UART driver 2019-01-30 09:31:31 +01:00
timbuart.c
timbuart.h
uartlite.c serial-uartlite: fix null pointer dereference on pointer port 2018-11-27 09:08:15 +01:00
ucc_uart.c docs: serial: convert docs to ReST and rename to *.rst 2019-04-25 11:37:42 +02:00
vr41xx_siu.c
vt8500_serial.c
xilinx_uartps.c serial: uartps: Remove useless return from cdns_uart_poll_put_char 2019-06-18 09:34:28 +02:00
zs.c
zs.h