title: max732x.c I2C IO Expander + GPIO Keys w/ Linux Device Tree not working
body: <p>I'm working with a Freescale MX6 and a 3.10.31 Freescale modified kernel.   I have a Maxim MAX7325 used as an IO expander, which has pushbuttons attached to P0-P2.   The interrupt line from the 7325 is attached to the GPIO_3 pad (which I believe is GPIO1_3...)</p>
  
  <p>I set up the 7325 and gpio-keys in the device tree like this:</p>
  
  <pre><code>max7325_reset: max7325-reset {
    compatible = "gpio-reset";
    reset-gpios = &lt;&amp;gpio5 16 GPIO_ACTIVE_LOW&gt;;
    reset-delay-us = &lt;1&gt;;
    #reset-cells = &lt;0&gt;;
  };
  
  
  gpio-keys {
    compatible = "gpio-keys";
  
    sw2 {
       gpios = &lt;&amp;max7325 2 GPIO_ACTIVE_LOW&gt;;
       linux,code = &lt;30&gt;;    //a
       gpio-key,wakeup;
    };
  };
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&amp;i2c1 {
     clock-frequency = &lt;100000&gt;;
     pinctrl-names = "default";
     pinctrl-0 = &lt;&amp;pinctrl_i2c1_2&gt;;
     status = "okay";
  
     max7325: gpio@68 {
        compatible = "maxim,max7325";
        reg = &lt;0x68&gt;;
        gpio-controller;
        #gpio-cells = &lt;2&gt;;
        resets = &lt;&amp;max7325_reset&gt;;
  
        gpios = &lt;&amp;gpio1 3 GPIO_ACTIVE_LOW&gt;;
        interrupt-parent = &lt;&amp;gpio1&gt;;
        interrupts = &lt;3 2&gt;;
     };
  };
  </code></pre>
  
  <p>What appears to happen is when probe for the MAX7325 driver is called, client->dev.platform_data is NULL.   Because of this, when max732x_irq_setup is called later, it doesn't set up the chip->gpio_chip.to_irq pointer to point at max732x_gpio_to_irq function (presumably because it doesn't have the right info for this to work.)   Later, when gpio_keys
  tries to config the first input, it fails when it tries to set up the interrupt and none of the other keys get set up.</p>
  
  <pre><code>gpio-keys gpio-keys.20: Unable to get irq number for GPIO 242, error -6
  </code></pre>
  
  <p>I did determine using the /sys interface that P0 maps to GPIO 240, so yeah, GPIO 242 is the sw2 GPIO-KEY I was trying to set up.</p>
  
  <p>I'm wondering, does this driver not work with a device tree?   I don't see it trying to get any device tree properties, but other IO expander drivers I looked at didn't either, so I thought maybe the I2C core is reading the device tree and supposed to fill in the platform_data from there somehow before it calls the driver's probe function (?)   </p>
  
  <p>I'm fairly new at this, so any help would be appreciated. =)   I did read a few of the Device Tree docs online, but I'm thinking this is something fairly specific that I'm not doing correctly, which they don't cover... (?)</p>
  
  <p>I do have CONFIG_GPIO_MAX732X_IRQ configured in the kernel... and I did at one point try setting the interrupt-controller property for the max7325 I2c1 node, but I wasn't sure that was needed (?) </p>