[{"id":1760171,"web_url":"http://patchwork.ozlabs.org/comment/1760171/","msgid":"<a4aeec52-9d95-5f66-fa02-27f493a9c222@roeck-us.net>","list_archive_url":null,"date":"2017-08-30T13:50:04","subject":"Re: [PATCH v3 04/11] staging: typec: fusb302: Get max snk mv/ma/mw\n\tfrom device-properties","submitter":{"id":21889,"url":"http://patchwork.ozlabs.org/api/people/21889/","name":"Guenter Roeck","email":"linux@roeck-us.net"},"content":"On 08/30/2017 02:48 AM, Hans de Goede wrote:\n> This is board specific info so it should come from board config, such\n> as devicetree.\n> \n> I've chosen to prefix these with \"fcs,\" treating them as fusb302 driver\n> specific for now. We may want to revisit this and replace these with\n> properties which are part of a (to be written) generic type-c controller\n> devicetree binding.\n> \n> Since this commit adds new dt-properties it also adds devicetree-bindings\n> documentation (which so far was absent for the fusb302 driver).\n> \n> Cc: Rob Herring <robh+dt@kernel.org>\n> Cc: Frank Rowand <frowand.list@gmail.com>\n> Cc: devicetree@vger.kernel.org\n> Cc: \"Yueyao (Nathan) Zhu\" <yueyao@google.com>\n> Signed-off-by: Hans de Goede <hdegoede@redhat.com>\n> Acked-by: Rob Herring <robh@kernel.org>\n\nReviewed-by: Guenter Roeck <linux@roeck-us.net>\n\n> ---\n> Changes in v2:\n> -Use micro... instead of mili...\n> -Add devicetree bindings documentation\n> \n> Changes in v3:\n> -Use sink rather then snk in property names\n> -Add Rob's Acked-by\n> ---\n>   .../devicetree/bindings/usb/fcs,fusb302.txt        | 29 ++++++++++++++++++++++\n>   drivers/staging/typec/fusb302/TODO                 |  4 +++\n>   drivers/staging/typec/fusb302/fusb302.c            | 18 +++++++++++++-\n>   3 files changed, 50 insertions(+), 1 deletion(-)\n>   create mode 100644 Documentation/devicetree/bindings/usb/fcs,fusb302.txt\n> \n> diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt\n> new file mode 100644\n> index 000000000000..472facfa5a71\n> --- /dev/null\n> +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt\n> @@ -0,0 +1,29 @@\n> +Fairchild FUSB302 Type-C Port controllers\n> +\n> +Required properties :\n> +- compatible             : \"fcs,fusb302\"\n> +- reg                    : I2C slave address\n> +- interrupts             : Interrupt specifier\n> +\n> +Optional properties :\n> +- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as sink\n> +- fcs,max-sink-microamp  : Maximum current to negotiate when configured as sink\n> +- fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink\n> +\t\t\t   If this is less then max-sink-microvolt *\n> +\t\t\t   max-sink-microamp then the configured current will\n> +\t\t\t   be clamped.\n> +- fcs,operating-sink-microwatt :\n> +\t\t\t   Minimum amount of power accepted from a sink\n> +\t\t\t   when negotiating\n> +\n> +Example:\n> +\n> +fusb302: typec-portc@54 {\n> +\tcompatible = \"fcs,fusb302\";\n> +\treg = <0x54>;\n> +\tinterrupt-parent = <&nmi_intc>;\n> +\tinterrupts = <0 IRQ_TYPE_LEVEL_LOW>;\n> +\tfcs,max-sink-microvolt = <12000000>;\n> +\tfcs,max-sink-microamp = <3000000>;\n> +\tfcs,max-sink-microwatt = <36000000>;\n> +};\n> diff --git a/drivers/staging/typec/fusb302/TODO b/drivers/staging/typec/fusb302/TODO\n> index 4933a1d92c32..19b466eb585d 100644\n> --- a/drivers/staging/typec/fusb302/TODO\n> +++ b/drivers/staging/typec/fusb302/TODO\n> @@ -4,3 +4,7 @@ fusb302:\n>   - Find a non-hacky way to coordinate between PM and I2C access\n>   - Documentation? The FUSB302 datasheet provides information on the chip to help\n>     understand the code. But it may still be helpful to have a documentation.\n> +- We may want to replace the  \"fcs,max-snk-microvolt\", \"fcs,max-snk-microamp\",\n> +  \"fcs,max-snk-microwatt\" and \"fcs,operating-snk-microwatt\" device(tree)\n> +  properties with properties which are part of a generic type-c controller\n> +  devicetree binding.\n> diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c\n> index 6baed06a3c0d..1c1751c994db 100644\n> --- a/drivers/staging/typec/fusb302/fusb302.c\n> +++ b/drivers/staging/typec/fusb302/fusb302.c\n> @@ -90,6 +90,7 @@ struct fusb302_chip {\n>   \tstruct i2c_client *i2c_client;\n>   \tstruct tcpm_port *tcpm_port;\n>   \tstruct tcpc_dev tcpc_dev;\n> +\tstruct tcpc_config tcpc_config;\n>   \n>   \tstruct regulator *vbus;\n>   \n> @@ -1198,7 +1199,6 @@ static const struct tcpc_config fusb302_tcpc_config = {\n>   \n>   static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)\n>   {\n> -\tfusb302_tcpc_dev->config = &fusb302_tcpc_config;\n>   \tfusb302_tcpc_dev->init = tcpm_init;\n>   \tfusb302_tcpc_dev->get_vbus = tcpm_get_vbus;\n>   \tfusb302_tcpc_dev->set_cc = tcpm_set_cc;\n> @@ -1684,7 +1684,9 @@ static int fusb302_probe(struct i2c_client *client,\n>   {\n>   \tstruct fusb302_chip *chip;\n>   \tstruct i2c_adapter *adapter;\n> +\tstruct device *dev = &client->dev;\n>   \tint ret = 0;\n> +\tu32 v;\n>   \n>   \tadapter = to_i2c_adapter(client->dev.parent);\n>   \tif (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {\n> @@ -1699,8 +1701,22 @@ static int fusb302_probe(struct i2c_client *client,\n>   \tchip->i2c_client = client;\n>   \ti2c_set_clientdata(client, chip);\n>   \tchip->dev = &client->dev;\n> +\tchip->tcpc_config = fusb302_tcpc_config;\n> +\tchip->tcpc_dev.config = &chip->tcpc_config;\n>   \tmutex_init(&chip->lock);\n>   \n> +\tif (!device_property_read_u32(dev, \"fcs,max-sink-microvolt\", &v))\n> +\t\tchip->tcpc_config.max_snk_mv = v / 1000;\n> +\n> +\tif (!device_property_read_u32(dev, \"fcs,max-sink-microamp\", &v))\n> +\t\tchip->tcpc_config.max_snk_ma = v / 1000;\n> +\n> +\tif (!device_property_read_u32(dev, \"fcs,max-sink-microwatt\", &v))\n> +\t\tchip->tcpc_config.max_snk_mw = v / 1000;\n> +\n> +\tif (!device_property_read_u32(dev, \"fcs,operating-sink-microwatt\", &v))\n> +\t\tchip->tcpc_config.operating_snk_mw = v / 1000;\n> +\n>   \tret = fusb302_debugfs_init(chip);\n>   \tif (ret < 0)\n>   \t\treturn ret;\n> \n\n--\nTo unsubscribe from this list: send the line \"unsubscribe devicetree\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html","headers":{"Return-Path":"<devicetree-owner@vger.kernel.org>","X-Original-To":"incoming-dt@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-dt@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=devicetree-owner@vger.kernel.org; receiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=roeck-us.net header.i=@roeck-us.net\n\theader.b=\"uBwsQ+yF\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xj6RC3L0jz9sQl\n\tfor <incoming-dt@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 23:53:27 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751317AbdH3Nwb (ORCPT\n\t<rfc822;incoming-dt@patchwork.ozlabs.org>);\n\tWed, 30 Aug 2017 09:52:31 -0400","from bh-25.webhostbox.net ([208.91.199.152]:54861 \"EHLO\n\tbh-25.webhostbox.net\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751318AbdH3Nvb (ORCPT\n\t<rfc822; devicetree@vger.kernel.org>); Wed, 30 Aug 2017 09:51:31 -0400","from 108-223-40-66.lightspeed.sntcca.sbcglobal.net\n\t([108.223.40.66]:36382 helo=server.roeck-us.net)\n\tby bh-25.webhostbox.net with esmtpsa\n\t(TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)\n\t(Exim 4.89) (envelope-from <linux@roeck-us.net>)\n\tid 1dn3No-000qNR-LS; Wed, 30 Aug 2017 13:51:28 +0000"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=roeck-us.net; s=default; h=Content-Transfer-Encoding:Content-Type:\n\tIn-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender\n\t:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:\n\tList-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;\n\tbh=ES/hnMJWALaz7IIYvnJw0BfJedLbXtEnp36Cznjk7CA=;\n\tb=uBwsQ+yF91wUr5/Pe+4q6fJ6V9\n\txZuP96OwJ84Mw+JOV69tTs2zjBw+MmJ4Ef1fc+r8Jc8CCU2gq+/AKGirVeeXfxUho1dX7Z1T7ZeJA\n\tILWdvfIexlB7h9702gR/za1zMiSPg+2cNhZFjrkIL4iOa2gMBH/bjw8H4vz6jmisUR6p477MH+KrQ\n\tkMEllCQKzJQ4s7vcKRGdRurkZlDBLadYhi2e5T3mF7gaFgljHyJ3ZUebKfeGJurI2VzY3MbcFhRyt\n\tUX0Zy0vonfgSRxFofLgDUQFLX5yaJUXtdT9wbeu/b8rCbJ0jgEsSSJbCT3PE0SaVtfdmIRus2Uu56\n\tiPnM8J2g==;","Subject":"Re: [PATCH v3 04/11] staging: typec: fusb302: Get max snk mv/ma/mw\n\tfrom device-properties","To":"Hans de Goede <hdegoede@redhat.com>, Darren Hart <dvhart@infradead.org>, \n\tAndy Shevchenko <andy@infradead.org>, Wolfram Sang <wsa@the-dreams.de>, \n\tSebastian Reichel <sre@kernel.org>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\tHeikki Krogerus <heikki.krogerus@linux.intel.com>","Cc":"platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tlinux-i2c@vger.kernel.org, Liam Breck <liam@networkimprov.net>,\n\tTony Lindgren <tony@atomide.com>, linux-pm@vger.kernel.org,\n\tdevel@driverdev.osuosl.org, Rob Herring <robh+dt@kernel.org>,\n\tFrank Rowand <frowand.list@gmail.com>, devicetree@vger.kernel.org,\n\t\"Yueyao (Nathan) Zhu\" <yueyao@google.com>","References":"<20170830094814.17758-1-hdegoede@redhat.com>\n\t<20170830094814.17758-5-hdegoede@redhat.com>","From":"Guenter Roeck <linux@roeck-us.net>","Message-ID":"<a4aeec52-9d95-5f66-fa02-27f493a9c222@roeck-us.net>","Date":"Wed, 30 Aug 2017 06:50:04 -0700","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170830094814.17758-5-hdegoede@redhat.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Authenticated_sender":"linux@roeck-us.net","X-OutGoing-Spam-Status":"No, score=-1.0","X-AntiAbuse":["This header was added to track abuse,\n\tplease include it with any abuse report","Primary Hostname - bh-25.webhostbox.net","Original Domain - vger.kernel.org","Originator/Caller UID/GID - [47 12] / [47 12]","Sender Address Domain - roeck-us.net"],"X-Get-Message-Sender-Via":"bh-25.webhostbox.net: authenticated_id:\n\tlinux@roeck-us.net","X-Authenticated-Sender":"bh-25.webhostbox.net: linux@roeck-us.net","X-Source":"","X-Source-Args":"","X-Source-Dir":"","Sender":"devicetree-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<devicetree.vger.kernel.org>","X-Mailing-List":"devicetree@vger.kernel.org"}}]