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 07:49:45 浏览: 133
SBSa.rar_scattering fiber_三波耦合_三波耦合方程_光纤传感_受激布里渊
5星 · 资源好评率100%
为了实现在UEFI方式启动系统时,UART驱动可以读取通用ACPI表中有关波特率的设置值,并以该值进行串口波特率设置,可以在sbsa_uart_probe函数中进行以下修改:
```c
static int sbsa_uart_probe(struct platform_device *pdev) {
struct uart_amba_port *uap;
struct resource r;
int portnr, ret;
int baudrate;
// 添加以下代码以读取ACPI表中的波特率设置值
struct acpi_table_header *header;
header = acpi_table_find("SPCR");
if (header) {
struct acpi_spcr_table *spcr = (struct acpi_spcr_table *)header;
baudrate = spcr->baudrate;
} 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);
}
```
ACPI SPCR表(System Product Compatibility Report)提供了系统的硬件配置和兼容性信息,包括处理器、内存、I/O端口和中断控制器等。在该表中,波特率设置值可以通过baudrate字段获取。因此,我们可以使用acpi_table_find函数来查找SPCR表,然后获取该字段的值,并将其用作串口波特率设置。请注意,在代码中,如果找不到SPCR表,则默认将波特率设置为115200。
阅读全文