All of lore.kernel.org
 help / color / mirror / Atom feed
From: Balakrishna Godavarthi <bgodavar@codeaurora.org>
To: Matthias Kaehlcke <mka@chromium.org>
Cc: marcel@holtmann.org, johan.hedberg@gmail.com,
	thierry.escande@linaro.org, linux-bluetooth@vger.kernel.org,
	rtatiya@codeaurora.org, hemantg@codeaurora.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
Date: Fri, 22 Jun 2018 16:35:47 +0530	[thread overview]
Message-ID: <21e02b13fd3c5d8796ef0eecc751074d@codeaurora.org> (raw)
In-Reply-To: <20180621211625.GL169030@google.com>

Hi Matthias,

On 2018-06-22 02:46, Matthias Kaehlcke wrote:
> Hi Balakrishna,
> 
> On Thu, Jun 21, 2018 at 07:30:25PM +0530, Balakrishna Godavarthi wrote:
>> Hi Matthias,
>> 
>> On 2018-06-20 03:23, Matthias Kaehlcke wrote:
>> > On Sat, Jun 16, 2018 at 11:57:18AM +0530, Balakrishna Godavarthi wrote:
>> > > Add support to set voltage/current of various regulators
>> > > to power up/down Bluetooth chip wcn3990.
>> > >
>> > > Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org>
>> > > ---
>> > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
>> > > index 28ae6a17a595..1961e313aae7 100644
>> > > --- a/drivers/bluetooth/hci_qca.c
>> > > +++ b/drivers/bluetooth/hci_qca.c
>> > >
>> > >  static int qca_setup(struct hci_uart *hu)
>> > >  {
>> > >  	struct hci_dev *hdev = hu->hdev;
>> > >  	struct qca_data *qca = hu->priv;
>> > > +	struct qca_serdev *qcadev;
>> > >  	unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
>> > >  	int ret;
>> > >  	int soc_ver = 0;
>> > >
>> > > -	bt_dev_info(hdev, "ROME setup");
>> > > +	qcadev = serdev_device_get_drvdata(hu->serdev);
>> > >
>> > >  	/* Patch downloading has to be done without IBS mode */
>> > >  	clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
>> > > -
>> > > -	/* Setup initial baudrate */
>> > >  	qca_set_init_speed(hu);
>> > > +
>> > > +	if (qcadev->btsoc_type == QCA_WCN3990) {
>> > > +		bt_dev_dbg(hdev, "setting up wcn3990");
>> > > +		hci_uart_set_flow_control(hu, true);
>> > > +		ret = qca_send_vendor_cmd(hdev, CHEROKEE_POWERON_PULSE);
>> > > +		if (ret) {
>> > > +			bt_dev_err(hdev, "failed to send power on command");
>> > > +			return ret;
>> > > +		}
>> > > +		serdev_device_close(hu->serdev);
>> > > +		ret = serdev_device_open(hu->serdev);
>> > > +		if (ret) {
>> > > +			bt_dev_err(hdev, "failed to open port");
>> > > +			return ret;
>> > > +		}
>> > > +		msleep(100);
>> > > +		qca_set_init_speed(hu);
>> > > +		hci_uart_set_flow_control(hu, false);
>> > > +		ret = qca_read_soc_version(hdev, &soc_ver);
>> > > +		if (ret < 0 || soc_ver == 0) {
>> > > +			bt_dev_err(hdev, "Failed to get version %d", ret);
>> >
>> > serdev_device_close() ?
>> >
>> > Also applies to other error paths in this function.
>> >
>> [Bala]: sorry, i didn't get you.
> 
> A few lines above serdev_device_open() is called, in the error paths
> the device should be closed.
> 

[Bala]: i don't think closing of port is required.
         qca_send_vendor_cmd() fails if skb_alloc() fails. that is not 
linked with serdev_close().
         we need to close the port, if we have issues from reading or 
writing into the port.
         pls correct me if i am wrong.

>> > >  static int qca_serdev_probe(struct serdev_device *serdev)
>> > >  {
>> > >  	struct qca_serdev *qcadev;
>> > > +	const struct qca_vreg_data *data;
>> > >  	int err;
>> > >
>> > >  	qcadev = devm_kzalloc(&serdev->dev, sizeof(*qcadev), GFP_KERNEL);
>> > > @@ -1041,47 +1264,85 @@ static int qca_serdev_probe(struct
>> > > serdev_device *serdev)
>> > >  		return -ENOMEM;
>> > >
>> > >  	qcadev->serdev_hu.serdev = serdev;
>> > > +	data = of_device_get_match_data(&serdev->dev);
>> > > +	if (data && data->soc_type == QCA_WCN3990)
>> > > +		qcadev->btsoc_type = QCA_WCN3990;
>> > > +	else
>> > > +		qcadev->btsoc_type = QCA_ROME;
>> > > +
>> > >  	serdev_device_set_drvdata(serdev, qcadev);
>> > > +	if (qcadev->btsoc_type == QCA_WCN3990) {
>> >
>> > nit: the double "if (soc_type == QCA_WCN3990)" is a bit odd. Consider
>> > changing this condition to "if (data && data->soc_type == QCA_WCN3990)"
>> > and assign qcadev->btsoc_type in the corresponding branch.
>> 
>> [bala]: will update.
>> 
>> I have idea of removing flow control from qca_setup() and use them in
>> qca_set_speed()
>> "i need to disable hardware flow control when sending change baudrate
>> request to WCN3990.
>> enabling it after setting host baudrate. this is only for wcn3990.
>> "
> 
> I definitely think it's positive to hide the
> hci_uart_set_flow_control() call in qca_set_speed(). A few comments
> inline.
> 
> 
>> static int qca_set_speed(struct hci_uart *hu, unsigned int speed,
>>                          enum qca_speed_type speed_type,
>>                          enum qca_btsoc_type soc_type)
>> {
> 
> That's a lot of parameters, in particular 'soc_type' seems a bit
> off-topic in a function called qca_set_speed(). Passing struct
> qca_serdev instead of struct hci_uart would make the 'soc_type'
> parameter unnecessary.
> 

[Bala]: will update.

>>         unsigned int qca_baudrate;
>>         int ret;
>> 
>>         if (speed_type == QCA_INIT_SPEED)
>>                 goto change_host_baudrate;
> 
> If the order of setting host and chip baudrate can't be changed I
> think it's preferable to set the init speed right here in the if
> branch instead of doing the goto. I earlier mentioned the short cut of
> a return (if possible) to save a level of indentation, but a goto
> IMO doesn't improve readability and it's the first level of
> indentation anyway.
> 

[Bala]: will update.

>>         if (soc_type == QCA_WCN3990)
>>                 hci_uart_set_flow_control(hu, true);
>> 
>>         qca_baudrate = qca_get_baudrate_value(speed);
>>         bt_dev_info(hu->hdev, "Set UART speed to %d", speed);
>>         ret = qca_set_baudrate(hu->hdev, qca_baudrate);
>>         if (ret) {
>>                 bt_dev_err(hu->hdev, "Failed to change the baudrate 
>> (%d)",
>> ret);
>>                 return ret;
>>         }
>> 
>> change_host_baudrate:
>> 
>>         host_set_baudrate(hu, speed);
>>         if (soc_type == QCA_WCN3990)
>>                 hci_uart_set_flow_control(hu, false);
>> 
>>         return ret;
>> }
>> 
>> 
>> is it good idea?
> 
> In general I think it is.

-- 
Regards
Balakrishna.

      reply	other threads:[~2018-06-22 11:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-16  6:27 [PATCH v7 0/8] Enable Bluetooth functionality for WCN3990 Balakrishna Godavarthi
2018-06-16  6:27 ` [PATCH v7 1/8] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990 Balakrishna Godavarthi
2018-06-18 13:29   ` Rob Herring
2018-06-20 11:33     ` Balakrishna Godavarthi
2018-06-20 14:54       ` Rob Herring
2018-06-20 15:28         ` Balakrishna Godavarthi
2018-06-16  6:27 ` [PATCH v7 2/8] Bluetooth: btqca: Rename string ROME to QCA in logs Balakrishna Godavarthi
2018-06-18 19:42   ` Matthias Kaehlcke
2018-06-19  6:49     ` Balakrishna Godavarthi
2018-06-16  6:27 ` [PATCH v7 3/8] Bluetooth: btqca: Rename ROME related functions to Generic functions Balakrishna Godavarthi
2018-06-18 19:59   ` Matthias Kaehlcke
2018-06-19  7:06     ` Balakrishna Godavarthi
2018-06-16  6:27 ` [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function Balakrishna Godavarthi
2018-06-18 21:19   ` Matthias Kaehlcke
2018-06-19  7:09     ` Balakrishna Godavarthi
2018-06-19 20:03       ` Matthias Kaehlcke
2018-06-20 10:53         ` Balakrishna Godavarthi
2018-06-20 23:33           ` Matthias Kaehlcke
2018-06-21 11:20             ` Balakrishna Godavarthi
2018-06-21 22:09               ` Matthias Kaehlcke
2018-06-22 15:11                 ` Balakrishna Godavarthi
2018-06-22 17:42                   ` Matthias Kaehlcke
2018-06-16  6:27 ` [PATCH v7 5/8] Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds Balakrishna Godavarthi
2018-06-18 21:51   ` Matthias Kaehlcke
2018-06-19  7:11     ` Balakrishna Godavarthi
2018-06-20 19:49       ` Balakrishna Godavarthi
2018-06-20 23:10         ` Matthias Kaehlcke
2018-06-16  6:27 ` [PATCH v7 6/8] Bluetooth: hci_qca: Enable 3.2 Mbps operating speed Balakrishna Godavarthi
2018-06-16  6:27 ` [PATCH v7 7/8] Bluetooth: btqca: Add wcn3990 firmware download support Balakrishna Godavarthi
2018-06-18 22:02   ` Matthias Kaehlcke
2018-06-19  6:14     ` Marcel Holtmann
2018-06-16  6:27 ` [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990 Balakrishna Godavarthi
2018-06-18 16:42   ` Stephen Boyd
2018-06-18 17:07     ` Balakrishna Godavarthi
2018-06-22  1:28       ` Stephen Boyd
2018-06-22 15:25         ` Balakrishna Godavarthi
2018-06-19 21:53   ` Matthias Kaehlcke
2018-06-21 14:00     ` Balakrishna Godavarthi
2018-06-21 21:16       ` Matthias Kaehlcke
2018-06-22 11:05         ` Balakrishna Godavarthi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21e02b13fd3c5d8796ef0eecc751074d@codeaurora.org \
    --to=bgodavar@codeaurora.org \
    --cc=hemantg@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mka@chromium.org \
    --cc=rtatiya@codeaurora.org \
    --cc=thierry.escande@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.