Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.13 99 lines 2.6 kB view raw
1/* 2 * PCAL9555a platform data initilization file 3 * 4 * Copyright (C) 2016, Intel Corporation 5 * 6 * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 7 * Dan O'Donovan <dan@emutex.com> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; version 2 12 * of the License. 13 */ 14 15#include <linux/gpio.h> 16#include <linux/init.h> 17#include <linux/i2c.h> 18#include <linux/platform_data/pca953x.h> 19#include <linux/sfi.h> 20 21#include <asm/intel-mid.h> 22 23#define PCAL9555A_NUM 4 24 25static struct pca953x_platform_data pcal9555a_pdata[PCAL9555A_NUM]; 26static int nr; 27 28static void __init *pcal9555a_platform_data(void *info) 29{ 30 struct i2c_board_info *i2c_info = info; 31 char *type = i2c_info->type; 32 struct pca953x_platform_data *pcal9555a; 33 char base_pin_name[SFI_NAME_LEN + 1]; 34 char intr_pin_name[SFI_NAME_LEN + 1]; 35 int gpio_base, intr; 36 37 snprintf(base_pin_name, sizeof(base_pin_name), "%s_base", type); 38 snprintf(intr_pin_name, sizeof(intr_pin_name), "%s_int", type); 39 40 gpio_base = get_gpio_by_name(base_pin_name); 41 intr = get_gpio_by_name(intr_pin_name); 42 43 /* Check if the SFI record valid */ 44 if (gpio_base == -1) 45 return NULL; 46 47 if (nr >= PCAL9555A_NUM) { 48 pr_err("%s: Too many instances, only %d supported\n", __func__, 49 PCAL9555A_NUM); 50 return NULL; 51 } 52 53 pcal9555a = &pcal9555a_pdata[nr++]; 54 pcal9555a->gpio_base = gpio_base; 55 56 if (intr >= 0) { 57 i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET; 58 pcal9555a->irq_base = gpio_base + INTEL_MID_IRQ_OFFSET; 59 } else { 60 i2c_info->irq = -1; 61 pcal9555a->irq_base = -1; 62 } 63 64 strcpy(type, "pcal9555a"); 65 return pcal9555a; 66} 67 68static const struct devs_id pcal9555a_1_dev_id __initconst = { 69 .name = "pcal9555a-1", 70 .type = SFI_DEV_TYPE_I2C, 71 .delay = 1, 72 .get_platform_data = &pcal9555a_platform_data, 73}; 74 75static const struct devs_id pcal9555a_2_dev_id __initconst = { 76 .name = "pcal9555a-2", 77 .type = SFI_DEV_TYPE_I2C, 78 .delay = 1, 79 .get_platform_data = &pcal9555a_platform_data, 80}; 81 82static const struct devs_id pcal9555a_3_dev_id __initconst = { 83 .name = "pcal9555a-3", 84 .type = SFI_DEV_TYPE_I2C, 85 .delay = 1, 86 .get_platform_data = &pcal9555a_platform_data, 87}; 88 89static const struct devs_id pcal9555a_4_dev_id __initconst = { 90 .name = "pcal9555a-4", 91 .type = SFI_DEV_TYPE_I2C, 92 .delay = 1, 93 .get_platform_data = &pcal9555a_platform_data, 94}; 95 96sfi_device(pcal9555a_1_dev_id); 97sfi_device(pcal9555a_2_dev_id); 98sfi_device(pcal9555a_3_dev_id); 99sfi_device(pcal9555a_4_dev_id);