Skip to content

Commit

Permalink
Merge pull request #400 from trabucayre/buildroot_refresh
Browse files Browse the repository at this point in the history
Refresh buildroot / adapt from litex_hw_ci
  • Loading branch information
enjoy-digital committed Jul 9, 2024
2 parents b30b2be + d97ae0f commit 674a1f9
Show file tree
Hide file tree
Showing 24 changed files with 6,814 additions and 12 deletions.
11 changes: 5 additions & 6 deletions buildroot/configs/litex_vexriscv_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BR2_RISCV_ABI_ILP32=y
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/patches"

# GCC
BR2_GCC_VERSION_11_X=y
BR2_GCC_VERSION_13_X=y

# System
BR2_TARGET_GENERIC_GETTY=y
Expand All @@ -35,13 +35,12 @@ BR2_TARGET_ROOTFS_CPIO=y
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/board/litex_vexriscv/post-image.sh"

# Kernel header version
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_9=y

# Kernel (litex-rebase branch)
# Kernel (mainline + patches set)
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Dolu1990/litex-linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="ae80e67c6b48bbedcd13db753237a25b3dec8301"
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.9"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/board/litex_vexriscv/linux.config"
BR2_LINUX_KERNEL_IMAGE=y
Expand Down
11 changes: 5 additions & 6 deletions buildroot/configs/litex_vexriscv_usbhost_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BR2_RISCV_ABI_ILP32=y
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/patches"

# GCC
BR2_GCC_VERSION_11_X=y
BR2_GCC_VERSION_13_X=y

# System
BR2_TARGET_GENERIC_GETTY=y
Expand All @@ -35,13 +35,12 @@ BR2_TARGET_ROOTFS_CPIO=y
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/board/litex_vexriscv/post-image.sh"

# Kernel header version
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_9=y

# Kernel (litex-rebase branch)
# Kernel (mainline + patches set)
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/Dolu1990/litex-linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="ae80e67c6b48bbedcd13db753237a25b3dec8301"
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.9"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/board/litex_vexriscv_usbhost/linux.config"
BR2_LINUX_KERNEL_IMAGE=y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
From f803101a8081466b71cf24df45675f79839bc06e Mon Sep 17 00:00:00 2001
From: Antony Pavlov <antonynpavlov@gmail.com>
Date: Wed, 25 Aug 2021 17:36:39 -0400
Subject: [PATCH 01/19] LiteX: LiteEth: add polling support

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
---
drivers/net/ethernet/litex/litex_liteeth.c | 41 ++++++++++++++++++----
1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/litex/litex_liteeth.c b/drivers/net/ethernet/litex/litex_liteeth.c
index ff54fbe41bcc..de2c83c1ecfe 100644
--- a/drivers/net/ethernet/litex/litex_liteeth.c
+++ b/drivers/net/ethernet/litex/litex_liteeth.c
@@ -8,6 +8,7 @@

#include <linux/etherdevice.h>
#include <linux/interrupt.h>
+#include <linux/iopoll.h>
#include <linux/litex.h>
#include <linux/module.h>
#include <linux/of_net.h>
@@ -43,6 +44,10 @@ struct liteeth {
struct device *dev;
u32 slot_size;

+ /* Polling support */
+ int use_polling;
+ struct timer_list poll_timer;
+
/* Tx */
u32 tx_slot;
u32 num_tx_slots;
@@ -111,6 +116,14 @@ static irqreturn_t liteeth_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}

+static void liteeth_timeout(struct timer_list *t)
+{
+ struct liteeth *priv = from_timer(priv, t, poll_timer);
+
+ liteeth_interrupt(0, priv->netdev);
+ mod_timer(&priv->poll_timer, jiffies + msecs_to_jiffies(10));
+}
+
static int liteeth_open(struct net_device *netdev)
{
struct liteeth *priv = netdev_priv(netdev);
@@ -120,10 +133,16 @@ static int liteeth_open(struct net_device *netdev)
litex_write8(priv->base + LITEETH_WRITER_EV_PENDING, 1);
litex_write8(priv->base + LITEETH_READER_EV_PENDING, 1);

- err = request_irq(netdev->irq, liteeth_interrupt, 0, netdev->name, netdev);
- if (err) {
- netdev_err(netdev, "failed to request irq %d\n", netdev->irq);
- return err;
+ if (priv->use_polling) {
+ timer_setup(&priv->poll_timer, liteeth_timeout, 0);
+ mod_timer(&priv->poll_timer, jiffies + msecs_to_jiffies(50));
+ } else {
+ err = request_irq(netdev->irq, liteeth_interrupt, 0, netdev->name, netdev);
+ if (err) {
+ netdev_err(netdev, "failed to request irq %d\n", netdev->irq);
+ return err;
+ }
+
}

/* Enable IRQs */
@@ -146,7 +165,11 @@ static int liteeth_stop(struct net_device *netdev)
litex_write8(priv->base + LITEETH_WRITER_EV_ENABLE, 0);
litex_write8(priv->base + LITEETH_READER_EV_ENABLE, 0);

- free_irq(netdev->irq, netdev);
+ if (priv->use_polling) {
+ del_timer_sync(&priv->poll_timer);
+ } else {
+ free_irq(netdev->irq, netdev);
+ }

return 0;
}
@@ -253,9 +276,13 @@ static int liteeth_probe(struct platform_device *pdev)
if (!netdev->tstats)
return -ENOMEM;

+ priv->use_polling = 0;
irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
+ if (irq < 0) {
+ dev_err(&pdev->dev, "Failed to get IRQ, using polling\n");
+ priv->use_polling = 1;
+ irq = 0;
+ }
netdev->irq = irq;

priv->base = devm_platform_ioremap_resource_byname(pdev, "mac");
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From e4912261137f29a582455989e329b8a7ee35bf80 Mon Sep 17 00:00:00 2001
From: Gabriel Somlo <gsomlo@gmail.com>
Date: Wed, 8 Dec 2021 07:43:45 -0500
Subject: [PATCH 02/19] LiteSDCard: re-introduce gpio-based card detection

This is untested, and therefore unsuitable for upstreaming at this
time. We need an example configuration in Doc/dt/bindings/mmc/litex*
and a successful `tested-by` on hardware before we should consider
pushing this into upstream linux.

Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
---
drivers/mmc/host/litex_mmc.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c
index 4ec8072dc60b..960a19ce7d4b 100644
--- a/drivers/mmc/host/litex_mmc.c
+++ b/drivers/mmc/host/litex_mmc.c
@@ -23,6 +23,7 @@
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
+#include <linux/mmc/slot-gpio.h>

#define LITEX_PHY_CARDDETECT 0x00
#define LITEX_PHY_CLOCKERDIV 0x04
@@ -240,7 +241,15 @@ static int litex_mmc_get_cd(struct mmc_host *mmc)
if (!mmc_card_is_removable(mmc))
return 1;

- ret = !litex_read8(host->sdphy + LITEX_PHY_CARDDETECT);
+ ret = mmc_gpio_get_cd(mmc);
+ if (ret >= 0) {
+ /* GPIO based card-detect explicitly specified in DTS */
+ ret = !!ret;
+ } else {
+ /* Use gateware card-detect bit by default */
+ ret = !litex_read8(host->sdphy + LITEX_PHY_CARDDETECT);
+ }
+
if (ret)
return ret;

--
2.43.0

Loading

0 comments on commit 674a1f9

Please sign in to comment.