1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef _BBC_I2C_H 31da177e4SLinus Torvalds #define _BBC_I2C_H 41da177e4SLinus Torvalds 5e21e245bSDavid S. Miller #include <linux/of.h> 6e21e245bSDavid S. Miller #include <linux/list.h> 71da177e4SLinus Torvalds 8e21e245bSDavid S. Miller struct bbc_i2c_client { 9e21e245bSDavid S. Miller struct bbc_i2c_bus *bp; 102dc11581SGrant Likely struct platform_device *op; 11e21e245bSDavid S. Miller int bus; 12e21e245bSDavid S. Miller int address; 13e21e245bSDavid S. Miller }; 14e21e245bSDavid S. Miller 15e21e245bSDavid S. Miller enum fan_action { FAN_SLOWER, FAN_SAME, FAN_FASTER, FAN_FULLBLAST, FAN_STATE_MAX }; 16e21e245bSDavid S. Miller 17e21e245bSDavid S. Miller struct bbc_cpu_temperature { 18e21e245bSDavid S. Miller struct list_head bp_list; 19e21e245bSDavid S. Miller struct list_head glob_list; 20e21e245bSDavid S. Miller 21e21e245bSDavid S. Miller struct bbc_i2c_client *client; 22e21e245bSDavid S. Miller int index; 23e21e245bSDavid S. Miller 24e21e245bSDavid S. Miller /* Current readings, and history. */ 25e21e245bSDavid S. Miller s8 curr_cpu_temp; 26e21e245bSDavid S. Miller s8 curr_amb_temp; 27e21e245bSDavid S. Miller s8 prev_cpu_temp; 28e21e245bSDavid S. Miller s8 prev_amb_temp; 29e21e245bSDavid S. Miller s8 avg_cpu_temp; 30e21e245bSDavid S. Miller s8 avg_amb_temp; 31e21e245bSDavid S. Miller 32e21e245bSDavid S. Miller int sample_tick; 33e21e245bSDavid S. Miller 34e21e245bSDavid S. Miller enum fan_action fan_todo[2]; 35e21e245bSDavid S. Miller #define FAN_AMBIENT 0 36e21e245bSDavid S. Miller #define FAN_CPU 1 37e21e245bSDavid S. Miller }; 38e21e245bSDavid S. Miller 39e21e245bSDavid S. Miller struct bbc_fan_control { 40e21e245bSDavid S. Miller struct list_head bp_list; 41e21e245bSDavid S. Miller struct list_head glob_list; 42e21e245bSDavid S. Miller 43e21e245bSDavid S. Miller struct bbc_i2c_client *client; 44e21e245bSDavid S. Miller int index; 45e21e245bSDavid S. Miller 46e21e245bSDavid S. Miller int psupply_fan_on; 47e21e245bSDavid S. Miller int cpu_fan_speed; 48e21e245bSDavid S. Miller int system_fan_speed; 49e21e245bSDavid S. Miller }; 50e21e245bSDavid S. Miller 51e21e245bSDavid S. Miller #define NUM_CHILDREN 8 52e21e245bSDavid S. Miller 53e21e245bSDavid S. Miller struct bbc_i2c_bus { 54e21e245bSDavid S. Miller struct bbc_i2c_bus *next; 55e21e245bSDavid S. Miller int index; 56e21e245bSDavid S. Miller spinlock_t lock; 57e21e245bSDavid S. Miller void __iomem *i2c_bussel_reg; 58e21e245bSDavid S. Miller void __iomem *i2c_control_regs; 59e21e245bSDavid S. Miller unsigned char own, clock; 60e21e245bSDavid S. Miller 61e21e245bSDavid S. Miller wait_queue_head_t wq; 62e21e245bSDavid S. Miller volatile int waiting; 63e21e245bSDavid S. Miller 64e21e245bSDavid S. Miller struct list_head temps; 65e21e245bSDavid S. Miller struct list_head fans; 66e21e245bSDavid S. Miller 672dc11581SGrant Likely struct platform_device *op; 68e21e245bSDavid S. Miller struct { 692dc11581SGrant Likely struct platform_device *device; 70e21e245bSDavid S. Miller int client_claimed; 71e21e245bSDavid S. Miller } devs[NUM_CHILDREN]; 72e21e245bSDavid S. Miller }; 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds /* Probing and attachment. */ 752dc11581SGrant Likely extern struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *, int); 762dc11581SGrant Likely extern struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_device *); 771da177e4SLinus Torvalds extern void bbc_i2c_detach(struct bbc_i2c_client *); 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds /* Register read/write. NOTE: Blocking! */ 801da177e4SLinus Torvalds extern int bbc_i2c_writeb(struct bbc_i2c_client *, unsigned char val, int off); 811da177e4SLinus Torvalds extern int bbc_i2c_readb(struct bbc_i2c_client *, unsigned char *byte, int off); 821da177e4SLinus Torvalds extern int bbc_i2c_write_buf(struct bbc_i2c_client *, char *buf, int len, int off); 831da177e4SLinus Torvalds extern int bbc_i2c_read_buf(struct bbc_i2c_client *, char *buf, int len, int off); 841da177e4SLinus Torvalds 85*61fc8d40SUwe Kleine-König extern int bbc_envctrl_init(struct bbc_i2c_bus *bp); 86*61fc8d40SUwe Kleine-König extern void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp); 87*61fc8d40SUwe Kleine-König 881da177e4SLinus Torvalds #endif /* _BBC_I2C_H */ 89