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