Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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