Amit Singh Tomar | 03d6edb | 2020-05-09 19:55:12 +0530 | [diff] [blame] | 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 | |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 8 | #include <asm/global_data.h> |
Amit Singh Tomar | 03d6edb | 2020-05-09 19:55:12 +0530 | [diff] [blame] | 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 | |
| 20 | /* pin control for MAC */ |
| 21 | #define RMII_TXD01_MFP_CTL0 (0x0 << 16) |
| 22 | #define RMII_RXD01_MFP_CTL0 (0x0 << 8) |
| 23 | #define RMII_TXEN_TXER_MFP_CTL0 (0x0 << 13) |
| 24 | #define RMII_REF_CLK_MFP_CTL0 (0x0 << 6) |
| 25 | #define CLKO_25M_EN_MFP_CTL3 BIT(30) |
| 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
| 29 | static void dwmac_board_setup(void) |
| 30 | { |
| 31 | clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 | |
| 32 | RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0)); |
| 33 | |
| 34 | setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3); |
| 35 | } |
| 36 | |
| 37 | static int dwmac_s700_probe(struct udevice *dev) |
| 38 | { |
| 39 | dwmac_board_setup(); |
| 40 | |
| 41 | /* This is undocumented, phy interface select register */ |
| 42 | writel(0x4, 0xe024c0a0); |
| 43 | |
| 44 | return designware_eth_probe(dev); |
| 45 | } |
| 46 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 47 | static int dwmac_s700_of_to_plat(struct udevice *dev) |
Amit Singh Tomar | 03d6edb | 2020-05-09 19:55:12 +0530 | [diff] [blame] | 48 | { |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 49 | return designware_eth_of_to_plat(dev); |
Amit Singh Tomar | 03d6edb | 2020-05-09 19:55:12 +0530 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static const struct udevice_id dwmac_s700_ids[] = { |
| 53 | {.compatible = "actions,s700-ethernet"}, |
| 54 | { } |
| 55 | }; |
| 56 | |
| 57 | U_BOOT_DRIVER(dwmac_s700) = { |
| 58 | .name = "dwmac_s700", |
| 59 | .id = UCLASS_ETH, |
| 60 | .of_match = dwmac_s700_ids, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 61 | .of_to_plat = dwmac_s700_of_to_plat, |
Amit Singh Tomar | 03d6edb | 2020-05-09 19:55:12 +0530 | [diff] [blame] | 62 | .probe = dwmac_s700_probe, |
| 63 | .ops = &designware_eth_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 64 | .priv_auto = sizeof(struct dw_eth_dev), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 65 | .plat_auto = sizeof(struct eth_pdata), |
Amit Singh Tomar | 03d6edb | 2020-05-09 19:55:12 +0530 | [diff] [blame] | 66 | .flags = DM_FLAG_ALLOC_PRIV_DMA, |
| 67 | }; |