Subject: Kernel bootsequence (was: Unable to write registers)

From: "Arjan Opmeer (EMN)" <[email-masked]>
Date: Thu, 3 Aug 2000 18:02:59 +0200

Hi,

This message is in repsonse to my troubles writing the SKPCR register on
the SA-1111 development board to enable the USB clock.

It seems John was right after all, only I wasn't paying attention and
missed the real cause of the problem. The USB initialisation is performed
before the code in sa1111_init() is executed. Hence, my code added to the
USB driver cannot work because the RAB hasn't been initialised properly
at this point in the bootsequence. Only after puting some more printks in
different parts of the kernel did I notice this... :(

This leads me to my next question. What controls in what sequence the
different parts of the kernel are executed during system boot and why is
the code in sa1111_init() executed at such a late stage in the sequence?

It seems to me that it would be beneficial to have the SA-1111
initalisation code executed earlier, so other kernel parts, like the
USB driver or the Ethernet driver, can also initialise while compiled
into the kernel. Compiling the drivers as modules would solve the problem,
but would be the wrong solution to the problem in my opinion.

I have been staring at the kernel code to try to understand what
determines the boot sequence, but haven't found it yet, not helped in the
least by the fact that I was dozing off on my keyboard.... :-)

Could someone shed some light on this matter?

Thanks in advance,

Arjan

unsubscribe: body of `unsubscribe linux-arm' to [email-masked]
++        Please use [email-masked] for           ++
++                        kernel-related discussions.                      ++

---

From: Nicolas Pitre <[email-masked]>
Date: Fri, 11 Aug 2000 15:03:42 -0400 (EDT)

> the code in sa1111_init() executed at such a late stage in the sequence?

This function is referenced by the module_init() macro.  This allows for
the linker to automatically build a list of pointers for all
initialization functions to be called upon booting the kernel.  The order
for those calls is the same as the link order.

> but would be the wrong solution to the problem in my opinion.

The right solution would require linux/arch/arm/kernel/kernel.o to be
linked before any drivers.

Nicolas

---

From: Russell King - ARM Linux Admin <[email-masked]>
Date: Sat, 12 Aug 2000 08:45:58 +0100 (BST)

> linked before any drivers.

Ah, but it is, and it appears at the head of the initcall list.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |        Russell King       [email-masked]      --- ---
  | | | |            http://www.arm.linux.org.uk/            /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

---

From: Nicolas Pitre <[email-masked]>
Date: Sat, 12 Aug 2000 11:44:41 -0400 (EDT)

> Ah, but it is, and it appears at the head of the initcall list.

You are right.  Here is the real problem:

linux/init/main.c:

#ifdef CONFIG_USB
        usb_init();  /* Do this before doing initcalls, so that we can make
                        usbcore initialize here, and all drivers initialize later */
#endif

So hw_sa1100_init() must not be called from the initcall list but way
before.  My next patch will fix this.

Nicolas

---

From: Russell King - ARM Linux Admin <[email-masked]>
Date: Sat, 12 Aug 2000 16:59:58 +0100 (BST)

> before.  My next patch will fix this.

Ok, after looking a little deeper at this problem, I am convinced that
this is far from the correct way to fix it.

The correct way is to move ohci_hcd_init out of usb_init() and make
ohci_hcd_init be called via the initcalls method.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |        Russell King       [email-masked]      --- ---
  | | | |            http://www.arm.linux.org.uk/            /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

---

From: Nicolas Pitre <[email-masked]>
Date: Sat, 12 Aug 2000 12:40:15 -0400 (EDT)

> ohci_hcd_init be called via the initcalls method.

You're probably right.  However I'll stick to the early explicit call with
my patch until your suggestion appears in a base kernel.

Nicolas