From patchwork Wed Nov 20 14:20:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khouloud Touil X-Patchwork-Id: 1198189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="W+tP1rw2"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47J4cc2yCTz9sPc for ; Thu, 21 Nov 2019 01:21:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730695AbfKTOVS (ORCPT ); Wed, 20 Nov 2019 09:21:18 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43158 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731181AbfKTOVS (ORCPT ); Wed, 20 Nov 2019 09:21:18 -0500 Received: by mail-wr1-f66.google.com with SMTP id n1so28334362wra.10 for ; Wed, 20 Nov 2019 06:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=za3zJeHvU0xsb+kVLYuV4NbEHUu6TiF22N06z5xdZ7U=; b=W+tP1rw2S5Fc+lxE+TQaS6NaMeN6WwgCXDo2wOGNxrp7LT9s9DLDz37CmIcQRKEPty 7fBrZtDiaimwh7tNkVJbYDYmxpbaRhBRP5O3OzoHb0LwAwJ3+DRGx1+fNKY7rCCT9hmW fCajlmDr973VZ8M1rWltXJS5PFSQ41nlVoiqGA+gvz1cViUy5V+EofZOjTiAS0Ljm4Eb m+hzw/4S2kXrhlCdQRqnBFbGEgDuhwIEsYa5JXLnA0BGr0fkf0pCoVfaqNjllDxZ4Xz0 Std7cZ1hyWOJOqXDTcLhieU/F4W2Gi+MsmxyqFumai8rTheltxM0x3a8ppfdUQbZKzLw keBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=za3zJeHvU0xsb+kVLYuV4NbEHUu6TiF22N06z5xdZ7U=; b=TXUuXgAyjgIPBHIVcuJR7s+kffBizOFrRIWe5mcOnz6kDlFsSqpg5mSrCNbQ3t809E ddMDaYSMXjTORYnUqpxwiUQ9Ej3geWXluMxw/3QeXB8ivN/9RRcW/znU81LyHRvsKjMx 5o9t7z+bdM8otcPt1fK+CiTQ0LzzjSyYncjMLQbhj+EuIji0hnv+UFSOUIrN7evlBpyy iObEY3PdB3gAFmUg4dgK2S7w9AT8eXS1/N6dJG92wuVYeOufE1uUy0b10ly5VF9z9vkT elfHPm854Fv1+pTFOKD14lHcJ76DMN1fQpDNQAXl8Pk0YRbi9sHNn/kUxTVD83cKUYrk V6Ew== X-Gm-Message-State: APjAAAUAxO7l8XtIoRjRUcgWGUhcBpa1FqOaZUbGXaOG8cPH3mVekmvD Z+6M5S292dfkBjWJb/4xbvfmMw== X-Google-Smtp-Source: APXvYqxRWKxe1lMjANGtX4GLxYvQr5Ad9CARdzZrXIVR1/8+l3Ghy89CSmQDbIhO9iKAq7OC83D49w== X-Received: by 2002:a5d:5262:: with SMTP id l2mr3626840wrc.315.1574259675393; Wed, 20 Nov 2019 06:21:15 -0800 (PST) Received: from khouloud-ThinkPad-T470p.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a6sm34544352wrh.69.2019.11.20.06.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:21:14 -0800 (PST) From: Khouloud Touil To: bgolaszewski@baylibre.com, robh+dt@kernel.org, mark.rutland@arm.com, srinivas.kandagatla@linaro.org, baylibre-upstreaming@groups.io Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linus.walleij@linaro.org, Khouloud Touil Subject: [PATCH 1/4] dt-bindings: nvmem: new optional property write-protect-gpios Date: Wed, 20 Nov 2019 15:20:35 +0100 Message-Id: <20191120142038.30746-2-ktouil@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120142038.30746-1-ktouil@baylibre.com> References: <20191120142038.30746-1-ktouil@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Many nvmem memory chips have a write-protect pin which, when pulled high, blocks the write operations. On some boards, this pin is connected to a GPIO and pulled high by default, which forces the user to manually change its state before writing. Instead of modifying all the memory drivers to check this pin, make the NVMEM subsystem check if the write-protect GPIO being passed through the nvmem_config or defined in the device tree and pull it low whenever writing to the memory. Add a new optional property to the device tree binding document, which allows to specify the GPIO line to which the write-protect pin is connected. Signed-off-by: Khouloud Touil --- Documentation/devicetree/bindings/nvmem/nvmem.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index 1c75a059206c..6724764af794 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -34,6 +34,11 @@ properties: description: Mark the provider as read only. + wp-gpios: + description: + GPIO to which the write-protect pin of the chip is connected. + maxItems: 1 + patternProperties: "^.*@[0-9a-f]+$": type: object @@ -66,6 +71,7 @@ examples: qfprom: eeprom@700000 { #address-cells = <1>; #size-cells = <1>; + wp-gpios = <&gpio1 3 0>; /* ... */ From patchwork Wed Nov 20 14:20:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khouloud Touil X-Patchwork-Id: 1198192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="mCQd+sjf"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47J4cf6zcsz9sPj for ; Thu, 21 Nov 2019 01:21:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730617AbfKTOVS (ORCPT ); Wed, 20 Nov 2019 09:21:18 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40382 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729157AbfKTOVS (ORCPT ); Wed, 20 Nov 2019 09:21:18 -0500 Received: by mail-wm1-f66.google.com with SMTP id y5so1832603wmi.5 for ; Wed, 20 Nov 2019 06:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UVgEzZUqj/rGeV0gpV6EMnUQLA1qOOwWUDV3PGhj9Ac=; b=mCQd+sjfE7wtBK6zJsJfF4TEClmFlV2uwcVjpSnEwxKCPKqyNnxS5rF0SWrBKnKPFU vHy/w/b9NSo8D3A5OZEfyQObyxMRCdIkhrP0n89BXzZlJ8I4AQ2+ETF1AuXEEZGTb5fQ Pvrqi0rGzqzV5busfH2snALRRbNZT7smyUtaV4gDLzfHy6OxFyDBzNz7xwbPWLzD+mM8 ZTH89EH4oP54C03BvVCusf/LKlspnfgTdij+a1w4Y4a0unaSRgIW+4khs5igJDxfhZXv l+iCQt8tJHt32aZpNyt/e1ECi+aK1OWelqL1gUMGEK2qh1WYtwIFBmPq4Qyk/fc1k2Z+ RsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UVgEzZUqj/rGeV0gpV6EMnUQLA1qOOwWUDV3PGhj9Ac=; b=ALJdMNANaDyvZMLzjeX5OhWlMghRYfhIRpufyHNSyx5dWD1TIw78IagTLTdkNMeXQQ kQa5Y5SkWtDRgTIBhNKPPlKApZDpHthKpkDxfUbkE85ykj0MD+rH/Pfx1Apii3J1/SUR NcRlWIUKPEKuPtEC4BUn7JkM4acLRXw/6nC/DS/xta+3gAfQjnS/EDu/eI8AYrjLTOmQ 0iZNnpuAspMIz+lQx6WSJJ9gto7jNtdEZ3+5mLFoLd6Nfb3lOvfYC8MW4u0C24PAp/31 DevoXQN0OIsLzWK7JP/Ae7LFIp4eZTTodKMDW6X4Qu0UGJO4IhjXTBXbi0Tlsu8lgvIr Topg== X-Gm-Message-State: APjAAAXG6fmGxDXDrdCYFzLahtYgZud/EuPzQ5AgwJAKfjwgqg/JhA8e HhNNoZSx4DakQxfDf3itRbffwsE+/dL95T2bYaw= X-Google-Smtp-Source: APXvYqwk+4VcPPuDXyBelcKuyBaFoMOPtFBDyG6NboDng6OOBsXXRFXQydRCyo8MLY0z7qDjd3Pr7w== X-Received: by 2002:a7b:c94e:: with SMTP id i14mr3439984wml.174.1574259676358; Wed, 20 Nov 2019 06:21:16 -0800 (PST) Received: from khouloud-ThinkPad-T470p.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a6sm34544352wrh.69.2019.11.20.06.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:21:15 -0800 (PST) From: Khouloud Touil To: bgolaszewski@baylibre.com, robh+dt@kernel.org, mark.rutland@arm.com, srinivas.kandagatla@linaro.org, baylibre-upstreaming@groups.io Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linus.walleij@linaro.org, Khouloud Touil Subject: [PATCH 2/4] nvmem: add support for the write-protect pin Date: Wed, 20 Nov 2019 15:20:36 +0100 Message-Id: <20191120142038.30746-3-ktouil@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120142038.30746-1-ktouil@baylibre.com> References: <20191120142038.30746-1-ktouil@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The write-protect pin handling looks like a standard property that could benefit other users if available in the core nvmem framework. Instead of modifying all the memory drivers to check this pin, make the NVMEM subsystem check if the write-protect GPIO being passed through the nvmem_config or defined in the device tree and pull it low whenever writing to the memory. There was a suggestion for introducing the gpiodesc from pdata, but as pdata is already removed it could be replaced by adding it to nvmem_config. Reference: https://lists.96boards.org/pipermail/dev/2018-August/001056.html Signed-off-by: Khouloud Touil --- drivers/nvmem/core.c | 20 ++++++++++++++++++-- drivers/nvmem/nvmem.h | 2 ++ include/linux/nvmem-provider.h | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 057d1ff87d5d..ae6c3455eb11 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include "nvmem.h" @@ -54,8 +55,14 @@ static int nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offset, static int nvmem_reg_write(struct nvmem_device *nvmem, unsigned int offset, void *val, size_t bytes) { - if (nvmem->reg_write) - return nvmem->reg_write(nvmem->priv, offset, val, bytes); + int ret; + + if (nvmem->reg_write) { + gpiod_set_value_cansleep(nvmem->wp_gpio, 0); + ret = nvmem->reg_write(nvmem->priv, offset, val, bytes); + gpiod_set_value_cansleep(nvmem->wp_gpio, 1); + return ret; + } return -EINVAL; } @@ -365,6 +372,15 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) kfree(nvmem); return ERR_PTR(rval); } + if (config->wp_gpio) + nvmem->wp_gpio = config->wp_gpio; + else + nvmem->wp_gpio = gpiod_get_optional(config->dev, + "wp", + GPIOD_OUT_HIGH); + if (IS_ERR(nvmem->wp_gpio)) + return PTR_ERR(nvmem->wp_gpio); + kref_init(&nvmem->refcnt); INIT_LIST_HEAD(&nvmem->cells); diff --git a/drivers/nvmem/nvmem.h b/drivers/nvmem/nvmem.h index eb8ed7121fa3..be0d66d75c8a 100644 --- a/drivers/nvmem/nvmem.h +++ b/drivers/nvmem/nvmem.h @@ -9,6 +9,7 @@ #include #include #include +#include struct nvmem_device { struct module *owner; @@ -26,6 +27,7 @@ struct nvmem_device { struct list_head cells; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; + struct gpio_desc *wp_gpio; void *priv; }; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index fe051323be0a..6d6f8e5d24c9 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -11,6 +11,7 @@ #include #include +#include struct nvmem_device; struct nvmem_cell_info; @@ -45,6 +46,7 @@ enum nvmem_type { * @word_size: Minimum read/write access granularity. * @stride: Minimum read/write access stride. * @priv: User context passed to read/write callbacks. + * @wp-gpio: Write protect pin * * Note: A default "nvmem" name will be assigned to the device if * no name is specified in its configuration. In such case "" is @@ -58,6 +60,7 @@ struct nvmem_config { const char *name; int id; struct module *owner; + struct gpio_desc *wp_gpio; const struct nvmem_cell_info *cells; int ncells; enum nvmem_type type; From patchwork Wed Nov 20 14:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khouloud Touil X-Patchwork-Id: 1198194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="lOLy+t1U"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47J4cl4gyqz9sPc for ; Thu, 21 Nov 2019 01:21:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731567AbfKTOVU (ORCPT ); Wed, 20 Nov 2019 09:21:20 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44428 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730882AbfKTOVU (ORCPT ); Wed, 20 Nov 2019 09:21:20 -0500 Received: by mail-wr1-f68.google.com with SMTP id i12so2187200wrn.11 for ; Wed, 20 Nov 2019 06:21:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LS7jj1HIKvxgyHyZgfXU7kIDSCI29CxRcup6bkz0xxs=; b=lOLy+t1UEdjZqFD3P7QqzpnA1t+QUe3z2C2PhubGVM1WveK1FYtTl8qbaE5mNeLVJB 6s6aDKzzbuZ5JOglZZIPE9rpWvEZmKeQ+ZJO/Twa1wjg5DIRQO7oF/sDcY0krKSkUwdg 0oDU19XvCeCb0byrTrDyCfh4NYiAfRAJQGBz92+RQo8IKUrPAQdfn9cSqsCLAEi05Er/ loijRwqaYkMGFUefPrD+qIsDTG1YvTH99ho8JcUv+2c8vaNxdIuwTYmOSQnvjifa39qa ZzuoPk1yxNCn01iBehSAPJLt9YGx2HeYznIW/BbdRgOezls7KFtXOjHAJKMTUV1lUD2D ZtmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LS7jj1HIKvxgyHyZgfXU7kIDSCI29CxRcup6bkz0xxs=; b=kgTWA6n8G5d/aPSlzdI9JsfHX46Or2NEAnmGxNhfMBtMVEcau1sArUfGYaUNKeq7yw uXySj/Dg+2N4ooxvufKv08U6PQcs5kZagHBVwYtdCfs9f0zzSPNpSlJcSZQMsXFpckCz F0gKAcgzimfLT7B9+IO0ihzo1vQMnFNUDUaWL0uUQwe6HIg4NKydAIfM3pMjJYl+GR+h n36NXAT+5LFE3GELM7VqOJngllM4VzjIm2qy7Tl9bqmimqtl8AnsZ214XBeHp5Zuk+Rt ekjmErD4fTPW3NqTrlMWKkAzUWQKoo78NBJPsVpe0Ou3n942oSTypifzQOCT3KAIBvzx hsyA== X-Gm-Message-State: APjAAAWxP4Pxu4MZ0D+OtefGbsC1io6AOwYph1AvlvLEZfo4JA+5IlMc jhWc5H4O5pXKqfQpLazaMPbAMQ== X-Google-Smtp-Source: APXvYqwz7SRyInT03KHZU5F1rb/YeUVzScLvge46nTa5iYaaaFChHhxw2MKL6FUI383HHm+OIXN7hA== X-Received: by 2002:a05:6000:101:: with SMTP id o1mr3721410wrx.394.1574259677371; Wed, 20 Nov 2019 06:21:17 -0800 (PST) Received: from khouloud-ThinkPad-T470p.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a6sm34544352wrh.69.2019.11.20.06.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:21:16 -0800 (PST) From: Khouloud Touil To: bgolaszewski@baylibre.com, robh+dt@kernel.org, mark.rutland@arm.com, srinivas.kandagatla@linaro.org, baylibre-upstreaming@groups.io Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linus.walleij@linaro.org, Khouloud Touil Subject: [PATCH 3/4] dt-bindings: at24: remove the optional property write-protect-gpios Date: Wed, 20 Nov 2019 15:20:37 +0100 Message-Id: <20191120142038.30746-4-ktouil@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120142038.30746-1-ktouil@baylibre.com> References: <20191120142038.30746-1-ktouil@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org NVMEM framework is an interface for the at24 EEPROMs as well as for other drivers, instead of passing the wp-gpios over the different drivers each time, it would be better to pass it over the NVMEM subsystem once and for all. Removing the optional property form the device tree binding document. Signed-off-by: Khouloud Touil --- Documentation/devicetree/bindings/eeprom/at24.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Documentation/devicetree/bindings/eeprom/at24.yaml b/Documentation/devicetree/bindings/eeprom/at24.yaml index e8778560d966..9894237ac432 100644 --- a/Documentation/devicetree/bindings/eeprom/at24.yaml +++ b/Documentation/devicetree/bindings/eeprom/at24.yaml @@ -145,11 +145,6 @@ properties: over reads to the next slave address. Please consult the manual of your device. - wp-gpios: - description: - GPIO to which the write-protect pin of the chip is connected. - maxItems: 1 - address-width: allOf: - $ref: /schemas/types.yaml#/definitions/uint32 @@ -181,7 +176,6 @@ examples: compatible = "microchip,24c32", "atmel,24c32"; reg = <0x52>; pagesize = <32>; - wp-gpios = <&gpio1 3 0>; num-addresses = <8>; }; }; From patchwork Wed Nov 20 14:20:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khouloud Touil X-Patchwork-Id: 1198193 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="bbGGdIG8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47J4cj6MsXz9sPc for ; Thu, 21 Nov 2019 01:21:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731582AbfKTOVV (ORCPT ); Wed, 20 Nov 2019 09:21:21 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52021 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730966AbfKTOVU (ORCPT ); Wed, 20 Nov 2019 09:21:20 -0500 Received: by mail-wm1-f68.google.com with SMTP id q70so7140140wme.1 for ; Wed, 20 Nov 2019 06:21:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hc8hYB3tbZIod+IQ6MbwVcYHzkJ7GhB4LPUoKfpHBhg=; b=bbGGdIG8CJ1VEwyvm3y8H9OEzouxX5YUlVCLvoh6v+C2mp5+I3HC5s5lrDBbxANKk1 cW3mLQhthQBpB6dK1G8UH5qpHOayPMkgVbLUim7e2ePY/pq0TNd5Add/viZsjSZQl+si //3W73zDWghkbFXIWkkWUPHTfv4GUJFnmTEdzN9U/9pWsk+dVTAfD0F6wnhVRf36ISDi CZTcdbRZPmQ1EfsMkC1gq3kwLiieQA48/nSscfZhpIgL5hO5bxJKF9O2KIHQRMCfCto4 1uRDYDVbbUUvqxjiUkoHfHQe6cKiJGK/6NlZdiR4Q5tdmuFEBN7pqTQp6iC0fEqVH2AW jGtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hc8hYB3tbZIod+IQ6MbwVcYHzkJ7GhB4LPUoKfpHBhg=; b=SY1oqmhc4+2LEEWnsznqfXgKpNRCbWUdzptSfgGAHMUNV9ZObbTa+mQTzfNztItDuy hnmB+Rp/1gPqqCDosGAM1AkQ9mvtn/ttjpEnOBtW3XA9pMlR1P8R4qnwpREAn1F+OeNg KPrRBWDC4rLg8BVAFK1+zZGjWxpUFawUGyfWAqKFDJ3sIP1LqR2X5jP27VfYv/qF0/Lz g15MGrgdMFFGh7vO1v4fdrZNlJE/cobBNXmX+B9Y52Yo3ROJI+Q/t4cqwoa1W1/ikidd /jH1rswbfZFPh0xjyVuHhi7Y0AfWCcgg3KjbzIJwGMtveUjBFYZ7NF7FSRtKZj9f+Sn7 NhXQ== X-Gm-Message-State: APjAAAWJgENY6uAh3RiRUQzafcXbX8HAhVwia1wumnQPGZHZCyNUNs2m G4LrW+h4GQyrmC38NdYKwtrgzw== X-Google-Smtp-Source: APXvYqxwZ6NxHy5lxmuWtOfJ8fr/iWLuyRSEw7VcXF5Wp1+axm988/wxsbwGi9rjW87fA0wtR/au+w== X-Received: by 2002:a1c:7d16:: with SMTP id y22mr3453604wmc.106.1574259678325; Wed, 20 Nov 2019 06:21:18 -0800 (PST) Received: from khouloud-ThinkPad-T470p.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id a6sm34544352wrh.69.2019.11.20.06.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:21:17 -0800 (PST) From: Khouloud Touil To: bgolaszewski@baylibre.com, robh+dt@kernel.org, mark.rutland@arm.com, srinivas.kandagatla@linaro.org, baylibre-upstreaming@groups.io Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, linus.walleij@linaro.org, Khouloud Touil Subject: [PATCH 4/4] eeprom: at24: remove the write-protect pin support Date: Wed, 20 Nov 2019 15:20:38 +0100 Message-Id: <20191120142038.30746-5-ktouil@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120142038.30746-1-ktouil@baylibre.com> References: <20191120142038.30746-1-ktouil@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org NVMEM framework is an interface for the at24 EEPROMs as well as for other drivers, instead of passing the wp-gpios over the different drivers each time, it would be better to pass it over the NVMEM subsystem once and for all. Removing the support for the write-protect pin after adding it to the NVMEM subsystem. Signed-off-by: Khouloud Touil --- drivers/misc/eeprom/at24.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 2cccd82a3106..eec2a34b7051 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -22,7 +22,6 @@ #include #include #include -#include /* Address pointer is 16 bit. */ #define AT24_FLAG_ADDR16 BIT(7) @@ -89,8 +88,6 @@ struct at24_data { struct nvmem_device *nvmem; - struct gpio_desc *wp_gpio; - /* * Some chips tie up multiple I2C addresses; dummy devices reserve * them for us, and we'll use them with SMBus calls. @@ -457,12 +454,10 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) * from this host, but not from other I2C masters. */ mutex_lock(&at24->lock); - gpiod_set_value_cansleep(at24->wp_gpio, 0); while (count) { ret = at24_regmap_write(at24, buf, off, count); if (ret < 0) { - gpiod_set_value_cansleep(at24->wp_gpio, 1); mutex_unlock(&at24->lock); pm_runtime_put(dev); return ret; @@ -472,7 +467,6 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) count -= ret; } - gpiod_set_value_cansleep(at24->wp_gpio, 1); mutex_unlock(&at24->lock); pm_runtime_put(dev); @@ -662,9 +656,6 @@ static int at24_probe(struct i2c_client *client) at24->client[0].client = client; at24->client[0].regmap = regmap; - at24->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); - if (IS_ERR(at24->wp_gpio)) - return PTR_ERR(at24->wp_gpio); writable = !(flags & AT24_FLAG_READONLY); if (writable) {