misc.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Miscelaneous DaVinci functions.
  4. *
  5. * Copyright (C) 2009 Nick Thompson, GE Fanuc Ltd, <nick.thompson@gefanuc.com>
  6. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  7. * Copyright (C) 2008 Lyrtech <www.lyrtech.com>
  8. * Copyright (C) 2004 Texas Instruments.
  9. */
  10. #include <common.h>
  11. #include <env.h>
  12. #include <i2c.h>
  13. #include <init.h>
  14. #include <log.h>
  15. #include <net.h>
  16. #include <asm/arch/hardware.h>
  17. #include <asm/global_data.h>
  18. #include <asm/io.h>
  19. #include <asm/arch/davinci_misc.h>
  20. DECLARE_GLOBAL_DATA_PTR;
  21. #ifndef CONFIG_SPL_BUILD
  22. int dram_init(void)
  23. {
  24. /* dram_init must store complete ramsize in gd->ram_size */
  25. gd->ram_size = get_ram_size(
  26. (void *)CFG_SYS_SDRAM_BASE,
  27. CFG_MAX_RAM_BANK_SIZE);
  28. return 0;
  29. }
  30. int dram_init_banksize(void)
  31. {
  32. gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
  33. gd->bd->bi_dram[0].size = gd->ram_size;
  34. return 0;
  35. }
  36. #endif
  37. #ifdef CONFIG_DRIVER_TI_EMAC
  38. /*
  39. * Set the mii mode as MII or RMII
  40. */
  41. void davinci_emac_mii_mode_sel(int mode_sel)
  42. {
  43. int val;
  44. val = readl(&davinci_syscfg_regs->cfgchip3);
  45. if (mode_sel == 0)
  46. val &= ~(1 << 8);
  47. else
  48. val |= (1 << 8);
  49. writel(val, &davinci_syscfg_regs->cfgchip3);
  50. }
  51. /*
  52. * If there is no MAC address in the environment, then it will be initialized
  53. * (silently) from the value in the EEPROM.
  54. */
  55. void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
  56. {
  57. uint8_t env_enetaddr[6];
  58. int ret;
  59. ret = eth_env_get_enetaddr_by_index("eth", 0, env_enetaddr);
  60. if (!ret) {
  61. /*
  62. * There is no MAC address in the environment, so we
  63. * initialize it from the value in the EEPROM.
  64. */
  65. debug("### Setting environment from EEPROM MAC address = "
  66. "\"%pM\"\n",
  67. env_enetaddr);
  68. ret = !eth_env_set_enetaddr("ethaddr", rom_enetaddr);
  69. }
  70. if (!ret)
  71. printf("Failed to set mac address from EEPROM: %d\n", ret);
  72. }
  73. #endif /* CONFIG_DRIVER_TI_EMAC */
  74. void irq_init(void)
  75. {
  76. /*
  77. * Mask all IRQs by clearing the global enable and setting
  78. * the enable clear for all the 90 interrupts.
  79. */
  80. writel(0, &davinci_aintc_regs->ger);
  81. writel(0, &davinci_aintc_regs->hier);
  82. writel(0xffffffff, &davinci_aintc_regs->ecr1);
  83. writel(0xffffffff, &davinci_aintc_regs->ecr2);
  84. writel(0xffffffff, &davinci_aintc_regs->ecr3);
  85. }
  86. /*
  87. * Enable PSC for various peripherals.
  88. */
  89. int da8xx_configure_lpsc_items(const struct lpsc_resource *item,
  90. const int n_items)
  91. {
  92. int i;
  93. for (i = 0; i < n_items; i++)
  94. lpsc_on(item[i].lpsc_no);
  95. return 0;
  96. }