Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Windfarm PowerMac thermal control
0004  *
0005  * Copyright 2012 Benjamin Herrenschmidt, IBM Corp.
0006  */
0007 
0008 #ifndef __WINDFARM_MPU_H
0009 #define __WINDFARM_MPU_H
0010 
0011 #include <linux/of.h>
0012 
0013 typedef unsigned short fu16;
0014 typedef int fs32;
0015 typedef short fs16;
0016 
0017 /* Definition of the MPU data structure which contains per CPU
0018  * calibration information (among others) for the G5 machines
0019  */
0020 struct mpu_data
0021 {
0022     u8  signature;      /* 0x00 - EEPROM sig. */
0023     u8  bytes_used;     /* 0x01 - Bytes used in eeprom (160 ?) */
0024     u8  size;           /* 0x02 - EEPROM size (256 ?) */
0025     u8  version;        /* 0x03 - EEPROM version */
0026     u32 data_revision;      /* 0x04 - Dataset revision */
0027     u8  processor_bin_code[3];  /* 0x08 - Processor BIN code */
0028     u8  bin_code_expansion; /* 0x0b - ??? (padding ?) */
0029     u8  processor_num;      /* 0x0c - Number of CPUs on this MPU */
0030     u8  input_mul_bus_div;  /* 0x0d - Clock input multiplier/bus divider */
0031     u8  reserved1[2];       /* 0x0e - */
0032     u32 input_clk_freq_high;    /* 0x10 - Input clock frequency high */
0033     u8  cpu_nb_target_cycles;   /* 0x14 - ??? */
0034     u8  cpu_statlat;        /* 0x15 - ??? */
0035     u8  cpu_snooplat;       /* 0x16 - ??? */
0036     u8  cpu_snoopacc;       /* 0x17 - ??? */
0037     u8  nb_paamwin;     /* 0x18 - ??? */
0038     u8  nb_statlat;     /* 0x19 - ??? */
0039     u8  nb_snooplat;        /* 0x1a - ??? */
0040     u8  nb_snoopwin;        /* 0x1b - ??? */
0041     u8  api_bus_mode;       /* 0x1c - ??? */
0042     u8  reserved2[3];       /* 0x1d - */
0043     u32 input_clk_freq_low; /* 0x20 - Input clock frequency low */
0044     u8  processor_card_slot;    /* 0x24 - Processor card slot number */
0045     u8  reserved3[2];       /* 0x25 - */
0046     u8  padjmax;            /* 0x27 - Max power adjustment (Not in OF!) */
0047     u8  ttarget;        /* 0x28 - Target temperature */
0048     u8  tmax;           /* 0x29 - Max temperature */
0049     u8  pmaxh;          /* 0x2a - Max power */
0050     u8  tguardband;     /* 0x2b - Guardband temp ??? Hist. len in OSX */
0051     fs32    pid_gp;         /* 0x2c - PID proportional gain */
0052     fs32    pid_gr;         /* 0x30 - PID reset gain */
0053     fs32    pid_gd;         /* 0x34 - PID derivative gain */
0054     fu16    voph;           /* 0x38 - Vop High */
0055     fu16    vopl;           /* 0x3a - Vop Low */
0056     fs16    nactual_die;        /* 0x3c - nActual Die */
0057     fs16    nactual_heatsink;   /* 0x3e - nActual Heatsink */
0058     fs16    nactual_system;     /* 0x40 - nActual System */
0059     u16 calibration_flags;  /* 0x42 - Calibration flags */
0060     fu16    mdiode;         /* 0x44 - Diode M value (scaling factor) */
0061     fs16    bdiode;         /* 0x46 - Diode B value (offset) */
0062     fs32    theta_heat_sink;    /* 0x48 - Theta heat sink */
0063     u16 rminn_intake_fan;   /* 0x4c - Intake fan min RPM */
0064     u16 rmaxn_intake_fan;   /* 0x4e - Intake fan max RPM */
0065     u16 rminn_exhaust_fan;  /* 0x50 - Exhaust fan min RPM */
0066     u16 rmaxn_exhaust_fan;  /* 0x52 - Exhaust fan max RPM */
0067     u8  processor_part_num[8];  /* 0x54 - Processor part number XX pumps min/max */
0068     u32 processor_lot_num;  /* 0x5c - Processor lot number */
0069     u8  orig_card_sernum[0x10]; /* 0x60 - Card original serial number */
0070     u8  curr_card_sernum[0x10]; /* 0x70 - Card current serial number */
0071     u8  mlb_sernum[0x18];   /* 0x80 - MLB serial number */
0072     u32 checksum1;      /* 0x98 - */
0073     u32 checksum2;      /* 0x9c - */    
0074 }; /* Total size = 0xa0 */
0075 
0076 static inline const struct mpu_data *wf_get_mpu(int cpu)
0077 {
0078     struct device_node *np;
0079     char nodename[64];
0080     const void *data;
0081     int len;
0082 
0083     /*
0084      * prom.c routine for finding a node by path is a bit brain dead
0085      * and requires exact @xxx unit numbers. This is a bit ugly but
0086      * will work for these machines
0087      */
0088     sprintf(nodename, "/u3@0,f8000000/i2c@f8001000/cpuid@a%d", cpu ? 2 : 0);
0089     np = of_find_node_by_path(nodename);
0090     if (!np)
0091         return NULL;
0092     data = of_get_property(np, "cpuid", &len);  
0093     of_node_put(np);
0094     if (!data)
0095         return NULL;
0096 
0097     /*
0098      * We are naughty, we have dropped the reference to the device
0099      * node and still return a pointer to the content. We know we
0100      * can do that though as this is only ever called on PowerMac
0101      * which cannot remove those nodes
0102      */
0103     return data;
0104 }
0105 
0106 #endif /*  __WINDFARM_MPU_H */