i.MX 6 BSP Porting Guide PDF
i.MX 6 BSP Porting Guide PDF
i.MX 6 BSP Porting Guide PDF
Chapter 1
Porting U-Boot from an i.MX 6 Reference Board to an i.MX 6 Custom Board
1.1 U-Boot Overview............................................................................................................................................................7
1.4 Debugging.......................................................................................................................................................................13
Chapter 2
Configuring the IOMUX Controller
2.1 IOMUX Overview..........................................................................................................................................................15
Chapter 3
Registering a New UART Driver
3.1 Enabling UART on Kernel Menuconfig.........................................................................................................................19
Chapter 4
Adding Support for SDHC
4.1 SDHC Overview.............................................................................................................................................................21
Chapter 5
Configuring the SPI NOR Flash Memory Technology Device (MTD) Driver
5.1 SPI NOR Overview.........................................................................................................................................................23
Chapter 6
Connecting an LVDS Panel to an i.MX 6Dual/6Quad/6Solo/6DualLite Reference Board
6.1 LVDS Overview.............................................................................................................................................................27
Chapter 7
Supporting the i.MX 6Dual/6Quad/6Solo/6DualLite Camera Sensor with CSI
7.1 CSI Overview..................................................................................................................................................................31
Chapter 8
Porting Audio Codecs to a Custom Board
8.1 Audio Overview..............................................................................................................................................................45
8.1.2 Porting the Reference BSP to a Custom Board (audio codec is the same as in the reference design)................46
8.1.3 Porting the Reference BSP to a Custom Board (audio codec is different than the reference design).................47
Chapter 9
Porting the Ethernet Controller Driver
9.1 Ethernet Controller Overview.........................................................................................................................................49
Chapter 10
Porting USB Host1 and USB OTG
10.1 USB Overview for i.MX 6Dual/6Quad/6Solo/6DualLite..............................................................................................53
NOTE
The configuration files for the i.MX 6 are located at
include/configs. The files associated with the boards are:
• i.MX 6 SABRE-SD:
• mx6sabresd_common.h
• mx6sabresd.h
• i.MX 6 SABRE-AI:
• mx6sabresd_common.h
• mx6sabreauto.h
• i.MX 6SL EVK:
• mx6slevk.h
NOTE
You should pay attention to the following configurations
when using a new board.
• CONFIG_LOADADDR: Normally your uImage will be
loaded to this address for boot.
• CONFIG_SYS_MALLOC_LEN: Heap memory size.
• CONFIG_STACKSIZE: Stack size.
• CONFIG_NR_DRAM_BANKS: Number of ddr banks.
• CONFIG_DDR_MB: Configure the DDR size in
• MB.PHYS_SDRAM: Physical address for the DDR
memory
• Config file is important for U-Boot. It determines the
size, functionality, and performance of u-boot.bin.
3. Create one entry in <UBOOT_DIR>/boards.cfg for the new -based configuration.
This file is in alphabetical order. The instruction is an example for i.MX 6Quad
board:
mx6q<customer_board_name> arm armv7 mx6q<customer_board_name>
freescale mx6
NOTE
U-Boot project developers recommend adding any new
board to the MAKEALL script and running this script to
validate that the new code has not broken any other
platform build. This is a requirement if you plan to submit a
patch back to the U-Boot community. For further
information, see the U-Boot README file.
4. Rename
board/freescale/mx6<reference board name>/mx6<reference board name>.c
to
board/freescale/mx6<custom board name>/mx6<custom board name>.c.
5. Change the line
COBJS := mx6<reference board name>.o (inside board/freescale/mx6<custom board
name>/Makefile)
to
COBJS := mx6<custom board name>.o
NOTE
The remaining instructions build the U-Boot manually and
do not use Yocto Project.
6. Create a shell script under <UBOOT_DIR> named build_u-boot.sh.
The file contents are as follows:
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=<path to cross compiler prefix> (e.g.
/opt/poky/1.4.1/sysroots/i686-pokysdk-linux/usr/bin/cortexa9hf-vfp-neon-poky-linux-
gnueabi/arm-poky-linux-gnueabi-
make distclean;
make mx6<custom board name>
make
7. Compile U-Boot by using $./build_u-boot.sh
8. If everything is correct, you should now have u-boot.bin, which indicates that your
build setup is correct and ready to be customized.
The new i.MX 6 custom board that you have created is an exact copy of the i.MX 6
reference board, but the boards are two independent builds. This allows you to proceed to
the next step: customizing the code to suit the new hardware design.
The following message should be displayed on the console if your custom board was
based on the i.MX 6SoloLite EVK:
All board initialization is executed inside this function. It starts by running through the
init_sequence[] array of function pointers.
The first board dependent function inside the init_sequence[] array is
board_early_init_f(). board_early_init_f() is implemented inside board/freescale/
mx6<custom board name>.c.
The following line of code is most important:
...
setup_iomux_uart();
...
NOTE
If a device tree is used, the machine ID is not used. The
compatible string of the DTS file is used to match the board.
The device tree for file each boot variation is specified in the
machine configuration files in the meta-fsl-arm/conf/machine
directory.
To customize the brute force way, delete identify_board_id( ) inside checkboard() and
replace printf("Board: "); with printf("Board: i.MX 6 on <custom board>\n");
If this replacement is not made, the custom board may use another identification method.
The identification can be detected and printed by implementing the
__print_board_info() function according to the identification method on the custom
board.
1.4 Debugging
There are two ways for debugging:
• Use Realview ICE.
• Use printf.
usdhc@0219c000 { /* uSDHC4 */
fsl,card-wired;
vmmc-supply = <®_3p3v>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc4_1>;
};
iomuxc@020e0000 {
compatible = "fsl,imx6q-iomuxc";
reg = <0x020e0000 0x4000>;
After enabling the UART driver, build the Linux kernel and boot the board.
Table below lists the UART files that are available on the directory <linux source code
directory>/arch/arm/plat-mxc/include/mach/
Table 3-2. Available Files-Second Set
File Description
imx_uart.h UART header containing UART configuration and data structures
usdhc@02194000 { /* uSDHC2 */
compatible = "fsl,imx6q-usdhc";
reg = <0x02194000 0x4000>;
arch/arm/boot/dts/imx6qdl-sabresd.dtsi
Support of SD3.0
SD3.0 requires 3.3V and 1.8V for signal voltage. Voltage selection needs to be
implemented on your platform.
Support of SDIO
In most cases, SDIO requires more power than SD/MMC memory cards. Make sure that
the power supply is in the SD slot while using SDIO, or apply an external power to SDIO
instead.
Since the size is only 4 MB, we do not implement partitions for the SPI NOR.
located at
drivers/mtd/devices/m25p80.c
ecspi1 {
pinctrl_ecspi1_1: ecspi1grp-1 {
fsl,pins = <
MX6Q_PAD_EIM_D17__ECSPI1_MISO 0x100b1
MX6Q_PAD_EIM_D18__ECSPI1_MOSI 0x100b1
MX6Q_PAD_EIM_D16__ECSPI1_SCLK 0x100b1
>;
};
pinctrl_ecspi1_2: ecspi1cr-1 {
fsl,pins = <
MX6Q_PAD_KEY_COL1__ECSPI1_MISO 0x100b1
MX6Q_PAD_KEY_ROW0__ECSPI1_MOSI 0x100b1
MX6Q_PAD_KEY_COL0__ECSPI1_SCLK 0x100b1
>;
};
};
2. Enable the SPI. For example:
ecspi@02008000 { /* eCSPI1 */
fsl,spi-num-chipselects = <1>;
cs-gpios = <&gpio3 19 0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1_1 &pinctrl_ecspi1_sabreauto>;
status = "okay"; /* pin conflict with WEIM NOR */
flash: m25p80@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,m25p32";
spi-max-frequency = <20000000>;
reg = <0>;
};
};
The memory is organized in pages of 512 bytes or 528 bytes. SPI NOR Flash also
contains two SRAM buffers of 512/528 bytes each, which allows data reception while a
page in the main memory is being reprogrammed. It also allows the writing of a
continuous data stream.
Unlike conventional Flash memories that are accessed randomly, the SPI NOR Flash
accesses data sequentially. It operates from a single 2.7-3.6 V power supply for program
and read operations.
SPI NOR Flashes are enabled through a chip select pin and accessed through a three-wire
interface: serial input, serial output, and serial clock.
The MTD subsystem for Linux is a generic interface to memory devices such as Flash
and RAM which provides simple read, write, and erase access to physical memory
devices. Devices called mtdblock devices can be mounted by JFFS, JFFS2, and
CRAMFS file systems. The SPI NOR MTD driver is based on the MTD data Flash driver
in the kernel by adding SPI accesses.
In the initialization phase, the SPI NOR MTD driver detects a data Flash by reading the
JEDEC ID. The driver then adds the MTD device. The SPI NOR MTD driver also
provides the interfaces to read, write, erase NOR Flash.
The kernel command line for 18-bit LVDS panels (3 pairs of LVDS data signals) displays
the following lines if the panel is properly connected:
LVDS0 and LVDS1 on the board: video=mxcfb0:dev=ldb,LDB-XGA,if=RGB666
video=mxcfb1:dev=ldb,LDB-XGA,if=RGB666 ldb=sep0
Therefore, only the CMOS-dependent layer needs to be modified to include a new CMOS
sensor. All other layers have been developed to work with V4L2.
CSI0 is used as a parallel sensor input interface. CSI1 is used as a MIPI sensor input
interface.
When CSI is in test mode, configure the CSI unit with a similar configuration to the
described settings in the following table. Call ipu_csi_init_interface() to configure the
CSI interface protocol, formats, and features.
Table 7-1. Settings for Test Mode
Bit Field Value Description
CSI0_DATA_DEST 0x4 Destination is IDMAC via SMFC
CSI0_DIV_RATIO 0x0 SENSB_MCLK rate = HSP_CLK rate
CSI0_EXT_VSYNC 0x1 External VSYNC mode
CSI0_DATA_WIDTH 0x1 8 bits per color
CSI0_SENS_DATA_FORMAT 0x0 Full RGB or YUV444
CSI0_PACK_TIGHT 0x0 Each component is written as a 16 bit word where the MSB is written to
bit #15. Color extension is done for the remaining least significant bits.
CSI0_SENS_PRTCL 0x1 Non-gated clock sensor timing/data mode.
CSI0_SENS_PIX_CLK_POL 0x1 Pixel clock is inverted before applied to internal circuitry.
CSI0_DATA_POL 0x0 Data lines are directly applied to internal circuitry.
CSI0_HSYNC_POL 0x0 HSYNC is directly applied to internal circuitry.
CSI0_VSYNC_POL 0x0 VSYNC is directly applied to internal circuitry.
To add a new camera sensor entry on the Kconfig camera file, perform the following
steps:
1. Enter the following command into the display specific folder:
$ cd linux/drivers/media/video/mxc/capture
2. Open the Kconfig file:
$ gedit Kconfig &
3. Add the entry where you want it to appear:
config MXC_IPUV3_CSI0_TEST_MODE
tristate "IPUv3 CSI0 test mode camera support"
depends on !VIDEO_MXC_EMMA_CAMERA
---help---
If you plan to use the IPUv3 CSI0 in test mode with your MXC
system, say Y here.
NOTE
Before connecting a camera sensor to the i.MX 6Dual/6Quad/
6Solo/6DualLite board, you must check whether the sensor is
powered with the proper supply voltages and whether the
sensor data interface has the correct VIO value. Power supply
mismatches can damage either the CMOS or the i.MX 6Dual/
6Quad/6Solo/6DualLite.
Create a file with the required panel-specific functions in the following path:
linux/drivers/media/video/mxc/capture/
After the functions have been created, you need to add additional information to
ipuv3_csi0_chess_slave and ipuv3_csi0_chess_int_device. The device uses this
information to register as a V4L2 device.
i.MX 6 BSP Porting Guide, Rev. L3.10.17_1.0.0-ga, 05/2014
Freescale Semiconductor, Inc. 35
Adding Support for a New CMOS Camera Sensor
It is also necessary to modify other files to prepare the BSP for CSI test mode. Change
the sensor pixel format from YUV to RGB565 in the ipu_bg_overlay_sdc.c file so that
the image converter will not perform color space conversion and the input received from
the CSI test mode generator will be sent directly to the memory. Additionally, modify
mxc_v4l2_capture.c to preserve CSI test mode settings which are set by the
ipuv3_csi0_chess_init_mode() function in the ipuv3_csi0_chess.c file.
$ cd linux/drivers/media/video/mxc/capture
2. Open the i.MX 6Dual/6Quad/6Solo/6DualLite camera support Makefile.
ipuv3_csi0_chess_camera-objs := ipuv3_csi0_chess.o
obj-$(CONFIG_MXC_IPUV3_CSI0_TEST_MODE) += ipuv3_csi0_chess_camera.o
The kernel object is created by using the ipuv3_csi0_chess.c file. You should have the
following files as output:
• ipuv3_csi0_chess_camera.mod.c
• ipuv3_csi0_chess.o
• ipuv3_csi0_chess_camera.o
• ipuv3_csi0_chess_camera.mod.o
• ipuv3_csi0_chess_camera.ko
MODULE_DEVICE_TABLE(i2c, mycamera_id);
*val = u8RdVal;
return u8RdVal;
}
module_init(mycamera_init);
module_exit(mycamera_clean);
To test the video0 input (camera), an mxc_v4l2_overlay test is included in the BSP. If the
imx-test package has also been included, open the unit test folder and execute the test.
root@freescale ~$ cd /unit_tests/
root@freescale /unit_tests$ ./mxc_v4l2_overlay.out
Several sensors can be connected to each of the CSIs. Simultaneous functionality (for
sending data) is supported as follows:
• Two sensors can send data independently, each through a different port.
• One stream can be transferred to the VDI or IC for on-the-fly processing while the
other one is sent directly to system memory.
The input rate supported by the camera port is as follows:
• Peak: up to 180 MHz (values/sec).
• Average (assuming 35% blanking overhead) for YUV 4:2:2.
• Pixel in one cycle (BT.1120): up to 135 MP/sec, such as 9 Mpixels at 15 fps.
• Pixel on two cycles (BT.656): up to 67 MP/sec, such as 4.5 Mpixels at 15 fps.
• On-the-fly processing may be restricted to a lower input rate.
If required, additional cameras can be connected though the USB port.
The CSI parallel interface (shown in figure below) provides a clock output (MCLK),
which is used by the sensor as a clock input reference. The i.MX 6Dual/6Quad/6Solo/
6DualLite requests either video or still images through a different interface between the
processor and the camera module. In most cases, the interface is a synchronous serial
interface such as the I2C. After the frame has been requested, the camera module takes
control of the CSI bus, and uses synchronization signals VSYNC, HSYNC, DATA_EN
and PIXCLK to send the image frame to the i.MX 6Dual/6Quad/6Solo/6DualLite. The
camera sensor creates PIXCLK based on MCLK input.
In parallel interface, a single value arrives in each clock, except in BT.1120 mode when
two values arrive per cycle. Each value can be 8-16 bits wide according to the
configuration of DATA_WIDTH. If DATA_WIDTH is configured to N, then 20-N LSB
bits are ignored.
Therefore, you never need CSI0_DAT[3:0], unless you are using BT.1120 mode, because
the maximum pixel width is 16 (CSI0_DAT[19:4]). The expansion port 2 includes
CSI0_DAT[19:4], but only CSI0_DAT[19:10] are used for the CSI data bus (10-bit wide
data). CSI0_DAT[9:4] are shared with other interfaces and are used for audio and I2C.
CSI can support several data formats according to SENS_DATA_FORMAT
configuration. When the data format is YUV, the output of the CSI is always YUV444-
even if the data arrives in YUV422 format.
The polarity of the inputs can be configured using the following registers:
• SENS_PIX_CLK_POL
• DATA_POL
• HSYNC_POL
• VSYNC_POL
The following table describes the camera parallel interface provided by the i.MX 6Dual/
6Quad/6Solo/6DualLite:
Table 7-3. CSI0 Parallel Interface Signals
Signal IPU Pin Description
MCLK CSI0_MCLK Master Clock (Output)
PIXCLK CSI0_PIXCLK Pixel Clock
VSYNC CSI0_VSYNC Vertical Synchronization signal
HSYNC CSI0_HSYNC Horizontal Synchronization signal
DATA_EN CSI0_DATA_EN Data Enable or Data ready
DATA[19:10] CSI0_DAT [19:10] Pixel data bus, optional to [19:4]
Timing Data Mode Protocols, explains how the timing data mode protocols use these
signals. Not all signals are used in each timing data mode protocol.
For details, refer to the i.MX 6Dual/6Quad Applications Processor Reference Manual or
the i.MX 6Solo/6DualLite Applications Processor Reference Manual.
audio-routing =
"Headphone Jack", "HPOUTL",
"Headphone Jack", "HPOUTR",
"Ext Spk", "SPKOUTL",
"Ext Spk", "SPKOUTR",
"MICBIAS", "AMIC",
"IN3R", "MICBIAS",
"DMIC", "MICBIAS",
"DMICDAT", "DMIC";
mux-int-port = <2>;
mux-ext-port = <3>;
hp-det-gpios = <&gpio7 8 1>; /*active low*/
mic-det-gpios = <&gpio1 9 1>; /*active low*/
};
NOTE
The specific meaning of the device tree binding can be checked
up in binding doc located in Documentation/devicetree/
bindings/sound/.
NOTE
If using a different codec, adapt the driver architecture shown in
table above accordingly. The exact adaptation will depend on
the codec chosen. Obtain the codec-specific software from the
codec vendor.
Because i.MX 6 has more functionality than it has physical I/O pins, it uses I/O pin
multiplexing.
Every module requires specific pad settings. For each pad there are up to eight muxing
options called ALT modes. For further explanation, refer to IOMUX chapter in the i.MX
6Dual/6Quad/6Solo/6DualLite/6SoloLite Multimedia Applications Processor Reference
Manual.
Please note in designs with an external Ethernet PHY may require an external pin
configured as a simple GPIO to reset the Ethernet PHY before enabling physical clock.
Otherwise, some PHYs will fail to work correctly.
The following signals, needed to set with proper IOMUX, are multiplexed with other
pins.
NOTE
For the USBOTG_ID pin, a pin which has an alternate
USBOTG_ID function must be used.
• USBOTG_ID
• USBOTG_OC_B
• one pin used to control USB_OTG_VBUS signal
For USB H1 port, the following signals are used:
• USB_H1_VBUS
• USB_H1_DN
• USB_H1_DP
• USBH_OC_B
The following signals are multiplexed with other pins, and need to set with proper
IOMUX:
• USBH_OC_B
For USB HSIC 1/2 port, the following signals are used:
• H2_STROBE
• H3_STROBE
• H2_DATA
• H3_DATA
The following signals are multiplexed with other pins, and need to set with proper
IOMUX:
• H2_STROBE
• H3_STROBE
• H2_DATA
• H3_DATA
To secure HSIC connection, the USB HSIC port must be powered up before the USB
HSIC device
For i. MX 6SoloLite, there is only one HSIC port, so only H2_xxx signals are used.
• USB_OTG2_DP
• USBOTG2_OC_B
The following signals are multiplexed with other pins, and need to set with proper
IOMUX:
• USBOTG2_OC_B
For USB HSIC 1 port, the following signals are used:
• H2_STROBE
• H2_DATA
The following signals are multiplexed with other pins, and need to set with proper
IOMUX:
• H2_STROBE
• H2_DATA
To secure HSIC connection, the USB HSIC port must be powered up before the USB
HSIC device
Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.,
Reg. U.S. Pat. & Tm. Off. All other product or service names are the property of their
respective owners. ARM and ARM Cortex-A9 are registered trademarks of ARM
Limited.
© 2014 Freescale Semiconductor, Inc.