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.

4x4 Matrix keypad on AM1808/OMAPl138

Other Parts Discussed in Thread: AM1808

Hi

I'm working with AM1808 processor i need to implement 4x4 matrix keypad is AM1808 support GPIO matrix keypad?

If its support please let me know the procedure to implement matrix keypad.

Thanks 

Sangly

  • Hi Sangly,

    Please refer to the following location for matric keyboard driver.

    drivers/input/keyboard/matrix_keypad.c

  • Hi Stalin

          I'm aware of matrix_keypad.c driver file i'm asking about board file configuration. 

          Is there any reference for matrix key board initialization for AM1808 processor ?

    Thanks

    Sangly

  • Hi Sangly,

    Select "OMAP Keypad" support in linux and add the platform data in your board file.

    Ex:

    //Map the keys to the appropriate key as your requirements
    static const unsigned int sample_keymap[] = {
    	KEY(0, 0, KEY_UP),	//	KEY(row, col, val)
    	KEY(1, 0, KEY_RIGHT),
    	KEY(2, 0, KEY_LEFT),
    	KEY(3, 0, KEY_DOWN),
    	KEY(0, 1, KEY_F10),
    	KEY(1, 1, KEY_SEND),
    	KEY(2, 1, KEY_END),
    	KEY(3, 1, KEY_VOLUMEDOWN),
    	KEY(0, 2, KEY_F9),
    	KEY(1, 2, KEY_3),
    	KEY(2, 2, KEY_6),
    	KEY(3, 2, KEY_9),
    	KEY(0, 3, KEY_BACK),
    	KEY(1, 3, KEY_2),
    	KEY(2, 3, KEY_5),
    	KEY(3, 3, KEY_8),
    };
    
    
    static const struct matrix_keymap_data sample_keymap_data = {
    	.keymap		= sample_keymap,
    	.keymap_size	= ARRAY_SIZE(sample_keymap),
    };
    
    static struct omap_kp_platform_data kp_data = {
    	.rows		= 4,
    	.cols		= 4,
    	.keymap_data	= &sample_keymap_data,
    	.delay		= 4,
    	.dbounce	= true,
    };
    
    
    static struct platform_device kp_device = {
    	.name		= "omap-keypad",
    	.id		= -1,
    	.dev		= {
    		.platform_data = &kp_data,
    	},
    };
    

  • Hi Stalin 

       Thanks for your reference i completed this already 

    //======================Matrix Keyboard start===================
    
    /* Keys mapping */
    static const uint32_t da850_matrix_keys[] = {
    	KEY(0, 0, KEY_1),
    	KEY(1, 0, KEY_2),	
    
    	KEY(0, 1, KEY_3),
    	KEY(1, 1, KEY_4),
    };
    
    const struct matrix_keymap_data da850_keymap_data = {
    	.keymap      = da850_matrix_keys,
    	.keymap_size = ARRAY_SIZE(da850_matrix_keys),
    };
    
    //da850_keypad_row_gpios,
    static const unsigned int da850_keypad_row_gpios[] = {
    	GPIO_TO_PIN(2, 1), GPIO_TO_PIN(2, 7)
    };
    
    //da850_keypad_col_gpios
    static const unsigned int da850_keypad_col_gpios[] = {
    	GPIO_TO_PIN(2, 6), GPIO_TO_PIN(2, 2)
    };
    
    static struct matrix_keypad_platform_data da850_keypad_platform_data = {
    	.keymap_data       = &da850_keymap_data,
    	.row_gpios         = da850_keypad_row_gpios,
    	.num_row_gpios     = ARRAY_SIZE(da850_keypad_row_gpios),
    	.col_gpios         = da850_keypad_col_gpios,
    	.num_col_gpios     = ARRAY_SIZE(da850_keypad_col_gpios),
    	.active_low        = true,
    	.debounce_ms       = 5,
    	.col_scan_delay_us = 2,
    };
    
    
    static struct platform_device da850_keyboard = {
    	.name  = "matrix-keypad",
    	.id    = -1,
    	.dev   = {
    		.platform_data = &da850_keypad_platform_data,
    	},
    };
    
    static short da850_matrix_gpio[] __initdata= { 
        DA850_GPIO2_1,
        DA850_GPIO2_7,
        DA850_GPIO2_6,
        DA850_GPIO2_2,
        -1 
    };
    
    static void omapl138_matrix_keyboard_init(void)
    {
    	int err;
    
    	//setup_pin_mux(matrix_keypad_pin_mux);
    	err=davinci_cfg_reg_list(da850_matrix_gpio); 
    	if (err) {
    	pr_err("failed to register matrix keypad (2x2) Pin mux\n");
    	}
    	else
    	pr_info("MATRIX_KEY :: configured the pinmux");
    
    	err = platform_device_register(&da850_keyboard);
    
    	if (err) {
    	pr_err("failed to register matrix keypad (2x2) device\n");
    	}
    	else
    	pr_info("MATRIX_KEY :: configured the 2x2 matrix keypad");
    }
    //======================Matrix Keyboard end===================
    

    Thanks

    Sangly

  • Hi Sangly,

    Thanks for your code and hope it could help others.

    Please close the thread if you don't have any other question.

  • Hi

             I'm looking for the reference for keypad driver like mobile 3x4 alphanumeric keypad work like if we want type "a" we need to press 2 and for "b" press 2 two times.

            Is there any reference driver for Linux ?

    Thanks

    Sangly

  • Hi Sangly,

    As far as I know, Linux don't have driver to do DTMF stuffs for matrix keypad.

    I've recollected the info from earlier app team member.

    Earlier, we have done this kind of stuffs through QT application.

    We have to handle the events in QT app such a way that if we receive 2 events then we need to send code of "a" (code is 30) if we receive 3 events then we have to send a code of "b" respectively for rest of the keys.

    Sorry. I don't know much about this implementation.

    Good luck.