luton.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  2. /*
  3. * Copyright (c) 2018 Microsemi Corporation
  4. */
  5. #include <common.h>
  6. #include <init.h>
  7. #include <asm/io.h>
  8. #include <led.h>
  9. #include <miiphy.h>
  10. enum {
  11. BOARD_TYPE_PCB090 = 0xAABBCD00,
  12. BOARD_TYPE_PCB091,
  13. };
  14. void board_debug_uart_init(void)
  15. {
  16. /* too early for the pinctrl driver, so configure the UART pins here */
  17. mscc_gpio_set_alternate(30, 1);
  18. mscc_gpio_set_alternate(31, 1);
  19. }
  20. int board_early_init_r(void)
  21. {
  22. /* Prepare SPI controller to be used in master mode */
  23. writel(0, BASE_CFG + ICPU_SW_MODE);
  24. /* Address of boot parameters */
  25. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE;
  26. /* LED setup */
  27. if (IS_ENABLED(CONFIG_LED))
  28. led_default_state();
  29. return 0;
  30. }
  31. int board_phy_config(struct phy_device *phydev)
  32. {
  33. phy_write(phydev, 0, 31, 0x10);
  34. phy_write(phydev, 0, 18, 0x80A0);
  35. while (phy_read(phydev, 0, 18) & 0x8000)
  36. ;
  37. phy_write(phydev, 0, 31, 0);
  38. return 0;
  39. }
  40. static void do_board_detect(void)
  41. {
  42. u32 chipid = (readl(BASE_DEVCPU_GCB + CHIP_ID) >> 12) & 0xFFFF;
  43. if (chipid == 0x7428 || chipid == 0x7424)
  44. gd->board_type = BOARD_TYPE_PCB091; // Lu10
  45. else
  46. gd->board_type = BOARD_TYPE_PCB090; // Lu26
  47. }
  48. #if defined(CONFIG_MULTI_DTB_FIT)
  49. int board_fit_config_name_match(const char *name)
  50. {
  51. if (gd->board_type == BOARD_TYPE_PCB090 &&
  52. strcmp(name, "luton_pcb090") == 0)
  53. return 0;
  54. if (gd->board_type == BOARD_TYPE_PCB091 &&
  55. strcmp(name, "luton_pcb091") == 0)
  56. return 0;
  57. return -1;
  58. }
  59. #endif
  60. #if defined(CONFIG_DTB_RESELECT)
  61. int embedded_dtb_select(void)
  62. {
  63. do_board_detect();
  64. fdtdec_setup();
  65. return 0;
  66. }
  67. #endif