Skip to content

Commit ae05690

Browse files
Frederic Danisholtmann
authored andcommitted
Bluetooth: hci_bcm: Retrieve UART speed from ACPI
Parse platform_device's ACPI to retrieve UART init speed. When BCM device is open, check if its TTY has same parent as one of the platform devices saved. If yes, use platform_device's init speed. Signed-off-by: Frederic Danis <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 9e60809 commit ae05690

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/bluetooth/hci_bcm.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ struct bcm_device {
4949

5050
struct clk *clk;
5151
bool clk_enabled;
52+
53+
u32 init_speed;
5254
};
5355

5456
struct bcm_data {
@@ -167,6 +169,7 @@ static int bcm_open(struct hci_uart *hu)
167169
*/
168170
if (hu->tty->dev->parent == dev->pdev->dev.parent) {
169171
bcm->dev = dev;
172+
hu->init_speed = dev->init_speed;
170173
break;
171174
}
172175
}
@@ -324,11 +327,29 @@ static const struct acpi_gpio_mapping acpi_bcm_default_gpios[] = {
324327
{ },
325328
};
326329

330+
static int bcm_resource(struct acpi_resource *ares, void *data)
331+
{
332+
struct bcm_device *dev = data;
333+
334+
if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
335+
struct acpi_resource_uart_serialbus *sb;
336+
337+
sb = &ares->data.uart_serial_bus;
338+
if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_UART)
339+
dev->init_speed = sb->default_baud_rate;
340+
}
341+
342+
/* Always tell the ACPI core to skip this resource */
343+
return 1;
344+
}
345+
327346
static int bcm_acpi_probe(struct bcm_device *dev)
328347
{
329348
struct platform_device *pdev = dev->pdev;
330349
const struct acpi_device_id *id;
331350
struct gpio_desc *gpio;
351+
struct acpi_device *adev;
352+
LIST_HEAD(resources);
332353
int ret;
333354

334355
id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
@@ -368,6 +389,13 @@ static int bcm_acpi_probe(struct bcm_device *dev)
368389
return -EINVAL;
369390
}
370391

392+
/* Retrieve UART ACPI info */
393+
adev = ACPI_COMPANION(&dev->pdev->dev);
394+
if (!adev)
395+
return 0;
396+
397+
acpi_dev_get_resources(adev, &resources, bcm_resource, dev);
398+
371399
return 0;
372400
}
373401

0 commit comments

Comments
 (0)