From patchwork Wed Aug 3 02:42:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yaroslav K." X-Patchwork-Id: 655544 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3s4LZh0XdJz9t0X for ; Thu, 4 Aug 2016 04:05:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=hzo/mEZC; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 39CB14BA3B; Wed, 3 Aug 2016 20:05:14 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VbuxIBb3XGhD; Wed, 3 Aug 2016 20:05:13 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3E0284BA5C; Wed, 3 Aug 2016 20:05:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 85D40A74FB for ; Wed, 3 Aug 2016 04:42:22 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C_xaV2xoiOoS for ; Wed, 3 Aug 2016 04:42:22 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by theia.denx.de (Postfix) with ESMTPS id 2F563A74DB for ; Wed, 3 Aug 2016 04:42:17 +0200 (CEST) Received: by mail-lf0-f65.google.com with SMTP id f93so11192852lfi.0 for ; Tue, 02 Aug 2016 19:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:cc; bh=lFd+D9XQbYirYP01U4I9h8YDeso2+ZznqolPWeeBeYs=; b=hzo/mEZCO9Ft1gqmTnD3jHG0SfYxcbq/98sVEg4SOhN4AqYaBlBdCRTngWFDD4T5rq yT3bwvVmmQiq87kGKozyhjYOATEqPy5ghQfzeV3bZBJMZ2/0UErQY2H2dMvEynYyOukl speBCdFGYjL2s+bd+20BbASJxzmEOxE7+b07kBtUJi1+DEmEmcPd6uq6imWMWEjXdPz/ emRjB4MED7gSp+Dep+H5Xin8KMue84Y0t5NoLawRWi++G7tJ9yiMHBhiS03g7/44wwd5 wO0Id18lBrJTVDfKm1i7VIVmr39D3tS8HXwvP+qHLU9nh1Ulh2JDuTS/QrbklztI4J5w m0bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=lFd+D9XQbYirYP01U4I9h8YDeso2+ZznqolPWeeBeYs=; b=MUeuCDuVkHpNVdFrZpZbtp4F7CZedOp6WBenN5Ooh38silpjMUWfqgh8JtqPa6oFJA GTASDTPs0YHC4ondZ1KsYcSiMeFm8B5Q/TB3ejtQRG0ISVPYtg7VVeQrJ5ERGxylJES+ a0Iesb+y8GdADTOH5yXR6x4zm1rgPqSzgumb4tDBXq4MnDC8DEcjawy+nufotsm4HIQD vCsUucmNaflR2/WQolbAgP/3nBQMreJJNnh81LfhGTFer73qo77ZdPijPeUV7zfvamrH 06K4cSHfEqFkkH5kMjcjWQxMILPQGOvHuT5wBAFQQB03wSaMPYuHwMz1lR4T+GrcC/to ciDQ== X-Gm-Message-State: AEkoouvV7v3XEq14P0U1HHr7TGeHWZsa2/W0Iq7J8/POMQlAt9ec30fNrKdzHzE3b/wv5qCuXfOD93037VeI8A== X-Received: by 10.25.160.139 with SMTP id j133mr18118361lfe.227.1470192136942; Tue, 02 Aug 2016 19:42:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.166.144 with HTTP; Tue, 2 Aug 2016 19:42:16 -0700 (PDT) From: "Yaroslav K." Date: Wed, 3 Aug 2016 08:42:16 +0600 Message-ID: To: U-Boot Mailing List X-Mailman-Approved-At: Wed, 03 Aug 2016 20:05:11 +0200 Subject: [U-Boot] [PATCH] net: e1000: Allow to use e1000 SPI command with DM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Fix compile errors when enabling CONFIG_DM_ETH, CONFIG_CMD_E1000 and CONFIG_E1000_SPI. Signed-off-by: Yaroslav K. Reviewed-by: Simon Glass --- drivers/net/e1000.c | 6 ++++- drivers/net/e1000_spi.c | 60 ++++++++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 31 deletions(-) int spi_claim_bus(struct spi_slave *spi) @@ -124,7 +124,7 @@ int spi_claim_bus(struct spi_slave *spi) struct e1000_hw *hw = e1000_hw_from_spi(spi); if (e1000_acquire_eeprom(hw)) { - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); return -1; } @@ -342,41 +342,41 @@ static int do_e1000_spi_show(cmd_tbl_t *cmdtp, struct e1000_hw *hw, /* Extra sanity checks */ if (!length) { - E1000_ERR(hw->nic, "Requested zero-sized dump!\n"); + E1000_ERR(hw, "Requested zero-sized dump!\n"); return 1; } if ((0x10000 < length) || (0x10000 - length < offset)) { - E1000_ERR(hw->nic, "Can't dump past 0xFFFF!\n"); + E1000_ERR(hw, "Can't dump past 0xFFFF!\n"); return 1; } /* Allocate a buffer to hold stuff */ buffer = malloc(length); if (!buffer) { - E1000_ERR(hw->nic, "Out of Memory!\n"); + E1000_ERR(hw, "Out of Memory!\n"); return 1; } /* Acquire the EEPROM and perform the dump */ if (e1000_acquire_eeprom(hw)) { - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); free(buffer); return 1; } err = e1000_spi_eeprom_dump(hw, buffer, offset, length, true); e1000_release_eeprom(hw); if (err) { - E1000_ERR(hw->nic, "Interrupted!\n"); + E1000_ERR(hw, "Interrupted!\n"); free(buffer); return 1; } /* Now hexdump the result */ printf("%s: ===== Intel e1000 EEPROM (0x%04hX - 0x%04hX) =====", - hw->nic->name, offset, offset + length - 1); + hw->name, offset, offset + length - 1); for (i = 0; i < length; i++) { if ((i & 0xF) == 0) - printf("\n%s: %04hX: ", hw->nic->name, offset + i); + printf("\n%s: %04hX: ", hw->name, offset + i); else if ((i & 0xF) == 0x8) printf(" "); printf(" %02hx", buffer[i]); @@ -407,29 +407,29 @@ static int do_e1000_spi_dump(cmd_tbl_t *cmdtp, struct e1000_hw *hw, /* Extra sanity checks */ if (!length) { - E1000_ERR(hw->nic, "Requested zero-sized dump!\n"); + E1000_ERR(hw, "Requested zero-sized dump!\n"); return 1; } if ((0x10000 < length) || (0x10000 - length < offset)) { - E1000_ERR(hw->nic, "Can't dump past 0xFFFF!\n"); + E1000_ERR(hw, "Can't dump past 0xFFFF!\n"); return 1; } /* Acquire the EEPROM */ if (e1000_acquire_eeprom(hw)) { - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); return 1; } /* Perform the programming operation */ if (e1000_spi_eeprom_dump(hw, dest, offset, length, true) < 0) { - E1000_ERR(hw->nic, "Interrupted!\n"); + E1000_ERR(hw, "Interrupted!\n"); e1000_release_eeprom(hw); return 1; } e1000_release_eeprom(hw); - printf("%s: ===== EEPROM DUMP COMPLETE =====\n", hw->nic->name); + printf("%s: ===== EEPROM DUMP COMPLETE =====\n", hw->name); return 0; } @@ -452,19 +452,19 @@ static int do_e1000_spi_program(cmd_tbl_t *cmdtp, struct e1000_hw *hw, /* Acquire the EEPROM */ if (e1000_acquire_eeprom(hw)) { - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); return 1; } /* Perform the programming operation */ if (e1000_spi_eeprom_program(hw, source, offset, length, true) < 0) { - E1000_ERR(hw->nic, "Interrupted!\n"); + E1000_ERR(hw, "Interrupted!\n"); e1000_release_eeprom(hw); return 1; } e1000_release_eeprom(hw); - printf("%s: ===== EEPROM PROGRAMMED =====\n", hw->nic->name); + printf("%s: ===== EEPROM PROGRAMMED =====\n", hw->name); return 0; } @@ -488,19 +488,19 @@ static int do_e1000_spi_checksum(cmd_tbl_t *cmdtp, struct e1000_hw *hw, length = sizeof(uint16_t) * (EEPROM_CHECKSUM_REG + 1); buffer = malloc(length); if (!buffer) { - E1000_ERR(hw->nic, "Unable to allocate EEPROM buffer!\n"); + E1000_ERR(hw, "Unable to allocate EEPROM buffer!\n"); return 1; } /* Acquire the EEPROM */ if (e1000_acquire_eeprom(hw)) { - E1000_ERR(hw->nic, "EEPROM SPI cannot be acquired!\n"); + E1000_ERR(hw, "EEPROM SPI cannot be acquired!\n"); return 1; } /* Read the EEPROM */ if (e1000_spi_eeprom_dump(hw, buffer, 0, length, true) < 0) { - E1000_ERR(hw->nic, "Interrupted!\n"); + E1000_ERR(hw, "Interrupted!\n"); e1000_release_eeprom(hw); return 1; } @@ -514,14 +514,14 @@ static int do_e1000_spi_checksum(cmd_tbl_t *cmdtp, struct e1000_hw *hw, /* Verify it! */ if (checksum_reg == checksum) { printf("%s: INFO: EEPROM checksum is correct! (0x%04hx)\n", - hw->nic->name, checksum); + hw->name, checksum); e1000_release_eeprom(hw); return 0; } /* Hrm, verification failed, print an error */ - E1000_ERR(hw->nic, "EEPROM checksum is incorrect!\n"); - E1000_ERR(hw->nic, " ...register was 0x%04hx, calculated 0x%04hx\n", + E1000_ERR(hw, "EEPROM checksum is incorrect!\n"); + E1000_ERR(hw, " ...register was 0x%04hx, calculated 0x%04hx\n", checksum_reg, checksum); /* If they didn't ask us to update it, just return an error */ @@ -531,11 +531,11 @@ static int do_e1000_spi_checksum(cmd_tbl_t *cmdtp, struct e1000_hw *hw, } /* Ok, correct it! */ - printf("%s: Reprogramming the EEPROM checksum...\n", hw->nic->name); + printf("%s: Reprogramming the EEPROM checksum...\n", hw->name); buffer[i] = cpu_to_le16(checksum); if (e1000_spi_eeprom_program(hw, &buffer[i], i * sizeof(uint16_t), sizeof(uint16_t), true)) { - E1000_ERR(hw->nic, "Interrupted!\n"); + E1000_ERR(hw, "Interrupted!\n"); e1000_release_eeprom(hw); return 1; } @@ -554,7 +554,7 @@ int do_e1000_spi(cmd_tbl_t *cmdtp, struct e1000_hw *hw, /* Make sure it has an SPI chip */ if (hw->eeprom.type != e1000_eeprom_spi) { - E1000_ERR(hw->nic, "No attached SPI EEPROM found!\n"); + E1000_ERR(hw, "No attached SPI EEPROM found!\n"); return 1; } diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 196989b..09d6870 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -5513,7 +5513,8 @@ static int do_e1000(cmd_tbl_t *cmdtp, int flag, struct udevice *dev; char name[30]; int ret; -#else +#endif +#if !defined(CONFIG_DM_ETH) || defined(CONFIG_E1000_SPI) struct e1000_hw *hw; #endif int cardnum; @@ -5532,6 +5533,9 @@ static int do_e1000(cmd_tbl_t *cmdtp, int flag, plat = dev_get_platdata(dev); mac = plat->enetaddr; } +#ifdef CONFIG_E1000_SPI + hw = dev_get_priv(dev); +#endif #else hw = e1000_find_card(cardnum); if (hw) diff --git a/drivers/net/e1000_spi.c b/drivers/net/e1000_spi.c index 576ddb8..78f4f15 100644 --- a/drivers/net/e1000_spi.c +++ b/drivers/net/e1000_spi.c @@ -94,29 +94,29 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, /* Make sure it has an SPI chip */ if (hw->eeprom.type != e1000_eeprom_spi) { - E1000_ERR(hw->nic, "No attached SPI EEPROM found!\n"); + E1000_ERR(hw, "No attached SPI EEPROM found!\n"); return NULL; } /* Argument sanity checks */ if (cs != 0) { - E1000_ERR(hw->nic, "No such SPI chip: %u\n", cs); + E1000_ERR(hw, "No such SPI chip: %u\n", cs); return NULL; } if (mode != SPI_MODE_0) { - E1000_ERR(hw->nic, "Only SPI MODE-0 is supported!\n"); + E1000_ERR(hw, "Only SPI MODE-0 is supported!\n"); return NULL; } /* TODO: Use max_hz somehow */ - E1000_DBG(hw->nic, "EEPROM SPI access requested\n"); + E1000_DBG(hw, "EEPROM SPI access requested\n"); return &hw->spi; } void spi_free_slave(struct spi_slave *spi) { __maybe_unused struct e1000_hw *hw = e1000_hw_from_spi(spi); - E1000_DBG(hw->nic, "EEPROM SPI access released\n"); + E1000_DBG(hw, "EEPROM SPI access released\n"); }