pmac_low_i2c.h 3.2 KB

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