-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <andrew@lunn.ch> Signed-off-by: MD Danish Anwar <danishanwar@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
MD Danish Anwar
authored and
David S. Miller
committed
Aug 2, 2023
1 parent
e9b4ece
commit b8d5008
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* ICSSG Buffer queue helpers | ||
* | ||
* Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com | ||
*/ | ||
|
||
#include <linux/regmap.h> | ||
#include "icssg_prueth.h" | ||
|
||
#define ICSSG_QUEUES_MAX 64 | ||
#define ICSSG_QUEUE_OFFSET 0xd00 | ||
#define ICSSG_QUEUE_PEEK_OFFSET 0xe00 | ||
#define ICSSG_QUEUE_CNT_OFFSET 0xe40 | ||
#define ICSSG_QUEUE_RESET_OFFSET 0xf40 | ||
|
||
int icssg_queue_pop(struct prueth *prueth, u8 queue) | ||
{ | ||
u32 val, cnt; | ||
|
||
if (queue >= ICSSG_QUEUES_MAX) | ||
return -EINVAL; | ||
|
||
regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, &cnt); | ||
if (!cnt) | ||
return -EINVAL; | ||
|
||
regmap_read(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, &val); | ||
|
||
return val; | ||
} | ||
|
||
void icssg_queue_push(struct prueth *prueth, int queue, u16 addr) | ||
{ | ||
if (queue >= ICSSG_QUEUES_MAX) | ||
return; | ||
|
||
regmap_write(prueth->miig_rt, ICSSG_QUEUE_OFFSET + 4 * queue, addr); | ||
} | ||
|
||
u32 icssg_queue_level(struct prueth *prueth, int queue) | ||
{ | ||
u32 reg; | ||
|
||
if (queue >= ICSSG_QUEUES_MAX) | ||
return 0; | ||
|
||
regmap_read(prueth->miig_rt, ICSSG_QUEUE_CNT_OFFSET + 4 * queue, ®); | ||
|
||
return reg; | ||
} |