This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MaxTouch mxt224e i2c touchscreen on AM335x-evm

Hi,

I'm looking for the right way to use Atmel MaxTouch mxt224e i2c touchscreen on AM335x-evm board running Android ICS. I'm focused on the touchscreen driver and how to integrate it into Linux kernel.

MaxTouch's driver is already present (as atmel_mxt_ts.c) into TI's ICS porting and I have a good understanding on how it works. What I'm looking now is the driver initialization. After some researches I've understand that board's initialization is done into board_am335xevm.c file, and I suppose this is the place where I should start editing in order to initialize the touchscreen driver.
Based on this blog post and on Linux's i2c documentation, initialization there is done using an i2c_board_info struct like this:

static struct i2c_board_info atmel_i2c_devices[] = {
{
    I2C_BOARD_INFO("mXT224", 0x4A),
    .irq = xx, /* IRQ number */
    },
};

And then registering the device using i2c_register_board_info() function like this:

i2c_register_board_info(0, atmel_i2c_devices, ARRAY_SIZE(atmel_i2c_devices));

What I'm missing is where to use i2c_register_board_info() function. Can someone point me to specific documentation?

Thanks,

Francesco

  • Hi,

    You can start with looking at am335x_evm_i2c_init() in board-am335xevm.c. You have to check on which instance of i2c Touchscreen is supported and add TSC details accordingly.

    Regards,

    Rachna

  • Hi,

    ok, thanks, this is exactly the place where I was looking.

    So in am335x_evm_i2c_init() I should use omap_register_i2c_bus() function on the correct bus number, adding the device as an i2c_board_info struct array.

    Thanks,
    Francesco

  • Hi all,

    I have a custom board based on am335x and having mxt224 touchscreen controller and touchpanel. I have enabled mxt224 support in kernel and it is successfully initiated on bootup. My problem is that mxt224 sends interrupt to host processor (am335x) every 200 ms and it puts the "Invalid Message" (0xFF according to datasheet) on i2c bus. I have updated the mxt224 driver an i am using atmel mxt-app to test the device (https://github.com/atmel-maxtouch/). I2C connection with device is OK, but it cannot detects anything on touchpanel, just sends Invalid Message every 200 ms. Is there anybody who is achieved to run this device? or any comment for this issue? Is there any extra job except for platform data in board file? I have no change in mxt224 driver.

    Thanks,

  • Hi Kadir,

    I'm sorry to bother you, but I encountered the same your problem: how did you solve it?

    Any advice would be appreciated because this problem is blocking my project.

    Thank you in advance

  • Hi Kadir and Igor, I'm trying to make mxt224 work without success, have you succeeded?, how?.

    This is what i do in board-am335xevm.c:

    # include <linux/i2c/atmel_mxt_ts.h>
    
    static u8 mxt_init_vals[] = { 0x00,0x00 ... };
    
    static struct mxt_platform_data mxt_platform_data = {
    .config = mxt_init_vals,
    .config_length = ARRAY_SIZE(mxt_init_vals),
    ...
    
    .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
    };
    
    static struct pinmux_config mxt224_pin_mux[] = {
    {"mcasp0_aclkr.gpio3_18", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
    {NULL, 0},
    };
    static void mxt224_tsp_init(int evm_id, int profile)
    {
    setup_pin_mux(mxt224_pin_mux);
    return;
    }
    
    static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
    
    ...
    
    {mxt224_tsp_init ,DEV_ON_BASEBOARD,PROFILE_NONE},
    {sgx_init ,DEV_ON_BASEBOARD,PROFILE_NONE},
    {NULL ,0 ,0 },
    };
    
    static struct i2c_board_info __initdata am335x_i2c0_boardinfo[] = {
    {
    I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
    .platform_data = &mxt_platform_data,
    .irq = OMAP_GPIO_IRQ(GPIO_TO_PIN(3, 18)),
    },
    
    ...
    
    };

    --

    The device is successfully detected but it has wrong parameters, X and Y sizes are not what I config in mxt_init_vals.

    [ 2.819000] atmel_mxt_ts 1-004a: Invalid object type
    [ 2.946166] atmel_mxt_ts 1-004a: Family ID: xxx Variant ID: x Version: xxx Build: xxx (IDs hidden)
    [ 2.954406] atmel_mxt_ts 1-004a: Matrix X Size: 16 Matrix Y Size: 14 Object Num: 16
    [ 2.967041] input: Atmel maXTouch Touchscreen as /devices/platform/omap/omap_i2c.1/i2c-1/1-004a/input/input0

    A new device is found in /dev/input/touchscreen0, but I can't see anything on it using 'cat'.

    Do you use mxt_init_vals?, how do you configure it?, do you have a firmware file?

    What am I doing wrong?

    Thank you in advance

  • Hi FordFairlane, 

    Sorry for late response, i was out of office for a while.

    Your error "Invalid object type" says that given init values and registers in the device not matched. You should give the correct register numbers and values in order to the device. Could you send me your driver code?

    This entry "/dev/input/touchscreen0" is created whenever a touchscreen input device is created in kernel. Entry is created but device under used is not configured due to some init failures. That's why you cant see anything under sysfs.

    Default mxt224 driver, detects the device version and reads the register table in device. Then, it assigns your values (mxt_init_values in your board file) to related registers in device. Therefore, you must give values and register numbers in your structure correctly. Otherwise, driver returns error.

    Is your device mxt224 or mxt224E ? 

  • Hi kadir yasar,

    I'm using ti-sdk-am335x-evm-06.00.00.00 which includes linux-3.2.0-psp04.06.00.11. I haven't modified /drivers/input/touchscreen/atmel_mxt_ts.c, you can find it here: lxr.free-electrons.com/source/drivers/input/touchscreen/atmel_mxt_ts.c?v=3.2;a=arm

    Should I update this driver to the latest mainlined? http://lxr.free-electrons.com/source/drivers/input/touchscreen/atmel_mxt_ts.c?a=arm

    Should I update this driver to the latest from github? https://github.com/atmel-maxtouch/linux/blob/maxtouch-v3.0/drivers/input/touchscreen/atmel_mxt_ts.c

    My device is mXT224E, but Atmel told me it is mXT224 and I have its protocol guide (released under NDA). I think the problem is I have docs and config for mXT224 and Atmel sent me mXT224E devices. I've been playing with obp-utils and I read objects from device not defined in my mXT224 protocol guide.

    Could you tell me which docs and files Atmel sent to you?, did you receive a config file for your touchscreen?, an OBP_RAW V1 config file?, a firmware file?, any application note?, any else?, did you modify objects for your touchscreen?, is there any computer software for mXT224?. Atmel touchscreens seem to be top secret!.

    I'd like to post more info about my device but Atmel releases it under NDA and I'm no allowed to do it.

    Thank you

  • Hi,

    Yes, you should update your driver with atmel's latest from github, we also did it.

    You are right. Your device is probably mxt224e but Atmel sends mxt224 documents not having enough info about device registers and values that registers should have. Atmel didnt send any config to us. We created our config according to ds under NDA. I sent you our config file for mxt224E. obp-utils is right tool to investigate your device, change register or object values.

    New driver runs like this: driver looks for mxt224e.cfg file on driver init(), you must locate your config file under firmaware/ directory in your kernel tree. Each line starts with object number and then values for relevant object. Be careful for T9, it consists most important configuration settings for sensing. And also, board file must be comply with new driver. In platform_data, you must only give the name of configuration file (cfg_name = mxt224e.cfg located under firmware/) in board file.

    these are your instructions:

    • Update your driver with latest in github
    • Customize and locate your mxt224e.cfg file under firmware/ dir.
    • Update your board file, compatible with new driver in platform_data
    • Compile and test it, then let me know the result :)

    7711.mxt224e.cfg

  • Thank you very much, I'm going to try it but I think it is not going to work because your config file does not have the same objects than mine, it is not the same firmware version although it is the same family and variant.

    81 01 10 AA 10 0E 12 is yours
    81 01 20 AB 10 0E 10 is mine
    (Family Variant Version Build X Y #Objects)

    T37-T44-T5-T6-T38-T7-T8-T9-----T18-T19-----T25-----T42-T46-T47-T48-T55- Your objects
    T37-T44-T5-T6-T38-T7-T8-T9-T15-T18-T19-T23-T25-T40-T42-T46-T47-T48----- My Objects

    I'll have to wait for a new protocol guide for my device under NDA from Atmel because I don't know most objects' format.

    Best regards

  • You are probably right, you can use obp-utils tool to investigate your device; get the list of all objects in your device and then customize the mxt224e.cfg file according to output. Actually, i helped you to setup the infrastructure of new driver. You just need to customize config file.

  • Hi kadir yasar

    1.- atmel_mxt_ts.c and atmel_mxt_ts.h are updated  from github.com/atmel-maxtouch/linux.

    2.- config read from chip using obp-utils is saved as linux/firmware/mXT224E.cfg

    3.- board file:
    3.1.- remove mxt_init_vals
    3.2.- modify mxt_platform_data:

    static struct mxt_platform_data mxt_platform_data = {
    	/*unsigned long 		*/.irqflags		= IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
    	/*u8 					*/.t19_num_keys	= 0,
    	/*const unsigned int *	*/.t19_keymap	= NULL,
    	/*int 					*/.t15_num_keys	= 0,
    	/*const unsigned int *	*/.t15_keymap	= NULL,
    	/*unsigned long 		*/.gpio_reset	= GPIO_TO_PIN(1, 27),
    	/*const char *			*/.cfg_name		= "mxt224e.cfg",
    };

    3.3.- add reset pin to pin mux:

    /* Module pin mux for mxt224E Atmel MaxTouch*/
    static struct pinmux_config mxt224_pin_mux[] = {
    {"mcasp0_aclkr.gpio3_18", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
    {"gpmc_a11.gpio1_27" , OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP | AM33XX_SLEWCTRL_SLOW | AM33XX_INPUT_EN},
    {NULL, 0},
    };
    

    3.4.- Add reset to mxt224 init (reset keeps high without this, but goes low twice with this)

    static void mxt224_tsp_init(int evm_id, int profile)
    {
    	setup_pin_mux(mxt224_pin_mux);
    	{
    		int status = gpio_request(mxt_platform_data.gpio_reset,	"mxt224_reset\n");
    		if (status < 0)
    			pr_err("Failed to request gpio for mxt_platform_data.gpio_reset");
    		gpio_direction_output(mxt_platform_data.gpio_reset, 0);
    		msleep(1);
    		gpio_direction_output(mxt_platform_data.gpio_reset, 1);
    		msleep(25);
    	}
    	return;
    }

    3.5.- i2c0 board info keeps unchanged, here is configured mxt224 irq pin:

    static struct i2c_board_info __initdata am335x_i2c0_boardinfo[] = {
    {
    I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
    .platform_data = &mxt_platform_data,
    .irq = OMAP_GPIO_IRQ(GPIO_TO_PIN(3, 18)),
    },
    
    ...
    
    };

    4.- Recompile linux

    RESULT:

    mXT224R does not work, and it causes a long delay when booting:

    [ 2.781951] mousedev: PS/2 mouse device common for all mice
    [ 2.789428] _regulator_get: 1-004a supply vdd not found, using dummy regulator
    [ 2.797332] _regulator_get: 1-004a supply avdd not found, using dummy regulator
    [ 3.115264] atmel_mxt_ts 1-004a: Wait for completion timed out.
    [ 3.133514] atmel_mxt_ts 1-004a: Family: 129 Variant: 1 Firmware V2.0.AB Objects: 16
    [ 3.142425] atmel_mxt_ts 1-004a: Enabling RETRIGEN workaround
    [ 3.164672] atmel_mxt_ts 1-004a: T7 cfg zero, resetting
    [ 3.170257] atmel_mxt_ts 1-004a: Resetting chip
    [ 3.778350] gadget: high-speed config #1: CDC Ethernet (ECM)
    [ 6.175231] atmel_mxt_ts 1-004a: Wait for completion timed out.
    [ 67.205871] atmel_mxt_ts 1-004a: Failure to request config file mXT224E.cfg
    [ 67.215270] atmel_mxt_ts 1-004a: Touchscreen size X799Y479
    [ 67.222076] input: Atmel maXTouch Touchscreen as /devices/platform/omap/omap_i2c.1/i2c-1/1-004a/input/input0
    [ 67.235107] omap_rtc am33xx-rtc: rtc core: registered am33xx-rtc as rtc0
    

    With mxt-app from obp-utils:

    * Display the input (E)vents from the device:

    Opening /dev/input/event2...
    Error opening /dev/input/event2
    

    * Display raw (M)essages: (no messages)

    * (C)alibrate the maxtouch device: 

    Send calibration command
    Successfully performed a global recalibration on all channels

    * Enter 1 for running Analog power test

    Enabling self test object
    Disabling noise suppression
    T22 does not exist
    T54 does not exist
    T62 does not exist
    TOUCH_MULTITOUCHSCREEN_T9[0] disabled
      UPSIGLIM:0
      LOSIGLIM:0
    Running tests
    Timeout
    

    What am I doing wrong?, could you help me once again?

  • Hi kadir yasar

    mxt224e.cfg is not found because it is not installed in root filesystem and is not compiled in the kernel. I have modified kernel .config (CONFIG_EXTRA_FIRMWARE="am335x-pm-firmware.bin mxt224e.cfg") to include this file in kernel binary and now it finds and loads it. Now there is no long delay (I think it was 60s firmware load timeout).

    [ 2.746459] mousedev: PS/2 mouse device common for all mice
    [ 2.753845] _regulator_get: 1-004a supply vdd not found, using dummy regulator
    [ 2.761749] _regulator_get: 1-004a supply avdd not found, using dummy regulator
    [ 3.075286] atmel_mxt_ts 1-004a: Wait for completion timed out.
    [ 3.093536] atmel_mxt_ts 1-004a: Family: 129 Variant: 1 Firmware V2.0.AB Objects: 16
    [ 3.102447] atmel_mxt_ts 1-004a: Enabling RETRIGEN workaround
    [ 3.124725] atmel_mxt_ts 1-004a: T7 cfg zero, resetting
    [ 3.130310] atmel_mxt_ts 1-004a: Resetting chip
    [ 3.719085] gadget: high-speed config #1: CDC Ethernet (ECM)
    [ 6.135284] atmel_mxt_ts 1-004a: Wait for completion timed out.
    [ 6.152343] MXT MSG:0d 00 00 00 00 00 00 00
    [ 6.152374] MXT MSG:0f 00 00 00 00 00 00 00
    [ 6.154235] atmel_mxt_ts 1-004a: Interrupt triggered but zero messages
    [ 6.166076] atmel_mxt_ts 1-004a: CRC zero, attempting to apply config
    [ 6.236755] atmel_mxt_ts 1-004a: Enabling RETRIGEN workaround
    [ 6.242889] atmel_mxt_ts 1-004a: Resetting chip
    [ 6.288177] atmel_mxt_ts 1-004a: Interrupt triggered but zero messages
    [ 6.467895] atmel_mxt_ts 1-004a: Config written
    [ 6.473510] atmel_mxt_ts 1-004a: Initialised power cfg: ACTV 20, IDLE 100
    [ 6.482391] atmel_mxt_ts 1-004a: Touchscreen size X799Y479
    [ 6.489410] input: Atmel maXTouch Touchscreen as /devices/platform/omap/omap_i2c.1/i2c-1/1-004a/input/input0
    [ 6.502593] omap_rtc am33xx-rtc: rtc core: registered am33xx-rtc as rtc0
    [ 6.510253] i2c /dev entries driver

    However it does not work,  I don't see activity on X and Y pins, but touchscreen object is enabled and CHG pin goes low for 1ms every 200ms. I suppose it is a config error.

    Using mxt-app from obp-utils I can read every object and I see no difference from config file (just debug, command, etc).

    Is there any tool to create the config file?

    Is there any application note about mxt224e and linux?

    What am I doing wrong?, could you help me once again?

    Regards

  • Hi, my touchscreen is working fine now, there was an error in T46, it can't be 0 because the touch panel does not have the standard 16X14Y.

    Regards

  • Hi Fordfairlane,

    I am working on touch screen driver development for mxt540e controller.
    I am using atmel-maxtouch driver from github (atmel-maxtouch / linux).
    I have successfully registered the input device but I am facing some issues after that.
    My touch screen is still not working.

    below is the log:

    [ 1.548485] mxt540e_init
    [ 1.550749] mxt540e_adding driver
    [ 1.554194] mxt540e_probe1
    [ 1.556808] mxt540e_probe2
    [ 1.559482] mxt540e_probe3
    [ 1.562116] atmel_mxt_ts 1-004c: Must have reset GPIO to use regulator support
    [ 1.569370] mxt540e_probe4
    [ 1.572004] mxt540e_probe5
    [ 1.604727] atmel_mxt_ts 1-004c: Family: 161 Variant: 12 Firmware V2.1.AA Objects: 24
    [ 1.610749] atmel_mxt_ts 1-004c: Enabling RETRIGEN workaround
    [ 1.615434] usb device setup delayed
    [ 1.708439] atmel_mxt_ts 1-004c: Initialised power cfg: ACTV 255, IDLE 255
    [ 1.715068] atmel_mxt_ts 1-004c: Touchscreen size X1023Y1023
    [ 1.718391] input: Atmel maXTouch Touchscreen as /devices/platform/sirfsoc_i2c.1/i2c-1/1-004c/input/input3
    [ 1.728022] mxt540e_probe6
    [ 1.730573] mxt540e_registered
    [ 1.733474] driver : atmel_mxt_ts
    [ 1.753108] using rtc device, sirfsoc_rtc, for alarms
    [ 1.755154] sirfsoc_rtc sirfsoc_rtc.0: rtc core: registered sirfsoc_rtc as rtc0
    ....
    .....
    ....
    [ 9.634533] E/Sensors : Fatal error: FIFOSendGyro returned 10
    [ 9.640119] E/SurfaceFlinger: eglSwapBuffers: EGL error 0x3008 (EGL_BAD_DISPLAY)

    My device serial terminal(putty log) gets stuck after above error lines.

    can you please suggest what I am doing wrong.This is blocking my project.

     Please can you also share your board file (board-am335xevm.c).

    I do not have any .cfg file (read from obp-utils package)

    Hoping a quick reply from you.
     
    Regards,
    Lenin.