Hi Jun, I think there is more than one benefit in mimicing the Linux driver, so I would lean towards the Pcd option. But as Ard points out to me, it needs to use a FixedPcd (using FixedPcdGet()) - this can only ever have a buildtime resolution.
Regards, Leif (technically on holiday, so no patch review until Monday) On Fri, Jun 30, 2017 at 11:35:26AM +0800, Jun Nie wrote: > Hi, > > I am trying to add support to different reg offset and bit offset in > PL011 UART. It seems impossible to add macro in platform.dsc to enable > undef/redef in the header file with "#ifdef ZX_PL011_FLAG". Is there > any proper way to control the reg/bit offset definition? Or we have to > adopt the Linux driver method with a structure to hold different > offset value and wrap register access function as below? If so, > another Pcd is needed to specify the offset structure index for the > platforms. > > > static u16 pl011_st_offsets[REG_ARRAY_SIZE] = { > [REG_DR] = UART01x_DR, > [REG_ST_DMAWM] = ST_UART011_DMAWM, > [REG_ST_TIMEOUT] = ST_UART011_TIMEOUT, > ... > } > > static unsigned int pl011_read(const struct uart_amba_port *uap, > unsigned int reg) > { > void __iomem *addr = uap->port.membase + uap->reg_offset[reg]; > > return (uap->port.iotype == UPIO_MEM32) ? > readl_relaxed(addr) : readw_relaxed(addr); > } > > Jun _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel