work on atheros ar2313
Subsystems (2)
RFC PATCH v2 3/3 MIPS: ar231x: add netgear-wg102
In reply to Oleksij Rempel--- arch/mips/Makefile | 1 + arch/mips/boards/netgear-wg102/Kconfig | 6 ++++++ arch/mips/boards/netgear-wg102/Makefile | 1 + arch/mips/boards/netgear-wg102/ram.c | 13 +++++++++++++ arch/mips/mach-ar231x/Kconfig | 10 ++++++++++ 5 files changed, 31 insertions(+) create mode 100644 arch/mips/boards/netgear-wg102/Kconfig create mode 100644 arch/mips/boards/netgear-wg102/Makefile create mode 100644 arch/mips/boards/netgear-wg102/ram.c
arch/mips/Makefile +1 -0
@@ -73,6 +73,7 @@ machine-$(CONFIG_MACH_MIPS_MALTA) := malta board-$(CONFIG_BOARD_QEMU_MALTA) := qemu-malta machine-$(CONFIG_MACH_MIPS_AR231X) := ar231x +board-$(CONFIG_BOARD_NETGEAR_WG102) := netgear-wg102 machine-$(CONFIG_MACH_MIPS_BCM47XX) := bcm47xx board-$(CONFIG_BOARD_DLINK_DIR320) := dlink-dir-320
arch/mips/boards/netgear-wg102/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +if BOARD_NETGEAR_WG102 + +config BOARDINFO + default "Netgear WG102" + +endif
arch/mips/boards/netgear-wg102/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += ram.o
arch/mips/boards/netgear-wg102/ram.c new file +13 -0
@@ -0,0 +1,13 @@ +#include <common.h> +#include <init.h> +#include <sizes.h> +#include <asm/memory.h> + +static int mem_init (void ) +{ +/* FIXME: theoretically we can calculate ram size */ +mips_add_ram0 (SZ_16M ); + +return 0 ; +} +mem_initcall (mem_init);
arch/mips/mach-ar231x/Kconfig +10 -0
@@ -4,4 +4,14 @@ config ARCH_TEXT_BASE hex default 0xa0800000 +choice + prompt "Board type" + +config BOARD_NETGEAR_WG102 + bool "Netgear WG102" + +endchoice + +source arch/mips/boards/netgear-wg102/Kconfig + endif
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH v2 1/3 MIPS: add Atheros ar531x family support
In reply to Oleksij Rempel--- arch/mips/Kconfig | 10 + arch/mips/Makefile | 2 + arch/mips/mach-ar231x/Kconfig | 7 + arch/mips/mach-ar231x/Makefile | 3 + arch/mips/mach-ar231x/ar231x.c | 199 +++++++++++++++ arch/mips/mach-ar231x/ar231x_reset.c | 64 +++++ arch/mips/mach-ar231x/board.c | 184 ++++++++++++++ arch/mips/mach-ar231x/include/mach/ar2312_regs.h | 269 +++++++++++++++++++++ .../mach-ar231x/include/mach/ar231x_platform.h | 89 +++++++ arch/mips/mach-ar231x/include/mach/debug_ll.h | 35 +++ 10 files changed, 862 insertions(+) create mode 100644 arch/mips/mach-ar231x/Kconfig create mode 100644 arch/mips/mach-ar231x/Makefile create mode 100644 arch/mips/mach-ar231x/ar231x.c create mode 100644 arch/mips/mach-ar231x/ar231x_reset.c create mode 100644 arch/mips/mach-ar231x/board.c create mode 100644 arch/mips/mach-ar231x/include/mach/ar2312_regs.h create mode 100644 arch/mips/mach-ar231x/include/mach/ar231x_platform.h create mode 100644 arch/mips/mach-ar231x/include/mach/debug_ll.h
arch/mips/Kconfig +10 -0
@@ -45,6 +45,15 @@ config MACH_MIPS_MALTA select SYS_SUPPORTS_BIG_ENDIAN select HAS_DEBUG_LL +config MACH_MIPS_AR231X + bool "Atheros ar231x-based boards" + select CSRC_R4K_LIB + select DRIVER_SERIAL_NS16550 + select SYS_HAS_CPU_MIPS32_R1 + select SYS_SUPPORTS_32BIT_KERNEL + select SYS_SUPPORTS_BIG_ENDIAN + select HAS_DEBUG_LL + config MACH_MIPS_BCM47XX bool "Broadcom BCM47xx-based boards" select CSRC_R4K_LIB
@@ -64,6 +73,7 @@ config MACH_MIPS_XBURST endchoice source arch/mips/mach-malta/Kconfig +source arch/mips/mach-ar231x/Kconfig source arch/mips/mach-bcm47xx/Kconfig source arch/mips/mach-xburst/Kconfig
arch/mips/Makefile +2 -0
@@ -72,6 +72,8 @@ LDFLAGS_barebox += -nostdlib machine-$(CONFIG_MACH_MIPS_MALTA) := malta board-$(CONFIG_BOARD_QEMU_MALTA) := qemu-malta +machine-$(CONFIG_MACH_MIPS_AR231X) := ar231x + machine-$(CONFIG_MACH_MIPS_BCM47XX) := bcm47xx board-$(CONFIG_BOARD_DLINK_DIR320) := dlink-dir-320
arch/mips/mach-ar231x/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +if MACH_MIPS_AR231X + +config ARCH_TEXT_BASE + hex + default 0xa0800000 + +endif
arch/mips/mach-ar231x/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-y += ar231x.o +obj-y += board.o +obj-y += ar231x_reset.o
arch/mips/mach-ar231x/ar231x.c new file +199 -0
199 lines not on this page · raw message
arch/mips/mach-ar231x/ar231x_reset.c new file +64 -0
64 lines not on this page · raw message
arch/mips/mach-ar231x/board.c new file +184 -0
184 lines not on this page · raw message
arch/mips/mach-ar231x/include/mach/ar2312_regs.h new file +269 -0
269 lines not on this page · raw message
arch/mips/mach-ar231x/include/mach/ar231x_platform.h new file +89 -0
89 lines not on this page · raw message
arch/mips/mach-ar231x/include/mach/debug_ll.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (C) 2011 Antony Pavlov <[email protected]> +* +* This file is part of barebox. +* See file CREDITS for list of people who contributed to this project. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +/** @file +* This File contains declaration for early output support +*/ +#ifndef __MACH_AR231X_DEBUG_LL_H__ +#define __MACH_AR231X_DEBUG_LL_H__ + +#include <mach/ar2312_regs.h> + +#define DEBUG_LL_UART_ADDR KSEG1ADDR(AR2312_UART0) +#define DEBUG_LL_UART_SHIFT AR2312_UART_SHIFT + +#define DEBUG_LL_UART_CLK (45000000 / 16) +#define DEBUG_LL_UART_BPS CONFIG_BAUDRATE +#define DEBUG_LL_UART_DIVISOR (DEBUG_LL_UART_CLK / DEBUG_LL_UART_BPS) + +#include <debug_ll_ns16550.h> + +#endif /* __MACH_AR231X_DEBUG_LL_H__ */
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
v2 cover work on atheros ar2313
Hello all,
here is next version of pachtes for atheros ar2313. Previous comments was handled and some more work was done
Oleksij Rempel (3):
MIPS: add Atheros ar531x family support
net: add ar231x-eth support
MIPS: ar231x: add netgear-wg102
arch/mips/Kconfig | 10 + arch/mips/Makefile | 3 + arch/mips/boards/netgear-wg102/Kconfig | 6 + arch/mips/boards/netgear-wg102/Makefile | 1 + arch/mips/boards/netgear-wg102/ram.c | 13 + arch/mips/mach-ar231x/Kconfig | 17 + arch/mips/mach-ar231x/Makefile | 3 + arch/mips/mach-ar231x/ar231x.c | 199 ++++++++++ arch/mips/mach-ar231x/ar231x_reset.c | 64 +++ arch/mips/mach-ar231x/board.c | 184 +++++++++ arch/mips/mach-ar231x/include/mach/ar2312_regs.h | 269 +++++++++++++ .../mach-ar231x/include/mach/ar231x_platform.h | 89 +++++ arch/mips/mach-ar231x/include/mach/debug_ll.h | 35 ++ drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ar231x.c | 429 +++++++++++++++++++++ drivers/net/ar231x.h | 219 +++++++++++ 17 files changed, 1549 insertions(+) create mode 100644 arch/mips/boards/netgear-wg102/Kconfig create mode 100644 arch/mips/boards/netgear-wg102/Makefile create mode 100644 arch/mips/boards/netgear-wg102/ram.c create mode 100644 arch/mips/mach-ar231x/Kconfig create mode 100644 arch/mips/mach-ar231x/Makefile create mode 100644 arch/mips/mach-ar231x/ar231x.c create mode 100644 arch/mips/mach-ar231x/ar231x_reset.c create mode 100644 arch/mips/mach-ar231x/board.c create mode 100644 arch/mips/mach-ar231x/include/mach/ar2312_regs.h create mode 100644 arch/mips/mach-ar231x/include/mach/ar231x_platform.h create mode 100644 arch/mips/mach-ar231x/include/mach/debug_ll.h create mode 100644 drivers/net/ar231x.c create mode 100644 drivers/net/ar231x.h
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC PATCH v2 2/3 net: add ar231x-eth support
This driver should work with some Atheros WiSoCs:
- ar2312, ar2313
- ar2315, ar2316 ...
--- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ar231x.c | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ar231x.h | 219 ++++++++++++++++++++++++++ 4 files changed, 656 insertions(+) create mode 100644 drivers/net/ar231x.c create mode 100644 drivers/net/ar231x.h
drivers/net/Kconfig +7 -0
@@ -27,6 +27,13 @@ menu "Network drivers" source "drivers/net/phy/Kconfig" +config DRIVER_NET_AR231X + bool "AR231X Ethernet support" + depends on MACH_MIPS_AR231X + select PHYLIB + help + Support for the AR231x/531x ethernet controller + config DRIVER_NET_CALXEDA_XGMAC bool "Calxeda xgmac"
drivers/net/Makefile +1 -0
@@ -1,3 +1,4 @@ +obj-$(CONFIG_DRIVER_NET_AR231X) += ar231x.o obj-$(CONFIG_DRIVER_NET_CALXEDA_XGMAC) += xgmac.o obj-$(CONFIG_DRIVER_NET_CS8900) += cs8900.o obj-$(CONFIG_DRIVER_NET_CPSW) += cpsw.o
drivers/net/ar231x.c new file +429 -0
429 lines not on this page · raw message
drivers/net/ar231x.h new file +219 -0
219 lines not on this page · raw message
Signature · 7 lines
1.8.1.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC, PATCH v2 1/3] MIPS: add Atheros ar531x family support
In reply to Oleksij RempelHi Oleksij,
Quoted 5 lines · Oleksij Rempel
Signed-off-by Oleksij Rempel <[email protected]>Signed-off-by Antony Pavlov <[email protected]>arch/mips/mach-ar231x/ar231x.c new file +3
-0+ +/* +* This table is indexed by bits 5..4 of the CLOCKCTL1 register
arch/mips/mach-ar231x/ar231x.c line 37
Quoted 10 lines
arch/mips/mach-ar231x/ar231x.c new file +10
-0+* to determine the predevisor value. +*/ +static int CLOCKCTL1_PREDIVIDE_TABLE [4 ] = {1 ,2 ,4 ,5 }; + +static unsigned int +ar2312_cpu_frequency (void ) +{ +unsigned int predivide_mask, predivide_shift; +unsigned int multiplier_mask, multiplier_shift; +unsigned int clockCtl1, preDivideSelect, preDivisor, multiplier;
No CamelCase please.
arch/mips/mach-ar231x/ar231x.c line 172
Quoted 8 lines
arch/mips/mach-ar231x/ar231x.c new file +8
-0+static int platform_init (void ) +{ +add_generic_device ("ar2312_reset" ,DEVICE_ID_SINGLE ,NULL , +KSEG1ADDR (AR2312_RESETTMR ),0x4 , +IORESOURCE_MEM ,NULL ); +watchdog_init (); +flash_init (); +ether_init ();
Whether or not the flash/ethernet/serial device is available is board specific, not SoC specific, so this should be done in board code. It's good to provide helpers to make this simple for the board code though, so a good option would be to add a SoC prefix to the functions and call it from board code.
Otherwise I am fine with this patch, but maybe Antony still has some comments.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC, PATCH v2 1/3] MIPS: add Atheros ar531x family support
Am 23.05.2013 15:35, schrieb Sascha Hauer:
Quoted 12 lines
Hi Oleksij,
Quoted 9 lines · Oleksij Rempel
Signed-off-by Oleksij Rempel <[email protected]>Signed-off-by Antony Pavlov <[email protected]>arch/mips/mach-ar231x/ar231x.c new file +7
-0+ +/* +* This table is indexed by bits 5..4 of the CLOCKCTL1 register +* to determine the predevisor value. +*/ +static int CLOCKCTL1_PREDIVIDE_TABLE [4 ] = {1 ,2 ,4 ,5 }; +
Quoted 8 lines
arch/mips/mach-ar231x/ar231x.c line 37
Quoted 6 lines
arch/mips/mach-ar231x/ar231x.c new file +6
-0+static unsigned int +ar2312_cpu_frequency (void ) +{ +unsigned int predivide_mask, predivide_shift; +unsigned int multiplier_mask, multiplier_shift; +unsigned int clockCtl1, preDivideSelect, preDivisor, multiplier;No CamelCase please.
ok. i'll fix it.
Quoted 6 lines
Quoted 6 lines
arch/mips/mach-ar231x/ar231x.c new file +6
-0+static int platform_init (void ) +{ +add_generic_device ("ar2312_reset" ,DEVICE_ID_SINGLE ,NULL , +KSEG1ADDR (AR2312_RESETTMR ),0x4 , +IORESOURCE_MEM ,NULL ); +watchdog_init ();
Quoted 8 lines
arch/mips/mach-ar231x/ar231x.c line 172
Quoted 2 lines
arch/mips/mach-ar231x/ar231x.c new file +2
-0+flash_init (); +ether_init ();Whether or not the flash/ethernet/serial device is available is board specific, not SoC specific, so this should be done in board code. It's good to provide helpers to make this simple for the board code though, so a good option would be to add a SoC prefix to the functions and call it from board code.
Probably it will make sense to have generic type of board. Because this will work with most configurations. Since it is WiSoC (Wireless SoC), ethernet is on chip too.
Quoted 2 lines
Otherwise I am fine with this patch, but maybe Antony still has some comments.
Signature · 7 lines
Regards, Oleksij _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC, PATCH v2 2/3] net: add ar231x-eth support
In reply to Oleksij RempelQuoted 14 lines · Oleksij Rempel
This driver should work with some Atheros WiSoCs:
- ar2312, ar2313
- ar2315, ar2316 ...Signed-off-by Oleksij Rempel <[email protected]>--- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ar231x.c | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ar231x.h | 219 ++++++++++++++++++++++++++ 4 files changed, 656 insertions(+) create mode 100644 drivers/net/ar231x.c create mode 100644 drivers/net/ar231x.h
drivers/net/ar231x.c line 99
Quoted 3 lines
drivers/net/ar231x.c new file +3
-0+ +/* FIXME: priv->{t,r}x_ring are virtual addresses, +* use virt-to-phys convertion */
We use 1:1 mappings, so I think this comment should be removed.
drivers/net/ar231x.c line 135
Quoted 8 lines
drivers/net/ar231x.c new file +8
-0+ +static void ar231x_allocate_dma_descriptors (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; +u16 ar231x_descr_size =sizeof (struct ar231x_descr ); +u16 i; + + priv->tx_ring =xmalloc (ar231x_descr_size);
What alignment do you need here? This may or may not be safe.
Quoted 18 lines
drivers/net/ar231x.c new file +18
-0+ +static int ar231x_eth_recv (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; + +while (1 ) { +struct ar231x_descr *rxdsc = priv->next_rxdsc; +u32 status = rxdsc->status; + +/* owned by DMA? */ +if (status &DMA_RX_OWN ) +break ; + +/* Pick only packets what we can handle: +* - only complete packet per buffer +* (First and Last at same time) +* - drop multicast */ + if (!priv->kill_rx_ring &&
drivers/net/ar231x.c line 226
Quoted 10 lines
drivers/net/ar231x.c new file +10
-0+ ((status & DMA_RX_MASK) == DMA_RX_FSLS)) { +u16 length = + ((status >>DMA_RX_LEN_SHIFT ) &0x3fff ) + -CRC_LEN ; +net_receive ((void *)rxdsc->buffer_ptr, length); + } +/* Clean descriptor. now it is owned by DMA. */ + priv->next_rxdsc = (struct ar231x_descr *)rxdsc->next_dsc_ptr; +ar231x_flash_rxdsc (rxdsc); + }
This loop looks wrong. You should only receive a single packet for each call of this function.
Quoted 37 lines
drivers/net/ar231x.c new file +37
-0+ +static int ar231x_eth_probe (struct device_d *dev) +{ +struct ar231x_eth_priv *priv; +struct eth_device *edev; +struct mii_bus *miibus; +struct ar231x_eth_platform_data *pdata; + +if (!dev->platform_data) { +dev_err (dev,"no platform data\n" ); +return -ENODEV ; + } + + pdata = dev->platform_data; + + priv =xzalloc (sizeof (struct ar231x_eth_priv )); + edev = &priv->edev; + miibus = &priv->miibus; + edev->priv = priv; + +/* link all platform depended regs */ + priv->mac = pdata->mac; + + priv->eth_regs =dev_request_mem_region (dev,0 ); +/* we have 0x100000 for eth, part of it are dma regs. +* So they are already requested */ + priv->dma_regs = (void *)(priv->eth_regs +0x1000 ); + + priv->phy_regs =dev_request_mem_region (dev,1 ); + + priv->cfg = pdata; + edev->init = ar231x_eth_init; + edev->open = ar231x_eth_open; + edev->send = ar231x_eth_send; + edev->recv = ar231x_eth_recv; + edev->halt = ar231x_eth_halt; + edev->get_ethaddr = ar231x_get_ethaddr;
drivers/net/ar231x.c line 409
Quoted 10 lines
drivers/net/ar231x.c new file +10
-0+ edev->set_ethaddr = ar231x_set_ethaddr; + + priv->miibus.read = ar231x_miibus_read; + priv->miibus.write = ar231x_miibus_write; + priv->miibus.reset = ar231x_mdiibus_reset; + priv->miibus.priv = priv; + priv->miibus.parent = dev; + +mdiobus_register (miibus); +eth_register (edev);
Please check the return values of dev_request_mem_region, mdiobus_register and eth_register. I'm fine with not properly cleaning up afterwards, but we should be able to notice the user if something goes wrong here. (Yeah, I know, many network driver don't do so)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC, PATCH v2 2/3] net: add ar231x-eth support
Quoted 15 lines · Sascha Hauer
Quoted 14 lines · Oleksij Rempel
This driver should work with some Atheros WiSoCs:
- ar2312, ar2313
- ar2315, ar2316 ...Signed-off-by Oleksij Rempel <[email protected]>--- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ar231x.c | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ar231x.h | 219 ++++++++++++++++++++++++++ 4 files changed, 656 insertions(+) create mode 100644 drivers/net/ar231x.c create mode 100644 drivers/net/ar231x.h
Quoted 5 lines
drivers/net/ar231x.c line 99
Quoted 3 lines
drivers/net/ar231x.c new file +3
-0+ +/* FIXME: priv->{t,r}x_ring are virtual addresses, +* use virt-to-phys convertion */ We use 1:1 mappings, so I think this comment should be removed.
on mips it's not the case
Quoted 11 lines
drivers/net/ar231x.c line 135
Quoted 9 lines
drivers/net/ar231x.c new file +8
-0+ +static void ar231x_allocate_dma_descriptors (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; +u16 ar231x_descr_size =sizeof (struct ar231x_descr ); +u16 i; + + priv->tx_ring =xmalloc (ar231x_descr_size);What alignment do you need here? This may or may not be safe.
dma_alloc too
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC, PATCH v2 2/3] net: add ar231x-eth support
In reply to Sascha HauerAm 24.05.2013 09:09, schrieb Sascha Hauer:
Quoted 15 lines · Oleksij Rempel
Quoted 14 lines
This driver should work with some Atheros WiSoCs:
- ar2312, ar2313
- ar2315, ar2316 ...Signed-off-by Oleksij Rempel <[email protected]>--- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ar231x.c | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ar231x.h | 219 ++++++++++++++++++++++++++ 4 files changed, 656 insertions(+)create mode 100644
drivers/net/ar231x.c
create mode 100644drivers/net/ar231x.h
Quoted 5 lines
drivers/net/ar231x.c line 99
Quoted 3 lines
drivers/net/ar231x.c new file +3
-0+ +/* FIXME: priv->{t,r}x_ring are virtual addresses, +* use virt-to-phys convertion */ We use 1:1 mappings, so I think this comment should be removed.
This part should be fixed after Anthonys "MIPS: add initial cache support"
Quoted 10 lines
drivers/net/ar231x.c line 135
Quoted 8 lines
drivers/net/ar231x.c new file +8
-0+ +static void ar231x_allocate_dma_descriptors (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; +u16 ar231x_descr_size =sizeof (struct ar231x_descr ); +u16 i; + + priv->tx_ring =xmalloc (ar231x_descr_size);What alignment do you need here? This may or may not be safe.
Currently there is no other choice.
Quoted 23 lines
Quoted 23 lines
drivers/net/ar231x.c new file +23
-0+ +static int ar231x_eth_recv (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; + +while (1 ) { +struct ar231x_descr *rxdsc = priv->next_rxdsc; +u32 status = rxdsc->status; + +/* owned by DMA? */ +if (status &DMA_RX_OWN ) +break ; + +/* Pick only packets what we can handle: +* - only complete packet per buffer +* (First and Last at same time) +* - drop multicast */ +if (!priv->kill_rx_ring && + ((status &DMA_RX_MASK ) ==DMA_RX_FSLS )) { +u16 length = + ((status >>DMA_RX_LEN_SHIFT ) &0x3fff ) + -CRC_LEN ; +net_receive ((void *)rxdsc->buffer_ptr, length);
Quoted 8 lines
drivers/net/ar231x.c line 226
Quoted 5 lines
drivers/net/ar231x.c new file +5
-0+ } +/* Clean descriptor. now it is owned by DMA. */ + priv->next_rxdsc = (struct ar231x_descr *)rxdsc->next_dsc_ptr; +ar231x_flash_rxdsc (rxdsc); + }This loop looks wrong. You should only receive a single packet for each call of this function.
This loop is needed to filter broadcast packtes. If remove this loop and reduce rx buffer, i will get really bad packet losses.
Quoted 45 lines
Quoted 45 lines
drivers/net/ar231x.c new file +44
-0+ +static int ar231x_eth_probe (struct device_d *dev) +{ +struct ar231x_eth_priv *priv; +struct eth_device *edev; +struct mii_bus *miibus; +struct ar231x_eth_platform_data *pdata; + +if (!dev->platform_data) { +dev_err (dev,"no platform data\n" ); +return -ENODEV ; + } + + pdata = dev->platform_data; + + priv =xzalloc (sizeof (struct ar231x_eth_priv )); + edev = &priv->edev; + miibus = &priv->miibus; + edev->priv = priv; + +/* link all platform depended regs */ + priv->mac = pdata->mac; + + priv->eth_regs =dev_request_mem_region (dev,0 ); +/* we have 0x100000 for eth, part of it are dma regs. +* So they are already requested */ + priv->dma_regs = (void *)(priv->eth_regs +0x1000 ); + + priv->phy_regs =dev_request_mem_region (dev,1 ); + + priv->cfg = pdata; + edev->init = ar231x_eth_init; + edev->open = ar231x_eth_open; + edev->send = ar231x_eth_send; + edev->recv = ar231x_eth_recv; + edev->halt = ar231x_eth_halt; + edev->get_ethaddr = ar231x_get_ethaddr; + edev->set_ethaddr = ar231x_set_ethaddr; + + priv->miibus.read = ar231x_miibus_read; + priv->miibus.write = ar231x_miibus_write; + priv->miibus.reset = ar231x_mdiibus_reset; + priv->miibus.priv = priv; + priv->miibus.parent = dev;
Quoted 8 lines
drivers/net/ar231x.c line 409
Quoted 3 lines
drivers/net/ar231x.c new file +3
-0+ +mdiobus_register (miibus); +eth_register (edev);Please check the return values of
dev_request_mem_region,mdiobus_registerandeth_register. I'm fine with not properly cleaning up afterwards, but we should be able to notice the user if something goes wrong here. (Yeah, I know, many network driver don't do so)
ok
Signature · 7 lines
Regards, Oleksij _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC, PATCH v2 2/3] net: add ar231x-eth support
Quoted 69 lines · Oleksij Rempel
Am 24.05.2013 09:09, schrieb Sascha Hauer:
Quoted 15 lines · Oleksij Rempel
Quoted 14 lines
This driver should work with some Atheros WiSoCs:
- ar2312, ar2313
- ar2315, ar2316 ...Signed-off-by Oleksij Rempel <[email protected]>--- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/ar231x.c | 429 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/ar231x.h | 219 ++++++++++++++++++++++++++ 4 files changed, 656 insertions(+) create mode 100644 drivers/net/ar231x.c create mode 100644 drivers/net/ar231x.hQuoted 5 lines
drivers/net/ar231x.c line 99
Quoted 3 lines
drivers/net/ar231x.c new file +3
-0+ +/* FIXME: priv->{t,r}x_ring are virtual addresses, +* use virt-to-phys convertion */ We use 1:1 mappings, so I think this comment should be removed.
This part should be fixed after Anthonys "MIPS: add initial cache support"
Quoted 10 lines
drivers/net/ar231x.c line 135
Quoted 8 lines
drivers/net/ar231x.c new file +8
-0+ +static void ar231x_allocate_dma_descriptors (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; +u16 ar231x_descr_size =sizeof (struct ar231x_descr ); +u16 i; + + priv->tx_ring =xmalloc (ar231x_descr_size);What alignment do you need here? This may or may not be safe.
Currently there is no other choice.
Quoted 23 lines
Quoted 23 lines
drivers/net/ar231x.c new file +23
-0+ +static int ar231x_eth_recv (struct eth_device *edev) +{ +struct ar231x_eth_priv *priv = edev->priv; + +while (1 ) { +struct ar231x_descr *rxdsc = priv->next_rxdsc; +u32 status = rxdsc->status; + +/* owned by DMA? */ +if (status &DMA_RX_OWN ) +break ; + +/* Pick only packets what we can handle: +* - only complete packet per buffer +* (First and Last at same time) +* - drop multicast */ +if (!priv->kill_rx_ring && + ((status &DMA_RX_MASK ) ==DMA_RX_FSLS )) { +u16 length = + ((status >>DMA_RX_LEN_SHIFT ) &0x3fff ) + -CRC_LEN ; +net_receive ((void *)rxdsc->buffer_ptr, length);Quoted 8 lines
drivers/net/ar231x.c line 226
Quoted 5 lines
drivers/net/ar231x.c new file +5
-0+ } +/* Clean descriptor. now it is owned by DMA. */ + priv->next_rxdsc = (struct ar231x_descr *)rxdsc->next_dsc_ptr; +ar231x_flash_rxdsc (rxdsc); + }This loop looks wrong. You should only receive a single packet for each call of this function.
Quoted 2 lines
This loop is needed to filter broadcast packtes. If remove this loop and reduce rx buffer, i will get really bad packet losses.
What I meant is that you should only pull a single packet out of the queue each time you enter ar231x_eth_recv. You shouldn't have to reduce the rx buffer for this.
Anyway, thinking about it it should be fine to call net_receive on all currently available buffers like you did above. Just keep it like it is now.
So with the request_mem_region fix this driver should be fine.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox