mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Thomas Hämmerle" <Thomas.Haemmerle@wolfvision.net>
To: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Cc: "Thomas Hämmerle" <Thomas.Haemmerle@wolfvision.net>
Subject: [PATCH 5/6] macb: disable second priority queue for zynqmp gem support
Date: Tue, 8 Jan 2019 14:35:57 +0000	[thread overview]
Message-ID: <1546958133-6556-5-git-send-email-thomas.haemmerle@wolfvision.net> (raw)
In-Reply-To: <1546958133-6556-1-git-send-email-thomas.haemmerle@wolfvision.net>

Provide descriptors for second priority rx and tx queues and disable the
the queues if hardware is GEM. Otherwise the function macb_send() will run
into a timeout.

Signed-off-by: Thomas Haemmerle <thomas.haemmerle@wolfvision.net>
---
 drivers/net/macb.c | 21 +++++++++++++++++++++
 drivers/net/macb.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index c129282..2a30457 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -46,9 +46,11 @@
 #define RX_BUFFER_MULTIPLE	64  /* bytes */
 #define RX_NB_PACKET		10
 #define TX_RING_SIZE		2 /* must be power of 2 */
+#define GEM_Q1_DESCS		2
 
 #define RX_RING_BYTES(bp)	(sizeof(struct macb_dma_desc) * bp->rx_ring_size)
 #define TX_RING_BYTES		(sizeof(struct macb_dma_desc) * TX_RING_SIZE)
+#define GEM_Q1_DESC_BYTES	(sizeof(struct macb_dma_desc) * GEM_Q1_DESCS)
 
 struct macb_device {
 	void			__iomem *regs;
@@ -60,6 +62,7 @@ struct macb_device {
 	void			*tx_buffer;
 	struct macb_dma_desc	*rx_ring;
 	struct macb_dma_desc	*tx_ring;
+	struct macb_dma_desc	*gem_q1_descs;
 
 	int			rx_buffer_size;
 	int			rx_ring_size;
@@ -340,6 +343,20 @@ static void macb_init(struct macb_device *macb)
 	macb_writel(macb, RBQP, (ulong)macb->rx_ring);
 	macb_writel(macb, TBQP, (ulong)macb->tx_ring);
 
+	if (macb->is_gem && macb->gem_q1_descs) {
+		/* Disable the second priority queue */
+		macb->gem_q1_descs[0].addr = 0;
+		macb->gem_q1_descs[0].ctrl = MACB_BIT(TX_WRAP) |
+				MACB_BIT(TX_LAST) |
+				MACB_BIT(TX_USED);
+		macb->gem_q1_descs[1].addr = MACB_BIT(RX_USED) |
+				MACB_BIT(RX_WRAP);
+		macb->gem_q1_descs[1].ctrl = 0;
+
+		gem_writel(macb, TQ1, (ulong)&macb->gem_q1_descs[0]);
+		gem_writel(macb, RQ1, (ulong)&macb->gem_q1_descs[1]);
+	}
+
 	switch(macb->interface) {
 	case PHY_INTERFACE_MODE_RGMII:
 		val = GEM_BIT(RGMII);
@@ -689,6 +706,10 @@ static int macb_probe(struct device_d *dev)
 	macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb), DMA_ADDRESS_BROKEN);
 	macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES, DMA_ADDRESS_BROKEN);
 
+	if (macb->is_gem)
+		macb->gem_q1_descs = dma_alloc_coherent(GEM_Q1_DESC_BYTES,
+				DMA_ADDRESS_BROKEN);
+
 	macb_reset_hw(macb);
 	ncfgr = macb_mdc_clk_div(macb);
 	ncfgr |= MACB_BIT(PAE);		/* PAuse Enable */
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 6be9732..979f53c 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -72,6 +72,8 @@
 #define GEM_DCFG5				0x0290
 #define GEM_DCFG6				0x0294
 #define GEM_DCFG7				0x0298
+#define GEM_TQ1					0x0440
+#define GEM_RQ1					0x0480
 
 /* Bitfields in NCR */
 #define MACB_LB_OFFSET				0
-- 
2.7.4


Thomas Hämmerle
Research and Development 

Wolfvision GmbH
 | 6833 Klaus | Austria 
Tel: +43 5523 52250 | Mail: Thomas.Haemmerle@wolfvision.net 

Webpage: www.wolfvision.com | www.wolfvision.com/green
Firmenbuch / Commercial Register: FN283521v Feldkirch/Austria


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-01-08 14:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <afd44571-b69b-41cc-bf15-9eff29f89a72.95bf7d06-047e-438c-8c7b-895af195351a.c64368fe-8a97-44b6-81ce-d981799f53c2@emailsignatures365.codetwo.com>
2019-01-08 14:35 ` [PATCH 1/6] dp83867: port from linux Thomas Hämmerle
     [not found]   ` <afd44571-b69b-41cc-bf15-9eff29f89a72.95bf7d06-047e-438c-8c7b-895af195351a.2f59ab5f-ece6-4f67-bfed-5c6c80a92f11@emailsignatures365.codetwo.com>
2019-01-08 14:35     ` [PATCH 2/6] macb: fix format specifiers for debug output Thomas Hämmerle
     [not found]   ` <afd44571-b69b-41cc-bf15-9eff29f89a72.95bf7d06-047e-438c-8c7b-895af195351a.e3a33094-2d73-4d32-bde8-2dc1ddd31fbf@emailsignatures365.codetwo.com>
2019-01-08 14:35     ` [PATCH 3/6] macb: fix check if hw is gem Thomas Hämmerle
     [not found]   ` <afd44571-b69b-41cc-bf15-9eff29f89a72.95bf7d06-047e-438c-8c7b-895af195351a.d7953183-96ef-4a79-9c25-4e47b7b852de@emailsignatures365.codetwo.com>
2019-01-08 14:35     ` [PATCH 4/6] macb: fix memory leakage due to double allocation of rx_buffer Thomas Hämmerle
     [not found]   ` <afd44571-b69b-41cc-bf15-9eff29f89a72.95bf7d06-047e-438c-8c7b-895af195351a.365885ea-854d-40ae-9139-9d74dd250caf@emailsignatures365.codetwo.com>
2019-01-08 14:35     ` Thomas Hämmerle [this message]
     [not found]   ` <afd44571-b69b-41cc-bf15-9eff29f89a72.95bf7d06-047e-438c-8c7b-895af195351a.d8af94ec-04db-4c9a-8f5a-ca89336b761c@emailsignatures365.codetwo.com>
2019-01-08 14:36     ` [PATCH 6/6] zynqmp: enable macb Ethernet support Thomas Hämmerle
2019-01-09  7:22   ` [PATCH 1/6] dp83867: port from linux Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1546958133-6556-5-git-send-email-thomas.haemmerle@wolfvision.net \
    --to=thomas.haemmerle@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox