fearly_uart.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: early_uart.c
  15. * Date: 2022-02-11 13:33:28
  16. * LastEditTime: 2022-02-17 17:59:26
  17. * Description:  This file is for
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 rtos 2022/6/25 init commit
  23. * 1.1 zhangyan 2023/7/11 modify
  24. */
  25. /***************************** Include Files *********************************/
  26. #include "rtconfig.h"
  27. #ifdef RT_USING_SMART
  28. #include <ioremap.h>
  29. #endif
  30. #include "fkernel.h"
  31. #include "fio.h"
  32. #include "fparameters.h"
  33. #include "fearly_uart.h"
  34. #include "fpl011.h"
  35. /**************************** Type Definitions *******************************/
  36. static FPl011 early_uart;
  37. void FEarlyUartProbe(void)
  38. {
  39. FPl011Config config;
  40. config = *FPl011LookupConfig(EARLY_UART_CTRL_ID);
  41. #ifdef RT_USING_SMART
  42. config.base_address = (uintptr)rt_ioremap((void *)config.base_address, 0x2000);
  43. #endif
  44. FPl011CfgInitialize(&early_uart, &config);
  45. return;
  46. }
  47. /************************** Constant Definitions *****************************/
  48. /************************** Variable Definitions *****************************/
  49. /***************** Macros (Inline Functions) Definitions *********************/
  50. /*****************************************************************************/
  51. void OutByte(s8 byte)
  52. {
  53. FPl011BlockSend(&early_uart, (u8 *)&byte, 1);
  54. }
  55. char GetByte(void)
  56. {
  57. return (char)(FPl011BlockReceive(&early_uart));
  58. }