summaryrefslogtreecommitdiff
path: root/drivers/serial/serial_msm.c
AgeCommit message (Collapse)Author
2025-10-29serial: msm: Use single character modeStephan Gerhold
The UART DM controller supports different channel data packing modes, either the 4-character packing mode (where 32-bit are read/written at once) or the single-character mode (where only a single character is read/written at a time). The 4-character mode can be more efficient, but the single-character mode is much easier to implement. At the moment, serial_msm uses the 4-character mode. Since the dm_serial_ops operate on one character at the time, the code goes through quite some hoops in order to break this down to single characters. This code is prone to race conditions (e.g. priv->chars_cnt is read from the registers, then a command is issued, what if another char came in inbetween?). It also seems to cause another subtle issue with autoboot: Unlike the previous autoboot failures that happened when UART was disconnected, this problem occurs when UART is connected and open in a terminal: For EFI boot, the console size is queried in efi_console.c query_console_serial() by sending an ANSI escape code via UART. For some reason, with the current driver we get yet another 0x00 byte (UART break event?) when reading the reply from serial input. Because of that, reading the console size fails in efi_console.c, the actual reply remains in the UART buffer, and later the boot flow aborts because it detects input after printing a prompt. Rather than trying to fix the issue in the current complicated approach, switch the driver to use the single-character mode. This is simple and straightforward to implement without race conditions: - We write one character at a time to UARTDM_TF, as long as the TX FIFO has space available (TX_READY). To flush the console before starting Linux, we wait for TX_EMPTY. - We read one character at a time from UARTDM_RF and strip off the additional error information (assuming there is something in the RX FIFO, as indicated by RX_READY). In this mode, querying the serial console size works and autoboot is no longer interrupted. The overall code is also much shorter. Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Stephan Gerhold <[email protected]> Tested-by: Alexey Minnekhanov <[email protected]> Acked-by: Sumit Garg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-10-29serial: msm: Re-enable after resettingStephan Gerhold
The documentation for the UART controller in the APQ8016E specifies that both RESET and ENABLE commands must be issued to set up the receiver and transmitter, but at the moment we only issue RESET. This doesn't seem to cause issues in practice (looks like the reset already re-enables the receiver/transmitter), but let's add the two writes to RX_ENABLE/TX_ENABLE to better match the recommendations in the documentation. Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Stephan Gerhold <[email protected]> Tested-by: Alexey Minnekhanov <[email protected]> Acked-by: Sumit Garg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-10-29serial: msm: Reset after writing to DMENStephan Gerhold
According to the documentation of the UART controller in the APQ8016E TRM, clearing bits inside UARTDM_DMEN requires resetting the transmitter and/or receiver. We do reset inside uart_dm_init(), but before writing to UARTDM_DMEN. This doesn't seem to cause problems in practice, but let's move the reset to the end of uart_dm_init() to better match the recommendations in the documentation. Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Stephan Gerhold <[email protected]> Tested-by: Alexey Minnekhanov <[email protected]> Acked-by: Sumit Garg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-10-29serial: msm: Cleanup register namingStephan Gerhold
Some of the register definitions are inconsistently named (likely copied as-is from Qualcomm's Little Kernel/LK bootloader, which uses the MSM_BOOT_UART naming scheme). Rename them to be in line with the other register definitions and move them up to be next to the related register. No functional change. Signed-off-by: Stephan Gerhold <[email protected]> Tested-by: Alexey Minnekhanov <[email protected]> Acked-by: Sumit Garg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-10-29Revert "serial: serial_msm: Delay initialization to let pins stabilize"Stephan Gerhold
There have been issues with autoboot on DB410c for years, where autoboot gets interrupted by spurious input on the UART console. Back in 2021, I've tried to fix this by inserting a delay before UART initialization, but it has turned out this is not working reliably either. It looks like the root cause has always been the lack of bias-pull-up, which was causing the RX line to be floating when UART is disconnected. The delay does not seem to be needed anymore when applying bias-pull-up, so drop it again in favor of the proper fix. This reverts commit ad7e967738a9c639e07cf50b83ffccdf9a8537b0. Signed-off-by: Stephan Gerhold <[email protected]> Tested-by: Alexey Minnekhanov <[email protected]> Acked-by: Sumit Garg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-07serial: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from this driver directory and when needed add missing include files directly. Reviewed-by: Peter Robinson <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-04-23serial_msm: Enable RS232 flow controlSumit Garg
SE HMIBSC board debug console requires RS232 flow control, so enable corresponding support if RS232 gpios are present. Reviewed-by: Caleb Connolly <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Signed-off-by: Caleb Connolly <[email protected]>
2024-04-23apq8016: Add support for UART1 clocks and pinmuxSumit Garg
SE HMIBSC board uses UART1 as the main debug console, so add corresponding clocks and pinmux support. Along with that update instructions to enable clocks for debug UART support. Reviewed-by: Caleb Connolly <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Signed-off-by: Caleb Connolly <[email protected]>
2024-04-23serial: msm: calculate bit clock dividerCaleb Connolly
The driver currently requires the bit clock divider be hardcoded in devicetree (or use the hardcoded default from apq8016). The bit clock divider is used to derive the baud rate from the core clock: baudrate = clk_rate / csr_div clk_rate is the actual programmed core clock rate which is returned by clk_set_rate(), and this UART driver only supports a baudrate of 115200. We can therefore determine the appropriate value for UARTDM_CSR by iterating over the possible values and finding the one where the equation above holds true for a baudrate of 115200. Implement this logic and drop the non-standard DT bindings for this driver. Tested on dragonboard410c. Tested-by: Robert Marko <[email protected]> Signed-off-by: Caleb Connolly <[email protected]>
2024-04-23serial: msm_serial: remove .clk_rate from debug UARTRobert Marko
MSM serial in DEBUG UART mode is trying to set .clk_rate, but the msm_serial_data structure does not have such property at all, so lets remove it as otherwise it will fail compiling. Fixes: 90023bdfe979 ("serial: msm: add debug UART") Signed-off-by: Robert Marko <[email protected]> Reviewed-by: Caleb Connolly <[email protected]> Signed-off-by: Caleb Connolly <[email protected]>
2024-03-01serial: msm: fix clock handling and pinctrlCaleb Connolly
Use the modern helpers to fetch the clock and use the correct property ("clocks" instead of "clock"). Drop the call to pinctrl_select_state() as no boards have a "uart" pinctrl state and this prints confusing errors. Reviewed-by: Neil Armstrong <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Tested-by: Sumit Garg <[email protected]> #qcs404 Signed-off-by: Caleb Connolly <[email protected]>
2024-03-01serial: msm: add debug UARTCaleb Connolly
Introduce support for early debugging. This relies on the previous stage bootloader to initialise the UART clocks, when running with U-Boot as the primary bootloader this feature doesn't work. It will require a way to configure the clocks before the driver model is available. Reviewed-by: Neil Armstrong <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Caleb Connolly <[email protected]>
2024-01-29treewide: Remove clk_freeSean Anderson
This function is a no-op. Remove it. Signed-off-by: Sean Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2021-09-30WS cleanup: remove trailing white spaceWolfgang Denk
Signed-off-by: Wolfgang Denk <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-07-23serial: serial_msm: Delay initialization to let pins stabilizeStephan Gerhold
For some reason, the DragonBoard 410c aborts autoboot immediately if U-Boot is started without LK. It looks like it picks up a single broken character via serial and therefore believes a key was pressed to abort autoboot. After some debugging, it seems like adding some delay after pinctrl setup but before UART initialization fixes the issue. It's also worth mentioning that unlike when booting from LK, the pinctrl setup is actually necessary when booting U-Boot without LK since UART is broken if the pinctrl line is removed. I suspect that reconfiguring the pins might take some time to stabilize and if the UART controller is enabled too quickly it will pick up some random noise. Adding a few milliseconds of delay fixes the issue and shouldn't have any other negative side effects. 3ms seems to be the minimum delay required in my tests, use 5ms instead just to be sure. Signed-off-by: Stephan Gerhold <[email protected]>
2021-07-06serial: serial_msm: Ensure BAM/single character mode are disabledStephan Gerhold
At the moment, the U-Boot serial_msm driver does not initialize the UART_DM_DMEN register with the required value. Usually this does not cause any problems, because there is Qualcomm's LK bootloader running before U-Boot which initializes the register with the correct value. It's important that this register is initialized correctly, because the U-Boot driver does not make use of the BAM/DMA or single character mode functionality of the UART controller. A different bootloader before U-Boot might initialize the register differently. For example, on DragonBoard 410c U-Boot can also be installed to the "aboot" partition (replacing LK entirely). In this case U-Boot is loaded directly by SBL, which seems to use the single-character mode for some reason. In single character mode there is always just one char in the FIFO, instead of the 4 characters expected by msm_serial_fetch(). It also causes issues with "earlycon" later in the Linux kernel, which tries to output 4 chars at once, but only the first char will be written. This causes early UART log in Linux to be corrupted like this: [ 00ano:ameoi .Q1B[ 00ac _idaM00080oo'ahani-lcle._20). 15NdNii 5 SPMSJ20:U2 [ 00rkoolmsamel [ 00Fw ]elamletopsioble [ 00ore instead of [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd030] [ 0.000000] Machine model: Qualcomm Technologies, Inc. APQ 8016 SBC [ 0.000000] earlycon: msm_serial_dm0 at MMIO 0x00000000078b0000 (options '') [ 0.000000] printk: bootconsole [msm_serial_dm0] enabled Make sure to initialize UART_DM_DMEN correctly to fix this issue when loading U-Boot directly after SBL (instead of through LK). There is no functional difference when loading U-Boot through LK since LK also initializes UART_DM_DMEN to 0x0. [1] [1]: https://git.linaro.org/landing-teams/working/qualcomm/lk.git/tree/platform/msm_shared/uart_dm.c?h=dragonboard410c-LA.BR.1.2.7-03810-8x16.0-linaro3#n203 Cc: Ramon Fried <[email protected]> Signed-off-by: Stephan Gerhold <[email protected]> Reviewed-by: Ramon Fried <[email protected]>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2020-12-13dm: treewide: Rename ofdata_to_platdata() to of_to_plat()Simon Glass
This name is far too long. Rename it to remove the 'data' bits. This makes it consistent with the platdata->plat rename. Signed-off-by: Simon Glass <[email protected]>
2020-12-13dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <[email protected]>
2020-07-29msm_serial: Read bit rate register value from DTRobert Marko
IPQ40xx and currently supported Snapdragon boards don't use the same one so enable reading it from DT, if no DT property is found default value is the same as the previous define. Signed-off-by: Robert Marko <[email protected]> Reviewed-By: Ramon Fried <[email protected]>
2020-07-25treewide: convert devfdt_get_addr() to dev_read_addr()Masahiro Yamada
When you enable CONFIG_OF_LIVE, you will end up with a lot of conversions. To generate this commit, I used coccinelle excluding drivers/core/, include/dm/, and test/ The semantic patch that makes this change is as follows: <smpl> @@ expression dev; @@ -devfdt_get_addr(dev) +dev_read_addr(dev) </smpl> Signed-off-by: Masahiro Yamada <[email protected]>
2020-07-24Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini
This reverts commit 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7, reversing changes made to 56d37f1c564107e27d873181d838571b7d7860e7. Unfortunately this is causing CI failures: https://travis-ci.org/github/trini/u-boot/jobs/711313649 Signed-off-by: Tom Rini <[email protected]>
2020-07-20treewide: convert devfdt_get_addr() to dev_read_addr()Masahiro Yamada
When you enable CONFIG_OF_LIVE, you will end up with a lot of conversions. To generate this commit, I used coccinelle excluding drivers/core/, include/dm/, and test/ The semantic patch that makes this change is as follows: <smpl> @@ expression dev; @@ -devfdt_get_addr(dev) +dev_read_addr(dev) </smpl> Signed-off-by: Masahiro Yamada <[email protected]>
2020-02-05dm: core: Create a new header file for 'compat' featuresSimon Glass
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <[email protected]>
2018-05-26serial: serial_msm: added pinmux & configRamon Fried
Serial port configuration was missing from previous implementation. It only worked because it was preconfigured by LK. This patch configures the uart for 115200 8N1. It also configures the pin mux for uart pins using DT bindings. Signed-off-by: Ramon Fried <[email protected]>
2018-05-26serial: serial_msm: initialize uart only before relocationRamon Fried
The uart is already initialized prior to relocation, reinitialization after relocation is unnecessary. Signed-off-by: Ramon Fried <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2018-05-26serial: serial_msm: fail probe if settings clocks failsRamon Fried
Failure to set the clocks will causes data abort exception when trying to write to AHB uart registers. This patch ensures that we don't touch these registers if clock setting failed. Signed-off-by: Ramon Fried <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <[email protected]>
2017-06-01dm: Rename dev_addr..() functionsSimon Glass
These support the flat device tree. We want to use the dev_read_..() prefix for functions that support both flat tree and live tree. So rename the existing functions to avoid confusion. In the end we will have: 1. dev_read_addr...() - works on devices, supports flat/live tree 2. devfdt_get_addr...() - current functions, flat tree only 3. of_get_address() etc. - new functions, live tree only All drivers will be written to use 1. That function will in turn call either 2 or 3 depending on whether the flat or live tree is in use. Note this involves changing some dead code - the imx_lpi2c.c file. Signed-off-by: Simon Glass <[email protected]>
2017-02-08dm: core: Replace of_offset with accessorSimon Glass
At present devices use a simple integer offset to record the device tree node associated with the device. In preparation for supporting a live device tree, which uses a node pointer instead, refactor existing code to access this field through an inline function. Signed-off-by: Simon Glass <[email protected]>
2016-06-19clk: convert API to match reset/mailbox styleStephen Warren
The following changes are made to the clock API: * The concept of "clocks" and "peripheral clocks" are unified; each clock provider now implements a single set of clocks. This provides a simpler conceptual interface to clients, and better aligns with device tree clock bindings. * Clocks are now identified with a single "struct clk", rather than requiring clients to store the clock provider device and clock identity values separately. For simple clock consumers, this isolates clients from internal details of the clock API. * clk.h is split so it only contains the client/consumer API, whereas clk-uclass.h contains the provider API. This aligns with the recently added reset and mailbox APIs. * clk_ops .of_xlate(), .request(), and .free() are added so providers can customize these operations if needed. This also aligns with the recently added reset and mailbox APIs. * clk_disable() is added. * All users of the current clock APIs are updated. * Sandbox clock tests are updated to exercise clock lookup via DT, and clock enable/disable. * rkclk_get_clk() is removed and replaced with standard APIs. Buildman shows no clock-related errors for any board for which buildman can download a toolchain. test/py passes for sandbox (which invokes the dm clk test amongst others). Signed-off-by: Stephen Warren <[email protected]> Acked-by: Simon Glass <[email protected]>
2016-04-01serial: Add support for Qualcomm serial portMateusz Kulikowski
This driver works in "new" Data Mover UART mode, so will be compatible with modern Qualcomm chips only. Signed-off-by: Mateusz Kulikowski <[email protected]> Reviewed-by: Simon Glass <[email protected]> Tested-by: Simon Glass <[email protected]>