From: Tom Rini Date: Wed, 29 Jan 2014 17:32:30 -0500 Subject: [U-Boot] [PATCH 2/6] arch: bcm281xx: Initial commit of bcm281xx architecture code In-Reply-To: <1390848810-7227-3-git-send-email-drambo@broadcom.com> References: <1390848810-7227-1-git-send-email-drambo@broadcom.com> <1390848810-7227-3-git-send-email-drambo@broadcom.com> Message-ID: <20140129223230.GX3277@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, Jan 27, 2014 at 10:53:26AM -0800, Darwin Rambo wrote: > Add bcm281xx architecture support code including a clock framework and > chip reset. Define register block base addresses for the bcm281xx > architecture and create an empty gpio header file required when > CONFIG_CMD_GPIO is set. [snip] > +/* Bitfield operations */ > + > +/* Produces a mask of set bits covering a range of a 32-bit value */ > +static inline u32 bitfield_mask(u32 shift, u32 width) > +{ > + return ((1 << width) - 1) << shift; > +} > + > +/* Extract the value of a bitfield found within a given register value */ > +static inline u32 bitfield_extract(u32 reg_val, u32 shift, u32 width) > +{ > + return (reg_val & bitfield_mask(shift, width)) >> shift; > +} > + > +/* Replace the value of a bitfield found within a given register value */ > +static inline u32 bitfield_replace(u32 reg_val, u32 shift, u32 width, u32 val) > +{ > + u32 mask = bitfield_mask(shift, width); > + > + return (reg_val & ~mask) | (val << shift); > +} This all feels horribly generic, isn't there some linux header we've already got that I can't think off of the top of my head that gives us these kind of functions? > + clk_dbg("%s: %s\n", __func__, c->name); Please juse use debug(...), here and elsewhere. > +#ifndef offsetof > +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) > +#endif > + > +#ifndef container_of > +#define container_of(ptr, type, member) ({ \ > + const typeof(((type *)0)->member) * __mptr = (ptr); \ > + (type *)((char *)__mptr - offsetof(type, member)); }) > +#endif We already have these.. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: