Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933808AbdC3N1o (ORCPT ); Thu, 30 Mar 2017 09:27:44 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:57450 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933331AbdC3N1k (ORCPT ); Thu, 30 Mar 2017 09:27:40 -0400 X-IronPort-AV: E=Sophos;i="5.36,246,1486393200"; d="scan'208";a="238243858" From: Chris Brandt To: Linus Walleij CC: Jacopo Mondi , Bjorn Andersson , Geert Uytterhoeven , Laurent Pinchart , Rob Herring , Mark Rutland , Russell King , Linux-Renesas , "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v3 3/7] arm: dts: dt-bindings: Add Renesas RZ pinctrl header Thread-Topic: [PATCH v3 3/7] arm: dts: dt-bindings: Add Renesas RZ pinctrl header Thread-Index: AQHSpLJ6VNE1pFUaX0a1Hx3QR4RDhaGr1ZuAgAAPSICAAS0xgIAARUCA Date: Thu, 30 Mar 2017 13:27:31 +0000 Message-ID: References: <1490368934-12494-1-git-send-email-jacopo+renesas@jmondi.org> <1490368934-12494-4-git-send-email-jacopo+renesas@jmondi.org> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=renesas.com; x-originating-ip: [75.60.247.61] x-microsoft-exchange-diagnostics: 1;SG2PR06MB1168;7:yS2OAKnKmXwEZN5e/O2hJBD9sbWM59ynwpCyb8pycCM+bleYHmyAdJ1HeCvJGXwGLmOBHLTzLhwawS4CDVk3YqVcqqG6xqTI7A9NcZlxpXvA+0tZhJsU0g0qZmMXYY68mie3H0SWkQvUH3I/UV7LkaiM0zTADi4PYJtr05KRapvkAkMt+BQ4LJ3wZ+VSCvv01fLO8QP1WuimRhmr04LYfddS4XWnsjuMV91Rj5F46VWPxlZZEEOYwEpOfka+Av/p6vfY058gKxTRqNX8m/9s8puyhyPZKWhOklEyTFlpNZiTVbIOd4edY/8UagY+Xpvt9KMQ+LVqa+Y4YSJ3mFnewg==;20:9QzfRKa3kw/UDXyETtLT5am3SrJoIqMYdR1OWYyTsUUQwq755moh+H+MOnz5cNjnovHZn73og1WXR5fU0lWFa7s3M9YqOsH3Rl1NtE3vUAtMRIY+MZLVWmh+TNx+Vu+9eRZDJFfcdLcSg0Vf01jV63zlzbh7f5FHiI3zPaUDMHc= x-ms-office365-filtering-correlation-id: ad38d16e-bf15-445f-61fc-08d4777084f7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:SG2PR06MB1168; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006067)(93001067)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123562025)(20161123564025)(6072148);SRVR:SG2PR06MB1168;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB1168; x-forefront-prvs: 02622CEF0A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(6009001)(39840400002)(39450400003)(39860400002)(39850400002)(39400400002)(39410400002)(24454002)(102836003)(66066001)(189998001)(229853002)(6116002)(3846002)(8676002)(6506006)(54906002)(122556002)(99286003)(55016002)(77096006)(9686003)(53936002)(6436002)(33656002)(110136004)(54356999)(2900100001)(7416002)(50986999)(76176999)(2950100002)(6916009)(4326008)(25786009)(7696004)(81166006)(93886004)(6246003)(38730400002)(5660300001)(3660700001)(86362001)(2906002)(3280700002)(7736002)(305945005)(8936002)(74316002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB1168;H:SG2PR06MB1165.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Mar 2017 13:27:31.5298 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1168 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v2UDRnAc003385 Content-Length: 4289 Lines: 94 On Thursday, March 30, 2017, Linus Walleij wrote: > >> > +/* > >> > + * Pin is bi-directional. > >> > + * An alternate function that needs both input/output > >> > +functionalities shall > >> > + * be configured as bidirectional. > >> > + * Eg. SDA/SCL pins of an I2c interface. > >> > + */ > >> > +#define BI_DIR (1 << 3) > >> > >> Any specific reason why this should not simply be added to > >> include/linux/pinctrl/pinconf-generic.h > >> as PIN_CONFIG_BIDIRECTIONAL and parsed in drivers/pinctrl/pinconf- > >> generic.c from the (new) DT property "bidirectional" simply? > > > > I see your point. It would cut down from every driver out there > > inventing some new property or config instead of everyone just sharing > > a fixed set. > > Maybe someone else out there will end up having a need for a > > "bidirectional" option. > > I was thinking about that one. It is a bit weird electrically, like what > kind of electronics is really bidirectional? > > It seems like a fancy name for open drain/open source, what we call > "single ended" configuration. (See docs in > Documentation/gpio/driver.txt) > > It would be great if you could check if that is what they mean, actually. Here is the definition of the register in the hardware manual: --- 54.3.13 Port Bidirection Control Register (PBDCn) This register enables or disables the input buffer while the output buffer is enabled. When the input buffer is enabled while the output buffer is enabled, the bidirectional mode is entered, allowing the level of the Pn_m pin to always be read via the PPRn.PPRnm bit. --- But...what they don't really tell you is that any peripheral that needs to TX and RX data over a pin needs this set. In the hardware manual, there is a pretty picture (Figure 54.1 Logical Diagram of Port Control) that shows a detailed logic diagram of the interface between the peripheral bus and the pin pad. As far as I can tell, the "function mux" portion of this controller only knows how to set a pin as direction=in or direction=out. So, in the case of I2C where each the SCL and SDA pins needs to be driven and read...it can't do that. Therefore, there is an additional register to manually enable the input buffer and let the mux enable the output buffer. So while yes, I2C is open-drain, this is also the case for the data pins for the SDHI. And the MDIO pin from Ethernet. It really has to do with the fact that this pin controller wasn't designed to enable both the input and output buffers at the same time. The situation is similar for our SWIO_IN and SWIO_OUT flags. For example, to use the SSI sound interface, you have to set the TX signals to "input" (SWIO_IN). Makes sense, right?? I could argue that all of these "FLAGS" settings should have been incorporated in the HW logic of the pin controller...but for whatever reason, the they had to make them separate registers and make SW do it. So, I could argue that these registers settings are really part of pin muxing, not really user config....and hence belong in the "pinmux" property. How about this compromise: Instead of BI_DIR, we use "TYPE_I2C", "TYPE_SDDATA", "TYPE_MDIO", "TYPE_LVDS", etc... to describe the 'special' ones. That way it can go back under "pinmux". Like Jacopo said, these register settings are really supposed to be set when you are selecting the pin-mux option. Of course behind the scenes, it's really: #define TYPE_I2C BI_DIR #define TYPE_SDDATA BI_DIR #define TYPE_SDCMD BI_DIR #define TYPE_LVDS SWIO_OUT Examples: i2c3_pins: i2c3 { pinmux = , ; }; /* SHDI ch1 on CN1 */ sdhi1_pins: sdhi1 { /* SHDI ch1 on Port 3 */ pinmux = , /* SDHI1 CD */ , /* SDHI1 WP */ , /* SDHI1 DAT1 */ , /* SDHI1 DAT0 */ , /* SDHI1 CLK */ , /* SDHI1 CMD */ , /* SDHI1 DAT3 */ ; /* SDHI1 DAT2 */ }; # Honestly, I have no idea where this pin controller came from. I have not seen it in any other Renesas part (Mitsubishi/Hitachi/NEC). Chris