2 * PCAL9555a platform data initilization file
4 * Copyright (C) 2016, Intel Corporation
6 * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7 * Dan O'Donovan <dan@emutex.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; version 2
15 #include <linux/gpio.h>
16 #include <linux/init.h>
17 #include <linux/i2c.h>
18 #include <linux/platform_data/pca953x.h>
19 #include <linux/sfi.h>
21 #include <asm/intel-mid.h>
23 #define PCAL9555A_NUM 4
25 static struct pca953x_platform_data pcal9555a_pdata
[PCAL9555A_NUM
];
28 static void __init
*pcal9555a_platform_data(void *info
)
30 struct i2c_board_info
*i2c_info
= info
;
31 char *type
= i2c_info
->type
;
32 struct pca953x_platform_data
*pcal9555a
;
33 char base_pin_name
[SFI_NAME_LEN
+ 1];
34 char intr_pin_name
[SFI_NAME_LEN
+ 1];
37 snprintf(base_pin_name
, sizeof(base_pin_name
), "%s_base", type
);
38 snprintf(intr_pin_name
, sizeof(intr_pin_name
), "%s_int", type
);
40 gpio_base
= get_gpio_by_name(base_pin_name
);
41 intr
= get_gpio_by_name(intr_pin_name
);
43 /* Check if the SFI record valid */
47 if (nr
>= PCAL9555A_NUM
) {
48 pr_err("%s: Too many instances, only %d supported\n", __func__
,
53 pcal9555a
= &pcal9555a_pdata
[nr
++];
54 pcal9555a
->gpio_base
= gpio_base
;
57 i2c_info
->irq
= intr
+ INTEL_MID_IRQ_OFFSET
;
58 pcal9555a
->irq_base
= gpio_base
+ INTEL_MID_IRQ_OFFSET
;
61 pcal9555a
->irq_base
= -1;
64 strcpy(type
, "pcal9555a");
68 static const struct devs_id pcal9555a_1_dev_id __initconst
= {
69 .name
= "pcal9555a-1",
70 .type
= SFI_DEV_TYPE_I2C
,
72 .get_platform_data
= &pcal9555a_platform_data
,
75 static const struct devs_id pcal9555a_2_dev_id __initconst
= {
76 .name
= "pcal9555a-2",
77 .type
= SFI_DEV_TYPE_I2C
,
79 .get_platform_data
= &pcal9555a_platform_data
,
82 static const struct devs_id pcal9555a_3_dev_id __initconst
= {
83 .name
= "pcal9555a-3",
84 .type
= SFI_DEV_TYPE_I2C
,
86 .get_platform_data
= &pcal9555a_platform_data
,
89 static const struct devs_id pcal9555a_4_dev_id __initconst
= {
90 .name
= "pcal9555a-4",
91 .type
= SFI_DEV_TYPE_I2C
,
93 .get_platform_data
= &pcal9555a_platform_data
,
96 sfi_device(pcal9555a_1_dev_id
);
97 sfi_device(pcal9555a_2_dev_id
);
98 sfi_device(pcal9555a_3_dev_id
);
99 sfi_device(pcal9555a_4_dev_id
);