-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
xmm2usb
executable file
·45 lines (30 loc) · 1.02 KB
/
xmm2usb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
die() {
echo "ERROR ${1}" >&2
exit 1
}
[ "$(whoami)" = "root" ] || die "must be run as root"
for path in `find /sys/devices/pci0000:00 -name vendor`; do
path="${path%/vendor}"
[ -e "${path}/device" ] || continue
read -r vendor < "${path}/vendor" || continue
read -r device < "${path}/device" || continue
[ "${vendor}" = 0x8086 -a "${device}" = 0x7360 ] || continue
modem_id=${path##*/}
read -r acpi_path < "${path}/firmware_node/path" || \
die "Cannot read firmware node path"
printf "Found XMM7360 modem at %s (%s)\n" "${modem_id}" "${acpi_path}" >&2
bridge_id="${path%/*}"
bridge_id="${bridge_id##*/}"
printf "Parent port is at %s\n" "${bridge_id}" >&2
modprobe acpi_call || \
die "Could not load acpi_call module. Is it missing?"
printf "Disabling PCIe link...\n" >&2
setpci -s "${bridge_id}" "CAP_EXP+10.w=0052" || \
die "Could not run setpci"
printf "%s" "${acpi_path}._RST" > /proc/acpi/call || \
die "Could not reset PCI"
echo "OK!"
exit 0
done
die "Did not find an XMM7360 modem"