platform_tca6416.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include <linux/platform_data/pca953x.h>
  13. #include <linux/i2c.h>
  14. #include <linux/gpio.h>
  15. #include <asm/intel-mid.h>
  16. #define TCA6416_NAME "tca6416"
  17. #define TCA6416_BASE "tca6416_base"
  18. #define TCA6416_INTR "tca6416_int"
  19. static void *tca6416_platform_data(void *info)
  20. {
  21. static struct pca953x_platform_data tca6416;
  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. strcpy(i2c_info->type, TCA6416_NAME);
  27. strcpy(base_pin_name, TCA6416_BASE);
  28. strcpy(intr_pin_name, TCA6416_INTR);
  29. gpio_base = get_gpio_by_name(base_pin_name);
  30. intr = get_gpio_by_name(intr_pin_name);
  31. if (gpio_base < 0)
  32. return NULL;
  33. tca6416.gpio_base = gpio_base;
  34. if (intr >= 0) {
  35. i2c_info->irq = intr + INTEL_MID_IRQ_OFFSET;
  36. tca6416.irq_base = gpio_base + INTEL_MID_IRQ_OFFSET;
  37. } else {
  38. i2c_info->irq = -1;
  39. tca6416.irq_base = -1;
  40. }
  41. return &tca6416;
  42. }
  43. static const struct devs_id tca6416_dev_id __initconst = {
  44. .name = "tca6416",
  45. .type = SFI_DEV_TYPE_I2C,
  46. .delay = 1,
  47. .get_platform_data = &tca6416_platform_data,
  48. };
  49. sfi_device(tca6416_dev_id);