goflexhome.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2021-2022 Tony Dinh <mibodhi@gmail.com>
  4. * Copyright (C) 2013-2021 Suriyan Ramasami <suriyan.r@gmail.com>
  5. *
  6. * Based on dockstar.c originally written by
  7. * Copyright (C) 2010 Eric C. Cooper <ecc@cmu.edu>
  8. *
  9. * Based on sheevaplug.c originally written by
  10. * Prafulla Wadaskar <prafulla@marvell.com>
  11. * (C) Copyright 2009
  12. * Marvell Semiconductor <www.marvell.com>
  13. */
  14. #include <common.h>
  15. #include <bootstage.h>
  16. #include <init.h>
  17. #include <netdev.h>
  18. #include <asm/global_data.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/arch/soc.h>
  21. #include <asm/arch/mpp.h>
  22. #include <asm/arch/cpu.h>
  23. #include <asm/io.h>
  24. #include <linux/bitops.h>
  25. DECLARE_GLOBAL_DATA_PTR;
  26. int board_early_init_f(void)
  27. {
  28. /* Multi-Purpose Pins Functionality configuration */
  29. static const u32 kwmpp_config[] = {
  30. MPP0_NF_IO2,
  31. MPP1_NF_IO3,
  32. MPP2_NF_IO4,
  33. MPP3_NF_IO5,
  34. MPP4_NF_IO6,
  35. MPP5_NF_IO7,
  36. MPP6_SYSRST_OUTn,
  37. MPP7_GPO,
  38. MPP8_UART0_RTS,
  39. MPP9_UART0_CTS,
  40. MPP10_UART0_TXD,
  41. MPP11_UART0_RXD,
  42. MPP12_SD_CLK,
  43. MPP13_SD_CMD,
  44. MPP14_SD_D0,
  45. MPP15_SD_D1,
  46. MPP16_SD_D2,
  47. MPP17_SD_D3,
  48. MPP18_NF_IO0,
  49. MPP19_NF_IO1,
  50. MPP20_GPIO,
  51. MPP21_GPIO,
  52. MPP22_GPIO,
  53. MPP23_GPIO,
  54. MPP24_GPIO,
  55. MPP25_GPIO,
  56. MPP26_GPIO,
  57. MPP27_GPIO,
  58. MPP28_GPIO,
  59. MPP29_TSMP9,
  60. MPP30_GPIO,
  61. MPP31_GPIO,
  62. MPP32_GPIO,
  63. MPP33_GPIO,
  64. MPP34_GPIO,
  65. MPP35_GPIO,
  66. MPP36_GPIO,
  67. MPP37_GPIO,
  68. MPP38_GPIO,
  69. MPP39_GPIO,
  70. MPP40_GPIO,
  71. MPP41_GPIO,
  72. MPP42_GPIO,
  73. MPP43_GPIO,
  74. MPP44_GPIO,
  75. MPP45_GPIO,
  76. MPP46_GPIO,
  77. MPP47_GPIO,
  78. MPP48_GPIO,
  79. MPP49_GPIO,
  80. 0
  81. };
  82. /*
  83. * default gpio configuration
  84. * There are maximum 64 gpios controlled through 2 sets of registers
  85. * the below configuration configures mainly initial LED status
  86. */
  87. mvebu_config_gpio(GOFLEXHOME_OE_VAL_LOW,
  88. GOFLEXHOME_OE_VAL_HIGH,
  89. GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
  90. kirkwood_mpp_conf(kwmpp_config, NULL);
  91. return 0;
  92. }
  93. int board_eth_init(struct bd_info *bis)
  94. {
  95. return cpu_eth_init(bis);
  96. }
  97. int board_init(void)
  98. {
  99. /*
  100. * arch number of board
  101. */
  102. gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME;
  103. /* address of boot parameters */
  104. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  105. return 0;
  106. }
  107. #if CONFIG_IS_ENABLED(BOOTSTAGE)
  108. #define GREEN_LED BIT(14)
  109. #define ORANGE_LED BIT(15)
  110. #define BOTH_LEDS (GREEN_LED | ORANGE_LED)
  111. #define NEITHER_LED 0
  112. static void set_leds(u32 leds, u32 blinking)
  113. {
  114. struct kwgpio_registers *r;
  115. u32 oe;
  116. u32 bl;
  117. r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
  118. oe = readl(&r->oe) | BOTH_LEDS;
  119. writel(oe & ~leds, &r->oe); /* active low */
  120. bl = readl(&r->blink_en) & ~BOTH_LEDS;
  121. writel(bl | blinking, &r->blink_en);
  122. }
  123. void show_boot_progress(int val)
  124. {
  125. switch (val) {
  126. case BOOTSTAGE_ID_RUN_OS: /* booting Linux */
  127. set_leds(BOTH_LEDS, NEITHER_LED);
  128. break;
  129. case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */
  130. set_leds(GREEN_LED, GREEN_LED);
  131. break;
  132. default:
  133. if (val < 0) /* error */
  134. set_leds(ORANGE_LED, ORANGE_LED);
  135. break;
  136. }
  137. }
  138. #endif