wdr4300.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Marek Vasut <marex@denx.de>
  4. */
  5. #include <common.h>
  6. #include <init.h>
  7. #include <asm/io.h>
  8. #include <asm/addrspace.h>
  9. #include <asm/types.h>
  10. #include <linux/bitops.h>
  11. #include <linux/delay.h>
  12. #include <mach/ath79.h>
  13. #include <mach/ar71xx_regs.h>
  14. #include <mach/ddr.h>
  15. #include <debug_uart.h>
  16. #ifdef CONFIG_USB_HOST
  17. static void wdr4300_usb_start(void)
  18. {
  19. void __iomem *gpio_regs = map_physmem(AR71XX_GPIO_BASE,
  20. AR71XX_GPIO_SIZE, MAP_NOCACHE);
  21. if (!gpio_regs)
  22. return;
  23. /* Power up the USB HUB. */
  24. clrbits_be32(gpio_regs + AR71XX_GPIO_REG_OE, BIT(21) | BIT(22));
  25. writel(BIT(21) | BIT(22), gpio_regs + AR71XX_GPIO_REG_SET);
  26. mdelay(1);
  27. ath79_usb_reset();
  28. }
  29. #else
  30. static inline void wdr4300_usb_start(void) {}
  31. #endif
  32. void wdr4300_pinmux_config(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. }
  50. #ifdef CONFIG_DEBUG_UART_BOARD_INIT
  51. void board_debug_uart_init(void)
  52. {
  53. wdr4300_pinmux_config();
  54. }
  55. #endif
  56. #ifdef CONFIG_BOARD_EARLY_INIT_F
  57. int board_early_init_f(void)
  58. {
  59. #ifndef CONFIG_DEBUG_UART_BOARD_INIT
  60. wdr4300_pinmux_config();
  61. #endif
  62. #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  63. ar934x_pll_init(560, 480, 240);
  64. ar934x_ddr_init(560, 480, 240);
  65. #endif
  66. wdr4300_usb_start();
  67. ath79_eth_reset();
  68. return 0;
  69. }
  70. #endif