• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * platform_tca6416.c: tca6416 platform data initilization file
3  *
4  * (C) Copyright 2013 Intel Corporation
5  * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; version 2
10  * of the License.
11  */
12 
13 #include <linux/platform_data/pca953x.h>
14 #include <linux/i2c.h>
15 #include <linux/gpio.h>
16 #include <asm/intel-mid.h>
17 
18 #define TCA6416_NAME	"tca6416"
19 #define TCA6416_BASE	"tca6416_base"
20 #define TCA6416_INTR	"tca6416_int"
21 
tca6416_platform_data(void * info)22 static void *tca6416_platform_data(void *info)
23 {
24 	static struct pca953x_platform_data tca6416;
25 	struct i2c_board_info *i2c_info = info;
26 	int gpio_base, intr;
27 	char base_pin_name[SFI_NAME_LEN + 1];
28 	char intr_pin_name[SFI_NAME_LEN + 1];
29 
30 	strcpy(i2c_info->type, TCA6416_NAME);
31 	strcpy(base_pin_name, TCA6416_BASE);
32 	strcpy(intr_pin_name, TCA6416_INTR);
33 
34 	gpio_base = get_gpio_by_name(base_pin_name);
35 	intr = get_gpio_by_name(intr_pin_name);
36 
37 	if (gpio_base < 0)
38 		return NULL;
39 	tca6416.gpio_base = gpio_base;
40 	if (intr >= 0) {
41 		i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
42 		tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
43 	} else {
44 		i2c_info->irq = -1;
45 		tca6416.irq_base = -1;
46 	}
47 	return &tca6416;
48 }
49 
50 static const struct devs_id tca6416_dev_id __initconst = {
51 	.name = "tca6416",
52 	.type = SFI_DEV_TYPE_I2C,
53 	.delay = 1,
54 	.get_platform_data = &tca6416_platform_data,
55 };
56 
57 sfi_device(tca6416_dev_id);
58