]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Omap35xxPkg/TPS65950Dxe/TPS65950.c
ARM Packages: Fixed line endings
[mirror_edk2.git] / Omap35xxPkg / TPS65950Dxe / TPS65950.c
index 6b76da50708bb321fecc5d9af6481ed4cc39a6f8..ed19389d43516497358a0cfce3da759988123907 100644 (file)
-/** @file
-
-  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  
-  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 <Uefi.h>
-
-#include <TPS65950.h>
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include <Protocol/EmbeddedExternalDevice.h>
-#include <Protocol/SmbusHc.h>
-
-EFI_SMBUS_HC_PROTOCOL *Smbus;
-
-EFI_STATUS
-Read (
-  IN  EMBEDDED_EXTERNAL_DEVICE    *This,
-  IN  UINTN                       Register,
-  IN  UINTN                       Length,
-  OUT VOID                        *Buffer
-  )
-{
-  EFI_STATUS               Status;
-  EFI_SMBUS_DEVICE_ADDRESS SlaveAddress; 
-  UINT8                    DeviceRegister;
-  UINTN                    DeviceRegisterLength = 1;
-
-  SlaveAddress.SmbusDeviceAddress = EXTERNAL_DEVICE_REGISTER_TO_SLAVE_ADDRESS(Register);
-  DeviceRegister = (UINT8)EXTERNAL_DEVICE_REGISTER_TO_REGISTER(Register);
-
-  //Write DeviceRegister.
-  Status = Smbus->Execute(Smbus, SlaveAddress, 0, EfiSmbusWriteBlock, FALSE, &DeviceRegisterLength, &DeviceRegister);
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
-
-  //Read Data
-  Status = Smbus->Execute(Smbus, SlaveAddress, 0, EfiSmbusReadBlock, FALSE, &Length, Buffer);
-  return Status;
-}
-
-EFI_STATUS
-Write (
-  IN EMBEDDED_EXTERNAL_DEVICE   *This,
-  IN UINTN                      Register,
-  IN UINTN                      Length,
-  IN VOID                       *Buffer
-  )
-{
-  EFI_STATUS               Status;
-  EFI_SMBUS_DEVICE_ADDRESS SlaveAddress; 
-  UINT8                    DeviceRegister;
-  UINTN                    DeviceBufferLength = Length + 1;
-  UINT8                    *DeviceBuffer;
-
-  SlaveAddress.SmbusDeviceAddress = EXTERNAL_DEVICE_REGISTER_TO_SLAVE_ADDRESS(Register);
-  DeviceRegister = (UINT8)EXTERNAL_DEVICE_REGISTER_TO_REGISTER(Register);
-
-  //Prepare buffer for writing
-  DeviceBuffer = (UINT8 *)AllocatePool(DeviceBufferLength);
-  if (DeviceBuffer == NULL) {
-    Status = EFI_OUT_OF_RESOURCES;
-    goto exit;
-  }
-
-  //Set Device register followed by data to write.
-  DeviceBuffer[0] = DeviceRegister;
-  CopyMem(&DeviceBuffer[1], Buffer, Length);
-
-  //Write Data
-  Status = Smbus->Execute(Smbus, SlaveAddress, 0, EfiSmbusWriteBlock, FALSE, &DeviceBufferLength, DeviceBuffer);
-  if (EFI_ERROR(Status)) {
-    goto exit;
-  }
-
-exit:
-  if (DeviceBuffer) {
-    FreePool(DeviceBuffer);
-  }
-
-  return Status;
-}
-
-EMBEDDED_EXTERNAL_DEVICE ExternalDevice = {
-  Read,
-  Write
-};
-
-EFI_STATUS
-TPS65950Initialize (
-  IN EFI_HANDLE         ImageHandle,
-  IN EFI_SYSTEM_TABLE   *SystemTable
-  )
-{
-  EFI_STATUS  Status;
-  
-  Status = gBS->LocateProtocol(&gEfiSmbusHcProtocolGuid, NULL, (VOID **)&Smbus);
-  ASSERT_EFI_ERROR(Status);
-  
-  Status = gBS->InstallMultipleProtocolInterfaces(&ImageHandle, &gEmbeddedExternalDeviceProtocolGuid, &ExternalDevice, NULL);
-  return Status;
-}
+/** @file\r
+\r
+  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+  \r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+\r
+#include <TPS65950.h>\r
+\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#include <Protocol/EmbeddedExternalDevice.h>\r
+#include <Protocol/SmbusHc.h>\r
+\r
+EFI_SMBUS_HC_PROTOCOL *Smbus;\r
+\r
+EFI_STATUS\r
+Read (\r
+  IN  EMBEDDED_EXTERNAL_DEVICE    *This,\r
+  IN  UINTN                       Register,\r
+  IN  UINTN                       Length,\r
+  OUT VOID                        *Buffer\r
+  )\r
+{\r
+  EFI_STATUS               Status;\r
+  EFI_SMBUS_DEVICE_ADDRESS SlaveAddress; \r
+  UINT8                    DeviceRegister;\r
+  UINTN                    DeviceRegisterLength = 1;\r
+\r
+  SlaveAddress.SmbusDeviceAddress = EXTERNAL_DEVICE_REGISTER_TO_SLAVE_ADDRESS(Register);\r
+  DeviceRegister = (UINT8)EXTERNAL_DEVICE_REGISTER_TO_REGISTER(Register);\r
+\r
+  //Write DeviceRegister.\r
+  Status = Smbus->Execute(Smbus, SlaveAddress, 0, EfiSmbusWriteBlock, FALSE, &DeviceRegisterLength, &DeviceRegister);\r
+  if (EFI_ERROR(Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //Read Data\r
+  Status = Smbus->Execute(Smbus, SlaveAddress, 0, EfiSmbusReadBlock, FALSE, &Length, Buffer);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+Write (\r
+  IN EMBEDDED_EXTERNAL_DEVICE   *This,\r
+  IN UINTN                      Register,\r
+  IN UINTN                      Length,\r
+  IN VOID                       *Buffer\r
+  )\r
+{\r
+  EFI_STATUS               Status;\r
+  EFI_SMBUS_DEVICE_ADDRESS SlaveAddress; \r
+  UINT8                    DeviceRegister;\r
+  UINTN                    DeviceBufferLength = Length + 1;\r
+  UINT8                    *DeviceBuffer;\r
+\r
+  SlaveAddress.SmbusDeviceAddress = EXTERNAL_DEVICE_REGISTER_TO_SLAVE_ADDRESS(Register);\r
+  DeviceRegister = (UINT8)EXTERNAL_DEVICE_REGISTER_TO_REGISTER(Register);\r
+\r
+  //Prepare buffer for writing\r
+  DeviceBuffer = (UINT8 *)AllocatePool(DeviceBufferLength);\r
+  if (DeviceBuffer == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto exit;\r
+  }\r
+\r
+  //Set Device register followed by data to write.\r
+  DeviceBuffer[0] = DeviceRegister;\r
+  CopyMem(&DeviceBuffer[1], Buffer, Length);\r
+\r
+  //Write Data\r
+  Status = Smbus->Execute(Smbus, SlaveAddress, 0, EfiSmbusWriteBlock, FALSE, &DeviceBufferLength, DeviceBuffer);\r
+  if (EFI_ERROR(Status)) {\r
+    goto exit;\r
+  }\r
+\r
+exit:\r
+  if (DeviceBuffer) {\r
+    FreePool(DeviceBuffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+EMBEDDED_EXTERNAL_DEVICE ExternalDevice = {\r
+  Read,\r
+  Write\r
+};\r
+\r
+EFI_STATUS\r
+TPS65950Initialize (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  \r
+  Status = gBS->LocateProtocol(&gEfiSmbusHcProtocolGuid, NULL, (VOID **)&Smbus);\r
+  ASSERT_EFI_ERROR(Status);\r
+  \r
+  Status = gBS->InstallMultipleProtocolInterfaces(&ImageHandle, &gEmbeddedExternalDeviceProtocolGuid, &ExternalDevice, NULL);\r
+  return Status;\r
+}\r