From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.37.43; helo=nam02-cy1-obe.outbound.protection.outlook.com; envelope-from=pankaj.bansal@nxp.com; receiver=edk2-devel@lists.01.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0043.outbound.protection.outlook.com [104.47.37.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A16C21B02822 for ; Thu, 7 Dec 2017 00:31:04 -0800 (PST) Received: from BN3PR03CA0099.namprd03.prod.outlook.com (10.174.66.17) by CO2PR03MB2360.namprd03.prod.outlook.com (10.166.93.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Thu, 7 Dec 2017 08:35:34 +0000 Received: from BN1BFFO11FD001.protection.gbl (2a01:111:f400:7c10::1:162) by BN3PR03CA0099.outlook.office365.com (2603:10b6:400:4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Thu, 7 Dec 2017 08:35:33 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD001.mail.protection.outlook.com (10.58.144.64) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.282.5 via Frontend Transport; Thu, 7 Dec 2017 08:35:31 +0000 Received: from uefi-workstation.ap.freescale.net ([10.232.133.75]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vB78ZTac029128; Thu, 7 Dec 2017 01:35:30 -0700 From: Pankaj Bansal To: CC: , , , Pankaj Bansal Date: Thu, 7 Dec 2017 14:05:19 +0530 Message-ID: <1512635719-32003-1-git-send-email-pankaj.bansal@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131571093313821869; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(336005)(7966004)(39380400002)(39860400002)(376002)(346002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(356003)(305945005)(498600001)(106466001)(86362001)(105606002)(104016004)(47776003)(8656006)(2351001)(85426001)(4326008)(5660300001)(81156014)(81166006)(8936002)(51416003)(48376002)(68736007)(33646002)(8676002)(50466002)(50226002)(6666003)(53936002)(6916009)(77096006)(54906003)(2906002)(97736004)(551934003)(316002)(16586007)(36756003)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2360; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD001; 1:K+sqS73Z+3AnsrEOidIYpVOeYXxhr64Ydg1cjPwyLI2cm9njc1MNtEMfBYf7dC3ZTRhjAzUFraYpF33u9gl5XVQwq+22IALcMvLS0VgtIwZ198itUBOud8uCUM/fp+zV MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01604482-9cd6-4f6e-1cad-08d53d4d7a25 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603286); SRVR:CO2PR03MB2360; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2360; 3:CcHsWb1VfAx82wfb2q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5RjXJIPqOlqKOHXmokIQA0kEHxKw1ZEIV+/MYt5OzyJHvcrKErWf7EpYwVqJgTjZDrBf02cxQ1KQIY6Z69LPULf+VX0sVdOWwR4u4kW3NwzNM0deEngdDg2Im9Q20s0dziYyGEBBAga001P2gAnaIo0ldRRYp2sXg8j1ICNs44d0O4whrNB8Iki7n8A7hhYYfYYCBV72N3XGJKEVoa2qHXDWL569JC0YdF7/XbcD+RJjSzy2E+4FsrdmukEJLwgmqjsmHXX+ox3obkaZz7IsifFpdUKqbJzL+jJ8AEj1p2gP9Qi X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(185117386973197)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(3231022)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123565025)(20161123556025)(20161123559100)(20161123561025)(20161123563025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(201708071742011); SRVR:CO2PR03MB2360; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:CO2PR03MB2360; X-Forefront-PRVS: 05143A8241 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2360; 23:kZkPBZTrS7ivDVh5/Swl1jHEqEj95wQhdeNS+K0gv?= =?us-ascii?Q?KaT/rNDRakKc3zFkbbGcn3UyBN++zx6CQKq2pViPE69gawQgXOWGVZBpTEox?= =?us-ascii?Q?LEDdSyzy9Ltbq/UILiGBMERS0ptOiOTxzPHCon948PoFvZYivCFTpnAf47SW?= =?us-ascii?Q?K9dC219a0MXiGgkAIVY60ICEErxMShrN9QLmdHT7W7IwsMKmF5/kq7ztZYZy?= =?us-ascii?Q?SVY81mhoFsHGityn7jSndXlwfvKlwqMhE2l4A5l3CLvZ4m4J6JDKHD5NdfWr?= =?us-ascii?Q?Jwlo+q8mPR1/pr9jM2/mim+8hUICRSjYWsdfZsJBX/JZzi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E4LY4er4NiagtocS50F0JB/uqw9c+A1Fm/JAXCRJ5itg3sZ7i+AAqzn9OHWY/QlyeoMf57N3Zdbr9/9poi0jusD1fIPz3/3U2PEI4t7lmRBd3ag70b3rjxRve0gL+BMdhuzK7x1z24xrWaQhqABlGAdr45QynvtJDjEq2GyLFPxTNeXmk904fwOxTXc52D35LwCgDPS0OwPTwtXFCNqSnRbr0fqvDEhNitM1uIhQ3LTpOn1qZvKLx7Lx87oGciKuuvwsS+jll/Gvk81Ymz+202Ka60m+1vZXAcrN5YzxJtfWacpr7eI=; 5:VED/Bd4q1Fh4XXKcWpa6C8LO6tz6DK4Sn9NGTm3NYpkYn4buyt2HFO60Nq5QvSB1uVCxWRbI2gmOQIsfd4CAf3ESUFh58Wj6yjC4LIQ8PI5GCTi4CqF31hsLeOHdmf6MeF4Y/omjZvHzoXjUexmvE7yHJinlMAAYLCh2UvwWsIQ=; 24:n4NNsQgtOJNZXOoBlv+BF9S6nn95JAuBt7KWuTv+5aTAp88FQOprawFt0fGJbgGHMhB+GAtdEFzUoKgwkdSzVwef1Cd0z6KLf9Fy3jmATsI=; 7:/durjQPnh/Sxb8bu/4IlksZTn92l05pSkWPtdCGJ97/MUY79T8X3YZZrkNM7Zy4Gkk7TDBoTaRLtJ3Tx2qWgrK2nsLlKBUhSW4KoEyHxkYlpGQO0pY26ZKWraZ+u1Q0r+hIxaMvXLUVuX0/qGaPRhFoaoNntX4aXJuUkUY0zfxe+T8ykjslWfJdk7V116VPKOtDHGzRfcuiBxfiWUsIgUENa/pNng6rd68eOaE88HRPCzdU3BZBNqbi2Z9AvLjlq SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2017 08:35:31.2105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01604482-9cd6-4f6e-1cad-08d53d4d7a25 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2360 Subject: [RFC] MdePkg/Spi : Modify SPI Protocol strctures to make it more generic X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2017 08:31:05 -0000 Content-Type: text/plain Issue_1: Currenty SPI IO and SPI HC protocol strcture is not equipped to handle all type of SPI commands e.g. QuadIo Read Command (0xEBh) in spansion flash S25FS512S will not work. Cause: Currenty SPI protocol describes a SPI transaction as combination of data and address and command, which would all be transmitted on same data bus (1 or 2 or 4). BUT when we have a case in which command is send one single data bus and address and data is sent one 4 data bus (like 0xEB in spansion), then this will not work with current strcture. Fix: Instead of making a single transaction, we can specify a group of transactions (called packet, terminology borrowed from I2c Protocol) in which each transaction specifies the data width, frequency, delay and read/write info. Issue_2: Specify additional data about SPI transaction (i.e. transaction is of type cmd, address, data, dummy etc). some controllers need this info to communicate with SPI peripheral. others can ignore this info. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pankaj Bansal --- MdePkg/Include/Protocol/SpiHc.h | 15 +- MdePkg/Include/Protocol/SpiIo.h | 250 ++++++++++++------------------ 2 files changed, 104 insertions(+), 161 deletions(-) diff --git a/MdePkg/Include/Protocol/SpiHc.h b/MdePkg/Include/Protocol/SpiHc.h index 12fe5d2..65964bc 100644 --- a/MdePkg/Include/Protocol/SpiHc.h +++ b/MdePkg/Include/Protocol/SpiHc.h @@ -110,8 +110,11 @@ typedef EFI_STATUS status. @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure. - @param[in] BusTransaction Pointer to a EFI_SPI_BUS_ TRANSACTION containing - the description of the SPI transaction to perform. + @param[in] SpiPeripheral The address of an EFI_SPI_PERIPHERAL data structure + describing the SPI peripheral from(to) which + read(write) transactions to be performed. + @param[in] RequestPacket Pointer to a EFI_SPI_REQUEST_PACKET containing + the description of the SPI transactions to perform. @retval EFI_SUCCESS The transaction completed successfully @retval EFI_BAD_BUFFER_SIZE The BusTransaction->WriteBytes value is invalid, @@ -124,7 +127,8 @@ typedef EFI_STATUS typedef EFI_STATUS (EFIAPI *EFI_SPI_HC_PROTOCOL_TRANSACTION) ( IN CONST EFI_SPI_HC_PROTOCOL *This, - IN EFI_SPI_BUS_TRANSACTION *BusTransaction + IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral; + IN EFI_SPI_REQUEST_PACKET *RequestPacket ); /// @@ -135,7 +139,6 @@ struct _EFI_SPI_HC_PROTOCOL { /// Host control attributes, may have zero or more of the following set: /// * HC_SUPPORTS_WRITE_ONLY_OPERATIONS /// * HC_SUPPORTS_READ_ONLY_OPERATIONS - /// * HC_SUPPORTS_WRITE_THEN_READ_OPERATIONS /// * HC_TX_FRAME_IN_MOST_SIGNIFICANT_BITS /// - The SPI host controller requires the transmit frame to be in most /// significant bits instead of least significant bits.The host driver @@ -149,10 +152,6 @@ struct _EFI_SPI_HC_PROTOCOL { /// - The SPI controller supports a 2 - bit data bus /// * HC_SUPPORTS_4_B1T_DATA_BUS_WIDTH /// - The SPI controller supports a 4 - bit data bus - /// * HC_TRANSFER_SIZE_INCLUDES_OPCODE - /// - Transfer size includes the opcode byte - /// * HC_TRANSFER_SIZE_INCLUDES_ADDRESS - /// - Transfer size includes the 3 address bytes /// The SPI host controller must support full - duplex (receive while /// sending) operation.The SPI host controller must support a 1 - bit bus /// width. diff --git a/MdePkg/Include/Protocol/SpiIo.h b/MdePkg/Include/Protocol/SpiIo.h index 43e8045..507abb5 100644 --- a/MdePkg/Include/Protocol/SpiIo.h +++ b/MdePkg/Include/Protocol/SpiIo.h @@ -27,147 +27,33 @@ typedef struct _EFI_SPI_IO_PROTOCOL EFI_SPI_IO_PROTOCOL; /// Note: The UEFI PI 1.6 specification does not specify values for the /// members below. The order matches the specification. /// +/// +/// SPI peripheral transfer type +/// +/// The EFI_SPI_TRANSACTION_TYPE describes the type of SPI transaction to either +/// send or recievce from SPI peripheral. +/// some SPI controllers need this information to complete a SPI operation +/// (which consists of one or many transactions) +/// +/// for other controllers this field may be left 0 (SPI_TRANSACTION_NONE) +/// typedef enum { - /// - /// Data flowing in both direction between the host and - /// SPI peripheral.ReadBytes must equal WriteBytes and both ReadBuffer and - /// WriteBuffer must be provided. - /// - SPI_TRANSACTION_FULL_DUPLEX, - - /// - /// Data flowing from the host to the SPI peripheral.ReadBytes must be - /// zero.WriteBytes must be non - zero and WriteBuffer must be provided. - /// - SPI_TRANSACTION_WRITE_ONLY, - - /// - /// Data flowing from the SPI peripheral to the host.WriteBytes must be - /// zero.ReadBytes must be non - zero and ReadBuffer must be provided. - /// - SPI_TRANSACTION_READ_ONLY, - - /// - /// Data first flowing from the host to the SPI peripheral and then data - /// flows from the SPI peripheral to the host.These types of operations get - /// used for SPI flash devices when control data (opcode, address) must be - /// passed to the SPI peripheral to specify the data to be read. - /// - SPI_TRANSACTION_WRITE_THEN_READ -} EFI_SPI_TRANSACTION_TYPE; - -/** - Initiate a SPI transaction between the host and a SPI peripheral. - - This routine must be called at or below TPL_NOTIFY. - This routine works with the SPI bus layer to pass the SPI transaction to the - SPI controller for execution on the SPI bus. There are four types of - supported transactions supported by this routine: - * Full Duplex: WriteBuffer and ReadBuffer are the same size. - * Write Only: WriteBuffer contains data for SPI peripheral, ReadBytes = 0 - * Read Only: ReadBuffer to receive data from SPI peripheral, WriteBytes = 0 - * Write Then Read: WriteBuffer contains control data to write to SPI - peripheral before data is placed into the ReadBuffer. - Both WriteBytes and ReadBytes must be non-zero. - - @param[in] This Pointer to an EFI_SPI_IO_PROTOCOL structure. - @param[in] TransactionType Type of SPI transaction. - @param[in] DebugTransaction Set TRUE only when debugging is desired. - Debugging may be turned on for a single SPI - transaction. Only this transaction will display - debugging messages. All other transactions with - this value set to FALSE will not display any - debugging messages. - @param[in] ClockHz Specify the ClockHz value as zero (0) to use - the maximum clock frequency supported by the - SPI controller and part. Specify a non-zero - value only when a specific SPI transaction - requires a reduced clock rate. - @param[in] BusWidth Width of the SPI bus in bits: 1, 2, 4 - @param[in] FrameSize Frame size in bits, range: 1 - 32 - @param[in] WriteBytes The length of the WriteBuffer in bytes. - Specify zero for read-only operations. - @param[in] WriteBuffer The buffer containing data to be sent from the - host to the SPI chip. Specify NULL for read - only operations. - * Frame sizes 1-8 bits: UINT8 (one byte) per - frame - * Frame sizes 7-16 bits: UINT16 (two bytes) per - frame - * Frame sizes 17-32 bits: UINT32 (four bytes) - per frame The transmit frame is in the least - significant N bits. - @param[in] ReadBytes The length of the ReadBuffer in bytes. - Specify zero for write-only operations. - @param[out] ReadBuffer The buffer to receeive data from the SPI chip - during the transaction. Specify NULL for write - only operations. - * Frame sizes 1-8 bits: UINT8 (one byte) per - frame - * Frame sizes 7-16 bits: UINT16 (two bytes) per - frame - * Frame sizes 17-32 bits: UINT32 (four bytes) - per frame The received frame is in the least - significant N bits. - - @retval EFI_SUCCESS The SPI transaction completed successfully - @retval EFI_BAD_BUFFER_SIZE The writeBytes value was invalid - @retval EFI_BAD_BUFFER_SIZE The ReadBytes value was invalid - @retval EFI_INVALID_PARAMETER TransactionType is not valid, - or BusWidth not supported by SPI peripheral or - SPI host controller, - or WriteBytes non-zero and WriteBuffer is - NULL, - or ReadBytes non-zero and ReadBuffer is NULL, - or ReadBuffer != WriteBuffer for full-duplex - type, - or WriteBuffer was NULL, - or TPL is too high - @retval EFI_OUT_OF_RESOURCES Insufficient memory for SPI transaction - @retval EFI_UNSUPPORTED The FrameSize is not supported by the SPI bus - layer or the SPI host controller - @retval EFI_UNSUPPORTED The SPI controller was not able to support - -**/ -typedef -EFI_STATUS -(EFIAPI *EFI_SPI_IO_PROTOCOL_TRANSACTION) ( - IN CONST EFI_SPI_IO_PROTOCOL *This, - IN EFI_SPI_TRANSACTION_TYPE TransactionType, - IN BOOLEAN DebugTransaction, - IN UINT32 ClockHz OPTIONAL, - IN UINT32 BusWidth, - IN UINT32 FrameSize, - IN UINT32 WriteBytes, - IN UINT8 *WriteBuffer, - IN UINT32 ReadBytes, - OUT UINT8 *ReadBuffer - ); + SPI_TRANSACTION_NONE = 0, -/** - Update the SPI peripheral associated with this SPI 10 instance. + /// Command to send to SPI peripheral + SPI_TRANSACTION_COMMAND, - Support socketed SPI parts by allowing the SPI peripheral driver to replace - the SPI peripheral after the connection is made. An example use is socketed - SPI NOR flash parts, where the size and parameters change depending upon - device is in the socket. + /// Address from/to which data is to be read/written + SPI_TRANSACTION_ADDRESS, - @param[in] This Pointer to an EFI_SPI_IO_PROTOCOL structure. - @param[in] SpiPeripheral Pointer to an EFI_SPI_PERIPHERAL structure. + /// Dummy cycles + /// Some SPI peripherals need dummy clock cycles which can be used by + /// peripherals to have some delay between transfers. + SPI_TRANSACTION_DUMMY, - @retval EFI_SUCCESS The SPI peripheral was updated successfully - @retval EFI_INVALID_PARAMETER The SpiPeripheral value is NULL, - or the SpiPeripheral->SpiBus is NULL, - or the SpiP eripheral - >SpiBus pointing at - wrong bus, - or the SpiP eripheral - >SpiPart is NULL - -**/ -typedef EFI_STATUS -(EFIAPI *EFI_SPI_IO_PROTOCOL_UPDATE_SPI_PERIPHERAL) ( - IN CONST EFI_SPI_IO_PROTOCOL *This, - IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral - ); + /// Data Request (Read/write) + SPI_TRANSACTION_DATA, +} EFI_SPI_TRANSACTION_TYPE; /// /// The EFI_SPI_BUS_ TRANSACTION data structure contains the description of the @@ -175,11 +61,6 @@ typedef EFI_STATUS /// typedef struct _EFI_SPI_BUS_TRANSACTION { /// - /// Pointer to the SPI peripheral being manipulated. - /// - CONST EFI_SPI_PERIPHERAL *SpiPeripheral; - - /// /// Type of transaction specified by one of the EFI_SPI_TRANSACTION_TYPE /// values. /// @@ -204,9 +85,9 @@ typedef struct _EFI_SPI_BUS_TRANSACTION { UINT32 FrameSize; /// - /// Length of the write buffer in bytes + /// Length of the buffer (read or write or both) in bytes /// - UINT32 WriteBytes; + UINT32 Bytes; /// /// Buffer containing data to send to the SPI peripheral @@ -216,20 +97,87 @@ typedef struct _EFI_SPI_BUS_TRANSACTION { UINT8 *WriteBuffer; /// - /// Length of the read buffer in bytes - /// - UINT32 ReadBytes; - - /// /// Buffer to receive the data from the SPI peripheral /// * Frame sizes 1 - 8 bits: UINT8 (one byte) per frame /// * Frame sizes 7 - 16 bits : UINT16 (two bytes) per frame /// * Frame sizes 17 - 32 bits : UINT32 (four bytes) per frame /// UINT8 *ReadBuffer; + + /// delay afer transaction + UINT32 DelayMicroSeconds; + + /// Specify the ClockHz value as zero (0) to use + /// the maximum clock frequency supported by the + /// SPI controller and part. Specify a non-zero + /// value only when a specific SPI transaction + /// requires a reduced clock rate. + UINT32 ClockHz; } EFI_SPI_BUS_TRANSACTION; /// +/// SPI device request +/// +/// The EFI_SPI_REQUEST_PACKET describes single SPI operation, +/// between Chip Select deassert and Chip Select assert. +/// Some operation will consist of a single transaction while others will +/// be two or more. +/// +typedef struct _EFI_SPI_REQUEST_PACKET { + /// + /// Number of elements in the operation array + /// + UINTN TransactionCount; + /// + /// Description of the SPI operation + /// + EFI_SPI_BUS_TRANSACTION Transaction [1]; +} EFI_SPI_REQUEST_PACKET; + +/** + Initiate a SPI transaction between the host and a SPI peripheral. + + This routine must be called at or below TPL_NOTIFY. + This routine works with the SPI bus layer to pass the SPI transaction to the + SPI controller for execution on the SPI bus. + + @param[in] This Pointer to an EFI_SPI_IO_PROTOCOL structure. + @param[in] RequestPacket Pointer to an EFI_SPI_REQUEST_PACKET structure + describing the SPI transaction +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SPI_IO_PROTOCOL_TRANSACTION) ( + IN CONST EFI_SPI_IO_PROTOCOL *This, + IN EFI_SPI_REQUEST_PACKET *RequestPacket, + ); + +/** + Update the SPI peripheral associated with this SPI 10 instance. + + Support socketed SPI parts by allowing the SPI peripheral driver to replace + the SPI peripheral after the connection is made. An example use is socketed + SPI NOR flash parts, where the size and parameters change depending upon + device is in the socket. + + @param[in] This Pointer to an EFI_SPI_IO_PROTOCOL structure. + @param[in] SpiPeripheral Pointer to an EFI_SPI_PERIPHERAL structure. + + @retval EFI_SUCCESS The SPI peripheral was updated successfully + @retval EFI_INVALID_PARAMETER The SpiPeripheral value is NULL, + or the SpiPeripheral->SpiBus is NULL, + or the SpiP eripheral - >SpiBus pointing at + wrong bus, + or the SpiP eripheral - >SpiPart is NULL + +**/ +typedef EFI_STATUS +(EFIAPI *EFI_SPI_IO_PROTOCOL_UPDATE_SPI_PERIPHERAL) ( + IN CONST EFI_SPI_IO_PROTOCOL *This, + IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral + ); + +/// /// Support managed SPI data transactions between the SPI controller and a SPI /// chip. /// @@ -262,14 +210,10 @@ struct _EFI_SPI_IO_PROTOCOL { /// /// Transaction attributes: One or more from: - /// * SPI_10_SUPPORTS_2_B1T_DATA_BUS_W1DTH + /// * SPI_IO_SUPPORTS_2_B1T_DATA_BUS_W1DTH /// - The SPI host and peripheral supports a 2-bit data bus /// * SPI_IO_SUPPORTS_4_BIT_DATA_BUS_W1DTH /// - The SPI host and peripheral supports a 4-bit data bus - /// * SPI_IO_TRANSFER_SIZE_INCLUDES_OPCODE - /// - Transfer size includes the opcode byte - /// * SPI_IO_TRANSFER_SIZE_INCLUDES_ADDRESS - /// - Transfer size includes the 3 address bytes /// UINT32 Attributes; -- 2.7.4