Skip to content

Commit b8d5008

Browse files
danish-tidavem330
authored andcommitted
net: ti: icssg-prueth: Add icssg queues APIs and macros
Add icssg_queue.c file. This file introduces macros and APIs related to ICSSG queues. These will be used by ICSSG Ethernet driver. Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: MD Danish Anwar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e9b4ece commit b8d5008

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

drivers/net/ethernet/ti/icssg/icssg_prueth.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,9 @@ int emac_set_port_state(struct prueth_emac *emac,
209209
enum icssg_port_state_cmd state);
210210
void icssg_config_set_speed(struct prueth_emac *emac);
211211

212+
/* Buffer queue helpers */
213+
int icssg_queue_pop(struct prueth *prueth, u8 queue);
214+
void icssg_queue_push(struct prueth *prueth, int queue, u16 addr);
215+
u32 icssg_queue_level(struct prueth *prueth, int queue);
216+
212217
#endif /* __NET_TI_ICSSG_PRUETH_H */
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* ICSSG Buffer queue helpers
3+
*
4+
* Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com
5+
*/
6+
7+
#include <linux/regmap.h>
8+
#include "icssg_prueth.h"
9+
10+
#define ICSSG_QUEUES_MAX 64
11+
#define ICSSG_QUEUE_OFFSET 0xd00
12+
#define ICSSG_QUEUE_PEEK_OFFSET 0xe00
13+
#define ICSSG_QUEUE_CNT_OFFSET 0xe40
14+
#define ICSSG_QUEUE_RESET_OFFSET 0xf40
15+
16+
int icssg_queue_pop(struct prueth *prueth, u8 queue)
17+
{
18+
u32 val, cnt;
19+
20+
if (queue >= ICSSG_QUEUES_MAX)
21+
return -EINVAL;
22+
23+
regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, &cnt);
24+
if (!cnt)
25+
return -EINVAL;
26+
27+
regmap_read(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, &val);
28+
29+
return val;
30+
}
31+
32+
void icssg_queue_push(struct prueth *prueth, int queue, u16 addr)
33+
{
34+
if (queue >= ICSSG_QUEUES_MAX)
35+
return;
36+
37+
regmap_write(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, addr);
38+
}
39+
40+
u32 icssg_queue_level(struct prueth *prueth, int queue)
41+
{
42+
u32 reg;
43+
44+
if (queue >= ICSSG_QUEUES_MAX)
45+
return 0;
46+
47+
regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, &reg);
48+
49+
return reg;
50+
}

0 commit comments

Comments
 (0)