Skip to contentSkip to conversation

ks8851_mll: add ethernet support

RFC In review Raffaele Recalcati 3 participants 3 messages Mar 16, 2011 – Apr 30, 2011 Network drivers

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ks8851_mll: add ethernet support

From: Roberto Cerati <[email protected]>

The device interface is 16 bits wide.
All the available packets are read from the incoming fifo.

Signed-off-by Roberto Cerati <roberto.cerati at bticino.it

---
This driver has been adapted to u-boot starting from ks8851_mll linux driver. The smsc911x u-boot has been used as reference.

TODO: smsc911x reads only one packet from incoming fifo, ks8851_mll reads all packets in the incoming fifo, but it is not checked if upper driver level (net/eth.c ?) manages more than one packet.

This driver has been tested against u-boot-2009.11-psp03.00.01.06 u-boot version present in ti-dvsdk_dm3730-evm_4_01_00_09 DVSDK. The board name is baia and is based on dm3730 soc adapted from evm-dm3730 Ti board.

 drivers/net/Makefile     |    1 +
 drivers/net/ks8851_mll.c |  708 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ks8851_mll.h |  358 +++++++++++++++++++++++
 3 files changed, 1067 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ks8851_mll.c
 create mode 100644 drivers/net/ks8851_mll.h
drivers/net/Makefile +1 -0
index fd9d0b4..ed69090 100644
@@ -84,6 +84,7 @@ COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 COBJS-$(CONFIG_ULI526X) += uli526x.o
 COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o
 COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
+COBJS-$(CONFIG_KS8851_MLL) += ks8851_mll.o
 
 COBJS	:= $(sort $(COBJS-y))
 SRCS	:= $(COBJS:.o=.c)
drivers/net/ks8851_mll.c new file +708 -0

708 lines not on this page · raw message

drivers/net/ks8851_mll.h new file +358 -0

358 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

Dear Raffaele Recalcati,

Quoted 11 lines · In message <[email protected]> you wrote:

From: Roberto Cerati <[email protected]>

The device interface is 16 bits wide.
All the available packets are read from the incoming fifo.

---
This driver has been adapted to u-boot starting from ks8851_mll linux driver. The smsc911x u-boot has been used as reference.

Quoted 8 lines

TODO: smsc911x reads only one packet from incoming fifo, ks8851_mll reads all packets in the incoming fifo, but it is not checked if upper driver level (net/eth.c ?) manages more than one packet.

This driver has been tested against u-boot-2009.11-psp03.00.01.06 u-boot version present in ti-dvsdk_dm3730-evm_4_01_00_09 DVSDK. The board name is baia and is based on dm3730 soc adapted from evm-dm3730 Ti board.

We only add code to mainline that has users in mainline. Please resubmit with the patches that add support for this board. Thanks.

Quoted 7 lines

+/*
+ * Micrel KS8851_MLL 16bit Network driver
+ * Copyright (c) 2011 Roberto Cerati <[email protected]>
+ *
+ * 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.

Also, U-Boot requires the v2 or later clause, please see bullet # 3 at
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign

drivers/net/ks8851_mll.c line 134

Quoted 13 lines
drivers/net/ks8851_mll.c new file +13 -0
+static u8 ks_rdreg8(struct eth_device *dev, u16 offset)
+{
+	volatile u16 *hw_addr = (u16 *)(dev->iobase);
+	volatile u16 *hw_addr_cmd = (u16 *)(dev->iobase + 2);
+
+	u16 data;
+
+	u8 shift_bit = offset & 0x03;
+	u8 shift_data = (offset & 1) << 3;
+
+	*hw_addr_cmd = offset | (u16)(BE0 << shift_bit);
+
+	data  = *hw_addr;

And please get rid of all these volatile declarations and use proper I/O accessors instead.

Before resubmitting, make sure to run checkpatch.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"There's only one way to have a happy marriage and as soon as I learn
what it is I'll get married again."                  - Clint Eastwood
#2 lore raw
In reply to Raffaele Recalcati
Quoted 2 lines · On Wednesday, March 16, 2011 05:17:19 Raffaele Recalcati wrote:

This driver has been adapted to u-boot starting from ks8851_mll linux driver. The smsc911x u-boot has been used as reference.

if you're basing this driver on other code, then the copyright info in the header should be preserved from the other files

Review

Quoted 2 lines
(quoted diff) +2 -0
+static inline void ks_read_qmu(struct eth_device *dev, u16 *buf, u32 len)
+{

this is a fairly fat func to be forcing inline. in general, let gcc handle the optimization and only use "inline" when you really really need it.

drivers/net/ks8851_mll.c line 703

Quoted 7 lines
drivers/net/ks8851_mll.c new file +6 -0
+int ks8851_mll_register(u8 dev_num, int base_addr)
+{
...
+	dev->init = ks8851_mll_init;
+	dev->halt = ks8851_mll_halt;
+	dev->send = ks8851_mll_send;
+	dev->recv = ks8851_mll_rx;

missing dev->write_hwaddr

drivers/net/ks8851_mll.h line 356

Quoted 6 lines
drivers/net/ks8851_mll.h new file +4 -0
+static const struct chip_id chip_ids[] =  {
+	{ CIDER_ID, "KSZ8851" },
+	{ 0, NULL },
+};

headers should not be defining variables. this belongs in the .c file. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110430/6daca6fc/attachment.pgp