From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aneesh V Date: Tue, 21 Jun 2011 12:42:59 +0530 Subject: [U-Boot] [PATCH v2 13/22] omap4: add clock support In-Reply-To: <4E003952.30901@ti.com> References: <1298893591-17636-1-git-send-email-aneesh@ti.com> <1305472900-4004-14-git-send-email-aneesh@ti.com> <4E0030F8.6030104@ti.com> <4E003952.30901@ti.com> Message-ID: <4E00447B.9070804@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tuesday 21 June 2011 11:55 AM, Aneesh V wrote: > Dear Wolfgang, > > On Tuesday 21 June 2011 11:19 AM, Aneesh V wrote: >> 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 >> }; > > Apologies for the hasty mail. Looks like I can solve it by doing > something like: > > static unsigned int *const reg_arr[] = { > &(((struct my_regs_struct *)0x1000)->reg1), > &(((struct my_regs_struct *)0x1000)->reg3), > }; > > Analyzing this further right now. Hopefully, the issue can be solved > cleanly. > Some more interesting information: I can reproduce the problem with something as simple as this: main.c: const int const1 = 10; const int const2 = 11; int arr[] = { const1, const2 }; $ gcc main.c main.c:5: error: initializer element is not constant main.c:5: error: (near initialization for ?arr[0]?) main.c:7: error: initializer element is not constant main.c:7: error: (near initialization for ?arr[1]?) The ARM compiler RVCT happily compiles this without an issue. GCC and Visual C++ compilers fail! As a result, I will have to do something like this to populate my array: static unsigned int *const reg_arr[] = { &(((struct my_regs_struct *const)OMAP4_PRCM_REG_BASE)->uart_clkctrl), &(((struct my_regs_struct *const)OMAP4_PRCM_REG_BASE)->i2c_clkctrl), }; Is this acceptable? best regards, Aneesh