Skip to content
Permalink
Browse files

drivers: eth_enc28j60: update for dts change to local-mac-address

uint8_array values are now generated as structure initializers.  Update
the code accordingly.  The implementation assumes that existing
devicetree source does not provide the correct OUI so preserves the
in-driver override of the value provided by devicetree.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
  • Loading branch information...
pabigot authored and galak committed Jul 10, 2019
1 parent 79765b8 commit 388460ac14f8b043f9780a03ab0c02b4118ef9d3
Showing with 17 additions and 20 deletions.
  1. +16 −14 drivers/ethernet/eth_enc28j60.c
  2. +1 −6 tests/drivers/build_all/dts_fixup.h
@@ -348,6 +348,7 @@ static void eth_enc28j60_init_buffers(struct device *dev)
static void eth_enc28j60_init_mac(struct device *dev)
{
const struct eth_enc28j60_config *config = dev->config->config_info;
struct eth_enc28j60_runtime *context = dev->driver_data;
u8_t data_macon;

eth_enc28j60_set_bank(dev, ENC28J60_REG_MACON1);
@@ -381,14 +382,17 @@ static void eth_enc28j60_init_mac(struct device *dev)
/* Configure MAC address */
eth_enc28j60_set_bank(dev, ENC28J60_REG_MAADR0);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR0,
DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_5);
context->mac_address[5]);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR1,
DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_4);
context->mac_address[4]);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR2,
DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_3);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR3, MICROCHIP_OUI_B2);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR4, MICROCHIP_OUI_B1);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR5, MICROCHIP_OUI_B0);
context->mac_address[3]);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR3,
context->mac_address[2]);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR4,
context->mac_address[1]);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR5,
context->mac_address[0]);
}

static void eth_enc28j60_init_phy(struct device *dev)
@@ -715,6 +719,11 @@ static int eth_enc28j60_init(struct device *dev)
/* Errata B7/1 */
k_busy_wait(D10D24S);

/* Assign octets not previously taken from devicetree */
context->mac_address[0] = MICROCHIP_OUI_B0;
context->mac_address[1] = MICROCHIP_OUI_B1;
context->mac_address[2] = MICROCHIP_OUI_B2;

eth_enc28j60_init_buffers(dev);
eth_enc28j60_init_mac(dev);
eth_enc28j60_init_phy(dev);
@@ -743,14 +752,7 @@ static int eth_enc28j60_init(struct device *dev)
#ifdef CONFIG_ETH_ENC28J60_0

static struct eth_enc28j60_runtime eth_enc28j60_0_runtime = {
.mac_address = {
MICROCHIP_OUI_B0,
MICROCHIP_OUI_B1,
MICROCHIP_OUI_B2,
DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_3,
DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_4,
DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_5
},
.mac_address = DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS,
.tx_rx_sem = Z_SEM_INITIALIZER(eth_enc28j60_0_runtime.tx_rx_sem,
1, UINT_MAX),
.int_sem = Z_SEM_INITIALIZER(eth_enc28j60_0_runtime.int_sem,
@@ -321,12 +321,7 @@
#define DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_FLAGS 0
#define DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_PIN 0
#define DT_INST_0_MICROCHIP_ENC28J60_LABEL ""
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_0 0
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_1 0
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_2 0
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_3 0
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_4 0
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS_5 0
#define DT_INST_0_MICROCHIP_ENC28J60_LOCAL_MAC_ADDRESS {0, 0, 0, 0, 0, 0}
#define DT_INST_0_MICROCHIP_ENC28J60_SPI_MAX_FREQUENCY 0
#endif

0 comments on commit 388460a

Please sign in to comment.
You can’t perform that action at this time.