public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/6] arch: bcm281xx: Initial commit of bcm281xx architecture code
Date: Fri, 31 Jan 2014 12:54:27 -0500	[thread overview]
Message-ID: <20140131175427.GC3277@bill-the-cat> (raw)
In-Reply-To: <52EACC3D.7060105@broadcom.com>

On Thu, Jan 30, 2014 at 02:03:41PM -0800, Darwin Rambo wrote:
> 
> 
> On 14-01-29 02:32 PM, Tom Rini wrote:
> > 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?
> Hi Tom,
> 
> I had a similar feeling. There are files such as include/linux/bitops.h
> and arch/arm/include/asm/bitops.h and a host of others, but these seem
> single bit oriented, and don't provide the functionality here. The
> bcm281xx clock registers are a myriad of bit fields of different widths
> and positions, and the driver code is simpler because it uses these
> generic bitfield functions and data tables to describe the bitfields.
> Perhaps the bcm281xx clock register hardware has revealed the need for
> more functions like this now. I've searched through the tree for
> equivalent functions and they don't seem to exist, but I could be wrong.
> We could create include/bitfield.h with functions specifically for
> bitfield operations if it were warranted. But if it only ever got used
> by one driver, it might be wrong to make it generic. But my gut feel is
> that if we did create include/bitfield.h it probably would be used by
> others who wanted to take a similar data-driven approach to register
> fields. We would also have to make it non-u32 specific I imagine,
> possibly just 'int' types. Thanks.

With Matt chiming in on where this is within the kernel, lets go with
creating a include/bitfield.h here.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140131/951f3268/attachment.pgp>

  reply	other threads:[~2014-01-31 17:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27 18:53 [U-Boot] [PATCH 0/6] Introducing the Broadcom bcm281xx Architecture Darwin Rambo
2014-01-27 18:53 ` [U-Boot] [PATCH 1/6] arch: kona: Initial commit of kona-common architecture code Darwin Rambo
2014-01-29 22:32   ` Tom Rini
2014-01-30 23:09     ` Darwin Rambo
2014-01-27 18:53 ` [U-Boot] [PATCH 2/6] arch: bcm281xx: Initial commit of bcm281xx " Darwin Rambo
2014-01-29 22:32   ` Tom Rini
2014-01-30 22:03     ` Darwin Rambo
2014-01-31 17:54       ` Tom Rini [this message]
2014-01-31 18:19         ` Darwin Rambo
2014-01-31 17:47     ` Matt Porter
2014-01-27 18:53 ` [U-Boot] [PATCH 3/6] gpio: kona: Add Kona gpio driver Darwin Rambo
2014-01-27 18:53 ` [U-Boot] [PATCH 4/6] i2c: kona: Add Kona I2C driver Darwin Rambo
2014-01-27 18:53 ` [U-Boot] [PATCH 5/6] mmc: kona: Add Kona mmc driver Darwin Rambo
2014-01-27 18:53 ` [U-Boot] [PATCH 6/6] board: bcm28155_ap: Add board files Darwin Rambo
2014-01-29 22:33   ` Tom Rini
2014-01-30 23:05     ` Darwin Rambo
2014-01-31 14:17       ` Tom Rini
2014-01-31 17:05         ` Tim Kryger
2014-01-31 17:15           ` Tom Rini
2014-01-31 18:18             ` Darwin Rambo
2014-01-29 22:32 ` [U-Boot] [PATCH 0/6] Introducing the Broadcom bcm281xx Architecture Tom Rini
2014-01-30 23:12   ` Darwin Rambo
2014-01-31 19:14     ` Tom Rini

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=20140131175427.GC3277@bill-the-cat \
    --to=trini@ti.com \
    --cc=u-boot@lists.denx.de \
    /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