CM-X300: Linux: Kernel

From Compulab Mediawiki
Revision as of 13:43, 29 September 2013 by Grinberg (talk | contribs) (See also)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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/v3.x/linux-3.4.61.tar.bz2
tar xjf linux-3.4.61.tar.bz2
cd linux-3.4.61
cat /path/to/x300-linux/kernel/linux-3.4.61-cm-x300-3.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-3.4.61/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-3.4.61/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 3.4.61

  • Suspend/Resume support
  • Regulators support
  • USB OTG charge pump support
  • Keypad support
  • Battery capacity capability
  • Fixed audio driver
  • Fixed DM9000 Ethernet controller driver
  • Fixed frame buffer shift issue
  • Fixed Toppoly LCD and LCD control GPIOs warning

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                                                                    │ │
  │ │             [*]   Enable compatibility bits for old user-space                                 │ │
  │ │             <*>   I2C device interface                                                         │ │
  │ │             < >   I2C bus multiplexing support                                                 │ │
  │ │             [*]   Autoselect pertinent helper modules                                          │ │
  │ │                   I2C Hardware Bus support  --->                                               │ │
  │ │             [ ]   I2C Core debugging messages                                                  │ │
  │ │             [ ]   I2C Algorithm debugging messages                                             │ │
  │ │             [ ]   I2C Bus 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 CM-X270: Linux: SPI support article.

See also