pcat_timer.c 574 B

123456789101112131415161718192021222324252627
  1. /*
  2. * (C) Copyright 2002
  3. * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/i8254.h>
  10. #define TIMER2_VALUE 0x0a8e /* 440Hz */
  11. int pcat_timer_init(void)
  12. {
  13. /*
  14. * initialize 2, used to drive the speaker
  15. * (to start a beep: write 3 to port 0x61,
  16. * to stop it again: write 0)
  17. */
  18. outb(PIT_CMD_CTR2 | PIT_CMD_BOTH | PIT_CMD_MODE3,
  19. PIT_BASE + PIT_COMMAND);
  20. outb(TIMER2_VALUE & 0xff, PIT_BASE + PIT_T2);
  21. outb(TIMER2_VALUE >> 8, PIT_BASE + PIT_T2);
  22. return 0;
  23. }