bbc_i2c.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _BBC_I2C_H
  2. #define _BBC_I2C_H
  3. #include <linux/of.h>
  4. #include <linux/of_device.h>
  5. #include <linux/list.h>
  6. struct bbc_i2c_client {
  7. struct bbc_i2c_bus *bp;
  8. struct platform_device *op;
  9. int bus;
  10. int address;
  11. };
  12. enum fan_action { FAN_SLOWER, FAN_SAME, FAN_FASTER, FAN_FULLBLAST, FAN_STATE_MAX };
  13. struct bbc_cpu_temperature {
  14. struct list_head bp_list;
  15. struct list_head glob_list;
  16. struct bbc_i2c_client *client;
  17. int index;
  18. /* Current readings, and history. */
  19. s8 curr_cpu_temp;
  20. s8 curr_amb_temp;
  21. s8 prev_cpu_temp;
  22. s8 prev_amb_temp;
  23. s8 avg_cpu_temp;
  24. s8 avg_amb_temp;
  25. int sample_tick;
  26. enum fan_action fan_todo[2];
  27. #define FAN_AMBIENT 0
  28. #define FAN_CPU 1
  29. };
  30. struct bbc_fan_control {
  31. struct list_head bp_list;
  32. struct list_head glob_list;
  33. struct bbc_i2c_client *client;
  34. int index;
  35. int psupply_fan_on;
  36. int cpu_fan_speed;
  37. int system_fan_speed;
  38. };
  39. #define NUM_CHILDREN 8
  40. struct bbc_i2c_bus {
  41. struct bbc_i2c_bus *next;
  42. int index;
  43. spinlock_t lock;
  44. void __iomem *i2c_bussel_reg;
  45. void __iomem *i2c_control_regs;
  46. unsigned char own, clock;
  47. wait_queue_head_t wq;
  48. volatile int waiting;
  49. struct list_head temps;
  50. struct list_head fans;
  51. struct platform_device *op;
  52. struct {
  53. struct platform_device *device;
  54. int client_claimed;
  55. } devs[NUM_CHILDREN];
  56. };
  57. /* Probing and attachment. */
  58. extern struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *, int);
  59. extern struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_device *);
  60. extern void bbc_i2c_detach(struct bbc_i2c_client *);
  61. /* Register read/write. NOTE: Blocking! */
  62. extern int bbc_i2c_writeb(struct bbc_i2c_client *, unsigned char val, int off);
  63. extern int bbc_i2c_readb(struct bbc_i2c_client *, unsigned char *byte, int off);
  64. extern int bbc_i2c_write_buf(struct bbc_i2c_client *, char *buf, int len, int off);
  65. extern int bbc_i2c_read_buf(struct bbc_i2c_client *, char *buf, int len, int off);
  66. #endif /* _BBC_I2C_H */