# Force cpufreq to use specific kernel driver ?



## ajmcc (Jan 30, 2022)

Hi, I wish to run FreeBSD on an embedded device running an AMD GX-416RA SOC 1.6GHz quad-core, using an AMI Aptio 4.5 BIOS. Unfortunately it seems that although the BIOS ACPI implementation is mostly there, the tables are not correctly exposing the available processor frequencies, as the only one offered by cpufreq is 1600MHz.

The kernel is loading the hwpstate driver. I would like to try disabling the load of this driver, and instead force the kernel to load the powernow driver. I think this is done in /boot/loader.conf, but I'm unsure of the proper syntax.

Any advice on this would be greatly appreciated !

References:
cpufreq(4)
freebsd-src/sys/x86/cpufreq


----------



## Brains (Jan 30, 2022)

The Practical rc.d scripting article comes in handy for this sort of stuff.
I have two video devices, the onboard Intel and Nvidia. I switch between the two via OEM software in Windows, only one shows up depending on which I choose. I do not have a DE or WM and have 3 modes for my laptop with attached HDMI monitor for each graphics device, 6 modes, SpanView, TwinView and HDMI-Only. When I change the default mode a file is created for each device with the 00-ServerFlags.conf file which sets the last mode I choose and this service plants it in place. It also unmounts my NTFS and UFS data drives as I seem to have problems if I don't unmount them myself when the system goes down, have to boot to Windows and repair the NTFS often to enable writing again, and this service also throws some personal stats in root's home which I left here fore demo purposes.

I probably don't need to unload the opposite video driver as I do not have either i915kms or nvidia-modeset enabled in rc.conf as this service loads the appropriate module based on the devide ID it finds.


```
# PROVIDE: loadVidConf
# REQUIRE: root
# KEYWORD: nojail shutdown
name="loadVidConf"
rcvar="loadVidConf_enable"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile=/var/run/${name}.pid

. /etc/rc.subr

loadVidConf_start()
{
    logger ${name}_start
    touch ${pidfile}
    if pciconf -l | grep "1618" > /dev/null; then
        kldunload i915kms
        kldload nvidia-modeset
        cp /usr/local/.XX/xcon/NservFlag /usr/local/etc/X11/xorg.conf.d/00-ServerFlags.conf
        echo "NVidia-loaded $(date '+%j%:%T')" >> /root/stats
    fi
    if pciconf -l | grep "191b" > /dev/null; then
        kldunload nvidia-modeset nvidia
        kldload i915kms
        cp /usr/local/.XX/xcon/IservFlag /usr/local/etc/X11/xorg.conf.d/00-ServerFlags.conf
        if grep Intel-HDMI-Only /usr/local/etc/X11/xorg.conf.d/00*; then cp /usr/local/.XX/xcon/40-noLap.sh \
        /usr/local/etc/X11/xinit/xinitrc.d/; else echo "no" > /dev/null; fi
        echo "Intel-loaded $(date '+%j%:%T')" >> /root/stats
    fi
}

loadVidConf_stop()
{
    logger ${name}_stop
    rm /usr/local/etc/X11/xinit/xinitrc.d/40-noLap.sh
    umount /scraps  && echo "Scraps $(date '+%j%:%T')" >> /root/stats
    umount /dev/ada0p2 && echo "Junk $(date '+%j%:%T')" >> /root/stats
    rm ${pidfile}
}

load_rc_config $name
run_rc_command "$1"
```


----------

