diff -u orig-kernel/therm_pm72.c old-kernel/therm_pm72.c --- orig-kernel/drivers/macintosh/therm_pm72.c 2004-08-05 14:12:18.000000000 +0200 +++ old-kernel/drivers/macintosh/therm_pm72.c 2004-08-05 15:20:16.000000000 +0200 @@ -73,6 +73,9 @@ * values in the configuration register * - Switch back to use of target fan speed for PID, thus lowering * pressure on i2c + * Aug. 05, 2004: 0.91 + * - Harald Welte : + * - add minimal support for XServe G5 */ #include @@ -101,9 +104,9 @@ #include "therm_pm72.h" -#define VERSION "0.9" +#define VERSION "0.91" -#undef DEBUG +#define DEBUG #ifdef DEBUG #define DBG(args...) printk(args) @@ -509,10 +514,7 @@ DBG("cpu %d:\n", state->index); /* Read current fan status */ - if (state->index == 0) - rc = get_rpm_fan(CPUA_EXHAUST_FAN_RPM_ID, !RPM_PID_USE_ACTUAL_SPEED); - else - rc = get_rpm_fan(CPUB_EXHAUST_FAN_RPM_ID, !RPM_PID_USE_ACTUAL_SPEED); + rc = get_rpm_fan(state->exhaust_fan_id, !RPM_PID_USE_ACTUAL_SPEED); if (rc < 0) { printk(KERN_WARNING "Error %d reading CPU %d exhaust fan !\n", rc, state->index); @@ -662,12 +664,15 @@ * failures (-EFAULT) we probably want to notify userland * some way... */ - if (state->index == 0) { - set_rpm_fan(CPUA_INTAKE_FAN_RPM_ID, intake); - set_rpm_fan(CPUA_EXHAUST_FAN_RPM_ID, state->rpm); - } else { - set_rpm_fan(CPUB_INTAKE_FAN_RPM_ID, intake); - set_rpm_fan(CPUB_EXHAUST_FAN_RPM_ID, state->rpm); + set_rpm_fan(state->intake_fan_id, intake); + set_rpm_fan(state->exhaust_fan_id, state->rpm); + + /* ugly hack */ + if (machine_is_compatible("RackMac3,1")) { + if (state->index == 0) + set_rpm_fan(2, state->rpm); + else + set_rpm_fan(5, state->rpm); } } @@ -699,6 +704,24 @@ } DBG("CPU %d Using %d power history entries\n", index, state->count_power); + if (machine_is_compatible("PowerMac7,2")) { + if (index == 0) { + state->intake_fan_id = 3; + state->exhaust_fan_id = 4; + } else { + state->intake_fan_id = 5; + state->exhaust_fan_id = 6; + } + } else { + /* RackMac 3,1 */ + if (index == 0) { + state->intake_fan_id = 3; /* right */ + state->exhaust_fan_id = 1; /* left */ + } else { + state->intake_fan_id = 4; /* left */ + state->exhaust_fan_id = 6; /* right */ + } + } if (index == 0) { device_create_file(&of_dev->dev, &dev_attr_cpu0_temperature); device_create_file(&of_dev->dev, &dev_attr_cpu0_voltage); @@ -772,6 +795,7 @@ state->pwm = rc; DBG(" current pwm: %d\n", state->pwm); + if (machine_is_compatible("PowerMac7,2")) { /* Get some sensor readings */ temp = i2c_smbus_read_byte_data(state->monitor, MAX6690_EXT_TEMP) << 16; state->last_temp = temp; @@ -829,6 +853,8 @@ state->pwm = BACKSIDE_PID_OUTPUT_MIN; if (state->pwm > BACKSIDE_PID_OUTPUT_MAX) state->pwm = BACKSIDE_PID_OUTPUT_MAX; + } else + state->pwm = 40; DBG("** BACKSIDE PWM: %d\n", (int)state->pwm); set_pwm_fan(BACKSIDE_FAN_PWM_ID, state->pwm); @@ -843,11 +869,16 @@ state->first = 1; state->pwm = 50; - state->monitor = attach_i2c_chip(BACKSIDE_MAX_ID, "backside_temp"); - if (state->monitor == NULL) - return -ENODEV; + if (machine_is_compatible("PowerMac7,2")) { + state->monitor = attach_i2c_chip(BACKSIDE_MAX_ID, + "backside_temp"); + if (state->monitor == NULL) + return -ENODEV; + + device_create_file(&of_dev->dev, + &dev_attr_backside_temperature); + } - device_create_file(&of_dev->dev, &dev_attr_backside_temperature); device_create_file(&of_dev->dev, &dev_attr_backside_fan_pwm); return 0; @@ -860,11 +891,13 @@ { if (state->monitor == NULL) return; - - device_remove_file(&of_dev->dev, &dev_attr_backside_temperature); + if (machine_is_compatible("PowerMac7,2")) { + device_remove_file(&of_dev->dev, + &dev_attr_backside_temperature); + detach_i2c_chip(state->monitor); + } device_remove_file(&of_dev->dev, &dev_attr_backside_fan_pwm); - detach_i2c_chip(state->monitor); state->monitor = NULL; } @@ -1031,7 +1064,9 @@ if (cpu_state[1].monitor != NULL) do_monitor_cpu(&cpu_state[1]); do_monitor_backside(&backside_state); - do_monitor_drives(&drives_state); + if (machine_is_compatible("PowerMac7,2")) { + do_monitor_drives(&drives_state); + } up(&driver_lock); if (critical_state == 1) { @@ -1070,9 +1105,11 @@ { dispose_cpu_state(&cpu_state[0]); dispose_cpu_state(&cpu_state[1]); - dispose_backside_state(&backside_state); - dispose_drives_state(&drives_state); + + if (machine_is_compatible("PowerMac7,2")) { + dispose_drives_state(&drives_state); + } } /* @@ -1101,8 +1138,11 @@ goto fail; if (init_backside_state(&backside_state)) goto fail; - if (init_drives_state(&drives_state)) - goto fail; + + if (machine_is_compatible("PowerMac7,2")) { + if (init_drives_state(&drives_state)) + goto fail; + } DBG("all control loops up !\n"); @@ -1280,7 +1320,8 @@ { struct device_node *np; - if (!machine_is_compatible("PowerMac7,2")) + if (!machine_is_compatible("PowerMac7,2") && + !machine_is_compatible("RackMac3,1")) return -ENODEV; printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION); @@ -1313,6 +1354,6 @@ module_exit(therm_pm72_exit); MODULE_AUTHOR("Benjamin Herrenschmidt "); -MODULE_DESCRIPTION("Driver for Apple's PowerMac7,2 G5 thermal control"); +MODULE_DESCRIPTION("Driver for Apple's PowerMac7,2 / RackMac3,1 G5 thermal control"); MODULE_LICENSE("GPL"); diff -u orig-kernel/therm_pm72.h old-kernel/therm_pm72.h --- orig-kernel/drivers/macintosh/therm_pm72.h 2004-08-05 14:12:18.000000000 +0200 +++ old-kernel/drivers/macintosh/therm_pm72.h 2004-08-05 15:20:16.000000000 +0200 @@ -191,11 +191,6 @@ * CPU B FAKE POWER 49 (I_V_inputs: 18, 19) */ -#define CPUA_INTAKE_FAN_RPM_ID 3 -#define CPUA_EXHAUST_FAN_RPM_ID 4 -#define CPUB_INTAKE_FAN_RPM_ID 5 -#define CPUB_EXHAUST_FAN_RPM_ID 6 - #define CPU_INTAKE_SCALE 0x0000f852 #define CPU_TEMP_HISTORY_SIZE 2 #define CPU_POWER_HISTORY_SIZE 10 @@ -221,6 +216,8 @@ s32 last_temp; int first; u8 adc_config; + int exhaust_fan_id; + int intake_fan_id; }; /*