From nobody Fri Nov 7 10:27:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548086509760271.18683228536645; Mon, 21 Jan 2019 08:01:49 -0800 (PST) Received: from localhost ([127.0.0.1]:55631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glc13-0005iG-Gj for importer@patchew.org; Mon, 21 Jan 2019 11:01:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glbzn-00056X-CP for qemu-devel@nongnu.org; Mon, 21 Jan 2019 11:00:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glbzl-0007CD-7I for qemu-devel@nongnu.org; Mon, 21 Jan 2019 11:00:19 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1glbzk-0007Af-Rc for qemu-devel@nongnu.org; Mon, 21 Jan 2019 11:00:17 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0LFwrdl099657 for ; Mon, 21 Jan 2019 11:00:14 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q5fpqvbx7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 Jan 2019 11:00:14 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Jan 2019 16:00:11 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 21 Jan 2019 16:00:08 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0LG07KB44892230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 Jan 2019 16:00:07 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C806D11C06C; Mon, 21 Jan 2019 16:00:06 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B617C11C050; Mon, 21 Jan 2019 16:00:06 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 21 Jan 2019 16:00:06 +0000 (GMT) Received: from zorba.kaod.org.com (sig-9-145-190-81.de.ibm.com [9.145.190.81]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 1156A22019C; Mon, 21 Jan 2019 17:00:06 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Date: Mon, 21 Jan 2019 17:00:02 +0100 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19012116-4275-0000-0000-000003021FBE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19012116-4276-0000-0000-000038104DE8 Message-Id: <20190121160002.731-1-clg@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-21_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901210126 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id x0LFwrdl099657 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] m25p80: add basic support for the SFPD command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Peter Crosthwaite , Alistair Francis , Max Reitz , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP) provides a mean to describe the features of a serial flash device using a set of internal parameter tables. This is the initial framework for the RDSFPD command which is given access to a private SFPD area under the flash. This area now needs to be populated with the flash device characteristics, presumingly with the values from the FlashPartInfo array. Signed-off-by: C=C3=A9dric Le Goater --- hw/block/m25p80.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index e8dfa14b332f..581a9e1fb82e 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -340,6 +340,7 @@ typedef enum { BULK_ERASE =3D 0xc7, READ_FSR =3D 0x70, RDCR =3D 0x15, + RDSFPD =3D 0x5a, =20 READ =3D 0x03, READ4 =3D 0x13, @@ -405,6 +406,7 @@ typedef enum { STATE_COLLECTING_DATA, STATE_COLLECTING_VAR_LEN_DATA, STATE_READING_DATA, + STATE_READING_SFPD, } CMDState; =20 typedef enum { @@ -456,6 +458,8 @@ typedef struct Flash { =20 int64_t dirty_page; =20 +#define M25P80_SFPD_AREA_SIZE 0x100 + uint8_t sfpd_area[M25P80_SFPD_AREA_SIZE]; const FlashPartInfo *pi; =20 } Flash; @@ -626,6 +630,8 @@ static inline int get_addr_length(Flash *s) } =20 switch (s->cmd_in_progress) { + case RDSFPD: + return 3; case PP4: case PP4_4: case QPP_4: @@ -748,11 +754,55 @@ static void complete_collecting_data(Flash *s) " by device\n"); } break; + + case RDSFPD: + if (s->cur_addr < M25P80_SFPD_AREA_SIZE) { + s->state =3D STATE_READING_SFPD; + } else { + qemu_log_mask(LOG_GUEST_ERROR, + "M25P80: Invalid SFPD address %#" PRIx32 "\n", + s->cur_addr); + } + break; + default: break; } } =20 +static void reset_memory_sfpd(Flash *s) +{ + s->sfpd_area[0x00] =3D 'S'; + s->sfpd_area[0x01] =3D 'F'; + s->sfpd_area[0x02] =3D 'P'; + s->sfpd_area[0x03] =3D 'D'; + + s->sfpd_area[0x04] =3D 0x00; /* SFDP Minor Revision Number */ + s->sfpd_area[0x05] =3D 0x01; /* SFDP Major Revision Number */ + s->sfpd_area[0x06] =3D 0x01; /* Number of Parameter Headers */ + s->sfpd_area[0x07] =3D 0xFF; /* Unused */ + + s->sfpd_area[0x08] =3D 0x00; /* ID Number. 0x0 : JEDEC */ + s->sfpd_area[0x09] =3D 0x00; /* Parameter Table Minor Revision */ + s->sfpd_area[0x0A] =3D 0x01; /* Parameter Table Major Revision */ + s->sfpd_area[0x0B] =3D 0x09; /* Parameter Table Length (DWORD) */ + s->sfpd_area[0x0C] =3D 0x30; /* Parameter Table Pointer */ + s->sfpd_area[0x0D] =3D 0x00; /* Parameter Table Pointer */ + s->sfpd_area[0x0E] =3D 0x00; /* Parameter Table Pointer */ + s->sfpd_area[0x0F] =3D 0xFF; /* Unused */ + + s->sfpd_area[0x10] =3D s->pi->id[0]; /* ID Number. Manufacturer */ + s->sfpd_area[0x11] =3D 0x00; /* Parameter Table Minor Revision */ + s->sfpd_area[0x12] =3D 0x01; /* Parameter Table Major Revision */ + s->sfpd_area[0x13] =3D 0x04; /* Parameter Table Length (DWORD) */ + s->sfpd_area[0x14] =3D 0x60; /* Parameter Table Pointer */ + s->sfpd_area[0x15] =3D 0x00; /* Parameter Table Pointer */ + s->sfpd_area[0x16] =3D 0x00; /* Parameter Table Pointer */ + s->sfpd_area[0x17] =3D 0xFF; /* Unused */ + + /* TODO: populate accordingly to chip model */ +} + static void reset_memory(Flash *s) { s->cmd_in_progress =3D NOP; @@ -822,6 +872,8 @@ static void reset_memory(Flash *s) break; } =20 + reset_memory_sfpd(s); + DB_PRINT_L(0, "Reset done.\n"); } =20 @@ -1049,6 +1101,13 @@ static void decode_new_cmd(Flash *s, uint32_t value) s->state =3D STATE_READING_DATA; break; =20 + case RDSFPD: + s->needed_bytes =3D get_addr_length(s) + 1 ; /* SFPD addr + dummy = */ + s->pos =3D 0; + s->len =3D 0; + s->state =3D STATE_COLLECTING_DATA; + break; + case RDCR: s->data[0] =3D s->volatile_cfg & 0xFF; s->data[0] |=3D (!!s->four_bytes_address_mode) << 5; @@ -1241,6 +1300,8 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32= _t tx) } =20 r =3D s->data[s->pos]; + DB_PRINT_L(1, "READ DATA 0x%" PRIx32 "=3D%" PRIx8 "\n", s->pos, + (uint8_t)r); s->pos++; if (s->pos =3D=3D s->len) { s->pos =3D 0; @@ -1249,6 +1310,12 @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint3= 2_t tx) } } break; + case STATE_READING_SFPD: + r =3D s->sfpd_area[s->cur_addr]; + DB_PRINT_L(1, "READ SFPD 0x%" PRIx32 "=3D%" PRIx8 "\n", s->cur_add= r, + (uint8_t)r); + s->cur_addr =3D (s->cur_addr + 1) & (M25P80_SFPD_AREA_SIZE - 1); + break; =20 default: case STATE_IDLE: --=20 2.20.1