From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDBdg-0000N8-TL for qemu-devel@nongnu.org; Wed, 15 Jun 2016 10:17:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDBdc-0002oX-Mb for qemu-devel@nongnu.org; Wed, 15 Jun 2016 10:17:52 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDBdc-0002oI-E8 for qemu-devel@nongnu.org; Wed, 15 Jun 2016 10:17:48 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5FEETAm112174 for ; Wed, 15 Jun 2016 10:17:47 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 23jfmq0ext-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 15 Jun 2016 10:17:47 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 15 Jun 2016 15:17:44 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3C0352190046 for ; Wed, 15 Jun 2016 15:17:13 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5FEHf9W8519938 for ; Wed, 15 Jun 2016 14:17:41 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5FEHdtU018703 for ; Wed, 15 Jun 2016 08:17:41 -0600 References: <1465998071-7355-1-git-send-email-marcin.krzeminski@nokia.com> <1465998071-7355-3-git-send-email-marcin.krzeminski@nokia.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Date: Wed, 15 Jun 2016 16:17:37 +0200 MIME-Version: 1.0 In-Reply-To: <1465998071-7355-3-git-send-email-marcin.krzeminski@nokia.com> Content-Type: text/plain; charset=windows-1252 Message-Id: <57616381.6050903@fr.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/9] m25p80: Make a table for JEDEC ID. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcin.krzeminski@nokia.com, qemu-devel@nongnu.org Cc: crosthwaitepeter@gmail.com, pawel.lenkow@itlen.com, peter.maydell@linaro.org On 06/15/2016 03:41 PM, marcin.krzeminski@nokia.com wrote: > From: Marcin Krzeminski >=20 > Since it is now longer than 4. This work based on Pawel Lenkow > changes and the kernel SPI framework. > > Signed-off-by: Marcin Krzeminski Reviewed-by: C=E9dric Le Goater > --- > hw/block/m25p80.c | 61 ++++++++++++++++++++++++++++++++++++++---------= -------- > 1 file changed, 42 insertions(+), 19 deletions(-) >=20 > diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c > index 15765f5..342f7c9 100644 > --- a/hw/block/m25p80.c > +++ b/hw/block/m25p80.c > @@ -53,12 +53,17 @@ > /* 16 MiB max in 3 byte address mode */ > #define MAX_3BYTES_SIZE 0x1000000 >=20 > +#define SPI_NOR_MAX_ID_LEN 6 > + > typedef struct FlashPartInfo { > const char *part_name; > - /* jedec code. (jedec >> 16) & 0xff is the 1st byte, >> 8 the 2nd = etc */ > - uint32_t jedec; > - /* extended jedec code */ > - uint16_t ext_jedec; > + /* > + * This array stores the ID bytes. > + * The first three bytes are the JEDIC ID. > + * JEDEC ID zero means "no ID" (mostly older chips). > + */ > + uint8_t id[SPI_NOR_MAX_ID_LEN]; > + uint8_t id_len; > /* there is confusion between manufacturers as to what a sector is= . In this > * device model, a "sector" is the size that is erased by the ERAS= E_SECTOR > * command (opcode 0xd8). > @@ -70,11 +75,33 @@ typedef struct FlashPartInfo { > } FlashPartInfo; >=20 > /* adapted from linux */ > - > -#define INFO(_part_name, _jedec, _ext_jedec, _sector_size, _n_sectors,= _flags)\ > - .part_name =3D (_part_name),\ > - .jedec =3D (_jedec),\ > - .ext_jedec =3D (_ext_jedec),\ > +/* Used when the "_ext_id" is two bytes at most */ > +#define INFO(_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors,= _flags)\ > + .part_name =3D _part_name,\ > + .id =3D {\ > + ((_jedec_id) >> 16) & 0xff,\ > + ((_jedec_id) >> 8) & 0xff,\ > + (_jedec_id) & 0xff,\ > + ((_ext_id) >> 8) & 0xff,\ > + (_ext_id) & 0xff,\ > + },\ > + .id_len =3D (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),\ > + .sector_size =3D (_sector_size),\ > + .n_sectors =3D (_n_sectors),\ > + .page_size =3D 256,\ > + .flags =3D (_flags), > + > +#define INFO6(_part_name, _jedec_id, _ext_id, _sector_size, _n_sectors= , _flags)\ > + .part_name =3D _part_name,\ > + .id =3D {\ > + ((_jedec_id) >> 16) & 0xff,\ > + ((_jedec_id) >> 8) & 0xff,\ > + (_jedec_id) & 0xff,\ > + ((_ext_id) >> 16) & 0xff,\ > + ((_ext_id) >> 8) & 0xff,\ > + (_ext_id) & 0xff,\ > + },\ > + .id_len =3D 6,\ > .sector_size =3D (_sector_size),\ > .n_sectors =3D (_n_sectors),\ > .page_size =3D 256,\ > @@ -360,7 +387,7 @@ typedef struct M25P80Class { >=20 > static inline Manufacturer get_man(Flash *s) > { > - switch (((s->pi->jedec >> 16) & 0xFF)) { > + switch (s->pi->id[0]) { > case 0x20: > return MAN_NUMONYX; > case 0xEF: > @@ -630,6 +657,7 @@ static void reset_memory(Flash *s) > static void decode_new_cmd(Flash *s, uint32_t value) > { > s->cmd_in_progress =3D value; > + int i; > DB_PRINT_L(0, "decoded new command:%x\n", value); >=20 > if (value !=3D RESET_MEMORY) { > @@ -743,16 +771,11 @@ static void decode_new_cmd(Flash *s, uint32_t val= ue) >=20 > case JEDEC_READ: > DB_PRINT_L(0, "populated jedec code\n"); > - s->data[0] =3D (s->pi->jedec >> 16) & 0xff; > - s->data[1] =3D (s->pi->jedec >> 8) & 0xff; > - s->data[2] =3D s->pi->jedec & 0xff; > - if (s->pi->ext_jedec) { > - s->data[3] =3D (s->pi->ext_jedec >> 8) & 0xff; > - s->data[4] =3D s->pi->ext_jedec & 0xff; > - s->len =3D 5; > - } else { > - s->len =3D 3; > + for (i =3D 0; i < s->pi->id_len; i++) { > + s->data[i] =3D s->pi->id[i]; > } > + > + s->len =3D s->pi->id_len; > s->pos =3D 0; > s->state =3D STATE_READING_DATA; > break; >=20