Linux chip-level porting and bottom-driven (based on 3.7.4 kernel) kernel beats

Source: Internet
Author: User

1.SoC Linux Bottom drive composition and status

To allow Linux to run on a brand new arm SOC, there are a number of underlying support, such as timer beats, interrupt controllers, SMP booting, CPU HotPlug, and the underlying GPIO, clock, Pinctrl, and DMA hardware packages. Timer beats, interrupt controllers, SMP boot, and CPU hotplug are relatively not as cluttered as the early Gpio, clock, Pinctrl, and DMA implementations, and basically have a fixed routine. Timer beats for Linux based on time slice scheduling mechanism and kernel and user space timer to provide support, interrupt controller driver so that the Linux kernel engineers can directly invoke Local_irq_disable (), DISABLE_IRQ () and other common interrupt APIs, SMP boot support is used to enable multiple CPU cores within the SOC to run, and CPU hotplug to mount or unplug the CPU while running. These efforts, in the Linux 3.7 kernel, have a good hierarchy and architectural design.

In the Gpio, clock, Pinctrl, and DMA drivers, the Linux 2.6 era, the kernel has more or less the GPIO, clock and other low-level-driven architecture, but the core layer of the code is too weak, the SOC for these infrastructure implementation of the major differences, And each SOC still needs to implement a lot of code. Pinctrl and DMA are the most confusing, and almost all companies define their own unique implementations and APIs.

The community has to change that, so the kernel community has done the following in 2011-2012 years, which are basically ready in the current 3.7 kernel:

§ti's engineer, Mike Turquette, provides a common CLK framework that enables specific SOC implementations of CLK_OPS member functions, and through Clk_register, Clk_register_clkdev registered clock sources and source-device correspondence. The specific clock drivers are migrated uniformly to the DRIVERS/CLK directory;

§ In terms of Gpio, the gpiolib of Drivers/gpio has been able to coexist perfectly with the new Pinctrl, and to achieve the reuse of pins gpio and other functions, the specific SOC only needs to implement a universal gpio_chip structure member function.

After the above work, basically the chip on the bottom of the infrastructure-driven architecture to unify the implementation method is also unified. In addition, at present, Gpio, clock, pinmux and other functions can be good for device tree mapping processing, such as we can in terms of in. DTS to define a device to the clock, Pinmux pins and Gpio.

In addition to the above infrastructure, engineers often rely heavily on early PRINTK functionality when porting Linux to New Soc, while the kernel provides related debug_ll and EARLY_PRINTK support, requiring only a small number of callback or macros to be implemented by the SOC provider.

This article mainly carries on the analysis of the structure and the key realization part of the above components, in order to generalize the main work of porting Linux into the new Soc. This article is based on the 3.7.4 kernel.

2. Timer driver for operating system beats

The early days of Linux 2.6 (2.6.21) were based on tick design, when a general Soc company was porting Linux to its own chip, it would look for a timer from the inside of the chip and configure the timer to be the frequency of Hz, calling arm when each clock beat came. The Timer_tick () function of the core layer of the Linux kernel, which triggers a series of behaviors in the system. As in 2.6.17, the arch/arm/mach-s3c2410/time.c is:

127/*

128 * IRQ handler for the timer

129 */

130static irqreturn_t

131s3c2410_timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)

132{

Write_seqlock (&xtime_lock);

134 Timer_tick (regs);

135 Write_sequnlock (&xtime_lock);

136 return irq_handled;

137}

138

139static struct Irqaction S3c2410_timer_irq = {

140. Name = "s3c2410 Timer Tick",

A. Flags = Sa_interrupt | Sa_timer,

Handler = S3c2410_timer_interrupt,

143};

252static void __init s3c2410_timer_init (void)

253{

254 S3c2410_timer_setup ();

255 SETUP_IRQ (Irq_timer4, &S3C2410_TIMER_IRQ);

256}

257

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.