blob: 744b58bdd1a60d54f84997eac7d32f129774be73 [file] [log] [blame]
Amit Singh Tomar03d6edb2020-05-09 19:55:12 +05301// 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
Tom Riniabb9a042024-05-18 20:20:43 -06008#include <common.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Amit Singh Tomar03d6edb2020-05-09 19:55:12 +053010#include <asm/io.h>
11#include <dm.h>
12#include <clk.h>
13#include <phy.h>
14#include <regmap.h>
15#include <reset.h>
16#include <syscon.h>
17#include "designware.h"
18#include <asm/arch-owl/regs_s700.h>
19#include <linux/bitops.h>
20
21/* pin control for MAC */
22#define RMII_TXD01_MFP_CTL0 (0x0 << 16)
23#define RMII_RXD01_MFP_CTL0 (0x0 << 8)
24#define RMII_TXEN_TXER_MFP_CTL0 (0x0 << 13)
25#define RMII_REF_CLK_MFP_CTL0 (0x0 << 6)
26#define CLKO_25M_EN_MFP_CTL3 BIT(30)
27
28DECLARE_GLOBAL_DATA_PTR;
29
30static void dwmac_board_setup(void)
31{
32 clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 |
33 RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0));
34
35 setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3);
36}
37
38static int dwmac_s700_probe(struct udevice *dev)
39{
40 dwmac_board_setup();
41
42 /* This is undocumented, phy interface select register */
43 writel(0x4, 0xe024c0a0);
44
45 return designware_eth_probe(dev);
46}
47
Simon Glassaad29ae2020-12-03 16:55:21 -070048static int dwmac_s700_of_to_plat(struct udevice *dev)
Amit Singh Tomar03d6edb2020-05-09 19:55:12 +053049{
Simon Glassaad29ae2020-12-03 16:55:21 -070050 return designware_eth_of_to_plat(dev);
Amit Singh Tomar03d6edb2020-05-09 19:55:12 +053051}
52
53static const struct udevice_id dwmac_s700_ids[] = {
54 {.compatible = "actions,s700-ethernet"},
55 { }
56};
57
58U_BOOT_DRIVER(dwmac_s700) = {
59 .name = "dwmac_s700",
60 .id = UCLASS_ETH,
61 .of_match = dwmac_s700_ids,
Simon Glassaad29ae2020-12-03 16:55:21 -070062 .of_to_plat = dwmac_s700_of_to_plat,
Amit Singh Tomar03d6edb2020-05-09 19:55:12 +053063 .probe = dwmac_s700_probe,
64 .ops = &designware_eth_ops,
Simon Glass8a2b47f2020-12-03 16:55:17 -070065 .priv_auto = sizeof(struct dw_eth_dev),
Simon Glass71fa5b42020-12-03 16:55:18 -070066 .plat_auto = sizeof(struct eth_pdata),
Amit Singh Tomar03d6edb2020-05-09 19:55:12 +053067 .flags = DM_FLAG_ALLOC_PRIV_DMA,
68};