[U-Boot] [PATCH v4] da830: Move common code out of da830evm.c file

Ben Gardiner bengardiner at nanometrics.ca
Fri Jun 4 16:26:20 CEST 2010


On Thu, Jun 3, 2010 at 8:58 AM, Sudhakar Rajashekhara
<sudhakar.raj at ti.com> wrote:
> On Thu, Jun 03, 2010 at 16:23:36, Nick Thompson wrote:
>> On 03/06/10 05:25, Sudhakar Rajashekhara wrote:
>> > TI's DA850/OMAP-L138 platform is similar to DA830/OMAP-L137
>> > in many aspects. So instead of repeating the same code in
>> > multiple files, move the common code to a different file
>> > and call those functions from the respective da830/da850
>> > files.
>> >
>> > Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj at ti.com>
>> > Acked-by: Nick Thompson <nick.thompson at ge.com>
>> > Acked-by: Ben Gardiner <bengardiner at nanometrics.ca>
>> > ---
>> > Since v3:
>> > Fixes the following compiler error for other davinci targets:
>> >
>> > misc.c: In function 'irq_init':
>> > misc.c:51: error: 'davinci_aintc_regs' undeclared (first use in this function)
>> > misc.c:51: error: (Each undeclared identifier is reported only once
>> > misc.c:51: error: for each function it appears in.)
>> > make[1]: *** [.../build/board/davinci/common/misc.o] Error 1
>> > make: *** [.../build/board/davinci/common/libdavinci.a] Error 2
>> > make: *** Waiting for unfinished jobs....
>> >
>> >  board/davinci/common/misc.c       |   32 ++++++++++++++++++++++++++++++++
>> >  board/davinci/common/misc.h       |    7 +++++++
>> >  board/davinci/da830evm/da830evm.c |   28 +++++++++++-----------------
>> >  3 files changed, 50 insertions(+), 17 deletions(-)
>> >
>> > diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c
>> > index 25ca326..dcf3cf2 100644
>> > --- a/board/davinci/common/misc.c
>> > +++ b/board/davinci/common/misc.c
>> > @@ -41,6 +41,24 @@ int dram_init(void)
>> >     return(0);
>> >  }
>> >
>> > +#ifdef CONFIG_SOC_DA8XX
>> > +void irq_init(void)
>> > +{
>> > +   /*
>> > +    * Mask all IRQs by clearing the global enable and setting
>> > +    * the enable clear for all the 90 interrupts.
>> > +    */
>> > +
>> > +   writel(0, &davinci_aintc_regs->ger);
>> > +
>> > +   writel(0, &davinci_aintc_regs->hier);
>> > +
>> > +   writel(0xffffffff, &davinci_aintc_regs->ecr1);
>> > +   writel(0xffffffff, &davinci_aintc_regs->ecr2);
>> > +   writel(0xffffffff, &davinci_aintc_regs->ecr3);
>> > +}
>> > +#endif
>>
>> In the current code base, this code is not included in the da830 compilation
>> if IRQs are not used. With this patch the code is included, but not called
>> if IRQs are not used. IRQs are often not used, so this change causes bloat.
>>
>> Could you please make this conditional on IRQs?
>>
>
> I added the code between CONFIG_SOC_DA8XX macro because davinci_aintc_regs
> declaration is in between this macro in hardware.h file. So they'll not be
> available for targets other than DA830 and DA850. Also, AINTC register
> mapping is different on DM644x, DM646x, DM355 and DM365. Shall I consider
> moving the irq_init function out of misc.c?

I can confirm that compilation of da830evm_defconfig is not possible
with CONFIG_USE_IRQ; attempting this will result in a compilation
error in start.S.

Since it is da8XX specific, irq_init might be best placed somewhere in
the board/davinci/da8xxevm directory that is being introduced in the
da850 support series? Perhaps for this patch it could be extracted to
board/davinci/da830evm/common.c ?

I think that the unconditional definition of
davinci_configure_lpsc_items function has caused bloat in the other
davinci u-boot binaries:

--- ../davinci-before.out       2010-06-04 09:18:44.130839762 -0400
+++ ../davinci-after.out        2010-06-04 09:28:40.241776938 -0400
@@ -1,30 +1,30 @@
 Configuring for davinci_dvevm board...
    text           data     bss     dec     hex filename
- 178520           5500  297984  482004   75ad4 ./u-boot
+ 178568           5500  297984  482052   75b04 ./u-boot
 Configuring for davinci_schmoogie board...
    text           data     bss     dec     hex filename
- 154090           9000   54172  217262   350ae ./u-boot
+ 154138           9000   54172  217310   350de ./u-boot
 Configuring for davinci_sffsdr board...
    text           data     bss     dec     hex filename
- 153772           9024   54172  216968   34f88 ./u-boot
+ 153820           9024   54172  217016   34fb8 ./u-boot
 Configuring for davinci_sonata board...
    text           data     bss     dec     hex filename
- 145308           5296   55068  205672   32368 ./u-boot
+ 145356           5296   55068  205720   32398 ./u-boot
 Configuring for davinci_dm355evm board...
    text           data     bss     dec     hex filename
- 207202           8516   40864  256582   3ea46 ./u-boot
+ 207250           8516   40864  256630   3ea76 ./u-boot
 Configuring for davinci_dm355leopard board...
    text           data     bss     dec     hex filename
- 206320           7904   40864  255088   3e470 ./u-boot
+ 206492           7904   40864  255260   3e51c ./u-boot
 Configuring for davinci_dm365evm board...
    text           data     bss     dec     hex filename
- 243385           8704  297752  549841   863d1 ./u-boot
+ 243557           8704  297752  550013   8647d ./u-boot
 Configuring for davinci_dm6467evm board...
    text           data     bss     dec     hex filename
-  91776           4776   26100  122652   1df1c ./u-boot
+  91948           4776   26100  122824   1dfc8 ./u-boot
 Configuring for da830evm board...
    text           data     bss     dec     hex filename
- 147475           4888  295320  447683   6d4c3 ./u-boot
+ 147543           4888  295320  447751   6d507 ./u-boot

Whereas if the definition of the davinci_configure_lpsc_items function
is made conditional on the same CONFIG_SOC_DA8XX macro introduced for
irq_init the other davinci systems u-boot binaries stay slim.

i.e applying the following on top of your patch:

---
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c
index dcf3cf2..d6536f6 100644
--- a/board/davinci/common/misc.c
+++ b/board/davinci/common/misc.c
@@ -205,6 +205,7 @@ int davinci_configure_pin_mux_items(const struct
pinmux_resource *item,
        return 0;
 }

+#ifdef CONFIG_SOC_DA8XX
 /*
  * Enable PSC for various peripherals.
  */
@@ -218,3 +219,4 @@ int davinci_configure_lpsc_items(const struct
lpsc_resource *item,

        return 0;
 }
+#endif

results in no change in most of the davinci u-boot binaries:

--- ../davinci-before.out       2010-06-04 09:18:44.130839762 -0400
+++ ../davinci-after.out        2010-06-04 10:04:39.820802124 -0400
@@ -24,7 +24,7 @@ Configuring for davinci_dm6467evm board.
   91776           4776   26100  122652   1df1c ./u-boot
 Configuring for da830evm board...
    text           data     bss     dec     hex filename
- 147475           4888  295320  447683   6d4c3 ./u-boot
+ 147543           4888  295320  447751   6d507 ./u-boot

This bloat could also be addressed by moving the definition of that
function into a da8xx-common file along with irq_init.

Best Regards,

Ben Gardiner

PS: binary size output comparison was based on './MAKEALL davinci'
output with the following changes:

---
diff --git a/MAKEALL b/MAKEALL
index 2527352..d5a4ee2 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -545,6 +545,21 @@ LIST_ARM7="                \
 "

 #########################################################################
+## DaVinci Systems
+#########################################################################
+LIST_davinci="         \
+       davinci_dvevm           \
+       davinci_schmoogie       \
+       davinci_sffsdr          \
+       davinci_sonata          \
+       davinci_dm355evm        \
+       davinci_dm355leopard    \
+       davinci_dm365evm        \
+       davinci_dm6467evm       \
+       da830evm                \
+"
+
+#########################################################################
 ## ARM9 Systems
 #########################################################################

@@ -560,7 +575,6 @@ LIST_ARM9="                 \
        cp926ejs                \
        cp946es                 \
        cp966                   \
-       da830evm                \
        edb9301                 \
        edb9302                 \
        edb9302a                \
@@ -602,14 +616,7 @@ LIST_ARM9="                        \
        versatileab             \
        versatilepb             \
        voiceblue               \
-       davinci_dvevm           \
-       davinci_schmoogie       \
-       davinci_sffsdr          \
-       davinci_sonata          \
-       davinci_dm355evm        \
-       davinci_dm355leopard    \
-       davinci_dm365evm        \
-       davinci_dm6467evm       \
+       ${LIST_davinci}         \
 "

 #########################################################################
@@ -996,7 +1003,7 @@ print_stats() {
 for arg in $@
 do
        case "$arg" in
-       arm|SA|ARM7|ARM9|ARM10|ARM11|ARM_CORTEX_A8|at91|ixp|pxa \
+       arm|SA|ARM7|ARM9|ARM10|ARM11|ARM_CORTEX_A8|at91|ixp|pxa|davinci \
        |avr32 \
        |blackfin \
        |coldfire \

-- 
Ben Gardiner
Nanometrics Inc.
+1 (613) 592-6776 x239
http://www.nanometrics.ca


More information about the U-Boot mailing list