Skip to contentSkip to conversation

x86: Make sure i8254 is setup correctly before generating beeps

PATCH New Bin Meng 2 participants 12 messages Feb 26, 2019 – Mar 11, 2019 x86

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

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.

---

 arch/x86/lib/i8254.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/lib/i8254.c +4 -0
index d022795..0f97538 100644
@@ -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);
 
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/4 x86: Add a dtsi file for the pc speaker

The pc speaker driven by the i8254 is generic enough to deserve a single dtsi file to be included by boards that use it.

---

 arch/x86/dts/pcspkr.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 arch/x86/dts/pcspkr.dtsi
arch/x86/dts/pcspkr.dtsi new file +5 -0
new file mode 100644
index 0000000..934ab10
@@ -0,0 +1,5 @@
+/ {
+	pcspkr {
+		compatible = "i8254,beeper";
+	};
+};
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 x86: Add a dtsi file for the pc speaker

Quoted 10 lines · Bin Meng

The pc speaker driven by the i8254 is generic enough to deserve a single dtsi file to be included by boards that use it.

---

 arch/x86/dts/pcspkr.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 arch/x86/dts/pcspkr.dtsi
author
#3 lore raw

PATCH 2/4 x86: Add a dtsi file for the pc speaker

Quoted 6 lines · Simon Glass
Quoted 4 lines · Bin Meng

The pc speaker driven by the i8254 is generic enough to deserve a single dtsi file to be included by boards that use it.

Quoted 8 lines
Quoted 6 lines

---

 arch/x86/dts/pcspkr.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 arch/x86/dts/pcspkr.dtsi

applied to u-boot-x86, thanks!

author
#4 lore raw

PATCH 3/4 x86: coreboot: Add the missing pc speaker node in the device tree

In reply to Bin Meng

This is currently missing and without it the i8254 beeper driver won't work.

---

 arch/x86/dts/coreboot.dts | 1 +
 1 file changed, 1 insertion(+)
arch/x86/dts/coreboot.dts +1 -0
index e212f3d..a88da6e 100644
@@ -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"
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH 3/4 x86: coreboot: Add the missing pc speaker node in the device tree

Quoted 6 lines · Simon Glass
Quoted 4 lines · Bin Meng

This is currently missing and without it the i8254 beeper driver won't work.

Quoted 7 lines
Quoted 5 lines

---

 arch/x86/dts/coreboot.dts | 1 +
 1 file changed, 1 insertion(+)

applied to u-boot-x86, thanks!

author
#7 lore raw

PATCH 4/4 x86: crownbay: Enable the beeper sound driver

In reply to Bin Meng

Use the i8254 sound driver to support creating simple beeps.

---

 arch/x86/dts/crownbay.dts  | 1 +
 configs/crownbay_defconfig | 3 +++
 2 files changed, 4 insertions(+)
arch/x86/dts/crownbay.dts +1 -0
index 2ffcc5f..8938a94 100644
@@ -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"
configs/crownbay_defconfig +3 -0
index 34c2eb3..e0c9824 100644
@@ -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
Signature · 1 line
2.7.4
author
#9 lore raw

PATCH 4/4 x86: crownbay: Enable the beeper sound driver

Quoted 5 lines · Simon Glass
Quoted 3 lines · Bin Meng

Use the i8254 sound driver to support creating simple beeps.

Quoted 8 lines
Quoted 6 lines

---

 arch/x86/dts/crownbay.dts  | 1 +
 configs/crownbay_defconfig | 3 +++
 2 files changed, 4 insertions(+)

applied to u-boot-x86, thanks!

#10 lore raw

PATCH 1/4 x86: Make sure i8254 is setup correctly before generating beeps

In reply to Bin Meng
Quoted 8 lines · Bin Meng

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.

Quoted 5 lines

---

 arch/x86/lib/i8254.c | 4 ++++
 1 file changed, 4 insertions(+)
author
#11 lore raw

PATCH 1/4 x86: Make sure i8254 is setup correctly before generating beeps

Quoted 10 lines · Simon Glass
Quoted 8 lines · Bin Meng

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.

Quoted 7 lines
Quoted 5 lines

---

 arch/x86/lib/i8254.c | 4 ++++
 1 file changed, 4 insertions(+)

applied to u-boot-x86, thanks!