[U-Boot] [PATCH 1/4] x86: Make sure i8254 is setup correctly before generating beeps

The i8254 timer control IO port (0x43) should be setup correctly by using PIT counter 2 to generate beeps, however in U-Boot other codes like TSC driver utilizes PIT for TSC frequency calibration and configures the counter 2 to a different mode that does not beep. Fix this by always ensuring the PIT counter 2 is correctly initialized so that the i8254 beeper driver works as expected.
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
arch/x86/lib/i8254.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/x86/lib/i8254.c b/arch/x86/lib/i8254.c index d022795..0f97538 100644 --- a/arch/x86/lib/i8254.c +++ b/arch/x86/lib/i8254.c @@ -51,6 +51,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);

The pc speaker driven by the i8254 is generic enough to deserve a single dtsi file to be included by boards that use it.
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
arch/x86/dts/pcspkr.dtsi | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 arch/x86/dts/pcspkr.dtsi
diff --git a/arch/x86/dts/pcspkr.dtsi b/arch/x86/dts/pcspkr.dtsi new file mode 100644 index 0000000..934ab10 --- /dev/null +++ b/arch/x86/dts/pcspkr.dtsi @@ -0,0 +1,5 @@ +/ { + pcspkr { + compatible = "i8254,beeper"; + }; +};

On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
The pc speaker driven by the i8254 is generic enough to deserve a single dtsi file to be included by boards that use it.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/dts/pcspkr.dtsi | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 arch/x86/dts/pcspkr.dtsi
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Mar 11, 2019 at 5:51 AM Simon Glass sjg@chromium.org wrote:
On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
The pc speaker driven by the i8254 is generic enough to deserve a single dtsi file to be included by boards that use it.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/dts/pcspkr.dtsi | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 arch/x86/dts/pcspkr.dtsi
Reviewed-by: Simon Glass sjg@chromium.org
applied to u-boot-x86, thanks!

This is currently missing and without it the i8254 beeper driver won't work.
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
arch/x86/dts/coreboot.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/x86/dts/coreboot.dts b/arch/x86/dts/coreboot.dts index e212f3d..a88da6e 100644 --- a/arch/x86/dts/coreboot.dts +++ b/arch/x86/dts/coreboot.dts @@ -10,6 +10,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "keyboard.dtsi" +/include/ "pcspkr.dtsi" /include/ "reset.dtsi" /include/ "rtc.dtsi" /include/ "tsc_timer.dtsi"

On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
This is currently missing and without it the i8254 beeper driver won't work.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/dts/coreboot.dts | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Mar 11, 2019 at 5:51 AM Simon Glass sjg@chromium.org wrote:
On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
This is currently missing and without it the i8254 beeper driver won't work.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/dts/coreboot.dts | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org
applied to u-boot-x86, thanks!

Use the i8254 sound driver to support creating simple beeps.
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
arch/x86/dts/crownbay.dts | 1 + configs/crownbay_defconfig | 3 +++ 2 files changed, 4 insertions(+)
diff --git a/arch/x86/dts/crownbay.dts b/arch/x86/dts/crownbay.dts index 2ffcc5f..8938a94 100644 --- a/arch/x86/dts/crownbay.dts +++ b/arch/x86/dts/crownbay.dts @@ -10,6 +10,7 @@ /include/ "skeleton.dtsi" /include/ "serial.dtsi" /include/ "keyboard.dtsi" +/include/ "pcspkr.dtsi" /include/ "reset.dtsi" /include/ "rtc.dtsi" /include/ "tsc_timer.dtsi" diff --git a/configs/crownbay_defconfig b/configs/crownbay_defconfig index 34c2eb3..e0c9824 100644 --- a/configs/crownbay_defconfig +++ b/configs/crownbay_defconfig @@ -28,6 +28,7 @@ CONFIG_CMD_DHCP=y # CONFIG_CMD_NFS is not set CONFIG_CMD_PING=y CONFIG_CMD_TIME=y +CONFIG_CMD_SOUND=y CONFIG_CMD_EXT2=y CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y @@ -41,6 +42,8 @@ CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CPU=y CONFIG_E1000=y +CONFIG_SOUND=y +CONFIG_SOUND_I8254=y CONFIG_SPI=y CONFIG_USB_STORAGE=y CONFIG_USB_KEYBOARD=y

On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
Use the i8254 sound driver to support creating simple beeps.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/dts/crownbay.dts | 1 + configs/crownbay_defconfig | 3 +++ 2 files changed, 4 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Mar 11, 2019 at 5:51 AM Simon Glass sjg@chromium.org wrote:
On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
Use the i8254 sound driver to support creating simple beeps.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/dts/crownbay.dts | 1 + configs/crownbay_defconfig | 3 +++ 2 files changed, 4 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
applied to u-boot-x86, thanks!

On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
The i8254 timer control IO port (0x43) should be setup correctly by using PIT counter 2 to generate beeps, however in U-Boot other codes like TSC driver utilizes PIT for TSC frequency calibration and configures the counter 2 to a different mode that does not beep. Fix this by always ensuring the PIT counter 2 is correctly initialized so that the i8254 beeper driver works as expected.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/lib/i8254.c | 4 ++++ 1 file changed, 4 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Mar 11, 2019 at 5:51 AM Simon Glass sjg@chromium.org wrote:
On Tue, 26 Feb 2019 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
The i8254 timer control IO port (0x43) should be setup correctly by using PIT counter 2 to generate beeps, however in U-Boot other codes like TSC driver utilizes PIT for TSC frequency calibration and configures the counter 2 to a different mode that does not beep. Fix this by always ensuring the PIT counter 2 is correctly initialized so that the i8254 beeper driver works as expected.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
arch/x86/lib/i8254.c | 4 ++++ 1 file changed, 4 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
applied to u-boot-x86, thanks!
participants (2)
-
Bin Meng
-
Simon Glass