Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92
假设项目有需求要将调试串口uart2 改成 uart1, 改动如下
(还未验证,先分享给大家,有问题或者验证过的请告知.)
kernel/arch/arm/mach-rockchip/rk_fiq_debugger.c
static int debug_port_init(struct platform_device *pdev)int dll = 0, dlm = 0;
struct rk_fiq_debugger *t;
t = container_of(dev_get_platdata(&pdev->dev), typeof(*t), pdata);
if (rk_fiq_read(t, UART_LSR) & UART_LSR_DR)
(void)rk_fiq_read(t, UART_RX);
//switch (t->baudrate) {
//case 1500000:
//dll = 0x1;
//break;
//case 115200:
//default:
dll = 0xd;
//break;
//}
rk_fiq_write(t, 0x83, UART_LCR);
/* set baud rate */
rk_fiq_write(t, dll, UART_DLL);
rk_fiq_write(t, dlm, UART_DLM);
rk_fiq_write(t, 0x03, UART_LCR);
/* enable rx and lsr interrupt */
rk_fiq_write(t, UART_IER_RLSI | UART_IER_RDI, UART_IER);
/* interrupt on every character when receive,but we can enable fifo for TX
I found that if we enable the RX fifo, some problem may vanish such as when
you continuously input characters in the command line the uart irq may be disable
because of the uart irq is served when CPU is at IRQ exception,but it is
found unregistered, so it is disable.
hhb@rock-chips.com */
rk_fiq_write(t, 0xc1, UART_FCR);
return 0;
}
rk3288.dtsi
fiq_debugger: fiq-debugger {
compatible = "rockchip,fiq-debugger";
rockchip,serial-id = <1>;
rockchip,signal-irq = <182>;
rockchip,wake-irq = <0>;
rockchip,irq-mode-enable = <1>; /* If enable uart uses irq instead of fiq /
rockchip,baudrate = <1500000>; / Only 115200 and 1500000 */
pinctrl-names = "default";
pinctrl-0 = <&uart1_xfer>;
};
node的定义可参考 kernel/Documentation/devicetree/bindings/serial/rockchip_fiq_debugger.txt
* Fiq debugger based on UART
- compatible: "rockchip,fiq-debugger"
Compatibility with all rk30xx rk31xx rk32xx rk33xx SOCs.
- rockchip,serial-id: The uart which is used as debug port, start from 0,1,2,3...
- rockchip,signal-irq: A hardware interrupt without source, which is triggered by FIQ handler to call functions that
must be called in IRQ context. Often it is configured by
soc developer.
- rockchip,wake-irq: It is used to wake up fiq debugger, but usually not used.
- rockchip,irq-mode-enable: If it is set 1, uart uses irq instead of fiq.
- rockchip,baudrate: Only 115200 and 1500000.
Example: fiq-debugger {
compatible = "rockchip,fiq-debugger";
rockchip,serial-id = <2>;
rockchip,signal-irq = <186>;
rockchip,wake-irq = <0>;
rockchip,irq-mode-enable = <0>;
rockchip,baudrate = <115200>;
status = "disabled";
};