]> Git Repo - linux.git/blob - arch/x86/platform/intel-mid/device_libs/platform_max7315.c
enetc: Migrate to PHYLINK and PCS_LYNX
[linux.git] / arch / x86 / platform / intel-mid / device_libs / platform_max7315.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * platform_max7315.c: max7315 platform data initialization file
4  *
5  * (C) Copyright 2013 Intel Corporation
6  * Author: Sathyanarayanan Kuppuswamy <[email protected]>
7  */
8
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>
14
15 #define MAX7315_NUM 2
16
17 static void __init *max7315_platform_data(void *info)
18 {
19         static struct pca953x_platform_data max7315_pdata[MAX7315_NUM];
20         static int nr;
21         struct pca953x_platform_data *max7315 = &max7315_pdata[nr];
22         struct i2c_board_info *i2c_info = info;
23         int gpio_base, intr;
24         char base_pin_name[SFI_NAME_LEN + 1];
25         char intr_pin_name[SFI_NAME_LEN + 1];
26
27         if (nr == MAX7315_NUM) {
28                 pr_err("too many max7315s, we only support %d\n",
29                                 MAX7315_NUM);
30                 return NULL;
31         }
32         /* we have several max7315 on the board, we only need load several
33          * instances of the same pca953x driver to cover them
34          */
35         strcpy(i2c_info->type, "max7315");
36         if (nr++) {
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);
41         } else {
42                 strcpy(base_pin_name, "max7315_base");
43                 strcpy(intr_pin_name, "max7315_int");
44         }
45
46         gpio_base = get_gpio_by_name(base_pin_name);
47         intr = get_gpio_by_name(intr_pin_name);
48
49         if (gpio_base < 0)
50                 return NULL;
51         max7315->gpio_base = gpio_base;
52         if (intr != -1) {
53                 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
54                 max7315->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
55         } else {
56                 i2c_info->irq = -1;
57                 max7315->irq_base = -1;
58         }
59         return max7315;
60 }
61
62 static const struct devs_id max7315_dev_id __initconst = {
63         .name = "i2c_max7315",
64         .type = SFI_DEV_TYPE_I2C,
65         .delay = 1,
66         .get_platform_data = &max7315_platform_data,
67 };
68
69 static const struct devs_id max7315_2_dev_id __initconst = {
70         .name = "i2c_max7315_2",
71         .type = SFI_DEV_TYPE_I2C,
72         .delay = 1,
73         .get_platform_data = &max7315_platform_data,
74 };
75
76 sfi_device(max7315_dev_id);
77 sfi_device(max7315_2_dev_id);
This page took 0.039093 seconds and 4 git commands to generate.