static int qca_wcn3990_init(struct hci_uart *hu) { struct qca_serdev *qcadev; int ret; /* Check for vregs status, may be hci down has turned * off the voltage regulator. */ qcadev = serdev_device_get_drvdata(hu->serdev); if (!qcadev->bt_power->vregs_on) { serdev_device_close(hu->serdev); ret = qca_power_setup(hu, true); if (ret) return ret; ret = serdev_device_open(hu->serdev); if (ret) { bt_dev_err(hu->hdev, "failed to open port"); return ret; } } /* Forcefully enable wcn3990 to enter in to boot mode. */ host_set_baudrate(hu, 2400); ret = qca_send_power_pulse(hu, false); if (ret) return ret; qca_set_speed(hu, QCA_INIT_SPEED); ret = qca_send_power_pulse(hu, true); if (ret) return ret; /* Now the device is in ready state to communicate with host. * To sync host with device we need to reopen port. * Without this, we will have RTS and CTS synchronization * issues. */ serdev_device_close(hu->serdev); ret = serdev_device_open(hu->serdev); if (ret) { bt_dev_err(hu->hdev, "failed to open port"); return ret; } hci_uart_set_flow_control(hu, false); return 0; }
static int sirf_open(struct gnss_device *gdev) { struct sirf_data *data = gnss_get_drvdata(gdev); struct serdev_device *serdev = data->serdev; int ret; ret = serdev_device_open(serdev); if (ret) return ret; serdev_device_set_baudrate(serdev, data->speed); serdev_device_set_flow_control(serdev, false); ret = pm_runtime_get_sync(&serdev->dev); if (ret < 0) { dev_err(&gdev->dev, "failed to runtime resume: %d\n", ret); pm_runtime_put_noidle(&serdev->dev); goto err_close; } return 0; err_close: serdev_device_close(serdev); return ret; }
static int nokia_open(struct hci_uart *hu) { struct device *dev = &hu->serdev->dev; dev_dbg(dev, "protocol open"); serdev_device_open(hu->serdev); pm_runtime_enable(dev); return 0; }
int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p) { int err; struct hci_dev *hdev; BT_DBG(""); serdev_device_set_client_ops(hu->serdev, &hci_serdev_client_ops); err = serdev_device_open(hu->serdev); if (err) return err; err = p->open(hu); if (err) goto err_open; hu->proto = p; set_bit(HCI_UART_PROTO_READY, &hu->flags); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); err = -ENOMEM; goto err_alloc; } hu->hdev = hdev; hdev->bus = HCI_UART; hci_set_drvdata(hdev, hu); INIT_WORK(&hu->init_ready, hci_uart_init_work); INIT_WORK(&hu->write_work, hci_uart_write_work); percpu_init_rwsem(&hu->proto_lock); /* Only when vendor specific setup callback is provided, consider * the manufacturer information valid. This avoids filling in the * value for Ericsson when nothing is specified. */ if (hu->proto->setup) hdev->manufacturer = hu->proto->manufacturer; hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; hdev->setup = hci_uart_setup; SET_HCIDEV_DEV(hdev, &hu->serdev->dev); if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks); if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) hdev->dev_type = HCI_AMP; else hdev->dev_type = HCI_PRIMARY; if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) return 0; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); err = -ENODEV; goto err_register; } set_bit(HCI_UART_REGISTERED, &hu->flags); return 0; err_register: hci_free_dev(hdev); err_alloc: clear_bit(HCI_UART_PROTO_READY, &hu->flags); p->close(hu); err_open: serdev_device_close(hu->serdev); return err; }