static int sbsa_uart_probe(struct platform_device *pdev) { struct uart_amba_port *uap; struct resource r; int portnr, ret; int baudrate; / * Check the mandatory baud rate parameter in the DT node early * so that we can easily exit with the error. */ if (pdev->dev.of_node) { struct device_node *np = pdev->dev.of_node; ret = of_property_read_u32(np, "current-speed", &baudrate); if (ret) return ret; } else { baudrate = 115200; } portnr = pl011_find_free_port(); if (portnr < 0) return portnr; uap = devm_kzalloc(&pdev->dev, sizeof(struct uart_amba_port), GFP_KERNEL); if (!uap) return -ENOMEM; ret = platform_get_irq(pdev, 0); if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(&pdev->dev, "cannot obtain irq\n"); return ret; } uap->port.irq = ret; #ifdef CONFIG_ACPI_SPCR_TABLE if (qdf2400_e44_present) { dev_info(&pdev->dev, "working around QDF2400 SoC erratum 44\n"); uap->vendor = &vendor_qdt_qdf2400_e44; } else #endif uap->vendor = &vendor_sbsa; uap->reg_offset = uap->vendor->reg_offset; uap->fifosize = 32; uap->port.iotype = uap->vendor->access_32b ? UPIO_MEM32 : UPIO_MEM; uap->port.ops = &sbsa_uart_pops; uap->fixed_baud = baudrate; snprintf(uap->type, sizeof(uap->type), "SBSA"); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); ret = pl011_setup_port(&pdev->dev, uap, r, portnr); if (ret) return ret; platform_set_drvdata(pdev, uap); return pl011_register_port(uap); }在上述代码中,我需要添加一个功能:在以uefi方式启动系统时,uart驱动读取acpi表内有关波特率的设置值,并以这个值进行串口波特率设置,请根据我的要求,在原代码中添加这一功能,并给出acpi表的描述
时间: 2024-03-08 13:48:39 浏览: 243
SBSa.rar_scattering fiber_三波耦合_三波耦合方程_光纤传感_受激布里渊
5星 · 资源好评率100%
为了实现在以UEFI方式启动系统时,UART驱动能够读取ACPI表内有关波特率的设置值,并以这个值进行串口波特率设置,可以在sbsa_uart_probe函数中添加以下代码:
```
#ifdef CONFIG_ACPI
struct acpi_table_header *hdr;
acpi_status status;
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
status = acpi_get_table(ACPI_SIG_SPCR, 0, &buf);
if (ACPI_SUCCESS(status)) {
hdr = buf.pointer;
if (hdr->length >= sizeof(struct acpi_spcr)) {
struct acpi_spcr *spcr = (struct acpi_spcr *)hdr;
uap->fixed_baud = spcr->baud_rate;
}
}
kfree(buf.pointer);
#endif
```
这段代码会先通过acpi_get_table函数获取ACPI表,然后判断是否是SPCR表,如果是,则从中读取波特率的设置值,并把这个值赋给uap->fixed_baud。
ACPI表的描述:
ACPI(Advanced Configuration and Power Interface)是一种开放标准,用于操作系统与计算机硬件进行交互。其中SPCR(Serial Port Console Redirection)是一种ACPI表,用于描述串口控制台重定向相关的信息,包括波特率、数据位、停止位、校验位等参数。在Linux内核中,可以使用acpi_get_table函数获取SPCR表的内容。
阅读全文