Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753648AbdIDLUC (ORCPT ); Mon, 4 Sep 2017 07:20:02 -0400 Received: from mail-ve1eur01on0099.outbound.protection.outlook.com ([104.47.1.99]:3360 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753628AbdIDLT7 (ORCPT ); Mon, 4 Sep 2017 07:19:59 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Subject: Re: [PATCH 06/11] mux: Add Pericom PI3USB30532 Type-C mux driver To: Hans de Goede , MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Heikki Krogerus , Darren Hart , Andy Shevchenko , Mathias Nyman Cc: platform-driver-x86@vger.kernel.org, devel@driverdev.osuosl.org, Kuppuswamy Sathyanarayanan , Sathyanarayanan Kuppuswamy Natarajan , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org References: <20170901214845.7153-1-hdegoede@redhat.com> <20170901214845.7153-7-hdegoede@redhat.com> From: Peter Rosin Organization: Axentia Technologies AB Message-ID: <600628b1-5555-1b96-743f-0593af5a6069@axentia.se> Date: Mon, 4 Sep 2017 13:19:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170901214845.7153-7-hdegoede@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [81.224.168.30] X-ClientProxiedBy: HE1PR0301CA0001.eurprd03.prod.outlook.com (2603:10a6:3:76::11) To AM5PR0202MB2546.eurprd02.prod.outlook.com (2603:10a6:203:6d::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42c19e4c-eabf-42e8-183a-08d4f386deb7 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(2017082002075)(300000503095)(300135400095)(201703131423075)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:AM5PR0202MB2546; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0202MB2546;3:pkn9CBZGMD7Nd0KYULa55epfnMj6sAqb2fLARmJGgdUXO52q/tqGpf+mzuz4+lsSxNTbXKNSyM0O22JLhBJBPjMfyvOf1JaiXX2zIalk0RohMvN1XDNBV3XKR8S/xvLEetho5lNin2mFwv1oyaDeQ1DqaH/scTIeGpDiAu6v/P1HvAxtZ79gstuGeyRZiyH8aiyRxrsbGv4uKf5TI3JTi0wNNs1Uae6ib1gl9fO6TcsiS9LlrXuzUHa5eHgBxJ6I;25:fg50+U2JFemABuBV4sI3JiXa70EpkTvuGGRAJ53SbGeST4meVOWvOlnsTb5L0a/wiH2gvmuPlZ5scsCYRtQh+4Hckt1MQ5ErQQipY8IyubMfwEd2fxed2d4OpgQORyWsm/lluETTOChGuifLNm0UP9SdZb3ujKIxLpUT8+l5g0dmJKfx+xUOEzPAJQzntOVSny3Fu+qy2hV4GqDicWiCWMkTdFZBQWLQIakARrT0CBDxg1YBG67ehq3ceckppwkwCLniywVJBbxoBQ3LNWe/JGIjRYFJ2xBSwMYB+bOCGM8f8TNCjxDjZ81vC7RVgZXdxXlnP8fYCi1AW5+DN33SQA==;31:Z8wyMGML3ubSA3jBtOa2r5M8t+7RWC4zWvfn/udvZyYkwUy1U+FbX9vPznthkKp2m0A9G3Ug6ZEi42rKXlFdUyLjk80KTVQdh+jcQXy6WafNkM+V0NKPocjzxtBxTI0DduZmUzeHj4g8tetyQISrgJ5CWUDA+Atf5f3fFLcnzBJ9IeRbECkTJZyiPmT7M4ndA5H0bB8wE8Tx0edg9xxP1GUTh/LcUdM+wk7Avd2RGUM= X-MS-TrafficTypeDiagnostic: AM5PR0202MB2546: X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6041248)(2016111802025)(20161123555025)(20161123564025)(20161123560025)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6043046)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0202MB2546;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0202MB2546; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0202MB2546;4:zvegpj/tOMzFXSFAY6sz6rfYf82gkdHQADwRocIjqoPbN0q9L776CuMF5X6lWr+HcWvP1PU2g0BOZvI2JBj3d/8DtNMV990u1GVMikeLc9ZnZCpCq7rNIsi540E3eTtydX/+zV/hBOQZkkGkyDCPuQfTDKo3zAVrZWfvLyF+0fjZikQPpfOVY1lUkC4Sw5DJU/fjjWcNrwyPWLxBHNDCxtf4/hwPAieqDXVhjgSOxsdj111a2b5C9sTJ4x29AQx5 X-Forefront-PRVS: 0420213CCD X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6049001)(6009001)(39830400002)(189002)(199003)(24454002)(377424004)(31686004)(64126003)(229853002)(86362001)(6666003)(53936002)(65956001)(65806001)(117156002)(33646002)(50466002)(189998001)(4001350100001)(83506001)(7416002)(65826007)(97736004)(305945005)(77096006)(7736002)(6486002)(5660300001)(2950100002)(53546010)(31696002)(23676002)(101416001)(230700001)(105586002)(3260700006)(25786009)(4326008)(76176999)(54356999)(50986999)(81156014)(54906002)(36756003)(81166006)(106356001)(42186005)(8676002)(3846002)(74482002)(47776003)(66066001)(2906002)(7350300001)(6246003)(478600001)(68736007)(6116002)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XIVruryFyMfT+FCHxMTLo3ngn1ZrZYB5/VKP37m/nn9Mlw8F19vMPqp2Rg0=;7:I+999dn/Q+vHGKHBSubt7gtVH8T3hhsb1yu+3mpFOaVVj50nTUImZQ8glbsFJs+DUKSAq/iGB+GT5C4k7Wc3tgLPSESU/fZuJJxVKHLqXOcv7c/XjRR2Vva0EEnlUfIa5icclqH8I/OdoYIBUHT3Qj2nGzkxVdGMvPRZpJFUlr/rFCWFbXaXew7M6NYLs02B7WOS/ssmCsPA9+i26YImXpydUM4NC4j5edzTl84/2p4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 11:19:53.5509 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0202MB2546 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5115 Lines: 168 Hi! One comment inline... On 2017-09-01 23:48, Hans de Goede wrote: > Add a driver for the Pericom PI3USB30532 Type-C cross switch / > mux chip found on some devices with a Type-C port. > > Signed-off-by: Hans de Goede > --- > drivers/mux/Kconfig | 10 +++++ > drivers/mux/Makefile | 2 + > drivers/mux/pi3usb30532.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 109 insertions(+) > create mode 100644 drivers/mux/pi3usb30532.c > > diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig > index 17938918bf93..19a3065c34e6 100644 > --- a/drivers/mux/Kconfig > +++ b/drivers/mux/Kconfig > @@ -58,4 +58,14 @@ config MUX_MMIO > To compile the driver as a module, choose M here: the module will > be called mux-mmio. > > +config MUX_PI3USB30532 > + tristate "Pericom PI3USB30532 Type-C cross switch driver" > + depends on I2C > + help > + This driver adds support for the Pericom PI3USB30532 Type-C cross > + switch / mux chip found on some devices with a Type-C port. > + > + To compile the driver as a module, choose M here: the module will > + be called mux-pi3usb30532. > + > endmenu > diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile > index a12e812c7966..7563dbf04593 100644 > --- a/drivers/mux/Makefile > +++ b/drivers/mux/Makefile > @@ -7,9 +7,11 @@ mux-adg792a-objs := adg792a.o > mux-gpio-objs := gpio.o > mux-mmio-objs := mmio.o > mux-intel_cht_usb_mux-objs := intel_cht_usb_mux.o > +mux-pi3usb30532-objs := pi3usb30532.o > > obj-$(CONFIG_MULTIPLEXER) += mux-core.o > obj-$(CONFIG_MUX_ADG792A) += mux-adg792a.o > obj-$(CONFIG_MUX_GPIO) += mux-gpio.o > obj-$(CONFIG_MUX_MMIO) += mux-mmio.o > obj-$(CONFIG_MUX_CHT_USB_MUX) += mux-intel_cht_usb_mux.o > +obj-$(CONFIG_MUX_PI3USB30532) += mux-pi3usb30532.o > diff --git a/drivers/mux/pi3usb30532.c b/drivers/mux/pi3usb30532.c > new file mode 100644 > index 000000000000..fa8abd851520 > --- /dev/null > +++ b/drivers/mux/pi3usb30532.c > @@ -0,0 +1,97 @@ > +/* > + * Pericom PI3USB30532 Type-C cross switch / mux driver > + * > + * Copyright (c) 2017 Hans de Goede > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation, or (at your option) > + * any later version. > + */ > + > +#include > +#include > +#include > +#include /* For the MUX_USB_* defines */ > +#include > + > +#define PI3USB30532_CONF 0x00 > + > +#define PI3USB30532_CONF_OPEN 0x00 > +#define PI3USB30532_CONF_SWAP 0x01 > +#define PI3USB30532_CONF_4LANE_DP 0x02 > +#define PI3USB30532_CONF_USB3 0x04 > +#define PI3USB30532_CONF_USB3_AND_2LANE_DP 0x06 > + > +struct pi3usb30532_mux { > + struct i2c_client *client; > +}; > + > +static int pi3usb30532_mux_set_mux(struct mux_control *mux_ctrl, int state) > +{ > + struct pi3usb30532_mux *mux = mux_chip_priv(mux_ctrl->chip); The "mux" variable name is used for the mux_control in other drivers, and I don't think the private data is needed. Like so: static int pi3usb30532_mux_set_mux(struct mux_control *mux, int state) { struct i2c_client *i2c = to_i2c_client(mux->chip->dev.parent); ... Cheers, Peter > + u8 conf = PI3USB30532_CONF_OPEN; > + > + switch (state & ~MUX_USB_POLARITY_INV) { > + case MUX_USB_NONE: > + conf = PI3USB30532_CONF_OPEN; > + break; > + case MUX_USB_DEVICE: > + case MUX_USB_HOST: > + conf = PI3USB30532_CONF_USB3; > + break; > + case MUX_USB_HOST_AND_DP_SRC: > + conf = PI3USB30532_CONF_USB3_AND_2LANE_DP; > + break; > + case MUX_USB_DP_SRC: > + conf = PI3USB30532_CONF_4LANE_DP; > + break; > + } > + > + if (state & MUX_USB_POLARITY_INV) > + conf |= PI3USB30532_CONF_SWAP; > + > + return i2c_smbus_write_byte_data(mux->client, PI3USB30532_CONF, conf); > +} > + > +static const struct mux_control_ops pi3usb30532_mux_ops = { > + .set = pi3usb30532_mux_set_mux, > +}; > + > +static int pi3usb30532_mux_probe(struct i2c_client *client) > +{ > + struct device *dev = &client->dev; > + struct pi3usb30532_mux *mux; > + struct mux_chip *mux_chip; > + > + mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*mux)); > + if (IS_ERR(mux_chip)) > + return PTR_ERR(mux_chip); > + > + mux_chip->ops = &pi3usb30532_mux_ops; > + mux_chip->mux[0].states = MUX_USB_STATES; > + mux = mux_chip_priv(mux_chip); > + mux->client = client; > + > + return devm_mux_chip_register(dev, mux_chip); > +} > + > +static const struct i2c_device_id pi3usb30532_mux_table[] = { > + { "pi3usb30532" }, > + { } > +}; > +MODULE_DEVICE_TABLE(i2c, pi3usb30532_mux_table); > + > +static struct i2c_driver pi3usb30532_mux_driver = { > + .driver = { > + .name = "pi3usb30532", > + }, > + .probe_new = pi3usb30532_mux_probe, > + .id_table = pi3usb30532_mux_table, > +}; > + > +module_i2c_driver(pi3usb30532_mux_driver); > + > +MODULE_AUTHOR("Hans de Goede "); > +MODULE_DESCRIPTION("Pericom PI3USB30532 Type-C mux driver"); > +MODULE_LICENSE("GPL"); >