sromc.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2021 Google LLC
  4. */
  5. #define LOG_CATEGORY UCLASS_ETH
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <log.h>
  9. #include <asm/arch/pinmux.h>
  10. #include <asm/arch/sromc.h>
  11. enum {
  12. FDT_SROM_PMC,
  13. FDT_SROM_TACP,
  14. FDT_SROM_TAH,
  15. FDT_SROM_TCOH,
  16. FDT_SROM_TACC,
  17. FDT_SROM_TCOS,
  18. FDT_SROM_TACS,
  19. FDT_SROM_TIMING_COUNT,
  20. };
  21. static int exyno5_sromc_probe(struct udevice *dev)
  22. {
  23. u32 timing[FDT_SROM_TIMING_COUNT]; /* timing parameters */
  24. u32 smc_bw_conf, smc_bc_conf;
  25. int bank; /* srom bank number */
  26. int width; /* bus width in bytes */
  27. int ret;
  28. if (!IS_ENABLED(CONFIG_SMC911X))
  29. return 0;
  30. bank = dev_read_s32_default(dev, "bank", 0);
  31. width = dev_read_s32_default(dev, "width", 2);
  32. /* Ethernet needs data bus width of 16 bits */
  33. if (width != 2) {
  34. log_debug("Unsupported bus width %d\n", width);
  35. return log_msg_ret("width", -EINVAL);
  36. }
  37. ret = dev_read_u32_array(dev, "srom-timing", timing,
  38. FDT_SROM_TIMING_COUNT);
  39. if (ret)
  40. return log_msg_ret("sromc", -EINVAL);
  41. smc_bw_conf = SROMC_DATA16_WIDTH(bank) | SROMC_BYTE_ENABLE(bank);
  42. smc_bc_conf = SROMC_BC_TACS(timing[FDT_SROM_TACS]) |
  43. SROMC_BC_TCOS(timing[FDT_SROM_TCOS]) |
  44. SROMC_BC_TACC(timing[FDT_SROM_TACC]) |
  45. SROMC_BC_TCOH(timing[FDT_SROM_TCOH]) |
  46. SROMC_BC_TAH(timing[FDT_SROM_TAH]) |
  47. SROMC_BC_TACP(timing[FDT_SROM_TACP]) |
  48. SROMC_BC_PMC(timing[FDT_SROM_PMC]);
  49. /* Select and configure the SROMC bank */
  50. exynos_pinmux_config(PERIPH_ID_SROMC, bank);
  51. s5p_config_sromc(bank, smc_bw_conf, smc_bc_conf);
  52. return 0;
  53. }
  54. static const struct udevice_id exyno5_sromc_ids[] = {
  55. { .compatible = "samsung,exynos5-sromc" },
  56. {}
  57. };
  58. U_BOOT_DRIVER(exyno5_sromc) = {
  59. .name = "exyno5_sromc",
  60. .id = UCLASS_SIMPLE_BUS,
  61. .of_match = exyno5_sromc_ids,
  62. .probe = exyno5_sromc_probe,
  63. };