WIP FPC-III support
[linux/fpc-iii.git] / arch / x86 / platform / intel-mid / device_libs / platform_tca6416.c
blobe689d8f61059e6518657eee506d5229def17e5a7
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * platform_tca6416.c: tca6416 platform data initialization file
5 * (C) Copyright 2013 Intel Corporation
6 * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
7 */
9 #include <linux/platform_data/pca953x.h>
10 #include <linux/i2c.h>
11 #include <linux/gpio.h>
12 #include <asm/intel-mid.h>
14 #define TCA6416_NAME "tca6416"
15 #define TCA6416_BASE "tca6416_base"
16 #define TCA6416_INTR "tca6416_int"
18 static void *tca6416_platform_data(void *info)
20 static struct pca953x_platform_data tca6416;
21 struct i2c_board_info *i2c_info = info;
22 int gpio_base, intr;
23 char base_pin_name[SFI_NAME_LEN + 1];
24 char intr_pin_name[SFI_NAME_LEN + 1];
26 strcpy(i2c_info->type, TCA6416_NAME);
27 strcpy(base_pin_name, TCA6416_BASE);
28 strcpy(intr_pin_name, TCA6416_INTR);
30 gpio_base = get_gpio_by_name(base_pin_name);
31 intr = get_gpio_by_name(intr_pin_name);
33 if (gpio_base < 0)
34 return NULL;
35 tca6416.gpio_base = gpio_base;
36 if (intr >= 0) {
37 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
38 tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
39 } else {
40 i2c_info->irq = -1;
41 tca6416.irq_base = -1;
43 return &tca6416;
46 static const struct devs_id tca6416_dev_id __initconst = {
47 .name = "tca6416",
48 .type = SFI_DEV_TYPE_I2C,
49 .delay = 1,
50 .get_platform_data = &tca6416_platform_data,
53 sfi_device(tca6416_dev_id);