| 1 |
#!/bin/bash |
| 2 |
# (C) Rudolf Marek <[email protected]>, |
| 3 |
# Copyright (C) 2007-2011 Jean Delvare <[email protected]> |
| 4 |
# |
| 5 |
# Thanks Jean Delvare and Oliver Dreier <[email protected]> for testing. |
| 6 |
# |
| 7 |
# This program is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License version 2 |
| 9 |
# as published by the Free Software Foundation |
| 10 |
# |
| 11 |
# Supports the following Intel ICH chipsets: |
| 12 |
# PCI ID |
| 13 |
# ICH 8086:2410 |
| 14 |
# ICH2 8086:2440 |
| 15 |
# ICH2-M 8086:244C |
| 16 |
# ICH3 8086:2480 |
| 17 |
# ICH3-M 8086:248C |
| 18 |
# ICH4 8086:24C0 |
| 19 |
# ICH4-M 8086:24CC |
| 20 |
# ICH5 8086:24D0 |
| 21 |
|
| 22 |
pcibus="/sys/bus/pci/slots" |
| 23 |
device="00:1f" |
| 24 |
|
| 25 |
if [ "$UID" -ne 0 ] ; then |
| 26 |
echo "You need to be root to run this script!" |
| 27 |
exit 252 |
| 28 |
fi |
| 29 |
|
| 30 |
smbus=`lspci -n -s $device.3 | grep -i '0c05: *8086'` |
| 31 |
if [ -n "$smbus" ] ; then |
| 32 |
echo "ICH SMBus is already there!" |
| 33 |
lspci -s $device.3 |
| 34 |
exit |
| 35 |
fi |
| 36 |
|
| 37 |
intel=`lspci -n -s $device.0 | grep -i '8086:24[148CD][0C]'` |
| 38 |
if [ -z "$intel" ] ; then |
| 39 |
echo "Not for your chipset - Intel (ICH) only" |
| 40 |
echo "Supported: ICH, ICH2, ICH2-M, ICH3, ICH3-M, ICH4, ICH4-M, ICH5" |
| 41 |
exit 255; |
| 42 |
fi |
| 43 |
modprobe fakephp &> /dev/null |
| 44 |
|
| 45 |
if [ ! -d "$pcibus" ] ; then |
| 46 |
echo "You need the fake PCI hotplug driver! (fakephp.ko, kernel 2.6.5 or later)" |
| 47 |
exit 255; |
| 48 |
fi |
| 49 |
|
| 50 |
echo "Enabling SMBus PCI device ..." |
| 51 |
|
| 52 |
newval=$( printf '%x' $((0x$(setpci -s $device.0 f2.w) & 0xfff7))) |
| 53 |
setpci -s $device.0 f2.w=$newval |
| 54 |
|
| 55 |
echo "Rescanning the bus ..." |
| 56 |
echo 1 > $pcibus/0000:$device.0/power 2>/dev/null |
| 57 |
if [ ! -d "$pcibus/0000:$device.3" ] ; then |
| 58 |
echo "Failed to enable the SMBUS" |
| 59 |
exit 253; |
| 60 |
fi |
| 61 |
|
| 62 |
if [ ! -d "/sys/bus/pci/drivers/i801_smbus" ] ; then |
| 63 |
echo "Loading i2c-i801 ..." |
| 64 |
modprobe i2c-i801 |
| 65 |
if [ $? -ne 0 ] ; then |
| 66 |
exit 251 |
| 67 |
fi |
| 68 |
fi |
| 69 |
|
| 70 |
lspci -s $device.3 |
| 71 |
echo "Done!" |
| 72 |
echo "Remember: system suspend/resume is no longer safe to use." |