blob: c69cfd4f162215ed7c144bef5c97f0b438846364 [file] [log] [blame]
MD Danish Anwar89d709b2024-04-04 12:38:00 +05301/* SPDX-License-Identifier: GPL-2.0 */
2/* Texas Instruments K3 AM65 Ethernet Switch SubSystem Driver
3 *
4 * Copyright (C) 2018-2024 Texas Instruments Incorporated - https://www.ti.com/
5 *
6 */
7
8#ifndef __NET_TI_ICSSG_PRUETH_H
9#define __NET_TI_ICSSG_PRUETH_H
10
11#include <asm/io.h>
12#include <clk.h>
13#include <dm/lists.h>
14#include <dm/ofnode.h>
15#include <dm/device.h>
16#include <dma-uclass.h>
17#include <regmap.h>
18#include <linux/sizes.h>
19#include <linux/pruss_driver.h>
20#include "icssg_config.h"
21#include "icssg_switch_map.h"
22
23void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac);
24void icssg_class_set_host_mac_addr(struct regmap *miig_rt, u8 *mac);
25void icssg_class_disable(struct regmap *miig_rt, int slice);
26void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti);
27void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr);
28
29enum prueth_mac {
30 PRUETH_MAC0 = 0,
31 PRUETH_MAC1,
32 PRUETH_NUM_MACS,
33};
34
35enum prueth_port {
36 PRUETH_PORT_HOST = 0, /* host side port */
37 PRUETH_PORT_MII0, /* physical port MII 0 */
38 PRUETH_PORT_MII1, /* physical port MII 1 */
39};
40
41struct prueth {
42 struct udevice *dev;
43 struct udevice *pruss;
44 struct regmap *miig_rt;
45 struct regmap *mii_rt;
46 fdt_addr_t mdio_base;
47 struct pruss_mem_region shram;
48 struct pruss_mem_region dram[PRUETH_NUM_MACS];
49 phys_addr_t tmaddr;
50 struct mii_dev *bus;
51 u32 sram_pa;
52 ofnode eth_node[PRUETH_NUM_MACS];
53 u32 mdio_freq;
54 int phy_interface;
55 struct clk mdiofck;
56 struct dma dma_tx;
57 struct dma dma_rx;
58 struct dma dma_rx_mgm;
59 u32 rx_next;
60 u32 rx_pend;
61 int slice;
62 bool mdio_manual_mode;
63 int speed;
64 int duplex;
MD Danish Anwardd18b892024-04-04 12:38:02 +053065 u8 pru_core_id;
66 u8 rtu_core_id;
67 u8 txpru_core_id;
MD Danish Anwar6b8c29e2024-04-04 12:38:03 +053068 u8 icssg_hwcmdseq;
MD Danish Anwar89d709b2024-04-04 12:38:00 +053069};
70
71struct prueth_priv {
72 struct udevice *dev;
73 struct prueth *prueth;
74 u32 port_id;
75 struct phy_device *phydev;
76 bool has_phy;
77 ofnode phy_node;
78 u32 phy_addr;
79 int phy_interface;
80};
81
82/* config helpers */
83void icssg_config_ipg(struct prueth_priv *priv, int speed, int mii);
84int icssg_config(struct prueth_priv *priv);
85int emac_set_port_state(struct prueth_priv *priv, enum icssg_port_state_cmd cmd);
86
MD Danish Anwar6712abb2024-04-04 12:38:01 +053087/* Buffer queue helpers */
88int icssg_queue_pop(struct prueth *prueth, u8 queue);
89void icssg_queue_push(struct prueth *prueth, int queue, u16 addr);
90u32 icssg_queue_level(struct prueth *prueth, int queue);
91
MD Danish Anwar6b8c29e2024-04-04 12:38:03 +053092/* FDB helpers */
93int icssg_send_fdb_msg(struct prueth_priv *priv, struct mgmt_cmd *cmd,
94 struct mgmt_cmd_rsp *rsp);
95int emac_fdb_flow_id_updated(struct prueth_priv *priv);
96
MD Danish Anwar89d709b2024-04-04 12:38:00 +053097#endif /* __NET_TI_ICSSG_PRUETH_H */