#include "netif/ppp_oe.h"
/* end - lwIP headers */
-#include "hal/hal.h"
+#include "drv/gio.h"
#include "sys/sys.h" /* includes - sys/phy_dp83848h.h */
#include "drv/emac.h"
#include "os/os.h"
/* Number of EMAC Instances */
-#define MAX_EMAC_INSTANCE 1
+#define MAX_EMAC_INSTANCE 1
-#define DEFAULT_PHY_ADDR 0x1
-#define FIND_FIRST_PHY_ALIVE 1 /* or use default (phy_address: 1) */
-#define NUM_OF_PHYs 32
+#define DEFAULT_PHY_ADDR 0x1
+#define FIND_FIRST_PHY_ALIVE 1 /* or use default (phy_address: 1) */
+#define NUM_OF_PHYs 32
/* Size of the Buffer descriptor defined by the EMAC in bytes */
-#define SIZE_OF_DESC 16
+#define SIZE_OF_DESC 16
/* Channel number used for for RX, TX, unicast, broadcast or damaged frames;
* there are different channels for rx and tx operations (i.e. RXCH0 != TXCH0) */
-#define CHANNEL 0
+#define CHANNEL 0
/* take in account oversized frames */
-#define MAX_TRANSFER_UNIT 1500
+#define MAX_TRANSFER_UNIT 1500
/* WARNING!
* Be very carefull when setting this value. We have to keep in mind
* This is the implementation limitation. The PBUF_LEN_MAX should therefore
* be multiple of PBUF_POOL_BUFSIZE
*/
-#define PBUF_LEN_MAX (PBUF_POOL_BUFSIZE * 6)
+#define PBUF_LEN_MAX (PBUF_POOL_BUFSIZE * 6)
/* Maximum number of PBUFs preallocated in the driver
* init function to be used for the RX
*/
-#define MAX_RX_PBUF_ALLOC 10
-#define MIN_PKT_LEN 60
+#define MAX_RX_PBUF_ALLOC 10
+#define MIN_PKT_LEN 60
/* Define those to better describe the network interface. */
-#define IFNAME0 'e'
-#define IFNAME1 'n'
+#define IFNAME0 'e'
+#define IFNAME1 'n'
/* Time to wait for autonegotiation in ticks. */
-#define TICKS_PHY_AUTONEG 4000
+#define TICKS_PHY_AUTONEG 4000
/**
* TODO -- not implemented
* When cable is connected (link status goes up)
* autonegotiation and/or dhcp is started.
*/
-#define PHY_LINK_MONITOR_INT 0
+#define PHY_LINK_MONITOR_INT 0
/* Statically allocated structure describing interface state -- one per instance */
uint32_t rpp_eth_phylinkstat(uint32_t instNum)
{
struct hdkif *hdkif = &hdkif_data[instNum];
+
return PHY_link_status_get(hdkif->mdio_base, hdkif->phy_addr, 1);
}
ipaddr = (ipaddr << 8) + tmp;
dots++;
- if(dots > 3)break;
+ if (dots > 3)break;
tmp = 0;
fldEdit = FALSE;
*/
static void hdkif_inst_config(struct hdkif *hdkif)
{
- if (hdkif->inst_num == 0)
- {
+ if (hdkif->inst_num == 0) {
hdkif->emac_base = EMAC_BASE_m(0);
hdkif->emac_ctrl_base = EMAC_CTRL_BASE_m(0);
hdkif->emac_ctrl_ram = EMAC_CTRL_RAM_BASE_m(0);
return FAILURE;
/* Config each EMAC instance */
- for (instNum = 0; instNum < MAX_EMAC_INSTANCE; instNum++)
- {
+ for (instNum = 0; instNum < MAX_EMAC_INSTANCE; instNum++) {
struct hdkif *hdkif = &hdkif_data[instNum];
hdkif->inst_num = instNum;
* and initialize netif with specific function
*/
netif_tmp = netif_add(netif, &ip_addr, &net_mask, &gw_addr,
- &hdkif_data[instNum], rpp_eth_lwip_init,
- ethernet_input);
+ &hdkif_data[instNum], rpp_eth_lwip_init,
+ ethernet_input);
#else
netif_tmp = netif_add(netif, &ip_addr, &net_mask, &gw_addr,
- &hdkif_data[instNum], rpp_eth_lwip_init,
- tcpip_input);
+ &hdkif_data[instNum], rpp_eth_lwip_init,
+ tcpip_input);
#endif
if (netif_tmp == NULL)
return NETIF_ADD_ERR;
*/
index = configCPU_CLOCK_HZ/1000000;
#endif /* NO_SYS */
- hal_gpio_pin_set_value(*hal_gpio_pin_get_dsc(PIN_NAME_ETHRST, -1), 0);
- while(index--)
- ;
+ dio_pin_set(*dio_gpio_pin_get_dsc(PIN_NAME_ETHRST, -1), 0);
+ while (index--) ;
#endif /* !INIT_ONLY_AFTER_RESET */
-
/*
* We have pull-down resistor, so after reset, we only need
* to put ETHRST pin to log. high
*/
- hal_gpio_pin_set_value(*hal_gpio_pin_get_dsc(PIN_NAME_ETHRST, -1), 1);
+ gio_set(PIN_ETHRST, 1);
/* Initialize EMAC control module and EMAC module */
EMACInit(hdkif->emac_ctrl_base, hdkif->emac_base);
* when complete link register will be updated
*/
hdkif->phy_autoneg_start(hdkif->mdio_base, hdkif->phy_addr,
- PHY_100BASETXDUPL_m | PHY_100BASETX_m |
- PHY_10BASETDUPL_m | PHY_10BASET_m);
+ PHY_100BASETXDUPL_m | PHY_100BASETX_m |
+ PHY_10BASETDUPL_m | PHY_10BASET_m);
/*
* TODO: you can implement init of receive flow control somewhere
#ifdef DEBUG
num_bd = (((uintptr_t)rxch->active_tail - (uintptr_t)rxch->active_head)
- / sizeof(struct emac_rx_bd)) + 1;
+ / sizeof(struct emac_rx_bd)) + 1;
rpp_debug_printf("%d pbuf chains allocated for %d rx buffer descriptors\n",
- pbuf_cnt, num_bd);
+ pbuf_cnt, num_bd);
#endif
/* Set header descriptor pointers -- this shows EMAC which descriptor
*/
for (regContent = 0; regContent < 8; regContent++) {
EMACMACAddrSet(hdkif->emac_base, regContent, hdkif->mac_addr,
- EMAC_MACADDR_NO_MATCH_NO_FILTER);
+ EMAC_MACADDR_NO_MATCH_NO_FILTER);
}
#if !PHY_LINK_MONITOR_INT
err_t rpp_eth_send(struct netif *netif, struct pbuf *p)
{
err_t retVal = SUCCESS;
+
SYS_ARCH_DECL_PROTECT(lev);
/**
/* First 'part' of packet flags */
curr_bd->flags_pktlen = pbuf->tot_len |
- EMAC_DSC_FLAG_SOP |
- EMAC_DSC_FLAG_OWNER;
+ EMAC_DSC_FLAG_SOP |
+ EMAC_DSC_FLAG_OWNER;
/* Copy pbuf information into TX BDs --
* remember that the pbuf for a single packet might be chained!
while (HWREG(hdkif->emac_base + EMAC_TXHDP(CHANNEL)) != 0)
;
EMACTxHdrDescPtrWrite(hdkif->emac_base,
- (unsigned int)(active_head), CHANNEL);
+ (unsigned int)(active_head), CHANNEL);
}
}
txch->active_tail = active_tail;
/* Ack the Interrupt in the EMAC peripheral */
EMACTxCPWrite(hdkif->emac_base, CHANNEL,
- (uint32_t)curr_bd);
+ (uint32_t)curr_bd);
/* Free the corresponding pbuf
* Sidenote: Each fragment of the single packet points
rpp_sci_printk("HOSTPEND err\n");
reg = HWREG(hdkif->emac_base + EMAC_MACSTATUS);
rpp_sci_printk("TXCHERR: %d at CH: %d\n",
- ((reg >> EMAC_MACSTATUS_TXERRCODE_SHIFT) & 0x7),
- ((reg >> EMAC_MACSTATUS_TXERRCH_SHIFT) & 0x7));
+ ((reg >> EMAC_MACSTATUS_TXERRCODE_SHIFT) & 0x7),
+ ((reg >> EMAC_MACSTATUS_TXERRCH_SHIFT) & 0x7));
rpp_sci_printk("RXCHERR: %d at CH: %d\n",
- ((reg >> EMAC_MACSTATUS_RXERRCODE_SHIFT) & 0x7),
- ((reg >> EMAC_MACSTATUS_RXERRCH_SHIFT) & 0x7));
+ ((reg >> EMAC_MACSTATUS_RXERRCODE_SHIFT) & 0x7),
+ ((reg >> EMAC_MACSTATUS_RXERRCH_SHIFT) & 0x7));
{ /* Print out all the RX BDs */
struct rxch *rxch;
glob_len += curr_bd->pbuf->len;
rpp_sci_printk("[%p: buf: %p buffoff_len: 0x%x "
- "\tflags: 0x%x pktlen: 0x%x]",
- curr_bd,
- curr_bd->bufptr,
- curr_bd->bufoff_len,
- (curr_bd->flags_pktlen >> 16) & 0xFFFF,
- curr_bd->flags_pktlen & 0xFFFF);
+ "\tflags: 0x%x pktlen: 0x%x]",
+ curr_bd,
+ curr_bd->bufptr,
+ curr_bd->bufoff_len,
+ (curr_bd->flags_pktlen >> 16) & 0xFFFF,
+ curr_bd->flags_pktlen & 0xFFFF);
rpp_sci_printk(" pbuf: tot_len: 0x%x \tlen: 0x%x ref: 0x%x\n",
- curr_bd->pbuf->tot_len,
- curr_bd->pbuf->len,
- curr_bd->pbuf->ref);
+ curr_bd->pbuf->tot_len,
+ curr_bd->pbuf->len,
+ curr_bd->pbuf->ref);
}
rpp_sci_printk("glob_len: %d\n", glob_len);
}
while (index) {
hdkif = &hdkif_data[--index];
if ((hdkif->phy_addr ==
- (HWREG(hdkif->mdio_base + MDIO_USERPHYSEL0) & 0x1f)) &&
- (EMACIntVectorGet(hdkif->emac_base) &
- EMAC_MACINVECTOR_LINKINT0))
+ (HWREG(hdkif->mdio_base + MDIO_USERPHYSEL0) & 0x1f)) &&
+ (EMACIntVectorGet(hdkif->emac_base) &
+ EMAC_MACINVECTOR_LINKINT0))
phyFound = TRUE;
}
if (!phyFound)
#if STATIC_IP_ADDRESS
netif_set_up(netif);
#elif LWIP_DHCP /* STATIC_IP_ADDRESS-LWIP_DHCP */
- if (dhcp_start(netif) != ERR_OK) { /* XXX: can't be used from ISR (mem_malloc()) */
+ if (dhcp_start(netif) != ERR_OK) /* XXX: can't be used from ISR (mem_malloc()) */
return DHCP_MEM_ERR;
- }
+
#if ONCE_LINK_SETUP
while (netif->dhcp->state != DHCP_BOUND)
;