Skip to content

Commit 1145c19

Browse files
committed
serial/uart_ns16550: support cec1702 alternate clock
CEC1702 ns16550 compatible UART has alternate high-speed clock selectable with the high bit of the baud rate divisor register. Signed-off-by: Timo Teräs <[email protected]>
1 parent b801c5f commit 1145c19

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

drivers/serial/uart_ns16550.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ BUILD_ASSERT_MSG(IS_ENABLED(CONFIG_PCIE), "NS16550(s) in DT need CONFIG_PCIE");
7878
#define REG_DLF 0xC0 /* Divisor Latch Fraction */
7979
#define REG_PCP 0x200 /* PRV_CLOCK_PARAMS (Apollo Lake) */
8080

81+
/* equates for baud rate divisor register */
82+
83+
#define BRD_MCHP_XEC_BAUD_CLK_SEL 0x8000 /* microchip uart: use system clock */
84+
8185
/* equates for interrupt enable register */
8286

8387
#define IER_RXRDY 0x01 /* receiver data ready */
@@ -300,6 +304,11 @@ static void set_baud_rate(struct device *dev, u32_t baud_rate)
300304
*/
301305
divisor = ((dev_cfg->sys_clk_freq + (baud_rate << 3))
302306
/ baud_rate) >> 4;
307+
#if defined(DT_COMPAT_MICROCHIP_XEC_NS16550)
308+
if (dev_cfg->sys_clk_freq == CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {
309+
divisor |= BRD_MCHP_XEC_BAUD_CLK_SEL;
310+
}
311+
#endif
303312

304313
/* set the DLAB to access the baud rate divisor registers */
305314
lcr_cache = INBYTE(LCR(dev));

dts/arm/microchip/cec1702.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828

2929
soc {
3030
uart0: uart@400f2400 {
31-
compatible = "ns16550";
31+
compatible = "ns16550", "microchip,xec-ns16550";
3232
reg = <0x400f2400 0x400>;
3333
interrupts = <40 0>;
3434
clock-frequency = <1843200>;
3535
label = "UART_0";
3636
reg-shift = <0>;
3737
};
3838
uart1: uart@400f2800 {
39-
compatible = "ns16550";
39+
compatible = "ns16550", "microchip,xec-ns16550";
4040
reg = <0x400f2800 0x400>;
4141
interrupts = <41 0>;
4242
clock-frequency = <1843200>;

0 commit comments

Comments
 (0)