aboutsummaryrefslogtreecommitdiffstats
path: root/Chips/Hisilicon/Pv660/Drivers
diff options
context:
space:
mode:
authorZhangfei Gao <zhangfei.gao@linaro.org>2016-06-16 22:53:17 +0800
committerLeif Lindholm <leif.lindholm@linaro.org>2016-06-17 09:45:56 +0100
commit4e32c48a4ce9887797a5b935e4b53058b27ca200 (patch)
tree3f8b4b896230cf433a49c77f9cd86e9f0b6da5a1 /Chips/Hisilicon/Pv660/Drivers
parent96057b37f5c3dfee062e238a4f30e2ac9fd6c537 (diff)
downloaddevice_linaro_bootloader_OpenPlatformPkg-4e32c48a4ce9887797a5b935e4b53058b27ca200.tar.gz
device_linaro_bootloader_OpenPlatformPkg-4e32c48a4ce9887797a5b935e4b53058b27ca200.tar.bz2
device_linaro_bootloader_OpenPlatformPkg-4e32c48a4ce9887797a5b935e4b53058b27ca200.zip
Chips/Hisilicon: add sas protocol
PlatformSasProtocol is added for init sas device as well as transferring controller base address. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Chips/Hisilicon/Pv660/Drivers')
-rw-r--r--Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.c114
-rw-r--r--Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.inf48
2 files changed, 162 insertions, 0 deletions
diff --git a/Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.c b/Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.c
new file mode 100644
index 0000000..055cc37
--- /dev/null
+++ b/Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.c
@@ -0,0 +1,114 @@
+/** @file
+*
+* Copyright (c) 2016, Hisilicon Limited. All rights reserved.
+* Copyright (c) 2016, Linaro Limited. All rights reserved.
+*
+* 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 <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/PlatformSasProtocol.h>
+
+#define SAS0_BASE 0xc0000000
+#define SAS0_RESET 0xa60
+#define SAS0_DISABLE_CLK 0x33c
+#define SAS0_DERESET 0xa64
+#define SAS0_ENABLE_CLK 0x338
+
+#define SAS1_BASE 0xb0000000
+#define SAS1_RESET 0xa18
+#define SAS1_DISABLE_CLK 0x31c
+#define SAS1_DERESET 0xa1c
+#define SAS1_ENABLE_CLK 0x318
+
+#define SAS_RESET_VALUE 0x7ffff
+
+STATIC
+VOID
+SasInit_0 (
+ IN PLATFORM_SAS_PROTOCOL *This
+)
+{
+ // Apply reset and disable clock
+ MmioWrite32(SAS0_BASE + SAS0_RESET, SAS_RESET_VALUE);
+ MmioWrite32(SAS0_BASE + SAS0_DISABLE_CLK, SAS_RESET_VALUE);
+ // Wait 1ms for reset takes effect, refer drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+ MicroSecondDelay(1000);
+ // De-reset and enable clock
+ MmioWrite32(SAS0_BASE + SAS0_DERESET, SAS_RESET_VALUE);
+ MmioWrite32(SAS0_BASE + SAS0_ENABLE_CLK, SAS_RESET_VALUE);
+ // Wait 1ms for de-reset takes effect, refer drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+ MicroSecondDelay(1000);
+}
+
+PLATFORM_SAS_PROTOCOL Sas0 = {
+ 0xc1000000,
+ SasInit_0
+};
+
+STATIC
+VOID
+SasInit_1 (
+ IN PLATFORM_SAS_PROTOCOL *This
+)
+{
+ // Apply reset and disable clock
+ MmioWrite32(SAS1_BASE + SAS1_RESET, SAS_RESET_VALUE);
+ MmioWrite32(SAS1_BASE + SAS1_DISABLE_CLK, SAS_RESET_VALUE);
+ // Wait 1ms for reset takes effect, refer drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+ MicroSecondDelay(1000);
+ // De-reset and enable clock
+ MmioWrite32(SAS1_BASE + SAS1_DERESET, SAS_RESET_VALUE);
+ MmioWrite32(SAS1_BASE + SAS1_ENABLE_CLK, SAS_RESET_VALUE);
+ // Wait 1ms for de-reset takes effect, refer drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+ MicroSecondDelay(1000);
+}
+
+PLATFORM_SAS_PROTOCOL Sas1 = {
+ 0xb1000000,
+ SasInit_1
+};
+
+EFI_STATUS
+EFIAPI
+SasV1InitEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &Handle,
+ &gPlatformSasProtocolGuid, &Sas0,
+ NULL
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &Handle,
+ &gPlatformSasProtocolGuid, &Sas1,
+ NULL
+ );
+ return Status;
+}
diff --git a/Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.inf b/Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.inf
new file mode 100644
index 0000000..484e54f
--- /dev/null
+++ b/Chips/Hisilicon/Pv660/Drivers/SasInitDxe/SasV1Init.inf
@@ -0,0 +1,48 @@
+/** @file
+*
+* Copyright (c) 2016, Hisilicon Limited. All rights reserved.
+* Copyright (c) 2016, Linaro Limited. All rights reserved.
+*
+* 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.
+*
+**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SasV1InitDxe
+ FILE_GUID = 6e673d64-4801-4cbd-a7c0-20a26a9d5919
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+
+ ENTRY_POINT = SasV1InitEntry
+
+[Sources.common]
+ SasV1Init.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OpenPlatformPkg/Chips/Hisilicon/HisiPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ IoLib
+ TimerLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+
+[Pcd]
+
+[Protocols]
+ gPlatformSasProtocolGuid
+
+[Depex]
+ TRUE