[U-Boot] [PATCH] NET: add ENC28J60 driver using SPI framework

Reinhard Meyer u-boot at emk-elektronik.de
Fri Sep 3 19:50:28 CEST 2010


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


More information about the U-Boot mailing list