~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/macintosh/therm_pm72.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
#include <linux/kernel.h>
115
115
#include <linux/delay.h>
116
116
#include <linux/sched.h>
117
 
#include <linux/slab.h>
118
117
#include <linux/init.h>
119
118
#include <linux/spinlock.h>
120
119
#include <linux/wait.h>
149
148
 * Driver statics
150
149
 */
151
150
 
152
 
static struct of_device *               of_dev;
 
151
static struct platform_device *         of_dev;
153
152
static struct i2c_adapter *             u3_0;
154
153
static struct i2c_adapter *             u3_1;
155
154
static struct i2c_adapter *             k2;
444
443
        tries = 0;
445
444
        for (;;) {
446
445
                nr = i2c_master_recv(fcu, buf, nb);
447
 
                if (nr > 0 || (nr < 0 && nr != ENODEV) || tries >= 100)
 
446
                if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
448
447
                        break;
449
448
                msleep(10);
450
449
                ++tries;
465
464
        tries = 0;
466
465
        for (;;) {
467
466
                nw = i2c_master_send(fcu, buf, nb);
468
 
                if (nw > 0 || (nw < 0 && nw != EIO) || tries >= 100)
 
467
                if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
469
468
                        break;
470
469
                msleep(10);
471
470
                ++tries;
948
947
                printk(KERN_WARNING "Warning ! Temperature way above maximum (%d) !\n",
949
948
                       temp_combi >> 16);
950
949
                state0->overtemp += CPU_MAX_OVERTEMP / 4;
951
 
        } else if (temp_combi > (state0->mpu.tmax << 16))
 
950
        } else if (temp_combi > (state0->mpu.tmax << 16)) {
952
951
                state0->overtemp++;
953
 
        else
 
952
                printk(KERN_WARNING "Temperature %d above max %d. overtemp %d\n",
 
953
                       temp_combi >> 16, state0->mpu.tmax, state0->overtemp);
 
954
        } else {
 
955
                if (state0->overtemp)
 
956
                        printk(KERN_WARNING "Temperature back down to %d\n",
 
957
                               temp_combi >> 16);
954
958
                state0->overtemp = 0;
 
959
        }
955
960
        if (state0->overtemp >= CPU_MAX_OVERTEMP)
956
961
                critical_state = 1;
957
962
        if (state0->overtemp > 0) {
1023
1028
                       " (%d) !\n",
1024
1029
                       state->index, temp >> 16);
1025
1030
                state->overtemp += CPU_MAX_OVERTEMP / 4;
1026
 
        } else if (temp > (state->mpu.tmax << 16))
 
1031
        } else if (temp > (state->mpu.tmax << 16)) {
1027
1032
                state->overtemp++;
1028
 
        else
 
1033
                printk(KERN_WARNING "CPU %d temperature %d above max %d. overtemp %d\n",
 
1034
                       state->index, temp >> 16, state->mpu.tmax, state->overtemp);
 
1035
        } else {
 
1036
                if (state->overtemp)
 
1037
                        printk(KERN_WARNING "CPU %d temperature back down to %d\n",
 
1038
                               state->index, temp >> 16);
1029
1039
                state->overtemp = 0;
 
1040
        }
1030
1041
        if (state->overtemp >= CPU_MAX_OVERTEMP)
1031
1042
                critical_state = 1;
1032
1043
        if (state->overtemp > 0) {
1085
1096
                       " (%d) !\n",
1086
1097
                       state->index, temp >> 16);
1087
1098
                state->overtemp = CPU_MAX_OVERTEMP / 4;
1088
 
        } else if (temp > (state->mpu.tmax << 16))
 
1099
        } else if (temp > (state->mpu.tmax << 16)) {
1089
1100
                state->overtemp++;
1090
 
        else
 
1101
                printk(KERN_WARNING "CPU %d temperature %d above max %d. overtemp %d\n",
 
1102
                       state->index, temp >> 16, state->mpu.tmax, state->overtemp);
 
1103
        } else {
 
1104
                if (state->overtemp)
 
1105
                        printk(KERN_WARNING "CPU %d temperature back down to %d\n",
 
1106
                               state->index, temp >> 16);
1091
1107
                state->overtemp = 0;
 
1108
        }
1092
1109
        if (state->overtemp >= CPU_MAX_OVERTEMP)
1093
1110
                critical_state = 1;
1094
1111
        if (state->overtemp > 0) {
1899
1916
         */
1900
1917
        if (rackmac)
1901
1918
                cpu_pid_type = CPU_PID_TYPE_RACKMAC;
1902
 
        else if (machine_is_compatible("PowerMac7,3")
 
1919
        else if (of_machine_is_compatible("PowerMac7,3")
1903
1920
            && (cpu_count > 1)
1904
1921
            && fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID
1905
1922
            && fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) {
2193
2210
        }
2194
2211
}
2195
2212
 
2196
 
static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match)
 
2213
static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match)
2197
2214
{
2198
2215
        state = state_detached;
 
2216
        of_dev = dev;
 
2217
 
 
2218
        dev_info(&dev->dev, "PowerMac G5 Thermal control driver %s\n", VERSION);
2199
2219
 
2200
2220
        /* Lookup the fans in the device tree */
2201
 
        fcu_lookup_fans(dev->node);
 
2221
        fcu_lookup_fans(dev->dev.of_node);
2202
2222
 
2203
2223
        /* Add the driver */
2204
2224
        return i2c_add_driver(&therm_pm72_driver);
2205
2225
}
2206
2226
 
2207
 
static int fcu_of_remove(struct of_device* dev)
 
2227
static int fcu_of_remove(struct platform_device* dev)
2208
2228
{
2209
2229
        i2c_del_driver(&therm_pm72_driver);
2210
2230
 
2211
2231
        return 0;
2212
2232
}
2213
2233
 
2214
 
static struct of_device_id fcu_match[] = 
 
2234
static const struct of_device_id fcu_match[] = 
2215
2235
{
2216
2236
        {
2217
2237
        .type           = "fcu",
2218
2238
        },
2219
2239
        {},
2220
2240
};
 
2241
MODULE_DEVICE_TABLE(of, fcu_match);
2221
2242
 
2222
2243
static struct of_platform_driver fcu_of_platform_driver = 
2223
2244
{
2224
 
        .name           = "temperature",
2225
 
        .match_table    = fcu_match,
 
2245
        .driver = {
 
2246
                .name = "temperature",
 
2247
                .owner = THIS_MODULE,
 
2248
                .of_match_table = fcu_match,
 
2249
        },
2226
2250
        .probe          = fcu_of_probe,
2227
2251
        .remove         = fcu_of_remove
2228
2252
};
2232
2256
 */
2233
2257
static int __init therm_pm72_init(void)
2234
2258
{
2235
 
        struct device_node *np;
2236
 
 
2237
 
        rackmac = machine_is_compatible("RackMac3,1");
2238
 
 
2239
 
        if (!machine_is_compatible("PowerMac7,2") &&
2240
 
            !machine_is_compatible("PowerMac7,3") &&
 
2259
        rackmac = of_machine_is_compatible("RackMac3,1");
 
2260
 
 
2261
        if (!of_machine_is_compatible("PowerMac7,2") &&
 
2262
            !of_machine_is_compatible("PowerMac7,3") &&
2241
2263
            !rackmac)
2242
2264
                return -ENODEV;
2243
2265
 
2244
 
        printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION);
2245
 
 
2246
 
        np = of_find_node_by_type(NULL, "fcu");
2247
 
        if (np == NULL) {
2248
 
                /* Some machines have strangely broken device-tree */
2249
 
                np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
2250
 
                if (np == NULL) {
2251
 
                            printk(KERN_ERR "Can't find FCU in device-tree !\n");
2252
 
                            return -ENODEV;
2253
 
                }
2254
 
        }
2255
 
        of_dev = of_platform_device_create(np, "temperature", NULL);
2256
 
        if (of_dev == NULL) {
2257
 
                printk(KERN_ERR "Can't register FCU platform device !\n");
2258
 
                return -ENODEV;
2259
 
        }
2260
 
 
2261
 
        of_register_platform_driver(&fcu_of_platform_driver);
2262
 
        
2263
 
        return 0;
 
2266
        return of_register_platform_driver(&fcu_of_platform_driver);
2264
2267
}
2265
2268
 
2266
2269
static void __exit therm_pm72_exit(void)
2267
2270
{
2268
2271
        of_unregister_platform_driver(&fcu_of_platform_driver);
2269
 
 
2270
 
        if (of_dev)
2271
 
                of_device_unregister(of_dev);
2272
2272
}
2273
2273
 
2274
2274
module_init(therm_pm72_init);