Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp246016pxf; Wed, 10 Mar 2021 05:34:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJYkZTn5kYwo/NzEo2m8V08GzEyRnJyfLuzfX9DGLtv5Apg3b8Ue9xhQ4Nt+oTtQaTzMMi X-Received: by 2002:a50:8a90:: with SMTP id j16mr3249146edj.334.1615383274432; Wed, 10 Mar 2021 05:34:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383274; cv=none; d=google.com; s=arc-20160816; b=M5K1G0KWaYaiTxmoKxpqDhcKf+0qvnAlJr8xuMAK4WoVYw3zs1EChjvq5OiI1W4CDS +DBbIvWubflAq7wolj1XQ4wnQgp6K6Om/Wa5hrVnAuZ3+y3R12MhbU0E+ZvlP7Pv1Aak /+96yqhS00Zi6Tlj2fWN7O9zBcjhVosqslan8hIGJCQ38JZWz9xU1ow6hARLnxvVK3hr zVQtVLonCopl/jtwLQirqxX9TzbB9R115Cr0Guu0XxhPdgDi19+cdYOjDAN0Itv1JZhd zuCGO9OsM1PduWsOhS9PhuBzw1HAY+6JkIUkI7PDii1oqxVx7abU1Lx8I3Ggr3L8X7ML H3Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o1ME6hb6osrnx5aK5yFegF0SrdvOIzSnljjbSEI6ycI=; b=T4eI1nX78KHT6tpL5LWj/wTygrw2rF1zpTAST2qDjNwYMiYO3u1FyiEoo0GTtzvKLW T4jD0mjgdxfDFHF/lhxpa7Btx40dXB0T5z5uoYEU8D4YcbSQ5a8iTs4+6g5z42zSo8Fx eFsKWs29qhOak/yJc7TJMlAu0yMI/Ovm2T6kUtGFfPGYpAV530MsNe3JqAwSLr3YCSvj yY+owDmxuLAUiTfXGDSl3Pi3FE5BlDucqmy+4fl3ZrQ92rKLzxKiuUU6g9+vi3FIYZBQ 2t/wRTq9ilbRnyBHX2vELuKQi+qMq1ovmUWs+1MWJCvGQlgFc20pw4N2gDHwIripeaqO 79NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rSKdU/ci"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si12567111eds.593.2021.03.10.05.34.11; Wed, 10 Mar 2021 05:34:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rSKdU/ci"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233621AbhCJNb1 (ORCPT + 99 others); Wed, 10 Mar 2021 08:31:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:49696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232727AbhCJNZ5 (ORCPT ); Wed, 10 Mar 2021 08:25:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A9BE65002; Wed, 10 Mar 2021 13:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382757; bh=N22cbig8t+Kn3IYf1hcYc864LB/Gb8FXtHKig0zmB3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSKdU/ciQUN8BsFIBeCl3pE1smfHTc4ZBuNGZ8IJ1Cs4ZG+QNC8am9IsOTiaQUqCc JKFuvTbJm7x0gDMjRapE7146Kzp1WDKUzXFIYRi8JOt0WLzEObo+eTWEOnSyt2/iRS UBml0QH9ys1iblPZ9YrXFS7xuBh09DPEMJLRaM5Q= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aswath Govindraju , Sasha Levin Subject: [PATCH 4.19 37/39] misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom Date: Wed, 10 Mar 2021 14:24:45 +0100 Message-Id: <20210310132320.867232378@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Aswath Govindraju [ Upstream commit f6f1f8e6e3eea25f539105d48166e91f0ab46dd1 ] A dummy zero bit is sent preceding the data during a read transfer by the Microchip 93LC46B eeprom (section 2.7 of[1]). This results in right shift of data during a read. In order to ignore this bit a quirk can be added to send an extra zero bit after the read address. Add a quirk to ignore the zero bit sent before data by adding a zero bit after the read address. [1] - https://www.mouser.com/datasheet/2/268/20001749K-277859.pdf Signed-off-by: Aswath Govindraju Link: https://lore.kernel.org/r/20210105105817.17644-3-a-govindraju@ti.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/eeprom/eeprom_93xx46.c | 15 +++++++++++++++ include/linux/eeprom_93xx46.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c index a3248ebd28c6..182feab6da25 100644 --- a/drivers/misc/eeprom/eeprom_93xx46.c +++ b/drivers/misc/eeprom/eeprom_93xx46.c @@ -38,6 +38,10 @@ static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = { EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH, }; +static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = { + .quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE, +}; + struct eeprom_93xx46_dev { struct spi_device *spi; struct eeprom_93xx46_platform_data *pdata; @@ -58,6 +62,11 @@ static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev) return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH; } +static inline bool has_quirk_extra_read_cycle(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->quirks & EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE; +} + static int eeprom_93xx46_read(void *priv, unsigned int off, void *val, size_t count) { @@ -99,6 +108,11 @@ static int eeprom_93xx46_read(void *priv, unsigned int off, dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n", cmd_addr, edev->spi->max_speed_hz); + if (has_quirk_extra_read_cycle(edev)) { + cmd_addr <<= 1; + bits += 1; + } + spi_message_init(&m); t[0].tx_buf = (char *)&cmd_addr; @@ -366,6 +380,7 @@ static void select_deassert(void *context) static const struct of_device_id eeprom_93xx46_of_table[] = { { .compatible = "eeprom-93xx46", }, { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, }, + { .compatible = "microchip,93lc46b", .data = µchip_93lc46b_data, }, {} }; MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table); diff --git a/include/linux/eeprom_93xx46.h b/include/linux/eeprom_93xx46.h index eec7928ff8fe..99580c22f91a 100644 --- a/include/linux/eeprom_93xx46.h +++ b/include/linux/eeprom_93xx46.h @@ -16,6 +16,8 @@ struct eeprom_93xx46_platform_data { #define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0) /* Instructions such as EWEN are (addrlen + 2) in length. */ #define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1) +/* Add extra cycle after address during a read */ +#define EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE BIT(2) /* * optional hooks to control additional logic -- 2.30.1