Example #1
0
static int qca_setup(struct hci_uart *hu)
{
	struct hci_dev *hdev = hu->hdev;
	struct qca_data *qca = hu->priv;
	unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
	int ret;

	BT_INFO("%s: ROME setup", hdev->name);

	/* Patch downloading has to be done without IBS mode */
	clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);

	/* Setup initial baudrate */
	speed = 0;
	if (hu->init_speed)
		speed = hu->init_speed;
	else if (hu->proto->init_speed)
		speed = hu->proto->init_speed;

	if (speed)
		hci_uart_set_baudrate(hu, speed);

	/* Setup user speed if needed */
	speed = 0;
	if (hu->oper_speed)
		speed = hu->oper_speed;
	else if (hu->proto->oper_speed)
		speed = hu->proto->oper_speed;

	if (speed) {
		qca_baudrate = qca_get_baudrate_value(speed);

		BT_INFO("%s: Set UART speed to %d", hdev->name, speed);
		ret = qca_set_baudrate(hdev, qca_baudrate);
		if (ret) {
			BT_ERR("%s: Failed to change the baud rate (%d)",
			       hdev->name, ret);
			return ret;
		}
		hci_uart_set_baudrate(hu, speed);
	}

	/* Setup patch / NVM configurations */
	ret = qca_uart_setup_rome(hdev, qca_baudrate);
	if (!ret) {
		set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
		qca_debugfs_init(hdev);
	}

	/* Setup bdaddr */
	hu->hdev->set_bdaddr = qca_set_bdaddr_rome;

	return ret;
}
Example #2
0
static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
{
	unsigned int speed, qca_baudrate;
	struct qca_serdev *qcadev;
	int ret = 0;

	if (speed_type == QCA_INIT_SPEED) {
		speed = qca_get_speed(hu, QCA_INIT_SPEED);
		if (speed)
			host_set_baudrate(hu, speed);
	} else {
		speed = qca_get_speed(hu, QCA_OPER_SPEED);
		if (!speed)
			return 0;

		/* Disable flow control for wcn3990 to deassert RTS while
		 * changing the baudrate of chip and host.
		 */
		qcadev = serdev_device_get_drvdata(hu->serdev);
		if (qcadev->btsoc_type == QCA_WCN3990)
			hci_uart_set_flow_control(hu, true);

		qca_baudrate = qca_get_baudrate_value(speed);
		bt_dev_dbg(hu->hdev, "Set UART speed to %d", speed);
		ret = qca_set_baudrate(hu->hdev, qca_baudrate);
		if (ret)
			goto error;

		host_set_baudrate(hu, speed);

error:
		if (qcadev->btsoc_type == QCA_WCN3990)
			hci_uart_set_flow_control(hu, false);
	}

	return ret;
}