From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10052.outbound.protection.outlook.com [40.107.1.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 60B2921CEB0FB for ; Thu, 7 Sep 2017 08:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7KMweeTWvuczFRPjH7j7t+0nUNCeBIBvo0S3m/Nc/O4=; b=XKPMBLaH0fstmkHi/3p5XDHl61YmldM74QidOCPm9eFr8LBDJ/BxNxU5x87NxlS7Cu/CKc6heJ550GwaAOjQ0yGn6DuUZP6cL3rolFFvE95Nu2Pz1Wi9pfjNQiU2WnU6AtEvWVPuMwd1vmih879vBGAOAJV+ZnMz2Sz0exbE7PQ= Received: from DB5PR04MB0998.eurprd04.prod.outlook.com (10.161.199.12) by DB5PR04MB1334.eurprd04.prod.outlook.com (10.162.220.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 7 Sep 2017 15:19:16 +0000 Received: from DB5PR04MB0998.eurprd04.prod.outlook.com ([fe80::b598:82e9:1137:1d56]) by DB5PR04MB0998.eurprd04.prod.outlook.com ([fe80::b598:82e9:1137:1d56%17]) with mapi id 15.20.0013.018; Thu, 7 Sep 2017 15:19:16 +0000 From: Meenakshi Aggarwal To: Leif Lindholm CC: "jun.nie@linaro.org" , "haojian.zhuang@linaro.org" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH v3 2/2] SD : Updated CMD 6 implememtation. Thread-Index: AQHTJ7NyJflelWwfY0msNm8547H/5qKpfbIAgAALrxA= Date: Thu, 7 Sep 2017 15:19:16 +0000 Message-ID: References: <1504793873-13078-1-git-send-email-meenakshi.aggarwal@nxp.com> <1504793873-13078-2-git-send-email-meenakshi.aggarwal@nxp.com> <20170907143528.vk5irpt4nyatvl6r@bivouac.eciton.net> In-Reply-To: <20170907143528.vk5irpt4nyatvl6r@bivouac.eciton.net> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=meenakshi.aggarwal@nxp.com; x-originating-ip: [180.188.246.193] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR04MB1334; 6:yxnCwLnN03UMbo8RYFEaFsFbPmtSaOb8quMgQ9M8PlD2CfhePctVh4M1hyNhoAZOM1K4NQXaAjjqm1VsuBrtuXFrMgTMs/PuyMPkxymO8emDtSpijlvKkc27VD3TwEl601mTn7RAmTXJFWj+Xci31o3FPQrXRDmxzhFEFuDzunWFke9rLZpn64pgHPhaPuLwkKbaD3CMSaq2HQz7fqr89mE8r1kzAqyGWUEAVwP4n8w/BgbnDKhSlfe71CrL2IfPXpUqkikig7JKiliVSXBh15elaBwpLs7oWT6yalzqOqO15u8503/tD4uh0rcR4k/CzajVi8ihyBn1JCZvUp7+7Q==; 5:97tVcDm04FVuru82wZfOjStcqqxFD0zxshRQr9nAVxpCc6X4aTtz9H/heP0bEmNzfynQg5lmlItnH6a67qIrY4s9/N5zFcL5Hm2VMeWmEHtnOwWKIiebM/r5K2iJjwwVsuWWwTMy00qsz90AlptQ4Q==; 24:0ooFRzyjS3GZY6ZHQLo/f+FrDgHAHB0y1AA+oMU7vYg4POLvLuu8JzTfPXYWDljxaKyJkF3479W5GSHFuFS7AvKboxY9Wv0ufoRyb8c9dz4=; 7:ep3uwI6lCyA1rmRGGKmj6VYoM3yzfD9DbreOGbw4ANvDgCynOHjgb8MDGkd9zVRqty3IUf72OkJUPR0h1MubC9jUM9OgDRg1FqUf3osMHqiZzoaUgNTCiVicoW4c1PolFL4beZFBiexg87Ncanz6Bx8nrZ6RrrcS10ny1YT+HVBtCiMbWOEMWaG99ELhEVRG5LQFfV/knjAR2rUwN3TxphDVztQMlNGNUMSXVeRPiC0= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 43c51532-3618-4afa-3433-08d4f603ce17 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DB5PR04MB1334; x-ms-traffictypediagnostic: DB5PR04MB1334: x-exchange-antispam-report-test: UriScan:(185117386973197)(162533806227266); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB5PR04MB1334; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB5PR04MB1334; x-forefront-prvs: 04238CD941 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(377454003)(13464003)(189002)(24454002)(199003)(76176999)(5250100002)(68736007)(6436002)(6506006)(101416001)(3846002)(102836003)(53936002)(8936002)(33656002)(8676002)(50986999)(6116002)(81166006)(81156014)(106356001)(7696004)(97736004)(25786009)(110136004)(105586002)(54356999)(189998001)(6246003)(74316002)(14454004)(2900100001)(99286003)(54906002)(66066001)(6916009)(229853002)(55016002)(4326008)(2950100002)(53546010)(478600001)(305945005)(15650500001)(7736002)(3280700002)(575784001)(9686003)(2906002)(86362001)(3660700001)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB1334; H:DB5PR04MB0998.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2017 15:19:16.8107 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1334 Subject: Re: [PATCH v3 2/2] SD : Updated CMD 6 implememtation. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2017 15:16:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Leif, I agree to contribute under TianoCore Contribution Agreement 1.1 Thanks, Meenakshi > -----Original Message----- > From: Leif Lindholm [mailto:leif.lindholm@linaro.org] > Sent: Thursday, September 07, 2017 8:05 PM > To: Meenakshi Aggarwal > Cc: jun.nie@linaro.org; haojian.zhuang@linaro.org; edk2-devel@lists.01.or= g > Subject: Re: [PATCH v3 2/2] SD : Updated CMD 6 implememtation. >=20 > On Thu, Sep 07, 2017 at 07:47:53PM +0530, Meenakshi Aggarwal wrote: > > For setting high speed in SD card, > > First CMD 6 (Switch) is send to check if card supports High Speed and > > Second command is send to switch card to high speed mode. > > > > In current inplementation, CMD 6 was sent only once to switch the card > > into HS mode without checking if card supports HS or not, which is not > > as per specification and also we are not setting the HS i.e. 50000000 > > but directly asking the card to switch to 26000000 which is incorrect > > as SD card supports either 25000000 or 50000000. > > > > Contributed-under: TianoCore Contribution Agreement 1.0 >=20 > Ok, I would say this one is good to go, but can you please confirm if you= are > happy to contribute under TianoCore Contribution Agreement 1.1, which is > the version currently described in Contributions.txt? >=20 > If so, I can fold in this change and push. >=20 > Oh, you also appear to have left out edk2-devel@lists.01.org in this > submission (added). >=20 > Best Regards, >=20 > Leif >=20 > > Signed-off-by: Meenakshi Aggarwal > > --- > > EmbeddedPkg/Universal/MmcDxe/Mmc.h | 8 ++++ > > EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 53 > > +++++++++++++++++++++--- > > 2 files changed, 56 insertions(+), 5 deletions(-) mode change 100644 > > =3D> 100755 EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > > > > diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > index f3e56ff..a77ba41 100644 > > --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > > @@ -64,6 +64,14 @@ > > #define EMMC_CMD6_ARG_VALUE(x) (((x) & 0xFF) << 8) > > #define EMMC_CMD6_ARG_CMD_SET(x) (((x) & 0x7) << 0) > > > > +#define SWITCH_CMD_DATA_LENGTH 64 > > +#define SD_HIGH_SPEED_SUPPORTED 0x20000 > > +#define SD_DEFAULT_SPEED 25000000 > > +#define SD_HIGH_SPEED 50000000 > > +#define SWITCH_CMD_SUCCESS_MASK 0x0f000000 > > + > > +#define BUSWIDTH_4 4 > > + > > typedef enum { > > UNKNOWN_CARD, > > MMC_CARD, //MMC card > > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > > b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > > old mode 100644 > > new mode 100755 > > index 27e4444..f661a0c > > --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c > > @@ -318,6 +318,23 @@ InitializeEmmcDevice ( } > > > > STATIC > > +UINT32 > > +CreateSwitchCmdArgument ( > > + IN UINT32 Mode, > > + IN UINT8 Group, > > + IN UINT8 Value > > + ) > > +{ > > + UINT32 Argument; > > + > > + Argument =3D Mode << 31 | 0x00FFFFFF; Argument &=3D ~(0xF << (Group= * > > + 4)); Argument |=3D Value << (Group * 4); > > + > > + return Argument; > > +} > > + > > +STATIC > > EFI_STATUS > > InitializeSdMmcDevice ( > > IN MMC_HOST_INSTANCE *MmcHostInstance > > @@ -326,6 +343,7 @@ InitializeSdMmcDevice ( > > UINT32 CmdArg; > > UINT32 Response[4]; > > UINT32 Buffer[128]; > > + UINT32 Speed; > > UINTN BlockSize; > > UINTN CardSize; > > UINTN NumBlocks; > > @@ -334,6 +352,7 @@ InitializeSdMmcDevice ( > > EFI_STATUS Status; > > EFI_MMC_HOST_PROTOCOL *MmcHost; > > > > + Speed =3D SD_DEFAULT_SPEED; > > MmcHost =3D MmcHostInstance->MmcHost; > > > > // Send a command to get Card specific data @@ -439,20 +458,44 @@ > > InitializeSdMmcDevice ( > > } > > } > > if (CccSwitch) { > > + /* SD Switch, Mode:0, Group:0, Value:0 */ > > + CmdArg =3D CreateSwitchCmdArgument(0, 0, 0); > > + Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): Error and Status =3D %r\n", > __FUNCTION__, Status)); > > + return Status; > > + } else { > > + Status =3D MmcHost->ReadBlockData (MmcHost, 0, > SWITCH_CMD_DATA_LENGTH, Buffer); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): ReadBlockData Error > and Status =3D %r\n", __FUNCTION__, Status)); > > + return Status; > > + } > > + } > > + > > + if (!(Buffer[3] & SD_HIGH_SPEED_SUPPORTED)) { > > + DEBUG ((DEBUG_ERROR, "%a : High Speed not supported by Card > %r\n", __FUNCTION__, Status)); > > + return Status; > > + } > > + > > + Speed =3D SD_HIGH_SPEED; > > + > > /* SD Switch, Mode:1, Group:0, Value:1 */ > > - CmdArg =3D 1 << 31 | 0x00FFFFFF; > > - CmdArg &=3D ~(0xF << (0 * 4)); > > - CmdArg |=3D 1 << (0 * 4); > > + CmdArg =3D CreateSwitchCmdArgument(1, 0, 1); > > Status =3D MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg); > > if (EFI_ERROR (Status)) { > > DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): Error and Status =3D %r\n", > __FUNCTION__, Status)); > > return Status; > > } else { > > - Status =3D MmcHost->ReadBlockData (MmcHost, 0, 64, Buffer); > > + Status =3D MmcHost->ReadBlockData (MmcHost, 0, > > + SWITCH_CMD_DATA_LENGTH, Buffer); > > if (EFI_ERROR (Status)) { > > DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): ReadBlockData Error and > Status =3D %r\n", __FUNCTION__, Status)); > > return Status; > > } > > + > > + if ((Buffer[4] & SWITCH_CMD_SUCCESS_MASK) !=3D 0x01000000) { > > + DEBUG((DEBUG_ERROR, "Problem switching SD card into high-speed > mode\n")); > > + return Status; > > + } > > } > > } > > if (Scr.SD_BUS_WIDTHS & SD_BUS_WIDTH_4BIT) { @@ -470,7 +513,7 @@ > > InitializeSdMmcDevice ( > > } > > } > > if (MMC_HOST_HAS_SETIOS(MmcHost)) { > > - Status =3D MmcHost->SetIos (MmcHost, 26 * 1000 * 1000, 4, > EMMCBACKWARD); > > + Status =3D MmcHost->SetIos (MmcHost, Speed, BUSWIDTH_4, > > + EMMCBACKWARD); > > if (EFI_ERROR (Status)) { > > DEBUG ((DEBUG_ERROR, "%a (SetIos): Error and Status =3D %r\n", > __FUNCTION__, Status)); > > return Status; > > -- > > 1.9.1 > >