u-boot-brain/drivers/serial
Wolfgang Wallner 720f9e1fdb serial: ns16550: Move PCI access from ofdata_to_platdata() to probe()
Currently the ofdata_to_platdata() method calls dev_read_addr_pci(),
which potentially accesses the parent PCI bus. If this happens before
the parent PCI bus is probed the resulting address will be wrong.

This behavior was triggered by commit 82de42fa14 ("dm: core:
Allocate parent data separate from probing parent").

According to a comment in drivers/pci/pci-uclass.c [1] accessing
the PCI parent bus in ofdata_to_platdata() is not allowed, and the
access should be moved to the probe() function.

Move the call to dev_read_addr_pci() and the related handling of the
'addr' value from the ofdata_to_platdata() to its own function,
which is then called from the probe() method.

While moving the code, the comment /* try Processor Local Bus device
first */ was dropped. It was initially added with commit 3db886a5bf
("serial: ns16550: Support ns16550 compatible pci uart devices") and
later made obsolete with commit 33c215af4b ("dm: pci: Add a function
to read a PCI BAR").

[1] Comment in drivers/pci/pci-uclass.c:
"A common cause of this problem is that this function is called in the
ofdata_to_platdata() method of @dev. Accessing the PCI bus in that
method is not allowed, since it has not yet been probed. To fix this,
move that access to the probe() method of @dev instead."

Fixes: 82de42fa14 ("dm: core: Allocate parent data separate from probing parent")
Signed-off-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com> # Tested on Intel Galileo
2020-03-05 18:25:10 +08:00
..
altera_jtag_uart.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
altera_uart.c serial: altera_uart: convert to livetree 2019-05-10 22:48:11 +02:00
arm_dcc.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
atmel_usart.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
atmel_usart.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
Kconfig serial: serial_cortina: add UART DM driver for CAxxxx SoCs 2020-02-07 16:16:01 -05:00
lpc32xx_hsuart.c common: Move clock functions into a new file 2020-01-17 13:27:29 -05:00
Makefile serial: serial_cortina: add UART DM driver for CAxxxx SoCs 2020-02-07 16:16:01 -05:00
mcfuart.c drivers: serial: mcfuart: add DT support 2019-05-24 08:11:58 -04:00
ns16550.c serial: ns16550: Move PCI access from ofdata_to_platdata() to probe() 2020-03-05 18:25:10 +08:00
sandbox.c serial: sandbox: support Unicode 2019-12-10 05:54:55 -07:00
serial_ar933x.c common: Move clock functions into a new file 2020-01-17 13:27:29 -05:00
serial_arc.c serial_arc: Allocate buffer for private data 2019-01-25 08:40:26 +03:00
serial_bcm283x_mu.c drivers: bcm283x: Set pre-location flag for OF_BOARD 2019-11-24 10:46:27 +01:00
serial_bcm283x_pl011.c drivers: bcm283x: Set pre-location flag for OF_BOARD 2019-11-24 10:46:27 +01:00
serial_bcm6345.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial_coreboot.c x86: serial: Add a coreboot serial driver 2020-02-04 01:19:25 +08:00
serial_cortina.c serial: serial_cortina: add UART DM driver for CAxxxx SoCs 2020-02-07 16:16:01 -05:00
serial_efi.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_intel_mid.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_linflexuart.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
serial_lpuart.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial_meson.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_mpc8xx.c drivers: serial: get rid of non DM mpc8xx driver 2018-12-03 10:44:10 -05:00
serial_msm.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial_mtk.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
serial_mvebu_a3700.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_mxc.c serial: mxc: Add compatibles to NXP's serial driver (for imx21 and imx53) 2019-07-19 20:32:24 +02:00
serial_ns16550.c common: Move clock functions into a new file 2020-01-17 13:27:29 -05:00
serial_nulldev.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
serial_omap.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
serial_owl.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_pic32.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial_pl01x_internal.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
serial_pl01x.c drivers: serial: dm: Enable DM_FLAG_PRE_RELOC in SBSA pl011 uart driver 2019-02-09 07:50:55 -05:00
serial_pxa.c common: Move hang() to the same header as panic() 2020-01-17 17:53:40 -05:00
serial_rockchip.c rockchip: use 'arch-rockchip' as header file path 2019-05-01 00:00:05 +02:00
serial_s5p.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_sh.c serial: sh: Drop assorted SH3, SH4, SH5 macros 2019-05-10 22:43:18 +02:00
serial_sh.h sh: sh3: Remove CPU support 2019-05-10 22:43:18 +02:00
serial_sifive.c dm: core: Require users of devres to include the header 2020-02-05 19:33:46 -07:00
serial_sti_asc.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_stm32.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial_stm32.h serial: stm32: add Framing error support 2019-08-27 11:19:23 +02:00
serial_uniphier.c serial: uniphier: set clock rate without clock-frequency property 2018-06-23 01:28:15 +09:00
serial_xuartlite.c serial: Remove DM_FLAG_PRE_RELOC flag in various drivers 2018-11-14 09:16:28 -08:00
serial_zynq.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial-uclass.c dm: core: Create a new header file for 'compat' features 2020-02-05 19:33:46 -07:00
serial.c common: Move hang() to the same header as panic() 2020-01-17 17:53:40 -05:00
usbtty.c serial: usb: Correct the usbtty_...() prototypes 2019-12-02 18:23:10 -05:00
usbtty.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00