diff mbox

[edk2,1/5] EmbeddedPkg: introduce platform PCI I/O protocol

Message ID 1477937590-10361-2-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Oct. 31, 2016, 6:13 p.m. UTC
Introduce a protocol that can be exposed by a platform for devices that
can be driven by a PCI driver, (e.g., AHCI, XHCI), but do not live on a
PCI bus. This used to be called 'PCI emulation' but given that we only
emulate the PCI config space and nothing else, it tends to be a bit
confusing so this introduces the term 'platform PCI I/O' instead.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 EmbeddedPkg/EmbeddedPkg.dec                  |  1 +
 EmbeddedPkg/Include/Protocol/PlatformPciIo.h | 74 ++++++++++++++++++++
 2 files changed, 75 insertions(+)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Leif Lindholm Nov. 1, 2016, 9:54 p.m. UTC | #1
On Mon, Oct 31, 2016 at 06:13:06PM +0000, Ard Biesheuvel wrote:
> Introduce a protocol that can be exposed by a platform for devices that

> can be driven by a PCI driver, (e.g., AHCI, XHCI), but do not live on a

> PCI bus. This used to be called 'PCI emulation' but given that we only

> emulate the PCI config space and nothing else, it tends to be a bit

> confusing so this introduces the term 'platform PCI I/O' instead.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  EmbeddedPkg/EmbeddedPkg.dec                  |  1 +

>  EmbeddedPkg/Include/Protocol/PlatformPciIo.h | 74 ++++++++++++++++++++


OK, so perhaps I should have commented on this already on 0/5, but I
think this belongs in MdeModulePkg. The closest thing to an "embedded"
user of this code is Juno.

>  2 files changed, 75 insertions(+)

> 

> diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec

> index 2c2cf41103c2..84a6f4d01077 100644

> --- a/EmbeddedPkg/EmbeddedPkg.dec

> +++ b/EmbeddedPkg/EmbeddedPkg.dec

> @@ -69,6 +69,7 @@ [Protocols.common]

>    gAndroidFastbootPlatformProtocolGuid =  { 0x524685a0, 0x89a0, 0x11e3, {0x9d, 0x4d, 0xbf, 0xa9, 0xf6, 0xa4, 0x03, 0x08}}

>    gUsbDeviceProtocolGuid =  { 0x021bd2ca, 0x51d2, 0x11e3, {0x8e, 0x56, 0xb7, 0x54, 0x17, 0xc7,  0x0b, 0x44 }}

>    gPlatformGpioProtocolGuid = { 0x52ce9845, 0x5af4, 0x43e2, {0xba, 0xfd, 0x23, 0x08, 0x12, 0x54, 0x7a, 0xc2 }}

> +  gPlatformPciIoProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a }}

>  

>  [PcdsFeatureFlag.common]

>    gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot|FALSE|BOOLEAN|0x00000001

> diff --git a/EmbeddedPkg/Include/Protocol/PlatformPciIo.h b/EmbeddedPkg/Include/Protocol/PlatformPciIo.h

> new file mode 100644

> index 000000000000..a7bd584049ac

> --- /dev/null

> +++ b/EmbeddedPkg/Include/Protocol/PlatformPciIo.h

> @@ -0,0 +1,74 @@

> +/** @file

> +

> +  Copyright (c) 2016, Linaro, Ltd. 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.

> +

> +**/

> +

> +#ifndef __PLATFORM_PCI_IO_H__

> +#define __PLATFORM_PCI_IO_H__

> +

> +#define PLATFORM_PCI_IO_PROTOCOL_GUID \

> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }

> +

> +//

> +// Protocol interface structure

> +//

> +typedef struct _PLATFORM_PCI_IO PLATFORM_PCI_IO;

> +

> +//

> +// Data Types

> +//

> +typedef enum {

> +  PlatformPciIoDeviceOhci,

> +  PlatformPciIoDeviceUhci,

> +  PlatformPciIoDeviceEhci,

> +  PlatformPciIoDeviceXhci,

> +  PlatformPciIoDeviceAhci,


SdMmc and Ufs?

> +  PlatformPciIoDeviceMax,

> +} PLATFORM_PCI_IO_DEVICE_TYPE;

> +

> +typedef enum {

> +  PlatformPciIoDmaCoherent,

> +  PlatformPciIoDmaNonCoherent,

> +  PlatformPciIoDmaMax,

> +} PLATFORM_PCI_IO_DMA_TYPE;

> +

> +//

> +// Function Prototypes

> +//

> +typedef

> +EFI_STATUS

> +(EFIAPI *PLATFORM_PCI_IO_INIT) (

> +  IN  PLATFORM_PCI_IO     *This

> +  );

> +

> +struct _PLATFORM_PCI_IO {

> +  //

> +  // The MMIO address of the device

> +  //

> +  EFI_PHYSICAL_ADDRESS          BaseAddress;

> +  //

> +  // The type of device

> +  //

> +  PLATFORM_PCI_IO_DEVICE_TYPE   DeviceType;

> +  //

> +  // Whether this device is DMA coherent

> +  //

> +  PLATFORM_PCI_IO_DMA_TYPE      DmaType;

> +  //

> +  // Initialization function for the device

> +  //

> +  PLATFORM_PCI_IO_INIT          Initialize;

> +};

> +

> +extern EFI_GUID gPlatformPciIoProtocolGuid;

> +

> +#endif

> -- 

> 2.7.4

> 

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ard Biesheuvel Nov. 2, 2016, 1:29 p.m. UTC | #2
On 1 November 2016 at 21:54, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Mon, Oct 31, 2016 at 06:13:06PM +0000, Ard Biesheuvel wrote:

>> Introduce a protocol that can be exposed by a platform for devices that

>> can be driven by a PCI driver, (e.g., AHCI, XHCI), but do not live on a

>> PCI bus. This used to be called 'PCI emulation' but given that we only

>> emulate the PCI config space and nothing else, it tends to be a bit

>> confusing so this introduces the term 'platform PCI I/O' instead.

>>

>> Contributed-under: TianoCore Contribution Agreement 1.0

>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>> ---

>>  EmbeddedPkg/EmbeddedPkg.dec                  |  1 +

>>  EmbeddedPkg/Include/Protocol/PlatformPciIo.h | 74 ++++++++++++++++++++

>

> OK, so perhaps I should have commented on this already on 0/5, but I

> think this belongs in MdeModulePkg. The closest thing to an "embedded"

> user of this code is Juno.

>

>>  2 files changed, 75 insertions(+)

>>

>> diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec

>> index 2c2cf41103c2..84a6f4d01077 100644

>> --- a/EmbeddedPkg/EmbeddedPkg.dec

>> +++ b/EmbeddedPkg/EmbeddedPkg.dec

>> @@ -69,6 +69,7 @@ [Protocols.common]

>>    gAndroidFastbootPlatformProtocolGuid =  { 0x524685a0, 0x89a0, 0x11e3, {0x9d, 0x4d, 0xbf, 0xa9, 0xf6, 0xa4, 0x03, 0x08}}

>>    gUsbDeviceProtocolGuid =  { 0x021bd2ca, 0x51d2, 0x11e3, {0x8e, 0x56, 0xb7, 0x54, 0x17, 0xc7,  0x0b, 0x44 }}

>>    gPlatformGpioProtocolGuid = { 0x52ce9845, 0x5af4, 0x43e2, {0xba, 0xfd, 0x23, 0x08, 0x12, 0x54, 0x7a, 0xc2 }}

>> +  gPlatformPciIoProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a }}

>>

>>  [PcdsFeatureFlag.common]

>>    gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot|FALSE|BOOLEAN|0x00000001

>> diff --git a/EmbeddedPkg/Include/Protocol/PlatformPciIo.h b/EmbeddedPkg/Include/Protocol/PlatformPciIo.h

>> new file mode 100644

>> index 000000000000..a7bd584049ac

>> --- /dev/null

>> +++ b/EmbeddedPkg/Include/Protocol/PlatformPciIo.h

>> @@ -0,0 +1,74 @@

>> +/** @file

>> +

>> +  Copyright (c) 2016, Linaro, Ltd. 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.

>> +

>> +**/

>> +

>> +#ifndef __PLATFORM_PCI_IO_H__

>> +#define __PLATFORM_PCI_IO_H__

>> +

>> +#define PLATFORM_PCI_IO_PROTOCOL_GUID \

>> +  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }

>> +

>> +//

>> +// Protocol interface structure

>> +//

>> +typedef struct _PLATFORM_PCI_IO PLATFORM_PCI_IO;

>> +

>> +//

>> +// Data Types

>> +//

>> +typedef enum {

>> +  PlatformPciIoDeviceOhci,

>> +  PlatformPciIoDeviceUhci,

>> +  PlatformPciIoDeviceEhci,

>> +  PlatformPciIoDeviceXhci,

>> +  PlatformPciIoDeviceAhci,

>

> SdMmc and Ufs?

>


Indeed. I have added both: SDHCI works in QEMU but I can't really test UFS.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Leif Lindholm Nov. 2, 2016, 3:42 p.m. UTC | #3
On Wed, Nov 02, 2016 at 01:29:06PM +0000, Ard Biesheuvel wrote:
> >> +//

> >> +// Data Types

> >> +//

> >> +typedef enum {

> >> +  PlatformPciIoDeviceOhci,

> >> +  PlatformPciIoDeviceUhci,

> >> +  PlatformPciIoDeviceEhci,

> >> +  PlatformPciIoDeviceXhci,

> >> +  PlatformPciIoDeviceAhci,

> >

> > SdMmc and Ufs?

> >

> 

> Indeed. I have added both: SDHCI works in QEMU but I can't really test UFS.


Haojian - are you able to help out with testing UFS?

Regards,

Leif
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 2c2cf41103c2..84a6f4d01077 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -69,6 +69,7 @@  [Protocols.common]
   gAndroidFastbootPlatformProtocolGuid =  { 0x524685a0, 0x89a0, 0x11e3, {0x9d, 0x4d, 0xbf, 0xa9, 0xf6, 0xa4, 0x03, 0x08}}
   gUsbDeviceProtocolGuid =  { 0x021bd2ca, 0x51d2, 0x11e3, {0x8e, 0x56, 0xb7, 0x54, 0x17, 0xc7,  0x0b, 0x44 }}
   gPlatformGpioProtocolGuid = { 0x52ce9845, 0x5af4, 0x43e2, {0xba, 0xfd, 0x23, 0x08, 0x12, 0x54, 0x7a, 0xc2 }}
+  gPlatformPciIoProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a }}
 
 [PcdsFeatureFlag.common]
   gEmbeddedTokenSpaceGuid.PcdEmbeddedMacBoot|FALSE|BOOLEAN|0x00000001
diff --git a/EmbeddedPkg/Include/Protocol/PlatformPciIo.h b/EmbeddedPkg/Include/Protocol/PlatformPciIo.h
new file mode 100644
index 000000000000..a7bd584049ac
--- /dev/null
+++ b/EmbeddedPkg/Include/Protocol/PlatformPciIo.h
@@ -0,0 +1,74 @@ 
+/** @file
+
+  Copyright (c) 2016, Linaro, Ltd. 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.
+
+**/
+
+#ifndef __PLATFORM_PCI_IO_H__
+#define __PLATFORM_PCI_IO_H__
+
+#define PLATFORM_PCI_IO_PROTOCOL_GUID \
+  { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } }
+
+//
+// Protocol interface structure
+//
+typedef struct _PLATFORM_PCI_IO PLATFORM_PCI_IO;
+
+//
+// Data Types
+//
+typedef enum {
+  PlatformPciIoDeviceOhci,
+  PlatformPciIoDeviceUhci,
+  PlatformPciIoDeviceEhci,
+  PlatformPciIoDeviceXhci,
+  PlatformPciIoDeviceAhci,
+  PlatformPciIoDeviceMax,
+} PLATFORM_PCI_IO_DEVICE_TYPE;
+
+typedef enum {
+  PlatformPciIoDmaCoherent,
+  PlatformPciIoDmaNonCoherent,
+  PlatformPciIoDmaMax,
+} PLATFORM_PCI_IO_DMA_TYPE;
+
+//
+// Function Prototypes
+//
+typedef
+EFI_STATUS
+(EFIAPI *PLATFORM_PCI_IO_INIT) (
+  IN  PLATFORM_PCI_IO     *This
+  );
+
+struct _PLATFORM_PCI_IO {
+  //
+  // The MMIO address of the device
+  //
+  EFI_PHYSICAL_ADDRESS          BaseAddress;
+  //
+  // The type of device
+  //
+  PLATFORM_PCI_IO_DEVICE_TYPE   DeviceType;
+  //
+  // Whether this device is DMA coherent
+  //
+  PLATFORM_PCI_IO_DMA_TYPE      DmaType;
+  //
+  // Initialization function for the device
+  //
+  PLATFORM_PCI_IO_INIT          Initialize;
+};
+
+extern EFI_GUID gPlatformPciIoProtocolGuid;
+
+#endif