13cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** @file 23cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Intel ICH9 SMBUS library implementation built upon I/O library. 33cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 43cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> 53cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 63cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 73cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This program and the accompanying materials are licensed and made available under 83cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 93cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei the terms and conditions of the BSD License that accompanies this distribution. 103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The full text of the license may be found at 123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei http://opensource.org/licenses/bsd-license.php. 143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei#include "CommonHeader.h" 273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Gets Io port base address of Smbus Host Controller. 303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This internal function depends on a feature flag named PcdIchSmbusFixedIoPortBaseAddress 323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei to retrieve Smbus Io port base. If that feature flag is true, it will get Smbus Io port base 333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei address from a preset Pcd entry named PcdIchSmbusIoPortBaseAddress; otherwise, it will always 343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei read Pci configuration space to get that value in each Smbus bus transaction. 353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The Io port base address of Smbus host controller. 373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 393cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN 403cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInternalGetSmbusIoPortBaseAddress ( 413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei VOID 423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN IoPortBaseAddress; 453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoPortBaseAddress = (UINTN) MmioRead32 (MmPciAddress (0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_SMBUS, PCI_FUNCTION_NUMBER_PCH_SMBUS, R_PCH_SMBUS_BASE)) & B_PCH_SMBUS_BASE_BAR; 473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Make sure that the IO port base address has been properly set. 503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (IoPortBaseAddress != 0); 523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return IoPortBaseAddress; 543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Acquires the ownership of SMBUS. 583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This internal function reads the host state register. 603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If the SMBUS is not available, RETURN_TIMEOUT is returned; 613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Otherwise, it performs some basic initializations and returns 623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RETURN_SUCCESS. 633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param IoPortBaseAddress The Io port base address of Smbus Host controller. 653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval RETURN_SUCCESS The SMBUS command was executed successfully. 673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval RETURN_TIMEOUT A timeout occurred while executing the SMBUS command. 683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 703cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiRETURN_STATUS 713cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInternalSmBusAcquire ( 723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN IoPortBaseAddress 733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 HostStatus; 763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei HostStatus = IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS); 783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ((HostStatus & B_PCH_SMBUS_IUS) != 0) { 793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return RETURN_TIMEOUT; 803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } else if ((HostStatus & B_PCH_SMBUS_HBSY) != 0) { 813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear host status register and exit. 833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS, B_PCH_SMBUS_HSTS_ALL); 853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return RETURN_TIMEOUT; 863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear out any odd status information (Will Not Clear In Use). 893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS, HostStatus); 913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return RETURN_SUCCESS; 933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Starts the SMBUS transaction and waits until the end. 973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This internal function start the SMBUS transaction and waits until the transaction 993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei of SMBUS is over by polling the INTR bit of Host status register. 1003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If the SMBUS is not available, RETURN_TIMEOUT is returned; 1013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Otherwise, it performs some basic initializations and returns 1023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RETURN_SUCCESS. 1033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param IoPortBaseAddress The Io port base address of Smbus Host controller. 1053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param HostControl The Host control command to start SMBUS transaction. 1063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval RETURN_SUCCESS The SMBUS command was executed successfully. 1083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect). 1093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected 1103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei in the Host Status Register bit. Device errors are 1113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei a result of a transaction collision, illegal command field, 1123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei unclaimed cycle (host initiated), or bus errors (collisions). 1133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 1153cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiRETURN_STATUS 1163cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInternalSmBusStart ( 1173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN IoPortBaseAddress, 1183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 HostControl 1193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 1203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 1213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 HostStatus; 1223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 AuxiliaryStatus; 1233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Host Control Register (Initiate Operation, Interrupt disabled). 1263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HCTL, (UINT8)(HostControl + B_PCH_SMBUS_START)); 1283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei do { 1303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Poll INTR bit of Host Status Register. 1323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei HostStatus = IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS); 1343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } while ((HostStatus & (B_PCH_SMBUS_INTR | B_PCH_SMBUS_ERRORS | B_PCH_SMBUS_BYTE_DONE_STS)) == 0); 1353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ((HostStatus & B_PCH_SMBUS_ERRORS) == 0) { 1373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return RETURN_SUCCESS; 1383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear error bits of Host Status Register. 1423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS, B_PCH_SMBUS_ERRORS); 1443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Read Auxiliary Status Register to judge CRC error. 1473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei AuxiliaryStatus = IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_AUXS); 1493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if ((AuxiliaryStatus & B_PCH_SMBUS_CRCE) != 0) { 1503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return RETURN_CRC_ERROR; 1513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return RETURN_DEVICE_ERROR; 1543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 1553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 1573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS quick, byte or word command. 1583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This internal function executes an SMBUS quick, byte or word commond. 1603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 1613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param HostControl The value of Host Control Register to set. 1633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 1643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 1653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Value The byte/word write to the SMBUS. 1663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 1673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 1683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The byte/word read from the SMBUS. 1703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 1723cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT16 1733cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInternalSmBusNonBlock ( 1743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 HostControl, 1753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 1763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT16 Value, 1773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status 1783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 1793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 1803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RETURN_STATUS ReturnStatus; 1813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN IoPortBaseAddress; 1823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 AuxiliaryControl; 1833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoPortBaseAddress = InternalGetSmbusIoPortBaseAddress (); 1853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Try to acquire the ownership of ICH SMBUS. 1883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReturnStatus = InternalSmBusAcquire (IoPortBaseAddress); 1903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (RETURN_ERROR (ReturnStatus)) { 1913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei goto Done; 1923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 1933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 1943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set the appropriate Host Control Register and auxiliary Control Register. 1963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 1973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei AuxiliaryControl = 0; 1983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (SMBUS_LIB_PEC (SmBusAddress)) { 1993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei AuxiliaryControl |= B_PCH_SMBUS_AAC; 2003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei HostControl |= B_PCH_SMBUS_PEC_EN; 2013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 2023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Host Command Register. 2053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HCMD, (UINT8) SMBUS_LIB_COMMAND (SmBusAddress)); 2073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write value to Host Data 0 and Host Data 1 Registers. 2103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HD0, (UINT8) Value); 2123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HD1, (UINT8) (Value >> 8)); 2133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Auxiliary Control Register. 2163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_AUXC, AuxiliaryControl); 2183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set SMBUS slave address for the device to send/receive from. 2213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_TSA, (UINT8) SmBusAddress); 2233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Start the SMBUS transaction and wait for the end. 2263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReturnStatus = InternalSmBusStart (IoPortBaseAddress, HostControl); 2283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Read value from Host Data 0 and Host Data 1 Registers. 2313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value = (UINT16)(IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HD1) << 8); 2333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value = (UINT16)(Value | IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HD0)); 2343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear Host Status Register and Auxiliary Status Register. 2373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 2383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS, B_PCH_SMBUS_HSTS_ALL); 2393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_AUXS, B_PCH_SMBUS_CRCE); 2403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2413cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiDone: 2423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Status != NULL) { 2433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei *Status = ReturnStatus; 2443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 2453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return Value; 2473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 2483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 2503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS quick read command. 2513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress. 2533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address field of SmBusAddress is required. 2543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 2553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If PEC is set in SmBusAddress, then ASSERT(). 2563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Command in SmBusAddress is not zero, then ASSERT(). 2573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 2583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 2593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 2613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 2623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 2633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 2643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 2663cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 2673cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 2683cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusQuickRead ( 2693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 2703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 2713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 2723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 2733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); 2743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); 2753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 2763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 2773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InternalSmBusNonBlock ( 2793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_QUICK, 2803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_READ, 2813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 2823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 2833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 2843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 2853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 2873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS quick write command. 2883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress. 2903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address field of SmBusAddress is required. 2913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 2923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If PEC is set in SmBusAddress, then ASSERT(). 2933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Command in SmBusAddress is not zero, then ASSERT(). 2943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 2953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 2963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 2973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 2983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 2993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 3003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 3013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 3033cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiVOID 3043cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 3053cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusQuickWrite ( 3063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 3073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 3083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 3093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 3103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); 3113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); 3123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 3133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 3143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei InternalSmBusNonBlock ( 3163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_QUICK, 3173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 3183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 3193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 3203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 3213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 3223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 3243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS receive byte command. 3253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress. 3273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address field of SmBusAddress is required. 3283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The byte received from the SMBUS is returned. 3293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 3303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Command in SmBusAddress is not zero, then ASSERT(). 3313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 3323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 3333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 3353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 3363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 3373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 3383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The byte received from the SMBUS. 3403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 3423cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 3433cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 3443cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusReceiveByte ( 3453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 3463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 3473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 3483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 3493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 ValueReturn = 0; 3503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); 3523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 3533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 3543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = (UINT8) InternalSmBusNonBlock ( 3563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_BYTE, 3573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_READ, 3583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 3593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 3603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 3613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 3623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 3643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 3663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS send byte command. 3673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress. 3693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The byte specified by Value is sent. 3703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address field of SmBusAddress is required. Value is returned. 3713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 3723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Command in SmBusAddress is not zero, then ASSERT(). 3733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 3743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 3753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 3773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 3783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Value The 8-bit value to send. 3793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 3803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 3813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The parameter of Value. 3833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 3853cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 3863cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 3873cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusSendByte ( 3883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 3893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 Value, 3903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 3913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 3923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 3933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 ValueReturn = 0; 3943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); 3963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 3973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 3983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 3993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = (UINT8) InternalSmBusNonBlock ( 4003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_BYTE, 4013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 4023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value, 4033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 4043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 4053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 4063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 4083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 4103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS read data byte command. 4113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress. 4133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. 4143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The 8-bit value read from the SMBUS is returned. 4153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 4163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 4173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 4183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 4203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 4213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 4223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 4233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The byte read from the SMBUS. 4253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 4273cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 4283cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 4293cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusReadDataByte ( 4303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 4313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 4323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 4333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 4343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 ValueReturn = 0; 4353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 4373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 4383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = (UINT8) InternalSmBusNonBlock ( 4393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_BYTE_DATA, 4403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_READ, 4413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 4423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 4433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 4443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 4453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 4463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 4483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS write data byte command. 4493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress. 4513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The 8-bit value specified by Value is written. 4523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. 4533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value is returned. 4543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 4553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 4563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 4573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 4593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 4603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Value The 8-bit value to write. 4613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 4623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 4633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The parameter of Value. 4653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 4673cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT8 4683cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 4693cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusWriteDataByte ( 4703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 4713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 Value, 4723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 4733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 4743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 4753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 ValueReturn = 0; 4763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 4783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 4793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = (UINT8) InternalSmBusNonBlock ( 4813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_BYTE_DATA, 4823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 4833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value, 4843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 4853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 4863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 4873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 4893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 4913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS read data word command. 4923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 4933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress. 4943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. 4953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The 16-bit value read from the SMBUS is returned. 4963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 4973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 4983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 4993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 5013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 5023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 5033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 5043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The byte read from the SMBUS. 5063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 5083cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT16 5093cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 5103cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusReadDataWord ( 5113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 5123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 5133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 5143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 5153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 ValueReturn = 0; 5163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 5173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 5183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = InternalSmBusNonBlock ( 5203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_WORD_DATA, 5213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_READ, 5223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 0, 5233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 5243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 5253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 5263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 5283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 5303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS write data word command. 5313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress. 5333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The 16-bit value specified by Value is written. 5343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. 5353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value is returned. 5363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 5373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 5383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 5393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 5413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 5423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Value The 16-bit value to write. 5433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 5443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 5453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The parameter of Value. 5473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 5493cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT16 5503cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 5513cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusWriteDataWord ( 5523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 5533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT16 Value, 5543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 5553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 5563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 5573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 ValueReturn = 0; 5583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 5593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 5603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = InternalSmBusNonBlock ( 5623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_WORD_DATA, 5633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 5643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value, 5653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 5663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 5673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 5683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 5693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 5713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS process call command. 5723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress. 5743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The 16-bit value specified by Value is written. 5753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. 5763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The 16-bit value returned by the process call command is returned. 5773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 5783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 5793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 5803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 5823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 5833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Value The 16-bit value to write. 5843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 5853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 5863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The 16-bit value returned by the process call command. 5883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 5893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 5903cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINT16 5913cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 5923cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusProcessCall ( 5933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 5943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT16 Value, 5953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 5963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 5973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 5983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT16 ValueReturn = 0; 5993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 6003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 6013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ValueReturn = InternalSmBusNonBlock ( 6033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_PROCESS_CALL, 6043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 6053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Value, 6063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 6073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 6083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return ValueReturn; 6093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 6103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 6123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS block command. 6133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS block read, block write and block write-block read command 6153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei on the SMBUS device specified by SmBusAddress. 6163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Bytes are read from the SMBUS and stored in Buffer. 6173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The number of bytes read is returned, and will never return a value larger than 32-bytes. 6183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 6193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. 6203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. 6213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param HostControl The value of Host Control Register to set. 6233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 6243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 6253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. 6263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. 6273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 6283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 6293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The number of bytes read from the SMBUS. 6313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 6333cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN 6343cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiInternalSmBusBlock ( 6353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 HostControl, 6363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 6373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINT8 *WriteBuffer, 6383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT UINT8 *ReadBuffer, 6393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status 6403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 6413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 6423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei RETURN_STATUS ReturnStatus; 6433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN Index; 6443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN BytesCount; 6453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN IoPortBaseAddress; 6463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINT8 AuxiliaryControl; 6473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoPortBaseAddress = InternalGetSmbusIoPortBaseAddress (); 6493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BytesCount = SMBUS_LIB_LENGTH (SmBusAddress); 6513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Try to acquire the ownership of ICH SMBUS. 6543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReturnStatus = InternalSmBusAcquire (IoPortBaseAddress); 6563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (RETURN_ERROR (ReturnStatus)) { 6573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei goto Done; 6583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 6593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set the appropriate Host Control Register and auxiliary Control Register. 6623cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6633cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei AuxiliaryControl = B_PCH_SMBUS_E32B; 6643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (SMBUS_LIB_PEC (SmBusAddress)) { 6653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei AuxiliaryControl |= B_PCH_SMBUS_AAC; 6663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei HostControl |= B_PCH_SMBUS_PEC_EN; 6673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 6683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Host Command Register. 6713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HCMD, (UINT8) SMBUS_LIB_COMMAND (SmBusAddress)); 6733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set Auxiliary Control Regiester. 6763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_AUXC, AuxiliaryControl); 6783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear byte pointer of 32-byte buffer. 6813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HCTL); 6833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (WriteBuffer != NULL) { 6853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write the number of block to Host Block Data Byte Register. 6873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HD0, (UINT8) BytesCount); 6893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write data block to Host Block Data Register. 6923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei for (Index = 0; Index < BytesCount; Index++) { 6943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HBD, WriteBuffer[Index]); 6953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 6963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 6973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 6983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 6993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Set SMBUS slave address for the device to send/receive from. 7003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_TSA, (UINT8) SmBusAddress); 7023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Start the SMBUS transaction and wait for the end. 7053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReturnStatus = InternalSmBusStart (IoPortBaseAddress, HostControl); 7073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (RETURN_ERROR (ReturnStatus)) { 7083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei goto Done; 7093cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 7103cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7113cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (ReadBuffer != NULL) { 7123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Read the number of block from host block data byte register. 7143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BytesCount = IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HD0); 7163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Write data block from Host Block Data Register. 7193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei for (Index = 0; Index < BytesCount; Index++) { 7213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ReadBuffer[Index] = IoRead8 (IoPortBaseAddress + R_PCH_SMBUS_HBD); 7223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 7233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 7243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7253cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiDone: 7263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // Clear Host Status Register and Auxiliary Status Register. 7283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei // 7293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_HSTS, B_PCH_SMBUS_HSTS_ALL); 7303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IoWrite8 (IoPortBaseAddress + R_PCH_SMBUS_AUXS, B_PCH_SMBUS_CRCE); 7313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei if (Status != NULL) { 7333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei *Status = ReturnStatus; 7343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei } 7353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return BytesCount; 7373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 7383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 7403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS read block command. 7413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress. 7433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required. 7443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Bytes are read from the SMBUS and stored in Buffer. 7453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The number of bytes read is returned, and will never return a value larger than 32-bytes. 7463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 7473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read. 7483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. 7493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is not zero, then ASSERT(). 7503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Buffer is NULL, then ASSERT(). 7513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 7523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 7543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 7553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. 7563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 7573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 7583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The number of bytes read. 7603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7613cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 7623cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN 7633cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 7643cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusReadBlock ( 7653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 7663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT VOID *Buffer, 7673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 7683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 7693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 7703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN BytesCount = 0; 7713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (Buffer != NULL); 7733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); 7743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 7753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BytesCount = InternalSmBusBlock ( 7783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_BLOCK, 7793cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_READ, 7803cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 7813cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Buffer, 7823cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 7833cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 7843cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return BytesCount; 7853cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7863cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 7873cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7883cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 7893cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS write block command. 7903cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 7913cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress. 7923cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. 7933cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Bytes are written to the SMBUS from Buffer. 7943cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The number of bytes written is returned, and will never return a value larger than 32-bytes. 7953cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 7963cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is zero or greater than 32, then ASSERT(). 7973cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Buffer is NULL, then ASSERT(). 7983cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 7993cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8003cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 8013cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 8023cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Buffer Pointer to the buffer to store the bytes read from the SMBUS. 8033cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 8043cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 8053cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8063cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The number of bytes written. 8073cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8083cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 8093cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN 8103cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 8113cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusWriteBlock ( 8123cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 8133cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT VOID *Buffer, 8143cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 8153cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 8163cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 8173cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN BytesCount = 0; 8183cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8193cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (Buffer != NULL); 8203cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); 8213cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); 8223cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 8233cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8243cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8253cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BytesCount = InternalSmBusBlock ( 8263cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8273cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei V_PCH_SMBUS_SMB_CMD_BLOCK, 8283cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 8293cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Buffer, 8303cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei NULL, 8313cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Status 8323cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ); 8333cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8343cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei return BytesCount; 8353cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei} 8363cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8373cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei/** 8383cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS block process call command. 8393cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8403cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress. 8413cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required. 8423cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer. 8433cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Status is not NULL, then the status of the executed command is returned in Status. 8443cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read. 8453cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes. 8463cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If Length in SmBusAddress is zero or greater than 32, then ASSERT(). 8473cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If WriteBuffer is NULL, then ASSERT(). 8483cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If ReadBuffer is NULL, then ASSERT(). 8493cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei If any reserved bits of SmBusAddress are set, then ASSERT(). 8503cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8513cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param SmBusAddress Address that encodes the SMBUS Slave Address, 8523cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei SMBUS Command, SMBUS Data Length, and PEC. 8533cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS. 8543cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS. 8553cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @param Status Return status for the executed command. 8563cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei This is an optional parameter and may be NULL. 8573cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8583cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei @return The number of bytes written. 8593cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8603cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei**/ 8613cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiUINTN 8623cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiEFIAPI 8633cbfba02fef9dae07a041fdbf2e89611d72d6f90David WeiSmBusBlockProcessCall ( 8643cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN UINTN SmBusAddress, 8653cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei IN VOID *WriteBuffer, 8663cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT VOID *ReadBuffer, 8673cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei OUT RETURN_STATUS *Status OPTIONAL 8683cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ) 8693cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei{ 8703cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei UINTN BytesCount = 0; 8713cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8723cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (WriteBuffer != NULL); 8733cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (ReadBuffer != NULL); 8743cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); 8753cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); 8763cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); 8773cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei 8783cbfba02fef9dae07a041fdbf2e89611d72d6f90David Wei BytesCount = InternalSmBusBlock ( 879 V_PCH_SMBUS_SMB_CMD_BLOCK_PROCESS, 880 SmBusAddress | B_PCH_SMBUS_RW_SEL_WRITE, 881 WriteBuffer, 882 ReadBuffer, 883 Status 884 ); 885 return BytesCount; 886 887 } 888