xref: /freebsd/usr.sbin/fwget/pci/pci_network_mediatek (revision 0be82d56b44fbe157d4bf1c125eca6625486d17f)
1dd8a74e7SBjoern A. Zeeb#-
2dd8a74e7SBjoern A. Zeeb# SPDX-License-Identifier: BSD-2-Clause
3dd8a74e7SBjoern A. Zeeb#
4dd8a74e7SBjoern A. Zeeb# Copyright 2023 Bjoern A. Zeeb
5dd8a74e7SBjoern A. Zeeb#
6dd8a74e7SBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without
7dd8a74e7SBjoern A. Zeeb# modification, are permitted provided that the following conditions
8dd8a74e7SBjoern A. Zeeb# are met:
9dd8a74e7SBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright
10dd8a74e7SBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer.
11dd8a74e7SBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright
12dd8a74e7SBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer in the
13dd8a74e7SBjoern A. Zeeb#    documentation and/or other materials provided with the distribution.
14dd8a74e7SBjoern A. Zeeb#
15dd8a74e7SBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16dd8a74e7SBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17dd8a74e7SBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18dd8a74e7SBjoern A. Zeeb# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19dd8a74e7SBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20dd8a74e7SBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21dd8a74e7SBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22dd8a74e7SBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23dd8a74e7SBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24dd8a74e7SBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25dd8a74e7SBjoern A. Zeeb# SUCH DAMAGE.
26dd8a74e7SBjoern A. Zeeb#
27dd8a74e7SBjoern A. Zeeb
28dd8a74e7SBjoern A. Zeeb# mt7915
29dd8a74e7SBjoern A. Zeebpci_network_mediatek_mt7915()
30dd8a74e7SBjoern A. Zeeb{
31dd8a74e7SBjoern A. Zeeb
32*0be82d56SBjoern A. Zeeb	# awk 'BEGIN { x = 0; } { if (/mt7915_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
33dd8a74e7SBjoern A. Zeeb
34dd8a74e7SBjoern A. Zeeb	case "$1" in
35dd8a74e7SBjoern A. Zeeb	0x7915)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
36dd8a74e7SBjoern A. Zeeb	0x7906)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
37dd8a74e7SBjoern A. Zeeb	esac
38dd8a74e7SBjoern A. Zeeb}
39dd8a74e7SBjoern A. Zeeb
40dd8a74e7SBjoern A. Zeeb# mt7921
41dd8a74e7SBjoern A. Zeebpci_network_mediatek_mt7921()
42dd8a74e7SBjoern A. Zeeb{
43dd8a74e7SBjoern A. Zeeb
44*0be82d56SBjoern A. Zeeb	# awk 'BEGIN { x = 0; } { if (/mt7921_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
45dd8a74e7SBjoern A. Zeeb        case "$1" in
46dd8a74e7SBjoern A. Zeeb	0x7961)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
47dd8a74e7SBjoern A. Zeeb	0x7922)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
48dd8a74e7SBjoern A. Zeeb	0x0608)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
49dd8a74e7SBjoern A. Zeeb	0x0616)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
50dd8a74e7SBjoern A. Zeeb	esac
51dd8a74e7SBjoern A. Zeeb}
52dd8a74e7SBjoern A. Zeeb
53*0be82d56SBjoern A. Zeeb# mt7996
54*0be82d56SBjoern A. Zeebpci_network_mediatek_mt7996()
55*0be82d56SBjoern A. Zeeb{
56*0be82d56SBjoern A. Zeeb
57*0be82d56SBjoern A. Zeeb	# awk 'BEGIN { x = 0; } { if (/mt7996_pci_device_table/) { x=1 }; if (/^\};/) { x=0 }; if (x==1 && /PCI_DEVICE\(PCI_VENDOR_ID_MEDIATEK,/) { gsub(").*", "", $3); printf "%s)\taddpkg \"wifi-firmware-mt76-kmod\"; return 1 ;;\n", tolower($3) } }' *.c
58*0be82d56SBjoern A. Zeeb	case "$1" in
59*0be82d56SBjoern A. Zeeb	0x7990)	addpkg "wifi-firmware-mt76-kmod"; return 1 ;;
60*0be82d56SBjoern A. Zeeb	esac
61*0be82d56SBjoern A. Zeeb}
62dd8a74e7SBjoern A. Zeeb
63dd8a74e7SBjoern A. Zeebpci_network_mediatek()
64dd8a74e7SBjoern A. Zeeb{
65dd8a74e7SBjoern A. Zeeb
66*0be82d56SBjoern A. Zeeb	for _drv in mt7915 mt7921 mt7996; do
67dd8a74e7SBjoern A. Zeeb		pci_network_mediatek_${_drv} "$1"
68dd8a74e7SBjoern A. Zeeb		case $? in
69dd8a74e7SBjoern A. Zeeb		1)	break ;;
70dd8a74e7SBjoern A. Zeeb		esac
71dd8a74e7SBjoern A. Zeeb	done
72dd8a74e7SBjoern A. Zeeb}
73