[PATCH 5/5] commands: smc: make command usable when ARM_PSCI is undefined

2019-11-14 Thread Ahmad Fatoum
The smc command can be useful whenever PSCI is used, regardless of
whether barebox provides the secure monitor or not. Have it depend
on ARM_SMCCC instead.

Signed-off-by: Ahmad Fatoum 
---
 commands/Kconfig | 2 +-
 commands/smc.c   | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 08b3af8b20f2..7784966282ac 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1869,7 +1869,7 @@ config CMD_POWEROFF
 
 config CMD_SMC
bool
-   depends on ARM_PSCI
+   depends on ARM_SMCCC
prompt "PSCI test command"
default CONFIG_ARM_PSCI_DEBUG
help
diff --git a/commands/smc.c b/commands/smc.c
index 997103676eba..84102f3249bc 100644
--- a/commands/smc.c
+++ b/commands/smc.c
@@ -97,6 +97,11 @@ static int do_smc(int argc, char *argv[])
while ((opt = getopt(argc, argv, "nic")) > 0) {
switch (opt) {
case 'n':
+   if (!IS_ENABLED(CONFIG_ARM_SECURE_MONITOR)) {
+   printf("secure monitor support not compiled 
in\n");
+   return COMMAND_ERROR;
+   }
+
armv7_secure_monitor_install();
break;
case 'i':
-- 
2.20.1


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


[PATCH 3/5] commands: psci: make locally-used function static

2019-11-14 Thread Ahmad Fatoum
Fixes a warning that the function is global, but without prototype.
No functional change.

Signed-off-by: Ahmad Fatoum 
---
 commands/smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/smc.c b/commands/smc.c
index 67ca4ee9022f..eb96e581dc02 100644
--- a/commands/smc.c
+++ b/commands/smc.c
@@ -8,7 +8,7 @@
 #include 
 #include 
 
-void second_entry(void)
+static void second_entry(void)
 {
struct arm_smccc_res res;
 
-- 
2.20.1


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


[PATCH 2/5] ARM: psci: properly wire in command help

2019-11-14 Thread Ahmad Fatoum
This was supposed to happen in 9efa1f8b ("ARM: psci: wire in smc command
help") along with some other changes. After rebases, the other changes
remained but this one was lost.. Do this right this time and specify the
appropriate BAREBOX_CMD_HELP.

Fixes: 9efa1f8b ("ARM: psci: wire in smc command help")
Signed-off-by: Ahmad Fatoum 
---
 commands/smc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/commands/smc.c b/commands/smc.c
index 2a00e1586790..67ca4ee9022f 100644
--- a/commands/smc.c
+++ b/commands/smc.c
@@ -103,5 +103,6 @@ BAREBOX_CMD_HELP_END
 BAREBOX_CMD_START(smc)
.cmd = do_smc,
BAREBOX_CMD_DESC("secure monitor test command")
+   BAREBOX_CMD_HELP(cmd_smc_help)
BAREBOX_CMD_GROUP(CMD_GRP_MISC)
 BAREBOX_CMD_END
-- 
2.20.1


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


[PATCH 1/5] ARM: psci: factor out smc command into commands/

2019-11-14 Thread Ahmad Fatoum
So far, the smc command was only usable when barebox also provides the
secure monitor. It's useful to have it when barebox is a PSCI consumer
as well to test whether the secure monitor works.
Factor out the code into commands/ in preparation to do so.
No functional change.

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/cpu/psci.c | 105 ---
 commands/Kconfig|  15 +++
 commands/Makefile   |   1 +
 commands/smc.c  | 107 
 4 files changed, 123 insertions(+), 105 deletions(-)
 create mode 100644 commands/smc.c

diff --git a/arch/arm/cpu/psci.c b/arch/arm/cpu/psci.c
index 22ce1dfd0e84..713ab2396c01 100644
--- a/arch/arm/cpu/psci.c
+++ b/arch/arm/cpu/psci.c
@@ -227,108 +227,3 @@ static int armv7_psci_init(void)
return of_register_fixup(of_psci_do_fixup, NULL);
 }
 device_initcall(armv7_psci_init);
-
-#ifdef CONFIG_ARM_PSCI_DEBUG
-
-#include 
-#include 
-#include "mmu.h"
-
-void second_entry(void)
-{
-   struct arm_smccc_res res;
-
-   psci_printf("2nd CPU online, now turn off again\n");
-
-   arm_smccc_smc(ARM_PSCI_0_2_FN_CPU_OFF,
- 0, 0, 0, 0, 0, 0, 0, &res);
-
-   psci_printf("2nd CPU still alive?\n");
-
-   while (1);
-}
-
-static const char *psci_xlate_str(long err)
-{
-   static char errno_string[sizeof "error 0x123456789ABCDEF0"];
-
-   switch(err)
-   {
-   case ARM_PSCI_RET_SUCCESS:
-  return "Success";
-   case ARM_PSCI_RET_NOT_SUPPORTED:
-  return "Operation not supported";
-   case ARM_PSCI_RET_INVAL:
-  return "Invalid argument";
-   case ARM_PSCI_RET_DENIED:
-  return "Operation not permitted";
-   case ARM_PSCI_RET_ALREADY_ON:
-  return "CPU already on";
-   case ARM_PSCI_RET_ON_PENDING:
-  return "CPU_ON in progress";
-   case ARM_PSCI_RET_INTERNAL_FAILURE:
-  return "Internal failure";
-   case ARM_PSCI_RET_NOT_PRESENT:
-  return "Trusted OS not present on core";
-   case ARM_PSCI_RET_DISABLED:
-  return "CPU is disabled";
-   case ARM_PSCI_RET_INVALID_ADDRESS:
-  return "Bad address";
-   }
-
-   sprintf(errno_string, "error 0x%lx", err);
-   return errno_string;
-}
-
-static int do_smc(int argc, char *argv[])
-{
-   long ret;
-   int opt;
-   struct arm_smccc_res res = {
-   .a0 = 0xdeadbee0,
-   .a1 = 0xdeadbee1,
-   .a2 = 0xdeadbee2,
-   .a3 = 0xdeadbee3,
-   };
-
-   if (argc < 2)
-   return COMMAND_ERROR_USAGE;
-
-   while ((opt = getopt(argc, argv, "nic")) > 0) {
-   switch (opt) {
-   case 'n':
-   armv7_secure_monitor_install();
-   break;
-   case 'i':
-   arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION,
- 0, 0, 0, 0, 0, 0, 0, &res);
-   printf("found psci version %ld.%ld\n", res.a0 >> 16, 
res.a0 & 0x);
-   break;
-   case 'c':
-   arm_smccc_smc(ARM_PSCI_0_2_FN_CPU_ON,
- 1, (unsigned long)second_entry, 0, 0, 0, 
0, 0, &res);
-   ret = (long)res.a0;
-   printf("CPU_ON returns with: %s\n", 
psci_xlate_str(ret));
-   if (ret)
-   return COMMAND_ERROR;
-   }
-   }
-
-
-   return 0;
-}
-BAREBOX_CMD_HELP_START(smc)
-BAREBOX_CMD_HELP_TEXT("Secure monitor code test command")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-n",  "Install secure monitor and switch to nonsecure 
mode")
-BAREBOX_CMD_HELP_OPT ("-i",  "Show information about installed PSCI version")
-BAREBOX_CMD_HELP_OPT ("-c",  "Start secondary CPU core")
-BAREBOX_CMD_HELP_END
-
-BAREBOX_CMD_START(smc)
-   .cmd = do_smc,
-   BAREBOX_CMD_DESC("secure monitor test command")
-   BAREBOX_CMD_GROUP(CMD_GRP_MISC)
-BAREBOX_CMD_END
-#endif
diff --git a/commands/Kconfig b/commands/Kconfig
index a6db52ae54b7..08b3af8b20f2 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1867,6 +1867,21 @@ config CMD_POWEROFF
help
  Turn the power off.
 
+config CMD_SMC
+   bool
+   depends on ARM_PSCI
+   prompt "PSCI test command"
+   default CONFIG_ARM_PSCI_DEBUG
+   help
+ Secure monitor code test command
+
+ Usage: smc [-nic]
+
+ Options:
+   -n  Install secure monitor and switch to nonsecure mode
+   -i  Show information about installed PSCI version
+   -c  Start secondary CPU core
+
 config CMD_SPI
bool
depends on SPI
diff --git a/commands/Makefile b/commands/Makefile
index 2f0980185c2b..01082de44c9b 100644
--- a/commands/Makefile
++

[PATCH 4/5] commands: smc: verify PSCI_POWER_ON with interprocessor handshake

2019-11-14 Thread Ahmad Fatoum
The use of psci_printf here, at least for the phytec-phycore-imx7,
is racy, because access to the UART is not synchronized. This may
lead to characters being swallowed and most certainly to garbled
text. One way around this would be using separate UART ports for
each core or even more generically, just dropping psci_printf and
resorting to inter-core communication over shared-memory to check
whether code execution succeeded.

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/cpu/Makefile |  2 +-
 commands/smc.c| 61 ++-
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 09b3bc2eeab9..75cd42a5e271 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -2,7 +2,7 @@ obj-y += cpu.o
 
 obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions$(S64).o interrupts$(S64).o
 obj-$(CONFIG_MMU) += mmu$(S64).o mmu-common.o
-lwl-y += lowlevel$(S64).o
+obj-pbl-y += lowlevel$(S64).o
 obj-pbl-$(CONFIG_MMU) += mmu-early$(S64).o
 obj-pbl-$(CONFIG_CPU_32v7) += hyp.o
 AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
diff --git a/commands/smc.c b/commands/smc.c
index eb96e581dc02..997103676eba 100644
--- a/commands/smc.c
+++ b/commands/smc.c
@@ -3,23 +3,47 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
 #include 
 
-static void second_entry(void)
+#define STACK_SIZE 100
+#define HANDSHAKE_MAGIC0xBA12EB0C
+#define ERROR_MAGIC0xDEADBEEF
+
+struct cpu_context {
+   unsigned long stack[STACK_SIZE];
+   long handshake;
+};
+
+static void noinline cpu_handshake(long *handshake)
 {
struct arm_smccc_res res;
 
-   psci_printf("2nd CPU online, now turn off again\n");
+   writel(HANDSHAKE_MAGIC, handshake);
 
arm_smccc_smc(ARM_PSCI_0_2_FN_CPU_OFF,
  0, 0, 0, 0, 0, 0, 0, &res);
 
-   psci_printf("2nd CPU still alive?\n");
+   writel(ERROR_MAGIC, handshake);
+
+   while (1)
+   ;
+}
+
+static void __naked second_entry(unsigned long arg0)
+{
+   struct cpu_context *context = (void*)arg0;
+
+   arm_cpu_lowlevel_init();
+   arm_setup_stack((unsigned long)&context->stack[STACK_SIZE]);
+   barrier();
 
-   while (1);
+   cpu_handshake(&context->handshake);
 }
 
 static const char *psci_xlate_str(long err)
@@ -54,6 +78,8 @@ static const char *psci_xlate_str(long err)
return errno_string;
 }
 
+static struct cpu_context *context;
+
 static int do_smc(int argc, char *argv[])
 {
long ret;
@@ -79,12 +105,35 @@ static int do_smc(int argc, char *argv[])
printf("found psci version %ld.%ld\n", res.a0 >> 16, 
res.a0 & 0x);
break;
case 'c':
+   if (!context)
+   context = dma_alloc_coherent(sizeof(*context),
+
DMA_ADDRESS_BROKEN);
+
+   if (!context) {
+   printf("Out of memory\n");
+   return COMMAND_ERROR;
+   }
+
arm_smccc_smc(ARM_PSCI_0_2_FN_CPU_ON,
- 1, (unsigned long)second_entry, 0, 0, 0, 
0, 0, &res);
+ 1, (unsigned long)second_entry, (unsigned 
long)context,
+ 0, 0, 0, 0, &res);
ret = (long)res.a0;
printf("CPU_ON returns with: %s\n", 
psci_xlate_str(ret));
-   if (ret)
+   if (ret) {
+   unsigned long magic = 
readl(&context->handshake);
+   if (magic == ERROR_MAGIC)
+   printf("Turning off CPU had failed\n");
return COMMAND_ERROR;
+   }
+
+   readl_poll_timeout(&context->handshake, ret,
+  ret != HANDSHAKE_MAGIC, 
USEC_PER_SEC);
+   if (ret == 0) {
+   printf("Second CPU handshake timed out.\n");
+   return COMMAND_ERROR;
+   }
+
+   printf("Second CPU handshake successful.\n");
}
}
 
-- 
2.20.1


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


[PATCH 1/3] net: designware: eqos: properly stop DMA on halt

2019-11-14 Thread Ahmad Fatoum
From: Ahmad Fatoum 

Specifying ->halt only means that it's called along with eth_unregister.
If we want to halt the DMA, we will have to call it ourselves in the
remove callback. Do this.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/designware_eqos.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/designware_eqos.c b/drivers/net/designware_eqos.c
index a49239e0573e..52a5ec272e7f 100644
--- a/drivers/net/designware_eqos.c
+++ b/drivers/net/designware_eqos.c
@@ -869,6 +869,8 @@ void eqos_remove(struct device_d *dev)
 {
struct eqos *eqos = dev->priv;
 
+   eth_unregister(&eqos->netdev);
+
mdiobus_unregister(&eqos->miibus);
 
dma_free(phys_to_virt(eqos->rx_descs[0].des0));
-- 
2.20.1


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


[PATCH 2/3] net: designware: eqos: enable clocks before mdio_register

2019-11-14 Thread Ahmad Fatoum
We can't be using the MAC including the MDIO controller while the clocks
are off, but this is exactly the case when mdio_register is called and
the interface is not yet up. To allow reading the PHY id to succeed
before the interface is up, turn on the clocks as part of the
initialization in the probe.

This fixes following error at probe time:

ERROR: : MDIO not idle at entry

The NULL is fixed in a follow-up commit.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/designware_eqos.c |  8 +++---
 drivers/net/designware_eqos.h |  4 ---
 drivers/net/designware_stm32.c| 33 +-
 drivers/net/designware_tegra186.c | 47 ++-
 4 files changed, 14 insertions(+), 78 deletions(-)

diff --git a/drivers/net/designware_eqos.c b/drivers/net/designware_eqos.c
index 52a5ec272e7f..84dcd04a3fc9 100644
--- a/drivers/net/designware_eqos.c
+++ b/drivers/net/designware_eqos.c
@@ -365,7 +365,7 @@ static int phy_resume(struct phy_device *phydev)
return 0;
 }
 
-int eqos_start(struct eth_device *edev)
+static int eqos_start(struct eth_device *edev)
 {
struct eqos *eqos = edev->priv;
u32 val, tx_fifo_sz, rx_fifo_sz, tqs, rqs, pbl;
@@ -611,7 +611,7 @@ int eqos_start(struct eth_device *edev)
return 0;
 }
 
-void eqos_stop(struct eth_device *edev)
+static void eqos_stop(struct eth_device *edev)
 {
struct eqos *eqos = edev->priv;
int i;
@@ -841,10 +841,10 @@ int eqos_probe(struct device_d *dev, const struct 
eqos_ops *ops, void *priv)
dev->priv = edev->priv = eqos;
 
edev->parent = dev;
-   edev->open = ops->start;
+   edev->open = eqos_start;
edev->send = eqos_send;
edev->recv = eqos_recv;
-   edev->halt = ops->stop;
+   edev->halt = eqos_stop;
edev->get_ethaddr = ops->get_ethaddr;
edev->set_ethaddr = ops->set_ethaddr;
 
diff --git a/drivers/net/designware_eqos.h b/drivers/net/designware_eqos.h
index 969a524c0a95..f794195db4a1 100644
--- a/drivers/net/designware_eqos.h
+++ b/drivers/net/designware_eqos.h
@@ -11,8 +11,6 @@ struct eth_device;
 
 struct eqos_ops {
int (*init)(struct device_d *dev, struct eqos *priv);
-   int (*start)(struct eth_device *edev);
-   void (*stop)(struct eth_device *edev);
int (*get_ethaddr)(struct eth_device *dev, unsigned char *mac);
int (*set_ethaddr)(struct eth_device *edev, const unsigned char *mac);
void (*adjust_link)(struct eth_device *edev);
@@ -73,8 +71,6 @@ int eqos_reset(struct eqos *priv);
 
 int eqos_get_ethaddr(struct eth_device *edev, unsigned char *mac);
 int eqos_set_ethaddr(struct eth_device *edev, const unsigned char *mac);
-int eqos_start(struct eth_device *edev);
-void eqos_stop(struct eth_device *edev);
 void eqos_adjust_link(struct eth_device *edev);
 
 #define eqos_dbg(eqos, ...) dev_dbg(&eqos->netdev.dev, __VA_ARGS__)
diff --git a/drivers/net/designware_stm32.c b/drivers/net/designware_stm32.c
index bb6781fb3450..4c682a5daca3 100644
--- a/drivers/net/designware_stm32.c
+++ b/drivers/net/designware_stm32.c
@@ -164,16 +164,6 @@ static int eqos_init_stm32(struct device_d *dev, struct 
eqos *eqos)
dev_dbg(dev, "No phy clock provided. Continuing without.\n");
}
 
-   return 0;
-
-}
-
-static int eqos_start_stm32(struct eth_device *edev)
-{
-   struct eqos *eqos = edev->priv;
-   struct eqos_stm32 *priv = to_stm32(eqos);
-   int ret;
-
ret = clk_bulk_enable(priv->num_clks, priv->clks);
if (ret < 0) {
eqos_err(eqos, "clk_bulk_enable() failed: %s\n",
@@ -181,35 +171,13 @@ static int eqos_start_stm32(struct eth_device *edev)
return ret;
}
 
-   udelay(10);
-
-   ret = eqos_start(edev);
-   if (ret)
-   goto err_stop_clks;
-
return 0;
-
-err_stop_clks:
-   clk_bulk_disable(priv->num_clks, priv->clks);
-
-   return ret;
-}
-
-static void eqos_stop_stm32(struct eth_device *edev)
-{
-   struct eqos_stm32 *priv = to_stm32(edev->priv);
-
-   eqos_stop(edev);
-
-   clk_bulk_disable(priv->num_clks, priv->clks);
 }
 
 static struct eqos_ops stm32_ops = {
.init = eqos_init_stm32,
.get_ethaddr = eqos_get_ethaddr,
.set_ethaddr = eqos_set_ethaddr,
-   .start = eqos_start_stm32,
-   .stop = eqos_stop_stm32,
.adjust_link = eqos_adjust_link,
.get_csr_clk_rate = eqos_get_csr_clk_rate_stm32,
 
@@ -229,6 +197,7 @@ static void eqos_remove_stm32(struct device_d *dev)
 
eqos_remove(dev);
 
+   clk_bulk_disable(priv->num_clks, priv->clks);
clk_bulk_put(priv->num_clks, priv->clks);
 }
 
diff --git a/drivers/net/designware_tegra186.c 
b/drivers/net/designware_tegra186.c
index 618ae113971d..20521db1c711 100644
--- a/drivers/net/designware_tegra186.c
+++ b/drivers/net/designware_tegra186.c
@@ -230,29 +230,16 @@ static int eqos_init_tegra186(struct device_d *dev, 
struct eqos *eqos)
priv->clks 

[PATCH 3/3] net: designware: eqos: fix NULL pointer use in dev_printf

2019-11-14 Thread Ahmad Fatoum
Inside mdio_register, a read of the PHY's id register is attempted.
If it fails, we print an error message with eqos_err, which uses the
ethernet device's unique name, but at this time there has been none set,
because eth_register was not yet called. Fix this by using the MDIO bus
device instead.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/designware_eqos.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/designware_eqos.c b/drivers/net/designware_eqos.c
index 84dcd04a3fc9..da67adf9a0f0 100644
--- a/drivers/net/designware_eqos.c
+++ b/drivers/net/designware_eqos.c
@@ -204,7 +204,7 @@ static int eqos_mdio_read(struct mii_bus *bus, int addr, 
int reg)
 
ret = eqos_mdio_wait_idle(eqos);
if (ret) {
-   eqos_err(eqos, "MDIO not idle at entry\n");
+   dev_err(&bus->dev, "MDIO not idle at entry\n");
return ret;
}
 
@@ -222,7 +222,7 @@ static int eqos_mdio_read(struct mii_bus *bus, int addr, 
int reg)
 
ret = eqos_mdio_wait_idle(eqos);
if (ret) {
-   eqos_err(eqos, "MDIO read didn't complete\n");
+   dev_err(&bus->dev, "MDIO read didn't complete\n");
return ret;
}
 
@@ -237,7 +237,7 @@ static int eqos_mdio_write(struct mii_bus *bus, int addr, 
int reg, u16 val)
 
ret = eqos_mdio_wait_idle(eqos);
if (ret) {
-   eqos_err(eqos, "MDIO not idle at entry\n");
+   dev_err(&bus->dev, "MDIO not idle at entry\n");
return ret;
}
 
@@ -256,7 +256,7 @@ static int eqos_mdio_write(struct mii_bus *bus, int addr, 
int reg, u16 val)
 
ret = eqos_mdio_wait_idle(eqos);
if (ret) {
-   eqos_err(eqos, "MDIO read didn't complete\n");
+   dev_err(&bus->dev, "MDIO read didn't complete\n");
return ret;
}
 
-- 
2.20.1


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


[PATCH v2 0/3] net: designware: eqos: stop DMA on halt

2019-11-14 Thread Ahmad Fatoum
I recently learnt that barebox Ethernet drivers need to call ->halt 
themselves, either directly or indirectly.

The first patch does this. Sascha, do you do fixups into master? If so,
you could fix the first commit up into my previous patch.

After applying the patch and doing a round of boot bnet, the first MDIO
access during probe times out:

ERROR: : MDIO not idle at entry

This is fixed by the other two commits.

The driver isn't in a release yet, so I hope they could join the driver
in master.

Cheers
Ahmad

Ahmad Fatoum (3):
  fixup! net: designware: eqos: stop DMA on halt
  net: designware: eqos: enable clocks before mdio_register
  net: designware: eqos: fix NULL pointer use in dev_printf

 drivers/net/designware_eqos.c | 18 ++--
 drivers/net/designware_eqos.h |  4 ---
 drivers/net/designware_stm32.c| 33 +-
 drivers/net/designware_tegra186.c | 47 ++-
 4 files changed, 20 insertions(+), 82 deletions(-)

-- 
2.20.1


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


Re: [PATCH] MIPS: ath79: art: fix typo in SPDX-License-Identifier

2019-11-14 Thread Ahmad Fatoum
Hello Yegor,

On 11/15/19 8:20 AM, Yegor Yefremov wrote:
> Hi Ahmad,
> 
> On Fri, Nov 15, 2019 at 8:14 AM Ahmad Fatoum  wrote:
>>
>> There's no GPL-2. SPDX identifier. Change it to GPL-2.0 instead.
> 
> GPL-2.0 is deprecated use GPL-2.0-only instead.
> 
> https://spdx.org/licenses/GPL-2.0.html

Ah, right.

Oleksij, could you change it to the correct variant
(GPL-2.0-only, GPL-2.0-or-later) and resend it?

Thanks

> 
> Regard,
> Yegor
> 
>>
>> Cc: Oleksij Rempel 
>> Signed-off-by: Ahmad Fatoum 
>> ---
>>  arch/mips/mach-ath79/art.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/mach-ath79/art.c b/arch/mips/mach-ath79/art.c
>> index 2a2099e9f561..4a8a3e1fe6b1 100644
>> --- a/arch/mips/mach-ath79/art.c
>> +++ b/arch/mips/mach-ath79/art.c
>> @@ -1,4 +1,4 @@
>> -// SPDX-License-Identifier: GPL-2.
>> +// SPDX-License-Identifier: GPL-2.0
>>  /*
>>   * Copyright (c) 2018 Oleksij Rempel 
>>   */
>> --
>> 2.20.1
>>
>>
>> ___
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


Re: [PATCH] MIPS: ath79: art: fix typo in SPDX-License-Identifier

2019-11-14 Thread Yegor Yefremov
Hi Ahmad,

On Fri, Nov 15, 2019 at 8:14 AM Ahmad Fatoum  wrote:
>
> There's no GPL-2. SPDX identifier. Change it to GPL-2.0 instead.

GPL-2.0 is deprecated use GPL-2.0-only instead.

https://spdx.org/licenses/GPL-2.0.html

Regard,
Yegor

>
> Cc: Oleksij Rempel 
> Signed-off-by: Ahmad Fatoum 
> ---
>  arch/mips/mach-ath79/art.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/mach-ath79/art.c b/arch/mips/mach-ath79/art.c
> index 2a2099e9f561..4a8a3e1fe6b1 100644
> --- a/arch/mips/mach-ath79/art.c
> +++ b/arch/mips/mach-ath79/art.c
> @@ -1,4 +1,4 @@
> -// SPDX-License-Identifier: GPL-2.
> +// SPDX-License-Identifier: GPL-2.0
>  /*
>   * Copyright (c) 2018 Oleksij Rempel 
>   */
> --
> 2.20.1
>
>
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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


[PATCH] nvmem: bsec: fix typo in function name (s/st32/stm32/)

2019-11-14 Thread Ahmad Fatoum
A m was missing. Reinstate it.

Signed-off-by: Ahmad Fatoum 
---
 drivers/nvmem/bsec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/bsec.c b/drivers/nvmem/bsec.c
index 8235d468d16d..d772d0b7af92 100644
--- a/drivers/nvmem/bsec.c
+++ b/drivers/nvmem/bsec.c
@@ -57,7 +57,7 @@ static int bsec_smc(struct bsec_priv *priv, u8 op, enum 
bsec_field field,
return -ENXIO;
 }
 
-static int st32_bsec_read_shadow(void *ctx, unsigned reg, unsigned *val)
+static int stm32_bsec_read_shadow(void *ctx, unsigned reg, unsigned *val)
 {
return bsec_smc(ctx, BSEC_SMC_READ_SHADOW, reg, 0, val);
 }
@@ -69,7 +69,7 @@ static int stm32_bsec_reg_write_shadow(void *ctx, unsigned 
reg, unsigned val)
 
 static struct regmap_bus stm32_bsec_regmap_bus = {
.reg_write = stm32_bsec_reg_write_shadow,
-   .reg_read = st32_bsec_read_shadow,
+   .reg_read = stm32_bsec_read_shadow,
 };
 
 static int stm32_bsec_write(struct device_d *dev, int offset,
-- 
2.20.1


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


[PATCH] MIPS: ath79: art: fix typo in SPDX-License-Identifier

2019-11-14 Thread Ahmad Fatoum
There's no GPL-2. SPDX identifier. Change it to GPL-2.0 instead.

Cc: Oleksij Rempel 
Signed-off-by: Ahmad Fatoum 
---
 arch/mips/mach-ath79/art.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/mach-ath79/art.c b/arch/mips/mach-ath79/art.c
index 2a2099e9f561..4a8a3e1fe6b1 100644
--- a/arch/mips/mach-ath79/art.c
+++ b/arch/mips/mach-ath79/art.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2018 Oleksij Rempel 
  */
-- 
2.20.1


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


Re: [PATCH 1/6] net: fsl-fman: reset device before leaving

2019-11-14 Thread Sascha Hauer
On Thu, Nov 14, 2019 at 02:23:44PM +0100, Ahmad Fatoum wrote:
> Hello Sascha,
> 
> On 11/14/19 2:00 PM, Sascha Hauer wrote:
> > edev->halt is implemented, but not called by the core during shutdown.
> 
> Oh, that's news to me. Apparently only eth_unregister calls ->halt and that
> one is only used by drivers. Shouldn't calling eth_unregister be a part of
> the barebox shutdown sequence?
> 

I had the same thought as well and have put it on my mental todo list.
It would be easy to put calling of edev->halt() somewhere in the
shutdown path, but this would result in edev->halt() being called twice
for drivers which already do this in their own remove function. I'm not
sure every driver handles this fine so we probably have to make sure it
is called only once.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


[PATCH] usb: dwc3: Remove wrong error messages

2019-11-14 Thread Sascha Hauer
When phy_get() returns -ENOSYS or -ENODEV it means we can go without
phy. Do not print an error message in this case.

Signed-off-by: Sascha Hauer 
---
 drivers/usb/dwc3/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d3f9d9ef27..c17327c791 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -914,7 +914,6 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
if (IS_ERR(dwc->usb2_generic_phy)) {
ret = PTR_ERR(dwc->usb2_generic_phy);
if (ret == -ENOSYS || ret == -ENODEV) {
-   dev_err(dev, "no usb2 phy configured\n");
dwc->usb2_generic_phy = NULL;
} else if (ret == -EPROBE_DEFER) {
return ret;
@@ -928,7 +927,6 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
if (IS_ERR(dwc->usb3_generic_phy)) {
ret = PTR_ERR(dwc->usb3_generic_phy);
if (ret == -ENOSYS || ret == -ENODEV) {
-   dev_err(dev, "no usb2 phy configured\n");
dwc->usb3_generic_phy = NULL;
} else if (ret == -EPROBE_DEFER) {
return ret;
-- 
2.24.0


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


[PATCH] net: designware: eqos: remove done TODO

2019-11-14 Thread Ahmad Fatoum
The todo split comment is a left-over from refactoring. Remove it.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/designware_stm32.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/designware_stm32.c b/drivers/net/designware_stm32.c
index ed54ff2b2615..bb6781fb3450 100644
--- a/drivers/net/designware_stm32.c
+++ b/drivers/net/designware_stm32.c
@@ -204,7 +204,6 @@ static void eqos_stop_stm32(struct eth_device *edev)
clk_bulk_disable(priv->num_clks, priv->clks);
 }
 
-// todo split!
 static struct eqos_ops stm32_ops = {
.init = eqos_init_stm32,
.get_ethaddr = eqos_get_ethaddr,
-- 
2.24.0


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


Re: [PATCH 1/6] net: fsl-fman: reset device before leaving

2019-11-14 Thread Ahmad Fatoum
Hello Sascha,

On 11/14/19 2:00 PM, Sascha Hauer wrote:
> edev->halt is implemented, but not called by the core during shutdown.

Oh, that's news to me. Apparently only eth_unregister calls ->halt and that
one is only used by drivers. Shouldn't calling eth_unregister be a part of
the barebox shutdown sequence?

Cheers
Ahmad

> We have to call it manually during device remove. With this and also
> resetting the whole FMan during shutdown the driver now works properly
> when started second stage from another barebox.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  drivers/net/fsl-fman.c | 19 +++
>  include/soc/fsl/fsl_fman.h |  3 +++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
> index 4e6bb2ecfd..287a891a63 100644
> --- a/drivers/net/fsl-fman.c
> +++ b/drivers/net/fsl-fman.c
> @@ -1175,6 +1175,8 @@ static int fsl_fman_memac_probe(struct device_d *dev)
>   /* alloc the FMan ethernet private struct */
>   fm_eth = xzalloc(sizeof(*fm_eth));
>  
> + dev->priv = fm_eth;
> +
>   fm_eth->dev = dev;
>  
>   ret = fsl_fman_memac_port_bind(fm_eth, FMAN_PORT_TYPE_TX);
> @@ -1216,6 +1218,13 @@ static int fsl_fman_memac_probe(struct device_d *dev)
>   return 0;
>  }
>  
> +static void fsl_fman_memac_remove(struct device_d *dev)
> +{
> + struct fm_eth *fm_eth = dev->priv;
> +
> + fm_eth_halt(&fm_eth->edev);
> +}
> +
>  static int fsl_fman_muram_probe(struct device_d *dev)
>  {
>   struct resource *iores;
> @@ -1274,6 +1283,7 @@ static struct of_device_id fsl_fman_memac_dt_ids[] = {
>  static struct driver_d fman_memac_driver = {
>   .name   = "fsl-fman-memac",
>   .probe  = fsl_fman_memac_probe,
> + .remove = fsl_fman_memac_remove,
>   .of_compatible = DRV_OF_COMPAT(fsl_fman_memac_dt_ids),
>  };
>  
> @@ -1303,6 +1313,7 @@ static int fsl_fman_probe(struct device_d *dev)
>   return PTR_ERR(iores);
>  
>   reg = IOMEM(iores->start);
> + dev->priv = reg;
>  
>   ret = of_platform_populate(dev->device_node, NULL, dev);
>   if (ret)
> @@ -1320,6 +1331,13 @@ static int fsl_fman_probe(struct device_d *dev)
>   return 0;
>  }
>  
> +static void fsl_fman_remove(struct device_d *dev)
> +{
> + struct ccsr_fman *reg = dev->priv;
> +
> + setbits_be32(®->fm_fpm.fmrstc, FMFP_RSTC_RFM);
> +}
> +
>  static struct of_device_id fsl_fman_dt_ids[] = {
>   {
>   .compatible = "fsl,fman",
> @@ -1330,6 +1348,7 @@ static struct of_device_id fsl_fman_dt_ids[] = {
>  static struct driver_d fman_driver = {
>   .name   = "fsl-fman",
>   .probe  = fsl_fman_probe,
> + .remove = fsl_fman_remove,
>   .of_compatible = DRV_OF_COMPAT(fsl_fman_dt_ids),
>  };
>  device_platform_driver(fman_driver);
> diff --git a/include/soc/fsl/fsl_fman.h b/include/soc/fsl/fsl_fman.h
> index 96d61298ef..fd69fded38 100644
> --- a/include/soc/fsl/fsl_fman.h
> +++ b/include/soc/fsl/fsl_fman.h
> @@ -348,6 +348,9 @@ struct fm_fpm {
>  /* FPM Flush Control Register */
>  #define FMFP_FLC_DISP_LIM_NONE   0x /* no dispatch limitation */
>  
> +/* FMan Reset Command Register */
> +#define FMFP_RSTC_RFM0x8000 /* FMan Soft Reset Command */
> +
>  /* FMFP_EE - FPM event and enable register */
>  #define FMFPEE_DECC  0x8000 /* double ECC err on FPM ram */
>  #define FMFPEE_STL   0x4000 /* stall of task ... */
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

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


[PATCH 2/6] net: fsl-fman: Store index for txbd

2019-11-14 Thread Sascha Hauer
Instead of storing a pointer to the current txbd store the index of the
current buffer. This makes the code more straight forward.

Signed-off-by: Sascha Hauer 
---
 drivers/net/fsl-fman.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 287a891a63..b5d617212e 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -107,8 +107,8 @@ struct fm_eth {
void *rx_bd_ring;   /* Rx BD ring base */
void *cur_rxbd; /* current Rx BD */
void *rx_buf;   /* Rx buffer base */
-   void *tx_bd_ring;   /* Tx BD ring base */
-   void *cur_txbd; /* current Tx BD */
+   struct fm_port_bd *tx_bd_ring;  /* Tx BD ring base */
+   int cur_txbd_idx;   /* current Tx BD index */
struct memac *regs;
 };
 
@@ -702,16 +702,16 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth 
*fm_eth)
* TX_BD_RING_SIZE);
/* save it to fm_eth */
fm_eth->tx_bd_ring = tx_bd_ring_base;
-   fm_eth->cur_txbd = tx_bd_ring_base;
+   fm_eth->cur_txbd_idx = 0;
 
/* init Tx BDs ring */
-   txbd = tx_bd_ring_base;
for (i = 0; i < TX_BD_RING_SIZE; i++) {
+   txbd = &fm_eth->tx_bd_ring[i];
+
muram_writew(&txbd->status, TxBD_LAST);
muram_writew(&txbd->len, 0);
muram_writew(&txbd->buf_ptr_hi, 0);
out_be32(&txbd->buf_ptr_lo, 0);
-   txbd++;
}
 
/* set the Tx queue decriptor */
@@ -834,13 +834,13 @@ static int fm_eth_send(struct eth_device *edev, void 
*buf, int len)
 {
struct fm_eth *fm_eth = to_fm_eth(edev);
struct fm_port_global_pram *pram;
-   struct fm_port_bd *txbd, *txbd_base;
+   struct fm_port_bd *txbd;
u16 offset_in;
int i;
dma_addr_t dma;
 
pram = fm_eth->tx_pram;
-   txbd = fm_eth->cur_txbd;
+   txbd = &fm_eth->tx_bd_ring[fm_eth->cur_txbd_idx];
 
/* find one empty TxBD */
for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) {
@@ -882,12 +882,7 @@ static int fm_eth_send(struct eth_device *edev, void *buf, 
int len)
dma_unmap_single(fm_eth->dev, dma, len, DMA_TO_DEVICE);
 
/* advance the TxBD */
-   txbd++;
-   txbd_base = fm_eth->tx_bd_ring;
-   if (txbd >= (txbd_base + TX_BD_RING_SIZE))
-   txbd = txbd_base;
-   /* update current txbd */
-   fm_eth->cur_txbd = (void *)txbd;
+   fm_eth->cur_txbd_idx = (fm_eth->cur_txbd_idx + 1) % TX_BD_RING_SIZE;
 
return 0;
 }
-- 
2.24.0


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


[PATCH 5/6] net: fsl-fman: simplify setting next offset

2019-11-14 Thread Sascha Hauer
The offset of the current packet can be retrieved from the current txbd
index, so do this instead of increasing the offset with each new packet.

Signed-off-by: Sascha Hauer 
---
 drivers/net/fsl-fman.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 196be3f6bd..01f7064fd2 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -835,7 +835,6 @@ static int fm_eth_send(struct eth_device *edev, void *buf, 
int len)
struct fm_eth *fm_eth = to_fm_eth(edev);
struct fm_port_global_pram *pram;
struct fm_port_bd *txbd;
-   u16 offset_in;
int i;
dma_addr_t dma;
 
@@ -862,12 +861,12 @@ static int fm_eth_send(struct eth_device *edev, void 
*buf, int len)
muram_writew(&txbd->len, len);
muram_writew(&txbd->status, TxBD_READY | TxBD_LAST);
 
+   /* advance the TxBD */
+   fm_eth->cur_txbd_idx = (fm_eth->cur_txbd_idx + 1) % TX_BD_RING_SIZE;
+
/* update TxQD, let RISC to send the packet */
-   offset_in = muram_readw(&pram->txqd.offset_in);
-   offset_in += sizeof(struct fm_port_bd);
-   if (offset_in >= muram_readw(&pram->txqd.bd_ring_size))
-   offset_in = 0;
-   muram_writew(&pram->txqd.offset_in, offset_in);
+   muram_writew(&pram->txqd.offset_in,
+fm_eth->cur_txbd_idx * sizeof(struct fm_port_bd));
 
/* wait for buffer to be transmitted */
for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) {
@@ -881,9 +880,6 @@ static int fm_eth_send(struct eth_device *edev, void *buf, 
int len)
 
dma_unmap_single(fm_eth->dev, dma, len, DMA_TO_DEVICE);
 
-   /* advance the TxBD */
-   fm_eth->cur_txbd_idx = (fm_eth->cur_txbd_idx + 1) % TX_BD_RING_SIZE;
-
return 0;
 }
 
-- 
2.24.0


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


[PATCH 1/6] net: fsl-fman: reset device before leaving

2019-11-14 Thread Sascha Hauer
edev->halt is implemented, but not called by the core during shutdown.
We have to call it manually during device remove. With this and also
resetting the whole FMan during shutdown the driver now works properly
when started second stage from another barebox.

Signed-off-by: Sascha Hauer 
---
 drivers/net/fsl-fman.c | 19 +++
 include/soc/fsl/fsl_fman.h |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 4e6bb2ecfd..287a891a63 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -1175,6 +1175,8 @@ static int fsl_fman_memac_probe(struct device_d *dev)
/* alloc the FMan ethernet private struct */
fm_eth = xzalloc(sizeof(*fm_eth));
 
+   dev->priv = fm_eth;
+
fm_eth->dev = dev;
 
ret = fsl_fman_memac_port_bind(fm_eth, FMAN_PORT_TYPE_TX);
@@ -1216,6 +1218,13 @@ static int fsl_fman_memac_probe(struct device_d *dev)
return 0;
 }
 
+static void fsl_fman_memac_remove(struct device_d *dev)
+{
+   struct fm_eth *fm_eth = dev->priv;
+
+   fm_eth_halt(&fm_eth->edev);
+}
+
 static int fsl_fman_muram_probe(struct device_d *dev)
 {
struct resource *iores;
@@ -1274,6 +1283,7 @@ static struct of_device_id fsl_fman_memac_dt_ids[] = {
 static struct driver_d fman_memac_driver = {
.name   = "fsl-fman-memac",
.probe  = fsl_fman_memac_probe,
+   .remove = fsl_fman_memac_remove,
.of_compatible = DRV_OF_COMPAT(fsl_fman_memac_dt_ids),
 };
 
@@ -1303,6 +1313,7 @@ static int fsl_fman_probe(struct device_d *dev)
return PTR_ERR(iores);
 
reg = IOMEM(iores->start);
+   dev->priv = reg;
 
ret = of_platform_populate(dev->device_node, NULL, dev);
if (ret)
@@ -1320,6 +1331,13 @@ static int fsl_fman_probe(struct device_d *dev)
return 0;
 }
 
+static void fsl_fman_remove(struct device_d *dev)
+{
+   struct ccsr_fman *reg = dev->priv;
+
+   setbits_be32(®->fm_fpm.fmrstc, FMFP_RSTC_RFM);
+}
+
 static struct of_device_id fsl_fman_dt_ids[] = {
{
.compatible = "fsl,fman",
@@ -1330,6 +1348,7 @@ static struct of_device_id fsl_fman_dt_ids[] = {
 static struct driver_d fman_driver = {
.name   = "fsl-fman",
.probe  = fsl_fman_probe,
+   .remove = fsl_fman_remove,
.of_compatible = DRV_OF_COMPAT(fsl_fman_dt_ids),
 };
 device_platform_driver(fman_driver);
diff --git a/include/soc/fsl/fsl_fman.h b/include/soc/fsl/fsl_fman.h
index 96d61298ef..fd69fded38 100644
--- a/include/soc/fsl/fsl_fman.h
+++ b/include/soc/fsl/fsl_fman.h
@@ -348,6 +348,9 @@ struct fm_fpm {
 /* FPM Flush Control Register */
 #define FMFP_FLC_DISP_LIM_NONE 0x /* no dispatch limitation */
 
+/* FMan Reset Command Register */
+#define FMFP_RSTC_RFM  0x8000 /* FMan Soft Reset Command */
+
 /* FMFP_EE - FPM event and enable register */
 #define FMFPEE_DECC0x8000 /* double ECC err on FPM ram */
 #define FMFPEE_STL 0x4000 /* stall of task ... */
-- 
2.24.0


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


[PATCH 4/6] net: fsl-fman: Store index for rxbd

2019-11-14 Thread Sascha Hauer
Like done for the txbd, also store the index of the current rxbd in the
driver private data. This makes the code easier to follow.

Signed-off-by: Sascha Hauer 
---
 drivers/net/fsl-fman.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 5dc7ed5090..196be3f6bd 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -104,8 +104,8 @@ struct fm_eth {
struct device_d *dev;
struct fm_port_global_pram *rx_pram; /* Rx parameter table */
struct fm_port_global_pram *tx_pram; /* Tx parameter table */
-   void *rx_bd_ring;   /* Rx BD ring base */
-   void *cur_rxbd; /* current Rx BD */
+   struct fm_port_bd *rx_bd_ring;  /* Rx BD ring base */
+   int cur_rxbd_idx;   /* current Rx BD index */
void *rx_buf;   /* Rx buffer base */
struct fm_port_bd *tx_bd_ring;  /* Tx BD ring base */
int cur_txbd_idx;   /* current Tx BD index */
@@ -628,12 +628,13 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth 
*fm_eth)
 
/* save them to fm_eth */
fm_eth->rx_bd_ring = rx_bd_ring_base;
-   fm_eth->cur_rxbd = rx_bd_ring_base;
+   fm_eth->cur_rxbd_idx = 0;
fm_eth->rx_buf = rx_buf_pool;
 
/* init Rx BDs ring */
-   rxbd = rx_bd_ring_base;
for (i = 0; i < RX_BD_RING_SIZE; i++) {
+   rxbd = &fm_eth->rx_bd_ring[i];
+
muram_writew(&rxbd->status, RxBD_EMPTY);
muram_writew(&rxbd->len, 0);
buf_hi = upper_32_bits(virt_to_phys(rx_buf_pool +
@@ -644,7 +645,6 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth 
*fm_eth)
   MAX_RXBUF_LEN, DMA_FROM_DEVICE);
muram_writew(&rxbd->buf_ptr_hi, (u16)buf_hi);
out_be32(&rxbd->buf_ptr_lo, buf_lo);
-   rxbd++;
}
 
/* set the Rx queue descriptor */
@@ -891,7 +891,7 @@ static int fm_eth_recv(struct eth_device *edev)
 {
struct fm_eth *fm_eth = to_fm_eth(edev);
struct fm_port_global_pram *pram;
-   struct fm_port_bd *rxbd, *rxbd_base;
+   struct fm_port_bd *rxbd;
u16 status, len;
u32 buf_lo, buf_hi;
u8 *data;
@@ -899,9 +899,10 @@ static int fm_eth_recv(struct eth_device *edev)
int ret = 1;
 
pram = fm_eth->rx_pram;
-   rxbd = fm_eth->cur_rxbd;
 
while (1) {
+   rxbd = &fm_eth->rx_bd_ring[fm_eth->cur_rxbd_idx];
+
status = muram_readw(&rxbd->status);
if (status & RxBD_EMPTY)
break;
@@ -931,10 +932,7 @@ static int fm_eth_recv(struct eth_device *edev)
muram_writew(&rxbd->len, 0);
 
/* advance RxBD */
-   rxbd++;
-   rxbd_base = fm_eth->rx_bd_ring;
-   if (rxbd >= (rxbd_base + RX_BD_RING_SIZE))
-   rxbd = rxbd_base;
+   fm_eth->cur_rxbd_idx = (fm_eth->cur_rxbd_idx + 1) % 
RX_BD_RING_SIZE;
 
/* update RxQD */
offset_out = muram_readw(&pram->rxqd.offset_out);
@@ -943,7 +941,6 @@ static int fm_eth_recv(struct eth_device *edev)
offset_out = 0;
muram_writew(&pram->rxqd.offset_out, offset_out);
}
-   fm_eth->cur_rxbd = rxbd;
 
return ret;
 }
-- 
2.24.0


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


[PATCH 3/6] net: fsl-fman: move status read into loop

2019-11-14 Thread Sascha Hauer
Instead of reading the status once before the loop and then again right
before the next iteration, just read the status in the loop.

Signed-off-by: Sascha Hauer 
---
 drivers/net/fsl-fman.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index b5d617212e..5dc7ed5090 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -900,9 +900,12 @@ static int fm_eth_recv(struct eth_device *edev)
 
pram = fm_eth->rx_pram;
rxbd = fm_eth->cur_rxbd;
-   status = muram_readw(&rxbd->status);
 
-   while (!(status & RxBD_EMPTY)) {
+   while (1) {
+   status = muram_readw(&rxbd->status);
+   if (status & RxBD_EMPTY)
+   break;
+
if (!(status & RxBD_ERROR)) {
buf_hi = muram_readw(&rxbd->buf_ptr_hi);
buf_lo = in_be32(&rxbd->buf_ptr_lo);
@@ -932,8 +935,6 @@ static int fm_eth_recv(struct eth_device *edev)
rxbd_base = fm_eth->rx_bd_ring;
if (rxbd >= (rxbd_base + RX_BD_RING_SIZE))
rxbd = rxbd_base;
-   /* read next status */
-   status = muram_readw(&rxbd->status);
 
/* update RxQD */
offset_out = muram_readw(&pram->rxqd.offset_out);
-- 
2.24.0


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


[PATCH 6/6] net: fsl-fman: do not leave not transmitted DMA buffers mapped

2019-11-14 Thread Sascha Hauer
When a packet can't be transmitted we should unmap it. This probably
won't change much since when we can't transmit a packet the fman
probably can't recover from it anyway, but still it is cleaner to not
leave the buffers mapped.

Signed-off-by: Sascha Hauer 
---
 drivers/net/fsl-fman.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index 01f7064fd2..467f7840bf 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -835,7 +835,7 @@ static int fm_eth_send(struct eth_device *edev, void *buf, 
int len)
struct fm_eth *fm_eth = to_fm_eth(edev);
struct fm_port_global_pram *pram;
struct fm_port_bd *txbd;
-   int i;
+   int i, ret;
dma_addr_t dma;
 
pram = fm_eth->tx_pram;
@@ -869,18 +869,20 @@ static int fm_eth_send(struct eth_device *edev, void 
*buf, int len)
 fm_eth->cur_txbd_idx * sizeof(struct fm_port_bd));
 
/* wait for buffer to be transmitted */
+   ret = 0;
for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) {
udelay(10);
if (i > 0x1) {
dev_err(&edev->dev, "Tx error, txbd->status = 0x%x\n",
   muram_readw(&txbd->status));
-   return -EIO;
+   ret = -EIO;
+   break;
}
}
 
dma_unmap_single(fm_eth->dev, dma, len, DMA_TO_DEVICE);
 
-   return 0;
+   return ret;
 }
 
 static int fm_eth_recv(struct eth_device *edev)
-- 
2.24.0


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


[PATCH 0/6] fsl-fman patches

2019-11-14 Thread Sascha Hauer
This series contains some patches for the fsl-fman ethernet controller.
Most important is the first one which makes the controller work when
barebox is started second stage from another barebox. The other patches
are some cleanups I stumbled upon while searching for the issue.

Sascha

Sascha Hauer (6):
  net: fsl-fman: reset device before leaving
  net: fsl-fman: Store index for txbd
  net: fsl-fman: move status read into loop
  net: fsl-fman: Store index for rxbd
  net: fsl-fman: simplify setting next offset
  net: fsl-fman: do not leave not transmitted DMA buffers mapped

 drivers/net/fsl-fman.c | 90 +-
 include/soc/fsl/fsl_fman.h |  3 ++
 2 files changed, 53 insertions(+), 40 deletions(-)

-- 
2.24.0


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