Binding an I2C device driver

613

I was missing platform data for this device.

I was able to get it working by inserting the platform data directly into the code for the driver module:

static uint32_t tca8418_km_data[] = {
    KEY(0, 0, KEY_F1),
    KEY(0, 1, KEY_F2),
    KEY(0, 2, KEY_F3),
    ...
};

static const struct matrix_keymap_data tca8418_mk_data = {
    .keymap         = tca8418_km_data,
    .keymap_size    = ARRAY_SIZE(tca8418_km_data),
};

static struct tca8418_keypad_platform_data my_tca8418_plat_data = {
    .keymap_data    = &tca8418_mk_data,
    .rows           = 6,
    .cols           = 8,
    .rep            = 1,
    .irq_is_gpio    = 1,
};

static struct i2c_board_info tca8418_board_info __initdata = {
    I2C_BOARD_INFO("tca8418_keypad", 0x34),
    .platform_data  = &my_tca8418_plat_data,
    .irq            = 16, // GPIO pin 16
};

Then adding this to the __init function:

static int __init tca8418_keypad_init(void)
{
    struct i2c_adapter *i2c_adap;
    i2c_adap = i2c_get_adapter(1);
    i2c_new_device(i2c_adap, &tca8418_board_info);
    ...
}

This is not the most elegant of fixes, but it worked for me. I would have preferred a userspace solution, but I was unable to find one.

Share:
613

Related videos on Youtube

DeadLee
Author by

DeadLee

Updated on September 18, 2022

Comments

  • DeadLee
    DeadLee over 1 year

    What I am trying to do is run a search against an API (which I have working) and then display the returned information in a table. Below is my code and a mocked up image of what I am trying to achieve plus what I currently see.

    JSON

    {
        "legalDescription": "Pork & Egg Gala Pie",
        "QUID": [
            "Pork 38%"
        ],
        "warningStatement": [
            "Caution: May contain bone"
        ],
        "GTIN": "0213090000000",
        "allergenInfo": [
            {
                "allergenName": "Contains",
                "allergenValues": "Wheat"
            },
            {
                "allergenName": "Contains",
                "allergenValues": "Egg"
            }
        ],
        "href": "http://product.global.tesco.org:8080/v2/products/counterproducts/0213090000000"
    }
    

    AngularJS

    $scope.products = [];
    
        $scope.runCountersSearch = function() {
    
            $http.get("http://product.global.tesco.org:8080/v2/products/counterproducts/" + $scope.searchInputCounters).success(function(theData) {
    
                $scope.products.push(theData);
            });
    
        }
    

    HTML

    <tr ng-repeat = "oneProduct in products">
                        <td> {{oneProduct.legalDescription}} </td>
                        <td ng-repeat="quid in oneProduct.QUID"> {{quid.QUID}} </td>
                        <td ng-repeat="warning in oneProduct.warningStatement">{{warning.warningStatement}} </td>
                    </tr>
                </table>
    

    What I see What I See What I want to get What I want to get

  • 0andriy
    0andriy over 4 years
    It should be done via DT or ACPI.