1 // SPDX-License-Identifier: GPL-2.0-only
3 * platform_max7315.c: max7315 platform data initialization file
5 * (C) Copyright 2013 Intel Corporation
6 * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
9 #include <linux/init.h>
10 #include <linux/gpio.h>
11 #include <linux/i2c.h>
12 #include <linux/platform_data/pca953x.h>
13 #include <asm/intel-mid.h>
17 static void __init
*max7315_platform_data(void *info
)
19 static struct pca953x_platform_data max7315_pdata
[MAX7315_NUM
];
21 struct pca953x_platform_data
*max7315
= &max7315_pdata
[nr
];
22 struct i2c_board_info
*i2c_info
= info
;
24 char base_pin_name
[SFI_NAME_LEN
+ 1];
25 char intr_pin_name
[SFI_NAME_LEN
+ 1];
27 if (nr
== MAX7315_NUM
) {
28 pr_err("too many max7315s, we only support %d\n",
32 /* we have several max7315 on the board, we only need load several
33 * instances of the same pca953x driver to cover them
35 strcpy(i2c_info
->type
, "max7315");
37 snprintf(base_pin_name
, sizeof(base_pin_name
),
38 "max7315_%d_base", nr
);
39 snprintf(intr_pin_name
, sizeof(intr_pin_name
),
40 "max7315_%d_int", nr
);
42 strcpy(base_pin_name
, "max7315_base");
43 strcpy(intr_pin_name
, "max7315_int");
46 gpio_base
= get_gpio_by_name(base_pin_name
);
47 intr
= get_gpio_by_name(intr_pin_name
);
51 max7315
->gpio_base
= gpio_base
;
53 i2c_info
->irq
= intr
+ INTEL_MID_IRQ_OFFSET
;
54 max7315
->irq_base
= gpio_base
+ INTEL_MID_IRQ_OFFSET
;
57 max7315
->irq_base
= -1;
62 static const struct devs_id max7315_dev_id __initconst
= {
63 .name
= "i2c_max7315",
64 .type
= SFI_DEV_TYPE_I2C
,
66 .get_platform_data
= &max7315_platform_data
,
69 static const struct devs_id max7315_2_dev_id __initconst
= {
70 .name
= "i2c_max7315_2",
71 .type
= SFI_DEV_TYPE_I2C
,
73 .get_platform_data
= &max7315_platform_data
,
76 sfi_device(max7315_dev_id
);
77 sfi_device(max7315_2_dev_id
);