via_aux.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
  4. */
  5. /*
  6. * infrastructure for devices connected via I2C
  7. */
  8. #ifndef __VIA_AUX_H__
  9. #define __VIA_AUX_H__
  10. #include <linux/list.h>
  11. #include <linux/i2c.h>
  12. #include <linux/fb.h>
  13. struct via_aux_bus {
  14. struct i2c_adapter *adap; /* the I2C device to access the bus */
  15. struct list_head drivers; /* drivers for devices on this bus */
  16. };
  17. struct via_aux_drv {
  18. struct list_head chain; /* chain to support multiple drivers */
  19. struct via_aux_bus *bus; /* the I2C bus used */
  20. u8 addr; /* the I2C target address */
  21. const char *name; /* human readable name of the driver */
  22. void *data; /* private data of this driver */
  23. void (*cleanup)(struct via_aux_drv *drv);
  24. const struct fb_videomode* (*get_preferred_mode)
  25. (struct via_aux_drv *drv);
  26. };
  27. struct via_aux_bus *via_aux_probe(struct i2c_adapter *adap);
  28. void via_aux_free(struct via_aux_bus *bus);
  29. const struct fb_videomode *via_aux_get_preferred_mode(struct via_aux_bus *bus);
  30. static inline bool via_aux_add(struct via_aux_drv *drv)
  31. {
  32. struct via_aux_drv *data = kmalloc(sizeof(*data), GFP_KERNEL);
  33. if (!data)
  34. return false;
  35. *data = *drv;
  36. list_add_tail(&data->chain, &data->bus->drivers);
  37. return true;
  38. }
  39. static inline bool via_aux_read(struct via_aux_drv *drv, u8 start, u8 *buf,
  40. u8 len)
  41. {
  42. struct i2c_msg msg[2] = {
  43. {.addr = drv->addr, .flags = 0, .len = 1, .buf = &start},
  44. {.addr = drv->addr, .flags = I2C_M_RD, .len = len, .buf = buf} };
  45. return i2c_transfer(drv->bus->adap, msg, 2) == 2;
  46. }
  47. /* probe functions of existing drivers - should only be called in via_aux.c */
  48. void via_aux_ch7301_probe(struct via_aux_bus *bus);
  49. void via_aux_edid_probe(struct via_aux_bus *bus);
  50. void via_aux_sii164_probe(struct via_aux_bus *bus);
  51. void via_aux_vt1636_probe(struct via_aux_bus *bus);
  52. void via_aux_vt1632_probe(struct via_aux_bus *bus);
  53. void via_aux_vt1631_probe(struct via_aux_bus *bus);
  54. void via_aux_vt1625_probe(struct via_aux_bus *bus);
  55. void via_aux_vt1622_probe(struct via_aux_bus *bus);
  56. void via_aux_vt1621_probe(struct via_aux_bus *bus);
  57. #endif /* __VIA_AUX_H__ */