@@ -29,6 +29,26 @@
/****************************************************************************/
/*
+ * some defines to allow switching between NET_MULTI and old API
+ */
+#if defined(CONFIG_NET_MULTI)
+#define KS8695_ETH_RESET ks8695_eth_reset
+#define KS8695_ETH_HALT ks8695_eth_halt
+#define KS8695_ETH_INIT ks8695_eth_init
+#define KS8695_ETH_RX ks8695_eth_rx
+#define KS8695_ETH_SEND ks8695_eth_send
+#define KS8695_DRIVERNAME "KS8695"
+#else
+#define KS8695_ETH_RESET eth_reset
+#define KS8695_ETH_HALT eth_halt
+#define KS8695_ETH_INIT eth_init
+#define KS8695_ETH_RX eth_rx
+#define KS8695_ETH_SEND eth_send
+#endif
+
+/****************************************************************************/
+
+/*
* Hardware register access to the KS8695 LAN ethernet port
* (well, it is the 4 port switch really).
*/
@@ -103,7 +123,7 @@
/****************************************************************************/
-void eth_reset(bd_t *bd)
+void KS8695_ETH_RESET(bd_t *bd)
{
int i;
@@ -159,28 +179,28 @@
/****************************************************************************/
-int eth_init(bd_t *bd)
+int KS8695_ETH_INIT(bd_t *bd)
{
debug ("%s(%d): eth_init()\n", __FILE__, __LINE__);
- eth_reset(bd);
+ KS8695_ETH_RESET(bd);
return 0;
}
/****************************************************************************/
-void eth_halt(void)
+void KS8695_ETH_HALT(void)
{
debug ("%s(%d): eth_halt()\n", __FILE__, __LINE__);
/* Reset the ethernet engines */
- ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
- ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
+/* ks8695_write(KS8695_LAN_DMA_TX, 0x80000000); */
+/* ks8695_write(KS8695_LAN_DMA_RX, 0x80000000); */
}
/****************************************************************************/
-int eth_rx(void)
+int KS8695_ETH_RX(void)
{
volatile struct ks8695_rxdesc *dp;
int i, len = 0;
@@ -203,7 +223,7 @@
/****************************************************************************/
-int eth_send(volatile void *packet, int len)
+int KS8695_ETH_SEND(volatile void *packet, int len)
{
volatile struct ks8695_txdesc *dp;
static int next = 0;
@@ -230,3 +250,72 @@
return len;
}
+
+/****************************************************************************/
+
+#ifdef CONFIG_NET_MULTI
+
+static void ks8695_halt(struct eth_device *dev)
+{
+ KS8695_ETH_HALT();
+}
+
+static int ks8695_init(struct eth_device *dev, bd_t * bd)
+{
+ return KS8695_ETH_INIT(bd);
+}
+
+static int ks8695_recv(struct eth_device *dev)
+{
+ int i;
+
+ i = KS8695_ETH_RX();
+ return i;
+}
+
+static int ks8695_send(struct eth_device *dev, volatile void *packet, int length)
+{
+ KS8695_ETH_SEND(packet, length);
+ return 0;
+}
+
+static void ks8695_get_enetaddr(struct eth_device *dev)
+{
+ int i;
+
+ ks8695_getmac(); /* load MAC to eth_mac */
+ for (i = 0; i < 6; i++) {
+ dev->enetaddr[i] = eth_mac[i];
+ }
+}
+
+int ks8695_initialize(void)
+{
+ struct eth_device *dev;
+
+ dev = malloc(sizeof(*dev));
+ if (!dev) {
+ free(dev);
+ return 0;
+ }
+ else {
+ memset(dev, 0, sizeof(*dev));
+
+ dev->iobase = KS8695_IO_BASE;
+ dev->priv = NULL;
+ dev->init = ks8695_init;
+ dev->halt = ks8695_halt;
+ dev->send = ks8695_send;
+ dev->recv = ks8695_recv;
+
+ /* Load MAC address from EEPROM */
+ ks8695_get_enetaddr(dev);
+
+ sprintf(dev->name, "%s", KS8695_DRIVERNAME);
+
+ eth_register(dev);
+ return 0;
+ }
+}
+
+#endif
Hello, Add support for the new NET MULTI api in the ethernet driver of the KS8695. Signed-off-by: Michael Bernstein <Michael.Bernstein@controlware.de> --- --