1
2#ifndef _BBC_I2C_H
3#define _BBC_I2C_H
4
5#include <linux/of.h>
6#include <linux/of_device.h>
7#include <linux/list.h>
8
9struct bbc_i2c_client {
10 struct bbc_i2c_bus *bp;
11 struct platform_device *op;
12 int bus;
13 int address;
14};
15
16enum fan_action { FAN_SLOWER, FAN_SAME, FAN_FASTER, FAN_FULLBLAST, FAN_STATE_MAX };
17
18struct 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
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
40struct 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
54struct 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
68 struct platform_device *op;
69 struct {
70 struct platform_device *device;
71 int client_claimed;
72 } devs[NUM_CHILDREN];
73};
74
75
76extern struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *, int);
77extern struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_device *);
78extern void bbc_i2c_detach(struct bbc_i2c_client *);
79
80
81extern int bbc_i2c_writeb(struct bbc_i2c_client *, unsigned char val, int off);
82extern int bbc_i2c_readb(struct bbc_i2c_client *, unsigned char *byte, int off);
83extern int bbc_i2c_write_buf(struct bbc_i2c_client *, char *buf, int len, int off);
84extern int bbc_i2c_read_buf(struct bbc_i2c_client *, char *buf, int len, int off);
85
86#endif
87