reg = <0x0 0xffd24000 0x0 0x18>;
interrupts = <0 26 1>;
status = "disable";
- clocks = <&xtal>;
- clock-names = "clk_uart";
+ clocks = <&xtal
+ &clkc CLKID_UART0>;
+ clock-names = "clk_uart",
+ "clk_gate";
fifosize = < 128 >;
pinctrl-names = "default";
pinctrl-0 = <&a_uart_pins>;
reg = <0x0 0xffd23000 0x0 0x18>;
interrupts = <0 75 1>;
status = "disable";
- clocks = <&xtal>;
- clock-names = "clk_uart";
+ clocks = <&xtal
+ &clkc CLKID_UART1>;
+ clock-names = "clk_uart",
+ "clk_gate";
fifosize = < 64 >;
pinctrl-names = "default";
pinctrl-0 = <&b_uart_pins>;
reg = <0x0 0xffd24000 0x0 0x18>;
interrupts = <0 26 1>;
status = "okay";
- clocks = <&xtal>;
- clock-names = "clk_uart";
+ clocks = <&xtal
+ &clkc CLKID_UART0>;
+ clock-names = "clk_uart",
+ "clk_gate";
fifosize = < 128 >;
pinctrl-names = "default";
pinctrl-0 = <&a_uart_pins>;
reg = <0x0 0xffd23000 0x0 0x18>;
interrupts = <0 75 1>;
status = "disable";
- clocks = <&xtal>;
- clock-names = "clk_uart";
+ clocks = <&xtal
+ &clkc CLKID_UART1>;
+ clock-names = "clk_uart",
+ "clk_gate";
fifosize = < 64 >;
pinctrl-names = "default";
pinctrl-0 = <&b_uart_pins>;
reg = <0x0 0xffd24000 0x0 0x18>;
interrupts = <0 26 1>;
status = "okay";
- clocks = <&xtal>;
- clock-names = "clk_uart";
+ clocks = <&xtal
+ &clkc CLKID_UART0>;
+ clock-names = "clk_uart",
+ "clk_gate";
fifosize = < 128 >;
pinctrl-names = "default";
pinctrl-0 = <&a_uart_pins>;
reg = <0x0 0xffd23000 0x0 0x18>;
interrupts = <0 75 1>;
status = "disable";
- clocks = <&xtal>;
- clock-names = "clk_uart";
+ clocks = <&xtal
+ &clkc CLKID_UART1>;
+ clock-names = "clk_uart",
+ "clk_gate";
fifosize = < 64 >;
pinctrl-names = "default";
pinctrl-0 = <&b_uart_pins>;
dev_info(&pdev->dev, "ttyS%d use xtal(24M) %d change %ld to %ld\n",
port->line, port->uartclk,
mup->baud, baud);
- val = (port->uartclk) / baud - 1;
+ val = (port->uartclk + baud / 2) / baud - 1;
val |= (AML_UART_BAUD_USE|AML_UART_BAUD_XTAL
|AML_UART_BAUD_XTAL_TICK);
} else {
dev_info(&pdev->dev, "ttyS%d use xtal(8M) %d change %ld to %ld\n",
port->line, port->uartclk,
mup->baud, baud);
- val = (port->uartclk / 3) / baud - 1;
+ val = ((port->uartclk / 3) + baud / 2) / baud - 1;
+ val &= (~AML_UART_BAUD_XTAL_TICK);
val |= (AML_UART_BAUD_USE|AML_UART_BAUD_XTAL);
}
} else {
port->line, port->uartclk,
mup->baud, baud);
val = ((port->uartclk * 10 / (baud * 4) + 5) / 10) - 1;
+ val &= (~(AML_UART_BAUD_XTAL|AML_UART_BAUD_XTAL_TICK));
val |= AML_UART_BAUD_USE;
}
writel(val, port->membase + AML_UART_REG5);
spin_lock_init(&mup->wr_lock);
port = &mup->port;
#ifdef CONFIG_AMLOGIC_CLK
+ clk = devm_clk_get(&pdev->dev, "clk_gate");
+ if (IS_ERR(clk)) {
+ pr_err("%s: clock gate not found\n", dev_name(&pdev->dev));
+ /* return PTR_ERR(clk); */
+ } else {
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ pr_err("uart: clock failed to prepare+enable: %d\n",
+ ret);
+ clk_put(clk);
+ /* return ret; */
+ }
+ }
clk = devm_clk_get(&pdev->dev, "clk_uart");
if (IS_ERR(clk)) {
- pr_err("%s: clock not found\n", dev_name(&pdev->dev));
+ pr_err("%s: clock source not found\n", dev_name(&pdev->dev));
/* return PTR_ERR(clk); */
}
- ret = clk_prepare_enable(clk);
- if (ret) {
- pr_err("uart: clock failed to prepare+enable: %d\n", ret);
- clk_put(clk);
- /* return ret; */
- }
+ port->uartclk = clk_get_rate(clk);
#endif
port->fifosize = 64;
xtal_tick_en = of_read_ulong(prop, 1);
}
xtal_tick_en = 0;
- port->uartclk = 24000000;
+
port->iotype = UPIO_MEM;
port->mapbase = res_mem->start;
port->irq = res_irq->start;