Re: [edk2] [PATCH edk2-platforms 05/41] Silicon/NXP: Add support for I2c driver
On Wed, Nov 28, 2018 at 08:31:19PM +0530, Meenakshi Aggarwal wrote: > I2C driver produces gEfiI2cMasterProtocolGuid which can be > used by other modules. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Meenakshi Aggarwal Many thanks for the non-trivial rework. A few style comments below. > --- > Silicon/NXP/Drivers/I2cDxe/ComponentName.c | 185 > Silicon/NXP/Drivers/I2cDxe/DriverBinding.c | 241 ++ > Silicon/NXP/Drivers/I2cDxe/I2cDxe.c| 693 > + > Silicon/NXP/Drivers/I2cDxe/I2cDxe.h| 96 > Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf | 64 +++ > 5 files changed, 1279 insertions(+) > create mode 100644 Silicon/NXP/Drivers/I2cDxe/ComponentName.c > create mode 100644 Silicon/NXP/Drivers/I2cDxe/DriverBinding.c > create mode 100644 Silicon/NXP/Drivers/I2cDxe/I2cDxe.c > create mode 100644 Silicon/NXP/Drivers/I2cDxe/I2cDxe.h > create mode 100644 Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf > > diff --git a/Silicon/NXP/Drivers/I2cDxe/ComponentName.c > b/Silicon/NXP/Drivers/I2cDxe/ComponentName.c > new file mode 100644 > index 000..efed6b9 > --- /dev/null > +++ b/Silicon/NXP/Drivers/I2cDxe/ComponentName.c > @@ -0,0 +1,185 @@ > +/** @file > + > + Copyright 2018 NXP > + > + This program and the accompanying materials > + are licensed and made available under the terms and conditions of the BSD > License > + which accompanies this distribution. The full text of the license may be > found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR > IMPLIED. > + > +**/ > + > +#include "I2cDxe.h" > + > +STATIC EFI_UNICODE_STRING_TABLE mNxpI2cDriverNameTable[] = { > + { > +"en", > +(CHAR16 *)L"Nxp I2C Driver" > + }, > + { } > +}; > + > +STATIC EFI_UNICODE_STRING_TABLE mNxpI2cControllerNameTable[] = { > + { > +"en", > +(CHAR16 *)L"Nxp I2C Controller" > + }, > + { } > +}; > + > +/** > + Retrieves a Unicode string that is the user readable name of the driver. > + > + This function retrieves the user readable name of a driver in the form of a > + Unicode string. If the driver specified by This has a user readable name in > + the language specified by Language, then a pointer to the driver name is > + returned in DriverName, and EFI_SUCCESS is returned. If the driver > specified > + by This does not support the language specified by Language, > + then EFI_UNSUPPORTED is returned. > + > + @param This[in] A pointer to the > EFI_COMPONENT_NAME2_PROTOCOL or > +EFI_COMPONENT_NAME_PROTOCOL instance. > + > + @param Language[in] A pointer to a Null-terminated ASCII string > +array indicating the language. This is the > +language of the driver name that the caller > is > +requesting, and it must match one of the > +languages specified in SupportedLanguages. > The > +number of languages supported by a driver is > up > +to the driver writer. Language is specified > +in RFC 4646 or ISO 639-2 language code > format. > + > + @param DriverName[out] A pointer to the Unicode string to return. > +This Unicode string is the name of the > +driver specified by This in the language > +specified by Language. > + > + @retval EFI_SUCCESS The Unicode string for the Driver specified > by > +This and the language specified by Language > was > +returned in DriverName. > + > + @retval EFI_INVALID_PARAMETER Language is NULL. > + > + @retval EFI_INVALID_PARAMETER DriverName is NULL. > + > + @retval EFI_UNSUPPORTED The driver specified by This does not support > +the language specified by Language. > + > +**/ > +STATIC > +EFI_STATUS > +EFIAPI > +NxpI2cGetDriverName ( > + IN EFI_COMPONENT_NAME2_PROTOCOL *This, > + IN CHAR8 *Language, > + OUT CHAR16**DriverName > + ) > +{ > + return LookupUnicodeString2 (Language, > + This->SupportedLanguages, > + mNxpI2cDriverNameTable, > + DriverName, > + FALSE); > +} > + > +/** > + Retrieves a Unicode string that is the user readable name of the controller > + that is being managed by a driver. > + > + This function retrieves the user readable name of the controller specified > by > + ControllerHandle and ChildHandle in the form of a Unicode string. If the > +
[edk2] [PATCH edk2-platforms 05/41] Silicon/NXP: Add support for I2c driver
I2C driver produces gEfiI2cMasterProtocolGuid which can be used by other modules. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Meenakshi Aggarwal --- Silicon/NXP/Drivers/I2cDxe/ComponentName.c | 185 Silicon/NXP/Drivers/I2cDxe/DriverBinding.c | 241 ++ Silicon/NXP/Drivers/I2cDxe/I2cDxe.c| 693 + Silicon/NXP/Drivers/I2cDxe/I2cDxe.h| 96 Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf | 64 +++ 5 files changed, 1279 insertions(+) create mode 100644 Silicon/NXP/Drivers/I2cDxe/ComponentName.c create mode 100644 Silicon/NXP/Drivers/I2cDxe/DriverBinding.c create mode 100644 Silicon/NXP/Drivers/I2cDxe/I2cDxe.c create mode 100644 Silicon/NXP/Drivers/I2cDxe/I2cDxe.h create mode 100644 Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf diff --git a/Silicon/NXP/Drivers/I2cDxe/ComponentName.c b/Silicon/NXP/Drivers/I2cDxe/ComponentName.c new file mode 100644 index 000..efed6b9 --- /dev/null +++ b/Silicon/NXP/Drivers/I2cDxe/ComponentName.c @@ -0,0 +1,185 @@ +/** @file + + Copyright 2018 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include "I2cDxe.h" + +STATIC EFI_UNICODE_STRING_TABLE mNxpI2cDriverNameTable[] = { + { +"en", +(CHAR16 *)L"Nxp I2C Driver" + }, + { } +}; + +STATIC EFI_UNICODE_STRING_TABLE mNxpI2cControllerNameTable[] = { + { +"en", +(CHAR16 *)L"Nxp I2C Controller" + }, + { } +}; + +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or +EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string +array indicating the language. This is the +language of the driver name that the caller is +requesting, and it must match one of the +languages specified in SupportedLanguages. The +number of languages supported by a driver is up +to the driver writer. Language is specified +in RFC 4646 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. +This Unicode string is the name of the +driver specified by This in the language +specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by +This and the language specified by Language was +returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support +the language specified by Language. + +**/ +STATIC +EFI_STATUS +EFIAPI +NxpI2cGetDriverName ( + IN EFI_COMPONENT_NAME2_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16**DriverName + ) +{ + return LookupUnicodeString2 (Language, + This->SupportedLanguages, + mNxpI2cDriverNameTable, + DriverName, + FALSE); +} + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support