Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp243577pxf; Wed, 10 Mar 2021 05:31:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUGNKSGwhU7B/Fxa4c6bj17G1d/xdgwXUI0hZuu1Ws96JafAdj3SdltgiT6EK+WWzaX8eY X-Received: by 2002:a50:ec07:: with SMTP id g7mr3293079edr.72.1615383069925; Wed, 10 Mar 2021 05:31:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383069; cv=none; d=google.com; s=arc-20160816; b=x8lR9ijNmooPP3q6M+BKJyaNq7qptEAB2AiAhoG4Ha+G6k6GqTuSdt4MKhTxWrbb2T UMvM4g86pj0At9TEh3rcpCQvGuF5APD0aXXHvvZPRq28xpejR+KsDugk1W++YjgBkalW xHJcQMlYwNKVdCHIWBz+Z2ZPjV0snZALRJOlat1jiOuagjtKC5f/4W1PoKu3rnTIRKuI ONwndTAAqKh7VmhsWR69vkrjKXrgXvUn88Ytm2m3IspCyw7q+VBD4Ti0Pky+4xkcGf1A ds7OJRcN7BpqQoE6hK4TvhJ62Hg525Svmo8b10G8GEQddlBZ7bXlCdO/7DZPV0RyK2Af QXgA== 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=84bThCZB39Zfnlb2LX2IUH5LBbeA+1qXMnqMsbyisCs=; b=r4bthq7AnR3Df3kDanMDMKXGE/eerqdPufr/ue3hbmFhMrUPvHuM3ab3+cg3YOezCp qFJ2eRONb7MHqDCmfVL4p8oR3pmJDlMJS3qGTJxhujw8arLBV45a4A3q7DB5gYsH8/0+ dLmtUT6nm9QjvkJ8HeHk7Cj34XJMcK8+cFmfv3PZkOBS7AoGb7m1yMk0dk0j0IaE7SZH CA5v3MmHEjhhuC0rHSJ+7kNWo4MJWs+JAxlEEe64hKrCeuylpJqbTzQbdp0XC8ojlAVg kQaI2jzK/t4P1YfSo9PhHitKwHnOgg/zdAivXXtY0va1QlD8+fNR7XlLZ7/oWLOGIkhY YMgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kyvZj6SN; 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 q12si6953358ejn.616.2021.03.10.05.30.46; Wed, 10 Mar 2021 05:31:09 -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=kyvZj6SN; 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 S232752AbhCJN15 (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:46682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233226AbhCJNZH (ORCPT ); Wed, 10 Mar 2021 08:25:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F59C64FF6; Wed, 10 Mar 2021 13:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382707; bh=0ZhR5sqCxzINWr7OlVluAT0KqxeEpRShcU9go6bln0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyvZj6SNUmQ6VUoHCFWayeyp0Jz6RIGXzcMiwVVOkUwx+L2f0s9Hp3mWLh8d/xiip eskqFQMdVmHtD82ruYgRy0VxvgYrKZyGYpK1hoBJd6xJQcp2Fgl6yBw9GhsD5l+iT/ YYpgyx7eizYOAweQnTiORw59wKbXdPpTVVCWGHZY= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aswath Govindraju , Sasha Levin Subject: [PATCH 5.10 34/49] misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom Date: Wed, 10 Mar 2021 14:23:45 +0100 Message-Id: <20210310132323.018011383@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132321.948258062@linuxfoundation.org> References: <20210310132321.948258062@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 d92c4d2c521a..6e5f544c9c73 100644 --- a/drivers/misc/eeprom/eeprom_93xx46.c +++ b/drivers/misc/eeprom/eeprom_93xx46.c @@ -35,6 +35,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; @@ -55,6 +59,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) { @@ -96,6 +105,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; @@ -363,6 +377,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