Received: by 10.192.165.148 with SMTP id m20csp921266imm; Fri, 27 Apr 2018 09:35:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo865H3ih9dmlz7GUAEnLoWQB9/Mo5NyID0fDbDbIY2Lj5VM3zUoZEXkhWeY6nbsgOPuyAy X-Received: by 2002:a17:902:1665:: with SMTP id g92-v6mr2927458plg.195.1524846953693; Fri, 27 Apr 2018 09:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524846953; cv=none; d=google.com; s=arc-20160816; b=n1ZwjGiW3TkF6VzNZlvuIKejy76chN+I1wT2aBivcNtrDrTEokkePcncyE5JLMDC6o w6R6XrD8dkzWcubeo0isA16PwjFRhXjuVcrfDgFbuSQuIeQaNT2xe8b/vc8x+mjg5mBA QltZW1yEzdXK6bmA/ST3+2uzgEBKlCWuV1wPDnSSYbbviIRR2Z92GdItcXzm6opVcPOv +84LCWfXpWMuQOQtaghgx1USC8dLv5oqwpELktDhOU+/g4OkFshW1NZ1S1JrKE7aYX2b qYRmaor4NKxqGyTm3NlkneRXcu+GzJvY7QTAjvI20uxBezPCzqFXU4gA7RZLW7hZMOXo d7tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=QzyE/WCXnqvd3NHnqMjFtMTT8Wb5kdXHbXICTVzbFso=; b=C7x1dZOknOOkYtnh7xkYLnpvbVPFrefjcI8ct2Om9iFjqXw/YuXTuenmBB5IQl7HN9 Nz8NHQSrhNNp53HSWIpRKOkKrpvMcjO1GZRaRVlpoRMn+URD35IDxh8Q7+Gs91CMbzlW kMHImu3RWRKjzlvongKkQINW+N+6mP6fclNF2tZnoXkeDyTulL3bentSzH48DtszNJLb RxFqNNoAMamQ6rTEQdUhi/NB+xaikhGhsnbR9L8LQEua+XxMHYCsV5lVnfTzQmDMwFMV VMRnriiOHutER/e7pXHspzueotpIBFVyTG5H/jonfttEnud+ViJxm78lY5vzOTHqpQID YfBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 85si1581729pfh.176.2018.04.27.09.35.39; Fri, 27 Apr 2018 09:35:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758779AbeD0Qe1 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 27 Apr 2018 12:34:27 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:53585 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758568AbeD0QeZ (ORCPT ); Fri, 27 Apr 2018 12:34:25 -0400 Received: from marcel-macpro.fritz.box (p5B3D2CDF.dip0.t-ipconnect.de [91.61.44.223]) by mail.holtmann.org (Postfix) with ESMTPSA id D186FCEEAF; Fri, 27 Apr 2018 18:40:48 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: [PATCH v1 6/7] Bluetooth: hci_mediatek: Add protocol support for MediaTek serial devices From: Marcel Holtmann In-Reply-To: <1524820468.12322.205.camel@mtkswgap22> Date: Fri, 27 Apr 2018 18:34:22 +0200 Cc: Rob Herring , Mark Rutland , Johan Hedberg , devicetree , BlueZ development , linux-arm-kernel , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <1524728068.12322.125.camel@mtkswgap22> <0DB4E6C1-28AD-41B7-8623-10046809A686@holtmann.org> <1524802381.12322.164.camel@mtkswgap22> <1524820468.12322.205.camel@mtkswgap22> To: Sean Wang X-Mailer: Apple Mail (2.3445.6.18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, >>>>>>> This adds a driver for the MediaTek serial protocol based on H4 protocol, >>>>>>> which can enable the built-in Bluetooth device inside MT7622 SoC. >>>>>>> >>>>>>> Signed-off-by: Sean Wang >>>>>>> --- >>> > > [... snip ...] > >>> >>> where could I find the newest btuart.c (which seems cannot be found in >>> 4.17 rc2)? It seems a time to rewrite the driver based on btuart.c >> >> It is not merged yet. I posted RFC patches to the mailing list. >> > > got it. > >>> >>> the Bluetooth device can't survive in a power/down cycle and >>> >>> * power on should be including >>> - enable clk and power domain >>> - download firmware through specific ACL command >>> - send specific commands to configure bluetooth (Required to note that >>> the steps should be after downloading firmware because the behavior for >>> the command might be changed by the firmware) >> >> Then this sounds like you need a quirk that runs setup() after every open() and not just after the first open(). You would be the first hardware that looses their firmware, but that is fine, I almost expect that at some point someone comes along and requires this. So just create a new HCI_QUIRK_NON_PERSISTENT_SETUP. >> > > Yes, it should be good to have an option HCI_QUIRK_NON_PERSISTENT_SETUP > to allow us to run setup() for every open(). > > When users are feeling unexpected thing happening on its device, they > always have a habit trying to restart device from UI. > > If close() -> open() can completely power reset a bluetooth device and > then it can recover from any fatal error to the initial state as at > boot. It's good for these problems specially hard to be reproduced and > required to reboot the whole machine to save. > > However, it would take a little longer time on open() since it takes > extra time to make firmware download and reconfiguration. if setup() is smart enough to skip the firmware download if it is already active, you can avoid these kind of things. It is up to your hardware. All the devices I have encountered so far only needed setup() once. Maybe some can be more power aggressive via GPIOs to full reset the hardware, but that could also be achieved via RFKILL. We need to see how this shapes up with your hardware. An alternative could be HCI_QUIRK_SETUP_AFTER_RFKILL and that means only the rfkill switch that brings down hciX interfaces will cause the full cycle. My recommendation is to not worry too much here. You want to get the base logic done and then we deal with the rest. Maybe doing ->post_open() and ->pre_close() is more useful since you want HCI transport to send a HCI command to complete transport activation and shutdown. > >>> * power off should be including >>> - send specific commands, such as to disable bluetooth >> >> So try to put these in shutdown() >> > > got it. > >>> - disable power domain and clk >> >> And do this in close(). >> > > got it. > > >>> >>>>> >>>>>>> + >>>>>>> + return err; > > > [ ... snip ....] > >> .open = mtk_open, >>>> >> >> Go with a brand new btmtkuart.c driver. I really sounds you don’t want the hci_ldisc.c framework in your way. You want direct control over the core callbacks. >> > > 1) > > In fact. the device is working via a internal serial bus, rather than > via uart for mt7622. so could i call it btmtkserial.c ? > > Becasue mediatek indeed also have bluetooth over uart, if i called it > btmtkserialc, the same code logic I think can be fit to all other > devices using either uart or internal serial bus. It is just a name so far. Start with btmtkuart.c for now. We will sort that naming out later. Mind you that as long as this is abstracted via serdev, it doesn’t really matter what it is in detail. It is just that Bluetooth called H:4 UART and H:5 3-Wire UART. These are the two UART protocol we are running. That you have extra serial bus framing is just some other detail. But picking the final driver name is something we worry about after detailed review. > > 2) > > Yes, i don't want hci_ldisc. so far i thought serdev version is enough, > and i preferred that bluetotoh device don't depend on any utility on > user space to launch. serdev is the way to go. I will not accept any now drivers that require btattach. > > 3) > > last question > > if i have bluetooth over usb, the usb version bluetooth can reuse > btmtkserial.c code? We would most likely create a btmtk.c for shared code. Similar to btintel.c, btbcm.c etc. However lets do that in step two since it is harder to review. Regards Marcel