Author Information
Author: Pengdonglin
Email: [email protected]
qq:405728433
Platform Introduction
Development Board: TINY4412ADK + S700 + 4GB Flash
Kernel version to port: Linux-4.4.0 (Support device tree)
U-boot version: Friendly arm comes with U-boot 2010.12 (for support uimage boot, made a little change)
BusyBox version: BusyBox 1.25
Cross-compilation Toolchain: ARM-NONE-LINUX-GNUEABI-GCC
(gcc version 4.8.3 20140320 (prerelease) (Sourcery codebench Lite 2014.05-29))
Summary
The last blog post on the tiny4412 of the MMA7660 driver, using the exynos4412 comes with the I²C hardware controller, I would like to say is to use the software to simulate an I²C controller, with the original two Gpio pin, This is not the case with the two Gpio function multiplexing or GPIO functionality. For this section refer to: http://www.cnblogs.com/pengdonglin137/p/4623169.html
porting
The Linux kernel drive layered design benefits, we only need to modify the driver part of the I²C controller, MMA7660 driver part of the completely no need to change, and the Linux kernel has been the software analog I²C Controller code implementation: drivers/i2c/ BUSSES/I2C-GPIO.C, we need to do only the configuration of the device tree, in the Arch/arm/boot/dts/exynos4412-tiny4412.dts to add software i²c hardware information, you can refer to: documentation/ Devicetree/bindings/i2c/i2c-gpio.txt:
1: i2c_mma7660:i2c-gpio-0 {
2: "I2c-gpio";
3: Gpios = <&gpa1 2 gpio_active_high>,/ * SDA * /
4: <&gpa1 3 gpio_active_high>; / * SCL * /
5: / * i2c-gpio,sda-open-drain; * /
6: / * i2c-gpio,scl-open-drain; * /
7: i2c-gpio,delay-us = <2>; / * + kHz * /
8: #address-cells = <1>;
9: #size-cells = <0>;
Ten: "Okay";
11:
: [Email protected] {
: "freescale,mma7660";
: reg = <0x4c>;
: interrupt-parent = <&gpx3>;
: interrupts = <1 2>;
: poll_interval = <100>;
: input_fuzz = <4>;
: Input_flat = <4>;
: "Okay";
: };
: };
Among the things to be concerned about:
The 3rd line represents the Gpio pin that implements the SDA signal;
The 4th line represents the Gpio pin that implements the SCL signal;
The 7th line is used to control the frequency of the SCL;
第12-20 line or MMA7660 hardware information, the same as the previous article, no change at all;
The following is an approximate sequence diagram of SDA and SCL:
you can see that the value I set for Udelay is 2, so the period is 4, the unit is microseconds, so the frequency is roughly 250KHz or so, MMA7660 's chip manual said that the communication rate of the maximum is 400KHz, less than this can be:
This part of the code I've uploaded to GitHub:
git clone https://github.com/pengdonglin137/linux-4.4_tiny4412.git-b port_to_tiny4412
You need to execute make menuconfig, set Config_mma7660_use_i2c_gpio to Y, and then do Dtbs.
Test
1:
2: GPIOs 0-7, Platform/11400000.pinctrl, gpa0:
3:
4: GPIOs 8-13, Platform/11400000.pinctrl, GPA1:
5: gpio-10 ( |sda in hi
6: gpio-11 ( |scl in hi
- Read the value of the MMA7660 register
1: [[email protected]]# cd/sys/bus/i2c/drivers/mma7660/9-004c/
2: [[email protected] 9-004c]# ls
3: all_axis_g input of_node subsystem x_axis_g
4: driver modalias power tilt_status Y_axis_g
5: hwmon name registers uevent z_axis_g
6:
7: 3, 0, 22
8:
9: reg:0x00 = 0x02 ... [0000 0010]
Ten: reg:0x01 = 0x00 ... [0000 0000]
One : reg:0x02 = 0x17 ... [0001 0111]
: reg:0x03 = 0x01 ... [0000 0001]
: reg:0x04 = 0x02 ... [0000 0010]
: reg:0x05 = 0xa0 ... [1010 0000]
: reg:0x06 = 0xe7 ... [1110 0111]
: reg:0x07 = 0x59 ... [0101 1001]
: reg:0x08 = 0x49 ... [0100 1001]
: reg:0x09 = 0x04 ... [0000 0100]
: reg:0x0a = 0x0f ... [0000 1111]
- View MMA7660 Escalation Events
1:
2: 0000000 00b6 0000 f0a8 000d 0003 0002 0016 0000
3: 0000010 00b6 0000 f0a8 000d 0000 0000 0000 0000
4: 0000020 00b7 0000 b77c 0001 0003 0000 0002 0000
5: 0000030 00b7 0000 b77c 0001 0000 0000 0000 0000
6: 0000040 00b9 0000 3125 0000 0003 0000 0004 0000
7: 0000050 00b9 0000 3125 0000 0003 0002 0015 0000
8: 0000060 00b9 0000 3125 0000 0000 0000 0000 0000
9: 0000070 00b9 0000 df77 000a 0003 0000 0003 0000
: 0000080 00b9 0000 df77 000a 0000 0000 0000 0000
One : 0000090 00b9 0000 ec9b 000d 0003 0000 0002 0000
: 00000a0 00b9 0000 ec9b 000d 0000 0000 0000 0000
: 00000b0 00ba 0000 3148 0000 0003 0000 0001 0000
: 00000c0 00ba 0000 3148 0000 0000 0000 0000 0000
: 00000d0 00ba 0000 58af 0009 0003 0002 0014 0000
: 00000e0 00ba 0000 58af 0009 0000 0000 0000 0000
To be Continued ...
TINY4412-based Linux kernel porting-MMA7660 drive porting (nine-2)