All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yu-Chien Peter Lin <peterlin@andestech.com>
To: opensbi@lists.infradead.org
Subject: [RFC PATCH] platform: generic: renesas: Add support to configure the PMA
Date: Wed, 21 Dec 2022 15:15:20 +0000	[thread overview]
Message-ID: <Y6MjCN7UD1PqL9pL@APC323> (raw)
In-Reply-To: <CA+V-a8t8G3AawnRNxi373Gp6W15hp9FmHYCCuSANVnyT7wqmXQ@mail.gmail.com>

Hi Prabhakar,

> > > +unsigned long rzfive_setup_pma_region(unsigned long addr, unsigned long size,
> > > +                                   int entry_id, u32 flag)
> > > +{
> > > +     unsigned long size_tmp, shift = 0, pmacfg_val;
> > > +     unsigned long mmsc = csr_read(CSR_MMSC_CFG);
> > > +     unsigned long pa = addr;
> > > +     char *pmaxcfg;
> > > +     int power = 0;
> > > +
> >
> > The granularity of PMA NAPOT mode is 4KiB, so we should not allow this
> > case.
> >
> > if (size < (1 << 12))
> >   return SBI_EINVAL;
> >
> The manual I am referring to says "The minimal size of NAPOT regions
> must be 8 bytes."

I checked the section "16.17.1 PMA Configuration Registers" [1],
it says "The granularity is 4K bytes.".

Besides, here is my observation:
Assume desired base: 0x58000000
               size: 0x00000400

(gdb) p/x $pmacfg0
$10 = {0xf, pma0cfg = {0xf, etyp = 0x3, mtyp = 0x3}, [...]
(gdb) p/x (0x58000000 >> 2) + (0x400 >> 3) - 1
$6 = 0x1600007f
(gdb) p/x $pmaaddr0=0x1600007fl
$8 = 0x1600007f
(gdb) p/x $pmaaddr0
$9 = 0x160001ff
(gdb) pma_to_addr 0x160001ff
translate pmaaddr 0x160001ff
==========================================
power:  12
base:?? 0x1000
region: 0x58000000 ~ 0x58001000

[1] http://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf

[...]
> >
> > Can we simplify the logic to calculate the value of pmaaddr?
> >
> > If addr = 0x58000000
> >    size = 0x08000000
> >
> > pmaaddr = (addr >> 2) + (size >> 3) - 1 = 0x16ffffff
> >
> Ok I'll simply as above.
> 
> Cheers,
> Prabhakar

Best regards,
Peter Lin


  reply	other threads:[~2022-12-21 15:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12  9:44 [RFC PATCH] platform: generic: renesas: Add support to configure the PMA Lad Prabhakar
2022-12-20 22:12 ` Yu-Chien Peter Lin
2022-12-21  0:38   ` Lad, Prabhakar
2022-12-21 15:15     ` Yu-Chien Peter Lin [this message]
2022-12-21 18:19       ` Lad, Prabhakar
2022-12-22 20:16         ` Yu-Chien Peter Lin
2022-12-22 17:52           ` Lad, Prabhakar
2022-12-21  1:23 ` Bin Meng
2022-12-21 14:22   ` Yu-Chien Peter Lin
2022-12-21 18:04     ` Lad, Prabhakar

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-all 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=Y6MjCN7UD1PqL9pL@APC323 \
    --to=peterlin@andestech.com \
    --cc=opensbi@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.