From mboxrd@z Thu Jan 1 00:00:00 1970 From: Reinhard Meyer Date: Fri, 03 Sep 2010 19:50:28 +0200 Subject: [U-Boot] [PATCH] NET: add ENC28J60 driver using SPI framework In-Reply-To: <201008252355.22876.vapier@gentoo.org> References: <1282740459-7941-1-git-send-email-u-boot@emk-elektronik.de> <201008252355.22876.vapier@gentoo.org> Message-ID: <4C813564.7010703@emk-elektronik.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Mike Frysinger, > pass the bus/cs/speed/mode in to the initialize function and store it in the > per-device state. then you can work fine with multiple enc28j60 devices in > one board. > > along those lines, all of the local enc funcs should be changed to take the > private state and operate off that instead of random global variables. Something like this? typedef struct enc_device { struct eth_device netdev; struct spi_slave *slave; u16 next_pointer; int rx_reset_counter; u8 bank; /* current bank in enc28j60 */ } enc_dev_t; #define to_enc(_nd) container_of(_nd, struct enc_device, netdev) ... static u8 enc_r8(enc_dev_t *, u16 reg); static u16 enc_r16(enc_dev_t *, u16 reg); static void enc_w8(enc_dev_t *, u16 reg, u8 data); static void enc_w16(enc_dev_t *, u16 reg, u16 data); static void enc_w8_retry(enc_dev_t *, u16 reg, u8 data, int c); I agree that's more perfect but kind of overkill, too; assuming that only one enc can be active at any given time;) Best Regards, Reinhard