2011-03-17 00:57:11     Using Max7301 as GPIO expander

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-03-17 00:57:11     Using Max7301 as GPIO expander

Shyam sundar (INDIA)

Message: 98982   

 

Hello world,

 

I want to use two max7301 chips as GPIO expanders.

 

How can I specify which GPIO pins to be used as chip select pins?

 

Suppose max7301 chip is connected to slave select 4, then If I want to configure,read or write the expanded GPIO's, should I open the device as spi0.4 or in some other way?

 

I want to connect a 4x4 keypad to the max7301 chip. How can I get notified in the user space that a key was being pressed?

QuoteReplyEditDelete

 

 

2011-03-17 01:16:21     Re: Using Max7301 as GPIO expander

Mike Frysinger (UNITED STATES)

Message: 98983   

 

once you declare the resources in  your boards file to connect things to gpiolib, you use the normal GPIO API as documented in the wiki

 

same goes for connecting to the input device sub system

 

if you need more assistance, please look in the kernel tree for boards already using this part, or ask Maximum for assistance.  we dont make this part nor support it.

QuoteReplyEditDelete

 

 

2011-03-18 02:26:00     Re: Using Max7301 as GPIO expander

Shyam sundar (INDIA)

Message: 99023   

 

Hello Mike,

 

Thanks   ! In board file I have added the following lines

 

#if defined(CONFIG_GPIO_MAX7301_CHIP_1)

#include <linux/spi/max7301.h>

static struct max7301_platform_data max7301_chip1_gpio_data = {

    .base = 50,

};

#endif

 

#if defined(CONFIG_GPIO_MAX7301_CHIP_2)

#include <linux/spi/max7301.h>

static struct max7301_platform_data max7301_chip2_gpio_data = {

    .base = 80,

};

#endif

 

 

static struct spi_board_info bfin_spi_board_info[] __initdata = {

 

#if defined(CONFIG_GPIO_MAX7301_CHIP_1)

    {

        /* the modalias must be the same as spi device driver name */

        .modalias = "max7301_chip1", /* Name of spi_driver for this device */

        .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */

        .bus_num = 0, /* Framework bus number */

        .chip_select = CONFIG_SPI_PFBIT_GPIO_EXPANDER_1, /* Framework chip select.*/

        .platform_data = &max7301_chip1_gpio_data,

    },

#endif

 

 

 

#if defined(CONFIG_GPIO_MAX7301_CHIP_2)

    {

        /* the modalias must be the same as spi device driver name */

        .modalias = "max7301_chip2", /* Name of spi_driver for this device */

        .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */

        .bus_num = 0, /* Framework bus number */

        .chip_select = CONFIG_SPI_PFBIT_GPIO_EXPANDER_2, /* Framework chip select.*/

        .platform_data = &max7301_chip2_gpio_data,

    },

#endif

 

 

Is the above addition correct ? I was not able to find any reference ! I will try to add device subsystem once, the basic functionality of the GPIO is done! When I specify .base= 50 does it mean that it corresponds to PF50?

QuoteReplyEditDelete

Attachments

    Outcomes