[U-Boot] [PATCH v2 13/22] omap4: add clock support

Aneesh V aneesh at ti.com
Tue Jun 21 07:49:44 CEST 2011


Dear Wolfgang,

On Sunday 15 May 2011 08:51 PM, Aneesh V wrote:
[snip ..]
> +static const u32 clk_modules_hw_auto_essential[] = {
> +	CM_WKUP_GPIO1_CLKCTRL,
> +	CM_L4PER_GPIO2_CLKCTRL,
> +	CM_L4PER_GPIO3_CLKCTRL,
> +	CM_L4PER_GPIO4_CLKCTRL,
> +	CM_L4PER_GPIO5_CLKCTRL,
> +	CM_L4PER_GPIO6_CLKCTRL,
> +	CM_MEMIF_EMIF_1_CLKCTRL,
> +	CM_MEMIF_EMIF_2_CLKCTRL,
> +	CM_L3INIT_HSUSBOTG_CLKCTRL,
> +	CM_L3INIT_USBPHY_CLKCTRL,
> +	CM_L4CFG_L4_CFG_CLKCTRL,
> +	0
> +};

In this series you asked me to convert the base + offset mode of
register address definition to struct based register address
definition. While doing this I am facing a problem. Please note the
above array that contain register addresses. This is a group of
registers that control our clock modules. All these registers have
similar bit fields and they can be programmed in same manner. So, I
keep them in an array and pass the array to a function that iterates
through array and does similar processing on all the registers(see
below).

I am finding it difficult to implement this using the struct based
approach. I tried the sample code below:

struct my_regs_struct {
	const unsigned int reg1;
	const unsigned int reg2;
	const unsigned int reg3;
};

static struct my_regs_struct *const my_regs = (struct my_regs_struct 
*)0x1000;

static unsigned int *const reg_arr[] = {
	&my_regs->reg1,
	&my_regs->reg3
};

void main(void)
{
	printf("regs %x %x \n", reg_arr[0], reg_arr[1]);
}

I am getting the following errors on compiling this:
main.c:10: error: initializer element is not constant
main.c:10: error: (near initialization for ‘reg_arr[0]’)
main.c:12: error: initializer element is not constant
main.c:12: error: (near initialization for ‘reg_arr[1]’)

I can't make it work unless I make my_regs a statically defined
structure itself and not a pointer - like this:

static struct my_regs_struct my_regs;

This seems quite strange(behavior is the same with gcc and Microsoft
compiler). Am I missing something?

Any ideas to make it work? If not, can I go back to defines for the
addresses. All the registers we have are 32 bit long and we always use
u32 for them and use readl/writel for accessor functions. Using the
wrong accessor function is highly unlikely.

[snip ...]

> +	/* Clock modules that need to be put in HW_AUTO */
> +	for (i = 0; (i<  max)&&  clock_modules_hw_auto[i]; i++) {
> +		enable_clock_module(clock_modules_hw_auto[i],
> +				    MODULE_CLKCTRL_MODULEMODE_HW_AUTO,
> +				    wait_for_enable);
> +	};

best regards,
Aneesh


More information about the U-Boot mailing list