Skip to contentSkip to conversation

OMAP3: Convert readl/writel and replace hardcoded values

U-Boot Dirk Behme 4 participants 11 messages Nov 23, 2008 – Nov 25, 2008

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

Convert readl/writel to base + offset style. Replace hardcoded values with macros.

No functional change.

---
 cpu/arm_cortexa8/omap3/board.c      |   56 ++++++++-------
 cpu/arm_cortexa8/omap3/clock.c      |   47 ++++++++-----
 cpu/arm_cortexa8/omap3/interrupts.c |   14 +--
 cpu/arm_cortexa8/omap3/mem.c        |   53 ++++++++------
 cpu/arm_cortexa8/omap3/sys_info.c   |   14 ++-
 include/asm-arm/arch-omap3/cpu.h    |  129 +++++++++++++++++++-----------------
 include/asm-arm/arch-omap3/mem.h    |    8 +-
 include/asm-arm/arch-omap3/omap3.h  |    2 
 8 files changed, 180 insertions(+), 143 deletions(-)
cpu/arm_cortexa8/omap3/mem.c +31 -22
Index: u-boot-arm/cpu/arm_cortexa8/omap3/mem.c
===================================================================
@@ -106,6 +106,8 @@ u32 *onenand_cs_base;
 
 #endif
 
+static u32 *sdrc_base = (u32 *)OMAP34XX_SDRC_BASE;
+
 /**************************************************************************
  * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
  *  command line mem=xyz use all memory with out discontinuous support
@@ -120,7 +122,7 @@ void make_cs1_contiguous(void)
 	size /= SZ_32M;			/* find size to offset CS1 */
 	a_add_high = (size & 3) << 8;	/* set up low field */
 	a_add_low = (size & 0x3C) >> 2;	/* set up high field */
-	writel((a_add_high | a_add_low), SDRC_CS_CFG);
+	writel((a_add_high | a_add_low), sdrc_base + OFFS(SDRC_CS_CFG));
 
 }
 
@@ -175,36 +177,43 @@ void do_sdrc_init(u32 offset, u32 early)
 
 	if (early) {
 		/* reset sdrc controller */
-		writel(SOFTRESET, SDRC_SYSCONFIG);
-		wait_on_value(RESETDONE, RESETDONE, SDRC_STATUS, 12000000);
-		writel(0, SDRC_SYSCONFIG);
+		writel(SOFTRESET, sdrc_base + OFFS(SDRC_SYSCONFIG));
+		wait_on_value(RESETDONE, RESETDONE, SDRC_STATUS_REG, 12000000);
+		writel(0, sdrc_base + OFFS(SDRC_SYSCONFIG));
 
 		/* setup sdrc to ball mux */
-		writel(SDP_SDRC_SHARING, SDRC_SHARING);
+		writel(SDP_SDRC_SHARING, sdrc_base + OFFS(SDRC_SHARING));
 
-		/* Disble Power Down of CKE cuz of 1 CKE on combo part */
-		writel(0x00000081, SDRC_POWER);
+		/* Disable Power Down of CKE cuz of 1 CKE on combo part */
+		writel(SRFRONRESET | PAGEPOLICY_HIGH,
+			sdrc_base + OFFS(SDRC_POWER));
 
-		writel(0x0000A, SDRC_DLLA_CTRL);
+		writel(ENADLL | DLLPHASE_90, sdrc_base + OFFS(SDRC_DLLA_CTRL));
 		sdelay(0x20000);
 	}
 
-	writel(0x02584099,	SDRC_MCFG_0 + offset);
-	writel(0x4e201,		SDRC_RFR_CTRL + offset);
-	writel(0xaa9db4c6,	SDRC_ACTIM_CTRLA_0 + actim_offs);
-	writel(0x11517,		SDRC_ACTIM_CTRLB_0 + actim_offs);
-
-	writel(CMD_NOP,		SDRC_MANUAL_0 + offset);
-	writel(CMD_PRECHARGE,	SDRC_MANUAL_0 + offset);
-	writel(CMD_AUTOREFRESH,	SDRC_MANUAL_0 + offset);
-	writel(CMD_AUTOREFRESH,	SDRC_MANUAL_0 + offset);
-
-	/*  CAS latency 3, Write Burst = Read Burst, Serial Mode,
-	    Burst length = 4 */
-	writel(0x00000032,	SDRC_MR_0 + offset);
+	writel(RASWIDTH_13BITS | CASWIDTH_10BITS | ADDRMUXLEGACY |
+		RAMSIZE_128 | BANKALLOCATION | B32NOT16 | B32NOT16 |
+		DEEPPD | DDR_SDRAM, sdrc_base + OFFS(SDRC_MCFG_0 + offset));
+	writel(ARCV | ARE_ARCV_1, sdrc_base + OFFS(SDRC_RFR_CTRL + offset));
+	writel(V_ACTIMA_165, sdrc_base +
+			OFFS(SDRC_ACTIM_CTRLA_0 + actim_offs));
+	writel(V_ACTIMB_165, sdrc_base +
+			OFFS(SDRC_ACTIM_CTRLB_0 + actim_offs));
+
+	writel(CMD_NOP, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
+	writel(CMD_PRECHARGE, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
+	writel(CMD_AUTOREFRESH, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
+	writel(CMD_AUTOREFRESH, sdrc_base + OFFS(SDRC_MANUAL_0 + offset));
+
+	/*
+	 * CAS latency 3, Write Burst = Read Burst, Serial Mode,
+	 * Burst length = 4
+	 */
+	writel(CASL3 | BURSTLENGTH4, sdrc_base + OFFS(SDRC_MR_0 + offset));
 
 	if (!mem_ok(offset))
-		writel(0, SDRC_MCFG_0 + offset);
+		writel(0, sdrc_base + OFFS(SDRC_MCFG_0 + offset));
 }
 
 void enable_gpmc_config(u32 *gpmc_config, u32 *gpmc_cs_base, u32 base,
cpu/arm_cortexa8/omap3/sys_info.c +9 -5
Index: u-boot-arm/cpu/arm_cortexa8/omap3/sys_info.c
===================================================================
@@ -33,6 +33,8 @@
 
 extern omap3_sysinfo sysinfo;
 static u32 *gpmc_base = (u32 *)GPMC_BASE;
+static u32 *sdrc_base = (u32 *)OMAP34XX_SDRC_BASE;
+static u32 *ctrl_base = (u32 *)OMAP34XX_CTRL_BASE;
 
 /******************************************
  * get_cpu_rev(void) - extract version info
@@ -59,7 +61,8 @@ u32 get_cpu_rev(void)
  ****************************************************/
 u32 is_mem_sdr(void)
 {
-	if (readl(SDRC_MR_0 + SDRC_CS0_OSET) == SDP_SDRC_MR_0_SDR)
+	if (readl(sdrc_base + OFFS(SDRC_MR_0 + SDRC_CS0_OSET)) ==
+			SDP_SDRC_MR_0_SDR)
 		return 1;
 	return 0;
 }
@@ -72,7 +75,7 @@ u32 get_sdr_cs_size(u32 offset)
 	u32 size;
 
 	/* get ram size field */
-	size = readl(SDRC_MCFG_0 + offset) >> 8;
+	size = readl(sdrc_base + OFFS(SDRC_MCFG_0 + offset)) >> 8;
 	size &= 0x3FF;		/* remove unwanted bits */
 	size *= SZ_2M;		/* find size in MB */
 	return size;
@@ -88,7 +91,7 @@ u32 get_sdr_cs_offset(u32 cs)
 	if (!cs)
 		return 0;
 
-	offset = readl(SDRC_CS_CFG);
+	offset = readl(sdrc_base + OFFS(SDRC_CS_CFG));
 	offset = (offset & 15) << 27 | (offset & 0x30) >> 17;
 
 	return offset;
@@ -240,7 +243,7 @@ u32 is_running_in_sdram(void)
  ***************************************************************/
 u32 get_boot_type(void)
 {
-	return (readl(CONTROL_STATUS) & SYSBOOT_MASK);
+	return (readl(ctrl_base + OFFS(CONTROL_STATUS)) & SYSBOOT_MASK);
 }
 
 /*************************************************************
@@ -248,5 +251,6 @@ u32 get_boot_type(void)
  *************************************************************/
 u32 get_device_type(void)
 {
-	return ((readl(CONTROL_STATUS) & (DEVICE_MASK)) >> 8);
+	return ((readl(ctrl_base + OFFS(CONTROL_STATUS)) &
+		(DEVICE_MASK)) >> 8);
 }
include/asm-arm/arch-omap3/cpu.h +71 -58

187 lines not on this page · raw message

include/asm-arm/arch-omap3/mem.h +4 -4
Index: u-boot-arm/include/asm-arm/arch-omap3/mem.h
===================================================================
@@ -80,16 +80,16 @@ typedef enum {
 #define TRP_165		3
 #define TRAS_165	7
 #define TRC_165		10
-#define TRFC_165	12
+#define TRFC_165	21
 #define V_ACTIMA_165	((TRFC_165 << 27) | (TRC_165 << 22) | \
 			(TRAS_165 << 18) | (TRP_165 << 15) |  \
 			(TRCD_165 << 12) | (TRRD_165 << 9) |  \
 			(TDPL_165 << 6) | (TDAL_165))
 
 #define TWTR_165	1
-#define TCKE_165	2
-#define TXP_165		2
-#define XSR_165		20
+#define TCKE_165	1
+#define TXP_165		5
+#define XSR_165		23
 #define V_ACTIMB_165	(((TCKE_165 << 12) | (XSR_165 << 0)) |	\
 			(TXP_165 << 8) | (TWTR_165 << 16))
 
cpu/arm_cortexa8/omap3/board.c +29 -27

91 lines not on this page · raw message

cpu/arm_cortexa8/omap3/interrupts.c +6 -8
Index: u-boot-arm/cpu/arm_cortexa8/omap3/interrupts.c
===================================================================
@@ -38,9 +38,6 @@
 
 #define TIMER_LOAD_VAL 0
 
-/* macro to read the 32 bit timer */
-#define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR))
-
 #ifdef CONFIG_USE_IRQ
 /* enable IRQ interrupts */
 void enable_interrupts(void)
@@ -170,15 +167,16 @@ void do_irq(struct pt_regs *pt_regs)
 
 static ulong timestamp;
 static ulong lastinc;
+static u32 *timer_base = (u32 *)CONFIG_SYS_TIMERBASE;
 
 /* nothing really to do with interrupts, just starts up a counter. */
 int interrupt_init(void)
 {
 	/* start the counter ticking up, reload value on overflow */
-	writel(TIMER_LOAD_VAL, CONFIG_SYS_TIMERBASE + TLDR);
+	writel(TIMER_LOAD_VAL, timer_base + OFFS(TLDR));
 	/* enable timer */
 	writel((CONFIG_SYS_PVT << 2) | TCLR_PRE | TCLR_AR | TCLR_ST,
-		CONFIG_SYS_TIMERBASE + TCLR);
+		timer_base + OFFS(TCLR));
 
 	reset_timer_masked();	/* init the timestamp and lastinc value */
 
@@ -233,14 +231,14 @@ void udelay(unsigned long usec)
 
 void reset_timer_masked(void)
 {
-	/* reset time */
-	lastinc = READ_TIMER;	/* capture current incrementer value time */
+	/* reset time, capture current incrementer value time */
+	lastinc = readl(timer_base + OFFS(TCRR));
 	timestamp = 0;		/* start "advancing" time stamp from 0 */
 }
 
 ulong get_timer_masked(void)
 {
-	ulong now = READ_TIMER;	/* current tick value */
+	ulong now = readl(timer_base + OFFS(TCRR)); /* current tick value */
 
 	if (now >= lastinc)	/* normal mode (non roll) */
 		/* move stamp fordward with absoulte diff ticks */
cpu/arm_cortexa8/omap3/clock.c +29 -18

88 lines not on this page · raw message

include/asm-arm/arch-omap3/omap3.h +1 -1
Index: u-boot-arm/include/asm-arm/arch-omap3/omap3.h
===================================================================
@@ -75,7 +75,7 @@
 
 /* 32KTIMER */
 #define SYNC_32KTIMER_BASE		0x48320000
-#define S32K_CR				(SYNC_32KTIMER_BASE + 0x10)
+#define S32K_CR				0x10
 
 /* OMAP3 GPIO registers */
 #define OMAP34XX_GPIO1_BASE		0x48310000
#1 lore raw

Dear Dirk,

Quoted 2 lines · In message <[email protected]> you…

Convert readl/writel to base + offset style. Replace hardcoded values with macros.

I think repeating the sequence "base + offset(foo)" again and again is not exactly nice or easy to read.

cpu/arm_cortexa8/omap3/mem.c void make_cs1_contiguous(void) · line 125

Quoted 2 lines
cpu/arm_cortexa8/omap3/mem.c +1 -1
-	writel((a_add_high | a_add_low), SDRC_CS_CFG);
+	writel((a_add_high | a_add_low), sdrc_base + OFFS(SDRC_CS_CFG));

I find this new code is even less readable.

At this point I was tempted to compain that you should not re-invent the offsetof() macro when I realized that the actual definition of OFFS is

	#define OFFS(x)    ((x) >> 2)

Argh... that's awfully error prone. So you rely on havnig to deal with 32 bit register accesses only, without any way of compiler supported type checking?

That's awful.

I am aware that many areas of ARM code use such a horrible program- ming syle of defining only register offsets instead of proper data structures like for example PowerPC has been doing for ages.

Do you see a chance to convert the OMAP3 code to use data structures instead of offset definitions to describe the processor registers and peripherals?

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Nearly everyone is in favor of going  to  heaven  but  too  many  are
hoping  they'll  live  long  enough  to see an easing of the entrance
requirements. Never appeal to a man's "better nature." he  might  not
have one.
author
#2 lore raw

Dear Wolfgang,

Quoted 10 lines · Wolfgang Denk

Dear Dirk,

Quoted 2 lines · In message <[email protected]> you…

Convert readl/writel to base + offset style. Replace hardcoded values with macros.

I think repeating the sequence "base + offset(foo)" again and again is not exactly nice or easy to read.

But it's what the patch does ;) Anyway, if I remember correctly this is why you asked me to re-send OMAP3 patch series to mailing list again once all the review comments are fixed and not directly git pull from OMAP3 branch. To get rid of all these "fix here, clean up there" comments.

Quoted 10 lines

cpu/arm_cortexa8/omap3/mem.c void make_cs1_contiguous(void) · line 125

Quoted 2 lines
cpu/arm_cortexa8/omap3/mem.c +1 -1
-	writel((a_add_high | a_add_low), SDRC_CS_CFG);
+	writel((a_add_high | a_add_low), sdrc_base + OFFS(SDRC_CS_CFG));

I find this new code is even less readable.

At this point I was tempted to compain that you should not re-invent the offsetof() macro when I realized that the actual definition of OFFS is

Quoted 7 lines
	#define OFFS(x)    ((x) >> 2)

Argh... that's awfully error prone. So you rely on havnig to deal with 32 bit register accesses only, without any way of compiler supported type checking?

That's awful.

This style is what Jean-Christophe and Scott asked me to use [1]. I was asked to convert all OMAP3 read/write access to this style to get the patches accepted.

Disussing this at IRC, we agreed on

-- cut --
#define GPMC_BASE 0x6E000000

OFFS(x) ((x) >> 2)

#define GPMC_ECC_CONFIG 0x1F4

static uint32_t *gpmc_base = (uint32_t *)GPMC_BASE;
...
writel(0x000, gpmc_base + OFFS(GPMC_ECC_CONFIG)); -- cut --

style for 32-bit accesses. OFFS is used to be able to use offset macros in assembly, too, and to be able to directly use offset addresses from TRM not needing them to divide by 4 "manually" (error prone).

[1] http://lists.denx.de/pipermail/u-boot/2008-October/042483.html

Quoted 7 lines

I am aware that many areas of ARM code use such a horrible program- ming syle of defining only register offsets instead of proper data structures like for example PowerPC has been doing for ages.

Do you see a chance to convert the OMAP3 code to use data structures instead of offset definitions to describe the processor registers and peripherals?

Looking at the time I already spent into converting to the style used now, no, unfortunately, not. This was the last read/write converting patch, btw.

Best regards

Dirk

Btw.: Did you notice how e.g. Nomadik patch [2] does it?

-- cut --
#define NOMADIK_GPIO1_BASE 0x101E5000
...
writel(0xC37800F0, NOMADIK_GPIO1_BASE + 0x20);
-- cut --

Having this patch applied in this format I slightly wonder

a) why I have to convert all hardcoded values to macros

b) why I have to convert all writex/readx

Style used by Nomadik patch is the same OMAP3 initially used and that wasn't accepted...

[2] http://lists.denx.de/pipermail/u-boot/2008-November/043651.html

#3 lore raw

Dear Dirk,

Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 3 lines

I think repeating the sequence "base + offset(foo)" again and again is not exactly nice or easy to read.

...

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cpu/arm_cortexa8/omap3/mem.c +1 -1
-	writel((a_add_high | a_add_low), SDRC_CS_CFG);
+	writel((a_add_high | a_add_low), sdrc_base + OFFS(SDRC_CS_CFG));

...

Quoted 3 lines
Quoted 3 lines

Argh... that's awfully error prone. So you rely on havnig to deal with 32 bit register accesses only, without any way of compiler supported type checking?

...

Quoted 3 lines

This style is what Jean-Christophe and Scott asked me to use [1]. I was asked to convert all OMAP3 read/write access to this style to get the patches accepted.

I don't see a request for this specific style in the message you referenced.

Anyway - I put both Jean-Christophe and Scott on Cc:, and hereby ask to discuss this again.

Quoted 5 lines

Disussing this at IRC, we agreed on

-- cut --
#define GPMC_BASE 0x6E000000

Quoted 8 lines

OFFS(x) ((x) >> 2)

#define GPMC_ECC_CONFIG 0x1F4

static uint32_t *gpmc_base = (uint32_t *)GPMC_BASE;
...
writel(0x000, gpmc_base + OFFS(GPMC_ECC_CONFIG)); -- cut --

But this is ugly and error prone, and I really do not want to continue adding such code to U-Boot.

Quoted 4 lines

style for 32-bit accesses. OFFS is used to be able to use offset macros in assembly, too, and to be able to directly use offset addresses from TRM not needing them to divide by 4 "manually" (error prone).

It may be true that the ARM referecne manuals just list register offsets - PowerPC manuals do the same. But this is in no way a reason to access the registers through a "base address + offset" style thing without type checking.

Quoted 10 lines

[1] http://lists.denx.de/pipermail/u-boot/2008-October/042483.html

Quoted 3 lines

Do you see a chance to convert the OMAP3 code to use data structures instead of offset definitions to describe the processor registers and peripherals?

Looking at the time I already spent into converting to the style used now, no, unfortunately, not. This was the last read/write converting patch, btw.

Well, if we do not clean this up now, more boards will get added which all use this style, and we will never be able to find resources to clean it up.

Instead of declaring lists of offsets like this:

	#define GPMC_ECC_CONFIG         0x1F4
	#define GPMC_ECC_CONTROL        0x1F8
	#define GPMC_ECC_SIZE_CONFIG    0x1FC
	#define GPMC_ECC1_RESULT        0x200
	#define GPMC_ECC2_RESULT        0x204
	#define GPMC_ECC3_RESULT        0x208
	#define GPMC_ECC4_RESULT        0x20C
	#define GPMC_ECC5_RESULT        0x210
	#define GPMC_ECC6_RESULT        0x214
	#define GPMC_ECC7_RESULT        0x218
	#define GPMC_ECC8_RESULT        0x21C
	#define GPMC_ECC9_RESULT        0x220

you should really use structures like this:

	struct ecc_control {
		u32 ecc_config;
		u32 ecc_control;
		u32 ecc_size_config;
		u32 ecc1_result;
		u32 ecc2_result;
		u32 ecc3_result;
		u32 ecc4_result;
		u32 ecc5_result;
		u32 ecc6_result;
		u32 ecc7_result;
		u32 ecc8_result;
		u32 ecc9_result;
	};

so that instead of

	writel(0x000, gpmc_base + OFFS(GPMC_ECC_CONFIG));

you can write

	writel(0x000, ptr->ecc_config);

or similar - and the compiler will actually perform type checking.

[Actually thius should be done for ALL such offset lists for all systems that use such stuff, i. e. for probably all ARM systems.]

I am aware that this is a major style change, but it really seems necessary to me.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Only a fool fights in a burning house.
	-- Kank the Klingon, "Day of the Dove", stardate unknown
#4 lore raw
Quoted 22 lines · Wolfgang Denk

Dear Dirk,

you should really use structures like this:

       struct ecc_control {
               u32 ecc_config;
               u32 ecc_control;
               u32 ecc_size_config;
               u32 ecc1_result;
               u32 ecc2_result;
               u32 ecc3_result;
               u32 ecc4_result;
               u32 ecc5_result;
               u32 ecc6_result;
               u32 ecc7_result;
               u32 ecc8_result;
               u32 ecc9_result;
       };

so that instead of

Quoted 7 lines
       writel(0x000, gpmc_base + OFFS(GPMC_ECC_CONFIG));

you can write

       writel(0x000, ptr->ecc_config);

or similar - and the compiler will actually perform type checking.

Wolfgang,

Do you mean to instance the ecc_control struct at a specific memory location and use writel(0x000, &ptr->ecc_config);? If so, why not simply use ptr->ecc_config = 0x0000?

Example:

The AMD sc520 has 4k of Memory Mapped Control Registers (MMCR) that range in size from 8 to 32 bits located at a fixed memory address (0xfffef000)

I am thinking of replacing the read/write_mmcr_byte/word/long () functions into a struct e.g.

struct sc520_mmcr {
	/* CPU */
	u16	revid;
	u8	cpuctl;
	u8	pad_0x003[0xd];

	/* SDRAM Controller */
	u8	drcctl;
	
	<etc>

} __attribute__((packed));

struct struct sc520_mmcr* mmcrptr = (volatile struct sc520_mmcr*)0xfffef000;

and replacing:

	write_mmcr_byte(SC520_DRCCTL, \
			(read_mmcr_byte(SC520_DRCCTL) & 0xcf) | (val<<4));

with:

	mmcrptr->drcctl = (mmcrptr->drcctl & 0xcf) | (val<<4);

Is this appropriate?

Regards,

Graeme

#5 lore raw

Dear Graeme,

Quoted 3 lines · in message <[email protected]> you…

Do you mean to instance the ecc_control struct at a specific memory location and use writel(0x000, &ptr->ecc_config);? If so, why not

Yes - this, and all other blocks of registers.

Quoted 1 line

simply use ptr->ecc_config = 0x0000?

Because in general it will not work. You may make it work in many situations by making sure that the poointer has the "volatile" attribute, but depending on CPu propoerties and/or compiler opti- mization this may or may not be sufficient. Please see for example Documentation/volatile-considered-harmful.txt in the Linux kernel tree.

The only clean and portable and thus reliable way is to use the (CPU specific) accessor macros or functions.

Quoted 7 lines

and replacing:

	write_mmcr_byte(SC520_DRCCTL, \
			(read_mmcr_byte(SC520_DRCCTL) & 0xcf) | (val<<4));
with:
	mmcrptr->drcctl = (mmcrptr->drcctl & 0xcf) | (val<<4);

Is this appropriate?

Probably not. Check what the Linux kenrel is doing (but then, x86 may be a poor example; these processors are simply not advanced enough).

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Plan to throw one away. You will anyway."
                              - Fred Brooks, "The Mythical Man Month"
#6 lore raw

Wolfgang,

Quoted 7 lines · Wolfgang Denk

Dear Graeme,

Quoted 3 lines · in message <[email protected]> you…

Do you mean to instance the ecc_control struct at a specific memory location and use writel(0x000, &ptr->ecc_config);? If so, why not

Quoted 7 lines

Yes - this, and all other blocks of registers.

Quoted 1 line

simply use ptr->ecc_config = 0x0000?

mization this may or may not be sufficient. Please see for example Documentation/volatile-considered-harmful.txt in the Linux kernel tree.

Have done

Quoted 3 lines

The only clean and portable and thus reliable way is to use the (CPU specific) accessor macros or functions.

Will do :)

It seems to me that more and more of these 'style' issues are cropping up. Should there be a document that covers them so we can start to systematically improve the consistency of the code?

Thanks

Graeme

#7 lore raw

Dear Graeme,

Quoted 5 lines · In message <[email protected]> you…
Quoted 3 lines

The only clean and portable and thus reliable way is to use the (CPU specific) accessor macros or functions.

Will do :)

thanks.

Quoted 3 lines

It seems to me that more and more of these 'style' issues are cropping up. Should there be a document that covers them so we can start to systematically improve the consistency of the code?

Well, there is: http://www.denx.de/wiki/U-Boot/CodingStyle and Linux/Documentation/

The thing is, that only now people start to realize the importance of some of these issues. The PowerPC tree may be well ahead compared to other architectures, because that's where both big fat 64bit server machines on one side and low-end (50 MHz) embedded processors on the other side have been supported for a long time. I think no other architecture does that in a similar way. [x86 may be different, because it always is.]

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
We do not colonize. We conquer. We rule. There is no  other  way  for
us.
	-- Rojan, "By Any Other Name", stardate 4657.5
#8 lore raw
Quoted 1 line · Wolfgang Denk

Linux/Documentation/

Hmmm, thats a big mouthful to chew for such a small bootloader

Maybe we could start to pick out particular specific pieces that apply directly to the U-Boot source?

Quoted 2 lines

architecture does that in a similar way. [x86 may be different, because it always is.]

One could argue that x86 is always the same and everyone else is (thankfully) different ;)

Cheers,

Graeme

#9 lore raw
Quoted 5 lines · On Mon, 24 Nov 2008 10:53:46 +1100 "Graeme Russ" <[email protected]> wrote:
Quoted 1 line · Wolfgang Denk

Linux/Documentation/

Hmmm, thats a big mouthful to chew for such a small bootloader

I believe he meant linux/Documentation/CodingStyle

Kim

author
#10 lore raw
In reply to Wolfgang Denk

Dear Jean-Christophe,

Quoted 4 lines
Quoted 2 lines · In message <[email protected]> you…

Convert readl/writel to base + offset style. Replace hardcoded values with macros.

It would be quite nice if you could apply this patch to u-boot-arm/omap3 branch independent of read/write discussion. As this is the last clean up patch, after applying this patch we would have the omap3 branch at least in a consistent style for the moment.

Many thanks

Dirk