/arch/powerpc/include/asm/pmac_low_i2c.h

http://github.com/mirrors/linux · C Header · 98 lines · 47 code · 17 blank · 34 comment · 0 complexity · 537938fdea6b3e6bf5d867f79bbbaa25 MD5 · raw file

  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * include/asm-ppc/pmac_low_i2c.h
  4. *
  5. * Copyright (C) 2003 Ben. Herrenschmidt (benh@kernel.crashing.org)
  6. */
  7. #ifndef __PMAC_LOW_I2C_H__
  8. #define __PMAC_LOW_I2C_H__
  9. #ifdef __KERNEL__
  10. /* i2c mode (based on the platform functions format) */
  11. enum {
  12. pmac_i2c_mode_dumb = 1,
  13. pmac_i2c_mode_std = 2,
  14. pmac_i2c_mode_stdsub = 3,
  15. pmac_i2c_mode_combined = 4,
  16. };
  17. /* RW bit in address */
  18. enum {
  19. pmac_i2c_read = 0x01,
  20. pmac_i2c_write = 0x00
  21. };
  22. /* i2c bus type */
  23. enum {
  24. pmac_i2c_bus_keywest = 0,
  25. pmac_i2c_bus_pmu = 1,
  26. pmac_i2c_bus_smu = 2,
  27. };
  28. /* i2c bus features */
  29. enum {
  30. /* can_largesub : supports >1 byte subaddresses (SMU only) */
  31. pmac_i2c_can_largesub = 0x00000001u,
  32. /* multibus : device node holds multiple busses, bus number is
  33. * encoded in bits 0xff00 of "reg" of a given device
  34. */
  35. pmac_i2c_multibus = 0x00000002u,
  36. };
  37. /* i2c busses in the system */
  38. struct pmac_i2c_bus;
  39. struct i2c_adapter;
  40. /* Init, called early during boot */
  41. extern int pmac_i2c_init(void);
  42. /* Lookup an i2c bus for a device-node. The node can be either the bus
  43. * node itself or a device below it. In the case of a multibus, the bus
  44. * node itself is the controller node, else, it's a child of the controller
  45. * node
  46. */
  47. extern struct pmac_i2c_bus *pmac_i2c_find_bus(struct device_node *node);
  48. /* Get the address for an i2c device. This strips the bus number if
  49. * necessary. The 7 bits address is returned 1 bit right shifted so that the
  50. * direction can be directly ored in
  51. */
  52. extern u8 pmac_i2c_get_dev_addr(struct device_node *device);
  53. /* Get infos about a bus */
  54. extern struct device_node *pmac_i2c_get_controller(struct pmac_i2c_bus *bus);
  55. extern struct device_node *pmac_i2c_get_bus_node(struct pmac_i2c_bus *bus);
  56. extern int pmac_i2c_get_type(struct pmac_i2c_bus *bus);
  57. extern int pmac_i2c_get_flags(struct pmac_i2c_bus *bus);
  58. extern int pmac_i2c_get_channel(struct pmac_i2c_bus *bus);
  59. /* i2c layer adapter helpers */
  60. extern struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus);
  61. extern struct pmac_i2c_bus *pmac_i2c_adapter_to_bus(struct i2c_adapter *adapter);
  62. /* March a device or bus with an i2c adapter structure, to be used by drivers
  63. * to match device-tree nodes with i2c adapters during adapter discovery
  64. * callbacks
  65. */
  66. extern int pmac_i2c_match_adapter(struct device_node *dev,
  67. struct i2c_adapter *adapter);
  68. /* (legacy) Locking functions exposed to i2c-keywest */
  69. extern int pmac_low_i2c_lock(struct device_node *np);
  70. extern int pmac_low_i2c_unlock(struct device_node *np);
  71. /* Access functions for platform code */
  72. extern int pmac_i2c_open(struct pmac_i2c_bus *bus, int polled);
  73. extern void pmac_i2c_close(struct pmac_i2c_bus *bus);
  74. extern int pmac_i2c_setmode(struct pmac_i2c_bus *bus, int mode);
  75. extern int pmac_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
  76. u32 subaddr, u8 *data, int len);
  77. /* Suspend/resume code called by via-pmu directly for now */
  78. extern void pmac_pfunc_i2c_suspend(void);
  79. extern void pmac_pfunc_i2c_resume(void);
  80. #endif /* __KERNEL__ */
  81. #endif /* __PMAC_LOW_I2C_H__ */