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