1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * platform_lis331.c:  lis331 platform data initialization file
4  *
5  * (C) Copyright 2013 Intel Corporation
6  * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
7  */
8 
9 #include <linux/i2c.h>
10 #include <linux/gpio.h>
11 #include <asm/intel-mid.h>
12 
lis331dl_platform_data(void * info)13 static void __init *lis331dl_platform_data(void *info)
14 {
15 	static short intr2nd_pdata;
16 	struct i2c_board_info *i2c_info = info;
17 	int intr = get_gpio_by_name("accel_int");
18 	int intr2nd = get_gpio_by_name("accel_2");
19 
20 	if (intr < 0)
21 		return NULL;
22 	if (intr2nd < 0)
23 		return NULL;
24 
25 	i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
26 	intr2nd_pdata = intr2nd + INTEL_MID_IRQ_OFFSET;
27 
28 	return &intr2nd_pdata;
29 }
30 
31 static const struct devs_id lis331dl_dev_id __initconst = {
32 	.name = "i2c_accel",
33 	.type = SFI_DEV_TYPE_I2C,
34 	.get_platform_data = &lis331dl_platform_data,
35 };
36 
37 sfi_device(lis331dl_dev_id);
38