+#include <common.h>
+#include <console.h>
#include "e1000.h"
+#include <linux/compiler.h>
/*-----------------------------------------------------------------------
* SPI transfer
* never return an error.
*/
static int e1000_spi_xfer(struct e1000_hw *hw, unsigned int bitlen,
- const void *dout_mem, void *din_mem, boolean_t intr)
+ const void *dout_mem, void *din_mem, bool intr)
{
const uint8_t *dout = dout_mem;
uint8_t *din = din_mem;
return container_of(spi, struct e1000_hw, spi);
}
-/* Not sure why all of these are necessary */
-void spi_init_r(void) { /* Nothing to do */ }
-void spi_init_f(void) { /* Nothing to do */ }
-void spi_init(void) { /* Nothing to do */ }
-
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int mode)
{
/* 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;
}
void spi_free_slave(struct spi_slave *spi)
{
- struct e1000_hw *hw = e1000_hw_from_spi(spi);
+ __maybe_unused struct e1000_hw *hw = e1000_hw_from_spi(spi);
E1000_DBG(hw->nic, "EEPROM SPI access released\n");
}
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;
}
if (flags & SPI_XFER_BEGIN)
e1000_standby_eeprom(hw);
- ret = e1000_spi_xfer(hw, bitlen, dout_mem, din_mem, TRUE);
+ ret = e1000_spi_xfer(hw, bitlen, dout_mem, din_mem, true);
if (flags & SPI_XFER_END)
e1000_standby_eeprom(hw);
#define SPI_EEPROM_STATUS_BUSY 0x01
#define SPI_EEPROM_STATUS_WREN 0x02
-static int e1000_spi_eeprom_enable_wr(struct e1000_hw *hw, boolean_t intr)
+static int e1000_spi_eeprom_enable_wr(struct e1000_hw *hw, bool intr)
{
u8 op[] = { SPI_EEPROM_ENABLE_WR };
e1000_standby_eeprom(hw);
* These have been tested to perform correctly, but they are not used by any
* of the EEPROM commands at this time.
*/
-#if 0
-static int e1000_spi_eeprom_disable_wr(struct e1000_hw *hw, boolean_t intr)
+static __maybe_unused int e1000_spi_eeprom_disable_wr(struct e1000_hw *hw,
+ bool intr)
{
u8 op[] = { SPI_EEPROM_DISABLE_WR };
e1000_standby_eeprom(hw);
return e1000_spi_xfer(hw, 8*sizeof(op), op, NULL, intr);
}
-static int e1000_spi_eeprom_write_status(struct e1000_hw *hw,
- u8 status, boolean_t intr)
+static __maybe_unused int e1000_spi_eeprom_write_status(struct e1000_hw *hw,
+ u8 status, bool intr)
{
u8 op[] = { SPI_EEPROM_WRITE_STATUS, status };
e1000_standby_eeprom(hw);
return e1000_spi_xfer(hw, 8*sizeof(op), op, NULL, intr);
}
-#endif
-static int e1000_spi_eeprom_read_status(struct e1000_hw *hw, boolean_t intr)
+static int e1000_spi_eeprom_read_status(struct e1000_hw *hw, bool intr)
{
u8 op[] = { SPI_EEPROM_READ_STATUS, 0 };
e1000_standby_eeprom(hw);
}
static int e1000_spi_eeprom_write_page(struct e1000_hw *hw,
- const void *data, u16 off, u16 len, boolean_t intr)
+ const void *data, u16 off, u16 len, bool intr)
{
u8 op[] = {
SPI_EEPROM_WRITE_PAGE,
}
static int e1000_spi_eeprom_read_page(struct e1000_hw *hw,
- void *data, u16 off, u16 len, boolean_t intr)
+ void *data, u16 off, u16 len, bool intr)
{
u8 op[] = {
SPI_EEPROM_READ_PAGE,
return 0;
}
-static int e1000_spi_eeprom_poll_ready(struct e1000_hw *hw, boolean_t intr)
+static int e1000_spi_eeprom_poll_ready(struct e1000_hw *hw, bool intr)
{
int status;
while ((status = e1000_spi_eeprom_read_status(hw, intr)) >= 0) {
}
static int e1000_spi_eeprom_dump(struct e1000_hw *hw,
- void *data, u16 off, unsigned int len, boolean_t intr)
+ void *data, u16 off, unsigned int len, bool intr)
{
/* Interruptibly wait for the EEPROM to be ready */
if (e1000_spi_eeprom_poll_ready(hw, intr))
}
static int e1000_spi_eeprom_program(struct e1000_hw *hw,
- const void *data, u16 off, u16 len, boolean_t intr)
+ const void *data, u16 off, u16 len, bool intr)
{
/* Program each page in sequence */
while (len) {
/* 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);
+ 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]);
/* 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");
+ if (e1000_spi_eeprom_dump(hw, dest, offset, length, true) < 0) {
+ 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;
}
/* 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");
+ if (e1000_spi_eeprom_program(hw, source, offset, length, true) < 0) {
+ 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;
}
static int do_e1000_spi_checksum(cmd_tbl_t *cmdtp, struct e1000_hw *hw,
int argc, char * const argv[])
{
- uint16_t i, length, checksum, checksum_reg;
+ uint16_t i, length, checksum = 0, checksum_reg;
uint16_t *buffer;
- boolean_t upd;
+ bool upd;
if (argc == 0)
upd = 0;
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");
+ if (e1000_spi_eeprom_dump(hw, buffer, 0, length, true) < 0) {
+ E1000_ERR(hw, "Interrupted!\n");
e1000_release_eeprom(hw);
return 1;
}
/* 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",
- checksum_reg, checksum);
+ 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 */
if (!upd) {
}
/* 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");
+ sizeof(uint16_t), true)) {
+ E1000_ERR(hw, "Interrupted!\n");
e1000_release_eeprom(hw);
return 1;
}
/* 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 (%d)!\n",
+ hw->eeprom.type);
return 1;
}