From nobody Thu Apr 10 22:45:57 2025 Received: from mail.cab.de (mail.cab.de [46.232.229.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFEC11F930 for ; Tue, 1 Apr 2025 13:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.232.229.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743514404; cv=none; b=t0rOsiXH/kwr9HmVqNxp7RMXCN+j4hKL96n21VdLDTiXbv8BuBKiaJbJthyHBEXhm2f9AJnUHvoY6RE+lNX2EZeGn6MF5K2kJSTLQAXSlQ4CwW2FOveVvl+UG1+kQjKySpOC/d6Yx24UP3w/2wxMM1d3I74rS2khHhahwtmnR5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743514404; c=relaxed/simple; bh=jMMC+wm6vXcF1DkhT8g6MXmLjOdtu1T9dhA3en6FymE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cjvkjaJajAUaPq9EoKfUZ1ZyawQMOYkOKCz/liEDK/atWoeIaFNIXQ7p+yf5BLxSHiU1r9r55VcF66vxlpXIU7VTOMVkEugXqBqNFM/21is3TGgWAk3BszyA1yTEIccmJZR2f03SNZVQImE23ewZ16gj6d8sQvEoEutj4fR9n3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cab.de; spf=pass smtp.mailfrom=cab.de; dkim=pass (1024-bit key) header.d=cab.de header.i=@cab.de header.b=TjkIegWK; arc=none smtp.client-ip=46.232.229.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cab.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cab.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cab.de header.i=@cab.de header.b="TjkIegWK" DKIM-Filter: OpenDKIM Filter v2.11.0 mail.cab.de 4ZRpq40P9dzMvZsd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cab.de; s=default; t=1743514400; bh=wnt780oLccvGGA06d4dBzhYIn/GiO4i1xcNjf5ih2p4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=TjkIegWKGkeuJpE+oToDmA5LAC1QbnP1tkqqXcR0wp5/hBAIYJEzRV5S79KI/6sK6 3QaDSvXZMS1Lniv7MlqiqHLu0PRCM+rEd7ETKuLaMlr8iAXeVy3ukbUKlC27uKAO/9 tMY87qOEa1Jc25HE6NiwkFEIlvraKcY+NbHcvwzE= X-cab-MailScanner-Watermark: 1744119195.55986@ypLX5Y4JCgHJBEtHSayM+Q X-cab-MailScanner-From: m.heidelberg@cab.de X-cab-MailScanner: Found to be clean X-cab-MailScanner-ID: 4ZRppv53YRzMvb0J X-cab-MailScanner-Information: Please contact it@cab.de for more information Received: from Adranos.cab.de ([10.10.1.54] [10.10.1.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (no client certificate requested) by hephaistos.cab.de (MailScanner Milter) with SMTP id 4ZRppv53YRzMvb0J; Tue, 1 Apr 2025 15:33:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.cab.de 4ZRppv53YRzMvb0J Received: from KAN23-025.cab.de (10.10.3.178) by Adranos.cab.de (10.10.1.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 1 Apr 2025 15:33:20 +0200 From: Markus Heidelberg To: Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Eggers CC: Markus Heidelberg , Jiri Prchal , , Subject: [RFC PATCH 1/2] eeprom: at25: support Cypress FRAMs without device ID Date: Tue, 1 Apr 2025 15:30:47 +0200 Message-ID: <20250401133148.38330-2-m.heidelberg@cab.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250401133148.38330-1-m.heidelberg@cab.de> References: <20250401133148.38330-1-m.heidelberg@cab.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: Adranos.cab.de (10.10.1.54) To Adranos.cab.de (10.10.1.54) Content-Type: text/plain; charset="utf-8" Not all FRAM chips have a device ID and implement the corresponding read command. For such chips this led to the following error on module loading: at25 spi2.0: Error: no Cypress FRAM (id 00) The device ID contains the memory size, so devices without this ID are supported now by setting the size manually in Devicetree using the "size" property. Tested with FM25L16B. According to Infineon/Cypress datasheets, these FRAMs have a device ID: FM25V01A FM25V02A FM25V05 FM25V10 FM25V20A FM25VN10 but these do not: FM25040B FM25640B FM25C160B FM25CL64B FM25L04B FM25L16B FM25W256 So all "FM25V*" FRAMs and only these have a device ID. The letter after "FM25" (V/C/L/W) only describes the voltage range, though. Signed-off-by: Markus Heidelberg --- drivers/misc/eeprom/at25.c | 42 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index 595ceb9a7126..16ce36c02ed4 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c @@ -382,35 +382,41 @@ static int at25_fram_to_chip(struct device *dev, stru= ct spi_eeprom *chip) struct at25_data *at25 =3D container_of(chip, struct at25_data, chip); u8 sernum[FM25_SN_LEN]; u8 id[FM25_ID_LEN]; + u32 val; int i; =20 strscpy(chip->name, "fm25", sizeof(chip->name)); =20 - /* Get ID of chip */ - fm25_aux_read(at25, id, FM25_RDID, FM25_ID_LEN); - if (id[6] !=3D 0xc2) { - dev_err(dev, "Error: no Cypress FRAM (id %02x)\n", id[6]); - return -ENODEV; - } - /* Set size found in ID */ - if (id[7] < 0x21 || id[7] > 0x26) { - dev_err(dev, "Error: unsupported size (id %02x)\n", id[7]); - return -ENODEV; + if (!device_property_read_u32(dev, "size", &val)) { + chip->byte_len =3D val; + } else { + /* Get ID of chip */ + fm25_aux_read(at25, id, FM25_RDID, FM25_ID_LEN); + if (id[6] !=3D 0xc2) { + dev_err(dev, "Error: no Cypress FRAM (id %02x)\n", id[6]); + return -ENODEV; + } + /* Set size found in ID */ + if (id[7] < 0x21 || id[7] > 0x26) { + dev_err(dev, "Error: unsupported size (id %02x)\n", id[7]); + return -ENODEV; + } + + chip->byte_len =3D BIT(id[7] - 0x21 + 4) * 1024; + + if (id[8]) { + fm25_aux_read(at25, sernum, FM25_RDSN, FM25_SN_LEN); + /* Swap byte order */ + for (i =3D 0; i < FM25_SN_LEN; i++) + at25->sernum[i] =3D sernum[FM25_SN_LEN - 1 - i]; + } } =20 - chip->byte_len =3D BIT(id[7] - 0x21 + 4) * 1024; if (chip->byte_len > 64 * 1024) chip->flags |=3D EE_ADDR3; else chip->flags |=3D EE_ADDR2; =20 - if (id[8]) { - fm25_aux_read(at25, sernum, FM25_RDSN, FM25_SN_LEN); - /* Swap byte order */ - for (i =3D 0; i < FM25_SN_LEN; i++) - at25->sernum[i] =3D sernum[FM25_SN_LEN - 1 - i]; - } - chip->page_size =3D PAGE_SIZE; return 0; } --=20 2.43.0 From nobody Thu Apr 10 22:45:57 2025 Received: from mail.cab.de (mail.cab.de [46.232.229.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FEDF1E47A9 for ; Tue, 1 Apr 2025 13:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.232.229.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743514976; cv=none; b=BLFa03ga7kaQiz6iZ+UmxWQsZSu14+loJkVSx0SqOTDTI8/NEu3GrP6yHcdz5foM7slHtIr5s3W3aY8XreoyNVy22qAcNGSewGSekHpUwLB22swYrSYKAiuaY/QFq+MdNqrlT9EnFipBEZdSCziP6636voC9cGfY3XDGZxe9jVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743514976; c=relaxed/simple; bh=utegZaxSQAewZydbCJUFE+vwbwIiJtX3JdvPqpjVQX8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ij5EWRP4SmAHL7HmHSkniXAjpHp6FXnqJ65ebC55ftuO1N3BoNhOdlSesLUM8g/gEFyYuE9vTruqNZvVhUbuOwkfJmeTP7nzTydcEx8ta+uN3lJZ7t6eTPcc2/dKcEVSZTeNfVNayOZnrZsd5w0gmxEVbTDRDUkXYmtP0qBzEzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cab.de; spf=pass smtp.mailfrom=cab.de; dkim=pass (1024-bit key) header.d=cab.de header.i=@cab.de header.b=brDoKA/T; arc=none smtp.client-ip=46.232.229.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cab.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cab.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cab.de header.i=@cab.de header.b="brDoKA/T" DKIM-Filter: OpenDKIM Filter v2.11.0 mail.cab.de 4ZRpq24YglzMvb08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cab.de; s=default; t=1743514398; bh=Zs6taA3QHKiFoxaMKD5p7Rb7UrpExF4LJRsAQKvWTzE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=brDoKA/TJYOiFwv4slaWFzeozgA+W4S4zXpnG3BTJMI18/OKMm3Bo1TwMdvJ+rDTD PAsF/MeQUoc3w/KW9iYJiylQhlm441uDez0hVaCMudS887tGeXM+CsQnA0+hrE6JQE Mma1ePVr4ZGuQ6XWWsfakfwKFTaav/E3wT87UAqw= X-cab-MailScanner-Watermark: 1744119197.45667@uUHBCFXwNkoKiXdvlmKeGg X-cab-MailScanner-From: m.heidelberg@cab.de X-cab-MailScanner: Found to be clean X-cab-MailScanner-ID: 4ZRpq0121rzMvb08 X-cab-MailScanner-Information: Please contact it@cab.de for more information Received: from Adranos.cab.de ([10.10.1.54] [10.10.1.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (no client certificate requested) by hephaistos.cab.de (MailScanner Milter) with SMTP id 4ZRpq0121rzMvb08; Tue, 1 Apr 2025 15:33:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.cab.de 4ZRpq0121rzMvb08 Received: from KAN23-025.cab.de (10.10.3.178) by Adranos.cab.de (10.10.1.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 1 Apr 2025 15:33:24 +0200 From: Markus Heidelberg To: Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Eggers CC: Markus Heidelberg , Jiri Prchal , , Subject: [RFC PATCH 2/2] eeprom: at25: make FRAM device ID error message more precise Date: Tue, 1 Apr 2025 15:30:48 +0200 Message-ID: <20250401133148.38330-3-m.heidelberg@cab.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250401133148.38330-1-m.heidelberg@cab.de> References: <20250401133148.38330-1-m.heidelberg@cab.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: Adranos.cab.de (10.10.1.54) To Adranos.cab.de (10.10.1.54) Content-Type: text/plain; charset="utf-8" The error description would be wrong in case the "size" Devicetree property is missing for an FRAM without device ID. Signed-off-by: Markus Heidelberg --- drivers/misc/eeprom/at25.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index 16ce36c02ed4..c45413e06e9c 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c @@ -393,7 +393,7 @@ static int at25_fram_to_chip(struct device *dev, struct= spi_eeprom *chip) /* Get ID of chip */ fm25_aux_read(at25, id, FM25_RDID, FM25_ID_LEN); if (id[6] !=3D 0xc2) { - dev_err(dev, "Error: no Cypress FRAM (id %02x)\n", id[6]); + dev_err(dev, "Error: no Cypress FRAM with device ID (manufacturer ID ba= nk 7: %02x)\n", id[6]); return -ENODEV; } /* Set size found in ID */ --=20 2.43.0