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