User:CesarB/cpufreq

From Openmoko

< User:CesarB(Difference between revisions)
Jump to: navigation, search
(done)
(To build: hints)
Line 19: Line 19:
 
# Run <code>make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage</code>
 
# Run <code>make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage</code>
 
# The last line of the output tells you the correct file which should be flashed on the emulator.
 
# The last line of the output tells you the correct file which should be flashed on the emulator.
 +
 +
=== Hints ===
 +
 +
* Enable <code>CONFIG_CPU_FREQ_DEBUG</code> and add <code>cpufreq.debug=7</code> to the kernel command line to enable the relevant debug output.
  
 
== What's already done ==
 
== What's already done ==

Revision as of 21:24, 19 January 2008

The cpufreq subsystem is a Linux kernel subsystem responsible for managing the CPU frequency. It's commonly used in laptops to reduce power usage when idle.

On the S3C2410, adjusting the CPU frequency changes the clocks for almost all devices on the chip. This means that, to write a cpufreq driver for the S3C2410, you have to also adjust some values on almost all devices.

This project aims to implement the cpufreq driver (which manages the CPU frequency transitions) and a cpufreq notifier for all the affected drivers (to do two things: quiesce the device before the change, and adjust the frequency after the change). Deciding which frequency to use is the responsability of code from somewhere else (either cpufreq governors or userspace).

The most recent version of the code can be found at http://repo.or.cz/w/linux-2.6/s3c2410-cpufreq.git on the branches s3c2410-cpufreq (for code which applies on top of the upstream "git HEAD" kernel) and s3c2410-cpufreq-gta01 (for code which applies on top of the OpenMoko patched kernel).

Contents

To build

NOTE: Do not run on real hardware, unless you really know what you are doing. This code is completely untested. It might even not compile.


You need a fully built OpenMoko tree for the cross-compiler and uboot tools.

  1. Checkout the s3c2410-cpufreq-gta01 branch
  2. Copy the defconfig file from branches/src/target/kernel/2.6.24.x/config on the OpenMoko svn as the .config file
  3. Set the PATH to the correct value (check the run.* temporary files bitbake generates to find out the correct value)
  4. Run make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- oldconfig and answer correctly the questions
  5. Run make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage
  6. The last line of the output tells you the correct file which should be flashed on the emulator.

Hints

  • Enable CONFIG_CPU_FREQ_DEBUG and add cpufreq.debug=7 to the kernel command line to enable the relevant debug output.

What's already done

S3C2410A cpufreq driver

This code resides on arch/arm/mach-s3c2410/s3c2410-cpufreq.c and is responsible for actually changing the frequency.

The list of available frequencies and their parameters (HCLK/PCLK dividers) can be found on this file.

Timer 4 driver

Timer 4 is used by the kernel as the periodic tick timer. The cpufreq notifier on arch/arm/plat-s3c24xx/time.c is responsible for adjusting the current and reload values of the timer to match the new frequency.

Serial driver

The cpufreq notifier on drivers/serial/s3c2410.c is responsible for (if possible) pausing both sides of the serial transmission before the frequency change and reloading the baud generator (and unpausing the serial transmission) after the change.

Pausing the transmission is currently only possible with hardware flow control. Since both serial ports on GTA01 use hardware flow control, that's not a problem (unless you are using the serial console).

Framebuffer driver

The cpufreq notifier on drivers/video/s3c2410fb.c is responsible for turning off the video before the frequency change and reloading its configuration after the frequency change.

NAND driver

The cpufreq notifier on drivers/mtd/nand/s3c2410.c is responsible for reprogramming the NAND timings after a frequency change.

What's missing

S3C2410A cpufreq driver

The frequency table should be checked for better divisor values (1:1:1 might be appropriate in more situations), and the code should be able to deal with HDIVN1 and different bus modes.

Timer 4 driver

The cpufreq notifier should perhaps use a higher priority, so as to run before all the others for more precise timekeeping.

NAND driver

The cpufreq notifier should make sure the NAND is quiesced before the frequency change, or change the timings to the most conservative ones before the frequency change.

Missing drivers

  • Backlight (uses a PWM timer)
  • Vibrator (uses a PWM timer)
  • MMC/SD
  • I2C (without a notifier and booting at the maximum speed, it can only get slower; there should be no side effects, since there's no minimum bus speed)
  • IIS
  • SPI

Frequency restrictions

Some drivers need specific frequencies. Currently there's no way to tell the cpufreq core of that, but at minimum a cpufreq notifier should be used to turn them off if they won't be able to work with that frequency.

  • The datasheet says the USB device gets unstable if the frequency is below a minimum value
  • When using the IIS device, changing the frequency might not be a good idea, since it can cause audio glitches. It also probably needs a minimum frequency depending on the output audio frequency and sample size.
  • The LCD device might also need a minimum frequency.

See also

Personal tools

The cpufreq subsystem is a Linux kernel subsystem responsible for managing the CPU frequency. It's commonly used in laptops to reduce power usage when idle.

On the S3C2410, adjusting the CPU frequency changes the clocks for almost all devices on the chip. This means that, to write a cpufreq driver for the S3C2410, you have to also adjust some values on almost all devices.

This project aims to implement the cpufreq driver (which manages the CPU frequency transitions) and a cpufreq notifier for all the affected drivers (to do two things: quiesce the device before the change, and adjust the frequency after the change). Deciding which frequency to use is the responsability of code from somewhere else (either cpufreq governors or userspace).

The most recent version of the code can be found at http://repo.or.cz/w/linux-2.6/s3c2410-cpufreq.git on the branches s3c2410-cpufreq (for code which applies on top of the upstream "git HEAD" kernel) and s3c2410-cpufreq-gta01 (for code which applies on top of the OpenMoko patched kernel).

To build

NOTE: Do not run on real hardware, unless you really know what you are doing. This code is completely untested. It might even not compile.


You need a fully built OpenMoko tree for the cross-compiler and uboot tools.

  1. Checkout the s3c2410-cpufreq-gta01 branch
  2. Copy the defconfig file from branches/src/target/kernel/2.6.24.x/config on the OpenMoko svn as the .config file
  3. Set the PATH to the correct value (check the run.* temporary files bitbake generates to find out the correct value)
  4. Run make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- oldconfig and answer correctly the questions
  5. Run make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage
  6. The last line of the output tells you the correct file which should be flashed on the emulator.

Hints

  • Enable CONFIG_CPU_FREQ_DEBUG and add cpufreq.debug=7 to the kernel command line to enable the relevant debug output.

What's already done

S3C2410A cpufreq driver

This code resides on arch/arm/mach-s3c2410/s3c2410-cpufreq.c and is responsible for actually changing the frequency.

The list of available frequencies and their parameters (HCLK/PCLK dividers) can be found on this file.

Timer 4 driver

Timer 4 is used by the kernel as the periodic tick timer. The cpufreq notifier on arch/arm/plat-s3c24xx/time.c is responsible for adjusting the current and reload values of the timer to match the new frequency.

Serial driver

The cpufreq notifier on drivers/serial/s3c2410.c is responsible for (if possible) pausing both sides of the serial transmission before the frequency change and reloading the baud generator (and unpausing the serial transmission) after the change.

Pausing the transmission is currently only possible with hardware flow control. Since both serial ports on GTA01 use hardware flow control, that's not a problem (unless you are using the serial console).

Framebuffer driver

The cpufreq notifier on drivers/video/s3c2410fb.c is responsible for turning off the video before the frequency change and reloading its configuration after the frequency change.

NAND driver

The cpufreq notifier on drivers/mtd/nand/s3c2410.c is responsible for reprogramming the NAND timings after a frequency change.

What's missing

S3C2410A cpufreq driver

The frequency table should be checked for better divisor values (1:1:1 might be appropriate in more situations), and the code should be able to deal with HDIVN1 and different bus modes.

Timer 4 driver

The cpufreq notifier should perhaps use a higher priority, so as to run before all the others for more precise timekeeping.

NAND driver

The cpufreq notifier should make sure the NAND is quiesced before the frequency change, or change the timings to the most conservative ones before the frequency change.

Missing drivers

  • Backlight (uses a PWM timer)
  • Vibrator (uses a PWM timer)
  • MMC/SD
  • I2C (without a notifier and booting at the maximum speed, it can only get slower; there should be no side effects, since there's no minimum bus speed)
  • IIS
  • SPI

Frequency restrictions

Some drivers need specific frequencies. Currently there's no way to tell the cpufreq core of that, but at minimum a cpufreq notifier should be used to turn them off if they won't be able to work with that frequency.

  • The datasheet says the USB device gets unstable if the frequency is below a minimum value
  • When using the IIS device, changing the frequency might not be a good idea, since it can cause audio glitches. It also probably needs a minimum frequency depending on the output audio frequency and sample size.
  • The LCD device might also need a minimum frequency.

See also