dwmac_s700.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2020 Amit Singh Tomar <amittomer25@gmail.com>
  4. *
  5. * Actions DWMAC specific glue layer
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <dm.h>
  10. #include <clk.h>
  11. #include <phy.h>
  12. #include <regmap.h>
  13. #include <reset.h>
  14. #include <syscon.h>
  15. #include "designware.h"
  16. #include <asm/arch-owl/regs_s700.h>
  17. #include <linux/bitops.h>
  18. /* pin control for MAC */
  19. #define RMII_TXD01_MFP_CTL0 (0x0 << 16)
  20. #define RMII_RXD01_MFP_CTL0 (0x0 << 8)
  21. #define RMII_TXEN_TXER_MFP_CTL0 (0x0 << 13)
  22. #define RMII_REF_CLK_MFP_CTL0 (0x0 << 6)
  23. #define CLKO_25M_EN_MFP_CTL3 BIT(30)
  24. DECLARE_GLOBAL_DATA_PTR;
  25. static void dwmac_board_setup(void)
  26. {
  27. clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 |
  28. RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0));
  29. setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3);
  30. }
  31. static int dwmac_s700_probe(struct udevice *dev)
  32. {
  33. dwmac_board_setup();
  34. /* This is undocumented, phy interface select register */
  35. writel(0x4, 0xe024c0a0);
  36. return designware_eth_probe(dev);
  37. }
  38. static int dwmac_s700_ofdata_to_platdata(struct udevice *dev)
  39. {
  40. return designware_eth_ofdata_to_platdata(dev);
  41. }
  42. static const struct udevice_id dwmac_s700_ids[] = {
  43. {.compatible = "actions,s700-ethernet"},
  44. { }
  45. };
  46. U_BOOT_DRIVER(dwmac_s700) = {
  47. .name = "dwmac_s700",
  48. .id = UCLASS_ETH,
  49. .of_match = dwmac_s700_ids,
  50. .ofdata_to_platdata = dwmac_s700_ofdata_to_platdata,
  51. .probe = dwmac_s700_probe,
  52. .ops = &designware_eth_ops,
  53. .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
  54. .platdata_auto_alloc_size = sizeof(struct eth_pdata),
  55. .flags = DM_FLAG_ALLOC_PRIV_DMA,
  56. };