From nobody Sat May 10 01:50:54 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1607536734; cv=none; d=zohomail.com; s=zohoarc; b=ZM5FIgeG5nEBwpxrG7/91OosCLgPmvmofNUnrfCJ4SoVY1vzs48EFUPF9eoOulCQE2mwuQMTLBEKQRcZiLo5crN9mXsl/yo9bjnx4b0K4PSFRZFJ4lyF4RxcVfn8AsvW1JQc5YH6fQ3yQL9sy1WojxPX3n4yBzfsVwjjSJHDC2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607536734; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=n2EdWdd2h0GvAOC4E08Jb6Cv4a45zDdLDR18BXOJQv4=; b=Q4A7sjm4bSXq1xZV7CVpgO1NO9mm8i0KArj5M1Vgn8h+6ft/UfxqllAejjvC9T6TN95aT6DyQHu3W//ru9wwUekWfqllRyeh5GRNljFPCpJTW3ZP7KdymVhNpr9QagYDcIqxztQ/NIck0yG/3I2xXBFQ5x1HEatSMDadGQ1Athw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1607536734571824.9791071422677; Wed, 9 Dec 2020 09:58:54 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbgLIR6S (ORCPT ); Wed, 9 Dec 2020 12:58:18 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:56352 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgLIR6R (ORCPT ); Wed, 9 Dec 2020 12:58:17 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0B9HvK6F043926; Wed, 9 Dec 2020 11:57:20 -0600 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0B9HvKaJ047440 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 9 Dec 2020 11:57:20 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 9 Dec 2020 11:57:19 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 9 Dec 2020 11:57:19 -0600 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0B9HvATG094634; Wed, 9 Dec 2020 11:57:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1607536640; bh=n2EdWdd2h0GvAOC4E08Jb6Cv4a45zDdLDR18BXOJQv4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gmbqirQKH4aCt0ZakLGl5Nqhn5vhNouSmwOiRoBMB+ccR7uyg8vPfq+DR5406MqsN S/vJB767kQD113Fjq5l0f4sOZHDU7lvrEhQ3fWSL29kFXQHeHv4S69VfV/Mcd3D1Eo tFFYQRwA6VIvY7liEzJzOZTgY0mWGxGzNe5Y4MEQ= From: Aswath Govindraju CC: Rob Herring , , , Arnd Bergmann , Greg Kroah-Hartman , Vadym Kochan , Vignesh Raghavendra , Sekhar Nori , Aswath Govindraju Subject: [PATCH RFC 1/2] Documentation: devicetree: Add property for ignoring the dummy bits sent before read transfer Date: Wed, 9 Dec 2020 23:27:07 +0530 Message-ID: <20201209175708.16252-2-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201209175708.16252-1-a-govindraju@ti.com> References: <20201209175708.16252-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dummy zero bits are sent before data during a read transfer. This causes the data read to be shifted to the right. To fix this send zero bits after the address during a read transfer. Add property to send zero bits after the address during a read transfer. Suggested-by: Vignesh Raghavendra Signed-off-by: Aswath Govindraju --- Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Doc= umentation/devicetree/bindings/misc/eeprom-93xx46.txt index a8ebb4621f79..09fb1cec54f0 100644 --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt @@ -10,7 +10,9 @@ Optional properties: - read-only : parameter-less property which disables writes to the EEPROM - select-gpios : if present, specifies the GPIO that will be asserted prio= r to each access to the EEPROM (e.g. for SPI bus multiplexing) - +- read-op-dummy-cycles: If present specifies the number of dummy zero-bits= to + be sent after the address during a read transfer to ignore any bits sent + preceding the data. Property rules described in Documentation/devicetree/bindings/spi/spi-bus.= txt apply. In particular, "reg" and "spi-max-frequency" properties must be gi= ven. =20 --=20 2.17.1 From nobody Sat May 10 01:50:54 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=quarantine dis=quarantine) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1607536737; cv=none; d=zohomail.com; s=zohoarc; b=TmNVv3MeNrTGNqyxq0Y2Q7P8UzNwvFLOU0G9++Y9RDTayWBaSEF3Tj3HMaiWK/dISqZWEXct+AXnaT+IMJhG/vaIoxH7d3e8a3d38aMvhGQo4obpYcaf5KNnveCoaTQYOJjgtKaQuQGHeljUmzeLjfJj7TCsYybzmIwbHK6cJRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607536737; h=Content-Type:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=xSo6kkY/WAzvZWiG0QrjkyrBLPDwYGU9Z/gfY9LWwv8=; b=d85AVaaWIrZ5XtFbWqdqsUn7Qzklt+bgf0VgIB7mJWDz2qxi/XN+R1K9M8OF2JW+DjuOpu4NwvOSNG9tY2DjCMDD1GQOxCtsel9mTOMstN5FLTzfFgfC1TEEOzVwaBgmESa9yj4ng+PwMmywgcA8GcYu2pMuiKLAcKm7L3ESFJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1607536737688643.6622430292487; Wed, 9 Dec 2020 09:58:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730278AbgLIR6g (ORCPT ); Wed, 9 Dec 2020 12:58:36 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:56360 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgLIR6W (ORCPT ); Wed, 9 Dec 2020 12:58:22 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0B9HvPea044251; Wed, 9 Dec 2020 11:57:25 -0600 Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0B9HvPTc088842 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 9 Dec 2020 11:57:25 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 9 Dec 2020 11:57:24 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 9 Dec 2020 11:57:24 -0600 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0B9HvATH094634; Wed, 9 Dec 2020 11:57:21 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1607536645; bh=xSo6kkY/WAzvZWiG0QrjkyrBLPDwYGU9Z/gfY9LWwv8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=s392Hq/6ukwNSrUVi9G49fjRFR+pNSTDUbKofRr6tEUIBBNhHF4cVFRp8rPq0RP7R bdGIot+bNVYMOr1TDWsU3l7XW0LyDknmRbMgG7cb/LAuL7Ukx2O7pwfGZG6xb3CLKB XQc3ROtdG7If/mYD8W3sa5FrCnEiA//hfEylYFqU= From: Aswath Govindraju CC: Rob Herring , , , Arnd Bergmann , Greg Kroah-Hartman , Vadym Kochan , Vignesh Raghavendra , Sekhar Nori , Aswath Govindraju Subject: [PATCH RFC 2/2] eeprom: eeprom_93xx46: Add support for ignoring the dummy bit preceding data during read transfer Date: Wed, 9 Dec 2020 23:27:08 +0530 Message-ID: <20201209175708.16252-3-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201209175708.16252-1-a-govindraju@ti.com> References: <20201209175708.16252-1-a-govindraju@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A dummy zero bit is sent by eeprom preceding the data of every read transfer. This results in right shift of data during a read. In order to ignore the dummy bits preceding the data, extra zero bits are transferred after the read address. This feature can be added by including the property read-op-dummy-cycles with the number of zero bits to be transferred as the value, in device tree node. Fix read by sending extra zero bits after the read address to ignore the zero bits sent by eeprom before data. Suggested-by: Vignesh Raghavendra Signed-off-by: Aswath Govindraju --- drivers/misc/eeprom/eeprom_93xx46.c | 23 +++++++++++++++++++++++ include/linux/eeprom_93xx46.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eepr= om_93xx46.c index 7c45f82b4302..e778ae54a6f1 100644 --- a/drivers/misc/eeprom/eeprom_93xx46.c +++ b/drivers/misc/eeprom/eeprom_93xx46.c @@ -55,6 +55,16 @@ static inline bool has_quirk_instruction_length(struct e= eprom_93xx46_dev *edev) return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH; } =20 +static inline bool needs_extra_read_cycle(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->flags & EE_EXTRA_CYCLE_READ; +} + +static inline u32 get_read_op_dummy_cycles(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->read_op_dummy_cycles; +} + static int eeprom_93xx46_read(void *priv, unsigned int off, void *val, size_t count) { @@ -80,6 +90,7 @@ static int eeprom_93xx46_read(void *priv, unsigned int of= f, u16 cmd_addr =3D OP_READ << edev->addrlen; size_t nbytes =3D count; int bits; + u32 read_op_dummy_cycles; =20 if (edev->addrlen =3D=3D 7) { cmd_addr |=3D off & 0x7f; @@ -93,6 +104,12 @@ static int eeprom_93xx46_read(void *priv, unsigned int = off, nbytes =3D 2; } =20 + if (needs_extra_read_cycle(edev)) { + read_op_dummy_cycles =3D get_read_op_dummy_cycles(edev); + cmd_addr =3D cmd_addr << read_op_dummy_cycles; + bits +=3D read_op_dummy_cycles; + } + dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n", cmd_addr, edev->spi->max_speed_hz); =20 @@ -398,6 +415,12 @@ static int eeprom_93xx46_probe_dt(struct spi_device *s= pi) if (of_property_read_bool(np, "read-only")) pd->flags |=3D EE_READONLY; =20 + ret =3D of_property_read_u32(np, "read-op-dummy-cycles", &tmp); + if (ret =3D=3D 0) { + pd->flags |=3D EE_EXTRA_CYCLE_READ; + pd->read_op_dummy_cycles =3D tmp; + } + pd->select =3D devm_gpiod_get_optional(&spi->dev, "select", GPIOD_OUT_LOW); if (IS_ERR(pd->select)) diff --git a/include/linux/eeprom_93xx46.h b/include/linux/eeprom_93xx46.h index eec7928ff8fe..f0d37e921aba 100644 --- a/include/linux/eeprom_93xx46.h +++ b/include/linux/eeprom_93xx46.h @@ -11,6 +11,12 @@ struct eeprom_93xx46_platform_data { #define EE_ADDR16 0x02 /* 16 bit addr. cfg */ #define EE_READONLY 0x08 /* forbid writing */ =20 +/* Add extra zero bits of data after the address during read transfer + * to ignore the dummy bits sent before data + */ +#define EE_EXTRA_CYCLE_READ 0x04 + u32 read_op_dummy_cycles; + unsigned int quirks; /* Single word read transfers only; no sequential read. */ #define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0) --=20 2.17.1