devices.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2011 by Vladimir Zapolskiy <vz@mleia.com>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #include <common.h>
  20. #include <asm/arch/cpu.h>
  21. #include <asm/arch/clk.h>
  22. #include <asm/arch/uart.h>
  23. #include <asm/io.h>
  24. static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
  25. static struct uart_ctrl_regs *ctrl = (struct uart_ctrl_regs *)UART_CTRL_BASE;
  26. void lpc32xx_uart_init(unsigned int uart_id)
  27. {
  28. if (uart_id < 1 || uart_id > 7)
  29. return;
  30. /* Disable loopback mode, if it is set by S1L bootloader */
  31. clrbits_le32(&ctrl->loop,
  32. UART_LOOPBACK(CONFIG_SYS_LPC32XX_UART));
  33. if (uart_id < 3 || uart_id > 6)
  34. return;
  35. /* Enable UART system clock */
  36. setbits_le32(&clk->uartclk_ctrl, CLK_UART(uart_id));
  37. /* Set UART into autoclock mode */
  38. clrsetbits_le32(&ctrl->clkmode,
  39. UART_CLKMODE_MASK(uart_id),
  40. UART_CLKMODE_AUTO(uart_id));
  41. /* Bypass pre-divider of UART clock */
  42. writel(CLK_UART_X_DIV(1) | CLK_UART_Y_DIV(1),
  43. &clk->u3clk + (uart_id - 3));
  44. }