From: "Gao, Liming" <liming.gao@intel.com>
To: Jun Nie <jun.nie@linaro.org>,
Leif Lindholm <leif.lindholm@linaro.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
"linaro-uefi@lists.linaro.org" <linaro-uefi@lists.linaro.org>,
"Alexei.Fedorov@arm.com" <Alexei.Fedorov@arm.com>,
"evan.lloyd@arm.com" <evan.lloyd@arm.com>
Subject: Re: How to add support to different reg offset definition to share the same driver code?
Date: Fri, 30 Jun 2017 13:29:47 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D750466@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <CABymUCOj0MBHHoia3ZFQ1L32rcyXDJzWcE35PT7L8XxmzPek3w@mail.gmail.com>
Jun:
You can add C MACRO in [BuildOptions] of Platform.dsc, then use DSC flag to control it.
For example: Platform.dsc
[Defines]
DEFINE ZX_PL011_FLAG = FALSE
[BuildOptions]
!if $(ZX_PL011_FLAG) == TRUE
*_*_*_CC_FLAGS = -D ZX_PL011_FLAG
!endif
Thanks
Liming
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jun Nie
> Sent: Friday, June 30, 2017 11:35 AM
> To: Leif Lindholm <leif.lindholm@linaro.org>; Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org;
> linaro-uefi@lists.linaro.org; Alexei.Fedorov@arm.com; evan.lloyd@arm.com
> Subject: [edk2] How to add support to different reg offset definition to share the same driver code?
>
> 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
next prev parent reply other threads:[~2017-06-30 13:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 3:35 How to add support to different reg offset definition to share the same driver code? Jun Nie
2017-06-30 11:01 ` Leif Lindholm
2017-07-03 2:33 ` Jun Nie
2017-06-30 13:29 ` Gao, Liming [this message]
2017-07-03 2:29 ` Jun Nie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14D750466@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox