devices.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2011 by Vladimir Zapolskiy <vz@mleia.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/arch/cpu.h>
  8. #include <asm/arch/clk.h>
  9. #include <asm/arch/uart.h>
  10. #include <asm/io.h>
  11. static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
  12. static struct uart_ctrl_regs *ctrl = (struct uart_ctrl_regs *)UART_CTRL_BASE;
  13. void lpc32xx_uart_init(unsigned int uart_id)
  14. {
  15. if (uart_id < 1 || uart_id > 7)
  16. return;
  17. /* Disable loopback mode, if it is set by S1L bootloader */
  18. clrbits_le32(&ctrl->loop,
  19. UART_LOOPBACK(CONFIG_SYS_LPC32XX_UART));
  20. if (uart_id < 3 || uart_id > 6)
  21. return;
  22. /* Enable UART system clock */
  23. setbits_le32(&clk->uartclk_ctrl, CLK_UART(uart_id));
  24. /* Set UART into autoclock mode */
  25. clrsetbits_le32(&ctrl->clkmode,
  26. UART_CLKMODE_MASK(uart_id),
  27. UART_CLKMODE_AUTO(uart_id));
  28. /* Bypass pre-divider of UART clock */
  29. writel(CLK_UART_X_DIV(1) | CLK_UART_Y_DIV(1),
  30. &clk->u3clk + (uart_id - 3));
  31. }
  32. void lpc32xx_mac_init(void)
  33. {
  34. /* Enable MAC interface */
  35. writel(CLK_MAC_REG | CLK_MAC_SLAVE | CLK_MAC_MASTER
  36. | CLK_MAC_MII, &clk->macclk_ctrl);
  37. }