aboutsummaryrefslogtreecommitdiff
path: root/drivers/sound/i8254_beep.c
diff options
context:
space:
mode:
authorSimon Glass2019-02-16 20:24:59 -0700
committerBin Meng2019-02-20 15:27:10 +0800
commit6a27e540de2c5ff580af99b6b093ce00f495466e (patch)
tree52d2b3187c4c04cac499147999d4d49d652af1ba /drivers/sound/i8254_beep.c
parent79a5be820d9b187a1d8617d6a1cb65392448322d (diff)
sound: Add a driver for the i8254 beep
Add a sound driver which can output simple beeps using this legacy timer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/sound/i8254_beep.c')
-rw-r--r--drivers/sound/i8254_beep.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/sound/i8254_beep.c b/drivers/sound/i8254_beep.c
new file mode 100644
index 00000000000..5572dc4d265
--- /dev/null
+++ b/drivers/sound/i8254_beep.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 Google LLC
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <sound.h>
+#include <asm/i8254.h>
+
+int i8254_start_beep(struct udevice *dev, int frequency_hz)
+{
+ return i8254_enable_beep(frequency_hz);
+}
+
+int i8254_stop_beep(struct udevice *dev)
+{
+ i8254_disable_beep();
+
+ return 0;
+}
+
+static const struct sound_ops i8254_ops = {
+ .start_beep = i8254_start_beep,
+ .stop_beep = i8254_stop_beep,
+};
+
+static const struct udevice_id i8254_ids[] = {
+ { .compatible = "i8254,beeper" },
+ { }
+};
+
+U_BOOT_DRIVER(i8254_drv) = {
+ .name = "i8254_drv",
+ .id = UCLASS_SOUND,
+ .of_match = i8254_ids,
+ .ops = &i8254_ops,
+};