wdr4300.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (C) 2016 Marek Vasut <marex@denx.de>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/addrspace.h>
  9. #include <asm/types.h>
  10. #include <mach/ath79.h>
  11. #include <mach/ar71xx_regs.h>
  12. #include <mach/ddr.h>
  13. #include <debug_uart.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. #ifdef CONFIG_USB
  16. static void wdr4300_usb_start(void)
  17. {
  18. void __iomem *gpio_regs = map_physmem(AR71XX_GPIO_BASE,
  19. AR71XX_GPIO_SIZE, MAP_NOCACHE);
  20. if (!gpio_regs)
  21. return;
  22. /* Power up the USB HUB. */
  23. clrbits_be32(gpio_regs + AR71XX_GPIO_REG_OE, BIT(21) | BIT(22));
  24. writel(BIT(21) | BIT(22), gpio_regs + AR71XX_GPIO_REG_SET);
  25. mdelay(1);
  26. ath79_usb_reset();
  27. }
  28. #else
  29. static inline void wdr4300_usb_start(void) {}
  30. #endif
  31. #ifdef CONFIG_BOARD_EARLY_INIT_F
  32. int board_early_init_f(void)
  33. {
  34. void __iomem *regs;
  35. regs = map_physmem(AR71XX_GPIO_BASE, AR71XX_GPIO_SIZE,
  36. MAP_NOCACHE);
  37. /* Assure JTAG is not disconnected. */
  38. writel(0x40, regs + AR934X_GPIO_REG_FUNC);
  39. /* Configure default GPIO input/output regs. */
  40. writel(0x3031b, regs + AR71XX_GPIO_REG_OE);
  41. writel(0x0f804, regs + AR71XX_GPIO_REG_OUT);
  42. /* Configure pin multiplexing. */
  43. writel(0x00000000, regs + AR934X_GPIO_REG_OUT_FUNC0);
  44. writel(0x0b0a0980, regs + AR934X_GPIO_REG_OUT_FUNC1);
  45. writel(0x00180000, regs + AR934X_GPIO_REG_OUT_FUNC2);
  46. writel(0x00000000, regs + AR934X_GPIO_REG_OUT_FUNC3);
  47. writel(0x0000004d, regs + AR934X_GPIO_REG_OUT_FUNC4);
  48. writel(0x00000000, regs + AR934X_GPIO_REG_OUT_FUNC5);
  49. #ifdef CONFIG_DEBUG_UART
  50. debug_uart_init();
  51. #endif
  52. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  53. ar934x_pll_init(560, 480, 240);
  54. ar934x_ddr_init(560, 480, 240);
  55. #endif
  56. wdr4300_usb_start();
  57. ath79_eth_reset();
  58. return 0;
  59. }
  60. #endif