summaryrefslogtreecommitdiffstats
path: root/drivers/net/designware_eqos.h
blob: 969a524c0a953b0a3f5f388f6e2684072893abb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2019 Ahmad Fatoum, Pengutronix
 */

#ifndef __EQOS_H_
#define __EQOS_H_

struct eqos;
struct eth_device;

struct eqos_ops {
	int (*init)(struct device_d *dev, struct eqos *priv);
	int (*start)(struct eth_device *edev);
	void (*stop)(struct eth_device *edev);
	int (*get_ethaddr)(struct eth_device *dev, unsigned char *mac);
	int (*set_ethaddr)(struct eth_device *edev, const unsigned char *mac);
	void (*adjust_link)(struct eth_device *edev);
	unsigned long (*get_csr_clk_rate)(struct eqos *);

	bool enh_desc;
	int mdio_wait_us;

#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_SHIFT		0
#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_MASK		3
#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_NOT_ENABLED	0
#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB	2
#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV	1
	unsigned clk_csr;

#define EQOS_MDIO_ADDR_CR_20_35			2
#define EQOS_MDIO_ADDR_CR_250_300		5
#define EQOS_MDIO_ADDR_SKAP			BIT(4)
#define EQOS_MDIO_ADDR_GOC_SHIFT		2
#define EQOS_MDIO_ADDR_GOC_READ			3
#define EQOS_MDIO_ADDR_GOC_WRITE		1
#define EQOS_MDIO_ADDR_C45E			BIT(1)
	unsigned config_mac;
};

struct eqos_desc;
struct eqos_dma_regs;
struct eqos_mac_regs;
struct eqos_mtl_regs;

struct eqos {
	struct eth_device netdev;
	struct mii_bus miibus;

	u8 macaddr[6];

	u32 tx_currdescnum, rx_currdescnum;

	struct eqos_desc *tx_descs, *rx_descs;

	void __iomem *regs;
	struct eqos_mac_regs __iomem *mac_regs;
	struct eqos_dma_regs __iomem *dma_regs;
	struct eqos_mtl_regs __iomem *mtl_regs;

	int phy_addr;
	phy_interface_t interface;

	const struct eqos_ops *ops;
	void *priv;
	bool started;
};

struct device_d;
int eqos_probe(struct device_d *dev, const struct eqos_ops *ops, void *priv);
void eqos_remove(struct device_d *dev);
int eqos_reset(struct eqos *priv);

int eqos_get_ethaddr(struct eth_device *edev, unsigned char *mac);
int eqos_set_ethaddr(struct eth_device *edev, const unsigned char *mac);
int eqos_start(struct eth_device *edev);
void eqos_stop(struct eth_device *edev);
void eqos_adjust_link(struct eth_device *edev);

#define eqos_dbg(eqos, ...) dev_dbg(&eqos->netdev.dev, __VA_ARGS__)
#define eqos_warn(eqos, ...) dev_warn(&eqos->netdev.dev, __VA_ARGS__)
#define eqos_err(eqos, ...) dev_err(&eqos->netdev.dev, __VA_ARGS__)

#endif