Difference between revisions of "Linux Kernel for CM-X300"

From Compulab Mediawiki
Jump to: navigation, search
(SPI support)
m (1 revision(s))
(No difference)

Revision as of 08:46, 26 November 2009

Overview

Linux kernel for CM-X300 modules provides support for on-board peripherals. Current support coverage is specified at O/S support coverage map page. CompuLab provides ready-to-run binary kernel images, and source code of the modifications and additions made to the Linux kernel to work properly with CM-X300 modules.

Building Linux kernel for CM-X300

mkdir /home/development/cm-x300/kernel
cd /home/development/cm-x300/kernel
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2
tar xjf linux-2.6.31.tar.bz2
cd linux-2.6.31
cat /path/to/x300-linux/kernel/linux-2.6.31-cm-x300.patch | patch -p1
export ARCH=arm
export CROSS_COMPILE=arm-linux-
make cm_x300_defconfig
make menuconfig
make && make uImage \
     INSTALL_MOD_PATH=/home/development/cm-x300/rootfs make modules_install

In the above example, the Linux kernel image (uImage) will be created in /home/development/cm-x300/kernel/linux-2.6.31/arch/arm/boot, and the loadable kernel modules will be installed into the /home/development/cm-x300/rootfs/lib/modules directory.

Now, if you boot CM-X300 with newly created kernel image and with networked root filesysem at /home/development/cm-x300/rootfs/ the system will be able to properly load kernel modules and you avoid modules versioning problems.

Creating Linux kernel JFFS2 image

The Linux kernel should be stored in the CM-X300 NAND flash as a JFFS2 image. This image can be created as follows:

mkdir /tmp/cm-x300-kernel/
cp /home/development/cm-x300/kernel/linux-2.6.31/arch/arm/boot/uImage
mkfs.jffs2 --no-cleanmarkers --pad --eraseblock=0x20000 --root=/tmp/cm-x300-kernel --output=/path/to/cm-x300-kernel.jffs2

Using mainline Linux kernel on CM-X300

It is possible to use mainline Linux Kernel on CM-X300 "as is". Just keep in mind that features and fixes listed in below sections are still not present in the mainline kernel.

CM-X300 specific additions and changes to Linux kernel 2.6.31

  • CM-X300 module revision 1.3 support
  • PXA310 cpu support
  • USB Host support
  • Audio and Touchscreen support
  • LCD and backlight support
  • WIFI and Bluetooth support
  • MMC binding fix
  • DA9030 PMIC and battery charger support

CM-X300 specific additions and changes to Linux kernel 2.6.26

  • Basic platform support
  • NAND flash support
  • PXA frame buffer and LCD support
  • WIFI and Bluetooth support
  • RTC support
  • DA9030 PMIC support
  • CPU frequency change support
  • Audio and Touchscreen support
  • USB Host support

Device support details

Basic platform support

The CM-X300 basic platform support is implemented in the linux/arch/arm/mach-pxa/cm-x300.c file. This file includes default setup of multifunction pins, registration of the devices integrated in the CM-X300 module and definitions of platform-specific configuration of these devices. This file also includes several routines needed for proper operation of the WI2WI chip (WiFI and Bluetooth).

I2C support

The I2C bus controller support is enabled in the default Linux Kernel for CM-X300. Standard I2C drivers can be used to access I2C bus on CM-X300 module.
In particular, you can enable the generic i2c-dev driver that allows issuing read/write requests to i2c device through /dev/i2c-X interface or you can use/implement in-kernel device driver.

Registering an I2C device

To register an I2C device, some code needs to be added to the platform initialization file arch/arm/mach-pxa/cm-x300.c:

  • Add struct i2c_board_info and initialize it using the macro (defined in linux/i2c.h) I2C_BOARD_INFO:
static struct i2c_board_info cm_x300_i2c_device = {
	I2C_BOARD_INFO("device name", <7 bit address>),
	/* here initialize other fields if used */
	...
};
  • Register the device with I2C bus controller:
static void __init cm_x300_init_i2c(void)
{
	...
	i2c_register_board_info(<i2c bus number>, &cm_x300_i2c_device, 1);
}

Generic i2c-dev driver

To enable the generic i2c-dev driver, in Linux Kernel configuration, in Device Drivers ---> I2C support select "I2C device interface" either as built-in driver or a module:

  ┌─────────────────────────────────────────── I2C support ────────────────────────────────────────────┐
  │  Arrow keys navigate the menu.  <Enter> selects submenus --->.  Highlighted letters are hotkeys.   │
  │  Pressing <Y> includes, <N> excludes, <M> modularizes features.  Press <Esc><Esc> to exit, <?> for │
  │  Help, </> for Search.  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable         │
  │                                                                                                    │
  │ ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │
  │ │             --- I2C support                                                                    │ │
  │ │             <M>   I2C device interface                                                         │ │
  │ │             [*]   Autoselect pertinent helper modules                                          │ │
  │ │                   I2C Hardware Bus support  --->                                               │ │
  │ │                   Miscellaneous I2C Chip support  --->                                         │ │
  │ │             [ ]   I2C Core debugging messages                                                  │ │
  │ │             [ ]   I2C Algorithm debugging messages                                             │ │
  │ │             [ ]   I2C Bus debugging messages                                                   │ │
  │ │             [ ]   I2C Chip debugging messages                                                  │ │
  │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ │
  ├────────────────────────────────────────────────────────────────────────────────────────────────────┤
  │                                  <Select>    < Exit >    < Help >                                  │
  └────────────────────────────────────────────────────────────────────────────────────────────────────┘

If you choose to compile the driver as a module, the module will be called i2c-dev.
This will create /dev/i2c-X files for each registered I2C adapter.
Information on accessing the I2C devices via the generic i2c-dev driver could be found in Documentation/i2c/dev-interface in the Linux Kernel tree.

SPI support

PXA3xx SPI controller is backward compatible with PXA2xx and it is handled on CM-X300 the same way as on CM-X270. Please refer to SPI support for CM-X270 article.

See also