Exemplo n.º 1
0
void InitTW8836( void )
{
    //sI2cInit();

    TW8836_WritePage(0x00);

   // printf("\r\nTW88xx ID = %x , REV = %x", TW8836_Read(REG000), TW8836_Read(REG001));

    SpiFlashInit();

    //TW8836_Configuration(); 
	Delay_1ms(20 * 10);
}
Exemplo n.º 2
0
EFI_STATUS
EFIAPI
InitSpiDevice (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_EVENT                     Event;
  CONST FLASH_PART_DESCRIPTION  *FlashDescription;
  UINT64                        FlashSize;
  EFI_HANDLE                    Handle;
  EFI_STATUS                    Status;

  mNvStorageBase = PcdGet32 (PcdFlashNvStorageVariableBase);

  //
  // Locate the SPI controller protocol and save it for later.
  //
  DEBUG((EFI_D_INFO, "Locating SPI Controller Protocol.\n"));
  Status = gBS->LocateProtocol (
                  &gEfiSpiProtocolGuid,
                  NULL,
                  (VOID **) &mSpiProtocol
                  );
  ASSERT_EFI_ERROR(Status);
  
  //
  // Loop through all the flash devices that are supported and see if one will
  // initialize the SPI Controller interface.
  //
  FlashSize = FindFlashSupport (
                &JedecIdRead,
                NULL,
                &FlashDescription
                );
  if (FlashSize == 0) {
    DEBUG((EFI_D_ERROR, "No SPI flash part description found!\r\n"));
  } else {
    //
    // Attempt to configure the SPI controller for this device.
    //
    DEBUG((EFI_D_INFO, "SPI flash size: %d MBytes\n", DivU64x32(FlashSize, 1024 * 1024 )));
    DEBUG((EFI_D_INFO, "Configuring SPI Controller.\n"));
    
    Status = SpiFlashInit (FlashDescription);    
    if (!EFI_ERROR (Status)) {
      //
      // Publish the SPI Device protocol.
      //
      DEBUG((EFI_D_INFO, "Installing SPI Device Protocol.\n"));
      Handle = NULL;
      Status = gBS->InstallMultipleProtocolInterfaces (
                      &Handle,
                      &gSpiDeviceProtocolGuid,
                      &mSpiDevProtocol,
                      NULL
                      );
      if (EFI_ERROR (Status)) {
        return EFI_OUT_OF_RESOURCES;
      }

      //
      // Make sure we can handle virtual address changes.
      //
      Event = NULL;
      Status = gBS->CreateEventEx (
                      EVT_NOTIFY_SIGNAL,
                      TPL_NOTIFY,
                      SpiDeviceVirtualAddressChangeEvent,
                      NULL,
                      &gEfiEventVirtualAddressChangeGuid,
                      &Event
                      );      

      return EFI_SUCCESS;
    }
  }

  //
  // Unable to find a supported SPI device
  //
  DEBUG((EFI_D_ERROR, "Unable to configure SPI Controller for SPI device present.\n"));

  return EFI_UNSUPPORTED;
}