Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753439AbbGNJE0 (ORCPT ); Tue, 14 Jul 2015 05:04:26 -0400 Received: from mail-ob0-f181.google.com ([209.85.214.181]:36011 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753362AbbGNJEA (ORCPT ); Tue, 14 Jul 2015 05:04:00 -0400 MIME-Version: 1.0 In-Reply-To: <1435667250-28299-4-git-send-email-pawelo@king.net.pl> References: <1435667250-28299-1-git-send-email-pawelo@king.net.pl> <1435667250-28299-4-git-send-email-pawelo@king.net.pl> Date: Tue, 14 Jul 2015 11:03:59 +0200 Message-ID: Subject: Re: [PATCH v2 3/9] arm: twr-k70f120m: clock driver for Kinetis SoC From: Linus Walleij To: Paul Osmialowski Cc: Greg Kroah-Hartman , Ian Campbell , Jiri Slaby , Kumar Gala , Mark Rutland , Michael Turquette , Pawel Moll , Rob Herring , Russell King , Stephen Boyd , Vinod Koul , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , linux-clk@vger.kernel.org, "linux-gpio@vger.kernel.org" , "linux-serial@vger.kernel.org" , "devicetree@vger.kernel.org" , dmaengine@vger.kernel.org, Arnd Bergmann , Geert Uytterhoeven , Nicolas Pitre , Paul Bolle , Thomas Gleixner , Uwe Kleine-Koenig , Anson Huang , Frank Li , Jingchang Lu , Rob Herring , Yuri Tikhonov , Sergei Poselenov , Alexander Potashev Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2177 Lines: 47 On Tue, Jun 30, 2015 at 2:27 PM, Paul Osmialowski wrote: > Based on K70P256M150SF3RM.pdf K70 Sub-Family Reference Manual, Rev. 3. > > Signed-off-by: Paul Osmialowski (...) > +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. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/