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-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Windfarm PowerMac thermal control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2012 Benjamin Herrenschmidt, IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #ifndef __WINDFARM_MPU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define __WINDFARM_MPU_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) typedef unsigned short fu16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) typedef int fs32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) typedef short fs16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* Definition of the MPU data structure which contains per CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * calibration information (among others) for the G5 machines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct mpu_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	u8	signature;		/* 0x00 - EEPROM sig. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	u8	bytes_used;		/* 0x01 - Bytes used in eeprom (160 ?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	u8	size;			/* 0x02 - EEPROM size (256 ?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	u8	version;		/* 0x03 - EEPROM version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	u32	data_revision;		/* 0x04 - Dataset revision */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	u8	processor_bin_code[3];	/* 0x08 - Processor BIN code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	u8	bin_code_expansion;	/* 0x0b - ??? (padding ?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	u8	processor_num;		/* 0x0c - Number of CPUs on this MPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u8	input_mul_bus_div;	/* 0x0d - Clock input multiplier/bus divider */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	u8	reserved1[2];		/* 0x0e - */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u32	input_clk_freq_high;	/* 0x10 - Input clock frequency high */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u8	cpu_nb_target_cycles;	/* 0x14 - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u8	cpu_statlat;		/* 0x15 - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	u8	cpu_snooplat;		/* 0x16 - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u8	cpu_snoopacc;		/* 0x17 - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u8	nb_paamwin;		/* 0x18 - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	u8	nb_statlat;		/* 0x19 - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	u8	nb_snooplat;		/* 0x1a - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u8	nb_snoopwin;		/* 0x1b - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u8	api_bus_mode;		/* 0x1c - ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	u8	reserved2[3];		/* 0x1d - */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	u32	input_clk_freq_low;	/* 0x20 - Input clock frequency low */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	u8	processor_card_slot;	/* 0x24 - Processor card slot number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	u8	reserved3[2];		/* 0x25 - */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u8	padjmax;       		/* 0x27 - Max power adjustment (Not in OF!) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	u8	ttarget;		/* 0x28 - Target temperature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u8	tmax;			/* 0x29 - Max temperature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u8	pmaxh;			/* 0x2a - Max power */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u8	tguardband;		/* 0x2b - Guardband temp ??? Hist. len in OSX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	fs32	pid_gp;			/* 0x2c - PID proportional gain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	fs32	pid_gr;			/* 0x30 - PID reset gain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	fs32	pid_gd;			/* 0x34 - PID derivative gain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	fu16	voph;			/* 0x38 - Vop High */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	fu16	vopl;			/* 0x3a - Vop Low */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	fs16	nactual_die;		/* 0x3c - nActual Die */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	fs16	nactual_heatsink;	/* 0x3e - nActual Heatsink */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	fs16	nactual_system;		/* 0x40 - nActual System */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u16	calibration_flags;	/* 0x42 - Calibration flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	fu16	mdiode;			/* 0x44 - Diode M value (scaling factor) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	fs16	bdiode;			/* 0x46 - Diode B value (offset) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	fs32	theta_heat_sink;	/* 0x48 - Theta heat sink */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	u16	rminn_intake_fan;	/* 0x4c - Intake fan min RPM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	u16	rmaxn_intake_fan;	/* 0x4e - Intake fan max RPM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	u16	rminn_exhaust_fan;	/* 0x50 - Exhaust fan min RPM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u16	rmaxn_exhaust_fan;	/* 0x52 - Exhaust fan max RPM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u8	processor_part_num[8];	/* 0x54 - Processor part number XX pumps min/max */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u32	processor_lot_num;	/* 0x5c - Processor lot number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	u8	orig_card_sernum[0x10];	/* 0x60 - Card original serial number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	u8	curr_card_sernum[0x10];	/* 0x70 - Card current serial number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u8	mlb_sernum[0x18];	/* 0x80 - MLB serial number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u32	checksum1;		/* 0x98 - */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	u32	checksum2;		/* 0x9c - */	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }; /* Total size = 0xa0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static inline const struct mpu_data *wf_get_mpu(int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	char nodename[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	const void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 * prom.c routine for finding a node by path is a bit brain dead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * and requires exact @xxx unit numbers. This is a bit ugly but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 * will work for these machines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	sprintf(nodename, "/u3@0,f8000000/i2c@f8001000/cpuid@a%d", cpu ? 2 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	np = of_find_node_by_path(nodename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	data = of_get_property(np, "cpuid", &len);	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * We are naughty, we have dropped the reference to the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 * node and still return a pointer to the content. We know we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 * can do that though as this is only ever called on PowerMac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 * which cannot remove those nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif /*  __WINDFARM_MPU_H */