public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Bill Pringlemeir <bpringlemeir@nbsps.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] ARmv7: Add a soc_init hook to start.S
Date: Thu, 22 Jan 2015 10:48:30 -0500	[thread overview]
Message-ID: <87ppa6yfxt.fsf@nbsps.com> (raw)
In-Reply-To: <54C0FB4F.1070304@redhat.com> (Hans de Goede's message of "Thu, 22 Jan 2015 14:29:51 +0100")


>> On 21 Jan 2015, hdegoede at redhat.com wrote:
>>
>>> On some SoCs / ARMv7 CPU cores we need to do some setup before
>>> enabling the icache, etc. Add a soc_init hook with a weak default
>>> which just calls cpu_init_cp15.
>>>
>>> This way different implementations can be provided to do some extra
>>> work before or after cpu_init_cp15, or completely replacing
>>> cpu_init_cp15.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>> arch/arm/cpu/armv7/start.S | 18 +++++++++++++++++-
>>> 1 file changed, 17 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
>>> index fdc05b9..9882b20 100644
>>> --- a/arch/arm/cpu/armv7/start.S
>>> +++ b/arch/arm/cpu/armv7/start.S
>>>>> -64,7 +64,7 @@ reset:
>>>
>>> 	/* the mask ROM code should have PLL and others stable */
>>> #ifndef CONFIG_SKIP_LOWLEVEL_INIT
>>> -	bl	cpu_init_cp15
>>> +	bl	soc_init
>>> 	bl	cpu_init_crit
>>> #endif
>>>
>>>>> -102,6 +102,22 @@ ENDPROC(save_boot_params)
>>> /*************************************************************************
>>> * + * void soc_init(void) + * __attribute__((weak)); + * + * Stack
>>> pointer is not yet initialized at this moment + * Don't save
>>> anything to stack even if compiled with -O0 + * +
>>> *************************************************************************/
>>> +ENTRY(soc_init)
>>> + mov r9, lr 
>>> + bl cpu_init_cp15 
>>> + mov pc, r9 @ back to my caller 
>>> +ENDPROC(soc_init)
>>> + .weak soc_init

> On 21-01-15 22:59, Bill Pringlemeir wrote:
>>
>> You could just use a 'tail call' and make this,
>>
>> +ENTRY(soc_init)
>> +	b	cpu_init_cp15
>> +ENDPROC(soc_init)

On 22 Jan 2015, hdegoede at redhat.com wrote:

> True, although I think that actually saving lr to r9 is useful as an
> example for boards who want to override this, and that we can spare
> the 2 extra instructions :)

Yes, it is a good example if you are looking to over-ride the 'soc_init'
and I expect that it was hard to figure out that you needed to save the
lr; I can see why you want to warn others.  Two instructions isn't bad.
However, I looked a the code from a different perspective.  I just want
to see what is going on in a normal boot.  I would look at this code and
think what the heck is this about.  Especially as 'r9' is used for other
purposes.

>> Or even as the code follows just add a duplicate label, so 'soc_init'
>> is a weak version of 'cpu_init_cp15'?  This gives no additional code
>> in a final binary.  I guess it depends on how the generic 'soc_init'
>> might be modified in the future?

> I think that having a separate entry for it is much more clear,
> otherwise the entire symbol will be hard to find / grok for people
> trying to get into the code.

Hmm.  I understood better after looking at the sunxi implementation.
The weak 'soc_init' seemed like I didn't understand something.  The
saving of 'lr' in 'r9' is only needed if you have extra code and is
nothing to do with global data or something.  So, it is not just less
code but I think it is more clear what the default case is doing.

I agree, it is definitely an opinion.  Either way works.

> Albert what do you want to do here?

  reply	other threads:[~2015-01-22 15:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 20:03 [U-Boot] [PATCH 1/3] ARmv7: Add a soc_init hook to start.S Hans de Goede
2015-01-21 20:03 ` [U-Boot] [PATCH 2/3] ARMv7: Add a cpu_init_cortex_a7 helper function Hans de Goede
2015-01-21 20:03 ` [U-Boot] [PATCH 3/3] sunxi: Switch to using soc_init hook for setting the ACTLR.SMP bit Hans de Goede
2015-02-08  5:42   ` Ian Campbell
2015-01-21 21:59 ` [U-Boot] [PATCH 1/3] ARmv7: Add a soc_init hook to start.S Bill Pringlemeir
2015-01-22 13:29   ` Hans de Goede
2015-01-22 15:48     ` Bill Pringlemeir [this message]
2015-01-22 16:20 ` Tom Rini
2015-01-22 19:10   ` Hans de Goede
2015-01-22 21:03     ` Tom Rini
2015-01-23  8:54       ` Hans de Goede
2015-01-26 15:18         ` Tom Rini
2015-01-26 19:32           ` Hans de Goede
2015-01-27 14:23             ` Tom Rini
2015-01-31 21:25               ` Albert ARIBAUD
2015-01-31 21:49                 ` Tom Rini
2015-01-31 22:14                   ` Simon Glass
2015-02-02 18:56                     ` Tom Rini
2015-02-02 19:26                       ` Simon Glass
2015-02-04  8:48                       ` Albert ARIBAUD
2015-02-05  3:00                         ` Simon Glass
2015-02-05  8:27                           ` Hans de Goede
2015-02-05 15:14                           ` Albert ARIBAUD
2015-02-05 15:34                             ` Simon Glass
2015-02-05 18:02                               ` Albert ARIBAUD
2015-02-05 19:13                                 ` Simon Glass
2015-02-10 22:07                         ` Tom Rini
2015-02-10 23:27                           ` Simon Glass
2015-01-26  8:09   ` Albert ARIBAUD
2015-01-26 10:50     ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ppa6yfxt.fsf@nbsps.com \
    --to=bpringlemeir@nbsps.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox