Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932890AbdDFLaP (ORCPT ); Thu, 6 Apr 2017 07:30:15 -0400 Received: from mail-dm3nam03on0057.outbound.protection.outlook.com ([104.47.41.57]:52885 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753441AbdDFLaF (ORCPT ); Thu, 6 Apr 2017 07:30:05 -0400 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Reply-To: Subject: Re: [PATCH v4 2/2] i2c: mux: ltc4306: LTC4306 and LTC4305 I2C multiplexer/switch References: <1491397671-14675-1-git-send-email-michael.hennerich@analog.com> <1491397671-14675-2-git-send-email-michael.hennerich@analog.com> To: Peter Rosin , , , , CC: , , , From: Michael Hennerich Organization: Analog Devices Inc. Message-ID: <376f970f-9e0f-1d44-3813-93691c849b83@analog.com> Date: Thu, 6 Apr 2017 13:31:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39860400002)(39840400002)(39850400002)(39410400002)(39400400002)(2980300002)(438002)(199003)(377424004)(24454002)(189002)(7636002)(43066003)(2906002)(54356999)(305945005)(966004)(76176999)(50986999)(356003)(36756003)(23746002)(1720100001)(77096006)(6306002)(31686004)(3450700001)(54906002)(106466001)(2870700001)(4001350100001)(38730400002)(53546009)(8676002)(5660300001)(6246003)(229853002)(4326008)(83506001)(33646002)(2950100002)(64126003)(65956001)(65806001)(8936002)(47776003)(189998001)(31696002)(6666003)(86362001)(562404015);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB3149;H:nwd2mta2.analog.com;FPR:;SPF:Pass;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD038;1:oJE/D0Lb/UTeSdv5MQmdJmMxqAo2hbaKA7NjJKXpIs9bK8Ma9Q2J+5Fl2Ild6bkcu0xeh6rlE5/Bj9ZApFGX3YzGbxUk9h0axvtNJ/j8iH9QYSwWot8CN1ny9Cvy0AVyJtDz1uI6OV4SpZ0TqX+x08iieZvT2nWRi1H6f1gZGGazvezyOWUEaVPkebildsJ8Tr5H1Le5RZBERLGIoLxk4FkIvondwswmNZq6ZdLLyQdjMwvryC6vJN4KSQpuIz3Mm4TPKk6IQraMsRdMnvTdV/iFtDfeOIReAlFowq8C4I83A2+0YkkocXFmND6NvnqZbREyGOejKQR2qwiLd4BoosEFVOPenkg1RZxGxNzvF/EovUohHZ/s4yLUzbIUhy1T4cQFrIngG55kNogyZGCs7oxldf4i1Od5i3xFa5066iHMuZ6kEuh2COpLll55mtgJAJkyZ6EzKGf8/d0jpaXZkup+aG569Sa4geeLXyWBX6aCNp1mHJiPzyz2JQ9tFci8d5VHWW559OXUuXYfTCNwTRrqJMNfkdtQr09RfU3VBoC3Ag5oYMObdyCKQVpxO8vg8X55JVpmkiJX3v3+I836umAfGkg541OvuIzI9hFuykkRFcIVCqufN4kyixVstkm+ X-MS-Office365-Filtering-Correlation-Id: 04d322cf-ec48-4cb6-1287-08d47ce042d0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081);SRVR:MWHPR03MB3149; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3149;3:LOCohE44JUa1pAwBWNDwBxT8Scf5Bx9cM6HKTbl1dHctPo839Sodvz9xaYrl1RrHy9WgEWcu/Apo4sOBLMrRJXe7ZU9/nHg1ejXqTbVkSKo/J5s8Nre6ez5ALNNDbQEJ6DPuf3GJHSAhzV3LAGItak2aRX4sJMK4a2Ew39WvK97Cslt/P3KexG7fDQTDtVWwbfk6KKmYdkjCgKEoC9PA/UjW9b5kn/wFcPXwtsk1h3h31CvFjW/2THF2DULLmEYAewDNFWm9OSTYs5Mz0ZlGe3IENHYYN9uJp6lu9jNtQfvT8HGyiXioGXCwxQoXmjwTg+J+FwRk6OOYfmn8zo/cHTeGYJFrEMkozs1OkZjyDXLC5PZ9Q0Wogcx6MkPNlC1UI5Gi/u4AD+/SNIvaZxxLU1knUZ9J2kOAah+OC/IN7vTpsIWbi18wtO5/FQdgs4lya2UZpFiF0b5E/Br98DIV1Yl+CPonas2v/cAhlMNP3PVDms2F2PvWF1oGF4kEVTZw X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3149;25:Cr6MzXnjrsS2oKJRHRzZ/1beTuZ7zJ/CsSzwFR+JdWv5ploA3ffpWfhGVKpLu19vyyVVyeQyAFKhC2xOYGe5wKmJdDB1nZKDBb1JnYKCCGaRaULqH2Lykbfsf/UFNHqeFzCP7vcACyx12BtIVT1HAFSOTwlq3Wx1DUlL75x9YmpeaJoUkZ5dGwzhCDUcmOpFdW8SmTXVJXjf/cp9bZJmw17Fiekou4o6PEDtgsTEPp0IncD7adIsSi6Tx+DDS4vJdqEJBnxY7yhsfTdgMcOm2fXcf5hx/YNrxVyEvNDQFX40MINxOK/Q/bMnjtvmT7Vn9ugf6Vx3XudQfj1Hf46j9x8xkoBROOskJOQM4BieDGdL4fdb0ENeKCwJB8y3I+NCaT6VPC4zEQXldhWbYzTXM++6U+2P4wCWjgUaPD9qm0Fh+LyZ6HhAgNv6ApoNDjKy68XteXIXh/NyxOVpybl4lA==;31:jC/t+iKAiWhh6G9+Pi0FibT414277ei5yvvHqgugJKW0FEAbbd0bRvriQaSm0g5xq7sbAc9zPc6BgCsRn8PcoNPhNzcYGpIjIXH0aZH2sjsPlLwY+JEPHB2E9DmohMu6JhlWu1iZ8G5oiNrY/nRpzcURoe+EuMLRS14ubWEsMr/n5ZlrNNhcxZ9oiAkQQIKb8Y8a3qVrB5o0Eu7V6VCOcJr072/meVzjcyJK/lDxGht4szQCm76xziWOsHPH6XzCnfae027hHCPCKexLsBV/WoRgsCA73KsJP5tWbw1gcqc= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3149;20:pPbF17yy0URTBPG24vFx7kODisPWWky2re5KNENNPcOGyPkGwpUL1tn/nzOfs9JM9crfXAn5zNOD4BWxa0zSmjD2si37It5MeBxvKFh2giv0qxmqkbBAIe0r82nJeZSL8VHz6kfWkvYa29ELcSCeZ4608DK4IMpAat8+G8kAQxPGTVdvr1SeNVA2lsHQci8N3KOf4MFQc4z7YLf7AK0Uvpn/OyvBaYj6Yb3G7TDZuQrZE4jlJnnbN1nlXpS9OtPrHuURPilq54ZqF+5Ipp8BxwYewqZZrqKm0GMWpkRF/tXECRpwe/YFonugMqNw6bRWfa6/7p7IjtTBV1kGnQXmC7vY+UUehql6uhvjuDb1BplDx0t58ws3uVGpqL3nw4cIU3oSEye4PczohBIjRAFbHKgQYNv3opZZcAgtzAiuOS9NAYjOdS3+5WGFL8pXr1tm1cd01Wma8sE+aq9xYgPJrOW+BLImS8AS7lXaNFeiqrLcC8SmE7F8lttUwDXCx2H1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(232431446821674)(788757137089)(211171220733660)(170811661138872); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(13015025)(8121501046)(5005006)(13017025)(13024025)(13018025)(13023025)(93006095)(93004095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(6072148);SRVR:MWHPR03MB3149;BCL:0;PCL:0;RULEID:;SRVR:MWHPR03MB3149; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;MWHPR03MB3149;4:vFuDItijP5B+AXTfBbiFKMXuNsEC1oF5p3ZoFH?= =?Windows-1252?Q?88JxPYAfqm+enDa+GW2dM+ZjpTWhuCcxmk0FMXcM6F6Q0puxUnFbXvHK?= =?Windows-1252?Q?SqmSD+C7Bmv7zn2Ja75P26jXWQmK2bcq7DqeqNee/216KPYWb5hsWOjW?= =?Windows-1252?Q?m6/4EKXOXw5pgpBfYxNpNiaLUf+wTkiHHVR5sxq+o0JxAEdIF6SNGKni?= =?Windows-1252?Q?iPRYIvpR8fm0xijye5ZKICGfwUPvlTXPSIxytfAEcO/vg158CRGWLh+2?= =?Windows-1252?Q?oz2d0wb9jEiQ0djfBna8rJRfnwAIug7NcjGVMjMucMo2K6mwBjdmh4Un?= =?Windows-1252?Q?OB3yXFyzIUT5Ug3iBQAAIwvca3okCbEZqrvAuc8ZEzflZuB3zdVFvW8b?= =?Windows-1252?Q?WmqiDGIpF8zPEEOxcq749qIoIMn/SJZSQ9ARmzrNeD1A7Nnnhka3xYac?= =?Windows-1252?Q?C+rUc4puO8RokdE8JVOwxtgTrWdWI2HyBIwJ0/hw+h03PjRgJ6gK9oXA?= =?Windows-1252?Q?EKvhlF2cNxCw52witwbrkwNt/AtFR78WT0dGNclEGUy+uV4s6esjpZnO?= =?Windows-1252?Q?GJPlMEK4Rxr0FIAmfrAHRyuS3BVHM3KbfioIcp2PNfU0EKvEU6FzCggw?= =?Windows-1252?Q?0dWHQrwSCKuK1jNDS2DR5kRlxQgNp4T520QqSCKTUZXeBCi2BkW1V7ei?= =?Windows-1252?Q?RuC/SfhpLgFy1hk3s8+UfR6SGRA9I3QYOn/Z8zDZvJISVVNYNNb+HCOf?= =?Windows-1252?Q?NRdvOSDsyBtM9unLu3s74RHZL+RJii4egGB5/hAln2ri6uQoOYfTo3Mx?= =?Windows-1252?Q?YEGOE+aitEZ9VePIfDn9c6vQWaAKHhVKKQAacBljJkfBR73n5WQP9+8W?= =?Windows-1252?Q?boWEJ8KC6XrYYoQqxKumsHOjCMQ+sD9TvIFNvydegJeeVIRctNpcj9L3?= =?Windows-1252?Q?vQNLFlJBluMfmSdbZ5BF/5E4h/hRzLv/TYJY3tNWPg+x8q0BySzQ6hUj?= =?Windows-1252?Q?3ELQJLf0LyMUG4XanRRIbCQwJKPvc4aQtqf5BdTmVLMlLdVnIGSTL2S9?= =?Windows-1252?Q?KEbbK1At2SoviOGUDQA66G/nlJtOQqqQnu?= X-Forefront-PRVS: 02698DF457 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;MWHPR03MB3149;23:/jlKG7sJu72ZaijbiyR6T6I+fQPQdMELC4dl7?= =?Windows-1252?Q?YwMbHDU+BR+rh+s168/Vot/C0SHlh33I+iSYcKmGr39BhRAy6Yau4MwT?= =?Windows-1252?Q?v3WgneqE0skQ9A6GF98IDbQAP9w8v7MaMyERpIykKYD2Sq7dWQzq+M/0?= =?Windows-1252?Q?ExLZeIzDt0TwfYFRpTwj+yB1qfQf8rUH5o8EDneozOiPJj5D5IRSIswI?= =?Windows-1252?Q?UKMdHiZO/u0tLyt/5Ws2XHcEU36pkJaUvenmCt+DQQ4/lzgPibA2gDmf?= =?Windows-1252?Q?suVzxAHjTczaQFZVvJkClml6om6LmGzmADzz+aDbxUkpuglIrwSZtVoz?= =?Windows-1252?Q?/Hwb39gtuIKXb12Wvvj3c/GW2Yt8+haN6DoDmo4mosWLfpVdnTbToE5g?= =?Windows-1252?Q?9q8GCtThLPoKwPTc1kqD/IfSePYNpAAZlNgreBHk8uax147zHdv5n1D8?= =?Windows-1252?Q?5XED9xEhyHlY7ThyHFmumoPI5BGnvJiSyG3ldHoTe1/zybZJjXheTYJr?= =?Windows-1252?Q?pEspvRKBeW2F+9aaZaZHw76BPHEF9B9XXrnS8w/lMX7Rhemsy7Hqux73?= =?Windows-1252?Q?0nLY/fKB63zoGrfYImurrOICbqpJrABSJFV9ebuMRxhNcP8dW+ZmKnCp?= =?Windows-1252?Q?5IcPD908A/8D56fUsDgbF2V/BgyQ4JlTx5fiCW+jjlyKIKOm5dmHao+7?= =?Windows-1252?Q?NpHelGbJPpoxz2Sww+32+Ms1xNJ4dYQHZfS+ZaraK6M5ZfQ08dtRBU59?= =?Windows-1252?Q?RV7DPej9j+zr5AT/lrSzKIi7PF6Ge0BX5TbjumBvYf+tv/X4qeSnShqP?= =?Windows-1252?Q?cgQ8mFm6fsARrPn0FET7r9+FtNbFo3zdBz5GVNnuwkImJHNR8Ah0bCr5?= =?Windows-1252?Q?j/FPJEWo1hV6gl0DVHisaSJC4HUOJL/uxXk3trrAhurVfsjsIsjB1g7T?= =?Windows-1252?Q?HdlBwP2iCSIpX2FARIxiu3JF+3xgJlGMJ9VuXS2afIFHU5QYvc1DQ48b?= =?Windows-1252?Q?ep96n6EcHQMwhNHikEZep5RtWVwudYnCq2zc+D6FNsnrqntSNeHGNgtq?= =?Windows-1252?Q?IXkUElKgB6LVUc+3q/osQbUthTaCCqv911tH2XeIqkEB6GV9y/lXyIqE?= =?Windows-1252?Q?a1JAs8HV7VkGVNXxmUinWlSZnkm4wX2fDEyf4VPXuLmUC6cAY7FKku4M?= =?Windows-1252?Q?FWLnd0lOfuNZRbvd0jEMgewr0Xq3NqCKjdfJSHAytoSop67pZLmhscQ5?= =?Windows-1252?Q?77x1BVR0XH6hAkEKdhkaMIb4YfkdDyqlJrUQGi3/nA3CGw6C02HGoinS?= =?Windows-1252?Q?yFvyJ+8uJafD31kIv3EhzM83X0/wpw+/wYyNRKUg0Z2LcGUvWX+wcxkO?= =?Windows-1252?Q?21WqKefKExghxaiussaCPqBNZhJqYXfRA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3149;6:JqeLr9PD5GXJuuRO+MXKJzuqyx11p6DVHJh9Xm1GdzOwU84+yP9QysSObUEJ5oC/GqSpjhvt/uytC8JWdNuDOyrZ2Q2uCmO/a3ztUBJbO8tpQTyAn6+Yxm4wm1Yq9FF24OG1kDz9BUIqS8PhVHWf8D41gRQf5ARCLfwN4DmqIqPV6+6+LnOX6AlpgmcDyGO6YSjyOOg6tma6jam8sYT5e6+6jkmxFKEC7c1Pf6apxJAbG9rO5Co3LSCOR9I1A/mt0ASa/bbSHY8x0IqmmIaDnRA0/Rk8KRFjnsyRSCBeH/BlXYs7R7TrE6T2Hrg7mEGiUNURcOdEw6vIajtnyz1prhtQBI0qgG7vsqqfKU9HhuRjL+psSiE6QfFy5FafWo+lVA03GYBD+CQKtQ5uAK2bz76bLyCQCV9Hw78MY+7eFW8=;5:D+j2iIb+n5lS4yj+7dJY+QDt5CjfcXwPdLq9cGfnMuQhAkbHpx6eDvy2nePSx0VISYEnt5cIfoYJoJQGlbeCsN+n8CXXNjrBaJoWqXQM4iZo1ur1qjWwzM2SLp8zfOh/7KRcWV1JJdQlXMg7QtCxxw==;24:wBqXTrDSw2SyKzOj4OU66A4IibGRcKYVvwhceAY0O9CiK+dU46IZwM/YYtSyxXuybooL6NP+Kr6yccKq3gL/EVi9y5IL3dsEN2jc7/e+tpc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB3149;7:xHTEMxvFLGZKXy+5o+rJDMecZOyl5SG8gdNXqjVsPgxEubB/Ucwt/rYfzCyhgFD6Fc+hQut6o0mt9Ygge1IALMnhjgD/Pwljmf+y7GQujZF4bMo+0BosHTVsbnS+BehWB+MyHK3SmDb5Sfcrf+bH1NreVWRuN1lVWjqUOxahsb01xXWD62TI+88xqSmFBMSMUeJ5elGymcqp8BVyopMDRiYbzuQx5ZEnUhRULneUZDx1F2uAbgFiZ39dpaObl9tjK/tQbaox/5aecV6ze/O/sSU3bEUjxdo9kOvBABFrfN+xZ7WrCYSYDJMUW1RkAud8KaxfH/CS7iPDknp5B/SQpw== X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2017 11:29:56.8773 (UTC) X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3149 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 15553 Lines: 518 On 06.04.2017 10:39, Peter Rosin wrote: > Hi Michael, > > I would still like to hear from someone with more gpio experience. I'll ping Linus. > > Anyway, from my point of view, there's just a few minor things left, > with comments inline as usual. > > Thanks for you patience! Thanks for review. > > Cheers, > peda > > On 2017-04-05 15:07, michael.hennerich@analog.com wrote: >> From: Michael Hennerich >> >> This patch adds support for the Analog Devices / Linear Technology >> LTC4306 and LTC4305 4/2 Channel I2C Bus Multiplexer/Switches. >> The LTC4306 optionally provides two general purpose input/output pins >> (GPIOs) that can be configured as logic inputs, opendrain outputs or >> push-pull outputs via the generic GPIOLIB framework. >> >> Signed-off-by: Michael Hennerich >> >> --- >> >> Changes since v1: >> >> - Sort makefile entries >> - Sort driver includes >> - Use proper defines >> - Miscellaneous coding style fixups >> - Rename mux select callback >> - Revise i2c-mux-idle-disconnect handling >> - Add ENABLE GPIO handling on error and device removal. >> - Remove surplus of_match_device call. >> >> Changes since v2: >> >> - Stop double error reporting (i2c_mux_add_adapter) >> - Change subject >> - Split dt bindings to separate patch >> >> Changes since v3: >> >> - Change subject and add spaces >> - Convert to I2C_MUX_LOCKED >> - Convert to regmap >> - Remove local register cache >> - Restore previous ENABLE GPIO handling >> - Initially pulse ENABLE low >> - Eliminate i2c client struct in driver state structure >> - Simplify error return path >> - Misc minor cleanups >> --- >> MAINTAINERS | 8 + >> drivers/i2c/muxes/Kconfig | 11 ++ >> drivers/i2c/muxes/Makefile | 1 + >> drivers/i2c/muxes/i2c-mux-ltc4306.c | 310 ++++++++++++++++++++++++++++++++++++ >> 4 files changed, 330 insertions(+) >> create mode 100644 drivers/i2c/muxes/i2c-mux-ltc4306.c >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index c776906..9a27a19 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -7698,6 +7698,14 @@ S: Maintained >> F: Documentation/hwmon/ltc4261 >> F: drivers/hwmon/ltc4261.c >> >> +LTC4306 I2C MULTIPLEXER DRIVER >> +M: Michael Hennerich >> +W: http://ez.analog.com/community/linux-device-drivers >> +L: linux-i2c@vger.kernel.org >> +S: Supported >> +F: drivers/i2c/muxes/i2c-mux-ltc4306.c >> +F: Documentation/devicetree/bindings/i2c/i2c-mux-ltc4306.txt >> + >> LTP (Linux Test Project) >> M: Mike Frysinger >> M: Cyril Hrubis >> diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig >> index 10b3d17..41153b4 100644 >> --- a/drivers/i2c/muxes/Kconfig >> +++ b/drivers/i2c/muxes/Kconfig >> @@ -30,6 +30,17 @@ config I2C_MUX_GPIO >> This driver can also be built as a module. If so, the module >> will be called i2c-mux-gpio. >> >> +config I2C_MUX_LTC4306 >> + tristate "LTC LTC4306/5 I2C multiplexer" >> + select GPIOLIB >> + select REGMAP_I2C >> + help >> + If you say yes here you get support for the LTC LTC4306 or LTC4305 > > This reads a bit funny, and I think you should just spell out the > first LTC? But perhaps not in the tristate above though, depending > on how long it gets? Ok - I rename LTC -> Analog Devices > >> + I2C mux/switch devices. >> + >> + This driver can also be built as a module. If so, the module >> + will be called i2c-mux-ltc4306. >> + >> config I2C_MUX_PCA9541 >> tristate "NXP PCA9541 I2C Master Selector" >> help >> diff --git a/drivers/i2c/muxes/Makefile b/drivers/i2c/muxes/Makefile >> index 9948fa4..ff7618c 100644 >> --- a/drivers/i2c/muxes/Makefile >> +++ b/drivers/i2c/muxes/Makefile >> @@ -6,6 +6,7 @@ obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE) += i2c-arb-gpio-challenge.o >> obj-$(CONFIG_I2C_DEMUX_PINCTRL) += i2c-demux-pinctrl.o >> >> obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o >> +obj-$(CONFIG_I2C_MUX_LTC4306) += i2c-mux-ltc4306.o >> obj-$(CONFIG_I2C_MUX_MLXCPLD) += i2c-mux-mlxcpld.o >> obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o >> obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o >> diff --git a/drivers/i2c/muxes/i2c-mux-ltc4306.c b/drivers/i2c/muxes/i2c-mux-ltc4306.c >> new file mode 100644 >> index 0000000..7d34434 >> --- /dev/null >> +++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c >> @@ -0,0 +1,310 @@ >> +/* >> + * Linear Technology LTC4306 and LTC4305 I2C multiplexer/switch >> + * >> + * Copyright (C) 2017 Analog Devices Inc. >> + * >> + * Licensed under the GPL-2. >> + * >> + * Based on: i2c-mux-pca954x.c >> + * >> + * Datasheet: http://cds.linear.com/docs/en/datasheet/4306.pdf >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#define LTC4305_MAX_NCHANS 2 >> +#define LTC4306_MAX_NCHANS 4 >> + >> +#define LTC_REG_STATUS 0x0 >> +#define LTC_REG_CONFIG 0x1 >> +#define LTC_REG_MODE 0x2 >> +#define LTC_REG_SWITCH 0x3 >> + >> +#define LTC_DOWNSTREAM_ACCL_EN BIT(6) >> +#define LTC_UPSTREAM_ACCL_EN BIT(7) >> + >> +#define LTC_GPIO_ALL_INPUT 0xC0 >> +#define LTC_SWITCH_MASK 0xF0 >> + >> +enum ltc_type { >> + ltc_4305, >> + ltc_4306, >> +}; >> + >> +struct chip_desc { >> + u8 nchans; >> + u8 num_gpios; >> +}; >> + >> +struct ltc4306 { >> + struct regmap *regmap; >> + struct gpio_chip gpiochip; >> + const struct chip_desc *chip; >> +}; >> + >> +static const struct chip_desc chips[] = { >> + [ltc_4305] = { >> + .nchans = LTC4305_MAX_NCHANS, >> + }, >> + [ltc_4306] = { >> + .nchans = LTC4306_MAX_NCHANS, >> + .num_gpios = 2, >> + }, >> +}; >> + >> +static bool ltc4306_is_volatile_reg(struct device *dev, unsigned int reg) >> +{ >> + return (reg == LTC_REG_CONFIG) ? true : false; >> +} >> + >> +static const struct regmap_config ltc4306_regmap_config = { >> + .reg_bits = 8, >> + .val_bits = 8, >> + .max_register = LTC_REG_SWITCH, >> + .volatile_reg = ltc4306_is_volatile_reg, >> + .cache_type = REGCACHE_RBTREE, > > Did you consider REGCACHE_FLAT? There are very few registers and no hole > in the map, and maintaining a tree seems like total overkill. There is no reason to use REGCACHE_FLAT, in our case it will be a single node. > >> +}; >> + >> +static int ltc4306_gpio_get(struct gpio_chip *chip, unsigned int offset) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + unsigned int val; >> + int ret; >> + >> + ret = regmap_read(data->regmap, LTC_REG_CONFIG, &val); >> + if (ret < 0) >> + return ret; >> + >> + return (val & BIT(1 - offset)); > > The outer parentheses do not add anything, and I think they might remain > from when you just removed a double negation at some point. But is it > good practice to indicate "high" with anything other than one? Sure, the > gpiolib function that wraps the ->get() op does the !! dance for you, > but even so, every single one of the half dozen random gpio providers I > looked at had code to coerce the value to 0/1 (or error). Which makes me > think you should also have it. And the gpio_chip documentation on ->get() > agrees with me... I'll restore the double negations. > >> +} >> + >> +static void ltc4306_gpio_set(struct gpio_chip *chip, unsigned int offset, >> + int value) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + >> + regmap_update_bits(data->regmap, LTC_REG_CONFIG, BIT(5 - offset), >> + value ? BIT(5 - offset) : 0); >> +} >> + >> +static int ltc4306_gpio_direction_input(struct gpio_chip *chip, >> + unsigned int offset) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + >> + return regmap_update_bits(data->regmap, LTC_REG_MODE, >> + BIT(7 - offset), BIT(7 - offset)); >> +} >> + >> +static int ltc4306_gpio_direction_output(struct gpio_chip *chip, >> + unsigned int offset, int value) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + >> + ltc4306_gpio_set(chip, offset, value); >> + return regmap_update_bits(data->regmap, LTC_REG_MODE, >> + BIT(7 - offset), 0); >> +} >> + >> +static int ltc4306_gpio_set_config(struct gpio_chip *chip, >> + unsigned int offset, unsigned long config) >> +{ >> + struct ltc4306 *data = gpiochip_get_data(chip); >> + unsigned int val; >> + >> + switch (pinconf_to_config_param(config)) { >> + case PIN_CONFIG_DRIVE_OPEN_DRAIN: >> + val = 0; >> + break; >> + case PIN_CONFIG_DRIVE_PUSH_PULL: >> + val = BIT(4 - offset); >> + break; >> + default: >> + return -ENOTSUPP; >> + } >> + >> + return regmap_update_bits(data->regmap, LTC_REG_MODE, >> + BIT(4 - offset), val); >> +} >> + >> +static int ltc4306_gpio_init(struct ltc4306 *data) >> +{ >> + struct device *dev = regmap_get_device(data->regmap); >> + >> + if (!data->chip->num_gpios) >> + return 0; >> + >> + data->gpiochip.label = dev_name(dev); >> + data->gpiochip.base = -1; >> + data->gpiochip.ngpio = data->chip->num_gpios; >> + data->gpiochip.parent = dev; >> + data->gpiochip.can_sleep = true; >> + data->gpiochip.direction_input = ltc4306_gpio_direction_input; >> + data->gpiochip.direction_output = ltc4306_gpio_direction_output; > > I'm missing a get_direction op? No - its purely optional - the vast majority of gpiochips don't implement it. linux/drivers/gpio$ grep -lr --include \*.c get_direction | wc 36 36 523 linux/drivers/gpio$ grep -Lr --include \*.c get_direction | wc 101 101 1461 > >> + data->gpiochip.get = ltc4306_gpio_get; >> + data->gpiochip.set = ltc4306_gpio_set; >> + data->gpiochip.set_config = ltc4306_gpio_set_config; >> + data->gpiochip.owner = THIS_MODULE; >> + >> + /* gpiolib assumes all GPIOs default input */ >> + regmap_write(data->regmap, LTC_REG_MODE, LTC_GPIO_ALL_INPUT); >> + >> + return devm_gpiochip_add_data(dev, &data->gpiochip, data); >> +} >> + >> +static int ltc4306_select_mux(struct i2c_mux_core *muxc, u32 chan) >> +{ >> + struct ltc4306 *data = i2c_mux_priv(muxc); >> + >> + return regmap_update_bits(data->regmap, LTC_REG_SWITCH, >> + LTC_SWITCH_MASK, BIT(7 - chan)); > > Since the bits outside the mask are ignored for writes, I'd go with > regmap_write. Especially since those bits are volatile, which admittedly > will not have much impact until there is a need to read those volatile > bits outside the mask. But still. Yes they are volatile - but not declared as such. So regmap cache just ignores them. And we totally ignore these RONLY status bits, too. regmap_write() will always write and ignore the cache, while regmap_update_bits() uses the cached value. Are these callbacks guaranteed to be never called with the same CHAN sequentially? if yes - use regmap_write() otherwise its more efficient to use regmap_update_bits(). > >> +} >> + >> +static int ltc4306_deselect_mux(struct i2c_mux_core *muxc, u32 chan) >> +{ >> + struct ltc4306 *data = i2c_mux_priv(muxc); >> + >> + return regmap_update_bits(data->regmap, LTC_REG_SWITCH, >> + LTC_SWITCH_MASK, 0); > > Dito. > >> +} >> + >> +static const struct i2c_device_id ltc4306_id[] = { >> + { "ltc4305", ltc_4305 }, >> + { "ltc4306", ltc_4306 }, >> + { } >> +}; >> +MODULE_DEVICE_TABLE(i2c, ltc4306_id); >> + >> +static const struct of_device_id ltc4306_of_match[] = { >> + { .compatible = "lltc,ltc4305", .data = &chips[ltc_4305] }, >> + { .compatible = "lltc,ltc4306", .data = &chips[ltc_4306] }, >> + { } >> +}; >> +MODULE_DEVICE_TABLE(of, ltc4306_of_match); >> + >> +static int ltc4306_probe(struct i2c_client *client, >> + const struct i2c_device_id *id) >> +{ >> + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); >> + struct device_node *of_node = client->dev.of_node; >> + struct i2c_mux_core *muxc; >> + struct ltc4306 *data; >> + struct gpio_desc *gpio; >> + bool idle_disc = false; >> + int num, ret; >> + >> + if (of_node) >> + idle_disc = of_property_read_bool(of_node, >> + "i2c-mux-idle-disconnect"); >> + >> + muxc = i2c_mux_alloc(adap, &client->dev, >> + LTC4306_MAX_NCHANS, sizeof(*data), > > Hmmm, I didn't see this before, but if you do some more rearranging, it > should be possible to replace LTC4306_MAX_NCHANS with data->chip->nchans > and reduce resource waste for ltc4305. But it's just storage for two > pointers which is really really minor... Feel free to ignore. > > But you want to set a good example, right :-) > >> + I2C_MUX_LOCKED, ltc4306_select_mux, >> + idle_disc ? ltc4306_deselect_mux : NULL); >> + if (!muxc) >> + return -ENOMEM; >> + data = i2c_mux_priv(muxc); >> + >> + i2c_set_clientdata(client, muxc); >> + >> + data->regmap = devm_regmap_init_i2c(client, <c4306_regmap_config); >> + if (IS_ERR(data->regmap)) { >> + ret = PTR_ERR(data->regmap); >> + dev_err(&client->dev, "Failed to allocate register map: %d\n", >> + ret); >> + return ret; >> + } >> + >> + /* Reset and enable the mux if an enable GPIO is specified. */ >> + gpio = devm_gpiod_get_optional(&client->dev, "enable", GPIOD_OUT_LOW); >> + if (IS_ERR(gpio)) >> + return PTR_ERR(gpio); >> + >> + if (gpio) { >> + udelay(1); >> + gpiod_set_value(gpio, 1); >> + } >> + >> + /* >> + * Write the mux register at addr to verify >> + * that the mux is in fact present. This also >> + * initializes the mux to disconnected state. >> + */ >> + if (regmap_write(data->regmap, LTC_REG_SWITCH, 0) < 0) { >> + dev_warn(&client->dev, "probe failed\n"); >> + return -ENODEV; >> + } >> + >> + if (of_node) { >> + unsigned int val = 0; >> + >> + data->chip = of_device_get_match_data(&client->dev); >> + >> + if (of_property_read_bool(of_node, >> + "ltc,downstream-accelerators-enable")) >> + val |= LTC_DOWNSTREAM_ACCL_EN; >> + >> + if (of_property_read_bool(of_node, >> + "ltc,upstream-accelerators-enable")) >> + val |= LTC_UPSTREAM_ACCL_EN; >> + >> + if (regmap_write(data->regmap, LTC_REG_CONFIG, val) < 0) >> + return -ENODEV; >> + } else { >> + data->chip = &chips[id->driver_data]; >> + } >> + >> + ret = ltc4306_gpio_init(data); >> + if (ret < 0) >> + return ret; >> + >> + /* Now create an adapter for each channel */ >> + for (num = 0; num < data->chip->nchans; num++) { >> + ret = i2c_mux_add_adapter(muxc, 0, num, 0); >> + if (ret) { >> + i2c_mux_del_adapters(muxc); >> + return ret; >> + } >> + } >> + >> + dev_info(&client->dev, >> + "registered %d multiplexed busses for I2C switch %s\n", >> + num, client->name); >> + >> + return 0; >> +} >> + >> +static int ltc4306_remove(struct i2c_client *client) >> +{ >> + struct i2c_mux_core *muxc = i2c_get_clientdata(client); >> + >> + i2c_mux_del_adapters(muxc); >> + >> + return 0; >> +} >> + >> +static struct i2c_driver ltc4306_driver = { >> + .driver = { >> + .name = "ltc4306", >> + .of_match_table = of_match_ptr(ltc4306_of_match), >> + }, >> + .probe = ltc4306_probe, >> + .remove = ltc4306_remove, >> + .id_table = ltc4306_id, >> +}; >> + >> +module_i2c_driver(ltc4306_driver); >> + >> +MODULE_AUTHOR("Michael Hennerich "); >> +MODULE_DESCRIPTION("Linear Technology LTC4306, LTC4305 I2C mux/switch driver"); >> +MODULE_LICENSE("GPL v2"); >> > > -- Greetings, Michael -- Analog Devices GmbH Otl-Aicher Strasse 60-64 80807 M?nchen Sitz der Gesellschaft M?nchen, Registergericht M?nchen HRB 40368, Gesch?ftsf?hrer: Peter Kolberg, Ali Raza Husain, Eileen Wynne