<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 15">
<meta name="Originator" content="Microsoft Word 15">
<link rel="File-List" href="cid:filelist.xml@01D73B61.434179F0"><!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:EnvelopeVis/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:DoNotExpandShiftReturn/>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="false" DefSemiHidden="false" DefQFormat="false" DefPriority="99" LatentStyleCount="376">
<w:LsdException Locked="false" Priority="0" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index 9"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" Name="toc 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Normal Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="footnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="annotation text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="header"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="footer"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="index heading"/>
<w:LsdException Locked="false" Priority="35" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="table of figures"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="envelope address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="envelope return"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="footnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="annotation reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="line number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="page number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="endnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="endnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="table of authorities"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="macro"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="toa heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Bullet"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Bullet 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Bullet 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Bullet 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Bullet 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Number 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Number 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Number 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Number 5"/>
<w:LsdException Locked="false" Priority="10" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Closing"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Signature"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="true" UnhideWhenUsed="true" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Continue"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Continue 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Continue 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Continue 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="List Continue 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Message Header"/>
<w:LsdException Locked="false" Priority="11" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Salutation"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Date"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text First Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text First Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Note Heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Body Text Indent 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Block Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Hyperlink"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="FollowedHyperlink"/>
<w:LsdException Locked="false" Priority="22" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Document Map"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Plain Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="E-mail Signature"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Top of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Bottom of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Normal (Web)"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Acronym"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Cite"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Code"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Definition"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Keyboard"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Preformatted"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Sample"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Typewriter"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="HTML Variable"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="annotation subject"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="No List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Outline List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Outline List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Outline List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Simple 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Simple 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Simple 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Classic 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Classic 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Classic 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Classic 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Colorful 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Colorful 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Colorful 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Columns 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Columns 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Columns 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Columns 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Columns 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Grid 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table List 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table 3D effects 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table 3D effects 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table 3D effects 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Contemporary"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Elegant"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Professional"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Subtle 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Subtle 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Web 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Table Web 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Balloon Text"/>
<w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" SemiHidden="true" UnhideWhenUsed="true" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true" UnhideWhenUsed="true" QFormat="true" Name="TOC Heading"/>
<w:LsdException Locked="false" Priority="41" Name="Plain Table 1"/>
<w:LsdException Locked="false" Priority="42" Name="Plain Table 2"/>
<w:LsdException Locked="false" Priority="43" Name="Plain Table 3"/>
<w:LsdException Locked="false" Priority="44" Name="Plain Table 4"/>
<w:LsdException Locked="false" Priority="45" Name="Plain Table 5"/>
<w:LsdException Locked="false" Priority="40" Name="Grid Table Light"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Mention"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Smart Hyperlink"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Hashtag"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Unresolved Mention"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true" Name="Smart Link"/>
</w:LatentStyles>
</xml><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-536858881 -1073711013 9 0 511 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:3 0 0 0 1 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-469750017 -1073732485 9 0 511 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0in;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-font-family:Calibri;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-noshow:yes;
mso-style-priority:99;
color:purple;
text-decoration:underline;
text-underline:single;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-style-unhide:no;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-font-family:Calibri;}
span.apple-converted-space
{mso-style-name:apple-converted-space;
mso-style-unhide:no;}
span.EmailStyle19
{mso-style-type:personal-reply;
mso-style-noshow:yes;
mso-style-unhide:no;
mso-ansi-font-size:11.0pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ascii-font-family:Calibri;
mso-fareast-font-family:Calibri;
mso-hansi-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";
color:windowtext;}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-size:10.0pt;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 10]><style>/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman",serif;}
</style><![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="tab-interval:.5in;word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman"">This is an example of another approach.<span style="mso-spacerun:yes">
</span>This module uses PCI I/O or <span class="SpellE">IoLib</span> based on the type of device.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><a href="https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Bus/Pci/PciSioSerialDxe">https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Bus/Pci/PciSioSerialDxe</a><span style="mso-tab-count:1">
</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman"">No additional protocols or lib classes/instances.<span style="mso-spacerun:yes">
</span>Instead, the register access APIs are included in the module and based on the type of device detected, it uses PCI I/O or
<span class="SpellE">IoLib</span>:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><a href="https://github.com/tianocore/edk2/blob/5b90b8abb4049e2d98040f548ad23b6ab22d5d19/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c#L1327">https://github.com/tianocore/edk2/blob/5b90b8abb4049e2d98040f548ad23b6ab22d5d19/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c#L1327</a><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><a href="https://github.com/tianocore/edk2/blob/5b90b8abb4049e2d98040f548ad23b6ab22d5d19/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c#L1358">https://github.com/tianocore/edk2/blob/5b90b8abb4049e2d98040f548ad23b6ab22d5d19/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c#L1358</a><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman"">This technique could for PCI I/O vs MMIO register access.<span style="mso-spacerun:yes">
</span>You would need to add more APIs for the use of PCI I/O or <span class="SpellE">
DmaLib</span> for DMA access.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman"">Mike<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;mso-bidi-font-family:"Times New Roman""><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="mso-fareast-font-family:"Times New Roman"">From:</span></b><span style="mso-fareast-font-family:"Times New Roman""> Andrew Fish <afish@apple.com>
<br>
<b>Sent:</b> Tuesday, April 27, 2021 10:31 AM<br>
<b>To:</b> edk2-devel-groups-io <devel@edk2.groups.io>; Loh, Tien Hock <tien.hock.loh@intel.com><br>
<b>Cc:</b> Kinney, Michael D <michael.d.kinney@intel.com>; thloh85@gmail.com; Leif Lindholm <leif@nuviainc.com>; Ard Biesheuvel <ardb+tianocore@kernel.org><br>
<b>Subject:</b> Re: [edk2-devel] [PATCH V5 1/1] EmbeddedPkg: DwMmcHcDxe: Add support for Designware SDMMC driver<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman"">One trick people have pulled in the past is to write a driver that produces a “fake” PCI IO Protocol. The “fake” PCI IO driver abstracts how the MMIO device shows up on the platform.
This works well if the MMIO device is really the same IP block as a PCI device. This usually maps to the PCI BAR being the same thing as the magic MMIO range. The “fake” PCI IO Protocol also abstracts platform specific DMA rules from the generic driver. <o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman""><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman"">Thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman""><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman"">Andrew Fish<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman""><br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman"">On Apr 27, 2021, at 2:08 AM, Loh, Tien Hock <<a href="mailto:tien.hock.loh@intel.com">tien.hock.loh@intel.com</a>> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman""><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Hi Mike<br>
<br>
Yes, the existing Sd driver is very tightly coupled with PCI IO struct, thus the reason for a new driver.<span class="apple-converted-space"> </span><br>
I can attempt to refactor the Pci/SdMmcPciHcDxe and make PCI and Mmio a library if that's the best route. I remember I tried briefly to refactor the code but it was quite a bit of work.<br>
<br>
Let me give it another go, and get back to you.<span class="apple-converted-space"> </span><br>
<br>
Thanks.<br>
<br>
<br style="mso-special-character:line-break;caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]></span><span style="mso-fareast-font-family:"Times New Roman""><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="mso-outline-level:1"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">-----Original Message-----<br>
From: Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
Sent: Tuesday, April 27, 2021 1:54 AM<br>
To: Loh, Tien Hock <<a href="mailto:tien.hock.loh@intel.com">tien.hock.loh@intel.com</a>>;<span class="apple-converted-space"> </span><a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>;<br>
Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
Cc:<span class="apple-converted-space"> </span><a href="mailto:thloh85@gmail.com">thloh85@gmail.com</a>; Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>; Ard Biesheuvel<br>
<<a href="mailto:ardb+tianocore@kernel.org">ardb+tianocore@kernel.org</a>><br>
Subject: RE: [PATCH V5 1/1] EmbeddedPkg: DwMmcHcDxe: Add support for<br>
Designware SDMMC driver<br>
<br>
I see the MdeModulePkg has the SdMmcPciHcDxe module and it uses the<br>
EDK II SD MMC Override<br>
Protocol for host controller specific behaviors. Why was this driver and an<br>
implementation<br>
of the EDK II SD MMC Override Protocol for the DesignWare MMC HC not<br>
used?<br>
<br>
If there is a good reason that this exiting module and override extensions can<br>
not be used,<br>
then please add that background and analysis to the BZ.<br>
<br>
I see the existing module is PCI and I think this new one is for a MMIO based<br>
device<br>
that requires different DMA services. Is this correct? I am wondering if there<br>
is<br>
a way to implement t a single UEFI Driver sources that can support a device<br>
that is<br>
with PCI or MMIO?<br>
<br>
If a new driver is required, then here is some more specific code review<br>
feedback:<br>
<br>
1) EmbeddedPkg/Include/Protocol/PlatformSwMmc.h<br>
<br>
The enum EFI_SD_MMC_SLOT_TYPE can not being with EFI_ unless is part<br>
of the UEFI Spec.<br>
This file appears to be specific to DW, so perhaps it should be prefixed with<br>
DW_ instead<br>
to match the usage of DW_MMC_HC_SLOT_CAP.<br>
<br>
The same comment applies to SD_MMC_CARD_TYPE. Should that be<br>
DW_SD_MMC_CARD_TYPE?<br>
<br>
<br>
2) EmbeddedPkg/Drivers/DwMmcHcDxe<br>
a) There is a package .dec file in this directory. Packages can never be<br>
nested. Any<br>
interfaces that need to be exported from the EmbeddedPkg should be<br>
declared in<br>
EmbeddedPkg.dec and DwMmcDcDxe.dec should be removed.<br>
b) DwMmcDcDxe.dec declared a token space GUID, but there are not PCDs.<br>
I think this GUID<br>
can be removed.<br>
c) DwMmcDcDxe.inf. Remove reference to DwMmcDcDxe.dec. Also, is this<br>
UEFI Driver really<br>
ARM specific? Why is there a dependency on ArmPkg/ArmPkg.dec? Can<br>
that be removed?<br>
Can the dependency on ArmLib be removed?<br>
<br>
3) I see use of #ifdef in the DwMmcHci.h file. This is highly discouraged. Why<br>
are<br>
those there and why not use featured flags PCD instead? If it is related to<br>
the<br>
PCI vs MMIO register mapping, then perhaps the PCI related content can<br>
be removed<br>
from this MMIO specific driver?<br>
<br>
Best regards,<br>
<br>
Mike<br>
<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="mso-outline-level:1"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">-----Original Message-----<br>
From: Loh, Tien Hock <<a href="mailto:tien.hock.loh@intel.com">tien.hock.loh@intel.com</a>><br>
Sent: Sunday, March 21, 2021 8:25 PM<br>
To: <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a><br>
Cc: <a href="mailto:thloh85@gmail.com">thloh85@gmail.com</a>; Loh, Tien Hock <<a href="mailto:tien.hock.loh@intel.com">tien.hock.loh@intel.com</a>>; Kinney,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Leif<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>; Ard Biesheuvel<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman""><<a href="mailto:ardb+tianocore@kernel.org">ardb+tianocore@kernel.org</a>><br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Subject: [PATCH V5 1/1] EmbeddedPkg: DwMmcHcDxe: Add support for<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Designware SDMMC driver<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman""><br>
From: "Tien Hock, Loh" <<a href="mailto:tien.hock.loh@intel.com">tien.hock.loh@intel.com</a>><br>
<br>
This adds support for Designware SDMMC driver. The SDMMC driver<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">depends on<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">MdeModulePkg/Bus/Sd/, and produces<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL. The<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">driver uses MMIO to read/write, and uses<br>
gEdkiiNonDiscoverableDeviceProtocolGuid. Platform needs to register<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">with gEdkiiNonDiscoverableDeviceProtocolGuid.<br>
<br>
Signed-off-by: Loh Tien Hock <<a href="mailto:tien.hock.loh@intel.com">tien.hock.loh@intel.com</a>><br>
Cc: Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>><br>
Cc: Ard Biesheuvel <<a href="mailto:ardb+tianocore@kernel.org">ardb+tianocore@kernel.org</a>><br>
---<br>
EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec | 40 +<br>
EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf | 70 +<br>
EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.h | 817<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">++++++++++<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.h | 985<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">++++++++++++<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EmbeddedPkg/Include/Protocol/PlatformDwMmc.h | 79 +<br>
EmbeddedPkg/Drivers/DwMmcHcDxe/ComponentName.c | 214 +++<br>
EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.c | 1296<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">++++++++++++++++<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.c | 1602<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">++++++++++++++++++++<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EmbeddedPkg/Drivers/DwMmcHcDxe/EmmcDevice.c | 1042<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+++++++++++++<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EmbeddedPkg/Drivers/DwMmcHcDxe/SdDevice.c | 1105<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">++++++++++++++<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">10 files changed, 7250 insertions(+)<br>
<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..cf85ccb1a030<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec<br>
@@ -0,0 +1,40 @@<br>
+#/** @file<br>
+# Framework Module Development Environment Industry Standards<br>
+#<br>
+# This Package provides headers and libraries that conform to EFI/PI<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Industry standards.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR><br>
+# Copyright (c) 2012-2014, ARM Ltd. All rights reserved.<BR><br>
+# Copyright (c) 2018, Linaro. All rights reserved.<BR><br>
+#<br>
+# This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available under<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# the terms and conditions of the BSD License which accompanies this<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">distribution.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# The full text of the license may be found at<br>
+# <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+#<br>
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#<br>
+#**/<br>
+<br>
+[Defines]<br>
+ DEC_SPECIFICATION = 0x00010019<br>
+ PACKAGE_NAME = DwMmcHcDxePkg<br>
+ PACKAGE_GUID = e73097ce-1fe2-41a6-a930-3136bc6d23ef<br>
+ PACKAGE_VERSION = 0.1<br>
+<br>
+<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#########################################################<br>
#######################<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#<br>
+# Include Section - list of Include Paths that are provided by this package.<br>
+# Comments are used for Keywords and Module Types.<br>
+#<br>
+# Supported Module Types:<br>
+# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">UEFI_APPLICATION<br>
+#<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#########################################################<br>
#######################<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+[Guids.common]<br>
+ gDwMmcHcDxeTokenSpaceGuid = { 0x576c132e, 0x7d51, 0x4abb, {<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">0xbc, 0x60, 0x13, 0x08, 0x04, 0x0e, 0x90, 0x92 }}<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+[Protocols.common]<br>
+ gPlatformDwMmcProtocolGuid = { 0x1d6dfde5, 0x76a7, 0x4404, { 0x85,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">0x74, 0x7a, 0xdf, 0x1a, 0x8a, 0xa2, 0x0d }}<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..4cd0960ef9c3<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf<br>
@@ -0,0 +1,70 @@<br>
+## @file<br>
+# DwSdMmcHcDxe driver is used to manage those host controllers which<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">comply with<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# Designware SD Host Controller.<br>
+#<br>
+# It will produce EFI_SD_MMC_PASS_THRU_PROTOCOL to allow sending<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD/MMC/eMMC cmds<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# to specified devices from upper layer.<br>
+#<br>
+# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR><br>
+# Copyright (C) 2016, Marvell International Ltd. All rights reserved.<BR><br>
+# Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR><br>
+#<br>
+# This program and the accompanying materials<br>
+# are licensed and made available under the terms and conditions of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BSD License<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# which accompanies this distribution. The full text of the license may be<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">found at<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#<br>
+#<br>
+##<br>
+<br>
+[Defines]<br>
+ INF_VERSION = 0x00010019<br>
+ BASE_NAME = DwMmcHcDxe<br>
+ MODULE_UNI_FILE = DwMmcHcDxe.uni<br>
+ FILE_GUID = 9be4d260-208c-4efe-a524-0b5d3bf77f9d<br>
+ MODULE_TYPE = UEFI_DRIVER<br>
+ VERSION_STRING = 1.0<br>
+ ENTRY_POINT = InitializeDwMmcHcDxe<br>
+<br>
+[Sources]<br>
+ ComponentName.c<br>
+ DwMmcHcDxe.c<br>
+ DwMmcHcDxe.h<br>
+ DwMmcHci.c<br>
+ DwMmcHci.h<br>
+ EmmcDevice.c<br>
+ SdDevice.c<br>
+<br>
+[Packages]<br>
+ ArmPkg/ArmPkg.dec<br>
+ EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec<br>
+ EmbeddedPkg/EmbeddedPkg.dec<br>
+ MdeModulePkg/MdeModulePkg.dec<br>
+ MdePkg/MdePkg.dec<br>
+<br>
+[LibraryClasses]<br>
+ ArmLib<br>
+ BaseLib<br>
+ BaseMemoryLib<br>
+ CacheMaintenanceLib<br>
+ DebugLib<br>
+ DevicePathLib<br>
+ DmaLib<br>
+ MemoryAllocationLib<br>
+ TimerLib<br>
+ UefiBootServicesTableLib<br>
+ UefiDriverEntryPoint<br>
+ UefiLib<br>
+ UefiRuntimeServicesTableLib<br>
+<br>
+[Protocols]<br>
+ gEdkiiNonDiscoverableDeviceProtocolGuid<br>
+ gEfiDevicePathProtocolGuid ## TO_START<br>
+ gEfiPciIoProtocolGuid ## TO_START<br>
+ gEfiSdMmcPassThruProtocolGuid ## BY_START<br>
+ gPlatformDwMmcProtocolGuid<br>
+<br>
+[UserExtensions.TianoCore."ExtraFiles"]<br>
+ DwMmcHcDxeExtra.uni<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.h<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.h<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..b783d9830325<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.h<br>
@@ -0,0 +1,817 @@<br>
+/** @file<br>
+<br>
+ Provides some data structure definitions used by the Designware<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD/MMC<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ host controller driver.<br>
+<br>
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (C) 2018, Linaro Ltd. All rigths reserved.<BR><br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#ifndef _DW_MMC_HC_DXE_H_<br>
+#define _DW_MMC_HC_DXE_H_<br>
+<br>
+#include <Uefi.h><br>
+<br>
+#include <Library/UefiLib.h><br>
+<br>
+#include <Protocol/ComponentName.h><br>
+#include <Protocol/ComponentName2.h><br>
+#include <Protocol/DeviceIo.h><br>
+#include <Protocol/DriverBinding.h><br>
+#include <Protocol/SdMmcPassThru.h><br>
+<br>
+#include "DwMmcHci.h"<br>
+<br>
+extern EFI_COMPONENT_NAME_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">gDwMmcHcComponentName;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+extern EFI_COMPONENT_NAME2_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">gDwMmcHcComponentName2;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+extern EFI_DRIVER_BINDING_PROTOCOL gDwMmcHcDriverBinding;<br>
+<br>
+#define DW_MMC_HC_PRIVATE_SIGNATURE SIGNATURE_32 ('d', 'w', 's',<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">'d')<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+#define DW_MMC_HC_PRIVATE_FROM_THIS(a) \<br>
+ CR(a, DW_MMC_HC_PRIVATE_DATA, PassThru,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_HC_PRIVATE_SIGNATURE)<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+//<br>
+// Generic time out value, 1 microsecond as unit.<br>
+//<br>
+#define DW_MMC_HC_GENERIC_TIMEOUT (1 * 1000 * 1000)<br>
+<br>
+//<br>
+// SD/MMC async transfer timer interval, set by experience.<br>
+// The unit is 100us, takes 1ms as interval.<br>
+//<br>
+#define DW_MMC_HC_ASYNC_TIMER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_TIMER_PERIOD_MILLISECONDS(1)<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+//<br>
+// SD/MMC removable device enumeration timer interval, set by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">experience.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+// The unit is 100us, takes 100ms as interval.<br>
+//<br>
+#define DW_MMC_HC_ENUM_TIMER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_TIMER_PERIOD_MILLISECONDS(100)<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+typedef struct {<br>
+ BOOLEAN Enable;<br>
+ EFI_SD_MMC_SLOT_TYPE SlotType;<br>
+ BOOLEAN MediaPresent;<br>
+ BOOLEAN Initialized;<br>
+ SD_MMC_CARD_TYPE CardType;<br>
+} DW_MMC_HC_SLOT;<br>
+<br>
+typedef struct {<br>
+ UINTN Signature;<br>
+<br>
+ EFI_HANDLE ControllerHandle;<br>
+<br>
+ // Mmio base address<br>
+ UINTN DevBase;<br>
+<br>
+ EFI_SD_MMC_PASS_THRU_PROTOCOL PassThru;<br>
+<br>
+ PLATFORM_DW_MMC_PROTOCOL *PlatformDwMmc;<br>
+ //<br>
+ // The field is used to record the previous slot in GetNextSlot().<br>
+ //<br>
+ UINT8 PreviousSlot;<br>
+ //<br>
+ // For Non-blocking operation.<br>
+ //<br>
+ EFI_EVENT TimerEvent;<br>
+ //<br>
+ // For Sd removable device enumeration.<br>
+ //<br>
+ EFI_EVENT ConnectEvent;<br>
+ LIST_ENTRY Queue;<br>
+<br>
+ DW_MMC_HC_SLOT Slot[DW_MMC_HC_MAX_SLOT];<br>
+ DW_MMC_HC_SLOT_CAP<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Capability[DW_MMC_HC_MAX_SLOT];<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ UINT64 MaxCurrent[DW_MMC_HC_MAX_SLOT];<br>
+<br>
+ UINT32 ControllerVersion;<br>
+} DW_MMC_HC_PRIVATE_DATA;<br>
+<br>
+#define DW_MMC_HC_TRB_SIG SIGNATURE_32 ('D', 'T', 'R', 'B')<br>
+<br>
+//<br>
+// TRB (Transfer Request Block) contains information for the cmd request.<br>
+//<br>
+typedef struct {<br>
+ UINT32 Signature;<br>
+ LIST_ENTRY TrbList;<br>
+<br>
+ UINT8 Slot;<br>
+ UINT16 BlockSize;<br>
+<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ VOID *Data;<br>
+ UINT32 DataLen;<br>
+ BOOLEAN Read;<br>
+ EFI_PHYSICAL_ADDRESS DataPhy;<br>
+ VOID *DataMap;<br>
+ DW_MMC_HC_TRANSFER_MODE Mode;<br>
+<br>
+ EFI_EVENT Event;<br>
+ BOOLEAN Started;<br>
+ UINT64 Timeout;<br>
+<br>
+ DW_MMC_HC_DMA_DESC_LINE *DmaDesc;<br>
+ EFI_PHYSICAL_ADDRESS DmaDescPhy;<br>
+ UINT32 DmaDescPages;<br>
+ VOID *DmaMap;<br>
+<br>
+ BOOLEAN UseFifo;<br>
+ BOOLEAN UseBE; // Big-endian<br>
+<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+} DW_MMC_HC_TRB;<br>
+<br>
+#define DW_MMC_HC_TRB_FROM_THIS(a) \<br>
+ CR(a, DW_MMC_HC_TRB, TrbList, DW_MMC_HC_TRB_SIG)<br>
+<br>
+//<br>
+// Task for Non-blocking mode.<br>
+//<br>
+typedef struct {<br>
+ UINT32 Signature;<br>
+ LIST_ENTRY Link;<br>
+<br>
+ UINT8 Slot;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ BOOLEAN IsStart;<br>
+ EFI_EVENT Event;<br>
+ UINT64 RetryTimes;<br>
+ BOOLEAN InfiniteWait;<br>
+ VOID *Map;<br>
+ VOID *MapAddress;<br>
+} DW_MMC_HC_QUEUE;<br>
+<br>
+//<br>
+// Prototypes<br>
+//<br>
+/**<br>
+ Execute card identification procedure.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The card is identified correctly.<br>
+ @retval Others The card can't be identified.<br>
+<br>
+**/<br>
+typedef<br>
+EFI_STATUS<br>
+(*DWMMC_CARD_TYPE_DETECT_ROUTINE) (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private<br>
+ );<br>
+<br>
+/**<br>
+ Sends SD command to an SD card that is attached to the SD controller.<br>
+<br>
+ The PassThru() function sends the SD command specified by Packet to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the SD<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ card specified by Slot.<br>
+<br>
+ If Packet is successfully sent to the SD card, then EFI_SUCCESS is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">returned.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ If a device error occurs while sending the Packet, then<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DEVICE_ERROR is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned.<br>
+<br>
+ If Slot is not in a valid range for the SD controller, then<br>
+ EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If Packet defines a data command but both InDataBuffer and<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">OutDataBuffer are<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ NULL, EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<br>
+ command to.<br>
+ @param[in,out] Packet A pointer to the SD command data structure.<br>
+ @param[in] Event If Event is NULL, blocking I/O is performed. If<br>
+ Event is not NULL, then nonblocking I/O is<br>
+ performed, and Event will be signaled when the<br>
+ Packet completes.<br>
+<br>
+ @retval EFI_SUCCESS The SD Command Packet was sent by the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">host.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_DEVICE_ERROR A device error occurred while attempting<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">to send<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the SD command Packet.<br>
+ @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Packet is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ invalid.<br>
+ @retval EFI_INVALID_PARAMETER Packet defines a data command but<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">both<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ InDataBuffer and OutDataBuffer are NULL.<br>
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.<br>
+ @retval EFI_UNSUPPORTED The command described by the SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Command Packet<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ is not supported by the host controller.<br>
+ @retval EFI_BAD_BUFFER_SIZE The InTransferLength or<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">OutTransferLength<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ exceeds the limit supported by SD card ( i.e. if<br>
+ the number of bytes exceed the Last LBA).<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruPassThru (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN UINT8 Slot,<br>
+ IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,<br>
+ IN EFI_EVENT Event OPTIONAL<br>
+ );<br>
+<br>
+/**<br>
+ Used to retrieve next slot numbers supported by the SD controller. The<br>
+ function returns information about all available slots (populated or<br>
+ not-populated).<br>
+<br>
+ The GetNextSlot() function retrieves the next slot number on an SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ If on input Slot is 0xFF, then the slot number of the first slot on the SD<br>
+ controller is returned.<br>
+<br>
+ If Slot is a slot number that was returned on a previous call to<br>
+ GetNextSlot(), then the slot number of the next slot on the SD controller<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned.<br>
+<br>
+ If Slot is not 0xFF and Slot was not returned on a previous call to<br>
+ GetNextSlot(), EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If Slot is the slot number of the last slot on the SD controller, then<br>
+ EFI_NOT_FOUND is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in,out] Slot On input, a pointer to a slot number on the SD<br>
+ controller.<br>
+ On output, a pointer to the next slot number on<br>
+ the SD controller.<br>
+ An input value of 0xFF retrieves the first slot<br>
+ number on the SD controller.<br>
+<br>
+ @retval EFI_SUCCESS The next slot number on the SD controller<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">was<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned in Slot.<br>
+ @retval EFI_NOT_FOUND There are no more slots on this SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">returned on a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ previous call to GetNextSlot().<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruGetNextSlot (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN OUT UINT8 *Slot<br>
+ );<br>
+<br>
+/**<br>
+ Used to allocate and build a device path node for an SD card on the SD<br>
+ controller.<br>
+<br>
+ The BuildDevicePath() function allocates and builds a single device node<br>
+ for the SD<br>
+ card specified by Slot.<br>
+<br>
+ If the SD card specified by Slot is not present on the SD controller, then<br>
+ EFI_NOT_FOUND is returned.<br>
+<br>
+ If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If there are not enough resources to allocate the device path node, then<br>
+ EFI_OUT_OF_RESOURCES is returned.<br>
+<br>
+ Otherwise, DevicePath is allocated with the boot service AllocatePool(),<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ contents of DevicePath are initialized to describe the SD card specified by<br>
+ Slot, and EFI_SUCCESS is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot Specifies the slot number of the SD card for<br>
+ which a device path node is to be allocated and<br>
+ built.<br>
+ @param[in,out] DevicePath A pointer to a single device path node that<br>
+ describes the SD card specified by Slot. This<br>
+ function is responsible for allocating the<br>
+ buffer DevicePath with the boot service<br>
+ AllocatePool(). It is the caller's responsibi-<br>
+ lity to free DevicePath when the caller is<br>
+ finished with DevicePath.<br>
+<br>
+ @retval EFI_SUCCESS The device path node that describes the SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">card<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ specified by Slot was allocated and returned in<br>
+ DevicePath.<br>
+ @retval EFI_NOT_FOUND The SD card specified by Slot does not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">exist on<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the SD controller.<br>
+ @retval EFI_INVALID_PARAMETER DevicePath is NULL.<br>
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">allocate<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DevicePath.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruBuildDevicePath (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN UINT8 Slot,<br>
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath<br>
+ );<br>
+<br>
+/**<br>
+ This function retrieves an SD card slot number based on the input device<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">path.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ The GetSlotNumber() function retrieves slot number for the SD card<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ by the DevicePath node. If DevicePath is NULL,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_INVALID_PARAMETER is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned.<br>
+<br>
+ If DevicePath is not a device path node type that the SD Pass Thru driver<br>
+ supports, EFI_UNSUPPORTED is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] DevicePath A pointer to the device path node that<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">describes<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ a SD card on the SD controller.<br>
+ @param[out] Slot On return, points to the slot number of an SD<br>
+ card on the SD controller.<br>
+<br>
+ @retval EFI_SUCCESS SD card slot number is returned in Slot.<br>
+ @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.<br>
+ @retval EFI_UNSUPPORTED DevicePath is not a device path node<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">type that<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the SD Pass Thru driver supports.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruGetSlotNumber (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,<br>
+ OUT UINT8 *Slot<br>
+ );<br>
+<br>
+/**<br>
+ Resets an SD card that is connected to the SD controller.<br>
+<br>
+ The ResetDevice() function resets the SD card specified by Slot.<br>
+<br>
+ If this SD controller does not support a device reset operation,<br>
+ EFI_UNSUPPORTED is returned.<br>
+<br>
+ If Slot is not in a valid slot number for this SD controller,<br>
+ EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If the device reset operation is completed, EFI_SUCCESS is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot Specifies the slot number of the SD card to be<br>
+ reset.<br>
+<br>
+ @retval EFI_SUCCESS The SD card specified by Slot was reset.<br>
+ @retval EFI_UNSUPPORTED The SD controller does not support a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ reset operation.<br>
+ @retval EFI_INVALID_PARAMETER Slot number is invalid.<br>
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.<br>
+ @retval EFI_DEVICE_ERROR The reset command failed due to a device<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">error<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruResetDevice (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN UINT8 Slot<br>
+ );<br>
+<br>
+//<br>
+// Driver model protocol interfaces<br>
+//<br>
+/**<br>
+ Tests to see if this driver supports a given controller. If a child device is<br>
+ provided, it further tests to see if this driver supports creating a handle<br>
+ for the specified child device.<br>
+<br>
+ This function checks to see if the driver specified by This supports the<br>
+ device specified by ControllerHandle. Drivers will typically use the device<br>
+ path attached to ControllerHandle and/or the services from the bus I/O<br>
+ abstraction attached to ControllerHandle to determine if the driver<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">supports<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ ControllerHandle. This function may be called many times during<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">platform<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ initialization. In order to reduce boot times, the tests performed by this<br>
+ function must be very small, and take as little time as possible to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">execute.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ This function must not change the state of any hardware devices, and<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ function must be aware that the device specified by ControllerHandle<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">may<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ already be managed by the same driver or a different driver. This<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">function<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ must match its calls to AllocatePages() with FreePages(), AllocatePool()<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">with<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ FreePool(), and OpenProtocol() with CloseProtocol().<br>
+ Since ControllerHandle may have been previously started by the same<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">driver, if<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ a protocol is already in the opened state, then it must not be closed with<br>
+ CloseProtocol(). This is required to guarantee the state of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ is not modified by this function.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DRIVER_BINDING_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] ControllerHandle The handle of the controller to test. This<br>
+ handle must support a protocol interface that<br>
+ supplies an I/O abstraction to the driver.<br>
+ @param[in] RemainingDevicePath A pointer to the remaining portion of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ device path. This parameter is ignored by<br>
+ device drivers, and is optional for bus<br>
+ drivers. For bus drivers, if this parameter<br>
+ is not NULL, then the bus driver must deter-<br>
+ mine if the bus controller specified by<br>
+ ControllerHandle and the child controller<br>
+ specified by RemainingDevicePath are both<br>
+ supported by this bus driver.<br>
+<br>
+ @retval EFI_SUCCESS The device specified by ControllerHandle<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is supported by the<br>
+ driver specified by This.<br>
+ @retval EFI_ALREADY_STARTED The device specified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is already being managed<br>
+ by the driver specified by This.<br>
+ @retval EFI_ACCESS_DENIED The device specified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is already being managed<br>
+ by a different driver or an application that<br>
+ requires exclusive access.<br>
+ Currently not implemented.<br>
+ @retval EFI_UNSUPPORTED The device specified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is not supported by the<br>
+ driver specified by This.<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcDriverBindingSupported (<br>
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath<br>
+ );<br>
+<br>
+/**<br>
+ Starts a device controller or a bus controller.<br>
+<br>
+ The Start() function is designed to be invoked from the EFI boot service<br>
+ ConnectController().<br>
+ As a result, much of the error checking on the parameters to Start() has<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">been<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ moved into this common boot service. It is legal to call Start() from other<br>
+ locations,<br>
+ but the following calling restrictions must be followed or the system<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">behavior<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ will not be deterministic.<br>
+ 1. ControllerHandle must be a valid EFI_HANDLE.<br>
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">natural-<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ ly aligned EFI_DEVICE_PATH_PROTOCOL.<br>
+ 3. Prior to calling Start(), the Supported() function for the driver specified<br>
+ by This must have been called with the same calling parameters, and<br>
+ Supported() must have returned EFI_SUCCESS.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DRIVER_BINDING_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] ControllerHandle The handle of the controller to start.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">This<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ handle must support a protocol interface that<br>
+ supplies an I/O abstraction to the driver.<br>
+ @param[in] RemainingDevicePath A pointer to the remaining portion of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ device path. This parameter is ignored by<br>
+ device drivers, and is optional for bus dri-<br>
+ vers. For a bus driver, if this parameter is<br>
+ NULL, then handles for all the children of<br>
+ Controller are created by this driver.<br>
+ If this parameter is not NULL and the first<br>
+ Device Path Node is not the End of Device<br>
+ Path Node, then only the handle for the<br>
+ child device specified by the first Device<br>
+ Path Node of RemainingDevicePath is created<br>
+ by this driver.<br>
+ If the first Device Path Node of<br>
+ RemainingDevicePath is the End of Device Path<br>
+ Node, no child handle is created by this<br>
+ driver.<br>
+<br>
+ @retval EFI_SUCCESS The device was started.<br>
+ @retval EFI_DEVICE_ERROR The device could not be started due to a<br>
+ device error. Currently not implemented.<br>
+ @retval EFI_OUT_OF_RESOURCES The request could not be<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">completed due to a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ lack of resources.<br>
+ @retval Others The driver failded to start the device.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcDriverBindingStart (<br>
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath<br>
+ );<br>
+<br>
+/**<br>
+ Stops a device controller or a bus controller.<br>
+<br>
+ The Stop() function is designed to be invoked from the EFI boot service<br>
+ DisconnectController().<br>
+ As a result, much of the error checking on the parameters to Stop() has<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">been<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ moved into this common boot service. It is legal to call Stop() from other<br>
+ locations, but the following calling restrictions must be followed or the<br>
+ system behavior will not be deterministic.<br>
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">previous<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ call to this same driver's Start() function.<br>
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">valid<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_HANDLE. In addition, all of these handles must have been created<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">in<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ this driver's Start() function, and the Start() function must have called<br>
+ OpenProtocol() on ControllerHandle with an Attribute of<br>
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DRIVER_BINDING_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] ControllerHandle A handle to the device being stopped.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">The handle<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ must support a bus specific I/O protocol for the<br>
+ driver to use to stop the device.<br>
+ @param[in] NumberOfChildren The number of child device handles in<br>
+ ChildHandleBuffer.<br>
+ @param[in] ChildHandleBuffer An array of child handles to be freed.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">May be<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ NULL if NumberOfChildren is 0.<br>
+<br>
+ @retval EFI_SUCCESS The device was stopped.<br>
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ error.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcDriverBindingStop (<br>
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINTN NumberOfChildren,<br>
+ IN EFI_HANDLE *ChildHandleBuffer<br>
+ );<br>
+<br>
+//<br>
+// EFI Component Name Functions<br>
+//<br>
+/**<br>
+ Retrieves a Unicode string that is the user readable name of the driver.<br>
+<br>
+ This function retrieves the user readable name of a driver in the form of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Unicode string. If the driver specified by This has a user readable name in<br>
+ the language specified by Language, then a pointer to the driver name is<br>
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ by This does not support the language specified by Language,<br>
+ then EFI_UNSUPPORTED is returned.<br>
+<br>
+ @param This[in] A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_COMPONENT_NAME2_PROTOCOL or<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_COMPONENT_NAME_PROTOCOL instance.<br>
+<br>
+ @param Language[in] A pointer to a Null-terminated ASCII string<br>
+ array indicating the language. This is the<br>
+ language of the driver name that the caller is<br>
+ requesting, and it must match one of the<br>
+ languages specified in SupportedLanguages. The<br>
+ number of languages supported by a driver is up<br>
+ to the driver writer. Language is specified<br>
+ in RFC 4646 or ISO 639-2 language code format.<br>
+<br>
+ @param DriverName[out] A pointer to the Unicode string to return.<br>
+ This Unicode string is the name of the<br>
+ driver specified by This in the language<br>
+ specified by Language.<br>
+<br>
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by<br>
+ This and the language specified by Language was<br>
+ returned in DriverName.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER Language is NULL.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.<br>
+<br>
+ @retval EFI_UNSUPPORTED The driver specified by This does not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">support<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the language specified by Language.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcComponentNameGetDriverName (<br>
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,<br>
+ IN CHAR8 *Language,<br>
+ OUT CHAR16 **DriverName<br>
+ );<br>
+<br>
+/**<br>
+ Retrieves a Unicode string that is the user readable name of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ that is being managed by a driver.<br>
+<br>
+ This function retrieves the user readable name of the controller specified<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">by<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ ControllerHandle and ChildHandle in the form of a Unicode string. If the<br>
+ driver specified by This has a user readable name in the language<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified by<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Language, then a pointer to the controller name is returned in<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerName,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ and EFI_SUCCESS is returned. If the driver specified by This is not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">currently<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ managing the controller specified by ControllerHandle and ChildHandle,<br>
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">not<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ support the language specified by Language, then EFI_UNSUPPORTED is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">returned.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param This[in] A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_COMPONENT_NAME2_PROTOCOL or<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_COMPONENT_NAME_PROTOCOL instance.<br>
+<br>
+ @param ControllerHandle[in] The handle of a controller that the driver<br>
+ specified by This is managing. This handle<br>
+ specifies the controller whose name is to be<br>
+ returned.<br>
+<br>
+ @param ChildHandle[in] The handle of the child controller to retrieve<br>
+ the name of. This is an optional parameter that<br>
+ may be NULL. It will be NULL for device<br>
+ drivers. It will also be NULL for a bus drivers<br>
+ that wish to retrieve the name of the bus<br>
+ controller. It will not be NULL for a bus<br>
+ driver that wishes to retrieve the name of a<br>
+ child controller.<br>
+<br>
+ @param Language[in] A pointer to a Null-terminated ASCII string<br>
+ array indicating the language. This is the<br>
+ language of the driver name that the caller is<br>
+ requesting, and it must match one of the<br>
+ languages specified in SupportedLanguages. The<br>
+ number of languages supported by a driver is up<br>
+ to the driver writer. Language is specified in<br>
+ RFC 4646 or ISO 639-2 language code format.<br>
+<br>
+ @param ControllerName[out] A pointer to the Unicode string to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">return.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ This Unicode string is the name of the<br>
+ controller specified by ControllerHandle and<br>
+ ChildHandle in the language specified by<br>
+ Language from the point of view of the driver<br>
+ specified by This.<br>
+<br>
+ @retval EFI_SUCCESS The Unicode string for the user readable<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">name in<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the language specified by Language for the<br>
+ driver specified by This was returned in<br>
+ DriverName.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_HANDLE.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">valid<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_HANDLE.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER Language is NULL.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.<br>
+<br>
+ @retval EFI_UNSUPPORTED The driver specified by This is not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">currently<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ managing the controller specified by<br>
+ ControllerHandle and ChildHandle.<br>
+<br>
+ @retval EFI_UNSUPPORTED The driver specified by This does not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">support<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the language specified by Language.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcComponentNameGetControllerName (<br>
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,<br>
+ IN EFI_HANDLE ControllerHandle,<br>
+ IN EFI_HANDLE ChildHandle, OPTIONAL<br>
+ IN CHAR8 *Language,<br>
+ OUT CHAR16 **ControllerName<br>
+ );<br>
+<br>
+/**<br>
+ Create a new TRB for the SD/MMC cmd request.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ to.<br>
+ @param[in] Packet A pointer to the SD command data structure.<br>
+ @param[in] Event If Event is NULL, blocking I/O is performed.<br>
+ If Event is not NULL, then nonblocking I/O is<br>
+ performed, and Event will be signaled when the<br>
+ Packet completes.<br>
+<br>
+ @return Created Trb or NULL.<br>
+<br>
+**/<br>
+DW_MMC_HC_TRB *<br>
+DwMmcCreateTrb (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN UINT8 Slot,<br>
+ IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,<br>
+ IN EFI_EVENT Event<br>
+ );<br>
+<br>
+/**<br>
+ Free the resource used by the TRB.<br>
+<br>
+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+**/<br>
+VOID<br>
+DwMmcFreeTrb (<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ );<br>
+<br>
+/**<br>
+ Check if the env is ready for execute specified TRB.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The env is ready for TRB execution.<br>
+ @retval EFI_NOT_READY The env is not ready for TRB execution.<br>
+ @retval Others Some erros happen.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcCheckTrbEnv (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ );<br>
+<br>
+/**<br>
+ Wait for the env to be ready for execute specified TRB.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The env is ready for TRB execution.<br>
+ @retval EFI_TIMEOUT The env is not ready for TRB execution in time.<br>
+ @retval Others Some erros happen.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcWaitTrbEnv (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ );<br>
+<br>
+/**<br>
+ Execute the specified TRB.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The TRB is sent to host controller successfully.<br>
+ @retval Others Some erros happen when sending this request to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ host controller.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcExecTrb (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ );<br>
+<br>
+/**<br>
+ Check the TRB execution result.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The TRB is executed successfully.<br>
+ @retval EFI_NOT_READY The TRB is not completed for execution.<br>
+ @retval Others Some erros happen when executing this request.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcCheckTrbResult (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ );<br>
+<br>
+/**<br>
+ Wait for the TRB execution result.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The TRB is executed successfully.<br>
+ @retval Others Some erros happen when executing this request.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcWaitTrbResult (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ );<br>
+<br>
+/**<br>
+ Execute EMMC device identification procedure.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS There is a EMMC card.<br>
+ @retval Others There is not a EMMC card.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcIdentification (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private<br>
+ );<br>
+<br>
+/**<br>
+ Execute EMMC device identification procedure.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS There is a EMMC card.<br>
+ @retval Others There is not a EMMC card.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardIdentification (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private<br>
+ );<br>
+<br>
+#endif /* _DW_MMC_HC_DXE_H_ */<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.h<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.h<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..12ef58a37368<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.h<br>
@@ -0,0 +1,985 @@<br>
+/** @file<br>
+<br>
+ Provides some data structure definitions used by the SD/MMC host<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ driver.<br>
+<br>
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR><br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#ifndef _DW_MMC_HCI_H_<br>
+#define _DW_MMC_HCI_H_<br>
+<br>
+#include <Library/CacheMaintenanceLib.h><br>
+#include <Library/TimerLib.h><br>
+<br>
+#include <Protocol/PlatformDwMmc.h><br>
+<br>
+//<br>
+// SD Host Controller SlotInfo Register Offset<br>
+//<br>
+#define DW_MMC_HC_SLOT_OFFSET 0x40<br>
+<br>
+#define DW_MMC_HC_MAX_SLOT 1<br>
+<br>
+//<br>
+// SD Host Controller MMIO Register Offset<br>
+//<br>
+#define DW_MMC_CTRL 0x000<br>
+#define DW_MMC_PWREN 0x004<br>
+#define DW_MMC_CLKDIV 0x008<br>
+#define DW_MMC_CLKSRC 0x00c<br>
+#define DW_MMC_CLKENA 0x010<br>
+#define DW_MMC_TMOUT 0x014<br>
+#define DW_MMC_CTYPE 0x018<br>
+#define DW_MMC_BLKSIZ 0x01c<br>
+#define DW_MMC_BYTCNT 0x020<br>
+#define DW_MMC_INTMASK 0x024<br>
+#define DW_MMC_CMDARG 0x028<br>
+#define DW_MMC_CMD 0x02c<br>
+#define DW_MMC_RESP0 0x030<br>
+#define DW_MMC_RESP1 0x034<br>
+#define DW_MMC_RESP2 0x038<br>
+#define DW_MMC_RESP3 0x03c<br>
+#define DW_MMC_RINTSTS 0x044<br>
+#define DW_MMC_STATUS 0x048<br>
+#define DW_MMC_FIFOTH 0x04c<br>
+#define DW_MMC_GPIO 0x058<br>
+#define DW_MMC_DEBNCE 0x064<br>
+#define DW_MMC_USRID 0x068<br>
+#define DW_MMC_VERID 0x06c<br>
+#define DW_MMC_HCON 0x070<br>
+#define DW_MMC_UHSREG 0x074<br>
+#define DW_MMC_BMOD 0x080<br>
+#define DW_MMC_DBADDR 0x088<br>
+#define DW_MMC_IDSTS 0x08c<br>
+#define DW_MMC_IDINTEN 0x090<br>
+#define DW_MMC_DSCADDR 0x094<br>
+#define DW_MMC_BUFADDR 0x098<br>
+#define DW_MMC_CARDTHRCTL 0x100<br>
+#define DW_MMC_UHSREG_EXT 0x108<br>
+#define DW_MMC_ENABLE_SHIFT 0x110<br>
+#define DW_MMC_FIFO_START 0x200<br>
+<br>
+#define GET_IDSTS_DMAC_FSM(x) (((x) >> 13) & 0xf)<br>
+#define IDSTS_FSM_DMA_IDLE 0<br>
+#define IDSTS_FSM_DMA_SUSPEND 1<br>
+#define IDSTS_FSM_DESC_RD 2<br>
+#define IDSTS_FSM_DESC_CHK 3<br>
+#define IDSTS_FSM_DMA_RD_REQ_WAIT 4<br>
+#define IDSTS_FSM_DMA_WR_REQ_WAIT 5<br>
+#define IDSTS_FSM_DMA_RD 6<br>
+#define IDSTS_FSM_DMA_WR 7<br>
+#define IDSTS_FSM_DESC_CLOSE 8<br>
+#define IDSTS_FSM_MASK 0xf<br>
+<br>
+#define CMD_UPDATE_CLK 0x80202000<br>
+#define CMD_START_BIT (1 << 31)<br>
+<br>
+#define MMC_8BIT_MODE (1 << 16)<br>
+#define MMC_4BIT_MODE (1 << 0)<br>
+#define MMC_1BIT_MODE 0<br>
+<br>
+#define DW_MMC_BLOCK_SIZE 512<br>
+<br>
+#define CMD_INDEX_MASK 0x3F<br>
+#define BIT_CMD_RESPONSE_EXPECT (1 << 6)<br>
+#define BIT_CMD_LONG_RESPONSE (1 << 7)<br>
+#define BIT_CMD_CHECK_RESPONSE_CRC (1 << 8)<br>
+#define BIT_CMD_DATA_EXPECTED (1 << 9)<br>
+#define BIT_CMD_READ (0 << 10)<br>
+#define BIT_CMD_WRITE (1 << 10)<br>
+#define BIT_CMD_BLOCK_TRANSFER (0 << 11)<br>
+#define BIT_CMD_STREAM_TRANSFER (1 << 11)<br>
+#define BIT_CMD_SEND_AUTO_STOP (1 << 12)<br>
+#define BIT_CMD_WAIT_PRVDATA_COMPLETE (1 << 13)<br>
+#define BIT_CMD_STOP_ABORT_CMD (1 << 14)<br>
+#define BIT_CMD_SEND_INIT (1 << 15)<br>
+#define BIT_CMD_UPDATE_CLOCK_ONLY (1 << 21)<br>
+#define BIT_CMD_READ_CEATA_DEVICE (1 << 22)<br>
+#define BIT_CMD_CCS_EXPECTED (1 << 23)<br>
+#define BIT_CMD_ENABLE_BOOT (1 << 24)<br>
+#define BIT_CMD_EXPECT_BOOT_ACK (1 << 25)<br>
+#define BIT_CMD_DISABLE_BOOT (1 << 26)<br>
+#define BIT_CMD_MANDATORY_BOOT (0 << 27)<br>
+#define BIT_CMD_ALTERNATE_BOOT (1 << 27)<br>
+#define BIT_CMD_VOLT_SWITCH (1 << 28)<br>
+#define BIT_CMD_USE_HOLD_REG (1 << 29)<br>
+#define BIT_CMD_START (1 << 31)<br>
+<br>
+#define CMD_INDEX(x) ((x) & CMD_INDEX_MASK)<br>
+<br>
+#define DW_MMC_INT_EBE (1 << 15) /* End-bit Err */<br>
+#define DW_MMC_INT_SBE (1 << 13) /* Start-bit Err */<br>
+#define DW_MMC_INT_HLE (1 << 12) /* Hardware-lock<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Err */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_FRUN (1 << 11) /* FIFO UN/OV<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">RUN */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_DRT (1 << 9) /* Data timeout */<br>
+#define DW_MMC_INT_RTO (1 << 8) /* Response<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">timeout */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_DCRC (1 << 7) /* Data CRC err */<br>
+#define DW_MMC_INT_RCRC (1 << 6) /* Response CRC<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">err */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_RXDR (1 << 5) /* Receive FIFO<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">data request */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_TXDR (1 << 4) /* Transmit FIFO<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">data request */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_DTO (1 << 3) /* Data trans over<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">*/<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_CMD_DONE (1 << 2) /* Command<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">done */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_INT_RE (1 << 1) /* Response error */<br>
+<br>
+#define DW_MMC_IDMAC_DES0_DIC (1 << 1)<br>
+#define DW_MMC_IDMAC_DES0_LD (1 << 2)<br>
+#define DW_MMC_IDMAC_DES0_FS (1 << 3)<br>
+#define DW_MMC_IDMAC_DES0_CH (1 << 4)<br>
+#define DW_MMC_IDMAC_DES0_ER (1 << 5)<br>
+#define DW_MMC_IDMAC_DES0_CES (1 << 30)<br>
+#define DW_MMC_IDMAC_DES0_OWN (1 << 31)<br>
+#define DW_MMC_IDMAC_DES1_BS1(x) ((x) & 0x1fff)<br>
+#define DW_MMC_IDMAC_DES2_BS2(x) (((x) & 0x1fff) << 13)<br>
+#define DW_MMC_IDMAC_SWRESET (1 << 0)<br>
+#define DW_MMC_IDMAC_FB (1 << 1)<br>
+#define DW_MMC_IDMAC_ENABLE (1 << 7)<br>
+<br>
+#define DW_MMC_CTRL_RESET (1 << 0)<br>
+#define DW_MMC_CTRL_FIFO_RESET (1 << 1)<br>
+#define DW_MMC_CTRL_DMA_RESET (1 << 2)<br>
+#define DW_MMC_CTRL_INT_EN (1 << 4)<br>
+#define DW_MMC_CTRL_DMA_EN (1 << 5)<br>
+#define DW_MMC_CTRL_IDMAC_EN (1 << 25)<br>
+#define DW_MMC_CTRL_RESET_ALL (DW_MMC_CTRL_RESET |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_CTRL_FIFO_RESET | DW_MMC_CTRL_DMA_RESET)<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+#define DW_MMC_STS_DATA_BUSY (1 << 9)<br>
+#define DW_MMC_STS_FIFO_COUNT(x) (((x) & 0x1fff) << 17) /*<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Number of filled locations in FIFO */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define GET_STS_FIFO_COUNT(x) (((x) >> 17) & 0x1fff)<br>
+#define DW_MMC_STS_FIFO_FULL(x) (((x) >> 3) & 1)<br>
+<br>
+#define DW_MMC_BMOD_SWR (1 << 0) /* Software<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Reset */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_BMOD_FB (1 << 1) /* Fix Burst */<br>
+#define DW_MMC_BMOD_DE (1 << 7) /* IDMAC Enable<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">*/<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+#define DW_MMC_IDSTS_TI (1 << 0) /* Transmit<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Interrupt */<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define DW_MMC_IDSTS_RI (1 << 1) /* Receive Interrupt<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">*/<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+#define DW_MMC_FIFO_TWMARK(x) ((x) & 0xfff)<br>
+#define DW_MMC_FIFO_RWMARK(x) (((x) & 0x1ff) << 16)<br>
+#define DW_MMC_DMA_BURST_SIZE(x) (((x) & 0x7) << 28)<br>
+<br>
+#define DW_MMC_CARD_RD_THR(x) (((x) & 0xfff) << 16)<br>
+#define DW_MMC_CARD_RD_THR_EN (1 << 0)<br>
+<br>
+#define UHS_DDR_MODE (1 << 16)<br>
+<br>
+#define GENCLK_DIV 7<br>
+<br>
+#define DW_MMC_GPIO_CLK_DIV(x) (((x) & 0xf) << 8)<br>
+#define DW_MMC_GPIO_USE_SAMPLE_DLY(x) (((x) & 1) << 13)<br>
+#define DW_MMC_GPIO_CLK_ENABLE BIT16<br>
+<br>
+#define UHSEXT_SAMPLE_PHASE(x) (((x) & 0x1f) << 16)<br>
+#define UHSEXT_SAMPLE_DRVPHASE(x) (((x) & 0x1f) << 21)<br>
+#define UHSEXT_SAMPLE_DLY(x) (((x) & 0x1f) << 26)<br>
+<br>
+#define DWMMC_DMA_BUF_SIZE (512 * 8)<br>
+#define DWMMC_FIFO_THRESHOLD 16<br>
+<br>
+#define DWMMC_INIT_CLOCK_FREQ 400 /* KHz */<br>
+<br>
+//<br>
+// The transfer modes supported by SD Host Controller<br>
+// Simplified Spec 3.0 Table 1-2<br>
+//<br>
+typedef enum {<br>
+ SdMmcNoData,<br>
+ SdMmcPioMode,<br>
+ SdMmcSdmaMode,<br>
+ SdMmcAdmaMode<br>
+} DW_MMC_HC_TRANSFER_MODE;<br>
+<br>
+//<br>
+// The maximum data length of each descriptor line<br>
+//<br>
+#define ADMA_MAX_DATA_PER_LINE 0x10000<br>
+<br>
+typedef struct {<br>
+ UINT32 Des0;<br>
+ UINT32 Des1;<br>
+ UINT32 Des2;<br>
+ UINT32 Des3;<br>
+} DW_MMC_HC_DMA_DESC_LINE;<br>
+<br>
+#define SD_MMC_SDMA_BOUNDARY 512 * 1024<br>
+#define SD_MMC_SDMA_ROUND_UP(x, n) (((x) + n) & ~(n - 1))<br>
+<br>
+typedef struct {<br>
+ UINT8 FirstBar:3; // bit 0:2<br>
+ UINT8 Reserved:1; // bit 3<br>
+ UINT8 SlotNum:3; // bit 4:6<br>
+ UINT8 Reserved1:1; // bit 7<br>
+} DW_MMC_HC_SLOT_INFO;<br>
+<br>
+/**<br>
+ Dump the content of SD/MMC host controller's Capability Register.<br>
+<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The buffer to store the capability data.<br>
+<br>
+**/<br>
+VOID<br>
+DumpCapabilityReg (<br>
+ IN UINT8 Slot,<br>
+ IN DW_MMC_HC_SLOT_CAP *Capability<br>
+ );<br>
+<br>
+#if 0<br>
+/**<br>
+ Read SlotInfo register from SD/MMC host controller pci config space.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[out] FirstBar The buffer to store the first BAR value.<br>
+ @param[out] SlotNum The buffer to store the supported slot number.<br>
+<br>
+ @retval EFI_SUCCESS The operation succeeds.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcGetSlotInfo (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ OUT UINT8 *FirstBar,<br>
+ OUT UINT8 *SlotNum<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Read/Write specified SD/MMC host controller mmio register.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] BarIndex The BAR index of the standard PCI<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Configuration<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ header to use as the base address for the memory<br>
+ operation to perform.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Read A boolean to indicate it's read or write<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2 , 4 or 8 bytes.<br>
+ @param[in, out] Data For read operations, the destination buffer to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">store<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the results. For write operations, the source buffer<br>
+ to write data from. The caller is responsible for<br>
+ having ownership of the data buffer and ensuring its<br>
+ size not less than Count bytes.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER The PciIo or Data is NULL or the Count<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">is not valid.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_SUCCESS The read/write operation succeeds.<br>
+ @retval Others The read/write operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcRwMmio (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 BarIndex,<br>
+ IN UINT32 Offset,<br>
+ IN BOOLEAN Read,<br>
+ IN UINT8 Count,<br>
+ IN OUT VOID *Data<br>
+ );<br>
+#else<br>
+/**<br>
+ Read/Write specified SD/MMC host controller mmio register.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Read A boolean to indicate it's read or write<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2 , 4 or 8 bytes.<br>
+ @param[in, out] Data For read operations, the destination buffer to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">store<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the results. For write operations, the source buffer<br>
+ to write data from. The caller is responsible for<br>
+ having ownership of the data buffer and ensuring its<br>
+ size not less than Count bytes.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER The PciIo or Data is NULL or the Count<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">is not valid.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_SUCCESS The read/write operation succeeds.<br>
+ @retval Others The read/write operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcRwMmio (<br>
+ IN UINTN DevBase,<br>
+ IN UINT32 Offset,<br>
+ IN BOOLEAN Read,<br>
+ IN UINT8 Count,<br>
+ IN OUT VOID *Data<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Do OR operation with the value of the specified SD/MMC host controller<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">mmio register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] BarIndex The BAR index of the standard PCI<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Configuration<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ header to use as the base address for the memory<br>
+ operation to perform.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2 , 4 or 8 bytes.<br>
+ @param[in] OrData The pointer to the data used to do OR<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ The caller is responsible for having ownership of<br>
+ the data buffer and ensuring its size not less than<br>
+ Count bytes.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER The PciIo or OrData is NULL or the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Count is not valid.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_SUCCESS The OR operation succeeds.<br>
+ @retval Others The OR operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcOrMmio (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 BarIndex,<br>
+ IN UINT32 Offset,<br>
+ IN UINT8 Count,<br>
+ IN VOID *OrData<br>
+ );<br>
+#else<br>
+/**<br>
+ Do OR operation with the value of the specified SD/MMC host controller<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">mmio register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] BarIndex The BAR index of the standard PCI<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Configuration<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ header to use as the base address for the memory<br>
+ operation to perform.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2 , 4 or 8 bytes.<br>
+ @param[in] OrData The pointer to the data used to do OR<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ The caller is responsible for having ownership of<br>
+ the data buffer and ensuring its size not less than<br>
+ Count bytes.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER The PciIo or OrData is NULL or the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Count is not valid.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_SUCCESS The OR operation succeeds.<br>
+ @retval Others The OR operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcOrMmio (<br>
+ IN UINTN DevBase,<br>
+ IN UINT32 Offset,<br>
+ IN UINT8 Count,<br>
+ IN VOID *OrData<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Do AND operation with the value of the specified SD/MMC host<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller mmio register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] BarIndex The BAR index of the standard PCI<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Configuration<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ header to use as the base address for the memory<br>
+ operation to perform.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2 , 4 or 8 bytes.<br>
+ @param[in] AndData The pointer to the data used to do AND<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ The caller is responsible for having ownership of<br>
+ the data buffer and ensuring its size not less than<br>
+ Count bytes.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER The PciIo or AndData is NULL or the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Count is not valid.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_SUCCESS The AND operation succeeds.<br>
+ @retval Others The AND operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcAndMmio (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 BarIndex,<br>
+ IN UINT32 Offset,<br>
+ IN UINT8 Count,<br>
+ IN VOID *AndData<br>
+ );<br>
+#else<br>
+/**<br>
+ Do AND operation with the value of the specified SD/MMC host<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller mmio register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2 , 4 or 8 bytes.<br>
+ @param[in] AndData The pointer to the data used to do AND<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ The caller is responsible for having ownership of<br>
+ the data buffer and ensuring its size not less than<br>
+ Count bytes.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER The PciIo or AndData is NULL or the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Count is not valid.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_SUCCESS The AND operation succeeds.<br>
+ @retval Others The AND operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcAndMmio (<br>
+ IN UINTN DevBase,<br>
+ IN UINT32 Offset,<br>
+ IN UINT8 Count,<br>
+ IN VOID *AndData<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Wait for the value of the specified MMIO register set to the test value.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] BarIndex The BAR index of the standard PCI<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Configuration<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ header to use as the base address for the memory<br>
+ operation to perform.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2, 4 or 8 bytes.<br>
+ @param[in] MaskValue The mask value of memory.<br>
+ @param[in] TestValue The test value of memory.<br>
+ @param[in] Timeout The time out value for wait memory set, uses 1<br>
+ microsecond as a unit.<br>
+<br>
+ @retval EFI_TIMEOUT The MMIO register hasn't expected value in<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">timeout<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ range.<br>
+ @retval EFI_SUCCESS The MMIO register has expected value.<br>
+ @retval Others The MMIO operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcWaitMmioSet (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 BarIndex,<br>
+ IN UINT32 Offset,<br>
+ IN UINT8 Count,<br>
+ IN UINT64 MaskValue,<br>
+ IN UINT64 TestValue,<br>
+ IN UINT64 Timeout<br>
+ );<br>
+#else<br>
+/**<br>
+ Wait for the value of the specified MMIO register set to the test value.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Offset The offset within the selected BAR to start the<br>
+ memory operation.<br>
+ @param[in] Count The width of the mmio register in bytes.<br>
+ Must be 1, 2, 4 or 8 bytes.<br>
+ @param[in] MaskValue The mask value of memory.<br>
+ @param[in] TestValue The test value of memory.<br>
+ @param[in] Timeout The time out value for wait memory set, uses 1<br>
+ microsecond as a unit.<br>
+<br>
+ @retval EFI_TIMEOUT The MMIO register hasn't expected value in<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">timeout<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ range.<br>
+ @retval EFI_SUCCESS The MMIO register has expected value.<br>
+ @retval Others The MMIO operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcWaitMmioSet (<br>
+ IN UINTN DevBase,<br>
+ IN UINT32 Offset,<br>
+ IN UINT8 Count,<br>
+ IN UINT64 MaskValue,<br>
+ IN UINT64 TestValue,<br>
+ IN UINT64 Timeout<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Software reset the specified SD/MMC host controller.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The software reset executes successfully.<br>
+ @retval Others The software reset fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcReset (<br>
+fark<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#else<br>
+/**<br>
+ Software reset the specified SD/MMC host controller.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+<br>
+ @retval EFI_SUCCESS The software reset executes successfully.<br>
+ @retval Others The software reset fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcReset (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Set all interrupt status bits in Normal and Error Interrupt Status Enable<br>
+ register.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The operation executes successfully.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcEnableInterrupt (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot<br>
+ );<br>
+#else<br>
+/**<br>
+ Set all interrupt status bits in Normal and Error Interrupt Status Enable<br>
+ register.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The operation executes successfully.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcEnableInterrupt (<br>
+ IN UINTN DevBase<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Get the capability data from the specified slot.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[out] Capability The buffer to store the capability data.<br>
+<br>
+ @retval EFI_SUCCESS The operation executes successfully.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcGetCapability (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT DW_MMC_HC_SLOT_CAP *Capability<br>
+ );<br>
+#else<br>
+/**<br>
+ Get the capability data from the specified slot.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[out] Capability The buffer to store the capability data.<br>
+<br>
+ @retval EFI_SUCCESS The operation executes successfully.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcGetCapability (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT DW_MMC_HC_SLOT_CAP *Capability<br>
+ );<br>
+#endif<br>
+<br>
+#if 0<br>
+/**<br>
+ Get the maximum current capability data from the specified slot.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[out] MaxCurrent The buffer to store the maximum current<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">capability data.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The operation executes successfully.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcGetMaxCurrent (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ OUT UINT64 *MaxCurrent<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Detect whether there is a SD/MMC card attached at the specified<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD/MMC host controller<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ slot.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.1 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[out] MediaPresent The pointer to the media present boolean<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">value.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS There is no media change happened.<br>
+ @retval EFI_MEDIA_CHANGED There is media change happened.<br>
+ @retval Others The detection fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcCardDetect (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT BOOLEAN *MediaPresent<br>
+ );<br>
+#else<br>
+/**<br>
+ Detect whether there is a SD/MMC card attached at the specified<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD/MMC host controller<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ slot.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.1 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[out] MediaPresent The pointer to the media present boolean<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">value.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS There is no media change happened.<br>
+ @retval EFI_MEDIA_CHANGED There is media change happened.<br>
+ @retval Others The detection fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcCardDetect (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT BOOLEAN *MediaPresent<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Stop SD/MMC card clock.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS Succeed to stop SD/MMC clock.<br>
+ @retval Others Fail to stop SD/MMC clock.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcStopClock (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot<br>
+ );<br>
+<br>
+/**<br>
+ SD/MMC card clock supply.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.2.1 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] ClockFreq The max clock frequency to be set. The unit is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">KHz.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The clock is supplied successfully.<br>
+ @retval Others The clock isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcClockSupply (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN UINT64 ClockFreq,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#else<br>
+/**<br>
+ Stop SD/MMC card clock.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+<br>
+ @retval EFI_SUCCESS Succeed to stop SD/MMC clock.<br>
+ @retval Others Fail to stop SD/MMC clock.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcStopClock (<br>
+ IN UINTN DevBase<br>
+ );<br>
+<br>
+/**<br>
+ SD/MMC card clock supply.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.2.1 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] ClockFreq The max clock frequency to be set. The unit is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">KHz.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The clock is supplied successfully.<br>
+ @retval Others The clock isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcClockSupply (<br>
+ IN UINTN DevBase,<br>
+ IN UINT64 ClockFreq,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#endif<br>
+<br>
+#if 0<br>
+/**<br>
+ SD/MMC bus power control.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PowerCtrl The value setting to the power control register.<br>
+<br>
+ @retval TRUE There is a SD/MMC card attached.<br>
+ @retval FALSE There is no a SD/MMC card attached.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcPowerControl (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN UINT8 PowerCtrl<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Set the SD/MMC bus width.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.4 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] BusWidth The bus width used by the SD/MMC device, it<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">must be 1, 4 or 8.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The bus width is set successfully.<br>
+ @retval Others The bus width isn't set successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcSetBusWidth (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN BOOLEAN IsDdr,<br>
+ IN UINT16 BusWidth<br>
+ );<br>
+#else<br>
+/**<br>
+ Set the SD/MMC bus width.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.4 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] BusWidth The bus width used by the SD/MMC device, it<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">must be 1, 4 or 8.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The bus width is set successfully.<br>
+ @retval Others The bus width isn't set successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcSetBusWidth (<br>
+ IN UINTN DevBase,<br>
+ IN BOOLEAN IsDdr,<br>
+ IN UINT16 BusWidth<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Supply SD/MMC card with lowest clock frequency at initialization.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The clock is supplied successfully.<br>
+ @retval Others The clock isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitClockFreq (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#else<br>
+/**<br>
+ Supply SD/MMC card with lowest clock frequency at initialization.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The clock is supplied successfully.<br>
+ @retval Others The clock isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitClockFreq (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Supply SD/MMC card with maximum voltage at initialization.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The voltage is supplied successfully.<br>
+ @retval Others The voltage isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitPowerVoltage (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#else<br>
+/**<br>
+ Supply SD/MMC card with maximum voltage at initialization.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The voltage is supplied successfully.<br>
+ @retval Others The voltage isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitPowerVoltage (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Initialize the Timeout Control register with most conservative value at<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">initialization.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 2.2.15 for details.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The timeout control register is configured<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">successfully.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval Others The timeout control register isn't configured<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">successfully.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitTimeoutCtrl (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot<br>
+ );<br>
+#else<br>
+/**<br>
+ Initialize the Timeout Control register with most conservative value at<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">initialization.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 2.2.15 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The timeout control register is configured<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">successfully.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval Others The timeout control register isn't configured<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">successfully.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitTimeoutCtrl (<br>
+ IN UINTN DevBase<br>
+ );<br>
+#endif<br>
+<br>
+#ifdef DWMMC_PCI<br>
+/**<br>
+ Initial SD/MMC host controller with lowest clock frequency, max power<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">and max timeout value<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ at initialization.<br>
+<br>
+ @param[in] PciIo The PCI IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command to.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The host controller is initialized successfully.<br>
+ @retval Others The host controller isn't initialized successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitHost (<br>
+ IN EFI_PCI_IO_PROTOCOL *PciIo,<br>
+ IN UINT8 Slot,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#else<br>
+/**<br>
+ Initial SD/MMC host controller with lowest clock frequency, max power<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ max timeout value at initialization.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The host controller is initialized successfully.<br>
+ @retval Others The host controller isn't initialized successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitHost (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ );<br>
+#endif<br>
+<br>
+#endif /* _DW_MMC_HCI_H_ */<br>
diff --git a/EmbeddedPkg/Include/Protocol/PlatformDwMmc.h<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Include/Protocol/PlatformDwMmc.h<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..acbc3e153dac<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Include/Protocol/PlatformDwMmc.h<br>
@@ -0,0 +1,79 @@<br>
+/** @file<br>
+<br>
+ Copyright (c) 2018, Linaro. All rights reserved.<br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#ifndef __PLATFORM_DW_MMC_H__<br>
+#define __PLATFORM_DW_MMC_H__<br>
+<br>
+typedef enum {<br>
+ RemovableSlot,<br>
+ EmbeddedSlot,<br>
+ SharedBusSlot,<br>
+ UnknownSlot<br>
+} EFI_SD_MMC_SLOT_TYPE;<br>
+<br>
+typedef enum {<br>
+ UnknownCardType,<br>
+ SdCardType,<br>
+ SdioCardType,<br>
+ MmcCardType,<br>
+ EmmcCardType<br>
+} SD_MMC_CARD_TYPE;<br>
+<br>
+typedef struct {<br>
+ UINT32 DefaultSpeed:1; // bit 0<br>
+ UINT32 HighSpeed:1; // bit 1<br>
+ UINT32 Sdr12:1; // bit 2<br>
+ UINT32 Sdr25:1; // bit 3<br>
+ UINT32 Sdr50:1; // bit 4<br>
+ UINT32 Sdr104:1; // bit 5<br>
+ UINT32 Ddr50:1; // bit 6<br>
+ UINT32 SysBus64:1; // bit 7<br>
+ UINT32 BusWidth:4; // bit 11:8<br>
+ UINT32 SlotType:2; // bit 13:12<br>
+ UINT32 CardType:3; // bit 16:14<br>
+ UINT32 Voltage18:1; // bit 17<br>
+ UINT32 Voltage30:1; // bit 18<br>
+ UINT32 Voltage33:1; // bit 19<br>
+ UINT32 BaseClkFreq;<br>
+ EFI_HANDLE Controller;<br>
+} DW_MMC_HC_SLOT_CAP;<br>
+<br>
+//<br>
+// Protocol interface structure<br>
+//<br>
+typedef struct _PLATFORM_DW_MMC_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">PLATFORM_DW_MMC_PROTOCOL;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+typedef<br>
+EFI_STATUS<br>
+(EFIAPI *PLATFORM_DW_MMC_GET_CAPABILITY) (<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT DW_MMC_HC_SLOT_CAP *Capability<br>
+ );<br>
+<br>
+typedef<br>
+BOOLEAN<br>
+(EFIAPI *PLATFORM_DW_MMC_CARD_DETECT) (<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot<br>
+ );<br>
+<br>
+struct _PLATFORM_DW_MMC_PROTOCOL {<br>
+ PLATFORM_DW_MMC_GET_CAPABILITY GetCapability;<br>
+ PLATFORM_DW_MMC_CARD_DETECT CardDetect;<br>
+};<br>
+<br>
+extern EFI_GUID gPlatformDwMmcProtocolGuid;<br>
+<br>
+#endif /* __PLATFORM_DW_MMC_H__ */<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/ComponentName.c<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/ComponentName.c<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..1edade69d091<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/ComponentName.c<br>
@@ -0,0 +1,214 @@<br>
+/** @file<br>
+ UEFI Component Name(2) protocol implementation for Designware<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD/MMC host<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ controller driver.<br>
+<br>
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR><br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#include "DwMmcHcDxe.h"<br>
+<br>
+//<br>
+// EFI Component Name Protocol<br>
+//<br>
+GLOBAL_REMOVE_IF_UNREFERENCED<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_COMPONENT_NAME_PROTOCOL gDwMmcHcComponentName = {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DwMmcHcComponentNameGetDriverName,<br>
+ DwMmcHcComponentNameGetControllerName,<br>
+ "eng"<br>
+};<br>
+<br>
+//<br>
+// EFI Component Name 2 Protocol<br>
+//<br>
+GLOBAL_REMOVE_IF_UNREFERENCED<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_COMPONENT_NAME2_PROTOCOL gDwMmcHcComponentName2 = {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DwMmcHcComponentNameGetDriverName,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DwMmcHcComponentNameGetControllerName,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ "en"<br>
+};<br>
+<br>
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">mDwMmcHcDriverNameTable[] = {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ { "eng;en", L"Designware Sd/Mmc Host Controller Driver" },<br>
+ { NULL , NULL }<br>
+};<br>
+<br>
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">mDwMmcHcControllerNameTable[] = {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ { "eng;en", L"Designware Sd/Mmc Host Controller" },<br>
+ { NULL , NULL }<br>
+};<br>
+<br>
+/**<br>
+ Retrieves a Unicode string that is the user readable name of the driver.<br>
+<br>
+ This function retrieves the user readable name of a driver in the form of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Unicode string. If the driver specified by This has a user readable name in<br>
+ the language specified by Language, then a pointer to the driver name is<br>
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ by This does not support the language specified by Language,<br>
+ then EFI_UNSUPPORTED is returned.<br>
+<br>
+ @param This[in] A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_COMPONENT_NAME2_PROTOCOL or<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_COMPONENT_NAME_PROTOCOL instance.<br>
+<br>
+ @param Language[in] A pointer to a Null-terminated ASCII string<br>
+ array indicating the language. This is the<br>
+ language of the driver name that the caller is<br>
+ requesting, and it must match one of the<br>
+ languages specified in SupportedLanguages. The<br>
+ number of languages supported by a driver is up<br>
+ to the driver writer. Language is specified<br>
+ in RFC 4646 or ISO 639-2 language code format.<br>
+<br>
+ @param DriverName[out] A pointer to the Unicode string to return.<br>
+ This Unicode string is the name of the<br>
+ driver specified by This in the language<br>
+ specified by Language.<br>
+<br>
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by<br>
+ This and the language specified by Language was<br>
+ returned in DriverName.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER Language is NULL.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.<br>
+<br>
+ @retval EFI_UNSUPPORTED The driver specified by This does not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">support<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the language specified by Language.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcComponentNameGetDriverName (<br>
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,<br>
+ IN CHAR8 *Language,<br>
+ OUT CHAR16 **DriverName<br>
+ )<br>
+{<br>
+ return LookupUnicodeString2 (<br>
+ Language,<br>
+ This->SupportedLanguages,<br>
+ mDwMmcHcDriverNameTable,<br>
+ DriverName,<br>
+ (BOOLEAN)(This == &gDwMmcHcComponentName)<br>
+ );<br>
+}<br>
+<br>
+/**<br>
+ Retrieves a Unicode string that is the user readable name of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ that is being managed by a driver.<br>
+<br>
+ This function retrieves the user readable name of the controller specified<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">by<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ ControllerHandle and ChildHandle in the form of a Unicode string. If the<br>
+ driver specified by This has a user readable name in the language<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified by<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Language, then a pointer to the controller name is returned in<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerName,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ and EFI_SUCCESS is returned. If the driver specified by This is not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">currently<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ managing the controller specified by ControllerHandle and ChildHandle,<br>
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">not<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ support the language specified by Language, then EFI_UNSUPPORTED is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">returned.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param This[in] A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_COMPONENT_NAME2_PROTOCOL or<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_COMPONENT_NAME_PROTOCOL instance.<br>
+<br>
+ @param ControllerHandle[in] The handle of a controller that the driver<br>
+ specified by This is managing. This handle<br>
+ specifies the controller whose name is to be<br>
+ returned.<br>
+<br>
+ @param ChildHandle[in] The handle of the child controller to retrieve<br>
+ the name of. This is an optional parameter that<br>
+ may be NULL. It will be NULL for device<br>
+ drivers. It will also be NULL for a bus drivers<br>
+ that wish to retrieve the name of the bus<br>
+ controller. It will not be NULL for a bus<br>
+ driver that wishes to retrieve the name of a<br>
+ child controller.<br>
+<br>
+ @param Language[in] A pointer to a Null-terminated ASCII string<br>
+ array indicating the language. This is the<br>
+ language of the driver name that the caller is<br>
+ requesting, and it must match one of the<br>
+ languages specified in SupportedLanguages. The<br>
+ number of languages supported by a driver is up<br>
+ to the driver writer. Language is specified in<br>
+ RFC 4646 or ISO 639-2 language code format.<br>
+<br>
+ @param ControllerName[out] A pointer to the Unicode string to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">return.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ This Unicode string is the name of the<br>
+ controller specified by ControllerHandle and<br>
+ ChildHandle in the language specified by<br>
+ Language from the point of view of the driver<br>
+ specified by This.<br>
+<br>
+ @retval EFI_SUCCESS The Unicode string for the user readable<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">name in<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the language specified by Language for the<br>
+ driver specified by This was returned in<br>
+ DriverName.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_HANDLE.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">valid<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_HANDLE.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER Language is NULL.<br>
+<br>
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.<br>
+<br>
+ @retval EFI_UNSUPPORTED The driver specified by This is not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">currently<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ managing the controller specified by<br>
+ ControllerHandle and ChildHandle.<br>
+<br>
+ @retval EFI_UNSUPPORTED The driver specified by This does not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">support<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the language specified by Language.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcComponentNameGetControllerName (<br>
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,<br>
+ IN EFI_HANDLE ControllerHandle,<br>
+ IN EFI_HANDLE ChildHandle, OPTIONAL<br>
+ IN CHAR8 *Language,<br>
+ OUT CHAR16 **ControllerName<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+<br>
+ if (Language == NULL || ControllerName == NULL) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ //<br>
+ // This is a device driver, so ChildHandle must be NULL.<br>
+ //<br>
+ if (ChildHandle != NULL) {<br>
+ return EFI_UNSUPPORTED;<br>
+ }<br>
+<br>
+ //<br>
+ // Make sure this driver is currently managing ControllerHandle<br>
+ //<br>
+ Status = EfiTestManagedDevice (<br>
+ ControllerHandle,<br>
+ gDwMmcHcDriverBinding.DriverBindingHandle,<br>
+ &gEfiPciIoProtocolGuid<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ return LookupUnicodeString2 (<br>
+ Language,<br>
+ This->SupportedLanguages,<br>
+ mDwMmcHcControllerNameTable,<br>
+ ControllerName,<br>
+ (BOOLEAN)(This == &gDwMmcHcComponentName)<br>
+ );<br>
+}<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.c<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.c<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..aea12170d2cc<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.c<br>
@@ -0,0 +1,1296 @@<br>
+/** @file<br>
+ This driver is used to manage Designware SD/MMC host controller.<br>
+<br>
+ It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">use.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (C) 2016 Marvell International Ltd. All rigths reserved.<BR><br>
+ Copyright (C) 2018, Linaro Ltd. All rigths reserved.<BR><br>
+<br>
+ This program and the accompanying materials<br>
+ are licensed and made available under the terms and conditions of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BSD License<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ which accompanies this distribution. The full text of the license may be<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">found at<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#include <Library/BaseMemoryLib.h><br>
+#include <Library/DebugLib.h><br>
+#include <Library/DevicePathLib.h><br>
+#include <Library/IoLib.h><br>
+#include <Library/MemoryAllocationLib.h><br>
+#include <Protocol/NonDiscoverableDevice.h><br>
+#include <Library/UefiBootServicesTableLib.h><br>
+#include <Library/UefiDriverEntryPoint.h><br>
+<br>
+#include <Protocol/DevicePath.h><br>
+#include <Protocol/PlatformDwMmc.h><br>
+<br>
+#include "DwMmcHcDxe.h"<br>
+<br>
+//<br>
+// Driver Global Variables<br>
+//<br>
+EFI_DRIVER_BINDING_PROTOCOL gDwMmcHcDriverBinding = {<br>
+ DwMmcHcDriverBindingSupported,<br>
+ DwMmcHcDriverBindingStart,<br>
+ DwMmcHcDriverBindingStop,<br>
+ 0x10,<br>
+ NULL,<br>
+ NULL<br>
+};<br>
+<br>
+//<br>
+// Template for Designware SD/MMC host controller private data.<br>
+//<br>
+DW_MMC_HC_PRIVATE_DATA gDwMmcHcTemplate = {<br>
+ DW_MMC_HC_PRIVATE_SIGNATURE, // Signature<br>
+ NULL, // ControllerHandle<br>
+ 0x0, // Mmio base address<br>
+ { // PassThru<br>
+ sizeof (UINT32),<br>
+ DwMmcPassThruPassThru,<br>
+ DwMmcPassThruGetNextSlot,<br>
+ DwMmcPassThruBuildDevicePath,<br>
+ DwMmcPassThruGetSlotNumber,<br>
+ DwMmcPassThruResetDevice<br>
+ },<br>
+ NULL, // PlatformDwMmc<br>
+ 0, // PreviousSlot<br>
+ NULL, // TimerEvent<br>
+ NULL, // ConnectEvent<br>
+ // Queue<br>
+ INITIALIZE_LIST_HEAD_VARIABLE (gDwMmcHcTemplate.Queue),<br>
+ { // Slot<br>
+ {0, UnknownSlot, 0, 0, 0}<br>
+ },<br>
+ { // Capability<br>
+ {0}<br>
+ },<br>
+ { // MaxCurrent<br>
+ 0<br>
+ },<br>
+ 0 // ControllerVersion<br>
+};<br>
+<br>
+SD_DEVICE_PATH mSdDpTemplate = {<br>
+ {<br>
+ MESSAGING_DEVICE_PATH,<br>
+ MSG_SD_DP,<br>
+ {<br>
+ (UINT8) (sizeof (SD_DEVICE_PATH)),<br>
+ (UINT8) ((sizeof (SD_DEVICE_PATH)) >> 8)<br>
+ }<br>
+ },<br>
+ 0<br>
+};<br>
+<br>
+EMMC_DEVICE_PATH mEmmcDpTemplate = {<br>
+ {<br>
+ MESSAGING_DEVICE_PATH,<br>
+ MSG_EMMC_DP,<br>
+ {<br>
+ (UINT8) (sizeof (EMMC_DEVICE_PATH)),<br>
+ (UINT8) ((sizeof (EMMC_DEVICE_PATH)) >> 8)<br>
+ }<br>
+ },<br>
+ 0<br>
+};<br>
+<br>
+//<br>
+// Prioritized function list to detect card type.<br>
+// User could add other card detection logic here.<br>
+//<br>
+DWMMC_CARD_TYPE_DETECT_ROUTINE<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">mCardTypeDetectRoutineTable[] = {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EmmcIdentification,<br>
+ SdCardIdentification,<br>
+ NULL<br>
+};<br>
+<br>
+/**<br>
+ The entry point for SD host controller driver, used to install this driver on<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the ImageHandle.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param[in] ImageHandle The firmware allocated handle for this driver<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">image.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] SystemTable Pointer to the EFI system table.<br>
+<br>
+ @retval EFI_SUCCESS Driver loaded.<br>
+ @retval other Driver not loaded.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+InitializeDwMmcHcDxe (<br>
+ IN EFI_HANDLE ImageHandle,<br>
+ IN EFI_SYSTEM_TABLE *SystemTable<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+<br>
+ Status = EfiLibInstallDriverBindingComponentName2 (<br>
+ ImageHandle,<br>
+ SystemTable,<br>
+ &gDwMmcHcDriverBinding,<br>
+ ImageHandle,<br>
+ &gDwMmcHcComponentName,<br>
+ &gDwMmcHcComponentName2<br>
+ );<br>
+ ASSERT_EFI_ERROR (Status);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Call back function when the timer event is signaled.<br>
+<br>
+ @param[in] Event The Event this notify function registered to.<br>
+ @param[in] Context Pointer to the context data registered to the<br>
+ Event.<br>
+<br>
+**/<br>
+VOID<br>
+EFIAPI<br>
+ProcessAsyncTaskList (<br>
+ IN EFI_EVENT Event,<br>
+ IN VOID* Context<br>
+ )<br>
+{<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ LIST_ENTRY *Link;<br>
+ DW_MMC_HC_TRB *Trb;<br>
+ EFI_STATUS Status;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ BOOLEAN InfiniteWait;<br>
+ EFI_EVENT TrbEvent;<br>
+<br>
+ Private = (DW_MMC_HC_PRIVATE_DATA *)Context;<br>
+<br>
+ //<br>
+ // Check if the first entry in the async I/O queue is done or not.<br>
+ //<br>
+ Status = EFI_SUCCESS;<br>
+ Trb = NULL;<br>
+ Link = GetFirstNode (&Private->Queue);<br>
+ if (!IsNull (&Private->Queue, Link)) {<br>
+ Trb = DW_MMC_HC_TRB_FROM_THIS (Link);<br>
+ if (!Private->Slot[Trb->Slot].MediaPresent) {<br>
+ Status = EFI_NO_MEDIA;<br>
+ goto Done;<br>
+ }<br>
+ if (!Trb->Started) {<br>
+ //<br>
+ // Check whether the cmd/data line is ready for transfer.<br>
+ //<br>
+ Status = DwMmcCheckTrbEnv (Private, Trb);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ Trb->Started = TRUE;<br>
+ Status = DwMmcExecTrb (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+ } else {<br>
+ goto Done;<br>
+ }<br>
+ }<br>
+ Status = DwMmcCheckTrbResult (Private, Trb);<br>
+ }<br>
+<br>
+Done:<br>
+ if ((Trb != NULL) && (Status == EFI_NOT_READY)) {<br>
+ Packet = Trb->Packet;<br>
+ if (Packet->Timeout == 0) {<br>
+ InfiniteWait = TRUE;<br>
+ } else {<br>
+ InfiniteWait = FALSE;<br>
+ }<br>
+ if ((!InfiniteWait) && (Trb->Timeout-- == 0)) {<br>
+ RemoveEntryList (Link);<br>
+ Trb->Packet->TransactionStatus = EFI_TIMEOUT;<br>
+ TrbEvent = Trb->Event;<br>
+ DwMmcFreeTrb (Trb);<br>
+ DEBUG ((<br>
+ DEBUG_VERBOSE,<br>
+ "ProcessAsyncTaskList(): Signal Event %p EFI_TIMEOUT\n",<br>
+ TrbEvent<br>
+ ));<br>
+ gBS->SignalEvent (TrbEvent);<br>
+ return;<br>
+ }<br>
+ }<br>
+ if ((Trb != NULL) && (Status != EFI_NOT_READY)) {<br>
+ RemoveEntryList (Link);<br>
+ Trb->Packet->TransactionStatus = Status;<br>
+ TrbEvent = Trb->Event;<br>
+ DwMmcFreeTrb (Trb);<br>
+ DEBUG ((<br>
+ DEBUG_VERBOSE,<br>
+ "ProcessAsyncTaskList(): Signal Event %p with %r\n",<br>
+ TrbEvent,<br>
+ Status<br>
+ ));<br>
+ gBS->SignalEvent (TrbEvent);<br>
+ }<br>
+ return;<br>
+}<br>
+<br>
+/**<br>
+ Sd removable device enumeration callback function when the timer<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">event is signaled.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @param[in] Event The Event this notify function registered to.<br>
+ @param[in] Context Pointer to the context data registered to the<br>
+ Event.<br>
+<br>
+**/<br>
+VOID<br>
+EFIAPI<br>
+DwMmcHcEnumerateDevice (<br>
+ IN EFI_EVENT Event,<br>
+ IN VOID* Context<br>
+ )<br>
+{<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ EFI_STATUS Status;<br>
+ BOOLEAN MediaPresent;<br>
+ UINT32 RoutineNum;<br>
+ DWMMC_CARD_TYPE_DETECT_ROUTINE *Routine;<br>
+ UINTN Index;<br>
+ LIST_ENTRY *Link;<br>
+ LIST_ENTRY *NextLink;<br>
+ DW_MMC_HC_TRB *Trb;<br>
+ EFI_TPL OldTpl;<br>
+<br>
+ Private = (DW_MMC_HC_PRIVATE_DATA *)Context;<br>
+<br>
+ if ((Private->Slot[0].Enable) &&<br>
+ (Private->Slot[0].SlotType == RemovableSlot)) {<br>
+ Status = DwMmcHcCardDetect (<br>
+ Private->DevBase,<br>
+ Private->ControllerHandle,<br>
+ 0,<br>
+ &MediaPresent<br>
+ );<br>
+ if ((Status == EFI_MEDIA_CHANGED) && !MediaPresent) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "DwMmcHcEnumerateDevice: device disconnected at %p\n",<br>
+ Private->DevBase<br>
+ ));<br>
+ Private->Slot[0].MediaPresent = FALSE;<br>
+ //<br>
+ // Signal all async task events at the slot with EFI_NO_MEDIA status.<br>
+ //<br>
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);<br>
+ for (Link = GetFirstNode (&Private->Queue);<br>
+ !IsNull (&Private->Queue, Link);<br>
+ Link = NextLink) {<br>
+ NextLink = GetNextNode (&Private->Queue, Link);<br>
+ Trb = DW_MMC_HC_TRB_FROM_THIS (Link);<br>
+ if (Trb->Slot == 0) {<br>
+ RemoveEntryList (Link);<br>
+ Trb->Packet->TransactionStatus = EFI_NO_MEDIA;<br>
+ gBS->SignalEvent (Trb->Event);<br>
+ DwMmcFreeTrb (Trb);<br>
+ }<br>
+ }<br>
+ gBS->RestoreTPL (OldTpl);<br>
+ //<br>
+ // Notify the upper layer the connect state change through<br>
+ // ReinstallProtocolInterface.<br>
+ //<br>
+ gBS->ReinstallProtocolInterface (<br>
+ Private->ControllerHandle,<br>
+ &gEfiSdMmcPassThruProtocolGuid,<br>
+ &Private->PassThru,<br>
+ &Private->PassThru<br>
+ );<br>
+ }<br>
+ if ((Status == EFI_MEDIA_CHANGED) && MediaPresent) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "DwMmcHcEnumerateDevice: device connected at %p\n",<br>
+ Private->DevBase<br>
+ ));<br>
+ //<br>
+ // Initialize slot and start identification process for the new<br>
+ // attached device<br>
+ //<br>
+ Status = DwMmcHcInitHost (Private->DevBase, Private->Capability[0]);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return;<br>
+ }<br>
+ //<br>
+ // Reset the specified slot of the SD/MMC Pci Host Controller<br>
+ //<br>
+ Status = DwMmcHcReset (Private->DevBase, Private->Capability[0]);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return;<br>
+ }<br>
+<br>
+ Private->Slot[0].MediaPresent = TRUE;<br>
+ RoutineNum = sizeof (mCardTypeDetectRoutineTable) /<br>
+ sizeof (DWMMC_CARD_TYPE_DETECT_ROUTINE);<br>
+ for (Index = 0; Index < RoutineNum; Index++) {<br>
+ Routine = &mCardTypeDetectRoutineTable[Index];<br>
+ if (*Routine != NULL) {<br>
+ Status = (*Routine) (Private);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
+ //<br>
+ // This card doesn't get initialized correctly.<br>
+ //<br>
+ if (Index == RoutineNum) {<br>
+ return;<br>
+ }<br>
+<br>
+ //<br>
+ // Notify the upper layer the connect state change through<br>
+ // ReinstallProtocolInterface.<br>
+ //<br>
+ gBS->ReinstallProtocolInterface (<br>
+ Private->ControllerHandle,<br>
+ &gEfiSdMmcPassThruProtocolGuid,<br>
+ &Private->PassThru,<br>
+ &Private->PassThru<br>
+ );<br>
+ }<br>
+ }<br>
+<br>
+ return;<br>
+}<br>
+<br>
+/**<br>
+ Reset the specified SD/MMC host controller and enable all interrupts.<br>
+<br>
+ @param[in] DevBase The Mmio Device Base Address.<br>
+<br>
+ @retval EFI_SUCCESS The software reset executes successfully.<br>
+ @retval Others The software reset fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcReset (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT32 BlkSize;<br>
+<br>
+ //<br>
+ // Enable all interrupt after reset all.<br>
+ //<br>
+ Status = DwMmcHcEnableInterrupt (DevBase);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((DEBUG_ERROR, "DwMmcHcReset: enable interrupts fail:<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">%r\n", Status));<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return Status;<br>
+ }<br>
+ Status = DwMmcHcInitTimeoutCtrl (DevBase);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ BlkSize = DW_MMC_BLOCK_SIZE;<br>
+ MmioWrite32 (DevBase + DW_MMC_BLKSIZ, BlkSize);<br>
+<br>
+ Status = DwMmcHcInitClockFreq (DevBase, Capability);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = DwMmcHcSetBusWidth (DevBase, FALSE, 1);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Tests to see if this driver supports a given controller. If a child device<br>
+ is provided, it further tests to see if this driver supports creating a<br>
+ handle for the specified child device.<br>
+<br>
+ This function checks to see if the driver specified by This supports the<br>
+ device specified by ControllerHandle. Drivers will typically use the device<br>
+ path attached to ControllerHandle and/or the services from the bus I/O<br>
+ abstraction attached to ControllerHandle to determine if the driver<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">supports<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ ControllerHandle. This function may be called many times during<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">platform<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ initialization. In order to reduce boot times, the tests performed by this<br>
+ function must be very small, and take as little time as possible to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">execute.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ This function must not change the state of any hardware devices, and<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ function must be aware that the device specified by ControllerHandle<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">may<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ already be managed by the same driver or a different driver. This<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">function<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ must match its calls to AllocatePages() with FreePages(), AllocatePool()<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">with<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ FreePool(), and OpenProtocol() with CloseProtocol(). Since<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ may have been previously started by the same driver, if a protocol is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">already<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ in the opened state, then it must not be closed with CloseProtocol(). This<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ required to guarantee the state of ControllerHandle is not modified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ function.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DRIVER_BINDING_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] ControllerHandle The handle of the controller to test. This<br>
+ handle must support a protocol interface that<br>
+ supplies an I/O abstraction to the driver.<br>
+ @param[in] RemainingDevicePath A pointer to the remaining portion of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ device path. This parameter is ignored by<br>
+ device drivers, and is optional for bus<br>
+ drivers. For bus drivers, if this parameter<br>
+ is not NULL, then the bus driver must deter-<br>
+ mine if the bus controller specified by<br>
+ ControllerHandle and the child controller<br>
+ specified by RemainingDevicePath are both<br>
+ supported by this bus driver.<br>
+<br>
+ @retval EFI_SUCCESS The device specified by ControllerHandle<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is supported by the<br>
+ driver specified by This.<br>
+ @retval EFI_ALREADY_STARTED The device specified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is already being managed<br>
+ by the driver specified by This.<br>
+ @retval EFI_ACCESS_DENIED The device specified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is already being managed<br>
+ by a different driver or an application that<br>
+ requires exclusive access.<br>
+ Currently not implemented.<br>
+ @retval EFI_UNSUPPORTED The device specified by<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ControllerHandle and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ RemainingDevicePath is not supported by the<br>
+ driver specified by This.<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcDriverBindingSupported (<br>
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;<br>
+ NON_DISCOVERABLE_DEVICE *Dev;<br>
+ PLATFORM_DW_MMC_PROTOCOL *PlatformDwMmc;<br>
+<br>
+ ParentDevicePath = NULL;<br>
+<br>
+ Status = gBS->LocateProtocol (<br>
+ &gPlatformDwMmcProtocolGuid,<br>
+ NULL,<br>
+ (VOID **) &PlatformDwMmc<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = gBS->OpenProtocol (<br>
+ Controller,<br>
+ &gEfiDevicePathProtocolGuid,<br>
+ (VOID *) &ParentDevicePath,<br>
+ This->DriverBindingHandle,<br>
+ Controller,<br>
+ EFI_OPEN_PROTOCOL_BY_DRIVER<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ //<br>
+ // EFI_ALREADY_STARTED is also an error.<br>
+ //<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Close the protocol because we don't use it here.<br>
+ //<br>
+ gBS->CloseProtocol (<br>
+ Controller,<br>
+ &gEfiDevicePathProtocolGuid,<br>
+ This->DriverBindingHandle,<br>
+ Controller<br>
+ );<br>
+<br>
+ //<br>
+ // Now test the EmbeddedNonDiscoverableIoProtocol.<br>
+ //<br>
+ Status = gBS->OpenProtocol (<br>
+ Controller,<br>
+ &gEdkiiNonDiscoverableDeviceProtocolGuid,<br>
+ (VOID **) &Dev,<br>
+ This->DriverBindingHandle,<br>
+ Controller,<br>
+ EFI_OPEN_PROTOCOL_BY_DRIVER<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ gBS->CloseProtocol (<br>
+ Controller,<br>
+ &gEdkiiNonDiscoverableDeviceProtocolGuid,<br>
+ This->DriverBindingHandle,<br>
+ Controller<br>
+ );<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Starts a device controller or a bus controller.<br>
+<br>
+ The Start() function is designed to be invoked from the EFI boot service<br>
+ ConnectController().<br>
+ As a result, much of the error checking on the parameters to Start() has<br>
+ been moved into this<br>
+ common boot service. It is legal to call Start() from other locations,<br>
+ but the following calling restrictions must be followed or the system<br>
+ behavior will not be deterministic.<br>
+ 1. ControllerHandle must be a valid EFI_HANDLE.<br>
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a<br>
+ naturally aligned EFI_DEVICE_PATH_PROTOCOL.<br>
+ 3. Prior to calling Start(), the Supported() function for the driver<br>
+ specified by This must have been called with the same calling<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">parameters,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ and Supported() must have returned EFI_SUCCESS.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DRIVER_BINDING_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] ControllerHandle The handle of the controller to start.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">This<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ handle must support a protocol interface<br>
+ that supplies an I/O abstraction to the<br>
+ driver.<br>
+ @param[in] RemainingDevicePath A pointer to the remaining portion of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ device path. This parameter is ignored by<br>
+ device drivers, and is optional for bus<br>
+ drivers.<br>
+ For a bus driver, if this parameter is NULL,<br>
+ then handles for all the children of<br>
+ Controller are created by this driver.<br>
+ If this parameter is not NULL and the first<br>
+ Device Path Node is not the End of Device<br>
+ Path Node, then only the handle for the<br>
+ child device specified by the first Device<br>
+ Path Node of RemainingDevicePath is created<br>
+ by this driver.<br>
+ If the first Device Path Node of<br>
+ RemainingDevicePath is the End of Device Path<br>
+ Node, no child handle is created by this<br>
+ driver.<br>
+<br>
+ @retval EFI_SUCCESS The device was started.<br>
+ @retval EFI_DEVICE_ERROR The device could not be started due to a<br>
+ device error. Currently not implemented.<br>
+ @retval EFI_OUT_OF_RESOURCES The request could not be<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">completed due to a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ lack of resources.<br>
+ @retval Others The driver failded to start the device.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcDriverBindingStart (<br>
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+<br>
+ NON_DISCOVERABLE_DEVICE *Dev;<br>
+<br>
+ BOOLEAN MediaPresent;<br>
+ DWMMC_CARD_TYPE_DETECT_ROUTINE *Routine;<br>
+ UINT8 Index;<br>
+ UINT32 RoutineNum;<br>
+ PLATFORM_DW_MMC_PROTOCOL *PlatformDwMmc;<br>
+<br>
+ Status = gBS->LocateProtocol (<br>
+ &gPlatformDwMmcProtocolGuid,<br>
+ NULL,<br>
+ (VOID **) &PlatformDwMmc<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((DEBUG_ERROR, "err %d", __LINE__));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = gBS->OpenProtocol (<br>
+ Controller,<br>
+ &gEdkiiNonDiscoverableDeviceProtocolGuid,<br>
+ (VOID **) &Dev,<br>
+ This->DriverBindingHandle,<br>
+ Controller,<br>
+ EFI_OPEN_PROTOCOL_BY_DRIVER<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((DEBUG_ERROR, "err %d", __LINE__));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Private = AllocateCopyPool (sizeof (DW_MMC_HC_PRIVATE_DATA),<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">&gDwMmcHcTemplate);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (Private == NULL) {<br>
+ DEBUG ((DEBUG_ERROR, "err %d", __LINE__));<br>
+ Status = EFI_OUT_OF_RESOURCES;<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Private->ControllerHandle = Controller;<br>
+ Private->DevBase = Dev->Resources[0].AddrRangeMin;<br>
+ Private->PlatformDwMmc = PlatformDwMmc;<br>
+ InitializeListHead (&Private->Queue);<br>
+<br>
+ Status = Private->PlatformDwMmc->GetCapability (Controller, 0,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">&Private->Capability[0]);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ if (Private->Capability[0].BaseClkFreq == 0) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ DumpCapabilityReg (0, &Private->Capability[0]);<br>
+<br>
+ MediaPresent = FALSE;<br>
+<br>
+ Status = Private->PlatformDwMmc->CardDetect (Controller, 0);<br>
+ Status = DwMmcHcCardDetect (Private->DevBase, Controller, 0,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">&MediaPresent);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (MediaPresent == FALSE) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ //<br>
+ // Initialize slot and start identification process for the new attached<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ Status = DwMmcHcInitHost (Private->DevBase, Private->Capability[0]);<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ //<br>
+ // Reset HC<br>
+ //<br>
+ Status = DwMmcHcReset (Private->DevBase, Private->Capability[0]);<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Private->Slot[0].CardType = Private->Capability[0].CardType;<br>
+ Private->Slot[0].Enable = TRUE;<br>
+ Private->Slot[0].MediaPresent = TRUE;<br>
+<br>
+ RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">(DWMMC_CARD_TYPE_DETECT_ROUTINE);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ for (Index = 0; Index < RoutineNum; Index++) {<br>
+ Routine = &mCardTypeDetectRoutineTable[Index];<br>
+ if (*Routine != NULL) {<br>
+ Status = (*Routine) (Private);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ //<br>
+ // Start the asynchronous I/O monitor<br>
+ //<br>
+ Status = gBS->CreateEvent (<br>
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,<br>
+ TPL_NOTIFY,<br>
+ ProcessAsyncTaskList,<br>
+ Private,<br>
+ &Private->TimerEvent<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Status = gBS->SetTimer (Private->TimerEvent, TimerPeriodic,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_HC_ASYNC_TIMER);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ //<br>
+ // Start the Sd removable device connection enumeration<br>
+ //<br>
+ Status = gBS->CreateEvent (<br>
+ EVT_TIMER | EVT_NOTIFY_SIGNAL,<br>
+ TPL_CALLBACK,<br>
+ DwMmcHcEnumerateDevice,<br>
+ Private,<br>
+ &Private->ConnectEvent<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Status = gBS->SetTimer (Private->ConnectEvent, TimerPeriodic,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_HC_ENUM_TIMER);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Status = gBS->InstallMultipleProtocolInterfaces (<br>
+ &Controller,<br>
+ &gEfiSdMmcPassThruProtocolGuid,<br>
+ &(Private->PassThru),<br>
+ NULL<br>
+ );<br>
+<br>
+ DEBUG ((DEBUG_INFO, "DwMmcHcDriverBindingStart: %r End on %x\n",<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Status, Controller));<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+Done:<br>
+ if (EFI_ERROR (Status)) {<br>
+ if ((Private != NULL) && (Private->TimerEvent != NULL)) {<br>
+ gBS->CloseEvent (Private->TimerEvent);<br>
+ }<br>
+<br>
+ if ((Private != NULL) && (Private->ConnectEvent != NULL)) {<br>
+ gBS->CloseEvent (Private->ConnectEvent);<br>
+ }<br>
+<br>
+ if (Private != NULL) {<br>
+ FreePool (Private);<br>
+ }<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Stops a device controller or a bus controller.<br>
+<br>
+ The Stop() function is designed to be invoked from the EFI boot service<br>
+ DisconnectController().<br>
+ As a result, much of the error checking on the parameters to Stop() has<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">been<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ moved into this common boot service. It is legal to call Stop() from other<br>
+ locations, but the following calling restrictions must be followed or the<br>
+ system behavior will not be deterministic.<br>
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">previous<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ call to this same driver's Start() function.<br>
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">valid<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ EFI_HANDLE. In addition, all of these handles must have been created<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">in<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ this driver's Start() function, and the Start() function must have called<br>
+ OpenProtocol() on ControllerHandle with an Attribute of<br>
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DRIVER_BINDING_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] ControllerHandle A handle to the device being stopped.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">The handle<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ must support a bus specific I/O protocol for the<br>
+ driver to use to stop the device.<br>
+ @param[in] NumberOfChildren The number of child device handles in<br>
+ ChildHandleBuffer.<br>
+ @param[in] ChildHandleBuffer An array of child handles to be freed.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">May be<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ NULL if NumberOfChildren is 0.<br>
+<br>
+ @retval EFI_SUCCESS The device was stopped.<br>
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ error.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcHcDriverBindingStop (<br>
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINTN NumberOfChildren,<br>
+ IN EFI_HANDLE *ChildHandleBuffer<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ LIST_ENTRY *Link;<br>
+ LIST_ENTRY *NextLink;<br>
+ DW_MMC_HC_TRB *Trb;<br>
+<br>
+ DEBUG ((DEBUG_INFO, "DwMmcHcDriverBindingStop: Start\n"));<br>
+<br>
+ Status = gBS->OpenProtocol (<br>
+ Controller,<br>
+ &gEfiSdMmcPassThruProtocolGuid,<br>
+ (VOID**) &PassThru,<br>
+ This->DriverBindingHandle,<br>
+ Controller,<br>
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (PassThru);<br>
+ //<br>
+ // Close Non-Blocking timer and free Task list.<br>
+ //<br>
+ if (Private->TimerEvent != NULL) {<br>
+ gBS->CloseEvent (Private->TimerEvent);<br>
+ Private->TimerEvent = NULL;<br>
+ }<br>
+ if (Private->ConnectEvent != NULL) {<br>
+ gBS->CloseEvent (Private->ConnectEvent);<br>
+ Private->ConnectEvent = NULL;<br>
+ }<br>
+ //<br>
+ // As the timer is closed, there is no needs to use TPL lock to<br>
+ // protect the critical region "queue".<br>
+ //<br>
+ for (Link = GetFirstNode (&Private->Queue);<br>
+ !IsNull (&Private->Queue, Link);<br>
+ Link = NextLink) {<br>
+ NextLink = GetNextNode (&Private->Queue, Link);<br>
+ RemoveEntryList (Link);<br>
+ Trb = DW_MMC_HC_TRB_FROM_THIS (Link);<br>
+ Trb->Packet->TransactionStatus = EFI_ABORTED;<br>
+ gBS->SignalEvent (Trb->Event);<br>
+ DwMmcFreeTrb (Trb);<br>
+ }<br>
+<br>
+ //<br>
+ // Uninstall Block I/O protocol from the device handle<br>
+ //<br>
+ Status = gBS->UninstallProtocolInterface (<br>
+ Controller,<br>
+ &gEfiSdMmcPassThruProtocolGuid,<br>
+ &(Private->PassThru)<br>
+ );<br>
+<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ gBS->CloseProtocol (<br>
+ Controller,<br>
+ &gEfiPciIoProtocolGuid,<br>
+ This->DriverBindingHandle,<br>
+ Controller<br>
+ );<br>
+<br>
+ FreePool (Private);<br>
+<br>
+ DEBUG ((DEBUG_INFO, "DwMmcHcDriverBindingStop: End with %r\n",<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Status));<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Sends SD command to an SD card that is attached to the SD controller.<br>
+<br>
+ The PassThru() function sends the SD command specified by Packet to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the SD<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ card specified by Slot.<br>
+<br>
+ If Packet is successfully sent to the SD card, then EFI_SUCCESS is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">returned.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ If a device error occurs while sending the Packet, then<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_DEVICE_ERROR is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned.<br>
+<br>
+ If Slot is not in a valid range for the SD controller, then<br>
+ EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If Packet defines a data command but both InDataBuffer and<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">OutDataBuffer are<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ NULL, EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<br>
+ command to.<br>
+ @param[in,out] Packet A pointer to the SD command data structure.<br>
+ @param[in] Event If Event is NULL, blocking I/O is performed. If<br>
+ Event is not NULL, then nonblocking I/O is<br>
+ performed, and Event will be signaled when the<br>
+ Packet completes.<br>
+<br>
+ @retval EFI_SUCCESS The SD Command Packet was sent by the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">host.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_DEVICE_ERROR A device error occurred while attempting<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">to send<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the SD command Packet.<br>
+ @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Packet is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ invalid.<br>
+ @retval EFI_INVALID_PARAMETER Packet defines a data command but<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">both<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ InDataBuffer and OutDataBuffer are NULL.<br>
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.<br>
+ @retval EFI_UNSUPPORTED The command described by the SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Command Packet<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ is not supported by the host controller.<br>
+ @retval EFI_BAD_BUFFER_SIZE The InTransferLength or<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">OutTransferLength<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ exceeds the limit supported by SD card<br>
+ ( i.e. if the number of bytes exceed the Last<br>
+ LBA).<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruPassThru (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN UINT8 Slot,<br>
+ IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,<br>
+ IN EFI_EVENT Event OPTIONAL<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ DW_MMC_HC_TRB *Trb;<br>
+ EFI_TPL OldTpl;<br>
+<br>
+ if ((This == NULL) || (Packet == NULL)) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if ((Packet->SdMmcCmdBlk == NULL) || (Packet->SdMmcStatusBlk ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">NULL)) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if ((Packet->OutDataBuffer == NULL) && (Packet->OutTransferLength !=<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">0)) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if ((Packet->InDataBuffer == NULL) && (Packet->InTransferLength != 0))<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">{<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (This);<br>
+<br>
+ if (!Private->Slot[Slot].Enable) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if (!Private->Slot[Slot].MediaPresent) {<br>
+ return EFI_NO_MEDIA;<br>
+ }<br>
+<br>
+ Trb = DwMmcCreateTrb (Private, Slot, Packet, Event);<br>
+ if (Trb == NULL) {<br>
+ return EFI_OUT_OF_RESOURCES;<br>
+ }<br>
+ //<br>
+ // Immediately return for async I/O.<br>
+ //<br>
+ if (Event != NULL) {<br>
+ return EFI_SUCCESS;<br>
+ }<br>
+<br>
+ //<br>
+ // Wait async I/O list is empty before execute sync I/O operation.<br>
+ //<br>
+ while (TRUE) {<br>
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);<br>
+ if (IsListEmpty (&Private->Queue)) {<br>
+ gBS->RestoreTPL (OldTpl);<br>
+ break;<br>
+ }<br>
+ gBS->RestoreTPL (OldTpl);<br>
+ }<br>
+<br>
+ Status = DwMmcWaitTrbEnv (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Status = DwMmcExecTrb (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+ Status = DwMmcWaitTrbResult (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ goto Done;<br>
+ }<br>
+<br>
+Done:<br>
+ if (Trb != NULL) {<br>
+ DwMmcFreeTrb (Trb);<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Used to retrieve next slot numbers supported by the SD controller. The<br>
+ function returns information about all available slots (populated or<br>
+ not-populated).<br>
+<br>
+ The GetNextSlot() function retrieves the next slot number on an SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ If on input Slot is 0xFF, then the slot number of the first slot on the SD<br>
+ controller is returned.<br>
+<br>
+ If Slot is a slot number that was returned on a previous call to<br>
+ GetNextSlot(), then the slot number of the next slot on the SD controller<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned.<br>
+<br>
+ If Slot is not 0xFF and Slot was not returned on a previous call to<br>
+ GetNextSlot(), EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If Slot is the slot number of the last slot on the SD controller, then<br>
+ EFI_NOT_FOUND is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in,out] Slot On input, a pointer to a slot number on the SD<br>
+ controller.<br>
+ On output, a pointer to the next slot number on<br>
+ the SD controller.<br>
+ An input value of 0xFF retrieves the first slot<br>
+ number on the SD controller.<br>
+<br>
+ @retval EFI_SUCCESS The next slot number on the SD controller<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">was<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned in Slot.<br>
+ @retval EFI_NOT_FOUND There are no more slots on this SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">controller.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">returned on a<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ previous call to GetNextSlot().<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruGetNextSlot (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN OUT UINT8 *Slot<br>
+ )<br>
+{<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+<br>
+ if ((This == NULL) || (Slot == NULL)) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (This);<br>
+<br>
+ if (*Slot == 0xFF) {<br>
+ if (Private->Slot[0].Enable) {<br>
+ *Slot = 0;<br>
+ Private->PreviousSlot = 0;<br>
+ return EFI_SUCCESS;<br>
+ }<br>
+ return EFI_NOT_FOUND;<br>
+ } else if (*Slot == Private->PreviousSlot) {<br>
+ return EFI_NOT_FOUND;<br>
+ } else {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+}<br>
+<br>
+/**<br>
+ Used to allocate and build a device path node for an SD card on the SD<br>
+ controller.<br>
+<br>
+ The BuildDevicePath() function allocates and builds a single device node<br>
+ for the SD card specified by Slot.<br>
+<br>
+ If the SD card specified by Slot is not present on the SD controller, then<br>
+ EFI_NOT_FOUND is returned.<br>
+<br>
+ If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If there are not enough resources to allocate the device path node, then<br>
+ EFI_OUT_OF_RESOURCES is returned.<br>
+<br>
+ Otherwise, DevicePath is allocated with the boot service AllocatePool(),<br>
+ the contents of DevicePath are initialized to describe the SD card<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ by Slot, and EFI_SUCCESS is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot Specifies the slot number of the SD card for<br>
+ which a device path node is to be allocated and<br>
+ built.<br>
+ @param[in,out] DevicePath A pointer to a single device path node that<br>
+ describes the SD card specified by Slot. This<br>
+ function is responsible for allocating the<br>
+ buffer DevicePath with the boot service<br>
+ AllocatePool(). It is the caller's responsi-<br>
+ bility to free DevicePath when the caller is<br>
+ finished with DevicePath.<br>
+<br>
+ @retval EFI_SUCCESS The device path node that describes the SD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">card<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ specified by Slot was allocated and returned in<br>
+ DevicePath.<br>
+ @retval EFI_NOT_FOUND The SD card specified by Slot does not<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">exist on<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the SD controller.<br>
+ @retval EFI_INVALID_PARAMETER DevicePath is NULL.<br>
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">allocate<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DevicePath.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruBuildDevicePath (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN UINT8 Slot,<br>
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath<br>
+ )<br>
+{<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ SD_DEVICE_PATH *SdNode;<br>
+ EMMC_DEVICE_PATH *EmmcNode;<br>
+<br>
+ if ((This == NULL) || (DevicePath == NULL) || (Slot >=<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_HC_MAX_SLOT)) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (This);<br>
+<br>
+ if ((!Private->Slot[Slot].Enable) || (!Private->Slot[Slot].MediaPresent)) {<br>
+ return EFI_NOT_FOUND;<br>
+ }<br>
+<br>
+ if (Private->Slot[Slot].CardType == SdCardType) {<br>
+ SdNode = AllocateCopyPool (sizeof (SD_DEVICE_PATH),<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">&mSdDpTemplate);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (SdNode == NULL) {<br>
+ return EFI_OUT_OF_RESOURCES;<br>
+ }<br>
+ SdNode->SlotNumber = Slot;<br>
+<br>
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) SdNode;<br>
+ } else if (Private->Slot[Slot].CardType == EmmcCardType) {<br>
+ EmmcNode = AllocateCopyPool (sizeof (EMMC_DEVICE_PATH),<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">&mEmmcDpTemplate);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EmmcNode == NULL) {<br>
+ return EFI_OUT_OF_RESOURCES;<br>
+ }<br>
+ EmmcNode->SlotNumber = Slot;<br>
+<br>
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) EmmcNode;<br>
+ } else {<br>
+ //<br>
+ // Currently we only support SD and EMMC two device nodes.<br>
+ //<br>
+ return EFI_NOT_FOUND;<br>
+ }<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ This function retrieves an SD card slot number based on the input device<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">path.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ The GetSlotNumber() function retrieves slot number for the SD card<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">specified<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ by the DevicePath node. If DevicePath is NULL,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_INVALID_PARAMETER is<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ returned.<br>
+<br>
+ If DevicePath is not a device path node type that the SD Pass Thru driver<br>
+ supports, EFI_UNSUPPORTED is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] DevicePath A pointer to the device path node that<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">describes<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ a SD card on the SD controller.<br>
+ @param[out] Slot On return, points to the slot number of an SD<br>
+ card on the SD controller.<br>
+<br>
+ @retval EFI_SUCCESS SD card slot number is returned in Slot.<br>
+ @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.<br>
+ @retval EFI_UNSUPPORTED DevicePath is not a device path node<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">type that<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the SD Pass Thru driver supports.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruGetSlotNumber (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,<br>
+ OUT UINT8 *Slot<br>
+ )<br>
+{<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ SD_DEVICE_PATH *SdNode;<br>
+ EMMC_DEVICE_PATH *EmmcNode;<br>
+ UINT8 SlotNumber;<br>
+<br>
+ if ((This == NULL) || (DevicePath == NULL) || (Slot == NULL)) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (This);<br>
+<br>
+ //<br>
+ // Check whether the DevicePath belongs to SD_DEVICE_PATH or<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EMMC_DEVICE_PATH<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||<br>
+ ((DevicePath->SubType != MSG_SD_DP) &&<br>
+ (DevicePath->SubType != MSG_EMMC_DP)) ||<br>
+ (DevicePathNodeLength(DevicePath) != sizeof(SD_DEVICE_PATH)) ||<br>
+ (DevicePathNodeLength(DevicePath) !=<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">sizeof(EMMC_DEVICE_PATH))) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return EFI_UNSUPPORTED;<br>
+ }<br>
+<br>
+ if (DevicePath->SubType == MSG_SD_DP) {<br>
+ SdNode = (SD_DEVICE_PATH *) DevicePath;<br>
+ SlotNumber = SdNode->SlotNumber;<br>
+ } else {<br>
+ EmmcNode = (EMMC_DEVICE_PATH *) DevicePath;<br>
+ SlotNumber = EmmcNode->SlotNumber;<br>
+ }<br>
+<br>
+ if (SlotNumber >= DW_MMC_HC_MAX_SLOT) {<br>
+ return EFI_NOT_FOUND;<br>
+ }<br>
+<br>
+ if (Private->Slot[SlotNumber].Enable) {<br>
+ *Slot = SlotNumber;<br>
+ return EFI_SUCCESS;<br>
+ } else {<br>
+ return EFI_NOT_FOUND;<br>
+ }<br>
+}<br>
+<br>
+/**<br>
+ Resets an SD card that is connected to the SD controller.<br>
+<br>
+ The ResetDevice() function resets the SD card specified by Slot.<br>
+<br>
+ If this SD controller does not support a device reset operation,<br>
+ EFI_UNSUPPORTED is returned.<br>
+<br>
+ If Slot is not in a valid slot number for this SD controller,<br>
+ EFI_INVALID_PARAMETER is returned.<br>
+<br>
+ If the device reset operation is completed, EFI_SUCCESS is returned.<br>
+<br>
+ @param[in] This A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot Specifies the slot number of the SD card to be<br>
+ reset.<br>
+<br>
+ @retval EFI_SUCCESS The SD card specified by Slot was reset.<br>
+ @retval EFI_UNSUPPORTED The SD controller does not support a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ reset operation.<br>
+ @retval EFI_INVALID_PARAMETER Slot number is invalid.<br>
+ @retval EFI_NO_MEDIA SD Device not present in the Slot.<br>
+ @retval EFI_DEVICE_ERROR The reset command failed due to a device<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">error<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+DwMmcPassThruResetDevice (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,<br>
+ IN UINT8 Slot<br>
+ )<br>
+{<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ LIST_ENTRY *Link;<br>
+ LIST_ENTRY *NextLink;<br>
+ DW_MMC_HC_TRB *Trb;<br>
+ EFI_TPL OldTpl;<br>
+<br>
+ if (This == NULL) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (This);<br>
+<br>
+ if (!Private->Slot[Slot].Enable) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if (!Private->Slot[Slot].MediaPresent) {<br>
+ return EFI_NO_MEDIA;<br>
+ }<br>
+<br>
+ //<br>
+ // Free all async I/O requests in the queue<br>
+ //<br>
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);<br>
+<br>
+ for (Link = GetFirstNode (&Private->Queue);<br>
+ !IsNull (&Private->Queue, Link);<br>
+ Link = NextLink) {<br>
+ NextLink = GetNextNode (&Private->Queue, Link);<br>
+ RemoveEntryList (Link);<br>
+ Trb = DW_MMC_HC_TRB_FROM_THIS (Link);<br>
+ Trb->Packet->TransactionStatus = EFI_ABORTED;<br>
+ gBS->SignalEvent (Trb->Event);<br>
+ DwMmcFreeTrb (Trb);<br>
+ }<br>
+<br>
+ gBS->RestoreTPL (OldTpl);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.c<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.c<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..b091f9803b2e<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHci.c<br>
@@ -0,0 +1,1602 @@<br>
+/** @file<br>
+ This driver is used to manage Designware SD/MMC PCI host controllers.<br>
+<br>
+ It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">use.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR><br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#include <IndustryStandard/Emmc.h><br>
+#include <IndustryStandard/Sd.h><br>
+<br>
+#include <Library/ArmLib.h><br>
+#include <Library/BaseMemoryLib.h><br>
+#include <Library/DmaLib.h><br>
+#include <Library/IoLib.h><br>
+#include <Library/DebugLib.h><br>
+#include <Library/MemoryAllocationLib.h><br>
+#include <Library/UefiBootServicesTableLib.h><br>
+<br>
+#include "DwMmcHcDxe.h"<br>
+<br>
+/**<br>
+ Dump the content of SD/MMC host controller's Capability Register.<br>
+<br>
+ @param[in] Slot The slot number of the SD card to send the<br>
+ command to.<br>
+ @param[in] Capability The buffer to store the capability data.<br>
+<br>
+**/<br>
+VOID<br>
+DumpCapabilityReg (<br>
+ IN UINT8 Slot,<br>
+ IN DW_MMC_HC_SLOT_CAP *Capability<br>
+ )<br>
+{<br>
+ //<br>
+ // Dump Capability Data<br>
+ //<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " == Slot [%d] Capability is 0x%x ==\n",<br>
+ Slot,<br>
+ Capability<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " Base Clk Freq %dKHz\n",<br>
+ Capability->BaseClkFreq<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " BusWidth %d\n",<br>
+ Capability->BusWidth<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " HighSpeed Support %a\n",<br>
+ Capability->HighSpeed ? "TRUE" : "FALSE"<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " Voltage 1.8 %a\n",<br>
+ Capability->Voltage18 ? "TRUE" : "FALSE"<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " 64-bit Sys Bus %a\n",<br>
+ Capability->SysBus64 ? "TRUE" : "FALSE"<br>
+ ));<br>
+ DEBUG ((DEBUG_INFO, " SlotType "));<br>
+ if (Capability->SlotType == 0x00) {<br>
+ DEBUG ((DEBUG_INFO, "%a\n", "Removable Slot"));<br>
+ } else if (Capability->SlotType == 0x01) {<br>
+ DEBUG ((DEBUG_INFO, "%a\n", "Embedded Slot"));<br>
+ } else if (Capability->SlotType == 0x02) {<br>
+ DEBUG ((DEBUG_INFO, "%a\n", "Shared Bus Slot"));<br>
+ } else {<br>
+ DEBUG ((DEBUG_INFO, "%a\n", "Reserved"));<br>
+ }<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " SDR50 Support %a\n",<br>
+ Capability->Sdr50 ? "TRUE" : "FALSE"<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " SDR104 Support %a\n",<br>
+ Capability->Sdr104 ? "TRUE" : "FALSE"<br>
+ ));<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ " DDR50 Support %a\n",<br>
+ Capability->Ddr50 ? "TRUE" : "FALSE"<br>
+ ));<br>
+ return;<br>
+}<br>
+<br>
+/**<br>
+ Set all interrupt status bits in Normal and Error Interrupt Status Enable<br>
+ register.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+<br>
+ @retval EFI_SUCCESS The operation executes successfully.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcEnableInterrupt (<br>
+ UINTN DevBase<br>
+ )<br>
+{<br>
+ UINT32 IntStatus;<br>
+ UINT32 IdIntEn;<br>
+ UINT32 IdSts;<br>
+<br>
+ //<br>
+ // Enable all bits in Interrupt Mask Register<br>
+ //<br>
+ IntStatus = 0;<br>
+ MmioWrite32 (DevBase + DW_MMC_INTMASK, IntStatus);<br>
+<br>
+ //<br>
+ // Clear status in Interrupt Status Register<br>
+ //<br>
+ IntStatus = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_RINTSTS, IntStatus);<br>
+<br>
+ IdIntEn = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_IDINTEN, IdIntEn);<br>
+<br>
+ IdSts = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_IDSTS, IdSts);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+DwMmcHcGetCapability (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT DW_MMC_HC_SLOT_CAP *Capacity<br>
+ )<br>
+{<br>
+ PLATFORM_DW_MMC_PROTOCOL *PlatformDwMmc;<br>
+ EFI_STATUS Status;<br>
+<br>
+ if (Capacity == NULL) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+ Status = gBS->LocateProtocol (<br>
+ &gPlatformDwMmcProtocolGuid,<br>
+ NULL,<br>
+ (VOID **) &PlatformDwMmc<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ Status = PlatformDwMmc->GetCapability (Controller, Slot, Capacity);<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Detect whether there is a SD/MMC card attached at the specified<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD/MMC host<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ controller slot.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.1 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ to.<br>
+ @param[out] MediaPresent The pointer to the media present boolean<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">value.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS There is no media change happened.<br>
+ @retval EFI_MEDIA_CHANGED There is media change happened.<br>
+ @retval Others The detection fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcCardDetect (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_HANDLE Controller,<br>
+ IN UINT8 Slot,<br>
+ OUT BOOLEAN *MediaPresent<br>
+ )<br>
+{<br>
+ PLATFORM_DW_MMC_PROTOCOL *PlatformDwMmc;<br>
+ EFI_STATUS Status;<br>
+<br>
+ if (MediaPresent == NULL) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+ Status = gBS->LocateProtocol (<br>
+ &gPlatformDwMmcProtocolGuid,<br>
+ NULL,<br>
+ (VOID **) &PlatformDwMmc<br>
+ );<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ *MediaPresent = PlatformDwMmc->CardDetect (Controller, Slot);<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+STATIC<br>
+EFI_STATUS<br>
+DwMmcHcUpdateClock (<br>
+ IN UINTN DevBase<br>
+ )<br>
+{<br>
+ UINT32 Cmd;<br>
+ UINT32 IntStatus;<br>
+<br>
+ Cmd = BIT_CMD_WAIT_PRVDATA_COMPLETE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_UPDATE_CLOCK_ONLY |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_START;<br>
+ MmioWrite32 (DevBase + DW_MMC_CMD, Cmd);<br>
+<br>
+ while (1) {<br>
+ Cmd = MmioRead32 (DevBase + DW_MMC_CMD);<br>
+<br>
+ if (!(Cmd & CMD_START_BIT)) {<br>
+ break;<br>
+ }<br>
+<br>
+ IntStatus = MmioRead32 (DevBase + DW_MMC_RINTSTS);<br>
+<br>
+ if (IntStatus & DW_MMC_INT_HLE) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "DwMmcHcUpdateClock: failed to update mmc clock frequency\n"<br>
+ ));<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ }<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Stop SD/MMC card clock.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+<br>
+ @retval EFI_SUCCESS Succeed to stop SD/MMC clock.<br>
+ @retval Others Fail to stop SD/MMC clock.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcStopClock (<br>
+ IN UINTN DevBase<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT32 ClkEna;<br>
+<br>
+ //<br>
+ // Disable MMC clock first<br>
+ //<br>
+ ClkEna = 0;<br>
+ MmioWrite32 (DevBase + DW_MMC_CLKENA, ClkEna);<br>
+<br>
+ Status = DwMmcHcUpdateClock (DevBase);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ SD/MMC card clock supply.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] ClockFreq The max clock frequency to be set. The unit is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">KHz.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The clock is supplied successfully.<br>
+ @retval Others The clock isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcClockSupply (<br>
+ IN UINTN DevBase,<br>
+ IN UINT64 ClockFreq,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT32 BaseClkFreq;<br>
+ UINT32 SettingFreq;<br>
+ UINT32 Divisor;<br>
+ UINT32 Remainder;<br>
+ UINT32 MmcStatus;<br>
+ UINT32 ClkEna;<br>
+ UINT32 ClkSrc;<br>
+<br>
+ //<br>
+ // Calculate a divisor for SD clock frequency<br>
+ //<br>
+ ASSERT (Capability.BaseClkFreq != 0);<br>
+<br>
+ BaseClkFreq = Capability.BaseClkFreq;<br>
+ if (ClockFreq == 0) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if (ClockFreq > BaseClkFreq) {<br>
+ ClockFreq = BaseClkFreq;<br>
+ }<br>
+<br>
+ //<br>
+ // Calculate the divisor of base frequency.<br>
+ //<br>
+ Divisor = 0;<br>
+ SettingFreq = BaseClkFreq;<br>
+ while (ClockFreq < SettingFreq) {<br>
+ Divisor++;<br>
+<br>
+ SettingFreq = BaseClkFreq / (2 * Divisor);<br>
+ Remainder = BaseClkFreq % (2 * Divisor);<br>
+ if ((ClockFreq == SettingFreq) && (Remainder == 0)) {<br>
+ break;<br>
+ }<br>
+ if ((ClockFreq == SettingFreq) && (Remainder != 0)) {<br>
+ SettingFreq ++;<br>
+ }<br>
+ }<br>
+<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "BaseClkFreq %dKHz Divisor %d ClockFreq %dKhz\n",<br>
+ BaseClkFreq,<br>
+ Divisor,<br>
+ ClockFreq<br>
+ ));<br>
+<br>
+ //<br>
+ // Wait until MMC is idle<br>
+ //<br>
+ do {<br>
+ MmcStatus = MmioRead32 (DevBase + DW_MMC_STATUS);<br>
+ } while (MmcStatus & DW_MMC_STS_DATA_BUSY);<br>
+<br>
+ do {<br>
+ Status = DwMmcHcStopClock (DevBase);<br>
+ } while (EFI_ERROR (Status));<br>
+<br>
+ do {<br>
+ ClkSrc = 0;<br>
+ MmioWrite32 (DevBase + DW_MMC_CLKSRC, ClkSrc);<br>
+ //<br>
+ // Set clock divisor<br>
+ //<br>
+ MmioWrite32 (DevBase + DW_MMC_CLKDIV, Divisor);<br>
+ //<br>
+ // Enable MMC clock<br>
+ //<br>
+ ClkEna = 1;<br>
+ MmioWrite32 (DevBase + DW_MMC_CLKENA, ClkEna);<br>
+<br>
+ Status = DwMmcHcUpdateClock (DevBase);<br>
+ } while (EFI_ERROR (Status));<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Set the SD/MMC bus width.<br>
+<br>
+ Refer to SD Host Controller Simplified spec 3.0 Section 3.4 for details.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] IsDdr A boolean to indicate it's dual data rate or not.<br>
+ @param[in] BusWidth The bus width used by the SD/MMC device, it<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">must be<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ 1, 4 or 8.<br>
+<br>
+ @retval EFI_SUCCESS The bus width is set successfully.<br>
+ @retval Others The bus width isn't set successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcSetBusWidth (<br>
+ IN UINTN DevBase,<br>
+ IN BOOLEAN IsDdr,<br>
+ IN UINT16 BusWidth<br>
+ )<br>
+{<br>
+ UINT32 Ctype;<br>
+ UINT32 Uhs;<br>
+<br>
+ switch (BusWidth) {<br>
+ case 1:<br>
+ Ctype = MMC_1BIT_MODE;<br>
+ break;<br>
+ case 4:<br>
+ Ctype = MMC_4BIT_MODE;<br>
+ break;<br>
+ case 8:<br>
+ Ctype = MMC_8BIT_MODE;<br>
+ break;<br>
+ default:<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+ MmioWrite32 (DevBase + DW_MMC_CTYPE, Ctype);<br>
+<br>
+ Uhs = MmioRead32 (DevBase + DW_MMC_UHSREG);<br>
+<br>
+ if (IsDdr) {<br>
+ Uhs |= UHS_DDR_MODE;<br>
+ } else {<br>
+ Uhs &= ~(UHS_DDR_MODE);<br>
+ }<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_UHSREG, Uhs);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Supply SD/MMC card with lowest clock frequency at initialization.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The clock is supplied successfully.<br>
+ @retval Others The clock isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitClockFreq (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT32 InitFreq;<br>
+<br>
+ //<br>
+ // Calculate a divisor for SD clock frequency<br>
+ //<br>
+ if (Capability.BaseClkFreq == 0) {<br>
+ //<br>
+ // Don't support get Base Clock Frequency information via another<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">method<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ return EFI_UNSUPPORTED;<br>
+ }<br>
+ //<br>
+ // Supply 400KHz clock frequency at initialization phase.<br>
+ //<br>
+ InitFreq = DWMMC_INIT_CLOCK_FREQ;<br>
+ Status = DwMmcHcClockSupply (DevBase, InitFreq, Capability);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ MicroSecondDelay (100);<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Supply SD/MMC card with maximum voltage at initialization.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The voltage is supplied successfully.<br>
+ @retval Others The voltage isn't supplied successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitPowerVoltage (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ )<br>
+{<br>
+ UINT32 Data;<br>
+ UINT32 Timeout;<br>
+<br>
+ Data = 0x1;<br>
+ MmioWrite32 (DevBase + DW_MMC_PWREN, Data);<br>
+<br>
+ Data = DW_MMC_CTRL_RESET_ALL;<br>
+ MmioWrite32 (DevBase + DW_MMC_CTRL, Data);<br>
+<br>
+ Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+ while (Timeout > 0) {<br>
+ Data = MmioRead32 (DevBase + DW_MMC_CTRL);<br>
+<br>
+ if ((Data & DW_MMC_CTRL_RESET_ALL) == 0) {<br>
+ break;<br>
+ }<br>
+ gBS->Stall (1);<br>
+<br>
+ Timeout--;<br>
+ }<br>
+<br>
+ if (Timeout <= 0) {<br>
+ DEBUG ((DEBUG_INFO,<br>
+ "DwMmcHcInitPowerVoltage: reset failed due to timeout"));<br>
+<br>
+ return EFI_TIMEOUT;<br>
+ }<br>
+<br>
+ Data = DW_MMC_CTRL_INT_EN;<br>
+ MmioWrite32 (DevBase + DW_MMC_CTRL, Data);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Initialize the Timeout Control register with most conservative value at<br>
+ initialization.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+<br>
+ @retval EFI_SUCCESS The timeout control register is configured<br>
+ successfully.<br>
+ @retval Others The timeout control register isn't configured<br>
+ successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitTimeoutCtrl (<br>
+ IN UINTN DevBase<br>
+ )<br>
+{<br>
+ UINT32 Data;<br>
+<br>
+ Data = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_TMOUT, Data);<br>
+<br>
+ Data = 0x00FFFFFF;<br>
+ MmioWrite32 (DevBase + DW_MMC_DEBNCE, Data);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Initial SD/MMC host controller with lowest clock frequency, max power<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">and<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ max timeout value at initialization.<br>
+<br>
+ @param[in] DevIo The DEVICE IO protocol instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ to.<br>
+ @param[in] Capability The capability of the slot.<br>
+<br>
+ @retval EFI_SUCCESS The host controller is initialized successfully.<br>
+ @retval Others The host controller isn't initialized successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcHcInitHost (<br>
+ IN UINTN DevBase,<br>
+ IN DW_MMC_HC_SLOT_CAP Capability<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+<br>
+ Status = DwMmcHcInitPowerVoltage (DevBase, Capability);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ return Status;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+DwMmcHcStartDma (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ UINTN DevBase;<br>
+ UINT32 Ctrl;<br>
+ UINT32 Bmod;<br>
+ UINT32 Timeout;<br>
+ UINT32 Data;<br>
+<br>
+// DevIo = Trb->Private->DevIo;<br>
+ DevBase = Trb->Private->DevBase;<br>
+<br>
+ //<br>
+ // Reset DMA<br>
+ //<br>
+ Ctrl = DW_MMC_CTRL_DMA_RESET;<br>
+ MmioWrite32 (DevBase + DW_MMC_CTRL, Ctrl);<br>
+<br>
+ Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+ while (Timeout > 0) {<br>
+ Data = MmioRead32 (DevBase + DW_MMC_CTRL);<br>
+<br>
+ if ((Data & DW_MMC_CTRL_DMA_RESET) == 0) {<br>
+ break;<br>
+ }<br>
+ gBS->Stall (1);<br>
+<br>
+ Timeout--;<br>
+ }<br>
+<br>
+ if (Timeout <= 0) {<br>
+ DEBUG ((DEBUG_ERROR, "Timed out waiting for CTRL_DMA_RESET"));<br>
+<br>
+ return EFI_TIMEOUT;<br>
+ }<br>
+<br>
+ Bmod = DW_MMC_IDMAC_SWRESET | MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_BMOD);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ MmioWrite32 (DevBase + DW_MMC_BMOD, Bmod);<br>
+<br>
+ //<br>
+ // Select IDMAC<br>
+ //<br>
+ Ctrl = DW_MMC_CTRL_IDMAC_EN;<br>
+ Ctrl |= MmioRead32 (DevBase + DW_MMC_CTRL);<br>
+ MmioWrite32 (DevBase + DW_MMC_CTRL, Ctrl);<br>
+<br>
+ //<br>
+ // Enable IDMAC<br>
+ //<br>
+ Bmod = DW_MMC_IDMAC_ENABLE | DW_MMC_IDMAC_FB;<br>
+ Bmod |= MmioRead32 (DevBase + DW_MMC_BMOD);<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_BMOD, Bmod);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+DwMmcHcStopDma (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ UINTN DevBase;<br>
+ UINT32 Ctrl;<br>
+ UINT32 Bmod;<br>
+<br>
+ DevBase = Trb->Private->DevBase;<br>
+<br>
+ //<br>
+ // Disable and reset IDMAC<br>
+ //<br>
+ Ctrl = MmioRead32 (DevBase + DW_MMC_CTRL);<br>
+ Ctrl &= ~DW_MMC_CTRL_IDMAC_EN;<br>
+ Ctrl |= DW_MMC_CTRL_DMA_RESET;<br>
+ MmioWrite32 (DevBase + DW_MMC_CTRL, Ctrl);<br>
+<br>
+ //<br>
+ // Stop IDMAC<br>
+ //<br>
+ Bmod = MmioRead32 (DevBase + DW_MMC_BMOD);<br>
+ Bmod &= ~(DW_MMC_BMOD_FB | DW_MMC_BMOD_DE);<br>
+ Bmod |= DW_MMC_BMOD_SWR;<br>
+ MmioWrite32 (DevBase + DW_MMC_BMOD, Bmod);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Build DMA descriptor table for transfer.<br>
+<br>
+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The DMA descriptor table is created<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">successfully.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @retval Others The DMA descriptor table isn't created successfully.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+BuildDmaDescTable (<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_PHYSICAL_ADDRESS Data;<br>
+ UINT64 DataLen;<br>
+ UINT64 Entries;<br>
+ UINT32 Index;<br>
+ UINT64 Remaining;<br>
+ UINTN TableSize;<br>
+ UINTN DevBase;<br>
+ EFI_STATUS Status;<br>
+ UINTN Bytes;<br>
+ UINTN Blocks;<br>
+ DW_MMC_HC_DMA_DESC_LINE *DmaDesc;<br>
+ UINT32 DmaDescPhy;<br>
+ UINT32 Idsts;<br>
+ UINT32 BytCnt;<br>
+ UINT32 BlkSize;<br>
+<br>
+ Data = Trb->DataPhy;<br>
+ DataLen = Trb->DataLen;<br>
+ DevBase = Trb->Private->DevBase;<br>
+ //<br>
+ // Only support 32bit DMA Descriptor Table<br>
+ //<br>
+ if ((Data >= 0x100000000ul) || ((Data + DataLen) > 0x100000000ul)) {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+ //<br>
+ // Address field shall be set on 32-bit boundary (Lower 2-bit is always set<br>
+ // to 0) for 32-bit address descriptor table.<br>
+ //<br>
+ if ((Data & (BIT0 | BIT1)) != 0) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "The buffer [0x%x] to construct DMA desc is not aligned to 4 bytes!\n",<br>
+ Data<br>
+ ));<br>
+ }<br>
+<br>
+ Entries = (DataLen + DWMMC_DMA_BUF_SIZE - 1) /<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DWMMC_DMA_BUF_SIZE;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ TableSize = Entries * sizeof (DW_MMC_HC_DMA_DESC_LINE);<br>
+ Blocks = (DataLen + DW_MMC_BLOCK_SIZE - 1) /<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_BLOCK_SIZE;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Trb->DmaDescPages = (UINT32)EFI_SIZE_TO_PAGES (Entries *<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DWMMC_DMA_BUF_SIZE);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+/* Status = DevIo->AllocateBuffer (<br>
+ DevIo,<br>
+ AllocateAnyPages,<br>
+ EfiBootServicesData,<br>
+ EFI_SIZE_TO_PAGES (TableSize),<br>
+ (EFI_PHYSICAL_ADDRESS *)&Trb->DmaDesc<br>
+ );*/<br>
+ Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">(TableSize),<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ (VOID *)&Trb->DmaDesc);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return EFI_OUT_OF_RESOURCES;<br>
+ }<br>
+<br>
+ ZeroMem (Trb->DmaDesc, TableSize);<br>
+ Bytes = TableSize;<br>
+<br>
+ Status = DmaMap (MapOperationBusMasterCommonBuffer,<br>
+ (EFI_PHYSICAL_ADDRESS *)Trb->DmaDesc,<br>
+ &Bytes, &Trb->DmaDescPhy, &Trb->DmaMap);<br>
+/* Status = DevIo->Map (<br>
+ DevIo,<br>
+ EfiBusMasterCommonBuffer,<br>
+ (EFI_PHYSICAL_ADDRESS *)Trb->DmaDesc,<br>
+ &Bytes,<br>
+ &Trb->DmaDescPhy,<br>
+ &Trb->DmaMap<br>
+ );*/<br>
+<br>
+ if (EFI_ERROR (Status) || (Bytes != TableSize)) {<br>
+ //<br>
+ // Map error or unable to map the whole RFis buffer into a contiguous<br>
+ // region.<br>
+ //<br>
+/* DevIo->FreeBuffer (<br>
+ DevIo,<br>
+ EFI_SIZE_TO_PAGES (TableSize),<br>
+ (EFI_PHYSICAL_ADDRESS)Trb->DmaDesc<br>
+ );*/<br>
+ return EFI_OUT_OF_RESOURCES;<br>
+ }<br>
+<br>
+ if ((UINT64)(UINTN)Trb->DmaDescPhy > 0x100000000ul) {<br>
+ //<br>
+ // The DMA doesn't support 64bit addressing.<br>
+ //<br>
+ DmaUnmap (Trb->DmaMap);<br>
+/* DevIo->Unmap (<br>
+ DevIo,<br>
+ Trb->DmaMap<br>
+ );*/<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+<br>
+ if (DataLen < DW_MMC_BLOCK_SIZE) {<br>
+ BlkSize = DataLen;<br>
+ BytCnt = DataLen;<br>
+ Remaining = DataLen;<br>
+ } else {<br>
+ BlkSize = DW_MMC_BLOCK_SIZE;<br>
+ BytCnt = DW_MMC_BLOCK_SIZE * Blocks;<br>
+ Remaining = DW_MMC_BLOCK_SIZE * Blocks;<br>
+ }<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_BLKSIZ, BlkSize);<br>
+ MmioWrite32 (DevBase + DW_MMC_BYTCNT, BytCnt);<br>
+ DmaDesc = Trb->DmaDesc;<br>
+ for (Index = 0; Index < Entries; Index++, DmaDesc++) {<br>
+ DmaDesc->Des0 = DW_MMC_IDMAC_DES0_OWN |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_IDMAC_DES0_CH |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DW_MMC_IDMAC_DES0_DIC;<br>
+ DmaDesc->Des1 = DW_MMC_IDMAC_DES1_BS1<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">(DWMMC_DMA_BUF_SIZE);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ // Buffer Address<br>
+ //<br>
+ DmaDesc->Des2 = (UINT32)((UINTN)Trb->DataPhy +<br>
+ (DWMMC_DMA_BUF_SIZE * Index));<br>
+ //<br>
+ // Next Descriptor Address<br>
+ //<br>
+ DmaDesc->Des3 = (UINT32)((UINTN)Trb->DmaDescPhy +<br>
+ sizeof (DW_MMC_HC_DMA_DESC_LINE) * (Index + 1));<br>
+ Remaining = Remaining - DWMMC_DMA_BUF_SIZE;<br>
+ }<br>
+ //<br>
+ // First Descriptor<br>
+ //<br>
+ Trb->DmaDesc[0].Des0 |= DW_MMC_IDMAC_DES0_FS;<br>
+ //<br>
+ // Last Descriptor<br>
+ //<br>
+ Trb->DmaDesc[Entries - 1].Des0 &= ~(DW_MMC_IDMAC_DES0_CH |<br>
+ DW_MMC_IDMAC_DES0_DIC);<br>
+ Trb->DmaDesc[Entries - 1].Des0 |= DW_MMC_IDMAC_DES0_OWN |<br>
+ DW_MMC_IDMAC_DES0_LD;<br>
+ Trb->DmaDesc[Entries - 1].Des1 = DW_MMC_IDMAC_DES1_BS1<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">(Remaining +<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DWMMC_DMA_BUF_SIZE);<br>
+ //<br>
+ // Set the next field of the Last Descriptor<br>
+ //<br>
+ Trb->DmaDesc[Entries - 1].Des3 = 0;<br>
+ DmaDescPhy = (UINT32)Trb->DmaDescPhy;<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_DBADDR, DmaDescPhy);<br>
+<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+ //<br>
+ // Clear interrupts<br>
+ //<br>
+ Idsts = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_IDSTS, Idsts);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+TransferFifo (<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ UINTN DevBase;<br>
+ UINT32 Data;<br>
+ UINT32 Received;<br>
+ UINT32 Count;<br>
+ UINT32 Intsts;<br>
+ UINT32 Sts;<br>
+ UINT32 FifoCount;<br>
+ UINT32 Index; /* count with bytes */<br>
+ UINT32 Ascending;<br>
+ UINT32 Descending;<br>
+<br>
+ DevBase = Trb->Private->DevBase;<br>
+ Received = 0;<br>
+ Count = 0;<br>
+ Index = 0;<br>
+ Ascending = 0;<br>
+ Descending = ((Trb->DataLen + 3) & ~3) - 4;<br>
+ do {<br>
+ Intsts = MmioRead32 (DevBase + DW_MMC_RINTSTS);<br>
+<br>
+ if (Trb->DataLen && (Intsts & DW_MMC_INT_TXDR) && !Trb->Read) {<br>
+ Sts = MmioRead32 (DevBase + DW_MMC_STATUS);<br>
+<br>
+ while (!(DW_MMC_STS_FIFO_FULL(Sts))<br>
+ && (Received < Trb->DataLen)<br>
+ && (Intsts & DW_MMC_INT_TXDR)) {<br>
+ if (Trb->UseBE) {<br>
+ Data = SwapBytes32 (*(UINT32 *)((UINTN)Trb->Data + Descending));<br>
+ Descending = Descending - 4;<br>
+ } else {<br>
+ Data = *(UINT32 *)((UINTN)Trb->Data + Ascending);<br>
+ Ascending += 4;<br>
+ }<br>
+ Index += 4;<br>
+ Received += 4;<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_FIFO_START, Data);<br>
+<br>
+ Intsts = DW_MMC_INT_TXDR;<br>
+ MmioWrite32 (DevBase + DW_MMC_RINTSTS, Intsts);<br>
+<br>
+ Intsts = MmioRead32 (DevBase + DW_MMC_RINTSTS);<br>
+ Sts = MmioRead32 (DevBase + DW_MMC_STATUS);<br>
+ }<br>
+ continue;<br>
+ }<br>
+<br>
+ if (Trb->DataLen && ((Intsts & DW_MMC_INT_RXDR) ||<br>
+ (Intsts & DW_MMC_INT_DTO)) && Trb->Read) {<br>
+ Sts = MmioRead32 (DevBase + DW_MMC_STATUS);<br>
+ //<br>
+ // Convert to bytes<br>
+ //<br>
+ FifoCount = GET_STS_FIFO_COUNT (Sts) << 2;<br>
+ if ((FifoCount == 0) && (Received < Trb->DataLen)) {<br>
+ continue;<br>
+ }<br>
+ Index = 0;<br>
+ Count = (MIN (FifoCount, Trb->DataLen) + 3) & ~3;<br>
+ while (Index < Count) {<br>
+ Data = MmioRead32 (DevBase + DW_MMC_FIFO_START);<br>
+<br>
+ if (Trb->UseBE) {<br>
+ *(UINT32 *)((UINTN)Trb->Data + Descending) = SwapBytes32 (Data);<br>
+ Descending = Descending - 4;<br>
+ } else {<br>
+ *(UINT32 *)((UINTN)Trb->Data + Ascending) = Data;<br>
+ Ascending += 4;<br>
+ }<br>
+ Index += 4;<br>
+ Received += 4;<br>
+ } /* while */<br>
+ } /* if */<br>
+ } while (((Intsts & DW_MMC_INT_CMD_DONE) == 0) || (Received < Trb-<br>
DataLen));<br>
+ //<br>
+ // Clear RINTSTS<br>
+ //<br>
+ Intsts = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_RINTSTS, Intsts);<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Create a new TRB for the SD/MMC cmd request.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ to.<br>
+ @param[in] Packet A pointer to the SD command data structure.<br>
+ @param[in] Event If Event is NULL, blocking I/O is performed. If<br>
+ Event is not NULL, then nonblocking I/O is<br>
+ performed, and Event will be signaled when the<br>
+ Packet completes.<br>
+<br>
+ @return Created Trb or NULL.<br>
+<br>
+**/<br>
+DW_MMC_HC_TRB *<br>
+DwMmcCreateTrb (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN UINT8 Slot,<br>
+ IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet,<br>
+ IN EFI_EVENT Event<br>
+ )<br>
+{<br>
+ DW_MMC_HC_TRB *Trb;<br>
+ EFI_STATUS Status;<br>
+ EFI_TPL OldTpl;<br>
+ EFI_IO_OPERATION_TYPE Flag;<br>
+ UINTN MapLength;<br>
+<br>
+ Trb = AllocateZeroPool (sizeof (DW_MMC_HC_TRB));<br>
+ if (Trb == NULL) {<br>
+ return NULL;<br>
+ }<br>
+<br>
+ Trb->Signature = DW_MMC_HC_TRB_SIG;<br>
+ Trb->Slot = Slot;<br>
+ Trb->BlockSize = 0x200;<br>
+ Trb->Packet = Packet;<br>
+ Trb->Event = Event;<br>
+ Trb->Started = FALSE;<br>
+ Trb->Timeout = Packet->Timeout;<br>
+ Trb->Private = Private;<br>
+<br>
+ if ((Packet->InTransferLength != 0) && (Packet->InDataBuffer != NULL)) {<br>
+ Trb->Data = Packet->InDataBuffer;<br>
+ Trb->DataLen = Packet->InTransferLength;<br>
+ Trb->Read = TRUE;<br>
+ ZeroMem (Trb->Data, Trb->DataLen);<br>
+ } else if (Packet->OutTransferLength && (Packet->OutDataBuffer !=<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">NULL)) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Trb->Data = Packet->OutDataBuffer;<br>
+ Trb->DataLen = Packet->OutTransferLength;<br>
+ Trb->Read = FALSE;<br>
+ } else if (!Packet->InTransferLength && !Packet->OutTransferLength) {<br>
+ Trb->Data = NULL;<br>
+ Trb->DataLen = 0;<br>
+ } else {<br>
+ goto Error;<br>
+ }<br>
+<br>
+ if (((Private->Slot[Trb->Slot].CardType == EmmcCardType) &&<br>
+ (Packet->SdMmcCmdBlk->CommandIndex ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EMMC_SEND_TUNING_BLOCK)) ||<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ ((Private->Slot[Trb->Slot].CardType == SdCardType) &&<br>
+ (Packet->SdMmcCmdBlk->CommandIndex ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SD_SEND_TUNING_BLOCK))) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Trb->Mode = SdMmcPioMode;<br>
+ } else {<br>
+ if (Trb->Read) {<br>
+ Flag = EfiBusMasterWrite;<br>
+ } else {<br>
+ Flag = EfiBusMasterRead;<br>
+ }<br>
+<br>
+ if (Private->Slot[Trb->Slot].CardType == SdCardType) {<br>
+ Trb->UseFifo = TRUE;<br>
+ } else {<br>
+ Trb->UseFifo = FALSE;<br>
+ if (Trb->DataLen) {<br>
+ MapLength = Trb->DataLen;<br>
+ Status = DmaMap (Flag, Trb->Data, &MapLength, &Trb->DataPhy,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">&Trb->DataMap);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+/* Status = DevIo->Map (<br>
+ DevIo,<br>
+ Flag,<br>
+ Trb->Data,<br>
+ &MapLength,<br>
+ &Trb->DataPhy,<br>
+ &Trb->DataMap<br>
+ );*/<br>
+ if (EFI_ERROR (Status) || (Trb->DataLen != MapLength)) {<br>
+ Status = EFI_BAD_BUFFER_SIZE;<br>
+ goto Error;<br>
+ }<br>
+<br>
+ Status = BuildDmaDescTable (Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DmaUnmap(Trb->DataMap);<br>
+ goto Error;<br>
+ }<br>
+ Status = DwMmcHcStartDma (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DmaUnmap(Trb->DataMap);<br>
+ goto Error;<br>
+ }<br>
+ }<br>
+ }<br>
+ } /* TuningBlock */<br>
+<br>
+ if (Event != NULL) {<br>
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);<br>
+ InsertTailList (&Private->Queue, &Trb->TrbList);<br>
+ gBS->RestoreTPL (OldTpl);<br>
+ }<br>
+<br>
+ return Trb;<br>
+<br>
+Error:<br>
+ return NULL;<br>
+}<br>
+<br>
+/**<br>
+ Free the resource used by the TRB.<br>
+<br>
+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+**/<br>
+VOID<br>
+DwMmcFreeTrb (<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ if (Trb->DmaMap != NULL) {<br>
+ DmaUnmap (Trb->DmaMap);<br>
+ }<br>
+ if (Trb->DataMap != NULL) {<br>
+ DmaUnmap (Trb->DataMap);<br>
+ }<br>
+ FreePool (Trb);<br>
+}<br>
+<br>
+/**<br>
+ Check if the env is ready for execute specified TRB.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The env is ready for TRB execution.<br>
+ @retval EFI_NOT_READY The env is not ready for TRB execution.<br>
+ @retval Others Some erros happen.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcCheckTrbEnv (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Wait for the env to be ready for execute specified TRB.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The env is ready for TRB execution.<br>
+ @retval EFI_TIMEOUT The env is not ready for TRB execution in time.<br>
+ @retval Others Some erros happen.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcWaitTrbEnv (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ UINT64 Timeout;<br>
+ BOOLEAN InfiniteWait;<br>
+<br>
+ //<br>
+ // Wait Command Complete Interrupt Status bit in Normal Interrupt<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Status<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ // Register<br>
+ //<br>
+ Packet = Trb->Packet;<br>
+ Timeout = Packet->Timeout;<br>
+ if (Timeout == 0) {<br>
+ InfiniteWait = TRUE;<br>
+ } else {<br>
+ InfiniteWait = FALSE;<br>
+ }<br>
+<br>
+ while (InfiniteWait || (Timeout > 0)) {<br>
+ //<br>
+ // Check Trb execution result by reading Normal Interrupt Status<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ Status = DwMmcCheckTrbEnv (Private, Trb);<br>
+ if (Status != EFI_NOT_READY) {<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Stall for 1 microsecond.<br>
+ //<br>
+ gBS->Stall (1);<br>
+<br>
+ Timeout--;<br>
+ }<br>
+<br>
+ return EFI_TIMEOUT;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+DwEmmcExecTrb (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ UINTN DevBase;<br>
+ UINT32 Cmd;<br>
+ UINT32 MmcStatus;<br>
+ UINT32 IntStatus;<br>
+ UINT32 Argument;<br>
+ UINT32 ErrMask;<br>
+ UINT32 Timeout;<br>
+<br>
+ Packet = Trb->Packet;<br>
+ DevBase = Trb->Private->DevBase;<br>
+<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+ //<br>
+ // Wait until MMC is idle<br>
+ //<br>
+ do {<br>
+ MmcStatus = MmioRead32 (DevBase + DW_MMC_STATUS);<br>
+ } while (MmcStatus & DW_MMC_STS_DATA_BUSY);<br>
+<br>
+ IntStatus = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_RINTSTS, IntStatus);<br>
+ Cmd = CMD_INDEX (Packet->SdMmcCmdBlk->CommandIndex);<br>
+ if ((Packet->SdMmcCmdBlk->CommandType ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SdMmcCommandTypeAc) ||<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ (Packet->SdMmcCmdBlk->CommandType ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SdMmcCommandTypeAdtc)) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ switch (Packet->SdMmcCmdBlk->CommandIndex) {<br>
+ case EMMC_SET_RELATIVE_ADDR:<br>
+ Cmd |= BIT_CMD_SEND_INIT;<br>
+ break;<br>
+ case EMMC_SEND_STATUS:<br>
+ Cmd |= BIT_CMD_WAIT_PRVDATA_COMPLETE;<br>
+ break;<br>
+ case EMMC_STOP_TRANSMISSION:<br>
+ Cmd |= BIT_CMD_STOP_ABORT_CMD;<br>
+ break;<br>
+ }<br>
+ if (Packet->InTransferLength) {<br>
+ Cmd |= BIT_CMD_WAIT_PRVDATA_COMPLETE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_DATA_EXPECTED |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_READ;<br>
+ } else if (Packet->OutTransferLength) {<br>
+ Cmd |= BIT_CMD_WAIT_PRVDATA_COMPLETE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_DATA_EXPECTED |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_WRITE;<br>
+ }<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_CHECK_RESPONSE_CRC;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ } else {<br>
+ switch (Packet->SdMmcCmdBlk->CommandIndex) {<br>
+ case EMMC_GO_IDLE_STATE:<br>
+ Cmd |= BIT_CMD_SEND_INIT;<br>
+ break;<br>
+ case EMMC_SEND_OP_COND:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT;<br>
+ break;<br>
+ case EMMC_ALL_SEND_CID:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT | BIT_CMD_LONG_RESPONSE |<br>
+ BIT_CMD_CHECK_RESPONSE_CRC | BIT_CMD_SEND_INIT;<br>
+ break;<br>
+ }<br>
+ }<br>
+ switch (Packet->SdMmcCmdBlk->ResponseType) {<br>
+ case SdMmcResponseTypeR2:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_CHECK_RESPONSE_CRC |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_LONG_RESPONSE;<br>
+ break;<br>
+ case SdMmcResponseTypeR3:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT;<br>
+ break;<br>
+ }<br>
+ Cmd |= BIT_CMD_USE_HOLD_REG | BIT_CMD_START;<br>
+<br>
+ Argument = Packet->SdMmcCmdBlk->CommandArgument;<br>
+ MmioWrite32 (DevBase + DW_MMC_CMDARG, Argument);<br>
+<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_CMD, Cmd);<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+<br>
+ ErrMask = DW_MMC_INT_EBE | DW_MMC_INT_HLE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_INT_RTO |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DW_MMC_INT_RCRC | DW_MMC_INT_RE;<br>
+ ErrMask |= DW_MMC_INT_DCRC | DW_MMC_INT_DRT |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_INT_SBE;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ do {<br>
+ Timeout = 10000;<br>
+ if (--Timeout == 0) {<br>
+ break;<br>
+ }<br>
+ IntStatus = MmioRead32 (DevBase + DW_MMC_RINTSTS);<br>
+ if (IntStatus & ErrMask) {<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ if (Trb->DataLen && ((IntStatus & DW_MMC_INT_DTO) == 0)) {<br>
+ //<br>
+ // Transfer Not Done<br>
+ //<br>
+ MicroSecondDelay (10);<br>
+ continue;<br>
+ }<br>
+ MicroSecondDelay (10);<br>
+ } while (!(IntStatus & DW_MMC_INT_CMD_DONE));<br>
+ switch (Packet->SdMmcCmdBlk->ResponseType) {<br>
+ case SdMmcResponseTypeR1:<br>
+ case SdMmcResponseTypeR1b:<br>
+ case SdMmcResponseTypeR3:<br>
+ case SdMmcResponseTypeR4:<br>
+ case SdMmcResponseTypeR5:<br>
+ Packet->SdMmcStatusBlk->Resp0 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP0);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ break;<br>
+ case SdMmcResponseTypeR2:<br>
+ Packet->SdMmcStatusBlk->Resp0 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP0);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Packet->SdMmcStatusBlk->Resp1 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP1);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Packet->SdMmcStatusBlk->Resp2 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP2);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Packet->SdMmcStatusBlk->Resp3 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP3);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ break;<br>
+ }<br>
+<br>
+ //<br>
+ // The workaround on EMMC_SEND_CSD is used to be compatible with<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SDHC.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ if (Packet->SdMmcCmdBlk->CommandIndex == EMMC_SEND_CSD) {<br>
+ {<br>
+ UINT32 Buf[4];<br>
+ ZeroMem (Buf, sizeof (Buf));<br>
+ CopyMem (<br>
+ (UINT8 *)Buf,<br>
+ (UINT8 *)&Packet->SdMmcStatusBlk->Resp0 + 1,<br>
+ sizeof (Buf) - 1<br>
+ );<br>
+ CopyMem (<br>
+ (UINT8 *)&Packet->SdMmcStatusBlk->Resp0,<br>
+ (UINT8 *)Buf,<br>
+ sizeof (Buf) - 1<br>
+ );<br>
+ }<br>
+ }<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+DwSdExecTrb (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ UINTN DevBase;<br>
+ UINT32 Cmd;<br>
+ UINT32 MmcStatus;<br>
+ UINT32 IntStatus;<br>
+ UINT32 Argument;<br>
+ UINT32 ErrMask;<br>
+ UINT32 Timeout;<br>
+ UINT32 Idsts;<br>
+ UINT32 BytCnt;<br>
+ UINT32 BlkSize;<br>
+ EFI_STATUS Status;<br>
+<br>
+ Packet = Trb->Packet;<br>
+ DevBase = Trb->Private->DevBase;<br>
+<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+ //<br>
+ // Wait until MMC is idle<br>
+ //<br>
+ do {<br>
+ MmcStatus = MmioRead32 (DevBase + DW_MMC_STATUS);<br>
+ } while (MmcStatus & DW_MMC_STS_DATA_BUSY);<br>
+<br>
+ IntStatus = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_RINTSTS, IntStatus);<br>
+ Cmd = CMD_INDEX (Packet->SdMmcCmdBlk->CommandIndex);<br>
+ if ((Packet->SdMmcCmdBlk->CommandType ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SdMmcCommandTypeAc) ||<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ (Packet->SdMmcCmdBlk->CommandType ==<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SdMmcCommandTypeAdtc)) {<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ switch (Packet->SdMmcCmdBlk->CommandIndex) {<br>
+ case SD_SET_RELATIVE_ADDR:<br>
+ Cmd |= BIT_CMD_SEND_INIT;<br>
+ break;<br>
+ case SD_STOP_TRANSMISSION:<br>
+ Cmd |= BIT_CMD_STOP_ABORT_CMD;<br>
+ break;<br>
+ case SD_SEND_SCR:<br>
+ Trb->UseBE = TRUE;<br>
+ break;<br>
+ }<br>
+ if (Packet->InTransferLength) {<br>
+ Cmd |= BIT_CMD_WAIT_PRVDATA_COMPLETE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_DATA_EXPECTED |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_READ;<br>
+ } else if (Packet->OutTransferLength) {<br>
+ Cmd |= BIT_CMD_WAIT_PRVDATA_COMPLETE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_DATA_EXPECTED |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_WRITE;<br>
+ }<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_CHECK_RESPONSE_CRC |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_SEND_AUTO_STOP;<br>
+ } else {<br>
+ switch (Packet->SdMmcCmdBlk->CommandIndex) {<br>
+ case SD_GO_IDLE_STATE:<br>
+ Cmd |= BIT_CMD_SEND_INIT;<br>
+ break;<br>
+ }<br>
+ }<br>
+ switch (Packet->SdMmcCmdBlk->ResponseType) {<br>
+ case SdMmcResponseTypeR2:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_CHECK_RESPONSE_CRC |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ BIT_CMD_LONG_RESPONSE;<br>
+ break;<br>
+ case SdMmcResponseTypeR3:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT;<br>
+ break;<br>
+ case SdMmcResponseTypeR1b:<br>
+ case SdMmcResponseTypeR4:<br>
+ case SdMmcResponseTypeR6:<br>
+ case SdMmcResponseTypeR7:<br>
+ Cmd |= BIT_CMD_RESPONSE_EXPECT |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BIT_CMD_CHECK_RESPONSE_CRC;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ break;<br>
+ }<br>
+ Cmd |= BIT_CMD_USE_HOLD_REG | BIT_CMD_START;<br>
+<br>
+ if (Trb->UseFifo == TRUE) {<br>
+ BytCnt = Trb->Read ? Packet->InTransferLength : Packet-<br>
OutTransferLength;<br>
+ MmioWrite32 (DevBase + DW_MMC_BYTCNT, BytCnt);<br>
+ if (Trb->Read) {<br>
+ if (Packet->InTransferLength > DW_MMC_BLOCK_SIZE) {<br>
+ BlkSize = DW_MMC_BLOCK_SIZE;<br>
+ } else {<br>
+ BlkSize = Packet->InTransferLength;<br>
+ }<br>
+ }<br>
+ else {<br>
+ if (Packet->OutTransferLength > DW_MMC_BLOCK_SIZE) {<br>
+ BlkSize = DW_MMC_BLOCK_SIZE;<br>
+ } else {<br>
+ BlkSize = Packet->OutTransferLength;<br>
+ }<br>
+ }<br>
+<br>
+ MmioWrite32 (DevBase + DW_MMC_BLKSIZ, BlkSize);<br>
+ }<br>
+<br>
+ Argument = Packet->SdMmcCmdBlk->CommandArgument;<br>
+ MmioWrite32 (DevBase + DW_MMC_CMDARG, Argument);<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+ MmioWrite32 (DevBase + DW_MMC_CMD, Cmd);<br>
+ ArmDataSynchronizationBarrier ();<br>
+ ArmInstructionSynchronizationBarrier ();<br>
+<br>
+ ErrMask = DW_MMC_INT_EBE | DW_MMC_INT_HLE |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_INT_RTO |<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DW_MMC_INT_RCRC | DW_MMC_INT_RE;<br>
+ ErrMask |= DW_MMC_INT_DRT | DW_MMC_INT_SBE;<br>
+ if (Packet->InTransferLength || Packet->OutTransferLength) {<br>
+ ErrMask |= DW_MMC_INT_DCRC;<br>
+ }<br>
+ if (Trb->UseFifo == TRUE) {<br>
+ Status = TransferFifo (Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ } else {<br>
+ Timeout = 10000;<br>
+ do {<br>
+ if (--Timeout == 0) {<br>
+ break;<br>
+ }<br>
+ IntStatus = MmioRead32 (DevBase + DW_MMC_RINTSTS);<br>
+ if (IntStatus & ErrMask) {<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ if (Trb->DataLen && ((IntStatus & DW_MMC_INT_DTO) == 0)) {<br>
+ //<br>
+ // Transfer not Done<br>
+ //<br>
+ MicroSecondDelay (10);<br>
+ continue;<br>
+ }<br>
+ MicroSecondDelay (10);<br>
+ } while (!(IntStatus & DW_MMC_INT_CMD_DONE));<br>
+ if (Packet->InTransferLength) {<br>
+ do {<br>
+ Idsts = MmioRead32 (DevBase + DW_MMC_IDSTS);<br>
+ } while ((Idsts & DW_MMC_IDSTS_RI) == 0);<br>
+ Status = DwMmcHcStopDma (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ } else if (Packet->OutTransferLength) {<br>
+ do {<br>
+ Idsts = MmioRead32 (DevBase + DW_MMC_IDSTS);<br>
+ } while ((Idsts & DW_MMC_IDSTS_TI) == 0);<br>
+ Status = DwMmcHcStopDma (Private, Trb);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ } /* Packet->InTransferLength */<br>
+ } /* UseFifo */<br>
+ switch (Packet->SdMmcCmdBlk->ResponseType) {<br>
+ case SdMmcResponseTypeR1:<br>
+ case SdMmcResponseTypeR1b:<br>
+ case SdMmcResponseTypeR3:<br>
+ case SdMmcResponseTypeR4:<br>
+ case SdMmcResponseTypeR5:<br>
+ case SdMmcResponseTypeR6:<br>
+ case SdMmcResponseTypeR7:<br>
+ Packet->SdMmcStatusBlk->Resp0 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP0);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ break;<br>
+ case SdMmcResponseTypeR2:<br>
+ Packet->SdMmcStatusBlk->Resp0 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP0);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Packet->SdMmcStatusBlk->Resp1 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP1);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Packet->SdMmcStatusBlk->Resp2 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP2);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Packet->SdMmcStatusBlk->Resp3 = MmioRead32 (DevBase +<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">DW_MMC_RESP3);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ break;<br>
+ }<br>
+<br>
+ //<br>
+ // The workaround on SD_SEND_CSD is used to be compatible with<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SDHC.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ if (Packet->SdMmcCmdBlk->CommandIndex == SD_SEND_CSD) {<br>
+ {<br>
+ UINT32 Buf[4];<br>
+ ZeroMem (Buf, sizeof (Buf));<br>
+ CopyMem (<br>
+ (UINT8 *)Buf,<br>
+ (UINT8 *)&Packet->SdMmcStatusBlk->Resp0 + 1,<br>
+ sizeof (Buf) - 1<br>
+ );<br>
+ CopyMem (<br>
+ (UINT8 *)&Packet->SdMmcStatusBlk->Resp0,<br>
+ (UINT8 *)Buf,<br>
+ sizeof (Buf) - 1<br>
+ );<br>
+ }<br>
+ }<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Execute the specified TRB.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The TRB is sent to host controller successfully.<br>
+ @retval Others Some erros happen when sending this request to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ host controller.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcExecTrb (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_STATUS Status = EFI_SUCCESS;<br>
+ UINT32 Slot;<br>
+<br>
+ Slot = Trb->Slot;<br>
+ if (Private->Slot[Slot].CardType == EmmcCardType) {<br>
+ Status = DwEmmcExecTrb (Private, Trb);<br>
+ } else if (Private->Slot[Slot].CardType == SdCardType) {<br>
+ Status = DwSdExecTrb (Private, Trb);<br>
+ } else {<br>
+ ASSERT (0);<br>
+ }<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Check the TRB execution result.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The TRB is executed successfully.<br>
+ @retval EFI_NOT_READY The TRB is not completed for execution.<br>
+ @retval Others Some erros happen when executing this request.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcCheckTrbResult (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ UINT32 Idsts;<br>
+ UINTN DevBase;<br>
+<br>
+ DevBase = Private->DevBase;<br>
+ Packet = Trb->Packet;<br>
+ if (Trb->UseFifo == TRUE) {<br>
+ return EFI_SUCCESS;<br>
+ }<br>
+ if (Packet->InTransferLength) {<br>
+ do {<br>
+ Idsts = MmioRead32 (DevBase + DW_MMC_IDSTS);<br>
+ } while ((Idsts & BIT1) == 0);<br>
+ } else if (Packet->OutTransferLength) {<br>
+ do {<br>
+ Idsts = MmioRead32 (DevBase + DW_MMC_IDSTS);<br>
+ } while ((Idsts & BIT0) == 0);<br>
+ } else {<br>
+ return EFI_SUCCESS;<br>
+ }<br>
+ Idsts = ~0;<br>
+ MmioWrite32 (DevBase + DW_MMC_IDSTS, Idsts);<br>
+<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Wait for the TRB execution result.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] Trb The pointer to the DW_MMC_HC_TRB instance.<br>
+<br>
+ @retval EFI_SUCCESS The TRB is executed successfully.<br>
+ @retval Others Some erros happen when executing this request.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+DwMmcWaitTrbResult (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private,<br>
+ IN DW_MMC_HC_TRB *Trb<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet;<br>
+ UINT64 Timeout;<br>
+ BOOLEAN InfiniteWait;<br>
+<br>
+ Packet = Trb->Packet;<br>
+ //<br>
+ // Wait Command Complete Interrupt Status bit in Normal Interrupt<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Status<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ // Register<br>
+ //<br>
+ Timeout = Packet->Timeout;<br>
+ if (Timeout == 0) {<br>
+ InfiniteWait = TRUE;<br>
+ } else {<br>
+ InfiniteWait = FALSE;<br>
+ }<br>
+<br>
+ while (InfiniteWait || (Timeout > 0)) {<br>
+ //<br>
+ // Check Trb execution result by reading Normal Interrupt Status<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ //<br>
+ Status = DwMmcCheckTrbResult (Private, Trb);<br>
+ if (Status != EFI_NOT_READY) {<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Stall for 1 microsecond.<br>
+ //<br>
+ gBS->Stall (1);<br>
+<br>
+ Timeout--;<br>
+ }<br>
+<br>
+ return EFI_TIMEOUT;<br>
+}<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/EmmcDevice.c<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/EmmcDevice.c<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..b7a8688c4d2e<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/EmmcDevice.c<br>
@@ -0,0 +1,1042 @@<br>
+/** @file<br>
+ This file provides some helper functions which are specific for EMMC<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) 2018, Linaro. All rights reserved.<BR><br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#include <IndustryStandard/Emmc.h><br>
+<br>
+#include <Library/BaseMemoryLib.h><br>
+#include <Library/DebugLib.h><br>
+#include <Library/UefiBootServicesTableLib.h><br>
+<br>
+#include "DwMmcHcDxe.h"<br>
+<br>
+#define EMMC_GET_STATE(x) (((x) >> 9) & 0xf)<br>
+#define EMMC_STATE_IDLE 0<br>
+#define EMMC_STATE_READY 1<br>
+#define EMMC_STATE_IDENT 2<br>
+#define EMMC_STATE_STBY 3<br>
+#define EMMC_STATE_TRAN 4<br>
+#define EMMC_STATE_DATA 5<br>
+#define EMMC_STATE_RCV 6<br>
+#define EMMC_STATE_PRG 7<br>
+#define EMMC_STATE_DIS 8<br>
+#define EMMC_STATE_BTST 9<br>
+#define EMMC_STATE_SLP 10<br>
+<br>
+#define EMMC_CMD1_CAPACITY_LESS_THAN_2GB 0x00FF8080 //<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Capacity <= 2GB, byte addressing used<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+#define EMMC_CMD1_CAPACITY_GREATER_THAN_2GB 0x40FF8080 //<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Capacity > 2GB, 512-byte sector addressing used<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+/**<br>
+ Send command GO_IDLE_STATE (CMD0 with argument of 0x00000000) to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the device to<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ make it go to Idle State.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Slot The slot number of the SD card to send the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">command<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ to.<br>
+<br>
+ @retval EFI_SUCCESS The EMMC device is reset correctly.<br>
+ @retval Others The device reset fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcReset (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_GO_IDLE_STATE;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBc;<br>
+ SdMmcCmdBlk.ResponseType = 0;<br>
+ SdMmcCmdBlk.CommandArgument = 0;<br>
+<br>
+ gBS->Stall (1000);<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_OP_COND to the EMMC device to get the data of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the OCR<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ register.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in, out] Argument On input, the argument of SEND_OP_COND<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">is to send<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ to the device.<br>
+ On output, the argument is the value of OCR<br>
+ register.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcGetOcr (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN OUT UINT32 *Argument<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SEND_OP_COND;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR3;<br>
+ SdMmcCmdBlk.CommandArgument = *Argument;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ //<br>
+ // For details, refer to SD Host Controller Simplified Spec 3.0 Table 2-12.<br>
+ //<br>
+ *Argument = SdMmcStatusBlk.Resp0;<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Broadcast command ALL_SEND_CID to the bus to ask all the EMMC<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">devices to send<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the data of their CID registers.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcGetAllCid (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_ALL_SEND_CID;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;<br>
+ SdMmcCmdBlk.CommandArgument = 0;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SET_RELATIVE_ADDR to the EMMC device to assign a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Relative device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Address (RCA).<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSetRca (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SET_RELATIVE_ADDR;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_CSD to the EMMC device to get the data of the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">CSD register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of selected device.<br>
+ @param[out] Csd The buffer to store the content of the CSD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Note the caller should ignore the lowest byte of<br>
+ this buffer as the content of this byte is<br>
+ meaningless even if the operation succeeds.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcGetCsd (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ OUT EMMC_CSD *Csd<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SEND_CSD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ //<br>
+ // Copy 128bit data for CSD structure.<br>
+ //<br>
+ CopyMem ((VOID *)Csd + 1, &SdMmcStatusBlk.Resp0, sizeof<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">(EMMC_CSD) - 1);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SELECT_DESELECT_CARD to the EMMC device to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">select/deselect it.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of selected device.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSelect (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SELECT_DESELECT_CARD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_EXT_CSD to the EMMC device to get the data of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">the EXT_CSD<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ register.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[out] ExtCsd The buffer to store the content of the EXT_CSD<br>
+ register.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcGetExtCsd (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ OUT EMMC_EXT_CSD *ExtCsd<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SEND_EXT_CSD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = 0x00000000;<br>
+<br>
+ Packet.InDataBuffer = ExtCsd;<br>
+ Packet.InTransferLength = sizeof (EMMC_EXT_CSD);<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SWITCH to the EMMC device to switch the mode of<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">operation of the<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ selected Device or modifies the EXT_CSD registers.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Access The access mode of SWTICH command.<br>
+ @param[in] Index The offset of the field to be access.<br>
+ @param[in] Value The value to be set to the specified field of<br>
+ EXT_CSD register.<br>
+ @param[in] CmdSet The value of CmdSet field of EXT_CSD register.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSwitch (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT8 Access,<br>
+ IN UINT8 Index,<br>
+ IN UINT8 Value,<br>
+ IN UINT8 CmdSet<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SWITCH;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;<br>
+ SdMmcCmdBlk.CommandArgument = (Access << 24) | (Index << 16) | \<br>
+ (Value << 8) | CmdSet;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_STATUS to the addressed EMMC device to get its<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">status<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ register.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of addressed device.<br>
+ @param[out] DevStatus The returned device status.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSendStatus (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ OUT UINT32 *DevStatus<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SEND_STATUS;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ *DevStatus = SdMmcStatusBlk.Resp0;<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_TUNING_BLOCK to the EMMC device for HS200<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">optimal sampling<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ point detection.<br>
+<br>
+ It may be sent up to 40 times until the host finishes the tuning<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">procedure.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] BusWidth The bus width to work.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSendTuningBlk (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+ UINT8 TuningBlock[128];<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = EMMC_SEND_TUNING_BLOCK;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = 0;<br>
+<br>
+ Packet.InDataBuffer = TuningBlock;<br>
+ if (BusWidth == 8) {<br>
+ Packet.InTransferLength = sizeof (TuningBlock);<br>
+ } else {<br>
+ Packet.InTransferLength = 64;<br>
+ }<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Tunning the clock to get HS200 optimal sampling point.<br>
+<br>
+ Command SEND_TUNING_BLOCK may be sent up to 40 times until the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">host finishes<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the tuning procedure.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8.<br>
+<br>
+ @param[in] DevIo A pointer to the EFI_DEVICE_IO_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] BusWidth The bus width to work.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcTuningClkForHs200 (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Switch the bus width to specified width.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.9.<br>
+<br>
+ @param[in] DevIo A pointer to the EFI_DEVICE_IO_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+ @param[in] IsDdr If TRUE, use dual data rate data simpling method.<br>
+ Otherwise use single data rate data simpling method.<br>
+ @param[in] BusWidth The bus width to be set, it could be 4 or 8.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSwitchBusWidth (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN BOOLEAN IsDdr,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT8 Access;<br>
+ UINT8 Index;<br>
+ UINT8 Value;<br>
+ UINT8 CmdSet;<br>
+ UINT32 DevStatus;<br>
+<br>
+ //<br>
+ // Write Byte, the Value field is written into the byte pointed by Index.<br>
+ //<br>
+ Access = 0x03;<br>
+ Index = OFFSET_OF (EMMC_EXT_CSD, BusWidth);<br>
+ if (BusWidth == 1) {<br>
+ Value = 0;<br>
+ } else {<br>
+ if (BusWidth == 4) {<br>
+ Value = 1;<br>
+ } else if (BusWidth == 8) {<br>
+ Value = 2;<br>
+ } else {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if (IsDdr) {<br>
+ Value += 4;<br>
+ }<br>
+ }<br>
+<br>
+ CmdSet = 0;<br>
+ Status = EmmcSwitch (PassThru, Access, Index, Value, CmdSet);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "EmmcSwitchBusWidth: Switch to bus width %d fails with %r\n",<br>
+ BusWidth,<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ do {<br>
+ Status = EmmcSendStatus (PassThru, Rca, &DevStatus);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "EmmcSwitchBusWidth: Send status fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Check the switch operation is really successful or not.<br>
+ //<br>
+ } while ((DevStatus & 0xf) == EMMC_STATE_PRG);<br>
+<br>
+ Status = DwMmcHcSetBusWidth (DevBase, IsDdr, BusWidth);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Switch the clock frequency to the specified value.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.<br>
+<br>
+ @param[in] DevIo A pointer to the EFI_DEVICE_IO_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+ @param[in] HsTiming The value to be written to HS_TIMING field of<br>
+ EXT_CSD register.<br>
+ @param[in] ClockFreq The max clock frequency to be set, the unit is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">MHz.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSwitchClockFreq (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN UINT8 HsTiming,<br>
+ IN UINT32 ClockFreq<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT8 Access;<br>
+ UINT8 Index;<br>
+ UINT8 Value;<br>
+ UINT8 CmdSet;<br>
+ UINT32 DevStatus;<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (PassThru);<br>
+ //<br>
+ // Write Byte, the Value field is written into the byte pointed by Index.<br>
+ //<br>
+ Access = 0x03;<br>
+ Index = OFFSET_OF (EMMC_EXT_CSD, HsTiming);<br>
+ Value = HsTiming;<br>
+ CmdSet = 0;<br>
+<br>
+ Status = EmmcSwitch (PassThru, Access, Index, Value, CmdSet);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "EmmcSwitchClockFreq: Switch to hstiming %d fails with %r\n",<br>
+ HsTiming,<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = EmmcSendStatus (PassThru, Rca, &DevStatus);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "EmmcSwitchClockFreq: Send status fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Check the switch operation is really successful or not.<br>
+ //<br>
+ if ((DevStatus & BIT7) != 0) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "EmmcSwitchClockFreq: The switch operation fails as DevStatus<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">0x%08x\n",<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DevStatus<br>
+ ));<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ //<br>
+ // Convert the clock freq unit from MHz to KHz.<br>
+ //<br>
+ Status = DwMmcHcClockSupply (DevBase, ClockFreq * 1000, Private-<br>
Capability[0]);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Switch to the High Speed timing according to request.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8.<br>
+<br>
+ @param[in] DevIo A pointer to the EFI_DEVICE_IO_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+ @param[in] ClockFreq The max clock frequency to be set.<br>
+ @param[in] IsDdr If TRUE, use dual data rate data simpling method.<br>
+ Otherwise use single data rate data simpling method.<br>
+ @param[in] BusWidth The bus width to be set, it could be 4 or 8.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSwitchToHighSpeed (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN UINT32 ClockFreq,<br>
+ IN BOOLEAN IsDdr,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT8 HsTiming;<br>
+<br>
+ HsTiming = 1;<br>
+ Status = EmmcSwitchClockFreq (DevBase, PassThru, Rca, HsTiming,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">ClockFreq);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ Status = EmmcSwitchBusWidth (DevBase, PassThru, Rca, IsDdr,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BusWidth);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Switch to the HS200 timing according to request.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8.<br>
+<br>
+ @param[in] DevIo A pointer to the EFI_DEVICE_IO_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+ @param[in] ClockFreq The max clock frequency to be set.<br>
+ @param[in] BusWidth The bus width to be set, it could be 4 or 8.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSwitchToHS200 (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN UINT32 ClockFreq,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ return EFI_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ Switch the high speed timing according to request.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8.<br>
+<br>
+ @param[in] DevIo A pointer to the EFI_DEVICE_IO_PROTOCOL<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcSetBusMode (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ EMMC_CSD Csd;<br>
+ EMMC_EXT_CSD ExtCsd;<br>
+ UINT8 HsTiming;<br>
+ BOOLEAN IsDdr;<br>
+ UINT32 DevStatus;<br>
+ UINT32 ClockFreq;<br>
+ UINT8 BusWidth;<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (PassThru);<br>
+ ASSERT (Private->Capability[0].BaseClkFreq != 0);<br>
+<br>
+ Status = EmmcGetCsd (PassThru, Rca, &Csd);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n",<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Status));<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return Status;<br>
+ }<br>
+<br>
+ Status = EmmcSelect (PassThru, Rca);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: Select fails with %r\n",<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Status));<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return Status;<br>
+ }<br>
+<br>
+ do {<br>
+ Status = EmmcSendStatus (PassThru, Rca, &DevStatus);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "EmmcSetBusMode: Get Status fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ } while (EMMC_GET_STATE (DevStatus) != EMMC_STATE_TRAN);<br>
+<br>
+ BusWidth = 1;<br>
+ Status = EmmcSwitchBusWidth (DevBase, PassThru, Rca, FALSE,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BusWidth);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ BusWidth = Private->Capability[0].BusWidth;<br>
+ //<br>
+ // Get Deivce_Type from EXT_CSD register.<br>
+ //<br>
+ Status = EmmcGetExtCsd (PassThru, &ExtCsd);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetExtCsd fails with<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">%r\n", Status));<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ return Status;<br>
+ }<br>
+<br>
+ //<br>
+ // Calculate supported bus speed/bus width/clock frequency.<br>
+ //<br>
+ HsTiming = 0;<br>
+ IsDdr = FALSE;<br>
+ ClockFreq = 0;<br>
+ if (((ExtCsd.DeviceType & (BIT4 | BIT5)) != 0) &&<br>
+ (Private->Capability[0].Sdr104 != 0)) {<br>
+ HsTiming = 2;<br>
+ IsDdr = FALSE;<br>
+ ClockFreq = 200;<br>
+ } else if (((ExtCsd.DeviceType & (BIT2 | BIT3)) != 0) &&<br>
+ (Private->Capability[0].Ddr50 != 0)) {<br>
+ HsTiming = 1;<br>
+ IsDdr = TRUE;<br>
+ ClockFreq = 52;<br>
+ } else if (((ExtCsd.DeviceType & BIT1) != 0) &&<br>
+ (Private->Capability[0].HighSpeed != 0)) {<br>
+ HsTiming = 1;<br>
+ IsDdr = FALSE;<br>
+ ClockFreq = 52;<br>
+ } else if (((ExtCsd.DeviceType & BIT0) != 0) &&<br>
+ (Private->Capability[0].HighSpeed != 0)) {<br>
+ HsTiming = 1;<br>
+ IsDdr = FALSE;<br>
+ ClockFreq = 26;<br>
+ }<br>
+<br>
+ if ((ClockFreq == 0) || (HsTiming == 0)) {<br>
+ //<br>
+ // Continue using default setting.<br>
+ //<br>
+ return EFI_SUCCESS;<br>
+ }<br>
+<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcSetBusMode: HsTiming %d ClockFreq %d BusWidth %d Ddr<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">%a\n",<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ HsTiming,<br>
+ ClockFreq,<br>
+ BusWidth,<br>
+ IsDdr ? "TRUE" : "FALSE"<br>
+ ));<br>
+<br>
+ if (HsTiming == 2) {<br>
+ //<br>
+ // Execute HS200 timing switch procedure<br>
+ //<br>
+ Status = EmmcSwitchToHS200 (DevBase, PassThru, Rca, ClockFreq,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BusWidth);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ } else {<br>
+ //<br>
+ // Execute High Speed timing switch procedure<br>
+ //<br>
+ Status = EmmcSwitchToHighSpeed (<br>
+ DevBase,<br>
+ PassThru,<br>
+ Rca,<br>
+ ClockFreq,<br>
+ IsDdr,<br>
+ BusWidth<br>
+ );<br>
+ }<br>
+<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcSetBusMode: Switch to %a %r\n",<br>
+ (HsTiming == 3) ? "HS400" : ((HsTiming == 2) ? "HS200" : "HighSpeed"),<br>
+ Status<br>
+ ));<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Execute EMMC device identification procedure.<br>
+<br>
+ Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.<br>
+<br>
+ @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">instance.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS There is a EMMC card.<br>
+ @retval Others There is not a EMMC card.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EmmcIdentification (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINTN DevBase;<br>
+ EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;<br>
+ UINT32 Ocr;<br>
+ UINT16 Rca;<br>
+ UINT32 DevStatus;<br>
+ UINT32 Timeout;<br>
+<br>
+ DevBase = Private->DevBase;<br>
+ PassThru = &Private->PassThru;<br>
+<br>
+ Status = EmmcReset (PassThru);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcIdentification: Executing Cmd0 fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Timeout = 100;<br>
+ do {<br>
+ Ocr = EMMC_CMD1_CAPACITY_GREATER_THAN_2GB;<br>
+ Status = EmmcGetOcr (PassThru, &Ocr);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcIdentification: Executing Cmd1 fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ if (--Timeout <= 0) {<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ MicroSecondDelay (100);<br>
+ } while ((Ocr & BIT31) == 0);<br>
+<br>
+ Status = EmmcGetAllCid (PassThru);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcIdentification: Executing Cmd2 fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // valid RCA starts from 1.<br>
+ // Here we takes a simple formula to calculate the RCA.<br>
+ // Don't support multiple devices on the slot, that is<br>
+ // shared bus slot feature.<br>
+ //<br>
+ Rca = 1;<br>
+ Status = EmmcSetRca (PassThru, Rca);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcIdentification: Executing Cmd3 fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Enter Data Tranfer Mode.<br>
+ //<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcIdentification: Found a EMMC device at RCA [%d]\n",<br>
+ Rca<br>
+ ));<br>
+ Private->Slot[0].CardType = EmmcCardType;<br>
+<br>
+ Status = EmmcSetBusMode (DevBase, PassThru, Rca);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ //<br>
+ // Exit DATA Mode.<br>
+ //<br>
+ do {<br>
+ Status = EmmcSendStatus (PassThru, Rca, &DevStatus);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "EmmcSwitchBusWidth: Send status fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ } while ((DevStatus & 0xf) == EMMC_STATE_DATA);<br>
+<br>
+ return Status;<br>
+}<br>
diff --git a/EmbeddedPkg/Drivers/DwMmcHcDxe/SdDevice.c<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">b/EmbeddedPkg/Drivers/DwMmcHcDxe/SdDevice.c<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">new file mode 100644<br>
index 000000000000..63246637b6dd<br>
--- /dev/null<br>
+++ b/EmbeddedPkg/Drivers/DwMmcHcDxe/SdDevice.c<br>
@@ -0,0 +1,1105 @@<br>
+/** @file<br>
+ This file provides some helper functions which are specific for SD card<br>
+ device.<br>
+<br>
+ Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) 2018, Linaro. All rights reserved.<BR><br>
+<br>
+ This program and the accompanying materials are licensed and made<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">available<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ under the terms and conditions of the BSD License which accompanies<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">this<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ distribution. The full text of the license may be found at<br>
+ <a href="http://opensource.org/licenses/bsd-license.php">http://opensource.org/licenses/bsd-license.php</a><br>
+<br>
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BASIS,<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EXPRESS OR IMPLIED.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+**/<br>
+<br>
+#include <IndustryStandard/Sd.h><br>
+<br>
+#include <Library/BaseMemoryLib.h><br>
+#include <Library/DebugLib.h><br>
+<br>
+#include "DwMmcHcDxe.h"<br>
+<br>
+/**<br>
+ Send command GO_IDLE_STATE to the device to make it go to Idle State.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+<br>
+ @retval EFI_SUCCESS The SD device is reset correctly.<br>
+ @retval Others The device reset fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardReset (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_GO_IDLE_STATE;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBc;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ //Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_IF_COND to the device to inquiry the SD Memory<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Card<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ interface condition.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] SupplyVoltage The supplied voltage by the host.<br>
+ @param[in] CheckPattern The check pattern to be sent to the device.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardVoltageCheck (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT8 SupplyVoltage,<br>
+ IN UINT8 CheckPattern<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SEND_IF_COND;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR7;<br>
+ SdMmcCmdBlk.CommandArgument = (SupplyVoltage << 8) |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">CheckPattern;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ if (!EFI_ERROR (Status)) {<br>
+ if (SdMmcStatusBlk.Resp0 != SdMmcCmdBlk.CommandArgument) {<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SDIO_SEND_OP_COND to the device to see whether it is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SDIO device.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SDIO Simplified Spec 3 Section 3.2 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] VoltageWindow The supply voltage window.<br>
+ @param[in] S18R The boolean to show if it should switch to 1.8v.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdioSendOpCond (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT32 VoltageWindow,<br>
+ IN BOOLEAN S18R<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+ UINT32 Switch;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SDIO_SEND_OP_COND;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR4;<br>
+<br>
+ Switch = S18R ? BIT24 : 0;<br>
+<br>
+ SdMmcCmdBlk.CommandArgument = (VoltageWindow & 0xFFFFFF) |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Switch;<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SD_SEND_OP_COND to the device to see whether it is<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SDIO device.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of addressed device.<br>
+ @param[in] VoltageWindow The supply voltage window.<br>
+ @param[in] S18R The boolean to show if it should switch to 1.8v.<br>
+ @param[in] Xpc The boolean to show if it should provide 0.36w<br>
+ power control.<br>
+ @param[in] Hcs The boolean to show if it support host capacity<br>
+ info.<br>
+ @param[out] Ocr The buffer to store returned OCR register value.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSendOpCond (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN UINT32 VoltageWindow,<br>
+ IN BOOLEAN S18R,<br>
+ IN BOOLEAN Xpc,<br>
+ IN BOOLEAN Hcs,<br>
+ OUT UINT32 *Ocr<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+ UINT32 Switch;<br>
+ UINT32 MaxPower;<br>
+ UINT32 HostCapacity;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_APP_CMD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SEND_OP_COND;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR3;<br>
+<br>
+ Switch = S18R ? BIT24 : 0;<br>
+ MaxPower = Xpc ? BIT28 : 0;<br>
+ HostCapacity = Hcs ? BIT30 : 0;<br>
+<br>
+ SdMmcCmdBlk.CommandArgument = (VoltageWindow & 0xFFFFFF) |<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Switch | \<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ MaxPower | HostCapacity;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ *Ocr = SdMmcStatusBlk.Resp0;<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Broadcast command ALL_SEND_CID to the bus to ask all the SD devices<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">to send<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ the data of their CID registers.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardAllSendCid (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_ALL_SEND_CID;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SET_RELATIVE_ADDR to the SD device to assign a<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Relative device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Address (RCA).<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[out] Rca The relative device address to assign.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSetRca (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ OUT UINT16 *Rca<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SET_RELATIVE_ADDR;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR6;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ *Rca = (UINT16)(SdMmcStatusBlk.Resp0 >> 16);<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_CSD to the SD device to get the data of the CSD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of selected device.<br>
+ @param[out] Csd The buffer to store the content of the CSD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Note the caller should ignore the lowest byte of<br>
+ this buffer as the content of this byte is meaning-<br>
+ less even if the operation succeeds.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardGetCsd (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ OUT SD_CSD *Csd<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SEND_CSD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ CopyMem (((UINT8*)Csd) + 1, &SdMmcStatusBlk.Resp0, sizeof<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">(SD_CSD) - 1);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_CSD to the SD device to get the data of the CSD<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of selected device.<br>
+ @param[out] Scr The buffer to store the content of the SCR<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">register.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardGetScr (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ OUT SD_SCR *Scr<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_APP_CMD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SEND_SCR;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+<br>
+ Packet.InDataBuffer = Scr;<br>
+ Packet.InTransferLength = sizeof (SD_SCR);<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SELECT_DESELECT_CARD to the SD device to<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">select/deselect it.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of selected device.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSelect (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SELECT_DESELECT_CARD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ if (Rca != 0) {<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;<br>
+ }<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command VOLTAGE_SWITCH to the SD device to switch the voltage<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">of the<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ device.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardVoltageSwitch (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_VOLTAGE_SWITCH;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = 0;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SET_BUS_WIDTH to the SD device to set the bus width.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of addressed device.<br>
+ @param[in] BusWidth The bus width to be set, it could be 1 or 4.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSetBusWidth (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+ UINT8 Value;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_APP_CMD;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SET_BUS_WIDTH;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+<br>
+ if (BusWidth == 1) {<br>
+ Value = 0;<br>
+ } else if (BusWidth == 4) {<br>
+ Value = 2;<br>
+ } else {<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ SdMmcCmdBlk.CommandArgument = Value & 0x3;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SWITCH_FUNC to the SD device to check switchable<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">function or<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ switch card function.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] AccessMode The value for access mode group.<br>
+ @param[in] CommandSystem The value for command set group.<br>
+ @param[in] DriveStrength The value for drive length group.<br>
+ @param[in] PowerLimit The value for power limit group.<br>
+ @param[in] Mode Switch or check function.<br>
+ @param[out] SwitchResp The return switch function status.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSwitch (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT8 AccessMode,<br>
+ IN UINT8 CommandSystem,<br>
+ IN UINT8 DriveStrength,<br>
+ IN UINT8 PowerLimit,<br>
+ IN BOOLEAN Mode,<br>
+ OUT UINT8 *SwitchResp<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+ UINT32 ModeValue;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SWITCH_FUNC;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+<br>
+ ModeValue = Mode ? BIT31 : 0;<br>
+ SdMmcCmdBlk.CommandArgument = (AccessMode & 0xF) | \<br>
+ ((PowerLimit & 0xF) << 4) | \<br>
+ ((DriveStrength & 0xF) << 8) | \<br>
+ ((DriveStrength & 0xF) << 12) | \<br>
+ ModeValue;<br>
+<br>
+ Packet.InDataBuffer = SwitchResp;<br>
+ Packet.InTransferLength = 64;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_STATUS to the addressed SD device to get its<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">status<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ register.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address of addressed device.<br>
+ @param[out] DevStatus The returned device status.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSendStatus (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ OUT UINT32 *DevStatus<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SEND_STATUS;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+ if (!EFI_ERROR (Status)) {<br>
+ *DevStatus = SdMmcStatusBlk.Resp0;<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Send command SEND_TUNING_BLOCK to the SD device for HS200<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">optimal sampling<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ point detection.<br>
+<br>
+ It may be sent up to 40 times until the host finishes the tuning<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">procedure.<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSendTuningBlk (<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru<br>
+ )<br>
+{<br>
+ EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;<br>
+ EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;<br>
+ EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;<br>
+ EFI_STATUS Status;<br>
+ UINT8 TuningBlock[64];<br>
+<br>
+ ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));<br>
+ ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));<br>
+ ZeroMem (&Packet, sizeof (Packet));<br>
+<br>
+ Packet.SdMmcCmdBlk = &SdMmcCmdBlk;<br>
+ Packet.SdMmcStatusBlk = &SdMmcStatusBlk;<br>
+ Packet.Timeout = DW_MMC_HC_GENERIC_TIMEOUT;<br>
+<br>
+ SdMmcCmdBlk.CommandIndex = SD_SEND_TUNING_BLOCK;<br>
+ SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;<br>
+ SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;<br>
+ SdMmcCmdBlk.CommandArgument = 0;<br>
+<br>
+ Packet.InDataBuffer = TuningBlock;<br>
+ Packet.InTransferLength = sizeof (TuningBlock);<br>
+<br>
+ Status = PassThru->PassThru (PassThru, 0, &Packet, NULL);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Switch the bus width to specified width.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and<br>
+ SD Host Controller Simplified Spec 3.0 section Figure 3-7 for details.<br>
+<br>
+ @param[in] PciIo A pointer to the EFI_PCI_IO_PROTOCOL instance.<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+ @param[in] BusWidth The bus width to be set, it could be 4 or 8.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSwitchBusWidth (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN BOOLEAN IsDdr,<br>
+ IN UINT8 BusWidth<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINT32 DevStatus;<br>
+<br>
+ Status = SdCardSetBusWidth (PassThru, Rca, BusWidth);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSwitchBusWidth: Switch to bus width %d fails with %r\n",<br>
+ BusWidth,<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = SdCardSendStatus (PassThru, Rca, &DevStatus);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSwitchBusWidth: Send status fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Check the switch operation is really successful or not.<br>
+ //<br>
+ if ((DevStatus >> 16) != 0) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSwitchBusWidth: The switch operation fails as DevStatus<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">0x%08x\n",<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ DevStatus<br>
+ ));<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+<br>
+ Status = DwMmcHcSetBusWidth (DevBase, IsDdr, BusWidth);<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+/**<br>
+ Switch the high speed timing according to request.<br>
+<br>
+ Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.<br>
+<br>
+ @param[in] PciIo A pointer to the EFI_PCI_IO_PROTOCOL instance.<br>
+ @param[in] PassThru A pointer to the<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">EFI_SD_MMC_PASS_THRU_PROTOCOL<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ instance.<br>
+ @param[in] Rca The relative device address to be assigned.<br>
+ @param[in] S18A The boolean to show if it's a UHS-I SD card.<br>
+ @param[in] BusWidths The bus width of the SD card.<br>
+<br>
+ @retval EFI_SUCCESS The operation is done correctly.<br>
+ @retval Others The operation fails.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+SdCardSetBusMode (<br>
+ IN UINTN DevBase,<br>
+ IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru,<br>
+ IN UINT16 Rca,<br>
+ IN BOOLEAN S18A,<br>
+ IN UINT32 BusWidths<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ DW_MMC_HC_SLOT_CAP *Capability;<br>
+ UINT32 ClockFreq;<br>
+ UINT8 AccessMode;<br>
+ UINT8 SwitchResp[64];<br>
+ DW_MMC_HC_PRIVATE_DATA *Private;<br>
+ BOOLEAN IsDdr;<br>
+<br>
+ Private = DW_MMC_HC_PRIVATE_FROM_THIS (PassThru);<br>
+<br>
+ Capability = &Private->Capability[0];<br>
+<br>
+ if ((Capability->BusWidth == 1) || (Capability->BusWidth == 4)) {<br>
+ BusWidths &= Capability[0].BusWidth;<br>
+ } else {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSetBusMode: BusWidths (%d) in capability are wrong\n",<br>
+ Capability->BusWidth<br>
+ ));<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if (BusWidths == 0) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSetBusMode: Get wrong BusWidths:%d\n",<br>
+ BusWidths<br>
+ ));<br>
+ return EFI_INVALID_PARAMETER;<br>
+ }<br>
+<br>
+ if (Private->Capability[0].Ddr50) {<br>
+ IsDdr = TRUE;<br>
+ } else {<br>
+ IsDdr = FALSE;<br>
+ }<br>
+<br>
+ Status = SdCardSwitchBusWidth (DevBase, PassThru, Rca, IsDdr,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">BusWidths);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSetBusMode: Executing SdCardSwitchBusWidth fails with<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">%r\n",<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ //<br>
+ // Get the supported bus speed from SWITCH cmd return data group #1.<br>
+ //<br>
+ Status = SdCardSwitch (PassThru, 0xF, 0xF, 0xF, 0xF, FALSE, SwitchResp);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // Calculate supported bus speed/bus width/clock frequency by host and<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">device<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ // capability.<br>
+ //<br>
+ ClockFreq = 0;<br>
+ if (S18A && (Capability->Sdr104 != 0) && ((SwitchResp[13] & BIT3) != 0)) {<br>
+ ClockFreq = 208;<br>
+ AccessMode = 3;<br>
+ } else if (S18A && (Capability->Sdr50 != 0) &&<br>
+ ((SwitchResp[13] & BIT2) != 0)) {<br>
+ ClockFreq = 100;<br>
+ AccessMode = 2;<br>
+ } else if (S18A && (Capability->Ddr50 != 0) &&<br>
+ ((SwitchResp[13] & BIT4) != 0)) {<br>
+ ClockFreq = 50;<br>
+ AccessMode = 4;<br>
+ } else if ((SwitchResp[13] & BIT1) != 0) {<br>
+ ClockFreq = 50;<br>
+ AccessMode = 1;<br>
+ } else {<br>
+ ClockFreq = 25;<br>
+ AccessMode = 0;<br>
+ }<br>
+<br>
+ Status = SdCardSwitch (PassThru, AccessMode, 0xF, 0xF, 0xF, TRUE,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">SwitchResp);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ if ((SwitchResp[16] & 0xF) != AccessMode) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardSetBusMode: Switch to AccessMode %d ClockFreq %d fails!<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">The Switch response is 0x%1x\n",<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ AccessMode,<br>
+ ClockFreq,<br>
+ SwitchResp[16] & 0xF<br>
+ ));<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "SdCardSetBusMode: Switch to AccessMode %d ClockFreq %d \n",<br>
+ AccessMode,<br>
+ ClockFreq<br>
+ ));<br>
+<br>
+ Status = DwMmcHcClockSupply (DevBase, ClockFreq * 1000, *Capability);<br>
+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ return Status;<br>
+}<br>
+<br>
+EFI_STATUS<br>
+SdCardIdentification (<br>
+ IN DW_MMC_HC_PRIVATE_DATA *Private<br>
+ )<br>
+{<br>
+ EFI_STATUS Status;<br>
+ UINTN DevBase;<br>
+ EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;<br>
+ UINT32 Ocr;<br>
+ UINT16 Rca;<br>
+ BOOLEAN Xpc;<br>
+ BOOLEAN S18r;<br>
+ UINT64 MaxCurrent;<br>
+ SD_SCR Scr;<br>
+ SD_CSD Csd;<br>
+<br>
+ DevBase = Private->DevBase;<br>
+ PassThru = &Private->PassThru;<br>
+ //<br>
+ // 1. Send Cmd0 to the device<br>
+ //<br>
+ Status = SdCardReset (PassThru);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "SdCardIdentification: Executing Cmd0 fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ MicroSecondDelay (10000);<br>
+ //<br>
+ // 2. Send Cmd8 to the device<br>
+ //<br>
+ Status = SdCardVoltageCheck (PassThru, 0x1, 0xFF);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "SdCardIdentification: Executing Cmd8 fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+ //<br>
+ // 3. Send Acmd41 with voltage window 0 to the device<br>
+ //<br>
+ Status = SdCardSendOpCond (PassThru, 0, 0, FALSE, FALSE, FALSE, &Ocr);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_INFO,<br>
+ "SdCardIdentification: Executing SdCardSendOpCond fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+<br>
+ if (Private->Capability[0].Voltage33 != 0) {<br>
+ //<br>
+ // Support 3.3V<br>
+ //<br>
+ MaxCurrent = ((UINT32)Private->MaxCurrent[0] & 0xFF) * 4;<br>
+ S18r = FALSE;<br>
+ } else if (Private->Capability[0].Voltage30 != 0) {<br>
+ //<br>
+ // Support 3.0V<br>
+ //<br>
+ MaxCurrent = (((UINT32)Private->MaxCurrent[0] >> 8) & 0xFF) * 4;<br>
+ S18r = FALSE;<br>
+ } else if (Private->Capability[0].Voltage18 != 0) {<br>
+ //<br>
+ // Support 1.8V<br>
+ //<br>
+ MaxCurrent = (((UINT32)Private->MaxCurrent[0] >> 16) & 0xFF) * 4;<br>
+ S18r = TRUE;<br>
+ } else {<br>
+ ASSERT (FALSE);<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+<br>
+ if (MaxCurrent >= 150) {<br>
+ Xpc = TRUE;<br>
+ } else {<br>
+ Xpc = FALSE;<br>
+ }<br>
+<br>
+ //<br>
+ // 4. Repeatly send Acmd41 with supply voltage window to the device.<br>
+ // Note here we only support the cards complied with SD physical<br>
+ // layer simplified spec version 2.0 and version 3.0 and above.<br>
+ //<br>
+ do {<br>
+ Status = SdCardSendOpCond (PassThru, 0, Ocr, S18r, Xpc, TRUE, &Ocr);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardIdentification: SdCardSendOpCond fails with %r Ocr %x, S18r<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">%x, Xpc %x\n",<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ Status,<br>
+ Ocr,<br>
+ S18r,<br>
+ Xpc<br>
+ ));<br>
+ return EFI_DEVICE_ERROR;<br>
+ }<br>
+ } while ((Ocr & BIT31) == 0);<br>
+<br>
+ Status = SdCardAllSendCid (PassThru);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardIdentification: Executing SdCardAllSendCid fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = SdCardSetRca (PassThru, &Rca);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardIdentification: Executing SdCardSetRca fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = SdCardGetCsd (PassThru, Rca, &Csd);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardIdentification: Executing SdCardGetCsd fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = SdCardSelect (PassThru, Rca);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardIdentification: Selecting card fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ Status = SdCardGetScr (PassThru, Rca, &Scr);<br>
+ if (EFI_ERROR (Status)) {<br>
+ DEBUG ((<br>
+ DEBUG_ERROR,<br>
+ "SdCardIdentification: Executing SdCardGetScr fails with %r\n",<br>
+ Status<br>
+ ));<br>
+ return Status;<br>
+ }<br>
+<br>
+ //<br>
+ // Enter Data Tranfer Mode.<br>
+ //<br>
+ DEBUG ((DEBUG_INFO, "SdCardIdentification: Found a SD device\n"));<br>
+ Private->Slot[0].CardType = SdCardType;<br>
+<br>
+ Status = SdCardSetBusMode (DevBase, PassThru, Rca, S18r,<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">Scr.SdBusWidths);<br style="mso-special-character:line-break">
<![if !supportLineBreakNewLine]><br style="mso-special-character:line-break">
<![endif]><o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman"">+ if (EFI_ERROR (Status)) {<br>
+ return Status;<br>
+ }<br>
+<br>
+ Private->Slot[0].Initialized = TRUE;<br>
+<br>
+ return Status;<br>
+}<br>
--<br>
2.12.3<o:p></o:p></span></p>
</blockquote>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;mso-fareast-font-family:"Times New Roman""><br>
<br>
<br>
</span><span style="mso-fareast-font-family:"Times New Roman""><o:p></o:p></span></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="mso-fareast-font-family:"Times New Roman""><o:p> </o:p></span></p>
</div>
</div>
</div>
</body>
</html>
<div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p> You receive all messages sent to this group. <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/74502">View/Reply Online (#74502)</a> | | <a target="_blank" href="https://groups.io/mt/81516685/1813853">Mute This Topic</a> | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br> <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> | <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a> [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>