3535#define DRVNAME "as7535_28xb_thermal"
3636#define ACCTON_IPMI_NETFN 0x34
3737#define IPMI_THERMAL_READ_CMD 0x12
38+ #define IPMI_FPGA_READ_CMD 0x22
3839
3940#define IPMI_TIMEOUT (5 * HZ)
4041#define IPMI_ERR_RETRY_TIMES 1
@@ -47,6 +48,9 @@ static ssize_t set_max(struct device *dev, struct device_attribute *da,
4748static int as7535_28xb_thermal_probe (struct platform_device * pdev );
4849static int as7535_28xb_thermal_remove (struct platform_device * pdev );
4950
51+ static int get_pcb_id (void );
52+ static int g_pcb_id = 0 ;
53+
5054enum temp_data_index {
5155 TEMP_ADDR ,
5256 TEMP_FAULT ,
@@ -95,17 +99,21 @@ static struct platform_driver as7535_28xb_thermal_driver = {
9599
96100enum as7535_28xb_thermal_sysfs_attrs {
97101 TEMP1_INPUT , // 0x4B
98- TEMP2_INPUT , // 0x4C tmp43 local
99- TEMP3_INPUT , // 0x4C tmp43 remote
102+ TEMP2_INPUT , // TMP431_0x4C_U50
103+ TEMP3_INPUT , // TMP431_0x4C_MAC
100104 TEMP4_INPUT , // 0x4D lm75
101105 TEMP5_INPUT , // 0x4E lm75
102106 TEMP6_INPUT , // 0x4F lm75
107+ TEMP7_INPUT , // TMP431_0x4C_U93
108+ TEMP8_INPUT , // TMP431_0x4C_C10
103109 TEMP1_MAX ,
104110 TEMP2_MAX ,
105111 TEMP3_MAX ,
106112 TEMP4_MAX ,
107113 TEMP5_MAX ,
108- TEMP6_MAX
114+ TEMP6_MAX ,
115+ TEMP7_MAX ,
116+ TEMP8_MAX
109117};
110118
111119// Read only temp_input
@@ -125,6 +133,8 @@ DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R(3);
125133DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R (4 );
126134DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R (5 );
127135DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R (6 );
136+ DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R (7 );
137+ DECLARE_THERMAL_SENSOR_DEVICE_ATTR_R (8 );
128138
129139static struct attribute * as7535_28xb_thermal_attributes [] = {
130140 DECLARE_THERMAL_ATTR (1 ),
@@ -133,6 +143,8 @@ static struct attribute *as7535_28xb_thermal_attributes[] = {
133143 DECLARE_THERMAL_ATTR (4 ),
134144 DECLARE_THERMAL_ATTR (5 ),
135145 DECLARE_THERMAL_ATTR (6 ),
146+ DECLARE_THERMAL_ATTR (7 ),
147+ DECLARE_THERMAL_ATTR (8 ),
136148 NULL
137149};
138150
@@ -276,28 +288,63 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
276288 complete (& ipmi -> read_complete );
277289}
278290
291+ static int get_pcb_id (void )
292+ {
293+ int status = 0 ;
294+ int pcb_id = 0 ;
295+ /* Get PCB ID */
296+ data -> ipmi_tx_data [0 ] = 0x60 ;
297+ data -> ipmi_tx_data [1 ] = 0x0 ;
298+ status = ipmi_send_message (& data -> ipmi , IPMI_FPGA_READ_CMD , data -> ipmi_tx_data , 2 ,
299+ data -> ipmi_resp , sizeof (data -> ipmi_resp ));
300+ if (unlikely (status != 0 ))
301+ goto exit ;
302+
303+ if (unlikely (data -> ipmi .rx_result != 0 )) {
304+ status = - EIO ;
305+ goto exit ;
306+ }
307+ /* (bit 3, bit 2) 00: No C10+IDT, 01: CY10+IDT, 10: no CY10+microchip, 11: CY10+microchip
308+ Support 8 thermals for CY10+IDT */
309+ pcb_id = (((s8 )data -> ipmi_resp [0 ]) >> 2 ) & 0xff ;
310+ return pcb_id ;
311+
312+ exit :
313+ return status ;
314+ }
315+
279316static ssize_t show_temp (struct device * dev , struct device_attribute * da ,
280317 char * buf )
281318{
282319 int status = 0 ;
283320 int index = 0 ;
284321 struct sensor_device_attribute * attr = to_sensor_dev_attr (da );
285-
286322 mutex_lock (& data -> update_lock );
287-
288- if (attr -> index >= TEMP1_MAX && attr -> index <= TEMP6_MAX ) {
323+ if (attr -> index >= TEMP1_MAX && attr -> index <= TEMP8_MAX ) {
289324 int max = data -> temp_max [attr -> index - TEMP1_MAX ];
290325 mutex_unlock (& data -> update_lock );
291326 return sprintf (buf , "%d\n" , max * 1000 );
292327 }
328+ /* Set 0 to Temp 7 and 8 if pcb id is not 01: CY10+IDT */
329+ if (g_pcb_id != 1 )
330+ {
331+ if ((attr -> index == TEMP7_INPUT ) || (attr -> index == TEMP8_INPUT ))
332+ {
333+ status = 0 ;
334+ mutex_unlock (& data -> update_lock );
335+ return sprintf (buf , "%d\n" , status );
336+ }
337+ }
293338
294339 if (time_after (jiffies , data -> last_updated + HZ * 5 ) || !data -> valid ) {
295340 data -> valid = 0 ;
296341
297342 status = ipmi_send_message (& data -> ipmi , IPMI_THERMAL_READ_CMD , NULL , 0 ,
298343 data -> ipmi_resp , sizeof (data -> ipmi_resp ));
299344 if (unlikely (status != 0 ))
345+ {
300346 goto exit ;
347+ }
301348
302349 if (unlikely (data -> ipmi .rx_result != 0 )) {
303350 status = - EIO ;
@@ -307,14 +354,12 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
307354 data -> last_updated = jiffies ;
308355 data -> valid = 1 ;
309356 }
310-
311357 /* Get temp fault status */
312358 index = attr -> index * TEMP_DATA_COUNT + TEMP_FAULT ;
313359 if (unlikely (data -> ipmi_resp [index ] == 0 )) {
314360 status = - EIO ;
315361 goto exit ;
316362 }
317-
318363 /* Get temperature in degree celsius */
319364 index = attr -> index * TEMP_DATA_COUNT + TEMP_INPUT ;
320365 status = ((s8 )data -> ipmi_resp [index ]) * 1000 ;
@@ -402,6 +447,8 @@ static int __init as7535_28xb_thermal_init(void)
402447 data -> temp_max [i ] = 70 ; /* default high threshold */
403448 }
404449
450+ g_pcb_id = get_pcb_id ();
451+
405452 return 0 ;
406453
407454ipmi_err :
0 commit comments