blob: 0b999a1d3193ed501106cbc3c05447bc3ddcf0fd [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk2262cfe2002-11-18 00:14:45 +00002/*
3 * (C) Copyright 2002
Albert ARIBAUDfa82f872011-08-04 18:45:45 +02004 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
wdenk2262cfe2002-11-18 00:14:45 +00005 */
6
wdenk2262cfe2002-11-18 00:14:45 +00007/* i8254.h Intel 8254 PIT registers */
8
wdenk2262cfe2002-11-18 00:14:45 +00009#ifndef _ASMI386_I8254_H_
Alistair Delva9bcd51b2021-10-20 21:31:30 +000010#define _ASMI386_I8254_H_
wdenk2262cfe2002-11-18 00:14:45 +000011
Bin Meng0a2ea022015-10-22 19:13:28 -070012#define PIT_T0 0x00 /* PIT channel 0 count/status */
13#define PIT_T1 0x01 /* PIT channel 1 count/status */
14#define PIT_T2 0x02 /* PIT channel 2 count/status */
15#define PIT_COMMAND 0x03 /* PIT mode control, latch and read back */
wdenk2262cfe2002-11-18 00:14:45 +000016
17/* PIT Command Register Bit Definitions */
18
Bin Meng0a2ea022015-10-22 19:13:28 -070019#define PIT_CMD_CTR0 0x00 /* Select PIT counter 0 */
20#define PIT_CMD_CTR1 0x40 /* Select PIT counter 1 */
21#define PIT_CMD_CTR2 0x80 /* Select PIT counter 2 */
wdenk2262cfe2002-11-18 00:14:45 +000022
Bin Meng0a2ea022015-10-22 19:13:28 -070023#define PIT_CMD_LATCH 0x00 /* Counter Latch Command */
24#define PIT_CMD_LOW 0x10 /* Access counter bits 7-0 */
25#define PIT_CMD_HIGH 0x20 /* Access counter bits 15-8 */
26#define PIT_CMD_BOTH 0x30 /* Access counter bits 15-0 in two accesses */
wdenk2262cfe2002-11-18 00:14:45 +000027
Bin Meng0a2ea022015-10-22 19:13:28 -070028#define PIT_CMD_MODE0 0x00 /* Select mode 0 */
29#define PIT_CMD_MODE1 0x02 /* Select mode 1 */
30#define PIT_CMD_MODE2 0x04 /* Select mode 2 */
31#define PIT_CMD_MODE3 0x06 /* Select mode 3 */
32#define PIT_CMD_MODE4 0x08 /* Select mode 4 */
33#define PIT_CMD_MODE5 0x0a /* Select mode 5 */
wdenk2262cfe2002-11-18 00:14:45 +000034
Bin Meng80de0492014-11-09 22:19:25 +080035/* The clock frequency of the i8253/i8254 PIT */
Bin Meng0a2ea022015-10-22 19:13:28 -070036#define PIT_TICK_RATE 1193182
Bin Meng80de0492014-11-09 22:19:25 +080037
Simon Glass79a5be82019-02-16 20:24:58 -070038/**
39 * i8254_enable_beep() - Start a beep using the PCAT timer
40 *
41 * This starts beeping using the legacy i8254 timer. The beep may be silenced
42 * after a delay with i8254_disable_beep().
43 *
44 * @frequency_hz: Frequency of beep in Hz
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010045 * Return: 0 if OK, -EINVAL if frequency_hz is 0
Simon Glass79a5be82019-02-16 20:24:58 -070046 */
47int i8254_enable_beep(uint frequency_hz);
48
49/**
50 * i8254_disable_beep() - Disable the bepper
51 *
52 * This stops any existing beep
53 */
54void i8254_disable_beep(void);
55
Alistair Delva9bcd51b2021-10-20 21:31:30 +000056#endif /* _ASMI386_I8254_H_ */