Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812183/?format=api
{ "id": 812183, "url": "http://patchwork.ozlabs.org/api/patches/812183/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170910214424.14945-3-linus.walleij@linaro.org/", "project": { "id": 35, "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api", "name": "Linux I2C development", "link_name": "linux-i2c", "list_id": "linux-i2c.vger.kernel.org", "list_email": "linux-i2c@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170910214424.14945-3-linus.walleij@linaro.org>", "list_archive_url": null, "date": "2017-09-10T21:44:21", "name": "[2/5] gpio: Make it possible for consumers to enforce open drain", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "2f5640ad327a1430e055ead0247599ed8c932c37", "submitter": { "id": 7055, "url": "http://patchwork.ozlabs.org/api/people/7055/?format=api", "name": "Linus Walleij", "email": "linus.walleij@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/20170910214424.14945-3-linus.walleij@linaro.org/mbox/", "series": [ { "id": 2418, "url": "http://patchwork.ozlabs.org/api/series/2418/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=2418", "date": "2017-09-10T21:44:19", "name": "I2C GPIO to use gpiolibs open drain", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/2418/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812183/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812183/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-i2c-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@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=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"f13CFFUt\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xr4N12555z9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 07:44:49 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751732AbdIJVor (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSun, 10 Sep 2017 17:44:47 -0400", "from mail-lf0-f49.google.com ([209.85.215.49]:37169 \"EHLO\n\tmail-lf0-f49.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751901AbdIJVop (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Sun, 10 Sep 2017 17:44:45 -0400", "by mail-lf0-f49.google.com with SMTP id 80so14425824lfy.4\n\tfor <linux-i2c@vger.kernel.org>; Sun, 10 Sep 2017 14:44:44 -0700 (PDT)", "from fabina.bredbandsbolaget.se\n\t(c-2209e055.014-348-6c756e10.cust.bredbandsbolaget.se.\n\t[85.224.9.34]) by smtp.gmail.com with ESMTPSA id\n\tc69sm1461546ljd.42.2017.09.10.14.44.42\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 10 Sep 2017 14:44:43 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=3OzOMaHhrE0eXAmi4wMrtmLcwMGHbnzFG+tb1ouVSTM=;\n\tb=f13CFFUtVyfsx5AcGsEqVgUFWW5TDbW6HKWikPTRqIHSH2wUOO+OlgOTRvUknjyOnK\n\tOdfuYEqlLGs3KBIOux40PqfeW8C9zXrUsWzjzfNA615n22sm02zpxRfSo8AJnwftFNae\n\tCnydNw11w+CGGgYpZZ3B5VGLmnwSWpDJJi1E8=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=3OzOMaHhrE0eXAmi4wMrtmLcwMGHbnzFG+tb1ouVSTM=;\n\tb=uOcRMMzyU1zlwWfOaFcmxO9Okm2sVD1vZdydT+VmnIWncrkYfZdeJsAWhfbYw+Cx3h\n\tp+wqss1nkfJwq/uVJX/XiNmBZzBWw/Te5F9ooWpiC1hhbt+25em0f1DYp4rOnmNI/OUK\n\tNj9XhUMH0L1OlZyVSg9kAS86KIcmwbFjN7FIx3NNo2pxf2XDHMRtKLVxbJECAZ+HXY+c\n\tLIuJUJd9n3LhLWPbTX1Qo3knEjuzrNmNPTvhy9bvRu8B3UVpH7yq4lzLrhC4CUImF9Ve\n\tUM7lqfJ1/o+SYJ78yF+TzjXgYvcL1GlkphIxIDtafNYgfFk3Y+d9ucp/zPP51CSKrDSG\n\tQgDw==", "X-Gm-Message-State": "AHPjjUhT3uwbFyFzw3qLDPcdF5gC9qPG9pofICGO14E0NRG8B+LXYUqj\n\tuOZ2tBR2HD3G27iPphtrnw==", "X-Google-Smtp-Source": "ADKCNb5W6zIcbW16ATH6Qujab5EAE8VX7IQ2ZIqmOz4qsx8c10NUo7kV+LHavYyn+Znnh/Ph1Xk/CA==", "X-Received": "by 10.46.69.194 with SMTP id s185mr3629566lja.102.1505079884086; \n\tSun, 10 Sep 2017 14:44:44 -0700 (PDT)", "From": "Linus Walleij <linus.walleij@linaro.org>", "To": "Wolfram Sang <wsa@the-dreams.de>, linux-i2c@vger.kernel.org", "Cc": "linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,\n\tadi-buildroot-devel@lists.sourceforge.net,\n\tLinus Walleij <linus.walleij@linaro.org>, linux-gpio@vger.kernel.org", "Subject": "[PATCH 2/5] gpio: Make it possible for consumers to enforce open\n\tdrain", "Date": "Sun, 10 Sep 2017 23:44:21 +0200", "Message-Id": "<20170910214424.14945-3-linus.walleij@linaro.org>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170910214424.14945-1-linus.walleij@linaro.org>", "References": "<20170910214424.14945-1-linus.walleij@linaro.org>", "Sender": "linux-i2c-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-i2c.vger.kernel.org>", "X-Mailing-List": "linux-i2c@vger.kernel.org" }, "content": "Some busses, like I2C, strictly need to have the line handled\nas open drain, i.e. not actively driven high. For this reason\nthe i2c-gpio.c bit-banged I2C driver is reimplementing open\ndrain handling outside of gpiolib.\n\nThis is not very optimal. Instead make it possible for a\nconsumer to explcitly express that the line must be handled\nas open drain instead of allowing local hacks papering over\nthis issue.\n\nThe descriptor tables, whether DT, ACPI or board files, should\nof course have flagged these lines as open drain. E.g.:\nenum gpio_lookup_flags GPIO_OPEN_DRAIN for a board file, or\ngpios = <&foo 42 GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN>; in a\ndevice tree using <dt-bindings/gpio/gpio.h>\n\nBut more often than not, these descriptors are wrong. So\nwe need to make it possible for consumers to enforce this\nopen drain behaviour.\n\nWe now have two new enumerated GPIO descriptor config flags:\nGPIOD_OUT_LOW_OPEN_DRAIN and GPIOD_OUT_HIGH_OPEN_DRAIN\nthat will set up the lined enforced as open drain as output\nlow or high, using open drain (if the driver supports it)\nor using open drain emulation (setting the line as input\nto drive it high) from the gpiolib core.\n\nCc: linux-gpio@vger.kernel.org\nSigned-off-by: Linus Walleij <linus.walleij@linaro.org>\n---\nObviously I authorize this patch to be applied directly\nto the I2C tree as part of the refactorings.\n---\n drivers/gpio/gpiolib.c | 13 +++++++++++++\n include/linux/gpio/consumer.h | 6 ++++++\n 2 files changed, 19 insertions(+)", "diff": "diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c\nindex cd003b74512f..cb73a50a5d5d 100644\n--- a/drivers/gpio/gpiolib.c\n+++ b/drivers/gpio/gpiolib.c\n@@ -3228,8 +3228,21 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,\n \n \tif (lflags & GPIO_ACTIVE_LOW)\n \t\tset_bit(FLAG_ACTIVE_LOW, &desc->flags);\n+\n \tif (lflags & GPIO_OPEN_DRAIN)\n \t\tset_bit(FLAG_OPEN_DRAIN, &desc->flags);\n+\telse if (dflags & GPIOD_FLAGS_BIT_OPEN_DRAIN) {\n+\t\t/*\n+\t\t * This enforces open drain mode from the consumer side.\n+\t\t * This is necessary for some busses like I2C, but the lookup\n+\t\t * should *REALLY* have specified them as open drain in the\n+\t\t * first place, so print a little warning here.\n+\t\t */\n+\t\tset_bit(FLAG_OPEN_DRAIN, &desc->flags);\n+\t\tgpiod_warn(desc,\n+\t\t\t \"enforced open drain please flag it properly in DT/ACPI DSDT/board file\\n\");\n+\t}\n+\n \tif (lflags & GPIO_OPEN_SOURCE)\n \t\tset_bit(FLAG_OPEN_SOURCE, &desc->flags);\n \tif (lflags & GPIO_SLEEP_MAY_LOOSE_VALUE)\ndiff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h\nindex 8f702fcbe485..5f72a49d1aa3 100644\n--- a/include/linux/gpio/consumer.h\n+++ b/include/linux/gpio/consumer.h\n@@ -28,6 +28,7 @@ struct gpio_descs {\n #define GPIOD_FLAGS_BIT_DIR_SET\t\tBIT(0)\n #define GPIOD_FLAGS_BIT_DIR_OUT\t\tBIT(1)\n #define GPIOD_FLAGS_BIT_DIR_VAL\t\tBIT(2)\n+#define GPIOD_FLAGS_BIT_OPEN_DRAIN\tBIT(3)\n \n /**\n * Optional flags that can be passed to one of gpiod_* to configure direction\n@@ -39,6 +40,11 @@ enum gpiod_flags {\n \tGPIOD_OUT_LOW\t= GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT,\n \tGPIOD_OUT_HIGH\t= GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT |\n \t\t\t GPIOD_FLAGS_BIT_DIR_VAL,\n+\tGPIOD_OUT_LOW_OPEN_DRAIN = GPIOD_FLAGS_BIT_DIR_SET |\n+\t\t\t GPIOD_FLAGS_BIT_DIR_OUT | GPIOD_FLAGS_BIT_OPEN_DRAIN,\n+\tGPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_FLAGS_BIT_DIR_SET |\n+\t\t\t GPIOD_FLAGS_BIT_DIR_OUT | GPIOD_FLAGS_BIT_DIR_VAL |\n+\t\t\t GPIOD_FLAGS_BIT_OPEN_DRAIN,\n };\n \n #ifdef CONFIG_GPIOLIB\n", "prefixes": [ "2/5" ] }