linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: pawelo@king.net.pl (Paul Osmialowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/9] arm: twr-k70f120m: clock driver for Kinetis SoC
Date: Wed, 15 Jul 2015 19:34:09 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1507151931200.7048@localhost.localdomain> (raw)
In-Reply-To: <alpine.LNX.2.00.1507150917470.32721@localhost.localdomain>

Hi Linus,

I had some discussion with an expert here and now I see drawbacks of using 
struct for regs, I'll turn it into defines as you suggested.

On Wed, 15 Jul 2015, Paul Osmialowski wrote:

> Hi Linus,
> 
> Thanks for all of your comments, I'll consider them during my works on the 
> next iteration. However, I have doubts about this one:
> 
> On Tue, 14 Jul 2015, Linus Walleij wrote:
> 
> > On Tue, Jun 30, 2015 at 2:27 PM, Paul Osmialowski <pawelo@king.net.pl> wrote:
> > 
> > > Based on K70P256M150SF3RM.pdf K70 Sub-Family Reference Manual, Rev. 3.
> > >
> > > Signed-off-by: Paul Osmialowski <pawelo@king.net.pl>
> > (...)
> > > +struct kinetis_sim_regs {
> > > +       u32 sopt1;      /* System Options Register 1 */
> > > +       u32 rsv0[1024];
> > > +       u32 sopt2;      /* System Options Register 2 */
> > > +       u32 rsv1;
> > > +       u32 sopt4;      /* System Options Register 4 */
> > > +       u32 sopt5;      /* System Options Register 5 */
> > > +       u32 sopt6;      /* System Options Register 6 */
> > > +       u32 sopt7;      /* System Options Register 7 */
> > > +       u32 rsv2[2];
> > > +       u32 sdid;       /* System Device Identification Register */
> > > +       u32 scgc[KINETIS_SIM_CG_NUMREGS];       /* Clock Gating Regs 1...7 */
> > > +       u32 clkdiv1;    /* System Clock Divider Register 1 */
> > > +       u32 clkdiv2;    /* System Clock Divider Register 2 */
> > > +       u32 fcfg1;      /* Flash Configuration Register 1 */
> > > +       u32 fcfg2;      /* Flash Configuration Register 2 */
> > > +       u32 uidh;       /* Unique Identification Register High */
> > > +       u32 uidmh;      /* Unique Identification Register Mid-High */
> > > +       u32 uidml;      /* Unique Identification Register Mid Low */
> > > +       u32 uidl;       /* Unique Identification Register Low */
> > > +       u32 clkdiv3;    /* System Clock Divider Register 3 */
> > > +       u32 clkdiv4;    /* System Clock Divider Register 4 */
> > > +       u32 mcr;        /* Misc Control Register */
> > > +};
> > 
> > Now there is this design pattern where you copy the datasheet
> > register map to a struct again.
> > 
> > This is not good if there is a second revision of the hardware and some
> > registers are shuffled around. IMO it is better to just use #defines
> > for register
> > offsets, so you can do exceptions later. Else a new hardware revision
> > leads to a new struct with new accessor functions etc etc.
> > 
> 
> I don't see how replacing this structure with bunch of defines could make 
> anyones life easier. As registers are shuffled around due to updated 
> hardware revision they could be shuffled in this structure too. Doing 
> this with buch of defines would require eager and careful adaptation of 
> all the defines. I don't see how this could be easier.
> 
> Note that I'm not making any instances of the structure (it is used only 
> for casting), so shuffling its fields around should not affect the code 
> that follows.
> 
> After recent purge it is only used within this macro:
> 
> #define KINETIS_SIM_PTR(base, reg) \
>         (&(((struct kinetis_sim_regs *)(base))->reg))
> 
> ...and used like this:
> 
>         ioread32(KINETIS_SIM_PTR(sim, clkdiv1));
> 
> IMHO changing the struct internals does not require subsequent changes in 
> any of those.
> 
> Thanks,
> Paul
> 

  reply	other threads:[~2015-07-15 17:34 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 12:27 [PATCH v2 0/9] [New BSP] Add initial support for Freescale Kinetis TWR-K70F120M development kit Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 1/9] arm: allow copying of vector table to internal SRAM memory Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 2/9] arm: twr-k70f120m: basic support for Kinetis TWR-K70F120M Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 3/9] arm: twr-k70f120m: clock driver for Kinetis SoC Paul Osmialowski
2015-06-30 20:36   ` Arnd Bergmann
2015-07-01 15:57     ` Paul Osmialowski
2015-07-02 10:08       ` Paul Osmialowski
2015-07-02 12:40         ` Arnd Bergmann
2015-07-02 21:42           ` Paul Osmialowski
2015-07-02 22:08             ` Thomas Gleixner
2015-07-03 17:40               ` Paul Osmialowski
2015-07-04 19:54               ` Arnd Bergmann
2015-07-04 21:50                 ` Paul Osmialowski
2015-07-06 20:57                   ` Paul Osmialowski
2015-07-24  3:42                   ` Michael Turquette
2015-07-26 20:24                     ` Paul Osmialowski
2015-07-28 16:03                       ` Michael Turquette
2015-07-28 20:30                         ` Paul Osmialowski
2015-07-29 23:05                           ` Michael Turquette
2015-07-30 21:40                             ` Paul Osmialowski
2015-08-01  0:58                               ` Michael Turquette
2015-08-01 15:27                                 ` Paul Osmialowski
2015-08-05 19:27                                   ` Michael Turquette
2015-07-14  9:03   ` Linus Walleij
2015-07-15  7:31     ` Paul Osmialowski
2015-07-15 17:34       ` Paul Osmialowski [this message]
2015-06-30 12:27 ` [PATCH v2 4/9] arm: twr-k70f120m: timer " Paul Osmialowski
2015-06-30 20:43   ` Arnd Bergmann
2015-07-01 11:44     ` Paul Osmialowski
2015-07-05 14:39     ` Rob Herring
2015-07-01  7:51   ` Thomas Gleixner
2015-07-01  8:42     ` Paul Osmialowski
2015-07-01 13:28       ` Thomas Gleixner
2015-07-01 14:20         ` Paul Osmialowski
2015-07-14  8:59           ` Linus Walleij
2015-06-30 12:27 ` [PATCH v2 5/9] arm: twr-k70f120m: IOMUX " Paul Osmialowski
2015-07-14  8:55   ` Linus Walleij
2015-06-30 12:27 ` [PATCH v2 6/9] arm: twr-k70f120m: extend Freescale eDMA driver with the ability to support " Paul Osmialowski
2015-07-05  6:45   ` Vinod Koul
2015-07-05  9:45     ` Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 7/9] arm: twr-k70f120m: use Freescale eDMA driver with " Paul Osmialowski
2015-06-30 20:49   ` Arnd Bergmann
2015-07-01  6:54     ` Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 8/9] arm: twr-k70f120m: extend Freescale lpuart driver with ability to support " Paul Osmialowski
2015-06-30 12:27 ` [PATCH v2 9/9] arm: twr-k70f120m: use Freescale lpuart driver with " Paul Osmialowski

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=alpine.LNX.2.00.1507151931200.7048@localhost.localdomain \
    --to=pawelo@king.net.pl \
    --cc=linux-arm-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).