1. Home
  2. Software Development for MediaTek X20
  3. Sensor Porting Guide
  4. 3.Driver Customization

3.Driver Customization

3.1 Config codegen.dws

Config the codegen.dws with DCT tool:

(1)Run the drvgen.exe and open the codegen.dws file

  • Drvgen.exe path:

– alps\kernel-3.18\tools\dct\DrvGen.exe

  • amt6797_64_open.dws path:

alps\kernel-3.18\drivers\misc\mediatek\dws\$(platform)\$(proj)\amt6797_64_open.dws

(2)config i2c bus and address

sensor3

(3) exit and save the amt6797_64_open.dws

(4) Change the name to  codegen.dws and copy to the follow path:

lk:

alps\vendor\mediatek\proprietary\bootable\bootloader\lk\target\$(proj)\dct\dct\codegen.dws

(5)If the sensor have used EINT like alsps, it must config gpio and eint.

if the sensor do not use EINT, please ignore this step.

sensor4

sensor5

(6)exit and save the codegen.dws

(7) Change the name to  codegen.dws and copy to the follow path:

gen.dws

lk:

alps\vendor\mediatek\proprietary\bootable\bootloader\lk\target\$(proj)\dct\dct\codegen.dws

3.2 Driver Customization-parameters

3.2.1 Accelerometer parameters customization

a、 Config the parameters in the path:

alps\kernel-3.18\arch\armxx\boot\dts\$(proj).dts

sensor6

Note:

If the project is 32bits, armxx is arm.

If the project is 64bits, armxx is arm64.

b、Accelerometer parameters description:

compatible :Identification for driver

i2c_num   :i2c channel ,depend on hardware

direction   :Sensor layout direction

power_id   :LDO id which the sensor has used

power_vol  :LDO voltage which the sensor hse used

is_batch_supported  :support batch mode or not

3.2.2 notice

Mapping coordinate(accelerometer, gyroscope, magnetometer)

sensor7

sensor8

3.2.3 Gyroscope parameters customization

a、Config the parameters in the path:

alps\kernel-3.18\arch\armxx\boot\dts\$(proj).dts

sensor9

Note:

If the project is 32bits, armxx is arm.

If the project is 64bits, armxx is arm64.

b、Gyroscope parameter description:

compatible         :Identification for driver

i2c_num             :i2c channel ,depend on hardware

direction             :Mapping the coordinate

power_id             : LDO id which the sensor has used

power_vol           : LDO voltage which the sensor hse used

firlen Data          :filter length, usually, it is set with 0

is_batch_supported :gyro support batch mode or not

3.2.4 Magnetometer parameters customization

a、alps\kernel-3.18\arch\armxx\boot\dts\$(proj).dts

sensor10

Note:

If the project is 32bits, armxx is arm.

If the project is 64bits, armxx is arm64.

b、Magnetometer parameter description:

compatible         :Identification for driver

i2c_num             :i2c channel ,depend on hardware

Direction             : Sensor layout direction

power_id             : LDO id which the sensor has used

power_vol           : LDO voltage which the sensor hse used

is_batch_supported :support batch mode or not

3.2.5 Alsps parameter description

a、Config the parameters with Device Tree

The customization file is :

alps\kernel-3.18\arch\armxx\boot\dts\$(project).dts

sensor11

Note:

  • If the project is 32bits, armxx is arm.
  • If the project is 64bits, armxx is arm64.

b、Alsps parameter description

Compatible                : Identification for driver

i2c_num                    :i2c channel ,depend on hardware

polling_mode_ps 0    :interrupt mode,1:polling mode

polling_mode_als 0   :interrupt mode,1:polling mode

power_id                    : LDO id which the sensor has used

power_vol                  : LDO voltage which the sensor hse used

als_level                            : The als data mapping table:

als_value                 : als_level–>als_value

ps_threshold_high     : ps_data > ps_threshold_high : close

ps_threshold_low       : ps_data < ps_threshold_low : far away

is_batch_supported_ps  : ps support batch mode or not

is_batch_supported_als   :als support batch mode or not

3.2.6 Driver Customization-gpio

Config the pin function  with Device Tree

sensor12

Was this article helpful to you? Yes No 1

How can we help?