Merge tag 'x86-pull-20230809' of https://source.denx.de/u-boot/custodians/u-boot-x86
[platform/kernel/u-boot.git] / arch / x86 / lib / i8254.c
index d022795..a8d1db1 100644 (file)
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/i8254.h>
+#include <asm/ibmpc.h>
 
 #define TIMER1_VALUE           18      /* 15.6us */
 #define BEEP_FREQUENCY_HZ      440
@@ -51,6 +52,10 @@ int i8254_enable_beep(uint frequency_hz)
        if (!frequency_hz)
                return -EINVAL;
 
+       /* make sure i8254 is setup correctly before generating beeps */
+       outb(PIT_CMD_CTR2 | PIT_CMD_BOTH | PIT_CMD_MODE3,
+            PIT_BASE + PIT_COMMAND);
+
        i8254_set_beep_freq(frequency_hz);
        setio_8(SYSCTL_PORTB, PORTB_BEEP_ENABLE);