dwmac_s700.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/global_data.h>
  9. #include <asm/io.h>
  10. #include <dm.h>
  11. #include <clk.h>
  12. #include <phy.h>
  13. #include <regmap.h>
  14. #include <reset.h>
  15. #include <syscon.h>
  16. #include "designware.h"
  17. #include <asm/arch-owl/regs_s700.h>
  18. #include <linux/bitops.h>
  19. /* pin control for MAC */
  20. #define RMII_TXD01_MFP_CTL0 (0x0 << 16)
  21. #define RMII_RXD01_MFP_CTL0 (0x0 << 8)
  22. #define RMII_TXEN_TXER_MFP_CTL0 (0x0 << 13)
  23. #define RMII_REF_CLK_MFP_CTL0 (0x0 << 6)
  24. #define CLKO_25M_EN_MFP_CTL3 BIT(30)
  25. DECLARE_GLOBAL_DATA_PTR;
  26. static void dwmac_board_setup(void)
  27. {
  28. clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 |
  29. RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0));
  30. setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3);
  31. }
  32. static int dwmac_s700_probe(struct udevice *dev)
  33. {
  34. dwmac_board_setup();
  35. /* This is undocumented, phy interface select register */
  36. writel(0x4, 0xe024c0a0);
  37. return designware_eth_probe(dev);
  38. }
  39. static int dwmac_s700_of_to_plat(struct udevice *dev)
  40. {
  41. return designware_eth_of_to_plat(dev);
  42. }
  43. static const struct udevice_id dwmac_s700_ids[] = {
  44. {.compatible = "actions,s700-ethernet"},
  45. { }
  46. };
  47. U_BOOT_DRIVER(dwmac_s700) = {
  48. .name = "dwmac_s700",
  49. .id = UCLASS_ETH,
  50. .of_match = dwmac_s700_ids,
  51. .of_to_plat = dwmac_s700_of_to_plat,
  52. .probe = dwmac_s700_probe,
  53. .ops = &designware_eth_ops,
  54. .priv_auto = sizeof(struct dw_eth_dev),
  55. .plat_auto = sizeof(struct eth_pdata),
  56. .flags = DM_FLAG_ALLOC_PRIV_DMA,
  57. };