| 1 | #!/bin/bash |
|---|
| 2 | # (C) Rudolf Marek <r.marek@assembler.cz>, |
|---|
| 3 | # Jean Delvare <khali@linux-fr.org> |
|---|
| 4 | # |
|---|
| 5 | # Thanks Jean Delvare and Oliver Dreier <oliver@dinux.de> 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 | # ICH2 8086:2440 |
|---|
| 14 | # ICH2-M 8086:244C |
|---|
| 15 | # ICH3 8086:2480 |
|---|
| 16 | # ICH3-M 8086:248C |
|---|
| 17 | # ICH4 8086:24C0 |
|---|
| 18 | # ICH4-M 8086:24CC |
|---|
| 19 | # ICH5 8086:24D0 |
|---|
| 20 | |
|---|
| 21 | pcibus="/sys/bus/pci/slots" |
|---|
| 22 | device="00:1f" |
|---|
| 23 | |
|---|
| 24 | if [ "$UID" -ne 0 ] ; then |
|---|
| 25 | echo "You need to be root to run this script!" |
|---|
| 26 | exit 252 |
|---|
| 27 | fi |
|---|
| 28 | |
|---|
| 29 | smbus=`lspci -n -s $device.3 | grep -i '0c05: *8086'` |
|---|
| 30 | if [ -n "$smbus" ] ; then |
|---|
| 31 | echo "ICH SMBus is already there!" |
|---|
| 32 | lspci -s $device.3 |
|---|
| 33 | exit |
|---|
| 34 | fi |
|---|
| 35 | |
|---|
| 36 | intel=`lspci -n -s $device.0 | grep -i '8086:24[48CD][0C]'` |
|---|
| 37 | if [ -z "$intel" ] ; then |
|---|
| 38 | echo "Not for your chipset - Intel (ICH) only" |
|---|
| 39 | echo "Supported: ICH2, ICH2-M, ICH3, ICH3-M, ICH4, ICH4-M, ICH5" |
|---|
| 40 | exit 255; |
|---|
| 41 | fi |
|---|
| 42 | modprobe fakephp &> /dev/null |
|---|
| 43 | |
|---|
| 44 | if [ ! -d "$pcibus" ] ; then |
|---|
| 45 | echo "You need the fake PCI hotplug driver! (fakephp.ko and 2.6 kernel)" |
|---|
| 46 | exit 255; |
|---|
| 47 | fi |
|---|
| 48 | |
|---|
| 49 | echo "Enabling SMBus PCI device ..." |
|---|
| 50 | |
|---|
| 51 | newval=$( printf '%x' $((0x$(setpci -s $device.0 f2.w) & 0xfff7))) |
|---|
| 52 | setpci -s $device.0 f2.w=$newval |
|---|
| 53 | |
|---|
| 54 | echo "Rescanning the bus ..." |
|---|
| 55 | echo 1 > $pcibus/0000:$device.0/power 2>/dev/null |
|---|
| 56 | if [ ! -d "$pcibus/0000:$device.3" ] ; then |
|---|
| 57 | echo "Failed to enable the SMBUS" |
|---|
| 58 | exit 253; |
|---|
| 59 | fi |
|---|
| 60 | |
|---|
| 61 | if [ ! -d "/sys/bus/pci/drivers/i801_smbus" ] ; then |
|---|
| 62 | echo "Loading i2c-i801 ..." |
|---|
| 63 | modprobe i2c-i801 |
|---|
| 64 | if [ $? -ne 0 ] ; then |
|---|
| 65 | exit 251 |
|---|
| 66 | fi |
|---|
| 67 | fi |
|---|
| 68 | |
|---|
| 69 | lspci -s $device.3 |
|---|
| 70 | echo "Done!" |
|---|
| 71 | echo "Remember: system suspend/resume is no longer safe to use." |
|---|