新路程------imx6的uart小結(1)
imx6用的是RS485,今天看看這個介面是怎麼初始化的。
首先在./arch/arm/mach-mx6/board-mx6q_sabresd.c裡找uart的相關資訊
在static void __init mx6_sabresd_board_init(void)肯定會有初始化的相關資訊
gpio_request(SABRESD_EPDC_PWRSTAT, "uart2_en"); 申請gpio
gpio_direction_output(SABRESD_EPDC_PWRSTAT, 1); 設定輸入輸出
gpio_set_value(SABRESD_EPDC_PWRSTAT, 1); 設定初始電平
gpio_request(SABRESD_EPDC_PWRCTRL0, "uart2_rts");
gpio_direction_output(SABRESD_EPDC_PWRCTRL0, 1);
gpio_set_value(SABRESD_EPDC_PWRCTRL0, 1);
gpio_request(SABRESD_EPDC_PWRCTRL1, "uart3_en");
gpio_direction_output(SABRESD_EPDC_PWRCTRL1, 1);
gpio_set_value(SABRESD_EPDC_PWRCTRL1, 1);
mx6q_sabresd_init_uart();
這裡找到了之後,看看mx6q_sabresd_init_uart()
static const struct imxuart_platform_data mx6q_sd_uart3_data __initconst = {
.flags = IMXUART_HAVE_RTSCTS,
.dma_req_rx = MX6Q_DMA_REQ_UART3_RX,
.dma_req_tx = MX6Q_DMA_REQ_UART3_TX,
};
再看看#define imx6q_add_imx_uart(id, pdata)\static inline void mx6q_sabresd_init_uart(void) { //imx6q_add_imx_uart(2, NULL); imx6q_add_imx_uart(0, NULL); imx6q_add_imx_uart(1, NULL); imx6q_add_imx_uart(2, &mx6q_sd_uart3_data); imx6q_add_imx_uart(3, NULL); imx6q_add_imx_uart(4, NULL); }
imx_add_imx_uart_1irq(&imx6q_imx_uart_data[id], pdata)
接下來是
之前只有uart2有pdata,所以也只有2有用struct platform_device *__init imx_add_imx_uart_1irq( const struct imx_imx_uart_1irq_data *data, const struct imxuart_platform_data *pdata) { struct resource res[] = { { .start = data->iobase, .end = data->iobase + data->iosize - 1, .flags = IORESOURCE_MEM, }, { .start = data->irq, .end = data->irq, .flags = IORESOURCE_IRQ, }, }; return imx_add_platform_device("imx-uart", data->id, res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); }
這個
#ifdef CONFIG_SOC_IMX6Q
const struct imx_imx_uart_1irq_data imx6q_imx_uart_data[] __initconst = {
#define imx6q_imx_uart_data_entry(_id, _hwid)
\
imx_imx_uart_1irq_data_entry(MX6Q, _id, _hwid, SZ_4K)
imx6q_imx_uart_data_entry(0, 1),
imx6q_imx_uart_data_entry(1, 2),
imx6q_imx_uart_data_entry(2, 3),
imx6q_imx_uart_data_entry(3, 4),
imx6q_imx_uart_data_entry(4, 5),
};
#define imx_imx_uart_1irq_data_entry(soc, _id, _hwid, _size)\
[_id] = {
\
.id = _id,
\
.iobase = soc ## _UART ## _hwid ## _BASE_ADDR,\
.iosize = _size,\
.irq = soc ## _INT_UART ## _hwid,\
}
到此為止,在linux系統中就存在了這個uart的pdate和resouce,等到驅動跑起來的時候傳入probe的引數就是從這裡來的