public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] Common mechanism to identify Si revision
@ 2009-09-03 10:44 Premi, Sanjeev
  2009-09-03 10:49 ` Premi, Sanjeev
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Premi, Sanjeev @ 2009-09-03 10:44 UTC (permalink / raw)
  To: linux-omap@vger.kernel.org

Hi,

Currently there are multiple mechanisms for identifying the si revisions.

Most places the comparison is against omap_rev() as a whole number. Example:

arch/arm/mach-omap2/board-3430sdp.c:695:    if (omap_rev() > OMAP3430_REV_ES1_0)
arch/arm/mach-omap2/board-3430sdp.c:728:    if (omap_rev() > OMAP3430_REV_ES1_0)

Then, there are custom macros. Example (cpu.h):

#define CHIP_GE_OMAP3430ES3_1		(CHIP_IS_OMAP3430ES3_1)
#define CHIP_GE_OMAP3430ES3		(CHIP_IS_OMAP3430ES3_0 | \
					 CHIP_GE_OMAP3430ES3_1)
#define CHIP_GE_OMAP3430ES2		(CHIP_IS_OMAP3430ES2 | \
					 CHIP_GE_OMAP3430ES3)

The problem with comparing against a whole number is that comparison is invalid
for another processor series. E.g. OMAP3430 and OMAP3517.

Here, I am proposing a common mechanism to identify the si revision; that focuses
on the revision bits alone. (See code below)

The usage would then be (example):

   if (omap_rev() > OMAP3430_REV_ES1_0)

To

   if (cpu_is_omap34xx() && OMAP_REV_GT(OMAP_ES_1_0)


Though I have not looked at the OMAP1 directory, I am assuming similar case there.
Since there aren't any new devices in the OMAP1 category, this may not appear as
a need. But consistency could help.

Few items that I feel need to be looked at:
- Possible differences in the MASK defined for Si revision.
  Irrespective of (possible) difference in the HW, the bits in 'omap_revision' can
  be same.

- How to phase in the change - one shot OR in steps.

I am not sending this as patch, for now; just to get the discussion started.

Best regards,
Sanjeev


(cpu.h)

/*
 * Identify silicon revision.
 */
#define OMAP_REV_MASK		0x0000ff00

#define OMAP_ES_1_0		0x00
#define OMAP_ES_2_0		0x10
#define OMAP_ES_2_1		0x20
#define OMAP_ES_3_0		0x30
#define OMAP_ES_3_1		0x40

#define OMAP_REV_IS(revid)						\
static inline u8 omap_rev_is_ ##revid (void)				\
{									\
	(((omap_rev() & OMAP_REV_MASK) >> 8) == revid) ? 1 : 0 ;	\
}

#define OMAP_REV_LT(revid)						\
static inline u8 omap_rev_lt_ ##revid (void)				\
{									\
	(((omap_rev() & OMAP_REV_MASK) >> 8) < revid) ? 1 : 0 ;	\
}

#define OMAP_REV_LE(revid)						\
static inline u8 omap_rev_le_ ##revid (void)				\
{									\
	(((omap_rev() & OMAP_REV_MASK) >> 8) <= revid) ? 1 : 0 ;	\
}

#define OMAP_REV_GE(revid)						\
static inline u8 omap_rev_ge_ ##revid (void)				\
{									\
	(((omap_rev() & OMAP_REV_MASK) >> 8) >= revid) ? 1 : 0 ;	\
}

#define OMAP_REV_GT(revid)						\
static inline u8 omap_rev_gt_ ##revid (void)				\
{									\
	(((omap_rev() & OMAP_REV_MASK) >> 8) > revid) ? 1 : 0 ;	\
}

OMAP_REV_IS(OMAP_ES_1_0)
OMAP_REV_LT(OMAP_ES_1_0)
OMAP_REV_LE(OMAP_ES_1_0)
OMAP_REV_GT(OMAP_ES_1_0)
OMAP_REV_GE(OMAP_ES_1_0)

OMAP_REV_IS(OMAP_ES_2_0)
OMAP_REV_LT(OMAP_ES_2_0)
OMAP_REV_LE(OMAP_ES_2_0)
OMAP_REV_GT(OMAP_ES_2_0)
OMAP_REV_GE(OMAP_ES_2_0)

OMAP_REV_IS(OMAP_ES_2_1)
OMAP_REV_LT(OMAP_ES_2_1)
OMAP_REV_LE(OMAP_ES_2_1)
OMAP_REV_GT(OMAP_ES_2_1)
OMAP_REV_GE(OMAP_ES_2_1)

OMAP_REV_IS(OMAP_ES_3_0)
OMAP_REV_LT(OMAP_ES_3_0)
OMAP_REV_LE(OMAP_ES_3_0)
OMAP_REV_GT(OMAP_ES_3_0)
OMAP_REV_GE(OMAP_ES_3_0)

OMAP_REV_IS(OMAP_ES_3_1)
OMAP_REV_LT(OMAP_ES_3_1)
OMAP_REV_LE(OMAP_ES_3_1)
OMAP_REV_GT(OMAP_ES_3_1)
OMAP_REV_GE(OMAP_ES_3_1)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-09-23  4:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-03 10:44 [RFC] Common mechanism to identify Si revision Premi, Sanjeev
2009-09-03 10:49 ` Premi, Sanjeev
2009-09-06 12:46 ` Olof Johansson
2009-09-07  6:03   ` Premi, Sanjeev
2009-09-07 12:34     ` Olof Johansson
2009-09-07 13:02       ` Premi, Sanjeev
2009-09-07 14:09         ` Olof Johansson
2009-09-10 17:54   ` Kevin Hilman
2009-09-11 13:04     ` Cousson, Benoit
2009-09-11 15:33     ` Premi, Sanjeev
2009-09-10  9:29 ` Paul Walmsley
2009-09-11 11:24   ` Premi, Sanjeev
2009-09-19 14:41     ` Paul Walmsley
2009-09-23  4:20       ` Premi, Sanjeev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox