Re: [PATCH] arch: arm: uDPU: fix PHY mode definition to sgmii-2500
On 12/05/2020 12:02, Jakov Petrina wrote: Commit f49ac7e1c4 switched the default PHY speed to 3.125Gbit to resolve issues with SFP modules. However, U-Boot does not have a "2500base-x" phy-mode. Resolve this by using "sgmii-2500" instead. Signed-off-by: Jakov Petrina Signed-off-by: Vladimir Vid Cc: Luka Perkov Cc: Stefan Roese --- arch/arm/dts/armada-3720-uDPU.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Hi Stefan, I'm curious if there are any feedback or blockers on this patch? Thanks, Jakov diff --git a/arch/arm/dts/armada-3720-uDPU.dts b/arch/arm/dts/armada-3720-uDPU.dts index 07c7b91175..7f4b8222f4 100644 --- a/arch/arm/dts/armada-3720-uDPU.dts +++ b/arch/arm/dts/armada-3720-uDPU.dts @@ -125,14 +125,14 @@ ð0 { pinctrl-0 = <&pcie_pins>; status = "okay"; - phy-mode = "2500base-x"; + phy-mode = "sgmii-2500"; managed = "in-band-status"; phy = <ðphy0>; }; ð1 { status = "okay"; - phy-mode = "2500base-x"; + phy-mode = "sgmii-2500"; managed = "in-band-status"; phy = <ðphy1>; }; -- Jakov Petrina
Re: rk3399: SPI boot: Return from ROM unsuccessful (with TPL)
On Wed, May 20, 2020 at 5:39 PM Jagan Teki wrote: > It seems like SPI boot on rk3399 with TPL based is unable to return > from ROM or switching to from TPL to SPL is unsuccessful. > > I have verified board_init_f on spl.c and the control is not even > reached here. On the other hand the SPL-alone boot flow works fine > from SPI. > > SPI boot log: > > U-Boot TPL 2020.07-rc2-00047-gd2ebbbd0e6,`irty (May 20 2020 - 17:22:25) > Channel 0: LPDDR4, 50MHz > BW=30 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Shze=2048LB > Channel 1: LPDR4,50MHz > BW=32 CoL=10 Bk=8 CR0 Row=15 CS1 Row=15 CS=2 Die BW=16 Cize=2048LB > 256B stride > 256B spride > lpddr4_set_rate: change freq to 4 mhz 0, 1 > lpddr4_set_rate8 changE freq to 8 mhz 0, 0 > Trying to bont from BOOTROM > Returning to boot ROM... > > Any inputs? > Hi, We have done the following changes and booted via SPI flash on roc-rk3399-pc and rockpro64-rk3399 targets. U-Boot TPL 2020.07-rc2-00204-ge74f823-dirty (May 23 2020 - 23:18:34) Channel 0: LPDDR4, 50MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: LPDDR4, 50MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride 256B stride lpddr4_set_rate: change freq to 4 mhz 0, 1 lpddr4_set_rate: change freq to 8 mhz 1, 0 spl_boot_device: Trying to boot from BOOTROM board_return_to_bootrom: Returning to boot ROM... U-Boot TPL 2020.07-rc2-00204-ge74f823-dirty (May 23 2020 - 23:18:34) sdram_init: LPDDR4 - 50MHz failed! rk3399_dmc_init DRAM init failed -22 spl_boot_device: Trying to boot from BOOTROM board_return_to_bootrom: Returning to boot ROM... for some reason, TPL loads twice. Unable to understand this behaviour. Any inputs ? diff --git a/Makefile b/Makefile index 463fa72..167de36 100644 --- a/Makefile +++ b/Makefile @@ -1439,10 +1439,10 @@ u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE ifeq ($(CONFIG_ARCH_ROCKCHIP),y) # rockchip image type -ifeq ($(CONFIG_SPL_SPI_LOAD),y) -ROCKCHIP_IMG_TYPE := rkspi -else +ifeq ($(CONFIG_SPL_MMC_SUPPORT),y) ROCKCHIP_IMG_TYPE := rksd +else +ROCKCHIP_IMG_TYPE := rkspi endif diff --git a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi index 141dd0b..a331d1a 100644 --- a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi +++ b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi @@ -11,8 +11,12 @@ spi0 = &spi1; }; + config { + u-boot,spl-payload-offset = <0x4>; /* @ 256KB */ + }; + chosen { - u-boot,spl-boot-order = "same-as-spl", &sdhci, &sdmmc; + u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdhci, &sdmmc; }; vcc_hub_en: vcc_hub_en-regulator { @@ -40,6 +44,12 @@ vin-supply = <&vcc_vbus_typec0>; }; +&spi1 { + spi_flash: flash@0 { + u-boot,dm-pre-reloc; + }; +}; + &vdd_log { regulator-min-microvolt = <43>; regulator-init-microvolt = <95>; diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig index aff690f..7ae6789 100644 --- a/configs/roc-pc-rk3399_defconfig +++ b/configs/roc-pc-rk3399_defconfig @@ -7,12 +7,15 @@ CONFIG_TARGET_ROC_PC_RK3399=y CONFIG_NR_DRAM_BANKS=1 CONFIG_DEBUG_UART_BASE=0xFF1A CONFIG_DEBUG_UART_CLOCK=2400 +CONFIG_SPL_SPI_FLASH_SUPPORT=y +CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEBUG_UART=y CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb" CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x1 +CONFIG_SPL_SPI_LOAD=y CONFIG_TPL=y CONFIG_TPL_GPIO_SUPPORT=y CONFIG_CMD_BOOTZ=y
Re: [PATCH v4] net: tftp: Add client support for RFC 7440
On Sat, May 23, 2020 at 8:40 PM Matthias Brugger wrote: ... > > I think it makes more sense to check: > if (tftp_window_size_option > 1 && tftp_state == STATE_SEND_RRQ) > > Because I understand that the tftp_state will change while the > tftp_window_size_option is set or at compile time or through the environment. > So > we can save the check of the tftp_state if we have the default value. > > Regards, > Matthias > The tftp_state can be only STATE_SEND_RRQ or STATE_SEND_WRQ and it's checked one time per transfer, it won't change in the middle of transfer. This code is run one time per transfer. Thanks, Ramon
Re: [PATCH v4] net: tftp: Add client support for RFC 7440
On 19/05/2020 21:25, Ramon Fried wrote: > Add support for RFC 7440: "TFTP Windowsize Option". > > This optional feature allows the client and server > to negotiate a window size of consecutive blocks to send as an > alternative for replacing the single-block lockstep schema. > > windowsize can be defined statically during compilation by > setting CONFIG_TFTP_WINDOWSIZE, or defined in runtime by > setting an environment variable: "tftpwindowsize" > If not defined, the windowsize is set to 1, meaning that it > behaves as it was never defined. > > Choosing the appropriate windowsize depends on the specific > network topology, underlying NIC. > You should test various windowsize scenarios and see which > best work for you. > > Setting a windowsize too big can actually decreases performance. > > Signed-off-by: Ramon Fried > Reviewed-by: Marek Vasut > --- > v2: > * Don't send windowsize option on tftpput, as it's not implemented yet. > * Don't send NACK for every out of order block that arrives, one nack >is enough. > v3: > * Add option CONFIG_TFTP_WINDOWSIZE to kconfig with default 1. > * Fixed some spelling errors. > * Took assignment out of a loop. > * simplified variable increment. > v4: > * send ack for last packet, so the server can finish >the tranfer gracefully and not in timeout. > > README | 5 > net/Kconfig | 9 ++ > net/tftp.c | 81 +++-- > 3 files changed, 87 insertions(+), 8 deletions(-) > > diff --git a/README b/README > index be9e6391d6..686474a2f1 100644 > --- a/README > +++ b/README > @@ -3522,6 +3522,11 @@ List of environment variables (most likely not > complete): > downloads succeed with high packet loss rates, or with > unreliable TFTP servers or client hardware. > > + tftpwindowsize - if this is set, the value is used for TFTP's > + window size as described by RFC 7440. > + This means the count of blocks we can receive before > + sending ack to server. > + >vlan - When set to a value < 4095 the traffic over > Ethernet is encapsulated/received over 802.1q > VLAN tagged frames. > diff --git a/net/Kconfig b/net/Kconfig > index ac6d0cf8a6..7916ae305f 100644 > --- a/net/Kconfig > +++ b/net/Kconfig > @@ -49,4 +49,13 @@ config TFTP_BLOCKSIZE > almost-MTU block sizes. > You can also activate CONFIG_IP_DEFRAG to set a larger block. > > +config TFTP_WINDOWSIZE > + int "TFTP window size" > + default 1 > + help > + Default TFTP window size. > + RFC7440 defines an optional window size of transmits, > + before an ack response is required. > + The default TFTP implementation implies a window size of 1. > + > endif # if NET > diff --git a/net/tftp.c b/net/tftp.c > index be24e63075..72d23e1574 100644 > --- a/net/tftp.c > +++ b/net/tftp.c > @@ -5,7 +5,6 @@ > * Copyright 2011 Comelit Group SpA, > *Luca Ceresoli > */ > - > #include > #include > #include > @@ -95,6 +94,12 @@ static int tftp_tsize; > /* The number of hashes we printed */ > static short tftp_tsize_num_hash; > #endif > +/* The window size negotiated */ > +static ushorttftp_windowsize; > +/* Next block to send ack to */ > +static ushorttftp_next_ack; > +/* Last nack block we send */ > +static ushorttftp_last_nack; > #ifdef CONFIG_CMD_TFTPPUT > /* 1 if writing, else 0 */ > static int tftp_put_active; > @@ -134,8 +139,19 @@ static char tftp_filename[MAX_LEN]; > * (but those using CONFIG_IP_DEFRAG may want to set a larger block in cfg > file) > */ > > +/* When windowsize is defined to 1, > + * tftp behaves the same way as it was > + * never declared > + */ > +#ifdef CONFIG_TFTP_WINDOWSIZE > +#define TFTP_WINDOWSIZE CONFIG_TFTP_WINDOWSIZE > +#else > +#define TFTP_WINDOWSIZE 1 > +#endif > + > static unsigned short tftp_block_size = TFTP_BLOCK_SIZE; > static unsigned short tftp_block_size_option = CONFIG_TFTP_BLOCKSIZE; > +static unsigned short tftp_window_size_option = TFTP_WINDOWSIZE; > > static inline int store_block(int block, uchar *src, unsigned int len) > { > @@ -348,6 +364,14 @@ static void tftp_send(void) > /* try for more effic. blk size */ > pkt += sprintf((char *)pkt, "blksize%c%d%c", > 0, tftp_block_size_option, 0); > + > + /* try for more effic. window size. > + * Implemented only for tftp get. > + * Don't bother sending if it's 1 > + */ > + if (tftp_state == STATE_SEND_RRQ && tftp_window_size_option > 1) I think it makes more sense to check: if (tftp_window_size_option > 1 && tftp_state == STATE_SEND_RRQ) Because I understand that the tftp_state will change while the tftp_window_size_option is set or at compile time or through the environment. So we can save the check
Re: [PATCH 30/30] net: eepro100: Add Kconfig entries
On Sat, May 23, 2020 at 7:45 PM Marek Vasut wrote: > > Add Kconfig entries for the eepro100 driver and convert various boards. > > Signed-off-by: Marek Vasut > --- > README | 3 --- > configs/MPC8315ERDB_defconfig | 1 + > configs/TQM834x_defconfig | 1 + > configs/integratorap_cm720t_defconfig | 1 + > configs/integratorap_cm920t_defconfig | 1 + > configs/integratorap_cm926ejs_defconfig | 1 + > configs/integratorap_cm946es_defconfig | 1 + > drivers/net/Kconfig | 6 ++ > include/configs/MPC8315ERDB.h | 1 - > include/configs/MPC8323ERDB.h | 1 - > include/configs/MPC832XEMDS.h | 1 - > include/configs/MPC8349EMDS.h | 1 - > include/configs/MPC8349EMDS_SDRAM.h | 1 - > include/configs/MPC837XEMDS.h | 1 - > include/configs/MPC8536DS.h | 1 - > include/configs/MPC8540ADS.h| 1 - > include/configs/MPC8541CDS.h| 1 - > include/configs/MPC8544DS.h | 1 - > include/configs/MPC8548CDS.h| 1 - > include/configs/MPC8555CDS.h| 1 - > include/configs/MPC8560ADS.h| 1 - > include/configs/MPC8568MDS.h| 1 - > include/configs/MPC8569MDS.h| 1 - > include/configs/MPC8572DS.h | 1 - > include/configs/MPC8641HPCN.h | 1 - > include/configs/TQM834x.h | 2 -- > include/configs/caddy2.h| 1 - > include/configs/integratorap.h | 1 - > include/configs/sbc8349.h | 1 - > include/configs/sbc8548.h | 1 - > include/configs/sbc8641d.h | 1 - > include/configs/vme8349.h | 1 - > scripts/config_whitelist.txt| 1 - > 33 files changed, 12 insertions(+), 29 deletions(-) > > diff --git a/README b/README > index c4bb6f3e7b..0e48c2aa7c 100644 > --- a/README > +++ b/README > @@ -889,9 +889,6 @@ The following options need to be configured: > Allow generic access to the SPI bus on the Intel 8257x, for > example with the "sspi" command. > > - CONFIG_EEPRO100 > - Support for Intel 82557/82559/82559ER chips. > - > CONFIG_TULIP > Support for Digital 2114x chips. > > diff --git a/configs/MPC8315ERDB_defconfig b/configs/MPC8315ERDB_defconfig > index bbb79dff2e..d7981e9855 100644 > --- a/configs/MPC8315ERDB_defconfig > +++ b/configs/MPC8315ERDB_defconfig > @@ -147,6 +147,7 @@ CONFIG_PHY_NATSEMI=y > CONFIG_PHY_REALTEK=y > CONFIG_PHY_SMSC=y > CONFIG_PHY_VITESSE=y > +CONFIG_EEPRO100=y > CONFIG_MII=y > CONFIG_TSEC_ENET=y > CONFIG_SYS_NS16550=y > diff --git a/configs/TQM834x_defconfig b/configs/TQM834x_defconfig > index 96ce4de0e6..c29d8a8be1 100644 > --- a/configs/TQM834x_defconfig > +++ b/configs/TQM834x_defconfig > @@ -159,6 +159,7 @@ CONFIG_PHY_NATSEMI=y > CONFIG_PHY_REALTEK=y > CONFIG_PHY_SMSC=y > CONFIG_PHY_VITESSE=y > +CONFIG_EEPRO100=y > CONFIG_MII=y > CONFIG_TSEC_ENET=y > CONFIG_SYS_NS16550=y > diff --git a/configs/integratorap_cm720t_defconfig > b/configs/integratorap_cm720t_defconfig > index f5f9cb28b3..1b7d672bcb 100644 > --- a/configs/integratorap_cm720t_defconfig > +++ b/configs/integratorap_cm720t_defconfig > @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y > CONFIG_FLASH_CFI_DRIVER=y > CONFIG_SYS_FLASH_PROTECTION=y > CONFIG_SYS_FLASH_CFI=y > +CONFIG_EEPRO100=y > CONFIG_PCI=y > CONFIG_BAUDRATE=38400 > CONFIG_OF_LIBFDT=y > diff --git a/configs/integratorap_cm920t_defconfig > b/configs/integratorap_cm920t_defconfig > index 8a0ad1f948..116ac015a0 100644 > --- a/configs/integratorap_cm920t_defconfig > +++ b/configs/integratorap_cm920t_defconfig > @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y > CONFIG_FLASH_CFI_DRIVER=y > CONFIG_SYS_FLASH_PROTECTION=y > CONFIG_SYS_FLASH_CFI=y > +CONFIG_EEPRO100=y > CONFIG_PCI=y > CONFIG_BAUDRATE=38400 > CONFIG_OF_LIBFDT=y > diff --git a/configs/integratorap_cm926ejs_defconfig > b/configs/integratorap_cm926ejs_defconfig > index ab61bf2ef4..9c1a3fa2f5 100644 > --- a/configs/integratorap_cm926ejs_defconfig > +++ b/configs/integratorap_cm926ejs_defconfig > @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y > CONFIG_FLASH_CFI_DRIVER=y > CONFIG_SYS_FLASH_PROTECTION=y > CONFIG_SYS_FLASH_CFI=y > +CONFIG_EEPRO100=y > CONFIG_PCI=y > CONFIG_BAUDRATE=38400 > CONFIG_OF_LIBFDT=y > diff --git a/configs/integratorap_cm946es_defconfig > b/configs/integratorap_cm946es_defconfig > index 7af5433161..ee9c69bce0 100644 > --- a/configs/integratorap_cm946es_defconfig > +++ b/configs/integratorap_cm946es_defconfig > @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y > CONFIG_FLASH_CFI_DRIVER=y > CONFIG_SYS_FLASH_PROTECTION=y > CONFIG_SYS_FLASH_CFI=y > +CONFIG_EEPRO100=y > CONFIG_PCI=y > CONFIG_BAUDRATE=38400 > CONFIG_OF_LIBFDT=y > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index f7855c92d3..c3e4510fa1 100644 > --- a/drivers/net/Kconfig > +++ b/driver
Re: [PATCH 29/30] net: eepro100: Add DM support
On Sat, May 23, 2020 at 7:45 PM Marek Vasut wrote: > > Add support for driver model to the driver. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 129 - > 1 file changed, 128 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index f474832552..45ea3b70fc 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -206,14 +206,21 @@ struct eepro100_priv { > /* TX descriptor ring pointer */ > int tx_next; > int tx_threshold; > +#ifdef CONFIG_DM_ETH > + struct udevice *devno; > +#else > struct eth_device dev; > pci_dev_t devno; > +#endif > char*name; > void __iomem*iobase; > u8 *enetaddr; > }; > > -#if defined(CONFIG_E500) > +#if defined(CONFIG_DM_ETH) > +#define bus_to_phys(dev, a)dm_pci_mem_to_phys((dev), (a)) > +#define phys_to_bus(dev, a)dm_pci_phys_to_mem((dev), (a)) > +#elif defined(CONFIG_E500) > #define bus_to_phys(dev, a)(a) > #define phys_to_bus(dev, a)(a) > #else > @@ -771,6 +778,7 @@ done: > return; > } > > +#ifndef CONFIG_DM_ETH > static int eepro100_init(struct eth_device *dev, bd_t *bis) > { > struct eepro100_priv *priv = > @@ -888,3 +896,122 @@ int eepro100_initialize(bd_t *bis) > > return card_number; > } > + > +#else /* DM_ETH */ > +static int eepro100_start(struct udevice *dev) > +{ > + struct eth_pdata *plat = dev_get_platdata(dev); > + struct eepro100_priv *priv = dev_get_priv(dev); > + > + memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); > + > + return eepro100_init_common(priv); > +} > + > +static void eepro100_stop(struct udevice *dev) > +{ > + struct eepro100_priv *priv = dev_get_priv(dev); > + > + eepro100_halt_common(priv); > +} > + > +static int eepro100_send(struct udevice *dev, void *packet, int length) > +{ > + struct eepro100_priv *priv = dev_get_priv(dev); > + int ret; > + > + ret = eepro100_send_common(priv, packet, length); > + > + return ret ? 0 : -ETIMEDOUT; > +} > + > +static int eepro100_recv(struct udevice *dev, int flags, uchar **packetp) > +{ > + struct eepro100_priv *priv = dev_get_priv(dev); > + > + return eepro100_recv_common(priv, packetp); > +} > + > +static int eepro100_free_pkt(struct udevice *dev, uchar *packet, int length) > +{ > + struct eepro100_priv *priv = dev_get_priv(dev); > + > + eepro100_free_pkt_common(priv); > + > + return 0; > +} > + > +static int eepro100_read_rom_hwaddr(struct udevice *dev) > +{ > + struct eepro100_priv *priv = dev_get_priv(dev); > + > + eepro100_get_hwaddr(priv); > + > + return 0; > +} > + > +static int eepro100_bind(struct udevice *dev) > +{ > + static int card_number; > + char name[16]; > + > + sprintf(name, "eepro100#%u", card_number++); > + > + return device_set_name(dev, name); > +} > + > +static int eepro100_probe(struct udevice *dev) > +{ > + struct eth_pdata *plat = dev_get_platdata(dev); > + struct eepro100_priv *priv = dev_get_priv(dev); > + u16 command, status; > + u32 iobase; > + int ret; > + > + dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase); > + iobase &= ~0xf; > + > + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase); > + > + priv->devno = dev; > + priv->enetaddr = plat->enetaddr; > + priv->iobase = (void __iomem *)bus_to_phys(dev, iobase); > + > + command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; > + dm_pci_write_config16(dev, PCI_COMMAND, command); > + dm_pci_read_config16(dev, PCI_COMMAND, &status); > + if ((status & command) != command) { > + printf("eepro100: Couldn't enable IO access or Bus > Mastering\n"); > + return -EINVAL; > + } > + > + ret = eepro100_initialize_mii(priv); > + if (ret) > + return ret; > + > + dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x20); > + > + return 0; > +} > + > +static const struct eth_ops eepro100_ops = { > + .start = eepro100_start, > + .send = eepro100_send, > + .recv = eepro100_recv, > + .stop = eepro100_stop, > + .free_pkt = eepro100_free_pkt, > + .read_rom_hwaddr = eepro100_read_rom_hwaddr, > +}; > + > +U_BOOT_DRIVER(eth_eepro100) = { > + .name = "eth_eepro100", > + .id = UCLASS_ETH, > + .bind = eepro100_bind, > + .probe = eepro100_probe, > + .ops= &eepro100_ops, > + .priv_auto_alloc_size = sizeof(struct eepro100_priv), > + .platdata_auto_alloc_size = sizeof(struct eth_pdata), > +}; > + > +U_BOOT_PCI_DEVICE(eth_eepro100, supported); > +#endif > -- > 2.25
Re: [PATCH 24/30] net: eepro100: Pass device private data around
On Sat, May 23, 2020 at 7:45 PM Marek Vasut wrote: > > This patch replaces the various uses of struct eth_device for accessing > device private data with struct eepro100_priv, which is compatible both > with DM and non-DM operation. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 264 ++--- > 1 file changed, 140 insertions(+), 124 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 2c25307002..1c33ec3da2 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -203,6 +203,10 @@ static const char i82558_config_cmd[] = { > > struct eepro100_priv { > struct eth_device dev; > + pci_dev_t devno; > + char*name; > + void __iomem*iobase; > + u8 *enetaddr; > }; > > #if defined(CONFIG_E500) > @@ -213,40 +217,40 @@ struct eepro100_priv { > #define phys_to_bus(dev, a)pci_phys_to_mem((dev), (a)) > #endif > > -static int INW(struct eth_device *dev, u_long addr) > +static int INW(struct eepro100_priv *priv, u_long addr) > { > - return le16_to_cpu(readw(addr + (void *)dev->iobase)); > + return le16_to_cpu(readw(addr + priv->iobase)); > } > > -static void OUTW(struct eth_device *dev, int command, u_long addr) > +static void OUTW(struct eepro100_priv *priv, int command, u_long addr) > { > - writew(cpu_to_le16(command), addr + (void *)dev->iobase); > + writew(cpu_to_le16(command), addr + priv->iobase); > } > > -static void OUTL(struct eth_device *dev, int command, u_long addr) > +static void OUTL(struct eepro100_priv *priv, int command, u_long addr) > { > - writel(cpu_to_le32(command), addr + (void *)dev->iobase); > + writel(cpu_to_le32(command), addr + priv->iobase); > } > > #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > -static int INL(struct eth_device *dev, u_long addr) > +static int INL(struct eepro100_priv *priv, u_long addr) > { > - return le32_to_cpu(readl(addr + (void *)dev->iobase)); > + return le32_to_cpu(readl(addr + priv->iobase)); > } > > -static int get_phyreg(struct eth_device *dev, unsigned char addr, > +static int get_phyreg(struct eepro100_priv *priv, unsigned char addr, > unsigned char reg, unsigned short *value) > { > - int cmd; > int timeout = 50; > + int cmd; > > /* read requested data */ > cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); > - OUTL(dev, cmd, SCB_CTRL_MDI); > + OUTL(priv, cmd, SCB_CTRL_MDI); > > do { > udelay(1000); > - cmd = INL(dev, SCB_CTRL_MDI); > + cmd = INL(priv, SCB_CTRL_MDI); > } while (!(cmd & (1 << 28)) && (--timeout)); > > if (timeout == 0) > @@ -257,17 +261,17 @@ static int get_phyreg(struct eth_device *dev, unsigned > char addr, > return 0; > } > > -static int set_phyreg(struct eth_device *dev, unsigned char addr, > +static int set_phyreg(struct eepro100_priv *priv, unsigned char addr, > unsigned char reg, unsigned short value) > { > - int cmd; > int timeout = 50; > + int cmd; > > /* write requested data */ > cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); > - OUTL(dev, cmd | value, SCB_CTRL_MDI); > + OUTL(priv, cmd | value, SCB_CTRL_MDI); > > - while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) > + while (!(INL(priv, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) > udelay(1000); > > if (timeout == 0) > @@ -280,49 +284,45 @@ static int set_phyreg(struct eth_device *dev, unsigned > char addr, > * Check if given phyaddr is valid, i.e. there is a PHY connected. > * Do this by checking model value field from ID2 register. > */ > -static struct eth_device *verify_phyaddr(const char *devname, > -unsigned char addr) > +static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr) > { > - struct eth_device *dev; > - unsigned short value; > - unsigned char model; > - > - dev = eth_get_dev_by_name(devname); > - if (!dev) { > - printf("%s: no such device\n", devname); > - return NULL; > - } > + unsigned short value, model; > + int ret; > > /* read id2 register */ > - if (get_phyreg(dev, addr, MII_PHYSID2, &value) != 0) { > - printf("%s: mii read timeout!\n", devname); > - return NULL; > + ret = get_phyreg(priv, addr, MII_PHYSID2, &value); > + if (ret) { > + printf("%s: mii read timeout!\n", priv->name); > + return ret; > } > > /* get model */ > - model = (unsigned char)((value >> 4) & 0x003f); > - > - if (model == 0) { > - printf("%s: no PHY at address %d\n", devnam
Re: [PATCH 28/30] net: eepro100: Split common parts of non-DM functions out
On Sat, May 23, 2020 at 7:45 PM Marek Vasut wrote: > > Split the common code from the non-DM code, so it can be reused by > the DM code later. As always, the recv() function had to be split > into the actual receiving part and free_pkt part to fit with the > DM. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 162 + > 1 file changed, 100 insertions(+), 62 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index fb8a68f84c..f474832552 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -202,6 +202,7 @@ struct eepro100_priv { > struct eepro100_txfdtx_ring[NUM_TX_DESC]; > /* RX descriptor ring pointer */ > int rx_next; > + u16 rx_stat; > /* TX descriptor ring pointer */ > int tx_next; > int tx_threshold; > @@ -535,10 +536,8 @@ static void eepro100_get_hwaddr(struct eepro100_priv > *priv) > } > } > > -static int eepro100_init(struct eth_device *dev, bd_t *bis) > +static int eepro100_init_common(struct eepro100_priv *priv) > { > - struct eepro100_priv *priv = > - container_of(dev, struct eepro100_priv, dev); > struct eepro100_rxfd *rx_ring = priv->rx_ring; > struct eepro100_txfd *tx_ring = priv->tx_ring; > struct eepro100_txfd *ias_cmd, *cfg_cmd; > @@ -628,10 +627,9 @@ done: > return status; > } > > -static int eepro100_send(struct eth_device *dev, void *packet, int length) > +static int eepro100_send_common(struct eepro100_priv *priv, > + void *packet, int length) > { > - struct eepro100_priv *priv = > - container_of(dev, struct eepro100_priv, dev); > struct eepro100_txfd *tx_ring = priv->tx_ring; > struct eepro100_txfd *desc; > int ret, status = -1; > @@ -672,82 +670,82 @@ done: > return status; > } > > -static int eepro100_recv(struct eth_device *dev) > +static int eepro100_recv_common(struct eepro100_priv *priv, uchar **packetp) > { > - struct eepro100_priv *priv = > - container_of(dev, struct eepro100_priv, dev); > struct eepro100_rxfd *rx_ring = priv->rx_ring; > struct eepro100_rxfd *desc; > - int rx_prev, length = 0; > - u16 status, stat; > + int length; > + u16 status; > > - stat = INW(priv, SCB_STATUS); > - OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS); > + priv->rx_stat = INW(priv, SCB_STATUS); > + OUTW(priv, priv->rx_stat & SCB_STATUS_RNR, SCB_STATUS); > > - for (;;) { > - desc = &rx_ring[priv->rx_next]; > - invalidate_dcache_range((unsigned long)desc, > - (unsigned long)desc + sizeof(*desc)); > - status = le16_to_cpu(desc->status); > + desc = &rx_ring[priv->rx_next]; > + invalidate_dcache_range((unsigned long)desc, > + (unsigned long)desc + sizeof(*desc)); > + status = le16_to_cpu(desc->status); > + > + if (!(status & RFD_STATUS_C)) > + return 0; > + > + /* Valid frame status. */ > + if (status & RFD_STATUS_OK) { > + /* A valid frame received. */ > + length = le32_to_cpu(desc->count) & 0x3fff; > + /* Pass the packet up to the protocol layers. */ > + *packetp = desc->data; > + return length; > + } > > - if (!(status & RFD_STATUS_C)) > - break; > + /* There was an error. */ > + printf("RX error status = 0x%08X\n", status); > + return -EINVAL; > +} > > - /* Valid frame status. */ > - if ((status & RFD_STATUS_OK)) { > - /* A valid frame received. */ > - length = le32_to_cpu(desc->count) & 0x3fff; > +static void eepro100_free_pkt_common(struct eepro100_priv *priv) > +{ > + struct eepro100_rxfd *rx_ring = priv->rx_ring; > + struct eepro100_rxfd *desc; > + int rx_prev; > > - /* Pass the packet up to the protocol layers. */ > - net_process_received_packet((u8 *)desc->data, length); > - } else { > - /* There was an error. */ > - printf("RX error status = 0x%08X\n", status); > - } > + desc = &rx_ring[priv->rx_next]; > > - desc->control = cpu_to_le16(RFD_CONTROL_S); > - desc->status = 0; > - desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16); > - flush_dcache_range((unsigned long)desc, > - (unsigned long)desc + sizeof(*desc)); > + desc->control = cpu_to_le16(RFD_CONTROL_S); > + desc->status = 0; > + desc->count = cpu_to_le32(PKTSIZE_ALIGN
Re: [PATCH 27/30] net: eepro100: Drop bd_t pointer from read_hw_addr()
On Sat, May 23, 2020 at 7:44 PM Marek Vasut wrote: > > The pointer is unused, so drop it. Rename the function to start > with the eepro100_ prefix. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index ed6bbd5cf8..fb8a68f84c 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -512,7 +512,7 @@ static struct pci_device_id supported[] = { > { } > }; > > -static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis) > +static void eepro100_get_hwaddr(struct eepro100_priv *priv) > { > u16 sum = 0; > int i, j; > @@ -845,7 +845,7 @@ int eepro100_initialize(bd_t *bis) > > udelay(10 * 1000); > > - read_hw_addr(priv, bis); > + eepro100_get_hwaddr(priv); > } > > return card_number; > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 25/30] net: eepro100: Pass device private data into mdiobus
On Sat, May 23, 2020 at 7:44 PM Marek Vasut wrote: > > Instead of doing ethernet device lookup by name every time there > is an MDIO access, pass the driver private data via mdiobus priv > to the MDIO bus accessors. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 9 +++-- > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 1c33ec3da2..78dedbdcc9 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, > unsigned char addr) > static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, > int reg) > { > - struct eth_device *dev = eth_get_dev_by_name(bus->name); > - struct eepro100_priv *priv = > - container_of(dev, struct eepro100_priv, dev); > + struct eepro100_priv *priv = bus->priv; > unsigned short value = 0; > int ret; > > @@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int > addr, int devad, > static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, > int reg, u16 value) > { > - struct eth_device *dev = eth_get_dev_by_name(bus->name); > - struct eepro100_priv *priv = > - container_of(dev, struct eepro100_priv, dev); > + struct eepro100_priv *priv = bus->priv; > int ret; > > ret = verify_phyaddr(priv, addr); > @@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv > *priv) > strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN); > mdiodev->read = eepro100_miiphy_read; > mdiodev->write = eepro100_miiphy_write; > + mdiodev->priv = priv; > > ret = mdio_register(mdiodev); > if (ret < 0) { > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 26/30] net: eepro100: Add RX/TX rings into the private data
On Sat, May 23, 2020 at 7:44 PM Marek Vasut wrote: > > The RX/TX DMA descriptor rings are per-device-instance private data, > so move them into the private data. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 59 +- > 1 file changed, 35 insertions(+), 24 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 78dedbdcc9..ed6bbd5cf8 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -183,12 +183,6 @@ struct descriptor {/* A generic > descriptor. */ > > #define TOUT_LOOP 100 > > -static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */ > -static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */ > -static int rx_next;/* RX descriptor ring pointer */ > -static int tx_next;/* TX descriptor ring pointer */ > -static int tx_threshold; > - > /* > * The parameters for a CmdConfigure operation. > * There are so many options that it would be difficult to document > @@ -202,6 +196,15 @@ static const char i82558_config_cmd[] = { > }; > > struct eepro100_priv { > + /* RX descriptor ring */ > + struct eepro100_rxfdrx_ring[NUM_RX_DESC]; > + /* TX descriptor ring */ > + struct eepro100_txfdtx_ring[NUM_TX_DESC]; > + /* RX descriptor ring pointer */ > + int rx_next; > + /* TX descriptor ring pointer */ > + int tx_next; > + int tx_threshold; > struct eth_device dev; > pci_dev_t devno; > char*name; > @@ -348,6 +351,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int > addr, int devad, > > static void init_rx_ring(struct eepro100_priv *priv) > { > + struct eepro100_rxfd *rx_ring = priv->rx_ring; > int i; > > for (i = 0; i < NUM_RX_DESC; i++) { > @@ -366,13 +370,15 @@ static void init_rx_ring(struct eepro100_priv *priv) >(unsigned long)rx_ring + >(sizeof(*rx_ring) * NUM_RX_DESC)); > > - rx_next = 0; > + priv->rx_next = 0; > } > > static void purge_tx_ring(struct eepro100_priv *priv) > { > - tx_next = 0; > - tx_threshold = 0x01208000; > + struct eepro100_txfd *tx_ring = priv->tx_ring; > + > + priv->tx_next = 0; > + priv->tx_threshold = 0x01208000; > memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); > > flush_dcache_range((unsigned long)tx_ring, > @@ -533,6 +539,8 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > { > struct eepro100_priv *priv = > container_of(dev, struct eepro100_priv, dev); > + struct eepro100_rxfd *rx_ring = priv->rx_ring; > + struct eepro100_txfd *tx_ring = priv->tx_ring; > struct eepro100_txfd *ias_cmd, *cfg_cmd; > int ret, status = -1; > int tx_cur; > @@ -569,20 +577,20 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > } > > /* RX ring cache was already flushed in init_rx_ring() */ > - OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]), > + OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[priv->rx_next]), > SCB_POINTER); > OUTW(priv, SCB_M | RUC_START, SCB_CMD); > > /* Send the Configure frame */ > - tx_cur = tx_next; > - tx_next = ((tx_next + 1) % NUM_TX_DESC); > + tx_cur = priv->tx_next; > + priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC); > > cfg_cmd = &tx_ring[tx_cur]; > cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | >CONFIG_SYS_CMD_CONFIGURE); > cfg_cmd->status = 0; > cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, > - (u32)&tx_ring[tx_next])); > + > (u32)&tx_ring[priv->tx_next])); > > memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, >sizeof(i82558_config_cmd)); > @@ -595,15 +603,15 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > } > > /* Send the Individual Address Setup frame */ > - tx_cur = tx_next; > - tx_next = ((tx_next + 1) % NUM_TX_DESC); > + tx_cur = priv->tx_next; > + priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC); > > ias_cmd = &tx_ring[tx_cur]; > ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | >CONFIG_SYS_CMD_IAS); > ias_cmd->status = 0; > ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, > - (u32)&tx_ring[tx_next])); > + > (u32)&tx_ring[priv->tx_next])); > > memcpy(((struct descrip
Re: [PATCH 20/30] net: eepro100: Fix EE_*_CMD macros
On Sat, May 23, 2020 at 7:44 PM Marek Vasut wrote: > > Those macros depended on specific variable names to be declared > at their usage sites, fix this by adding an argument to those > macros and also protect the argument with braces. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 861d39cf9f..a8d617c7e8 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -96,10 +96,10 @@ > #define EE_DATA_BITS 16 > > /* The EEPROM commands include the alway-set leading bit. */ > -#define EE_EWENB_CMD (4 << addr_len) > -#define EE_WRITE_CMD (5 << addr_len) > -#define EE_READ_CMD(6 << addr_len) > -#define EE_ERASE_CMD (7 << addr_len) > +#define EE_EWENB_CMD(addr_len) (4 << (addr_len)) > +#define EE_WRITE_CMD(addr_len) (5 << (addr_len)) > +#define EE_READ_CMD(addr_len) (6 << (addr_len)) > +#define EE_ERASE_CMD(addr_len) (7 << (addr_len)) > > /* Receive frame descriptors. */ > struct eepro100_rxfd { > @@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, > static int read_eeprom(struct eth_device *dev, int location, int addr_len) > { > unsigned short retval = 0; > - int read_cmd = location | EE_READ_CMD; > + int read_cmd = location | EE_READ_CMD(addr_len); > int i; > > OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 23/30] net: eepro100: Introduce device private data
On Sat, May 23, 2020 at 7:44 PM Marek Vasut wrote: > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 12 +--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 532d7aa649..2c25307002 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -201,6 +201,10 @@ static const char i82558_config_cmd[] = { > 0x31, 0x05, > }; > > +struct eepro100_priv { > + struct eth_device dev; > +}; > + > #if defined(CONFIG_E500) > #define bus_to_phys(dev, a)(a) > #define phys_to_bus(dev, a)(a) > @@ -751,6 +755,7 @@ done: > > int eepro100_initialize(bd_t *bis) > { > + struct eepro100_priv *priv; > struct eth_device *dev; > int card_number = 0; > u32 iobase, status; > @@ -785,11 +790,12 @@ int eepro100_initialize(bd_t *bis) > continue; > } > > - dev = calloc(1, sizeof(*dev)); > - if (!dev) { > + priv = calloc(1, sizeof(*priv)); > + if (!priv) { > printf("eepro100: Can not allocate memory\n"); > break; > } > + dev = &priv->dev; > > sprintf(dev->name, "i82559#%d", card_number); > dev->priv = (void *)devno; /* this have to come before > bus_to_phys() */ > @@ -804,7 +810,7 @@ int eepro100_initialize(bd_t *bis) > ret = eepro100_initialize_mii(dev); > if (ret) { > eth_unregister(dev); > - free(dev); > + free(priv); > return ret; > } > > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 19/30] net: eepro100: Factor out MII registration
On Sat, May 23, 2020 at 7:43 PM Marek Vasut wrote: > > Pull the MII registration code into a separate function. Moreover, > properly free memory in case any of the registration or allocation > functions fail, so this fixes an existing memleak. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 56 +- > 1 file changed, 39 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 8fa665743a..861d39cf9f 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -464,6 +464,36 @@ static int read_eeprom(struct eth_device *dev, int > location, int addr_len) > return retval; > } > > +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > +static int eepro100_initialize_mii(struct eth_device *dev) > +{ > + /* register mii command access routines */ > + struct mii_dev *mdiodev; > + int ret; > + > + mdiodev = mdio_alloc(); > + if (!mdiodev) > + return -ENOMEM; > + > + strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); > + mdiodev->read = eepro100_miiphy_read; > + mdiodev->write = eepro100_miiphy_write; > + > + ret = mdio_register(mdiodev); > + if (ret < 0) { > + mdio_free(mdiodev); > + return ret; > + } > + > + return 0; > +} > +#else > +static int eepro100_initialize_mii(struct eth_device *dev) > +{ > + return 0; > +} > +#endif > + > static struct pci_device_id supported[] = { > { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) }, > { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) }, > @@ -713,11 +743,12 @@ done: > > int eepro100_initialize(bd_t *bis) > { > - pci_dev_t devno; > - int card_number = 0; > struct eth_device *dev; > + int card_number = 0; > u32 iobase, status; > + pci_dev_t devno; > int idx = 0; > + int ret; > > while (1) { > /* Find PCI device */ > @@ -762,21 +793,12 @@ int eepro100_initialize(bd_t *bis) > > eth_register(dev); > > -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > - /* register mii command access routines */ > - int retval; > - struct mii_dev *mdiodev = mdio_alloc(); > - > - if (!mdiodev) > - return -ENOMEM; > - strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); > - mdiodev->read = eepro100_miiphy_read; > - mdiodev->write = eepro100_miiphy_write; > - > - retval = mdio_register(mdiodev); > - if (retval < 0) > - return retval; > -#endif > + ret = eepro100_initialize_mii(dev); > + if (ret) { > + eth_unregister(dev); > + free(dev); > + return ret; > + } > > card_number++; > > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 22/30] net: eepro100: Pass PCI BDF into bus_to_phys()/phys_to_bus()
On Sat, May 23, 2020 at 7:43 PM Marek Vasut wrote: > > This is a trick in preparation for adding DM support. By passing in > the PCI BDF into the bus_to_phys()/phys_to_bus() macros and calling > that dev, we can substitute dev with udevice when DM support lands > and do minor adjustment to the macros to support both DM and non-DM > operation. No functional change. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 36 ++-- > 1 file changed, 22 insertions(+), 14 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 4446251e11..532d7aa649 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -202,11 +202,11 @@ static const char i82558_config_cmd[] = { > }; > > #if defined(CONFIG_E500) > -#define bus_to_phys(a) (a) > -#define phys_to_bus(a) (a) > +#define bus_to_phys(dev, a)(a) > +#define phys_to_bus(dev, a)(a) > #else > -#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a) > -#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) > +#define bus_to_phys(dev, a)pci_mem_to_phys((dev), (a)) > +#define phys_to_bus(dev, a)pci_phys_to_mem((dev), (a)) > #endif > > static int INW(struct eth_device *dev, u_long addr) > @@ -352,7 +352,8 @@ static void init_rx_ring(struct eth_device *dev) > rx_ring[i].control = (i == NUM_RX_DESC - 1) ? > cpu_to_le16 (RFD_CONTROL_S) : 0; > rx_ring[i].link = > - cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % > + cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, > + (u32)&rx_ring[(i + 1) % > NUM_RX_DESC])); > rx_ring[i].rx_buf_addr = 0x; > rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); > @@ -401,7 +402,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, > if (!wait_for_eepro100(dev)) > return -ETIMEDOUT; > > - OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER); > + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)desc), SCB_POINTER); > OUTW(dev, SCB_M | CU_START, SCB_CMD); > > while (true) { > @@ -562,7 +563,8 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > } > > /* RX ring cache was already flushed in init_rx_ring() */ > - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); > + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)&rx_ring[rx_next]), > +SCB_POINTER); > OUTW(dev, SCB_M | RUC_START, SCB_CMD); > > /* Send the Configure frame */ > @@ -573,7 +575,8 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | >CONFIG_SYS_CMD_CONFIGURE); > cfg_cmd->status = 0; > - cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > + cfg_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, > + (u32)&tx_ring[tx_next])); > > memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, >sizeof(i82558_config_cmd)); > @@ -593,7 +596,8 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | >CONFIG_SYS_CMD_IAS); > ias_cmd->status = 0; > - ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > + ias_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, > + (u32)&tx_ring[tx_next])); > > memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6); > > @@ -629,9 +633,12 @@ static int eepro100_send(struct eth_device *dev, void > *packet, int length) > TXCB_CMD_S | TXCB_CMD_EL); > desc->status = 0; > desc->count = cpu_to_le32(tx_threshold); > - desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > - desc->tx_desc_addr = > cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0)); > - desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet)); > + desc->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, > + (u32)&tx_ring[tx_next])); > + desc->tx_desc_addr = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, > + > (u32)&desc->tx_buf_addr0)); > + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, > +(u_long)packet)); > desc->tx_buf_size0 = cpu_to_le32(length); > > ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); > @@ -706,7 +713,8 @@ static int eepro100_recv(struct eth_device *dev) >
Re: [PATCH 21/30] net: eepro100: Drop inline keyword
On Sat, May 23, 2020 at 7:43 PM Marek Vasut wrote: > > Drop the inline keyword from the static functions, the compiler has a > much better overview and can decide how to inline those functions much > better. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index a8d617c7e8..4446251e11 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -209,23 +209,23 @@ static const char i82558_config_cmd[] = { > #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) > #endif > > -static inline int INW(struct eth_device *dev, u_long addr) > +static int INW(struct eth_device *dev, u_long addr) > { > return le16_to_cpu(readw(addr + (void *)dev->iobase)); > } > > -static inline void OUTW(struct eth_device *dev, int command, u_long addr) > +static void OUTW(struct eth_device *dev, int command, u_long addr) > { > writew(cpu_to_le16(command), addr + (void *)dev->iobase); > } > > -static inline void OUTL(struct eth_device *dev, int command, u_long addr) > +static void OUTL(struct eth_device *dev, int command, u_long addr) > { > writel(cpu_to_le32(command), addr + (void *)dev->iobase); > } > > #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > -static inline int INL(struct eth_device *dev, u_long addr) > +static int INL(struct eth_device *dev, u_long addr) > { > return le32_to_cpu(readl(addr + (void *)dev->iobase)); > } > -- > 2.25.1 > Actually, AFAIK even if inline is used the compiled is free to do whatever he wants, this is only a suggestion, there's a GCC property named always_inline which forces the compiler to inline.
Re: [PATCH 17/30] net: eepro100: Use PCI_DEVICE() to define PCI device compat list
On Sat, May 23, 2020 at 7:43 PM Marek Vasut wrote: > > Use this macro to fully fill the PCI device ID table. This is mandatory > for the DM PCI support, which checks all the fields. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 9db9367e95..74b09e9afd 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -465,10 +465,10 @@ static int read_eeprom(struct eth_device *dev, int > location, int addr_len) > } > > static struct pci_device_id supported[] = { > - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, > - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, > - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, > - {} > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) }, > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) }, > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER) }, > + { } > }; > > static void read_hw_addr(struct eth_device *dev, bd_t *bis) > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 15/30] net: eepro100: Remove volatile misuse
On Sat, May 23, 2020 at 7:42 PM Marek Vasut wrote: > > Remove all the remaining use of the 'volatile' keyword, as this is > no longer required. All the accesses which might have needed this > use of 'volatile' have been repaired properly. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 42 +- > 1 file changed, 21 insertions(+), 21 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 89bfcfba0a..f3bcb0dfe4 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -103,13 +103,13 @@ > > /* Receive frame descriptors. */ > struct eepro100_rxfd { > - volatile u16 status; > - volatile u16 control; > - volatile u32 link; /* struct eepro100_rxfd * */ > - volatile u32 rx_buf_addr; /* void * */ > - volatile u32 count; > + u16 status; > + u16 control; > + u32 link; /* struct eepro100_rxfd * */ > + u32 rx_buf_addr;/* void * */ > + u32 count; > > - volatile u8 data[PKTSIZE_ALIGN]; > + u8 data[PKTSIZE_ALIGN]; > }; > > #define RFD_STATUS_C 0x8000 /* completion of received frame */ > @@ -136,17 +136,17 @@ struct eepro100_rxfd { > #define RFD_RX_TCO 0x0001 /* TCO indication */ > > /* Transmit frame descriptors */ > -struct eepro100_txfd { /* Transmit frame descriptor set. */ > - volatile u16 status; > - volatile u16 command; > - volatile u32 link; /* void * */ > - volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr > element. */ > - volatile s32 count; > - > - volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */ > - volatile s32 tx_buf_size0; /* Length of Tx frame. */ > - volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */ > - volatile s32 tx_buf_size1; /* Length of Tx frame. */ > +struct eepro100_txfd { /* Transmit frame descriptor set. */ > + u16 status; > + u16 command; > + u32 link; /* void * */ > + u32 tx_desc_addr; /* Always points to the tx_buf_addr element. > */ > + s32 count; > + > + u32 tx_buf_addr0; /* void *, frame to be transmitted. */ > + s32 tx_buf_size0; /* Length of Tx frame. */ > + u32 tx_buf_addr1; /* void *, frame to be transmitted. */ > + s32 tx_buf_size1; /* Length of Tx frame. */ > }; > > #define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */ > @@ -160,10 +160,10 @@ struct eepro100_txfd {/* Transmit > frame descriptor set. */ > #define TXCB_COUNT_EOF 0x8000 > > /* The Speedo3 Rx and Tx frame/buffer descriptors. */ > -struct descriptor {/* A generic descriptor. */ > - volatile u16 status; > - volatile u16 command; > - volatile u32 link; /* struct descriptor * */ > +struct descriptor {/* A generic descriptor. */ > + u16 status; > + u16 command; > + u32 link; /* struct descriptor * */ > > unsigned char params[0]; > }; > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 14/30] net: eepro100: Add cache management
On Sat, May 23, 2020 at 7:43 PM Marek Vasut wrote: > > Add cache invalidation and flushes wherever the DMA descriptors are > written or read, otherwise this driver cannot work reliably on any > systems where caches are enabled. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 65 +- > 1 file changed, 45 insertions(+), 20 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 03ba9a41a5..89bfcfba0a 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -5,6 +5,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -459,6 +460,9 @@ static int eepro100_txcmd_send(struct eth_device *dev, > u16 rstat; > int i = 0; > > + flush_dcache_range((unsigned long)desc, > + (unsigned long)desc + sizeof(*desc)); > + > if (!wait_for_eepro100(dev)) > return -ETIMEDOUT; > > @@ -466,6 +470,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, > OUTW(dev, SCB_M | CU_START, SCB_CMD); > > while (true) { > + invalidate_dcache_range((unsigned long)desc, > + (unsigned long)desc + sizeof(*desc)); > rstat = le16_to_cpu(desc->status); > if (rstat & CONFIG_SYS_STATUS_C) > break; > @@ -476,6 +482,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, > } > } > > + invalidate_dcache_range((unsigned long)desc, > + (unsigned long)desc + sizeof(*desc)); > rstat = le16_to_cpu(desc->status); > > if (!(rstat & CONFIG_SYS_STATUS_OK)) { > @@ -523,6 +531,7 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > goto done; > } > > + /* RX ring cache was already flushed in init_rx_ring() */ > OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); > OUTW(dev, SCB_M | RUC_START, SCB_CMD); > > @@ -573,6 +582,7 @@ done: > > static int eepro100_send(struct eth_device *dev, void *packet, int length) > { > + struct eepro100_txfd *desc; > int ret, status = -1; > int tx_cur; > > @@ -584,17 +594,15 @@ static int eepro100_send(struct eth_device *dev, void > *packet, int length) > tx_cur = tx_next; > tx_next = (tx_next + 1) % NUM_TX_DESC; > > - tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF > | > - TXCB_CMD_S | TXCB_CMD_EL); > - tx_ring[tx_cur].status = 0; > - tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold); > - tx_ring[tx_cur].link = > - cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); > - tx_ring[tx_cur].tx_desc_addr = > - cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0)); > - tx_ring[tx_cur].tx_buf_addr0 = > - cpu_to_le32 (phys_to_bus((u_long)packet)); > - tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length); > + desc = &tx_ring[tx_cur]; > + desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | > + TXCB_CMD_S | TXCB_CMD_EL); > + desc->status = 0; > + desc->count = cpu_to_le32(tx_threshold); > + desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > + desc->tx_desc_addr = > cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0)); > + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet)); > + desc->tx_buf_size0 = cpu_to_le32(length); > > ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); > if (ret) { > @@ -612,14 +620,18 @@ done: > > static int eepro100_recv(struct eth_device *dev) > { > - u16 status, stat; > + struct eepro100_rxfd *desc; > int rx_prev, length = 0; > + u16 status, stat; > > stat = INW(dev, SCB_STATUS); > OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS); > > for (;;) { > - status = le16_to_cpu(rx_ring[rx_next].status); > + desc = &rx_ring[rx_next]; > + invalidate_dcache_range((unsigned long)desc, > + (unsigned long)desc + sizeof(*desc)); > + status = le16_to_cpu(desc->status); > > if (!(status & RFD_STATUS_C)) > break; > @@ -627,22 +639,26 @@ static int eepro100_recv(struct eth_device *dev) > /* Valid frame status. */ > if ((status & RFD_STATUS_OK)) { > /* A valid frame received. */ > - length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff; > + length = le32_to_cpu(desc->count) & 0x3fff; > > /* Pass the packet up to the protocol layers. */ > - net_process_received_packet((u8 > *)rx_ring[rx_next].data, > -
Re: [PATCH 18/30] net: eepro100: Switch from malloc()+memset() to calloc()
On Sat, May 23, 2020 at 7:42 PM Marek Vasut wrote: > > Replace malloc()+memset() combination with calloc(), no functional change. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 74b09e9afd..8fa665743a 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -746,12 +746,11 @@ int eepro100_initialize(bd_t *bis) > continue; > } > > - dev = (struct eth_device *)malloc(sizeof(*dev)); > + dev = calloc(1, sizeof(*dev)); > if (!dev) { > printf("eepro100: Can not allocate memory\n"); > break; > } > - memset(dev, 0, sizeof(*dev)); > > sprintf(dev->name, "i82559#%d", card_number); > dev->priv = (void *)devno; /* this have to come before > bus_to_phys() */ > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 16/30] net: eepro100: Reorder functions in the driver
On Sat, May 23, 2020 at 7:42 PM Marek Vasut wrote: > > Move the functions around in the driver to prepare it for DM conversion. > Drop forward declarations which are not necessary anymore. No functional > change. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 330 - > 1 file changed, 160 insertions(+), 170 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index f3bcb0dfe4..9db9367e95 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -5,13 +5,13 @@ > */ > > #include > +#include > #include > #include > +#include > #include > #include > -#include > #include > -#include > #include > > /* Ethernet chip registers. */ > @@ -201,16 +201,6 @@ static const char i82558_config_cmd[] = { > 0x31, 0x05, > }; > > -static void init_rx_ring(struct eth_device *dev); > -static void purge_tx_ring(struct eth_device *dev); > - > -static void read_hw_addr(struct eth_device *dev, bd_t *bis); > - > -static int eepro100_init(struct eth_device *dev, bd_t *bis); > -static int eepro100_send(struct eth_device *dev, void *packet, int length); > -static int eepro100_recv(struct eth_device *dev); > -static void eepro100_halt(struct eth_device *dev); > - > #if defined(CONFIG_E500) > #define bus_to_phys(a) (a) > #define phys_to_bus(a) (a) > @@ -353,105 +343,50 @@ static int eepro100_miiphy_write(struct mii_dev *bus, > int addr, int devad, > > #endif > > -/* Wait for the chip get the command. */ > -static int wait_for_eepro100(struct eth_device *dev) > +static void init_rx_ring(struct eth_device *dev) > { > int i; > > - for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { > - if (i >= TOUT_LOOP) > - return 0; > + for (i = 0; i < NUM_RX_DESC; i++) { > + rx_ring[i].status = 0; > + rx_ring[i].control = (i == NUM_RX_DESC - 1) ? > +cpu_to_le16 (RFD_CONTROL_S) : 0; > + rx_ring[i].link = > + cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % > + NUM_RX_DESC])); > + rx_ring[i].rx_buf_addr = 0x; > + rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); > } > > - return 1; > -} > + flush_dcache_range((unsigned long)rx_ring, > + (unsigned long)rx_ring + > + (sizeof(*rx_ring) * NUM_RX_DESC)); > > -static struct pci_device_id supported[] = { > - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, > - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, > - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, > - {} > -}; > + rx_next = 0; > +} > > -int eepro100_initialize(bd_t *bis) > +static void purge_tx_ring(struct eth_device *dev) > { > - pci_dev_t devno; > - int card_number = 0; > - struct eth_device *dev; > - u32 iobase, status; > - int idx = 0; > - > - while (1) { > - /* Find PCI device */ > - devno = pci_find_devices(supported, idx++); > - if (devno < 0) > - break; > - > - pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); > - iobase &= ~0xf; > - > - debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", > - iobase); > - > - pci_write_config_dword(devno, PCI_COMMAND, > - PCI_COMMAND_MEMORY | > PCI_COMMAND_MASTER); > - > - /* Check if I/O accesses and Bus Mastering are enabled. */ > - pci_read_config_dword(devno, PCI_COMMAND, &status); > - if (!(status & PCI_COMMAND_MEMORY)) { > - printf("Error: Can not enable MEM access.\n"); > - continue; > - } > - > - if (!(status & PCI_COMMAND_MASTER)) { > - printf("Error: Can not enable Bus Mastering.\n"); > - continue; > - } > - > - dev = (struct eth_device *)malloc(sizeof(*dev)); > - if (!dev) { > - printf("eepro100: Can not allocate memory\n"); > - break; > - } > - memset(dev, 0, sizeof(*dev)); > - > - sprintf(dev->name, "i82559#%d", card_number); > - dev->priv = (void *)devno; /* this have to come before > bus_to_phys() */ > - dev->iobase = bus_to_phys(iobase); > - dev->init = eepro100_init; > - dev->halt = eepro100_halt; > - dev->send = eepro100_send; > - dev->recv = eepro100_recv; > - > - eth_register(dev); > - > -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > - /* register mii command access routines
Re: [PATCH 12/30] net: eepro100: Replace purge_tx_ring() with memset()
On Sat, May 23, 2020 at 7:41 PM Marek Vasut wrote: > > This function zeroes-out all the descriptors in the TX ring, > use memset() instead. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 16 +--- > 1 file changed, 1 insertion(+), 15 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 5d11665fdc..6fb9192e81 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -767,23 +767,9 @@ static void init_rx_ring(struct eth_device *dev) > > static void purge_tx_ring(struct eth_device *dev) > { > - int i; > - > tx_next = 0; > tx_threshold = 0x01208000; > - > - for (i = 0; i < NUM_TX_DESC; i++) { > - tx_ring[i].status = 0; > - tx_ring[i].command = 0; > - tx_ring[i].link = 0; > - tx_ring[i].tx_desc_addr = 0; > - tx_ring[i].count = 0; > - > - tx_ring[i].tx_buf_addr0 = 0; > - tx_ring[i].tx_buf_size0 = 0; > - tx_ring[i].tx_buf_addr1 = 0; > - tx_ring[i].tx_buf_size1 = 0; > - } > + memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); > } > > static void read_hw_addr(struct eth_device *dev, bd_t *bis) > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 13/30] net: eepro100: Factor out tx_ring command issuing
On Sat, May 23, 2020 at 7:42 PM Marek Vasut wrote: > > This code is replicated in the driver thrice almost verbatim, factor > it out into a separate function and clean it up. No functional change. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 124 ++--- > 1 file changed, 53 insertions(+), 71 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 6fb9192e81..03ba9a41a5 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -453,11 +453,44 @@ int eepro100_initialize(bd_t *bis) > return card_number; > } > > +static int eepro100_txcmd_send(struct eth_device *dev, > + struct eepro100_txfd *desc) > +{ > + u16 rstat; > + int i = 0; > + > + if (!wait_for_eepro100(dev)) > + return -ETIMEDOUT; > + > + OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER); > + OUTW(dev, SCB_M | CU_START, SCB_CMD); > + > + while (true) { > + rstat = le16_to_cpu(desc->status); > + if (rstat & CONFIG_SYS_STATUS_C) > + break; > + > + if (i++ >= TOUT_LOOP) { > + printf("%s: Tx error buffer not ready\n", dev->name); > + return -EINVAL; > + } > + } > + > + rstat = le16_to_cpu(desc->status); > + > + if (!(rstat & CONFIG_SYS_STATUS_OK)) { > + printf("TX error status = 0x%08X\n", rstat); > + return -EIO; > + } > + > + return 0; > +} > + > static int eepro100_init(struct eth_device *dev, bd_t *bis) > { > - int i, status = -1; > + struct eepro100_txfd *ias_cmd, *cfg_cmd; > + int ret, status = -1; > int tx_cur; > - struct descriptor *ias_cmd, *cfg_cmd; > > /* Reset the ethernet controller */ > OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); > @@ -497,35 +530,19 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > tx_cur = tx_next; > tx_next = ((tx_next + 1) % NUM_TX_DESC); > > - cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; > + cfg_cmd = &tx_ring[tx_cur]; > cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | >CONFIG_SYS_CMD_CONFIGURE); > cfg_cmd->status = 0; > cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > > - memcpy(cfg_cmd->params, i82558_config_cmd, > + memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, >sizeof(i82558_config_cmd)); > > - if (!wait_for_eepro100(dev)) { > - printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset > ethernet controller.\n"); > - goto done; > - } > - > - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); > - OUTW(dev, SCB_M | CU_START, SCB_CMD); > - > - for (i = 0; > -!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); > -i++) { > - if (i >= TOUT_LOOP) { > - printf("%s: Tx error buffer not ready\n", dev->name); > - goto done; > - } > - } > - > - if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { > - printf("TX error status = 0x%08X\n", > - le16_to_cpu(tx_ring[tx_cur].status)); > + ret = eepro100_txcmd_send(dev, cfg_cmd); > + if (ret) { > + if (ret == -ETIMEDOUT) > + printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not > reset ethernet controller.\n"); > goto done; > } > > @@ -533,36 +550,18 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > tx_cur = tx_next; > tx_next = ((tx_next + 1) % NUM_TX_DESC); > > - ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; > + ias_cmd = &tx_ring[tx_cur]; > ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | >CONFIG_SYS_CMD_IAS); > ias_cmd->status = 0; > ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > > - memcpy(ias_cmd->params, dev->enetaddr, 6); > - > - /* Tell the adapter where the TX ring is located. */ > - if (!wait_for_eepro100(dev)) { > - printf("Error: Can not reset ethernet controller.\n"); > - goto done; > - } > - > - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); > - OUTW(dev, SCB_M | CU_START, SCB_CMD); > - > - for (i = 0; > -!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); > -i++) { > - if (i >= TOUT_LOOP) { > - printf("%s: Tx error buffer not ready\n", > - dev->name); > - goto done; > - } > - } > + memcpy(((struct descriptor *)
Re: [PATCH 11/30] net: eepro100: Use standard I/O accessors
On Sat, May 23, 2020 at 7:42 PM Marek Vasut wrote: > > The current eepro100 driver accesses its memory mapped registers directly > instead of using the standard I/O accessors. This can cause problems on > some systems as the accesses can get out of order. So convert the direct > volatile dereferences to use the normal in/out macros. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index d3ced08761..5d11665fdc 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -220,23 +220,23 @@ static void eepro100_halt(struct eth_device *dev); > > static inline int INW(struct eth_device *dev, u_long addr) > { > - return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); > + return le16_to_cpu(readw(addr + (void *)dev->iobase)); > } > > static inline void OUTW(struct eth_device *dev, int command, u_long addr) > { > - *(volatile u16 *)((addr + (u_long)dev->iobase)) = > cpu_to_le16(command); > + writew(cpu_to_le16(command), addr + (void *)dev->iobase); > } > > static inline void OUTL(struct eth_device *dev, int command, u_long addr) > { > - *(volatile u32 *)((addr + (u_long)dev->iobase)) = > cpu_to_le32(command); > + writel(cpu_to_le32(command), addr + (void *)dev->iobase); > } > > #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > static inline int INL(struct eth_device *dev, u_long addr) > { > - return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); > + return le32_to_cpu(readl(addr + (void *)dev->iobase)); > } > > static int get_phyreg(struct eth_device *dev, unsigned char addr, > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 10/30] net: eepro100: Fix camelcase
On Sat, May 23, 2020 at 7:41 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace > drivers/net/eepro100.c > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 172 - > 1 file changed, 85 insertions(+), 87 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 45c013607e..d3ced08761 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -14,18 +14,18 @@ > #include > > /* Ethernet chip registers. */ > -#define SCBStatus 0 /* Rx/Command Unit Status *Word* */ > -#define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ > -#define SCBCmd 2 /* Rx/Command Unit Command *Word* */ > -#define SCBIntrCtlByte 3 /* Rx/Command Unit Intr.Control Byte > */ > -#define SCBPointer 4 /* General purpose pointer. */ > -#define SCBPort8 /* Misc. commands and > operands. */ > -#define SCBflash 12 /* Flash memory control. */ > -#define SCBeeprom 14 /* EEPROM memory control. */ > -#define SCBCtrlMDI 16 /* MDI interface control. */ > -#define SCBEarlyRx 20 /* Early receive byte count. */ > -#define SCBGenControl 28 /* 82559 General Control Register */ > -#define SCBGenStatus 29 /* 82559 General Status register */ > +#define SCB_STATUS 0 /* Rx/Command Unit Status *Word* */ > +#define SCB_INT_ACK_BYTE 1 /* Rx/Command Unit STAT/ACK byte */ > +#define SCB_CMD2 /* Rx/Command Unit Command > *Word* */ > +#define SCB_INTR_CTL_BYTE 3 /* Rx/Command Unit Intr.Control Byte > */ > +#define SCB_POINTER4 /* General purpose pointer. */ > +#define SCB_PORT 8 /* Misc. commands and operands. */ > +#define SCB_FLASH 12 /* Flash memory control. */ > +#define SCB_EEPROM 14 /* EEPROM memory control. */ > +#define SCB_CTRL_MDI 16 /* MDI interface control. */ > +#define SCB_EARLY_RX 20 /* Early receive byte count. */ > +#define SCB_GEN_CONTROL28 /* 82559 General Control > Register */ > +#define SCB_GEN_STATUS 29 /* 82559 General Status register */ > > /* 82559 SCB status word defnitions */ > #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */ > @@ -101,10 +101,10 @@ > #define EE_ERASE_CMD (7 << addr_len) > > /* Receive frame descriptors. */ > -struct RxFD { > +struct eepro100_rxfd { > volatile u16 status; > volatile u16 control; > - volatile u32 link; /* struct RxFD * */ > + volatile u32 link; /* struct eepro100_rxfd * */ > volatile u32 rx_buf_addr; /* void * */ > volatile u32 count; > > @@ -135,7 +135,7 @@ struct RxFD { > #define RFD_RX_TCO 0x0001 /* TCO indication */ > > /* Transmit frame descriptors */ > -struct TxFD { /* Transmit frame descriptor set. */ > +struct eepro100_txfd { /* Transmit frame descriptor set. */ > volatile u16 status; > volatile u16 command; > volatile u32 link; /* void * */ > @@ -148,15 +148,15 @@ struct TxFD { /* Transmit > frame descriptor set. */ > volatile s32 tx_buf_size1; /* Length of Tx frame. */ > }; > > -#define TxCB_CMD_TRANSMIT 0x0004 /* transmit command */ > -#define TxCB_CMD_SF0x0008 /* 0=simplified, 1=flexible mode */ > -#define TxCB_CMD_NC0x0010 /* 0=CRC insert by controller */ > -#define TxCB_CMD_I 0x2000 /* generate interrupt on completion */ > -#define TxCB_CMD_S 0x4000 /* suspend on completion */ > -#define TxCB_CMD_EL0x8000 /* last command block in CBL */ > +#define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */ > +#define TXCB_CMD_SF0x0008 /* 0=simplified, 1=flexible mode */ > +#define TXCB_CMD_NC0x0010 /* 0=CRC insert by controller */ > +#define TXCB_CMD_I 0x2000 /* generate interrupt on completion */ > +#define TXCB_CMD_S 0x4000 /* suspend on completion */ > +#define TXCB_CMD_EL0x8000 /* last command block in CBL */ > > -#define TxCB_COUNT_MASK0x3fff > -#define TxCB_COUNT_EOF 0x8000 > +#define TXCB_COUNT_MASK0x3fff > +#define TXCB_COUNT_EOF 0x8000 > > /* The Speedo3 Rx and Tx frame/buffer descriptors. */ > struct descriptor {/* A generic descriptor. */ > @@ -182,8 +182,8 @@ struct descriptor { /* A generic > descriptor. */ > > #define T
Re: [PATCH 08/30] net: eepro100: Fix indented label
On Sat, May 23, 2020 at 7:41 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace > drivers/net/eepro100.c > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 2aad124ae5..e5bc90f52c 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -566,7 +566,7 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > > status = 0; > > - Done: > +Done: > return status; > } > > @@ -623,7 +623,7 @@ static int eepro100_send(struct eth_device *dev, void > *packet, int length) > > status = length; > > - Done: > +Done: > return status; > } > > @@ -680,7 +680,7 @@ static int eepro100_recv(struct eth_device *dev) > OUTW(dev, SCB_M | RUC_START, SCBCmd); > } > > - Done: > +Done: > return length; > } > > @@ -707,7 +707,7 @@ static void eepro100_halt(struct eth_device *dev) > OUTL(dev, 0, SCBPointer); > OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); > > - Done: > +Done: > return; > } > > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 04/30] net: eepro100: Fix spacing
On Sat, May 23, 2020 at 7:40 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl --types SPACING -f --fix --fix-inplace > drivers/net/eepro100.c > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 278 - > 1 file changed, 139 insertions(+), 139 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index dd902386b1..1b6d5375f8 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -68,13 +68,13 @@ > #define CU_STATUS_MASK 0x00C0 > #define RU_STATUS_MASK 0x003C > > -#define RU_STATUS_IDLE (0<<2) > -#define RU_STATUS_SUS (1<<2) > -#define RU_STATUS_NORES(2<<2) > -#define RU_STATUS_READY(4<<2) > -#define RU_STATUS_NO_RBDS_SUS ((1<<2)|(8<<2)) > -#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) > -#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) > +#define RU_STATUS_IDLE (0 << 2) > +#define RU_STATUS_SUS (1 << 2) > +#define RU_STATUS_NORES(2 << 2) > +#define RU_STATUS_READY(4 << 2) > +#define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2)) > +#define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2)) > +#define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2)) > > /* 82559 Port interface commands. */ > #define I82559_RESET 0x /* Software reset */ > @@ -200,15 +200,15 @@ static const char i82558_config_cmd[] = { > 0x31, 0x05, > }; > > -static void init_rx_ring (struct eth_device *dev); > -static void purge_tx_ring (struct eth_device *dev); > +static void init_rx_ring(struct eth_device *dev); > +static void purge_tx_ring(struct eth_device *dev); > > -static void read_hw_addr (struct eth_device *dev, bd_t * bis); > +static void read_hw_addr(struct eth_device *dev, bd_t * bis); > > -static int eepro100_init (struct eth_device *dev, bd_t * bis); > +static int eepro100_init(struct eth_device *dev, bd_t * bis); > static int eepro100_send(struct eth_device *dev, void *packet, int length); > -static int eepro100_recv (struct eth_device *dev); > -static void eepro100_halt (struct eth_device *dev); > +static int eepro100_recv(struct eth_device *dev); > +static void eepro100_halt(struct eth_device *dev); > > #if defined(CONFIG_E500) > #define bus_to_phys(a) (a) > @@ -218,28 +218,28 @@ static void eepro100_halt (struct eth_device *dev); > #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) > #endif > > -static inline int INW (struct eth_device *dev, u_long addr) > +static inline int INW(struct eth_device *dev, u_long addr) > { > return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); > } > > -static inline void OUTW (struct eth_device *dev, int command, u_long addr) > +static inline void OUTW(struct eth_device *dev, int command, u_long addr) > { > *(volatile u16 *)((addr + (u_long)dev->iobase)) = > cpu_to_le16(command); > } > > -static inline void OUTL (struct eth_device *dev, int command, u_long addr) > +static inline void OUTL(struct eth_device *dev, int command, u_long addr) > { > *(volatile u32 *)((addr + (u_long)dev->iobase)) = > cpu_to_le32(command); > } > > #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) > -static inline int INL (struct eth_device *dev, u_long addr) > +static inline int INL(struct eth_device *dev, u_long addr) > { > return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); > } > > -static int get_phyreg (struct eth_device *dev, unsigned char addr, > +static int get_phyreg(struct eth_device *dev, unsigned char addr, > unsigned char reg, unsigned short *value) > { > int cmd; > @@ -247,22 +247,22 @@ static int get_phyreg (struct eth_device *dev, unsigned > char addr, > > /* read requested data */ > cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); > - OUTL (dev, cmd, SCBCtrlMDI); > + OUTL(dev, cmd, SCBCtrlMDI); > > do { > udelay(1000); > - cmd = INL (dev, SCBCtrlMDI); > + cmd = INL(dev, SCBCtrlMDI); > } while (!(cmd & (1 << 28)) && (--timeout)); > > if (timeout == 0) > return -1; > > - *value = (unsigned short) (cmd & 0x); > + *value = (unsigned short)(cmd & 0x); > > return 0; > } > > -static int set_phyreg (struct eth_device *dev, unsigned char addr, > +static int set_phyreg(struct eth_device *dev, unsigned char addr, > unsigned char reg, unsigned short value) > { > int cmd; > @@ -270,9 +270,9 @@ static int set_phyreg (struct eth_device *dev, unsigned > char addr, > > /* write requested data */ > cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); > - OUTL (dev, cmd | value, SCBCtrlMDI); > + OUTL(dev, cmd | value, SCBCt
Re: [PATCH 09/30] net: eepro100: Fix remaining checkpatch issues
On Sat, May 23, 2020 at 7:41 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl -f --fix --fix-inplace drivers/net/eepro100.c > > This fixes all the remaining errors except a couple of comments which > are longer than 80 characters, all the volatile misuse and all the > camelcase, that needs a separate patch. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 45 ++ > 1 file changed, 24 insertions(+), 21 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index e5bc90f52c..45c013607e 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -293,7 +293,7 @@ static struct eth_device *verify_phyaddr(const char > *devname, > unsigned char model; > > dev = eth_get_dev_by_name(devname); > - if (dev == NULL) { > + if (!dev) { > printf("%s: no such device\n", devname); > return NULL; > } > @@ -322,7 +322,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int > addr, int devad, > struct eth_device *dev; > > dev = verify_phyaddr(bus->name, addr); > - if (dev == NULL) > + if (!dev) > return -1; > > if (get_phyreg(dev, addr, reg, &value) != 0) { > @@ -339,7 +339,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int > addr, int devad, > struct eth_device *dev; > > dev = verify_phyaddr(bus->name, addr); > - if (dev == NULL) > + if (!dev) > return -1; > > if (set_phyreg(dev, addr, reg, value) != 0) { > @@ -392,9 +392,8 @@ int eepro100_initialize(bd_t *bis) > debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", > iobase); > > - pci_write_config_dword(devno, > - PCI_COMMAND, > - PCI_COMMAND_MEMORY | > PCI_COMMAND_MASTER); > + pci_write_config_dword(devno, PCI_COMMAND, > + PCI_COMMAND_MEMORY | > PCI_COMMAND_MASTER); > > /* Check if I/O accesses and Bus Mastering are enabled. */ > pci_read_config_dword(devno, PCI_COMMAND, &status); > @@ -408,7 +407,7 @@ int eepro100_initialize(bd_t *bis) > continue; > } > > - dev = (struct eth_device *)malloc(sizeof *dev); > + dev = (struct eth_device *)malloc(sizeof(*dev)); > if (!dev) { > printf("eepro100: Can not allocate memory\n"); > break; > @@ -429,6 +428,7 @@ int eepro100_initialize(bd_t *bis) > /* register mii command access routines */ > int retval; > struct mii_dev *mdiodev = mdio_alloc(); > + > if (!mdiodev) > return -ENOMEM; > strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); > @@ -453,7 +453,6 @@ int eepro100_initialize(bd_t *bis) > return card_number; > } > > - > static int eepro100_init(struct eth_device *dev, bd_t *bis) > { > int i, status = -1; > @@ -499,9 +498,10 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > tx_next = ((tx_next + 1) % NUM_TX_DESC); > > cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; > - cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | > CONFIG_SYS_CMD_CONFIGURE)); > + cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | > + CONFIG_SYS_CMD_CONFIGURE); > cfg_cmd->status = 0; > - cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); > + cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > > memcpy(cfg_cmd->params, i82558_config_cmd, >sizeof(i82558_config_cmd)); > @@ -534,9 +534,10 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > tx_next = ((tx_next + 1) % NUM_TX_DESC); > > ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; > - ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | > CONFIG_SYS_CMD_IAS)); > + ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | > + CONFIG_SYS_CMD_IAS); > ias_cmd->status = 0; > - ias_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); > + ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); > > memcpy(ias_cmd->params, dev->enetaddr, 6); > > @@ -549,8 +550,9 @@ static int eepro100_init(struct eth_device *dev, bd_t > *bis) > OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); > OUTW(dev, SCB_M | CU_START, SCBCmd); > > - for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & > CONFIG_SYS_STATUS_C); > -
Re: [PATCH 03/30] net: eepro100: Use plain debug()
On Sat, May 23, 2020 at 7:40 PM Marek Vasut wrote: > > Convert all the ifdef DEBUG to plain debug(), no functional change. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 15 --- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 503c44af4c..dd902386b1 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -13,8 +13,6 @@ > #include > #include > > -#undef DEBUG > - > /* Ethernet chip registers. */ > #define SCBStatus 0 /* Rx/Command Unit Status *Word* */ > #define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ > @@ -392,10 +390,8 @@ int eepro100_initialize (bd_t * bis) > pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, &iobase); > iobase &= ~0xf; > > -#ifdef DEBUG > - printf ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", > - iobase); > -#endif > + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", > + iobase); > > pci_write_config_dword (devno, > PCI_COMMAND, > @@ -810,10 +806,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * > bis) > > if (sum != 0xBABA) { > memset (dev->enetaddr, 0, ETH_ALEN); > -#ifdef DEBUG > - printf ("%s: Invalid EEPROM checksum %#4.4x, " > - "check settings before activating this device!\n", > - dev->name, sum); > -#endif > + debug("%s: Invalid EEPROM checksum %#4.4x, check settings > before activating this device!\n", > + dev->name, sum); > } > } > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 07/30] net: eepro100: Fix pointer location
On Sat, May 23, 2020 at 7:40 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl --types POINTER_LOCATION -f --fix --fix-inplace > drivers/net/eepro100.c > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index d367052cd2..2aad124ae5 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -203,9 +203,9 @@ static const char i82558_config_cmd[] = { > static void init_rx_ring(struct eth_device *dev); > static void purge_tx_ring(struct eth_device *dev); > > -static void read_hw_addr(struct eth_device *dev, bd_t * bis); > +static void read_hw_addr(struct eth_device *dev, bd_t *bis); > > -static int eepro100_init(struct eth_device *dev, bd_t * bis); > +static int eepro100_init(struct eth_device *dev, bd_t *bis); > static int eepro100_send(struct eth_device *dev, void *packet, int length); > static int eepro100_recv(struct eth_device *dev); > static void eepro100_halt(struct eth_device *dev); > @@ -285,7 +285,7 @@ static int set_phyreg(struct eth_device *dev, unsigned > char addr, > * Check if given phyaddr is valid, i.e. there is a PHY connected. > * Do this by checking model value field from ID2 register. > */ > -static struct eth_device* verify_phyaddr(const char *devname, > +static struct eth_device *verify_phyaddr(const char *devname, > unsigned char addr) > { > struct eth_device *dev; > @@ -372,7 +372,7 @@ static struct pci_device_id supported[] = { > {} > }; > > -int eepro100_initialize(bd_t * bis) > +int eepro100_initialize(bd_t *bis) > { > pci_dev_t devno; > int card_number = 0; > @@ -454,7 +454,7 @@ int eepro100_initialize(bd_t * bis) > } > > > -static int eepro100_init(struct eth_device *dev, bd_t * bis) > +static int eepro100_init(struct eth_device *dev, bd_t *bis) > { > int i, status = -1; > int tx_cur; > @@ -785,7 +785,7 @@ static void purge_tx_ring(struct eth_device *dev) > } > } > > -static void read_hw_addr(struct eth_device *dev, bd_t * bis) > +static void read_hw_addr(struct eth_device *dev, bd_t *bis) > { > u16 sum = 0; > int i, j; > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 06/30] net: eepro100: Fix parenthesis alignment
On Sat, May 23, 2020 at 7:40 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl --types PARENTHESIS_ALIGNMENT -f --fix --fix-inplace > drivers/net/eepro100.c > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 20 ++-- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 6dccd59bda..d367052cd2 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -240,7 +240,7 @@ static inline int INL(struct eth_device *dev, u_long addr) > } > > static int get_phyreg(struct eth_device *dev, unsigned char addr, > - unsigned char reg, unsigned short *value) > + unsigned char reg, unsigned short *value) > { > int cmd; > int timeout = 50; > @@ -263,7 +263,7 @@ static int get_phyreg(struct eth_device *dev, unsigned > char addr, > } > > static int set_phyreg(struct eth_device *dev, unsigned char addr, > - unsigned char reg, unsigned short value) > + unsigned char reg, unsigned short value) > { > int cmd; > int timeout = 50; > @@ -286,7 +286,7 @@ static int set_phyreg(struct eth_device *dev, unsigned > char addr, > * Do this by checking model value field from ID2 register. > */ > static struct eth_device* verify_phyaddr(const char *devname, > - unsigned char addr) > +unsigned char addr) > { > struct eth_device *dev; > unsigned short value; > @@ -393,7 +393,7 @@ int eepro100_initialize(bd_t * bis) > iobase); > > pci_write_config_dword(devno, > - PCI_COMMAND, > + PCI_COMMAND, > PCI_COMMAND_MEMORY | > PCI_COMMAND_MASTER); > > /* Check if I/O accesses and Bus Mastering are enabled. */ > @@ -504,7 +504,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * > bis) > cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); > > memcpy(cfg_cmd->params, i82558_config_cmd, > - sizeof(i82558_config_cmd)); > + sizeof(i82558_config_cmd)); > > if (!wait_for_eepro100(dev)) { > printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset > ethernet controller.\n"); > @@ -525,7 +525,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * > bis) > > if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { > printf("TX error status = 0x%08X\n", > - le16_to_cpu(tx_ring[tx_cur].status)); > + le16_to_cpu(tx_ring[tx_cur].status)); > goto Done; > } > > @@ -553,14 +553,14 @@ static int eepro100_init(struct eth_device *dev, bd_t * > bis) > i++) { > if (i >= TOUT_LOOP) { > printf("%s: Tx error buffer not ready\n", > - dev->name); > + dev->name); > goto Done; > } > } > > if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { > printf("TX error status = 0x%08X\n", > - le16_to_cpu(tx_ring[tx_cur].status)); > + le16_to_cpu(tx_ring[tx_cur].status)); > goto Done; > } > > @@ -599,7 +599,7 @@ static int eepro100_send(struct eth_device *dev, void > *packet, int length) > > if (!wait_for_eepro100(dev)) { > printf("%s: Tx error ethernet controller not ready.\n", > - dev->name); > + dev->name); > goto Done; > } > > @@ -617,7 +617,7 @@ static int eepro100_send(struct eth_device *dev, void > *packet, int length) > > if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { > printf("TX error status = 0x%08X\n", > - le16_to_cpu(tx_ring[tx_cur].status)); > + le16_to_cpu(tx_ring[tx_cur].status)); > goto Done; > } > > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 05/30] net: eepro100: Fix braces
On Sat, May 23, 2020 at 7:40 PM Marek Vasut wrote: > > This is automated cleanup via checkpatch, no functional change. > ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c > ./scripts/checkpatch.pl --types BRACES -f --fix --fix-inplace > drivers/net/eepro100.c > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 11 --- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 1b6d5375f8..6dccd59bda 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -358,9 +358,8 @@ static int wait_for_eepro100(struct eth_device *dev) > int i; > > for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) { > - if (i >= TOUT_LOOP) { > + if (i >= TOUT_LOOP) > return 0; > - } > } > > return 1; > @@ -383,9 +382,9 @@ int eepro100_initialize(bd_t * bis) > > while (1) { > /* Find PCI device */ > - if ((devno = pci_find_devices(supported, idx++)) < 0) { > + devno = pci_find_devices(supported, idx++); > + if (devno < 0) > break; > - } > > pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); > iobase &= ~0xf; > @@ -639,9 +638,8 @@ static int eepro100_recv(struct eth_device *dev) > for (;;) { > status = le16_to_cpu(rx_ring[rx_next].status); > > - if (!(status & RFD_STATUS_C)) { > + if (!(status & RFD_STATUS_C)) > break; > - } > > /* Valid frame status. */ > if ((status & RFD_STATUS_OK)) { > @@ -668,7 +666,6 @@ static int eepro100_recv(struct eth_device *dev) > } > > if (stat & SCB_STATUS_RNR) { > - > printf("%s: Receiver is not ready, restart it !\n", > dev->name); > > /* Reinitialize Rx ring. */ > -- > 2.25.1 > Reviewed-By: Ramon Fried
Re: [PATCH 02/30] net: eepro100: Clean up comments
On Sat, May 23, 2020 at 7:39 PM Marek Vasut wrote: > > Clean the comments up to they trigger fewer checkpatch warnings, > no functional change. > > Signed-off-by: Marek Vasut > --- > drivers/net/eepro100.c | 100 +++-- > 1 file changed, 36 insertions(+), 64 deletions(-) > > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index 62a0dc7522..503c44af4c 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -15,8 +15,7 @@ > > #undef DEBUG > > - /* Ethernet chip registers. > -*/ > +/* Ethernet chip registers. */ > #define SCBStatus 0 /* Rx/Command Unit Status *Word* */ > #define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ > #define SCBCmd 2 /* Rx/Command Unit Command *Word* */ > @@ -30,8 +29,7 @@ > #define SCBGenControl 28 /* 82559 General Control Register */ > #define SCBGenStatus 29 /* 82559 General Status register */ > > - /* 82559 SCB status word defnitions > -*/ > +/* 82559 SCB status word defnitions */ > #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */ > #define SCB_STATUS_FR 0x4000 /* frame received */ > #define SCB_STATUS_CNA 0x2000 /* CU left active state */ > @@ -45,8 +43,7 @@ > #define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA) > #define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR) > > - /* System control block commands > -*/ > +/* System control block commands */ > /* CU Commands */ > #define CU_NOP 0x > #define CU_START 0x0010 > @@ -81,16 +78,14 @@ > #define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) > #define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) > > - /* 82559 Port interface commands. > -*/ > +/* 82559 Port interface commands. */ > #define I82559_RESET 0x /* Software reset */ > #define I82559_SELFTEST0x0001 /* 82559 Selftest > command */ > #define I82559_SELECTIVE_RESET 0x0002 > #define I82559_DUMP0x0003 > #define I82559_DUMP_WAKEUP 0x0007 > > - /* 82559 Eeprom interface. > -*/ > +/* 82559 Eeprom interface. */ > #define EE_SHIFT_CLK 0x01/* EEPROM shift clock. */ > #define EE_CS 0x02/* EEPROM chip select. */ > #define EE_DATA_WRITE 0x04/* EEPROM chip data in. */ > @@ -101,15 +96,13 @@ > #define EE_CMD_BITS3 > #define EE_DATA_BITS 16 > > - /* The EEPROM commands include the alway-set leading bit. > -*/ > +/* The EEPROM commands include the alway-set leading bit. */ > #define EE_EWENB_CMD (4 << addr_len) > #define EE_WRITE_CMD (5 << addr_len) > #define EE_READ_CMD(6 << addr_len) > #define EE_ERASE_CMD (7 << addr_len) > > - /* Receive frame descriptors. > -*/ > +/* Receive frame descriptors. */ > struct RxFD { > volatile u16 status; > volatile u16 control; > @@ -143,8 +136,7 @@ struct RxFD { > #define RFD_RX_IA_MATCH0x0002 /* individual address does > not match */ > #define RFD_RX_TCO 0x0001 /* TCO indication */ > > - /* Transmit frame descriptors > -*/ > +/* Transmit frame descriptors */ > struct TxFD { /* Transmit frame descriptor set. */ > volatile u16 status; > volatile u16 command; > @@ -152,9 +144,9 @@ struct TxFD { /* Transmit > frame descriptor set. */ > volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr > element. */ > volatile s32 count; > > - volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. > */ > + volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */ > volatile s32 tx_buf_size0; /* Length of Tx frame. */ > - volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. > */ > + volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */ > volatile s32 tx_buf_size1; /* Length of Tx frame. */ > }; > > @@ -168,12 +160,11 @@ struct TxFD { /* Transmit > frame descriptor set. */ > #define TxCB_COUNT_MASK0x3fff > #define TxCB_COUNT_EOF 0x8000 > > - /* The Speedo3 Rx and Tx frame/buffer descriptors. > -*/ > +/* The Speedo3 Rx and Tx frame/buffer descriptors. */ > struct descriptor {/* A generic descriptor. */ > volatile u16 status; > volatile u16 command; > - volatile u32 link; /* struct descriptor * */ > + volatile u32 link; /* struct descriptor * */ > > unsigned char params[0]; > }; > @@ -187,15 +178,14 @@ struct descriptor { /* A generic > descriptor. */ > #define CONFI
Re: [PATCH 01/30] net: eepro100: Remove EEPRO100_SROM_WRITE
On Sat, May 23, 2020 at 7:39 PM Marek Vasut wrote: > > This code is never enabled, last board that used it was ELPPC which > was removed some 5 years ago, so just remove this code altogether. > > Signed-off-by: Marek Vasut > --- > README | 2 - > drivers/net/eepro100.c | 87 > scripts/config_whitelist.txt | 1 - > 3 files changed, 90 deletions(-) > > diff --git a/README b/README > index be9e6391d6..c4bb6f3e7b 100644 > --- a/README > +++ b/README > @@ -891,8 +891,6 @@ The following options need to be configured: > > CONFIG_EEPRO100 > Support for Intel 82557/82559/82559ER chips. > - Optional CONFIG_EEPRO100_SROM_WRITE enables EEPROM > - write routine for first time initialisation. > > CONFIG_TULIP > Support for Digital 2114x chips. > diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c > index e186ab4e5f..62a0dc7522 100644 > --- a/drivers/net/eepro100.c > +++ b/drivers/net/eepro100.c > @@ -781,93 +781,6 @@ static int read_eeprom (struct eth_device *dev, int > location, int addr_len) > return retval; > } > > -#ifdef CONFIG_EEPRO100_SROM_WRITE > -int eepro100_write_eeprom (struct eth_device* dev, int location, int > addr_len, unsigned short data) > -{ > -unsigned short dataval; > -int enable_cmd = 0x3f | EE_EWENB_CMD; > -int write_cmd = location | EE_WRITE_CMD; > -int i; > -unsigned long datalong, tmplong; > - > -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); > -udelay(1); > -OUTW(dev, EE_ENB, SCBeeprom); > - > -/* Shift the enable command bits out. */ > -for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--) > -{ > - dataval = (enable_cmd & (1 << i)) ? EE_DATA_WRITE : 0; > - OUTW(dev, EE_ENB | dataval, SCBeeprom); > - udelay(1); > - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); > - udelay(1); > -} > - > -OUTW(dev, EE_ENB, SCBeeprom); > -udelay(1); > -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); > -udelay(1); > -OUTW(dev, EE_ENB, SCBeeprom); > - > - > -/* Shift the write command bits out. */ > -for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--) > -{ > - dataval = (write_cmd & (1 << i)) ? EE_DATA_WRITE : 0; > - OUTW(dev, EE_ENB | dataval, SCBeeprom); > - udelay(1); > - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); > - udelay(1); > -} > - > -/* Write the data */ > -datalong= (unsigned long) data) & 0x00ff) << 8) | ( (data) >> 8)); > - > -for (i = 0; i< EE_DATA_BITS; i++) > -{ > -/* Extract and move data bit to bit DI */ > -dataval = ((datalong & 0x8000)>>13) ? EE_DATA_WRITE : 0; > - > -OUTW(dev, EE_ENB | dataval, SCBeeprom); > -udelay(1); > -OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); > -udelay(1); > -OUTW(dev, EE_ENB | dataval, SCBeeprom); > -udelay(1); > - > -datalong = datalong << 1; /* Adjust significant data bit*/ > -} > - > -/* Finish up command (toggle CS) */ > -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); > -udelay(1); /* delay for more than 250 ns */ > -OUTW(dev, EE_ENB, SCBeeprom); > - > -/* Wait for programming ready (D0 = 1) */ > -tmplong = 10; > -do > -{ > - dataval = INW(dev, SCBeeprom); > - if (dataval & EE_DATA_READ) > - break; > - udelay(1); > -} > -while (-- tmplong); > - > -if (tmplong == 0) > -{ > - printf ("Write i82559 eeprom timed out (100 ms waiting for data > ready.\n"); > - return -1; > -} > - > -/* Terminate the EEPROM access. */ > -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); > - > -return 0; > -} > -#endif > - > static void init_rx_ring (struct eth_device *dev) > { > int i; > diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt > index 3f5e6504e1..2dee446dde 100644 > --- a/scripts/config_whitelist.txt > +++ b/scripts/config_whitelist.txt > @@ -401,7 +401,6 @@ CONFIG_EDB93XX_SDCS1 > CONFIG_EDB93XX_SDCS2 > CONFIG_EDB93XX_SDCS3 > CONFIG_EEPRO100 > -CONFIG_EEPRO100_SROM_WRITE > CONFIG_EFLASH_PROTSECTORS > CONFIG_EHCI_DESC_BIG_ENDIAN > CONFIG_EHCI_HCD_INIT_AFTER_RESET > -- > 2.25.1 > Reviewed-By: Ramon Fried
[PATCH 30/30] net: eepro100: Add Kconfig entries
Add Kconfig entries for the eepro100 driver and convert various boards. Signed-off-by: Marek Vasut --- README | 3 --- configs/MPC8315ERDB_defconfig | 1 + configs/TQM834x_defconfig | 1 + configs/integratorap_cm720t_defconfig | 1 + configs/integratorap_cm920t_defconfig | 1 + configs/integratorap_cm926ejs_defconfig | 1 + configs/integratorap_cm946es_defconfig | 1 + drivers/net/Kconfig | 6 ++ include/configs/MPC8315ERDB.h | 1 - include/configs/MPC8323ERDB.h | 1 - include/configs/MPC832XEMDS.h | 1 - include/configs/MPC8349EMDS.h | 1 - include/configs/MPC8349EMDS_SDRAM.h | 1 - include/configs/MPC837XEMDS.h | 1 - include/configs/MPC8536DS.h | 1 - include/configs/MPC8540ADS.h| 1 - include/configs/MPC8541CDS.h| 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8548CDS.h| 1 - include/configs/MPC8555CDS.h| 1 - include/configs/MPC8560ADS.h| 1 - include/configs/MPC8568MDS.h| 1 - include/configs/MPC8569MDS.h| 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - include/configs/TQM834x.h | 2 -- include/configs/caddy2.h| 1 - include/configs/integratorap.h | 1 - include/configs/sbc8349.h | 1 - include/configs/sbc8548.h | 1 - include/configs/sbc8641d.h | 1 - include/configs/vme8349.h | 1 - scripts/config_whitelist.txt| 1 - 33 files changed, 12 insertions(+), 29 deletions(-) diff --git a/README b/README index c4bb6f3e7b..0e48c2aa7c 100644 --- a/README +++ b/README @@ -889,9 +889,6 @@ The following options need to be configured: Allow generic access to the SPI bus on the Intel 8257x, for example with the "sspi" command. - CONFIG_EEPRO100 - Support for Intel 82557/82559/82559ER chips. - CONFIG_TULIP Support for Digital 2114x chips. diff --git a/configs/MPC8315ERDB_defconfig b/configs/MPC8315ERDB_defconfig index bbb79dff2e..d7981e9855 100644 --- a/configs/MPC8315ERDB_defconfig +++ b/configs/MPC8315ERDB_defconfig @@ -147,6 +147,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=y diff --git a/configs/TQM834x_defconfig b/configs/TQM834x_defconfig index 96ce4de0e6..c29d8a8be1 100644 --- a/configs/TQM834x_defconfig +++ b/configs/TQM834x_defconfig @@ -159,6 +159,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=y diff --git a/configs/integratorap_cm720t_defconfig b/configs/integratorap_cm720t_defconfig index f5f9cb28b3..1b7d672bcb 100644 --- a/configs/integratorap_cm720t_defconfig +++ b/configs/integratorap_cm720t_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/configs/integratorap_cm920t_defconfig b/configs/integratorap_cm920t_defconfig index 8a0ad1f948..116ac015a0 100644 --- a/configs/integratorap_cm920t_defconfig +++ b/configs/integratorap_cm920t_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/configs/integratorap_cm926ejs_defconfig b/configs/integratorap_cm926ejs_defconfig index ab61bf2ef4..9c1a3fa2f5 100644 --- a/configs/integratorap_cm926ejs_defconfig +++ b/configs/integratorap_cm926ejs_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/configs/integratorap_cm946es_defconfig b/configs/integratorap_cm946es_defconfig index 7af5433161..ee9c69bce0 100644 --- a/configs/integratorap_cm946es_defconfig +++ b/configs/integratorap_cm946es_defconfig @@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index f7855c92d3..c3e4510fa1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -192,6 +192,12 @@ config CMD_E1000 used on devices with SPI support you can reprogram the EEPROM from U-Boot. +config EEPRO100 + bool "Intel PRO/100 82557/82559/82559ER Fast Ethernet support" + help + This driver supports Intel(R) PRO/100 82557/82559/8255
[PATCH 29/30] net: eepro100: Add DM support
Add support for driver model to the driver. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 129 - 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index f474832552..45ea3b70fc 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -206,14 +206,21 @@ struct eepro100_priv { /* TX descriptor ring pointer */ int tx_next; int tx_threshold; +#ifdef CONFIG_DM_ETH + struct udevice *devno; +#else struct eth_device dev; pci_dev_t devno; +#endif char*name; void __iomem*iobase; u8 *enetaddr; }; -#if defined(CONFIG_E500) +#if defined(CONFIG_DM_ETH) +#define bus_to_phys(dev, a)dm_pci_mem_to_phys((dev), (a)) +#define phys_to_bus(dev, a)dm_pci_phys_to_mem((dev), (a)) +#elif defined(CONFIG_E500) #define bus_to_phys(dev, a)(a) #define phys_to_bus(dev, a)(a) #else @@ -771,6 +778,7 @@ done: return; } +#ifndef CONFIG_DM_ETH static int eepro100_init(struct eth_device *dev, bd_t *bis) { struct eepro100_priv *priv = @@ -888,3 +896,122 @@ int eepro100_initialize(bd_t *bis) return card_number; } + +#else /* DM_ETH */ +static int eepro100_start(struct udevice *dev) +{ + struct eth_pdata *plat = dev_get_platdata(dev); + struct eepro100_priv *priv = dev_get_priv(dev); + + memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); + + return eepro100_init_common(priv); +} + +static void eepro100_stop(struct udevice *dev) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + eepro100_halt_common(priv); +} + +static int eepro100_send(struct udevice *dev, void *packet, int length) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + int ret; + + ret = eepro100_send_common(priv, packet, length); + + return ret ? 0 : -ETIMEDOUT; +} + +static int eepro100_recv(struct udevice *dev, int flags, uchar **packetp) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + return eepro100_recv_common(priv, packetp); +} + +static int eepro100_free_pkt(struct udevice *dev, uchar *packet, int length) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + eepro100_free_pkt_common(priv); + + return 0; +} + +static int eepro100_read_rom_hwaddr(struct udevice *dev) +{ + struct eepro100_priv *priv = dev_get_priv(dev); + + eepro100_get_hwaddr(priv); + + return 0; +} + +static int eepro100_bind(struct udevice *dev) +{ + static int card_number; + char name[16]; + + sprintf(name, "eepro100#%u", card_number++); + + return device_set_name(dev, name); +} + +static int eepro100_probe(struct udevice *dev) +{ + struct eth_pdata *plat = dev_get_platdata(dev); + struct eepro100_priv *priv = dev_get_priv(dev); + u16 command, status; + u32 iobase; + int ret; + + dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase); + iobase &= ~0xf; + + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase); + + priv->devno = dev; + priv->enetaddr = plat->enetaddr; + priv->iobase = (void __iomem *)bus_to_phys(dev, iobase); + + command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; + dm_pci_write_config16(dev, PCI_COMMAND, command); + dm_pci_read_config16(dev, PCI_COMMAND, &status); + if ((status & command) != command) { + printf("eepro100: Couldn't enable IO access or Bus Mastering\n"); + return -EINVAL; + } + + ret = eepro100_initialize_mii(priv); + if (ret) + return ret; + + dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x20); + + return 0; +} + +static const struct eth_ops eepro100_ops = { + .start = eepro100_start, + .send = eepro100_send, + .recv = eepro100_recv, + .stop = eepro100_stop, + .free_pkt = eepro100_free_pkt, + .read_rom_hwaddr = eepro100_read_rom_hwaddr, +}; + +U_BOOT_DRIVER(eth_eepro100) = { + .name = "eth_eepro100", + .id = UCLASS_ETH, + .bind = eepro100_bind, + .probe = eepro100_probe, + .ops= &eepro100_ops, + .priv_auto_alloc_size = sizeof(struct eepro100_priv), + .platdata_auto_alloc_size = sizeof(struct eth_pdata), +}; + +U_BOOT_PCI_DEVICE(eth_eepro100, supported); +#endif -- 2.25.1
[PATCH 28/30] net: eepro100: Split common parts of non-DM functions out
Split the common code from the non-DM code, so it can be reused by the DM code later. As always, the recv() function had to be split into the actual receiving part and free_pkt part to fit with the DM. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 162 + 1 file changed, 100 insertions(+), 62 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index fb8a68f84c..f474832552 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -202,6 +202,7 @@ struct eepro100_priv { struct eepro100_txfdtx_ring[NUM_TX_DESC]; /* RX descriptor ring pointer */ int rx_next; + u16 rx_stat; /* TX descriptor ring pointer */ int tx_next; int tx_threshold; @@ -535,10 +536,8 @@ static void eepro100_get_hwaddr(struct eepro100_priv *priv) } } -static int eepro100_init(struct eth_device *dev, bd_t *bis) +static int eepro100_init_common(struct eepro100_priv *priv) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); struct eepro100_rxfd *rx_ring = priv->rx_ring; struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *ias_cmd, *cfg_cmd; @@ -628,10 +627,9 @@ done: return status; } -static int eepro100_send(struct eth_device *dev, void *packet, int length) +static int eepro100_send_common(struct eepro100_priv *priv, + void *packet, int length) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *desc; int ret, status = -1; @@ -672,82 +670,82 @@ done: return status; } -static int eepro100_recv(struct eth_device *dev) +static int eepro100_recv_common(struct eepro100_priv *priv, uchar **packetp) { - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); struct eepro100_rxfd *rx_ring = priv->rx_ring; struct eepro100_rxfd *desc; - int rx_prev, length = 0; - u16 status, stat; + int length; + u16 status; - stat = INW(priv, SCB_STATUS); - OUTW(priv, stat & SCB_STATUS_RNR, SCB_STATUS); + priv->rx_stat = INW(priv, SCB_STATUS); + OUTW(priv, priv->rx_stat & SCB_STATUS_RNR, SCB_STATUS); - for (;;) { - desc = &rx_ring[priv->rx_next]; - invalidate_dcache_range((unsigned long)desc, - (unsigned long)desc + sizeof(*desc)); - status = le16_to_cpu(desc->status); + desc = &rx_ring[priv->rx_next]; + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); + status = le16_to_cpu(desc->status); + + if (!(status & RFD_STATUS_C)) + return 0; + + /* Valid frame status. */ + if (status & RFD_STATUS_OK) { + /* A valid frame received. */ + length = le32_to_cpu(desc->count) & 0x3fff; + /* Pass the packet up to the protocol layers. */ + *packetp = desc->data; + return length; + } - if (!(status & RFD_STATUS_C)) - break; + /* There was an error. */ + printf("RX error status = 0x%08X\n", status); + return -EINVAL; +} - /* Valid frame status. */ - if ((status & RFD_STATUS_OK)) { - /* A valid frame received. */ - length = le32_to_cpu(desc->count) & 0x3fff; +static void eepro100_free_pkt_common(struct eepro100_priv *priv) +{ + struct eepro100_rxfd *rx_ring = priv->rx_ring; + struct eepro100_rxfd *desc; + int rx_prev; - /* Pass the packet up to the protocol layers. */ - net_process_received_packet((u8 *)desc->data, length); - } else { - /* There was an error. */ - printf("RX error status = 0x%08X\n", status); - } + desc = &rx_ring[priv->rx_next]; - desc->control = cpu_to_le16(RFD_CONTROL_S); - desc->status = 0; - desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16); - flush_dcache_range((unsigned long)desc, - (unsigned long)desc + sizeof(*desc)); + desc->control = cpu_to_le16(RFD_CONTROL_S); + desc->status = 0; + desc->count = cpu_to_le32(PKTSIZE_ALIGN << 16); + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); - rx_prev = (priv->rx_next + NUM_RX_DESC - 1) % NUM_RX_DESC; - desc = &rx_ring[rx_prev]; - desc->control = 0; -
[PATCH 27/30] net: eepro100: Drop bd_t pointer from read_hw_addr()
The pointer is unused, so drop it. Rename the function to start with the eepro100_ prefix. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index ed6bbd5cf8..fb8a68f84c 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -512,7 +512,7 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr(struct eepro100_priv *priv, bd_t *bis) +static void eepro100_get_hwaddr(struct eepro100_priv *priv) { u16 sum = 0; int i, j; @@ -845,7 +845,7 @@ int eepro100_initialize(bd_t *bis) udelay(10 * 1000); - read_hw_addr(priv, bis); + eepro100_get_hwaddr(priv); } return card_number; -- 2.25.1
[PATCH 24/30] net: eepro100: Pass device private data around
This patch replaces the various uses of struct eth_device for accessing device private data with struct eepro100_priv, which is compatible both with DM and non-DM operation. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 264 ++--- 1 file changed, 140 insertions(+), 124 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 2c25307002..1c33ec3da2 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -203,6 +203,10 @@ static const char i82558_config_cmd[] = { struct eepro100_priv { struct eth_device dev; + pci_dev_t devno; + char*name; + void __iomem*iobase; + u8 *enetaddr; }; #if defined(CONFIG_E500) @@ -213,40 +217,40 @@ struct eepro100_priv { #define phys_to_bus(dev, a)pci_phys_to_mem((dev), (a)) #endif -static int INW(struct eth_device *dev, u_long addr) +static int INW(struct eepro100_priv *priv, u_long addr) { - return le16_to_cpu(readw(addr + (void *)dev->iobase)); + return le16_to_cpu(readw(addr + priv->iobase)); } -static void OUTW(struct eth_device *dev, int command, u_long addr) +static void OUTW(struct eepro100_priv *priv, int command, u_long addr) { - writew(cpu_to_le16(command), addr + (void *)dev->iobase); + writew(cpu_to_le16(command), addr + priv->iobase); } -static void OUTL(struct eth_device *dev, int command, u_long addr) +static void OUTL(struct eepro100_priv *priv, int command, u_long addr) { - writel(cpu_to_le32(command), addr + (void *)dev->iobase); + writel(cpu_to_le32(command), addr + priv->iobase); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static int INL(struct eth_device *dev, u_long addr) +static int INL(struct eepro100_priv *priv, u_long addr) { - return le32_to_cpu(readl(addr + (void *)dev->iobase)); + return le32_to_cpu(readl(addr + priv->iobase)); } -static int get_phyreg(struct eth_device *dev, unsigned char addr, +static int get_phyreg(struct eepro100_priv *priv, unsigned char addr, unsigned char reg, unsigned short *value) { - int cmd; int timeout = 50; + int cmd; /* read requested data */ cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL(dev, cmd, SCB_CTRL_MDI); + OUTL(priv, cmd, SCB_CTRL_MDI); do { udelay(1000); - cmd = INL(dev, SCB_CTRL_MDI); + cmd = INL(priv, SCB_CTRL_MDI); } while (!(cmd & (1 << 28)) && (--timeout)); if (timeout == 0) @@ -257,17 +261,17 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, return 0; } -static int set_phyreg(struct eth_device *dev, unsigned char addr, +static int set_phyreg(struct eepro100_priv *priv, unsigned char addr, unsigned char reg, unsigned short value) { - int cmd; int timeout = 50; + int cmd; /* write requested data */ cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL(dev, cmd | value, SCB_CTRL_MDI); + OUTL(priv, cmd | value, SCB_CTRL_MDI); - while (!(INL(dev, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) + while (!(INL(priv, SCB_CTRL_MDI) & (1 << 28)) && (--timeout)) udelay(1000); if (timeout == 0) @@ -280,49 +284,45 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, * Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr(const char *devname, -unsigned char addr) +static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr) { - struct eth_device *dev; - unsigned short value; - unsigned char model; - - dev = eth_get_dev_by_name(devname); - if (!dev) { - printf("%s: no such device\n", devname); - return NULL; - } + unsigned short value, model; + int ret; /* read id2 register */ - if (get_phyreg(dev, addr, MII_PHYSID2, &value) != 0) { - printf("%s: mii read timeout!\n", devname); - return NULL; + ret = get_phyreg(priv, addr, MII_PHYSID2, &value); + if (ret) { + printf("%s: mii read timeout!\n", priv->name); + return ret; } /* get model */ - model = (unsigned char)((value >> 4) & 0x003f); - - if (model == 0) { - printf("%s: no PHY at address %d\n", devname, addr); - return NULL; + model = (value >> 4) & 0x003f; + if (!model) { + printf("%s: no PHY at address %d\n", priv->name, addr); + return -EINVAL; } - return dev; + return 0; } static int eepro100_miiphy_read(
[PATCH 26/30] net: eepro100: Add RX/TX rings into the private data
The RX/TX DMA descriptor rings are per-device-instance private data, so move them into the private data. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 59 +- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 78dedbdcc9..ed6bbd5cf8 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -183,12 +183,6 @@ struct descriptor {/* A generic descriptor. */ #define TOUT_LOOP 100 -static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX descriptor ring */ -static struct eepro100_txfd tx_ring[NUM_TX_DESC]; /* TX descriptor ring */ -static int rx_next;/* RX descriptor ring pointer */ -static int tx_next;/* TX descriptor ring pointer */ -static int tx_threshold; - /* * The parameters for a CmdConfigure operation. * There are so many options that it would be difficult to document @@ -202,6 +196,15 @@ static const char i82558_config_cmd[] = { }; struct eepro100_priv { + /* RX descriptor ring */ + struct eepro100_rxfdrx_ring[NUM_RX_DESC]; + /* TX descriptor ring */ + struct eepro100_txfdtx_ring[NUM_TX_DESC]; + /* RX descriptor ring pointer */ + int rx_next; + /* TX descriptor ring pointer */ + int tx_next; + int tx_threshold; struct eth_device dev; pci_dev_t devno; char*name; @@ -348,6 +351,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, static void init_rx_ring(struct eepro100_priv *priv) { + struct eepro100_rxfd *rx_ring = priv->rx_ring; int i; for (i = 0; i < NUM_RX_DESC; i++) { @@ -366,13 +370,15 @@ static void init_rx_ring(struct eepro100_priv *priv) (unsigned long)rx_ring + (sizeof(*rx_ring) * NUM_RX_DESC)); - rx_next = 0; + priv->rx_next = 0; } static void purge_tx_ring(struct eepro100_priv *priv) { - tx_next = 0; - tx_threshold = 0x01208000; + struct eepro100_txfd *tx_ring = priv->tx_ring; + + priv->tx_next = 0; + priv->tx_threshold = 0x01208000; memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); flush_dcache_range((unsigned long)tx_ring, @@ -533,6 +539,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) { struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); + struct eepro100_rxfd *rx_ring = priv->rx_ring; + struct eepro100_txfd *tx_ring = priv->tx_ring; struct eepro100_txfd *ias_cmd, *cfg_cmd; int ret, status = -1; int tx_cur; @@ -569,20 +577,20 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[rx_next]), + OUTL(priv, phys_to_bus(priv->devno, (u32)&rx_ring[priv->rx_next]), SCB_POINTER); OUTW(priv, SCB_M | RUC_START, SCB_CMD); /* Send the Configure frame */ - tx_cur = tx_next; - tx_next = ((tx_next + 1) % NUM_TX_DESC); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC); cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; cfg_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); @@ -595,15 +603,15 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) } /* Send the Individual Address Setup frame */ - tx_cur = tx_next; - tx_next = ((tx_next + 1) % NUM_TX_DESC); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next + 1) % NUM_TX_DESC); ias_cmd = &tx_ring[tx_cur]; ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; ias_cmd->link = cpu_to_le32(phys_to_bus(priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); memcpy(((struct descriptor *)ias_cmd)->params, priv->enetaddr, 6); @@ -624,6 +632,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) { struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); + struct eepro100_txfd *tx_ri
[PATCH 20/30] net: eepro100: Fix EE_*_CMD macros
Those macros depended on specific variable names to be declared at their usage sites, fix this by adding an argument to those macros and also protect the argument with braces. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 861d39cf9f..a8d617c7e8 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -96,10 +96,10 @@ #define EE_DATA_BITS 16 /* The EEPROM commands include the alway-set leading bit. */ -#define EE_EWENB_CMD (4 << addr_len) -#define EE_WRITE_CMD (5 << addr_len) -#define EE_READ_CMD(6 << addr_len) -#define EE_ERASE_CMD (7 << addr_len) +#define EE_EWENB_CMD(addr_len) (4 << (addr_len)) +#define EE_WRITE_CMD(addr_len) (5 << (addr_len)) +#define EE_READ_CMD(addr_len) (6 << (addr_len)) +#define EE_ERASE_CMD(addr_len) (7 << (addr_len)) /* Receive frame descriptors. */ struct eepro100_rxfd { @@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, static int read_eeprom(struct eth_device *dev, int location, int addr_len) { unsigned short retval = 0; - int read_cmd = location | EE_READ_CMD; + int read_cmd = location | EE_READ_CMD(addr_len); int i; OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM); -- 2.25.1
[PATCH 25/30] net: eepro100: Pass device private data into mdiobus
Instead of doing ethernet device lookup by name every time there is an MDIO access, pass the driver private data via mdiobus priv to the MDIO bus accessors. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 1c33ec3da2..78dedbdcc9 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr) static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg) { - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); + struct eepro100_priv *priv = bus->priv; unsigned short value = 0; int ret; @@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, int reg, u16 value) { - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); + struct eepro100_priv *priv = bus->priv; int ret; ret = verify_phyaddr(priv, addr); @@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv *priv) strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write; + mdiodev->priv = priv; ret = mdio_register(mdiodev); if (ret < 0) { -- 2.25.1
[PATCH 23/30] net: eepro100: Introduce device private data
Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 532d7aa649..2c25307002 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -201,6 +201,10 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; +struct eepro100_priv { + struct eth_device dev; +}; + #if defined(CONFIG_E500) #define bus_to_phys(dev, a)(a) #define phys_to_bus(dev, a)(a) @@ -751,6 +755,7 @@ done: int eepro100_initialize(bd_t *bis) { + struct eepro100_priv *priv; struct eth_device *dev; int card_number = 0; u32 iobase, status; @@ -785,11 +790,12 @@ int eepro100_initialize(bd_t *bis) continue; } - dev = calloc(1, sizeof(*dev)); - if (!dev) { + priv = calloc(1, sizeof(*priv)); + if (!priv) { printf("eepro100: Can not allocate memory\n"); break; } + dev = &priv->dev; sprintf(dev->name, "i82559#%d", card_number); dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ @@ -804,7 +810,7 @@ int eepro100_initialize(bd_t *bis) ret = eepro100_initialize_mii(dev); if (ret) { eth_unregister(dev); - free(dev); + free(priv); return ret; } -- 2.25.1
[PATCH 22/30] net: eepro100: Pass PCI BDF into bus_to_phys()/phys_to_bus()
This is a trick in preparation for adding DM support. By passing in the PCI BDF into the bus_to_phys()/phys_to_bus() macros and calling that dev, we can substitute dev with udevice when DM support lands and do minor adjustment to the macros to support both DM and non-DM operation. No functional change. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 36 ++-- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 4446251e11..532d7aa649 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -202,11 +202,11 @@ static const char i82558_config_cmd[] = { }; #if defined(CONFIG_E500) -#define bus_to_phys(a) (a) -#define phys_to_bus(a) (a) +#define bus_to_phys(dev, a)(a) +#define phys_to_bus(dev, a)(a) #else -#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a) -#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) +#define bus_to_phys(dev, a)pci_mem_to_phys((dev), (a)) +#define phys_to_bus(dev, a)pci_phys_to_mem((dev), (a)) #endif static int INW(struct eth_device *dev, u_long addr) @@ -352,7 +352,8 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i == NUM_RX_DESC - 1) ? cpu_to_le16 (RFD_CONTROL_S) : 0; rx_ring[i].link = - cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % + cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&rx_ring[(i + 1) % NUM_RX_DESC])); rx_ring[i].rx_buf_addr = 0x; rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); @@ -401,7 +402,7 @@ static int eepro100_txcmd_send(struct eth_device *dev, if (!wait_for_eepro100(dev)) return -ETIMEDOUT; - OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER); + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)desc), SCB_POINTER); OUTW(dev, SCB_M | CU_START, SCB_CMD); while (true) { @@ -562,7 +563,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, (u32)&rx_ring[rx_next]), +SCB_POINTER); OUTW(dev, SCB_M | RUC_START, SCB_CMD); /* Send the Configure frame */ @@ -573,7 +575,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; - cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); + cfg_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&tx_ring[tx_next])); memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); @@ -593,7 +596,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; - ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); + ias_cmd->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&tx_ring[tx_next])); memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6); @@ -629,9 +633,12 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status = 0; desc->count = cpu_to_le32(tx_threshold); - desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); - desc->tx_desc_addr = cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet)); + desc->link = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, +(u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((pci_dev_t)dev->priv, +(u_long)packet)); desc->tx_buf_size0 = cpu_to_le32(length); ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); @@ -706,7 +713,8 @@ static int eepro100_recv(struct eth_device *dev) } /* RX ring cache was already flushed in init_rx_ring() */ - OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); + OUTL(dev, phys_to_bus((pci_dev_t)dev->priv, +
[PATCH 19/30] net: eepro100: Factor out MII registration
Pull the MII registration code into a separate function. Moreover, properly free memory in case any of the registration or allocation functions fail, so this fixes an existing memleak. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 56 +- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 8fa665743a..861d39cf9f 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -464,6 +464,36 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) return retval; } +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) +static int eepro100_initialize_mii(struct eth_device *dev) +{ + /* register mii command access routines */ + struct mii_dev *mdiodev; + int ret; + + mdiodev = mdio_alloc(); + if (!mdiodev) + return -ENOMEM; + + strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; + + ret = mdio_register(mdiodev); + if (ret < 0) { + mdio_free(mdiodev); + return ret; + } + + return 0; +} +#else +static int eepro100_initialize_mii(struct eth_device *dev) +{ + return 0; +} +#endif + static struct pci_device_id supported[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) }, @@ -713,11 +743,12 @@ done: int eepro100_initialize(bd_t *bis) { - pci_dev_t devno; - int card_number = 0; struct eth_device *dev; + int card_number = 0; u32 iobase, status; + pci_dev_t devno; int idx = 0; + int ret; while (1) { /* Find PCI device */ @@ -762,21 +793,12 @@ int eepro100_initialize(bd_t *bis) eth_register(dev); -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) - /* register mii command access routines */ - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - - if (!mdiodev) - return -ENOMEM; - strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval = mdio_register(mdiodev); - if (retval < 0) - return retval; -#endif + ret = eepro100_initialize_mii(dev); + if (ret) { + eth_unregister(dev); + free(dev); + return ret; + } card_number++; -- 2.25.1
[PATCH 14/30] net: eepro100: Add cache management
Add cache invalidation and flushes wherever the DMA descriptors are written or read, otherwise this driver cannot work reliably on any systems where caches are enabled. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 65 +- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 03ba9a41a5..89bfcfba0a 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -459,6 +460,9 @@ static int eepro100_txcmd_send(struct eth_device *dev, u16 rstat; int i = 0; + flush_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); + if (!wait_for_eepro100(dev)) return -ETIMEDOUT; @@ -466,6 +470,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, OUTW(dev, SCB_M | CU_START, SCB_CMD); while (true) { + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); rstat = le16_to_cpu(desc->status); if (rstat & CONFIG_SYS_STATUS_C) break; @@ -476,6 +482,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, } } + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); rstat = le16_to_cpu(desc->status); if (!(rstat & CONFIG_SYS_STATUS_OK)) { @@ -523,6 +531,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) goto done; } + /* RX ring cache was already flushed in init_rx_ring() */ OUTL(dev, phys_to_bus((u32)&rx_ring[rx_next]), SCB_POINTER); OUTW(dev, SCB_M | RUC_START, SCB_CMD); @@ -573,6 +582,7 @@ done: static int eepro100_send(struct eth_device *dev, void *packet, int length) { + struct eepro100_txfd *desc; int ret, status = -1; int tx_cur; @@ -584,17 +594,15 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) tx_cur = tx_next; tx_next = (tx_next + 1) % NUM_TX_DESC; - tx_ring[tx_cur].command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | - TXCB_CMD_S | TXCB_CMD_EL); - tx_ring[tx_cur].status = 0; - tx_ring[tx_cur].count = cpu_to_le32 (tx_threshold); - tx_ring[tx_cur].link = - cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); - tx_ring[tx_cur].tx_desc_addr = - cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_cur].tx_buf_addr0)); - tx_ring[tx_cur].tx_buf_addr0 = - cpu_to_le32 (phys_to_bus((u_long)packet)); - tx_ring[tx_cur].tx_buf_size0 = cpu_to_le32 (length); + desc = &tx_ring[tx_cur]; + desc->command = cpu_to_le16(TXCB_CMD_TRANSMIT | TXCB_CMD_SF | + TXCB_CMD_S | TXCB_CMD_EL); + desc->status = 0; + desc->count = cpu_to_le32(tx_threshold); + desc->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); + desc->tx_desc_addr = cpu_to_le32(phys_to_bus((u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus((u_long)packet)); + desc->tx_buf_size0 = cpu_to_le32(length); ret = eepro100_txcmd_send(dev, &tx_ring[tx_cur]); if (ret) { @@ -612,14 +620,18 @@ done: static int eepro100_recv(struct eth_device *dev) { - u16 status, stat; + struct eepro100_rxfd *desc; int rx_prev, length = 0; + u16 status, stat; stat = INW(dev, SCB_STATUS); OUTW(dev, stat & SCB_STATUS_RNR, SCB_STATUS); for (;;) { - status = le16_to_cpu(rx_ring[rx_next].status); + desc = &rx_ring[rx_next]; + invalidate_dcache_range((unsigned long)desc, + (unsigned long)desc + sizeof(*desc)); + status = le16_to_cpu(desc->status); if (!(status & RFD_STATUS_C)) break; @@ -627,22 +639,26 @@ static int eepro100_recv(struct eth_device *dev) /* Valid frame status. */ if ((status & RFD_STATUS_OK)) { /* A valid frame received. */ - length = le32_to_cpu(rx_ring[rx_next].count) & 0x3fff; + length = le32_to_cpu(desc->count) & 0x3fff; /* Pass the packet up to the protocol layers. */ - net_process_received_packet((u8 *)rx_ring[rx_next].data, - length); + net_process_received_packet((u8 *)desc->data, length); } else { /* There was an error. */ printf("RX error status = 0x%08X\n", status);
[PATCH 21/30] net: eepro100: Drop inline keyword
Drop the inline keyword from the static functions, the compiler has a much better overview and can decide how to inline those functions much better. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index a8d617c7e8..4446251e11 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -209,23 +209,23 @@ static const char i82558_config_cmd[] = { #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) #endif -static inline int INW(struct eth_device *dev, u_long addr) +static int INW(struct eth_device *dev, u_long addr) { return le16_to_cpu(readw(addr + (void *)dev->iobase)); } -static inline void OUTW(struct eth_device *dev, int command, u_long addr) +static void OUTW(struct eth_device *dev, int command, u_long addr) { writew(cpu_to_le16(command), addr + (void *)dev->iobase); } -static inline void OUTL(struct eth_device *dev, int command, u_long addr) +static void OUTL(struct eth_device *dev, int command, u_long addr) { writel(cpu_to_le32(command), addr + (void *)dev->iobase); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static inline int INL(struct eth_device *dev, u_long addr) +static int INL(struct eth_device *dev, u_long addr) { return le32_to_cpu(readl(addr + (void *)dev->iobase)); } -- 2.25.1
[PATCH 17/30] net: eepro100: Use PCI_DEVICE() to define PCI device compat list
Use this macro to fully fill the PCI device ID table. This is mandatory for the DM PCI support, which checks all the fields. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 9db9367e95..74b09e9afd 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -465,10 +465,10 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) } static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, - {} + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER) }, + { } }; static void read_hw_addr(struct eth_device *dev, bd_t *bis) -- 2.25.1
[PATCH 15/30] net: eepro100: Remove volatile misuse
Remove all the remaining use of the 'volatile' keyword, as this is no longer required. All the accesses which might have needed this use of 'volatile' have been repaired properly. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 89bfcfba0a..f3bcb0dfe4 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -103,13 +103,13 @@ /* Receive frame descriptors. */ struct eepro100_rxfd { - volatile u16 status; - volatile u16 control; - volatile u32 link; /* struct eepro100_rxfd * */ - volatile u32 rx_buf_addr; /* void * */ - volatile u32 count; + u16 status; + u16 control; + u32 link; /* struct eepro100_rxfd * */ + u32 rx_buf_addr;/* void * */ + u32 count; - volatile u8 data[PKTSIZE_ALIGN]; + u8 data[PKTSIZE_ALIGN]; }; #define RFD_STATUS_C 0x8000 /* completion of received frame */ @@ -136,17 +136,17 @@ struct eepro100_rxfd { #define RFD_RX_TCO 0x0001 /* TCO indication */ /* Transmit frame descriptors */ -struct eepro100_txfd { /* Transmit frame descriptor set. */ - volatile u16 status; - volatile u16 command; - volatile u32 link; /* void * */ - volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */ - volatile s32 count; - - volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */ - volatile s32 tx_buf_size0; /* Length of Tx frame. */ - volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */ - volatile s32 tx_buf_size1; /* Length of Tx frame. */ +struct eepro100_txfd { /* Transmit frame descriptor set. */ + u16 status; + u16 command; + u32 link; /* void * */ + u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */ + s32 count; + + u32 tx_buf_addr0; /* void *, frame to be transmitted. */ + s32 tx_buf_size0; /* Length of Tx frame. */ + u32 tx_buf_addr1; /* void *, frame to be transmitted. */ + s32 tx_buf_size1; /* Length of Tx frame. */ }; #define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */ @@ -160,10 +160,10 @@ struct eepro100_txfd {/* Transmit frame descriptor set. */ #define TXCB_COUNT_EOF 0x8000 /* The Speedo3 Rx and Tx frame/buffer descriptors. */ -struct descriptor {/* A generic descriptor. */ - volatile u16 status; - volatile u16 command; - volatile u32 link; /* struct descriptor * */ +struct descriptor {/* A generic descriptor. */ + u16 status; + u16 command; + u32 link; /* struct descriptor * */ unsigned char params[0]; }; -- 2.25.1
[PATCH 13/30] net: eepro100: Factor out tx_ring command issuing
This code is replicated in the driver thrice almost verbatim, factor it out into a separate function and clean it up. No functional change. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 124 ++--- 1 file changed, 53 insertions(+), 71 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 6fb9192e81..03ba9a41a5 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -453,11 +453,44 @@ int eepro100_initialize(bd_t *bis) return card_number; } +static int eepro100_txcmd_send(struct eth_device *dev, + struct eepro100_txfd *desc) +{ + u16 rstat; + int i = 0; + + if (!wait_for_eepro100(dev)) + return -ETIMEDOUT; + + OUTL(dev, phys_to_bus((u32)desc), SCB_POINTER); + OUTW(dev, SCB_M | CU_START, SCB_CMD); + + while (true) { + rstat = le16_to_cpu(desc->status); + if (rstat & CONFIG_SYS_STATUS_C) + break; + + if (i++ >= TOUT_LOOP) { + printf("%s: Tx error buffer not ready\n", dev->name); + return -EINVAL; + } + } + + rstat = le16_to_cpu(desc->status); + + if (!(rstat & CONFIG_SYS_STATUS_OK)) { + printf("TX error status = 0x%08X\n", rstat); + return -EIO; + } + + return 0; +} + static int eepro100_init(struct eth_device *dev, bd_t *bis) { - int i, status = -1; + struct eepro100_txfd *ias_cmd, *cfg_cmd; + int ret, status = -1; int tx_cur; - struct descriptor *ias_cmd, *cfg_cmd; /* Reset the ethernet controller */ OUTL(dev, I82559_SELECTIVE_RESET, SCB_PORT); @@ -497,35 +530,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next + 1) % NUM_TX_DESC); - cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; + cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); - memcpy(cfg_cmd->params, i82558_config_cmd, + memcpy(((struct descriptor *)cfg_cmd)->params, i82558_config_cmd, sizeof(i82558_config_cmd)); - if (!wait_for_eepro100(dev)) { - printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); - goto done; - } - - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); - OUTW(dev, SCB_M | CU_START, SCB_CMD); - - for (i = 0; -!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); -i++) { - if (i >= TOUT_LOOP) { - printf("%s: Tx error buffer not ready\n", dev->name); - goto done; - } - } - - if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + ret = eepro100_txcmd_send(dev, cfg_cmd); + if (ret) { + if (ret == -ETIMEDOUT) + printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); goto done; } @@ -533,36 +550,18 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next + 1) % NUM_TX_DESC); - ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; + ias_cmd = &tx_ring[tx_cur]; ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); - memcpy(ias_cmd->params, dev->enetaddr, 6); - - /* Tell the adapter where the TX ring is located. */ - if (!wait_for_eepro100(dev)) { - printf("Error: Can not reset ethernet controller.\n"); - goto done; - } - - OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCB_POINTER); - OUTW(dev, SCB_M | CU_START, SCB_CMD); - - for (i = 0; -!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); -i++) { - if (i >= TOUT_LOOP) { - printf("%s: Tx error buffer not ready\n", - dev->name); - goto done; - } - } + memcpy(((struct descriptor *)ias_cmd)->params, dev->enetaddr, 6); - if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { - printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + ret = eepro100_txcmd_send(dev, ias_cmd); + if (ret) { +
[PATCH 16/30] net: eepro100: Reorder functions in the driver
Move the functions around in the driver to prepare it for DM conversion. Drop forward declarations which are not necessary anymore. No functional change. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 330 - 1 file changed, 160 insertions(+), 170 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index f3bcb0dfe4..9db9367e95 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -5,13 +5,13 @@ */ #include +#include #include #include +#include #include #include -#include #include -#include #include /* Ethernet chip registers. */ @@ -201,16 +201,6 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring(struct eth_device *dev); -static void purge_tx_ring(struct eth_device *dev); - -static void read_hw_addr(struct eth_device *dev, bd_t *bis); - -static int eepro100_init(struct eth_device *dev, bd_t *bis); -static int eepro100_send(struct eth_device *dev, void *packet, int length); -static int eepro100_recv(struct eth_device *dev); -static void eepro100_halt(struct eth_device *dev); - #if defined(CONFIG_E500) #define bus_to_phys(a) (a) #define phys_to_bus(a) (a) @@ -353,105 +343,50 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, #endif -/* Wait for the chip get the command. */ -static int wait_for_eepro100(struct eth_device *dev) +static void init_rx_ring(struct eth_device *dev) { int i; - for (i = 0; INW(dev, SCB_CMD) & (CU_CMD_MASK | RU_CMD_MASK); i++) { - if (i >= TOUT_LOOP) - return 0; + for (i = 0; i < NUM_RX_DESC; i++) { + rx_ring[i].status = 0; + rx_ring[i].control = (i == NUM_RX_DESC - 1) ? +cpu_to_le16 (RFD_CONTROL_S) : 0; + rx_ring[i].link = + cpu_to_le32(phys_to_bus((u32)&rx_ring[(i + 1) % + NUM_RX_DESC])); + rx_ring[i].rx_buf_addr = 0x; + rx_ring[i].count = cpu_to_le32(PKTSIZE_ALIGN << 16); } - return 1; -} + flush_dcache_range((unsigned long)rx_ring, + (unsigned long)rx_ring + + (sizeof(*rx_ring) * NUM_RX_DESC)); -static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559}, - {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER}, - {} -}; + rx_next = 0; +} -int eepro100_initialize(bd_t *bis) +static void purge_tx_ring(struct eth_device *dev) { - pci_dev_t devno; - int card_number = 0; - struct eth_device *dev; - u32 iobase, status; - int idx = 0; - - while (1) { - /* Find PCI device */ - devno = pci_find_devices(supported, idx++); - if (devno < 0) - break; - - pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); - iobase &= ~0xf; - - debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", - iobase); - - pci_write_config_dword(devno, PCI_COMMAND, - PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); - - /* Check if I/O accesses and Bus Mastering are enabled. */ - pci_read_config_dword(devno, PCI_COMMAND, &status); - if (!(status & PCI_COMMAND_MEMORY)) { - printf("Error: Can not enable MEM access.\n"); - continue; - } - - if (!(status & PCI_COMMAND_MASTER)) { - printf("Error: Can not enable Bus Mastering.\n"); - continue; - } - - dev = (struct eth_device *)malloc(sizeof(*dev)); - if (!dev) { - printf("eepro100: Can not allocate memory\n"); - break; - } - memset(dev, 0, sizeof(*dev)); - - sprintf(dev->name, "i82559#%d", card_number); - dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ - dev->iobase = bus_to_phys(iobase); - dev->init = eepro100_init; - dev->halt = eepro100_halt; - dev->send = eepro100_send; - dev->recv = eepro100_recv; - - eth_register(dev); - -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) - /* register mii command access routines */ - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - - if (!mdiodev) - return -ENOMEM; - strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100
[PATCH 11/30] net: eepro100: Use standard I/O accessors
The current eepro100 driver accesses its memory mapped registers directly instead of using the standard I/O accessors. This can cause problems on some systems as the accesses can get out of order. So convert the direct volatile dereferences to use the normal in/out macros. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index d3ced08761..5d11665fdc 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -220,23 +220,23 @@ static void eepro100_halt(struct eth_device *dev); static inline int INW(struct eth_device *dev, u_long addr) { - return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); + return le16_to_cpu(readw(addr + (void *)dev->iobase)); } static inline void OUTW(struct eth_device *dev, int command, u_long addr) { - *(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command); + writew(cpu_to_le16(command), addr + (void *)dev->iobase); } static inline void OUTL(struct eth_device *dev, int command, u_long addr) { - *(volatile u32 *)((addr + (u_long)dev->iobase)) = cpu_to_le32(command); + writel(cpu_to_le32(command), addr + (void *)dev->iobase); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) static inline int INL(struct eth_device *dev, u_long addr) { - return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); + return le32_to_cpu(readl(addr + (void *)dev->iobase)); } static int get_phyreg(struct eth_device *dev, unsigned char addr, -- 2.25.1
[PATCH 12/30] net: eepro100: Replace purge_tx_ring() with memset()
This function zeroes-out all the descriptors in the TX ring, use memset() instead. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 16 +--- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 5d11665fdc..6fb9192e81 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -767,23 +767,9 @@ static void init_rx_ring(struct eth_device *dev) static void purge_tx_ring(struct eth_device *dev) { - int i; - tx_next = 0; tx_threshold = 0x01208000; - - for (i = 0; i < NUM_TX_DESC; i++) { - tx_ring[i].status = 0; - tx_ring[i].command = 0; - tx_ring[i].link = 0; - tx_ring[i].tx_desc_addr = 0; - tx_ring[i].count = 0; - - tx_ring[i].tx_buf_addr0 = 0; - tx_ring[i].tx_buf_size0 = 0; - tx_ring[i].tx_buf_addr1 = 0; - tx_ring[i].tx_buf_size1 = 0; - } + memset(tx_ring, 0, sizeof(*tx_ring) * NUM_TX_DESC); } static void read_hw_addr(struct eth_device *dev, bd_t *bis) -- 2.25.1
[PATCH 18/30] net: eepro100: Switch from malloc()+memset() to calloc()
Replace malloc()+memset() combination with calloc(), no functional change. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 74b09e9afd..8fa665743a 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -746,12 +746,11 @@ int eepro100_initialize(bd_t *bis) continue; } - dev = (struct eth_device *)malloc(sizeof(*dev)); + dev = calloc(1, sizeof(*dev)); if (!dev) { printf("eepro100: Can not allocate memory\n"); break; } - memset(dev, 0, sizeof(*dev)); sprintf(dev->name, "i82559#%d", card_number); dev->priv = (void *)devno; /* this have to come before bus_to_phys() */ -- 2.25.1
[PATCH 08/30] net: eepro100: Fix indented label
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 2aad124ae5..e5bc90f52c 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -566,7 +566,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) status = 0; - Done: +Done: return status; } @@ -623,7 +623,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) status = length; - Done: +Done: return status; } @@ -680,7 +680,7 @@ static int eepro100_recv(struct eth_device *dev) OUTW(dev, SCB_M | RUC_START, SCBCmd); } - Done: +Done: return length; } @@ -707,7 +707,7 @@ static void eepro100_halt(struct eth_device *dev) OUTL(dev, 0, SCBPointer); OUTW(dev, SCB_M | CU_ADDR_LOAD, SCBCmd); - Done: +Done: return; } -- 2.25.1
[PATCH 09/30] net: eepro100: Fix remaining checkpatch issues
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl -f --fix --fix-inplace drivers/net/eepro100.c This fixes all the remaining errors except a couple of comments which are longer than 80 characters, all the volatile misuse and all the camelcase, that needs a separate patch. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 45 ++ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index e5bc90f52c..45c013607e 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -293,7 +293,7 @@ static struct eth_device *verify_phyaddr(const char *devname, unsigned char model; dev = eth_get_dev_by_name(devname); - if (dev == NULL) { + if (!dev) { printf("%s: no such device\n", devname); return NULL; } @@ -322,7 +322,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad, struct eth_device *dev; dev = verify_phyaddr(bus->name, addr); - if (dev == NULL) + if (!dev) return -1; if (get_phyreg(dev, addr, reg, &value) != 0) { @@ -339,7 +339,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad, struct eth_device *dev; dev = verify_phyaddr(bus->name, addr); - if (dev == NULL) + if (!dev) return -1; if (set_phyreg(dev, addr, reg, value) != 0) { @@ -392,9 +392,8 @@ int eepro100_initialize(bd_t *bis) debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", iobase); - pci_write_config_dword(devno, - PCI_COMMAND, - PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + pci_write_config_dword(devno, PCI_COMMAND, + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); /* Check if I/O accesses and Bus Mastering are enabled. */ pci_read_config_dword(devno, PCI_COMMAND, &status); @@ -408,7 +407,7 @@ int eepro100_initialize(bd_t *bis) continue; } - dev = (struct eth_device *)malloc(sizeof *dev); + dev = (struct eth_device *)malloc(sizeof(*dev)); if (!dev) { printf("eepro100: Can not allocate memory\n"); break; @@ -429,6 +428,7 @@ int eepro100_initialize(bd_t *bis) /* register mii command access routines */ int retval; struct mii_dev *mdiodev = mdio_alloc(); + if (!mdiodev) return -ENOMEM; strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); @@ -453,7 +453,6 @@ int eepro100_initialize(bd_t *bis) return card_number; } - static int eepro100_init(struct eth_device *dev, bd_t *bis) { int i, status = -1; @@ -499,9 +498,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next + 1) % NUM_TX_DESC); cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; - cfg_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_CONFIGURE)); + cfg_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | + CONFIG_SYS_CMD_CONFIGURE); cfg_cmd->status = 0; - cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); + cfg_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); memcpy(cfg_cmd->params, i82558_config_cmd, sizeof(i82558_config_cmd)); @@ -534,9 +534,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next + 1) % NUM_TX_DESC); ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; - ias_cmd->command = cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND | CONFIG_SYS_CMD_IAS)); + ias_cmd->command = cpu_to_le16(CONFIG_SYS_CMD_SUSPEND | + CONFIG_SYS_CMD_IAS); ias_cmd->status = 0; - ias_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); + ias_cmd->link = cpu_to_le32(phys_to_bus((u32)&tx_ring[tx_next])); memcpy(ias_cmd->params, dev->enetaddr, 6); @@ -549,8 +550,9 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) OUTL(dev, phys_to_bus((u32)&tx_ring[tx_cur]), SCBPointer); OUTW(dev, SCB_M | CU_START, SCBCmd); - for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); -i++) { + for (i = 0; +!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C); +i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", dev->name); @@
[PATCH 10/30] net: eepro100: Fix camelcase
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 172 - 1 file changed, 85 insertions(+), 87 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 45c013607e..d3ced08761 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -14,18 +14,18 @@ #include /* Ethernet chip registers. */ -#define SCBStatus 0 /* Rx/Command Unit Status *Word* */ -#define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ -#define SCBCmd 2 /* Rx/Command Unit Command *Word* */ -#define SCBIntrCtlByte 3 /* Rx/Command Unit Intr.Control Byte */ -#define SCBPointer 4 /* General purpose pointer. */ -#define SCBPort8 /* Misc. commands and operands. */ -#define SCBflash 12 /* Flash memory control. */ -#define SCBeeprom 14 /* EEPROM memory control. */ -#define SCBCtrlMDI 16 /* MDI interface control. */ -#define SCBEarlyRx 20 /* Early receive byte count. */ -#define SCBGenControl 28 /* 82559 General Control Register */ -#define SCBGenStatus 29 /* 82559 General Status register */ +#define SCB_STATUS 0 /* Rx/Command Unit Status *Word* */ +#define SCB_INT_ACK_BYTE 1 /* Rx/Command Unit STAT/ACK byte */ +#define SCB_CMD2 /* Rx/Command Unit Command *Word* */ +#define SCB_INTR_CTL_BYTE 3 /* Rx/Command Unit Intr.Control Byte */ +#define SCB_POINTER4 /* General purpose pointer. */ +#define SCB_PORT 8 /* Misc. commands and operands. */ +#define SCB_FLASH 12 /* Flash memory control. */ +#define SCB_EEPROM 14 /* EEPROM memory control. */ +#define SCB_CTRL_MDI 16 /* MDI interface control. */ +#define SCB_EARLY_RX 20 /* Early receive byte count. */ +#define SCB_GEN_CONTROL28 /* 82559 General Control Register */ +#define SCB_GEN_STATUS 29 /* 82559 General Status register */ /* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */ @@ -101,10 +101,10 @@ #define EE_ERASE_CMD (7 << addr_len) /* Receive frame descriptors. */ -struct RxFD { +struct eepro100_rxfd { volatile u16 status; volatile u16 control; - volatile u32 link; /* struct RxFD * */ + volatile u32 link; /* struct eepro100_rxfd * */ volatile u32 rx_buf_addr; /* void * */ volatile u32 count; @@ -135,7 +135,7 @@ struct RxFD { #define RFD_RX_TCO 0x0001 /* TCO indication */ /* Transmit frame descriptors */ -struct TxFD { /* Transmit frame descriptor set. */ +struct eepro100_txfd { /* Transmit frame descriptor set. */ volatile u16 status; volatile u16 command; volatile u32 link; /* void * */ @@ -148,15 +148,15 @@ struct TxFD { /* Transmit frame descriptor set. */ volatile s32 tx_buf_size1; /* Length of Tx frame. */ }; -#define TxCB_CMD_TRANSMIT 0x0004 /* transmit command */ -#define TxCB_CMD_SF0x0008 /* 0=simplified, 1=flexible mode */ -#define TxCB_CMD_NC0x0010 /* 0=CRC insert by controller */ -#define TxCB_CMD_I 0x2000 /* generate interrupt on completion */ -#define TxCB_CMD_S 0x4000 /* suspend on completion */ -#define TxCB_CMD_EL0x8000 /* last command block in CBL */ +#define TXCB_CMD_TRANSMIT 0x0004 /* transmit command */ +#define TXCB_CMD_SF0x0008 /* 0=simplified, 1=flexible mode */ +#define TXCB_CMD_NC0x0010 /* 0=CRC insert by controller */ +#define TXCB_CMD_I 0x2000 /* generate interrupt on completion */ +#define TXCB_CMD_S 0x4000 /* suspend on completion */ +#define TXCB_CMD_EL0x8000 /* last command block in CBL */ -#define TxCB_COUNT_MASK0x3fff -#define TxCB_COUNT_EOF 0x8000 +#define TXCB_COUNT_MASK0x3fff +#define TXCB_COUNT_EOF 0x8000 /* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor {/* A generic descriptor. */ @@ -182,8 +182,8 @@ struct descriptor { /* A generic descriptor. */ #define TOUT_LOOP 100 -static struct RxFD rx_ring[NUM_RX_DESC]; /* RX descriptor ring */ -static struct TxFD tx_ring[NUM_TX_DESC]; /* TX descriptor ring */ +static struct eepro100_rxfd rx_ring[NUM_RX_DESC]; /* RX des
[PATCH 04/30] net: eepro100: Fix spacing
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types SPACING -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 278 - 1 file changed, 139 insertions(+), 139 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index dd902386b1..1b6d5375f8 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -68,13 +68,13 @@ #define CU_STATUS_MASK 0x00C0 #define RU_STATUS_MASK 0x003C -#define RU_STATUS_IDLE (0<<2) -#define RU_STATUS_SUS (1<<2) -#define RU_STATUS_NORES(2<<2) -#define RU_STATUS_READY(4<<2) -#define RU_STATUS_NO_RBDS_SUS ((1<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) +#define RU_STATUS_IDLE (0 << 2) +#define RU_STATUS_SUS (1 << 2) +#define RU_STATUS_NORES(2 << 2) +#define RU_STATUS_READY(4 << 2) +#define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2)) /* 82559 Port interface commands. */ #define I82559_RESET 0x /* Software reset */ @@ -200,15 +200,15 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring (struct eth_device *dev); -static void purge_tx_ring (struct eth_device *dev); +static void init_rx_ring(struct eth_device *dev); +static void purge_tx_ring(struct eth_device *dev); -static void read_hw_addr (struct eth_device *dev, bd_t * bis); +static void read_hw_addr(struct eth_device *dev, bd_t * bis); -static int eepro100_init (struct eth_device *dev, bd_t * bis); +static int eepro100_init(struct eth_device *dev, bd_t * bis); static int eepro100_send(struct eth_device *dev, void *packet, int length); -static int eepro100_recv (struct eth_device *dev); -static void eepro100_halt (struct eth_device *dev); +static int eepro100_recv(struct eth_device *dev); +static void eepro100_halt(struct eth_device *dev); #if defined(CONFIG_E500) #define bus_to_phys(a) (a) @@ -218,28 +218,28 @@ static void eepro100_halt (struct eth_device *dev); #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) #endif -static inline int INW (struct eth_device *dev, u_long addr) +static inline int INW(struct eth_device *dev, u_long addr) { return le16_to_cpu(*(volatile u16 *)(addr + (u_long)dev->iobase)); } -static inline void OUTW (struct eth_device *dev, int command, u_long addr) +static inline void OUTW(struct eth_device *dev, int command, u_long addr) { *(volatile u16 *)((addr + (u_long)dev->iobase)) = cpu_to_le16(command); } -static inline void OUTL (struct eth_device *dev, int command, u_long addr) +static inline void OUTL(struct eth_device *dev, int command, u_long addr) { *(volatile u32 *)((addr + (u_long)dev->iobase)) = cpu_to_le32(command); } #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) -static inline int INL (struct eth_device *dev, u_long addr) +static inline int INL(struct eth_device *dev, u_long addr) { return le32_to_cpu(*(volatile u32 *)(addr + (u_long)dev->iobase)); } -static int get_phyreg (struct eth_device *dev, unsigned char addr, +static int get_phyreg(struct eth_device *dev, unsigned char addr, unsigned char reg, unsigned short *value) { int cmd; @@ -247,22 +247,22 @@ static int get_phyreg (struct eth_device *dev, unsigned char addr, /* read requested data */ cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL (dev, cmd, SCBCtrlMDI); + OUTL(dev, cmd, SCBCtrlMDI); do { udelay(1000); - cmd = INL (dev, SCBCtrlMDI); + cmd = INL(dev, SCBCtrlMDI); } while (!(cmd & (1 << 28)) && (--timeout)); if (timeout == 0) return -1; - *value = (unsigned short) (cmd & 0x); + *value = (unsigned short)(cmd & 0x); return 0; } -static int set_phyreg (struct eth_device *dev, unsigned char addr, +static int set_phyreg(struct eth_device *dev, unsigned char addr, unsigned char reg, unsigned short value) { int cmd; @@ -270,9 +270,9 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr, /* write requested data */ cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16); - OUTL (dev, cmd | value, SCBCtrlMDI); + OUTL(dev, cmd | value, SCBCtrlMDI); - while (!(INL (dev, SCBCtrlMDI) & (1 << 28)) && (--timeout)) + while (!(INL(dev, SCBCtrlMDI) & (1 << 28)) && (--timeout)) udelay(1000); if (timeout == 0) @@ -285,7 +285,7 @@ static int set_phyreg (struct eth_device *dev, unsi
[PATCH 07/30] net: eepro100: Fix pointer location
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types POINTER_LOCATION -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index d367052cd2..2aad124ae5 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -203,9 +203,9 @@ static const char i82558_config_cmd[] = { static void init_rx_ring(struct eth_device *dev); static void purge_tx_ring(struct eth_device *dev); -static void read_hw_addr(struct eth_device *dev, bd_t * bis); +static void read_hw_addr(struct eth_device *dev, bd_t *bis); -static int eepro100_init(struct eth_device *dev, bd_t * bis); +static int eepro100_init(struct eth_device *dev, bd_t *bis); static int eepro100_send(struct eth_device *dev, void *packet, int length); static int eepro100_recv(struct eth_device *dev); static void eepro100_halt(struct eth_device *dev); @@ -285,7 +285,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, * Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device* verify_phyaddr(const char *devname, +static struct eth_device *verify_phyaddr(const char *devname, unsigned char addr) { struct eth_device *dev; @@ -372,7 +372,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize(bd_t * bis) +int eepro100_initialize(bd_t *bis) { pci_dev_t devno; int card_number = 0; @@ -454,7 +454,7 @@ int eepro100_initialize(bd_t * bis) } -static int eepro100_init(struct eth_device *dev, bd_t * bis) +static int eepro100_init(struct eth_device *dev, bd_t *bis) { int i, status = -1; int tx_cur; @@ -785,7 +785,7 @@ static void purge_tx_ring(struct eth_device *dev) } } -static void read_hw_addr(struct eth_device *dev, bd_t * bis) +static void read_hw_addr(struct eth_device *dev, bd_t *bis) { u16 sum = 0; int i, j; -- 2.25.1
[PATCH 03/30] net: eepro100: Use plain debug()
Convert all the ifdef DEBUG to plain debug(), no functional change. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 15 --- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 503c44af4c..dd902386b1 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -13,8 +13,6 @@ #include #include -#undef DEBUG - /* Ethernet chip registers. */ #define SCBStatus 0 /* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ @@ -392,10 +390,8 @@ int eepro100_initialize (bd_t * bis) pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, &iobase); iobase &= ~0xf; -#ifdef DEBUG - printf ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", - iobase); -#endif + debug("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n", + iobase); pci_write_config_dword (devno, PCI_COMMAND, @@ -810,10 +806,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis) if (sum != 0xBABA) { memset (dev->enetaddr, 0, ETH_ALEN); -#ifdef DEBUG - printf ("%s: Invalid EEPROM checksum %#4.4x, " - "check settings before activating this device!\n", - dev->name, sum); -#endif + debug("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n", + dev->name, sum); } } -- 2.25.1
[PATCH 06/30] net: eepro100: Fix parenthesis alignment
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types PARENTHESIS_ALIGNMENT -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 6dccd59bda..d367052cd2 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -240,7 +240,7 @@ static inline int INL(struct eth_device *dev, u_long addr) } static int get_phyreg(struct eth_device *dev, unsigned char addr, - unsigned char reg, unsigned short *value) + unsigned char reg, unsigned short *value) { int cmd; int timeout = 50; @@ -263,7 +263,7 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, } static int set_phyreg(struct eth_device *dev, unsigned char addr, - unsigned char reg, unsigned short value) + unsigned char reg, unsigned short value) { int cmd; int timeout = 50; @@ -286,7 +286,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr, * Do this by checking model value field from ID2 register. */ static struct eth_device* verify_phyaddr(const char *devname, - unsigned char addr) +unsigned char addr) { struct eth_device *dev; unsigned short value; @@ -393,7 +393,7 @@ int eepro100_initialize(bd_t * bis) iobase); pci_write_config_dword(devno, - PCI_COMMAND, + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); /* Check if I/O accesses and Bus Mastering are enabled. */ @@ -504,7 +504,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) cfg_cmd->link = cpu_to_le32 (phys_to_bus((u32)&tx_ring[tx_next])); memcpy(cfg_cmd->params, i82558_config_cmd, - sizeof(i82558_config_cmd)); + sizeof(i82558_config_cmd)); if (!wait_for_eepro100(dev)) { printf("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n"); @@ -525,7 +525,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -553,14 +553,14 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) i++) { if (i >= TOUT_LOOP) { printf("%s: Tx error buffer not ready\n", - dev->name); + dev->name); goto Done; } } if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } @@ -599,7 +599,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) if (!wait_for_eepro100(dev)) { printf("%s: Tx error ethernet controller not ready.\n", - dev->name); + dev->name); goto Done; } @@ -617,7 +617,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) if (!(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_OK)) { printf("TX error status = 0x%08X\n", - le16_to_cpu(tx_ring[tx_cur].status)); + le16_to_cpu(tx_ring[tx_cur].status)); goto Done; } -- 2.25.1
[PATCH 01/30] net: eepro100: Remove EEPRO100_SROM_WRITE
This code is never enabled, last board that used it was ELPPC which was removed some 5 years ago, so just remove this code altogether. Signed-off-by: Marek Vasut --- README | 2 - drivers/net/eepro100.c | 87 scripts/config_whitelist.txt | 1 - 3 files changed, 90 deletions(-) diff --git a/README b/README index be9e6391d6..c4bb6f3e7b 100644 --- a/README +++ b/README @@ -891,8 +891,6 @@ The following options need to be configured: CONFIG_EEPRO100 Support for Intel 82557/82559/82559ER chips. - Optional CONFIG_EEPRO100_SROM_WRITE enables EEPROM - write routine for first time initialisation. CONFIG_TULIP Support for Digital 2114x chips. diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index e186ab4e5f..62a0dc7522 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -781,93 +781,6 @@ static int read_eeprom (struct eth_device *dev, int location, int addr_len) return retval; } -#ifdef CONFIG_EEPRO100_SROM_WRITE -int eepro100_write_eeprom (struct eth_device* dev, int location, int addr_len, unsigned short data) -{ -unsigned short dataval; -int enable_cmd = 0x3f | EE_EWENB_CMD; -int write_cmd = location | EE_WRITE_CMD; -int i; -unsigned long datalong, tmplong; - -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); -udelay(1); -OUTW(dev, EE_ENB, SCBeeprom); - -/* Shift the enable command bits out. */ -for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--) -{ - dataval = (enable_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW(dev, EE_ENB | dataval, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); - udelay(1); -} - -OUTW(dev, EE_ENB, SCBeeprom); -udelay(1); -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); -udelay(1); -OUTW(dev, EE_ENB, SCBeeprom); - - -/* Shift the write command bits out. */ -for (i = (addr_len+EE_CMD_BITS-1); i >= 0; i--) -{ - dataval = (write_cmd & (1 << i)) ? EE_DATA_WRITE : 0; - OUTW(dev, EE_ENB | dataval, SCBeeprom); - udelay(1); - OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); - udelay(1); -} - -/* Write the data */ -datalong= (unsigned long) data) & 0x00ff) << 8) | ( (data) >> 8)); - -for (i = 0; i< EE_DATA_BITS; i++) -{ -/* Extract and move data bit to bit DI */ -dataval = ((datalong & 0x8000)>>13) ? EE_DATA_WRITE : 0; - -OUTW(dev, EE_ENB | dataval, SCBeeprom); -udelay(1); -OUTW(dev, EE_ENB | dataval | EE_SHIFT_CLK, SCBeeprom); -udelay(1); -OUTW(dev, EE_ENB | dataval, SCBeeprom); -udelay(1); - -datalong = datalong << 1; /* Adjust significant data bit*/ -} - -/* Finish up command (toggle CS) */ -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); -udelay(1); /* delay for more than 250 ns */ -OUTW(dev, EE_ENB, SCBeeprom); - -/* Wait for programming ready (D0 = 1) */ -tmplong = 10; -do -{ - dataval = INW(dev, SCBeeprom); - if (dataval & EE_DATA_READ) - break; - udelay(1); -} -while (-- tmplong); - -if (tmplong == 0) -{ - printf ("Write i82559 eeprom timed out (100 ms waiting for data ready.\n"); - return -1; -} - -/* Terminate the EEPROM access. */ -OUTW(dev, EE_ENB & ~EE_CS, SCBeeprom); - -return 0; -} -#endif - static void init_rx_ring (struct eth_device *dev) { int i; diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 3f5e6504e1..2dee446dde 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -401,7 +401,6 @@ CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 CONFIG_EEPRO100 -CONFIG_EEPRO100_SROM_WRITE CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET -- 2.25.1
[PATCH 05/30] net: eepro100: Fix braces
This is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types BRACES -f --fix --fix-inplace drivers/net/eepro100.c Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 1b6d5375f8..6dccd59bda 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -358,9 +358,8 @@ static int wait_for_eepro100(struct eth_device *dev) int i; for (i = 0; INW(dev, SCBCmd) & (CU_CMD_MASK | RU_CMD_MASK); i++) { - if (i >= TOUT_LOOP) { + if (i >= TOUT_LOOP) return 0; - } } return 1; @@ -383,9 +382,9 @@ int eepro100_initialize(bd_t * bis) while (1) { /* Find PCI device */ - if ((devno = pci_find_devices(supported, idx++)) < 0) { + devno = pci_find_devices(supported, idx++); + if (devno < 0) break; - } pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &iobase); iobase &= ~0xf; @@ -639,9 +638,8 @@ static int eepro100_recv(struct eth_device *dev) for (;;) { status = le16_to_cpu(rx_ring[rx_next].status); - if (!(status & RFD_STATUS_C)) { + if (!(status & RFD_STATUS_C)) break; - } /* Valid frame status. */ if ((status & RFD_STATUS_OK)) { @@ -668,7 +666,6 @@ static int eepro100_recv(struct eth_device *dev) } if (stat & SCB_STATUS_RNR) { - printf("%s: Receiver is not ready, restart it !\n", dev->name); /* Reinitialize Rx ring. */ -- 2.25.1
[PATCH 02/30] net: eepro100: Clean up comments
Clean the comments up to they trigger fewer checkpatch warnings, no functional change. Signed-off-by: Marek Vasut --- drivers/net/eepro100.c | 100 +++-- 1 file changed, 36 insertions(+), 64 deletions(-) diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 62a0dc7522..503c44af4c 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -15,8 +15,7 @@ #undef DEBUG - /* Ethernet chip registers. -*/ +/* Ethernet chip registers. */ #define SCBStatus 0 /* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1 /* Rx/Command Unit STAT/ACK byte */ #define SCBCmd 2 /* Rx/Command Unit Command *Word* */ @@ -30,8 +29,7 @@ #define SCBGenControl 28 /* 82559 General Control Register */ #define SCBGenStatus 29 /* 82559 General Status register */ - /* 82559 SCB status word defnitions -*/ +/* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000 /* CU finished command (transmit) */ #define SCB_STATUS_FR 0x4000 /* frame received */ #define SCB_STATUS_CNA 0x2000 /* CU left active state */ @@ -45,8 +43,7 @@ #define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA) #define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR) - /* System control block commands -*/ +/* System control block commands */ /* CU Commands */ #define CU_NOP 0x #define CU_START 0x0010 @@ -81,16 +78,14 @@ #define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) #define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) - /* 82559 Port interface commands. -*/ +/* 82559 Port interface commands. */ #define I82559_RESET 0x /* Software reset */ #define I82559_SELFTEST0x0001 /* 82559 Selftest command */ #define I82559_SELECTIVE_RESET 0x0002 #define I82559_DUMP0x0003 #define I82559_DUMP_WAKEUP 0x0007 - /* 82559 Eeprom interface. -*/ +/* 82559 Eeprom interface. */ #define EE_SHIFT_CLK 0x01/* EEPROM shift clock. */ #define EE_CS 0x02/* EEPROM chip select. */ #define EE_DATA_WRITE 0x04/* EEPROM chip data in. */ @@ -101,15 +96,13 @@ #define EE_CMD_BITS3 #define EE_DATA_BITS 16 - /* The EEPROM commands include the alway-set leading bit. -*/ +/* The EEPROM commands include the alway-set leading bit. */ #define EE_EWENB_CMD (4 << addr_len) #define EE_WRITE_CMD (5 << addr_len) #define EE_READ_CMD(6 << addr_len) #define EE_ERASE_CMD (7 << addr_len) - /* Receive frame descriptors. -*/ +/* Receive frame descriptors. */ struct RxFD { volatile u16 status; volatile u16 control; @@ -143,8 +136,7 @@ struct RxFD { #define RFD_RX_IA_MATCH0x0002 /* individual address does not match */ #define RFD_RX_TCO 0x0001 /* TCO indication */ - /* Transmit frame descriptors -*/ +/* Transmit frame descriptors */ struct TxFD { /* Transmit frame descriptor set. */ volatile u16 status; volatile u16 command; @@ -152,9 +144,9 @@ struct TxFD { /* Transmit frame descriptor set. */ volatile u32 tx_desc_addr; /* Always points to the tx_buf_addr element. */ volatile s32 count; - volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */ + volatile u32 tx_buf_addr0; /* void *, frame to be transmitted. */ volatile s32 tx_buf_size0; /* Length of Tx frame. */ - volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */ + volatile u32 tx_buf_addr1; /* void *, frame to be transmitted. */ volatile s32 tx_buf_size1; /* Length of Tx frame. */ }; @@ -168,12 +160,11 @@ struct TxFD { /* Transmit frame descriptor set. */ #define TxCB_COUNT_MASK0x3fff #define TxCB_COUNT_EOF 0x8000 - /* The Speedo3 Rx and Tx frame/buffer descriptors. -*/ +/* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor {/* A generic descriptor. */ volatile u16 status; volatile u16 command; - volatile u32 link; /* struct descriptor * */ + volatile u32 link; /* struct descriptor * */ unsigned char params[0]; }; @@ -187,15 +178,14 @@ struct descriptor { /* A generic descriptor. */ #define CONFIG_SYS_STATUS_C0x8000 #define CONFIG_SYS_STATUS_OK 0x2000 - /* Misc. -*/ +/* Misc. */ #define NUM_RX_DESCPKTBUFSRX -#define NUM_TX_DESC1 /* Number of TX descriptors */ +#define NUM_TX_DESC1 /
[PATCH] rockchip: enable RNG on RockPro64
Signed-off-by: Marcin Juszkiewicz --- arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 4 configs/rockpro64-rk3399_defconfig| 2 ++ 2 files changed, 6 insertions(+) diff --git arch/arm/dts/rk3399-rockpro64-u-boot.dtsi arch/arm/dts/rk3399-rockpro64-u-boot.dtsi index deaa3efd39..824ee4e3ce 100644 --- arch/arm/dts/rk3399-rockpro64-u-boot.dtsi +++ arch/arm/dts/rk3399-rockpro64-u-boot.dtsi @@ -23,3 +23,7 @@ &vdd_log { regulator-init-microvolt = <95>; }; + +&rng { + status = "okay"; +}; diff --git configs/rockpro64-rk3399_defconfig configs/rockpro64-rk3399_defconfig index 53abce0057..04ba151475 100644 --- configs/rockpro64-rk3399_defconfig +++ configs/rockpro64-rk3399_defconfig @@ -43,6 +43,8 @@ CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM_RK3399_LPDDR4=y +CONFIG_DM_RNG=y +CONFIG_RNG_ROCKCHIP=y CONFIG_BAUDRATE=150 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_ROCKCHIP_SPI=y -- 2.26.2
Re: [PATCH] tbs2910: migrate to DM_VIDEO
On 23.05.20 17:17, Anatolij Gustschin wrote: > On Sat, 23 May 2020 09:55:48 +0200 > Soeren Moch sm...@web.de wrote: > >> On 23.05.20 01:24, Anatolij Gustschin wrote: >>> Migration to DM_VIDEO driver is long overdue, configure it in >>> board config files. To enable the display set stdout like: >>> >>> setenv stdout serial,vidconsole >> And this exactly is the problem. >> There are some users of this board without serial console. They have no >> chance to set this after upgrading u-boot. >> >> What is the reason behind this incompatible change? In other words, why >> vga cannot be an alias for vidconsole, if this is the preferred name >> nowadays? > DM video console driver uses more generic name for the video console. > As a work-around, an alias exists for 'lcd' name. I've sent a patch > to also use 'vga' as an alias. > Thanks. I will test both patches for tbs2910. Soeren
Re: [PATCH] libfdt: Remove superfluous NUL character from overlay symbols
Hi Simon, Simon Glass writes: > You can send your patch to the mailing list on cc. > > Also see README.fdt-control fo the the git repo and other details. Thanks. Sent. // Marcus
Re: [PATCH] tbs2910: migrate to DM_VIDEO
On Sat, 23 May 2020 09:55:48 +0200 Soeren Moch sm...@web.de wrote: > On 23.05.20 01:24, Anatolij Gustschin wrote: > > Migration to DM_VIDEO driver is long overdue, configure it in > > board config files. To enable the display set stdout like: > > > > setenv stdout serial,vidconsole > And this exactly is the problem. > There are some users of this board without serial console. They have no > chance to set this after upgrading u-boot. > > What is the reason behind this incompatible change? In other words, why > vga cannot be an alias for vidconsole, if this is the preferred name > nowadays? DM video console driver uses more generic name for the video console. As a work-around, an alias exists for 'lcd' name. I've sent a patch to also use 'vga' as an alias. -- Anatolij
[PATCH] video: extend stdout video console work-around for 'vga'
cfb_console driver use 'vga' console name and we still have board environments defining this name. Re-use existing DM_VIDEO work- around for console name to support 'vga' name in stdout environment. Signed-off-by: Anatolij Gustschin --- arch/arm/mach-tegra/Kconfig | 1 - common/console.c| 7 --- drivers/video/Kconfig | 16 +--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index 00facf492e..15e7684028 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig @@ -58,7 +58,6 @@ config TEGRA_COMMON select MISC select OF_CONTROL select SPI - select VIDCONSOLE_AS_LCD if DM_VIDEO imply CMD_DM imply CRC32_VERIFY diff --git a/common/console.c b/common/console.c index 1deca3cb78..f149624954 100644 --- a/common/console.c +++ b/common/console.c @@ -713,7 +713,7 @@ struct stdio_dev *search_device(int flags, const char *name) dev = stdio_get_by_name(name); #ifdef CONFIG_VIDCONSOLE_AS_LCD - if (!dev && !strcmp(name, "lcd")) + if (!dev && !strcmp(name, CONFIG_VIDCONSOLE_AS_LCD)) dev = stdio_get_by_name("vidconsole"); #endif @@ -897,8 +897,9 @@ done: stdio_print_current_devices(); #endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ #ifdef CONFIG_VIDCONSOLE_AS_LCD - if (strstr(stdoutname, "lcd")) - printf("Warning: Please change 'lcd' to 'vidconsole' in stdout/stderr environment vars\n"); + if (strstr(stdoutname, CONFIG_VIDCONSOLE_AS_LCD)) + printf("Warning: Please change '%s' to 'vidconsole' in stdout/stderr environment vars\n", + CONFIG_VIDCONSOLE_AS_LCD); #endif #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 38123543a5..28c22fe525 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -146,14 +146,16 @@ config NO_FB_CLEAR source "drivers/video/fonts/Kconfig" config VIDCONSOLE_AS_LCD - bool "Use 'vidconsole' when 'lcd' is seen in stdout" + string "Use 'vidconsole' when string defined here is seen in stdout" depends on DM_VIDEO - help - This is a work-around for boards which have 'lcd' in their stdout - environment variable, but have moved to use driver model for video. - In this case the console will no-longer work. While it is possible - to update the environment, the breakage may be confusing for users. - This option will be removed around the end of 2016. + default "lcd" if LCD || TEGRA_COMMON + default "vga" if !LCD + help + This is a work-around for boards which have 'lcd' or 'vga' in their + stdout environment variable, but have moved to use driver model for + video. In this case the console will no-longer work. While it is + possible to update the environment, the breakage may be confusing for + users. This option will be removed around the end of 2020. config VIDEO_COREBOOT bool "Enable coreboot framebuffer driver support" -- 2.17.1
Re: [PATCH] libfdt: Remove superfluous NUL character from overlay symbols
+Devicetree Compiler On Sat, 23 May 2020 at 05:57, Marcus Comstedt wrote: > > > Hi Simon, > > > Simon Glass writes: > > > Could you please send this patch upstream? > > > Sure. But where is that, exactly? > > > // Marcus > > Hi Marcus, You can send your patch to the mailing list on cc. Also see README.fdt-control fo the the git repo and other details. Regards, Simon
Re: [PULL] u-boot-usb/master
On Sat, May 23, 2020 at 01:22:57AM +0200, Marek Vasut wrote: > The following changes since commit 2fa581ba910368d0f7f995fb906d6c5e4218b594: > > Merge git://git.denx.de/u-boot-sh (2020-05-21 08:26:40 -0400) > > are available in the Git repository at: > > git://git.denx.de/u-boot-usb.git master > > for you to fetch changes up to 2cff87f7abf060dda00302680f051d5e9ce60ab9: > > eth/r8152: fix typo in register name (2020-05-22 15:22:37 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PULL] u-boot-socfpga/net
On Sat, May 23, 2020 at 01:21:03AM +0200, Marek Vasut wrote: > So here are some more network patches for 2020.07 , the patches were > posted even before 2020.04 . > > However, I would really like Joe to come back soon. > > CI passes: > https://gitlab.denx.de/u-boot/custodians/u-boot-socfpga/pipelines/3367 > > The following changes since commit 2fa581ba910368d0f7f995fb906d6c5e4218b594: > > Merge git://git.denx.de/u-boot-sh (2020-05-21 08:26:40 -0400) > > are available in the Git repository at: > > git://git.denx.de/u-boot-socfpga.git net > > for you to fetch changes up to df4c4834fc008315bce2f978220ecc9da2e3862c: > > net: ks8851: Add Kconfig entries (2020-05-22 19:46:45 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH v3 12/13] cbfs: Allow reading a file from a CBFS given its base addr
On Sat, May 23, 2020 at 12:32 AM Simon Glass wrote: > > Currently we support reading a file from CBFS given the address of the end > of the ROM. Sometimes we only know the start of the CBFS. Add a function > to find a file given that. > > Signed-off-by: Simon Glass > --- > > Changes in v3: None > Changes in v2: > - Use void * instead of u8 * in file_cbfs_find_uncached_base() > - Fix and expand comments in file_cbfs_find_uncached_base() > > fs/cbfs/cbfs.c | 13 + > include/cbfs.h | 14 ++ > 2 files changed, 27 insertions(+) > Reviewed-by: Bin Meng
Re: [PATCH v3 11/13] cbfs: Change file_cbfs_find_uncached() to return an error
On Sat, May 23, 2020 at 12:32 AM Simon Glass wrote: > > This function currently returns a node pointer so there is no way to know > the error code. Also it uses data in BSS which seems unnecessary since the > caller might prefer to use a local variable. > > Update the function and split its body out into a separate function so we > can use it later. > > Signed-off-by: Simon Glass > --- > > Changes in v3: None > Changes in v2: > - Fix s/u8/void/ in find_uncached() > - Fix setting of start in file_cbfs_find_uncached() > - Add more comments on @node in file_cbfs_find_uncached() > > fs/cbfs/cbfs.c | 48 +++- > include/cbfs.h | 17 + > 2 files changed, 36 insertions(+), 29 deletions(-) > Reviewed-by: Bin Meng
Re: [PATCH v3 07/13] cbfs: Unify the two header loaders
On Sat, May 23, 2020 at 12:32 AM Simon Glass wrote: > > These two functions have mostly the same code. Pull this out into a common > function. > > Also make this function zero the private data so that callers don't have > to do it. Finally, update cbfs_load_header_ptr() to take the base of the > ROM as its parameter, which makes more sense than passing the address of > the header within the ROM. > > Signed-off-by: Simon Glass > --- > > Changes in v3: None > Changes in v2: > - Fix incorrect function comments > > fs/cbfs/cbfs.c | 59 +++--- > 1 file changed, 37 insertions(+), 22 deletions(-) > Reviewed-by: Bin Meng
Re: [PATCH v3 04/13] cbfs: Adjust return value of file_cbfs_next_file()
Hi Simon, On Sat, May 23, 2020 at 12:32 AM Simon Glass wrote: > > At present his uses a true return to indicate it found a file. Adjust it typo his => this was missed. > to use 0 for this, so it is consistent with other functions. > > Update its callers accordingly and add a check for malloc() failure in > file_cbfs_fill_cache(). > > Reviewed-by: Bin Meng > Signed-off-by: Simon Glass > --- > > Changes in v3: > - Fix typo in commit message > > Changes in v2: None > > fs/cbfs/cbfs.c | 43 +++ > 1 file changed, 23 insertions(+), 20 deletions(-) Regards, Bin
Re: [PATCH v3 03/13] cbfs: Use bool type for whether initialised
Hi Simon, On Sat, May 23, 2020 at 12:32 AM Simon Glass wrote: > > At present this uses an int type. U-Boot now supports bool so use this > instead. Also use English spelling for initialised which we are here. Sorry I was not clear. I don't think we should change to use 'initialised' here BTW: the Google spelling check prompts "initialised" is a typo and it suggests "initialized": :) > > Signed-off-by: Simon Glass > --- > > Changes in v3: None > Changes in v2: None > > fs/cbfs/cbfs.c | 28 ++-- > include/cbfs.h | 2 +- > 2 files changed, 15 insertions(+), 15 deletions(-) > Regards, Bin
[PATCH 1/1] doc: dfu: describe more DFU function
Add some of the missing DFU function descriptions. Signed-off-by: Heinrich Schuchardt --- include/dfu.h | 178 -- 1 file changed, 174 insertions(+), 4 deletions(-) diff --git a/include/dfu.h b/include/dfu.h index 938a4d1b81..065d8db824 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -159,20 +159,139 @@ struct dfu_entity { }; #ifdef CONFIG_SET_DFU_ALT_INFO +/** + * set_dfu_alt_info() - set dfu_alt_info environment variable + * + * If CONFIG_SET_DFU_ALT_INFO=y, this board specific function is called to set + * environment variable dfu_alt_info. + * + * @interface: dfu interface, e.g. "mmc" or "nand" + * @devstr:device number as string + */ void set_dfu_alt_info(char *interface, char *devstr); #endif + +/** + * dfu_alt_init() - initialize buffer for dfu entities + * + * @num: number of entities + * @dfu: on return allocated buffer + * Return: 0 on success + */ int dfu_alt_init(int num, struct dfu_entity **dfu); + +/** + * dfu_alt_add() - add alternate to dfu entity buffer + * + * @dfu: dfu entity + * @interface: dfu interface, e.g. "mmc" or "nand" + * @devstr:device number as string + * @s: string description of alternate + * Return: 0 on success + */ int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char *s); + +/** + * dfu_config_entities() - initialize dfu entitities from envirionment + * + * Initialize the list of dfu entities from environment variable dfu_alt_info. + * The list must be freed by calling dfu_free_entities(). This function bypasses + * set_dfu_alt_info(). So typically you should use dfu_init_env_entities() + * instead. + * + * See function :c:func:`dfu_free_entities` + * See function :c:func:`dfu_init_env_entities` + * + * @s: string with alternates + * @interface: interface, e.g. "mmc" or "nand" + * @devstr:device number as string + * Return: 0 on success, a negative error code otherwise + */ int dfu_config_entities(char *s, char *interface, char *devstr); + +/** + * dfu_free_entities() - free the list of dfu entities + * + * Free the internal list of dfu entities. + * + * See function :c:func:`dfu_init_env_entities` + */ void dfu_free_entities(void); + +/** + * dfu_show_entities() - print DFU alt settings list + */ void dfu_show_entities(void); + +/** + * dfu_get_alt_number() - get number of alternates + * + * Return: number of alternates in the dfu entities list + */ int dfu_get_alt_number(void); -const char *dfu_get_dev_type(enum dfu_device_type t); -const char *dfu_get_layout(enum dfu_layout l); + +/** + * dfu_get_dev_type() - get string representation for dfu device type + * + * @type: device type + * Return: string representation for device type + */ +const char *dfu_get_dev_type(enum dfu_device_type type); + +/** + * dfu_get_layout() - get string describing layout + * + * Internally layouts are represented by enum dfu_device_type values. This + * function translates an enum value to a human readable string, e.g. DFU_FS_FAT + * is translated to "FAT". + * + * @layout:layout + * Result: string representation for the layout + */ +const char *dfu_get_layout(enum dfu_layout layout); + +/** + * dfu_get_entity() - get dfu entity for an alternate id + * + * @alt: alternate id + * Return: dfu entity + */ struct dfu_entity *dfu_get_entity(int alt); + char *dfu_extract_token(char** e, int *n); + +/** + * dfu_get_alt() - get alternate id for filename + * + * Environment variable dfu_alt_info defines the write destinations (alternates) + * for different filenames. This function get the index of the alternate for + * a filename. If an absolute filename is provided (starting with '/'), the + * directory path is ignored. + * + * @name: filename + * Return: id of the alternate or negative error number (-ENODEV) + */ int dfu_get_alt(char *name); + +/** + * dfu_init_env_entities() - initialize dfu entitities from envirionment + * + * Initialize the list of dfu entities from environment variable dfu_alt_info. + * The list must be freed by calling dfu_free_entities(). + * @interface and @devstr are used to select the relevant set of alternates + * from environment variable dfu_alt_info. + * + * If environment variable dfu_alt_info specifies the interface and the device, + * use NULL for @interface and @devstr. + * + * See function :c:func:`dfu_free_entities` + * + * @interface: interface, e.g. "mmc" or "nand" + * @devstr:device number as string + * Return: 0 on success, a negative error code otherwise + */ int dfu_init_env_entities(char *interface, char *devstr); + unsigned char *dfu_get_buf(struct dfu_entity *dfu); unsigned char *dfu_free_buf(void); unsigned long dfu_get_buf_size(void); @@ -183,8 +302,59 @@ unsigned long dfu_get_timeout(void); void dfu_set_timeout(unsigned long); #endif +/** + * dfu_read() - read from dfu entity + * + * The block sequence number @blk_seq_num is a 16 bit counter that must
Re: [PATCH] libfdt: Remove superfluous NUL character from overlay symbols
Hi Simon, Simon Glass writes: > Could you please send this patch upstream? Sure. But where is that, exactly? // Marcus
Re: [PATCH 1/1] doc: dfu: fix typos in README.dfu
On Sat, May 23, 2020 at 2:48 PM Heinrich Schuchardt wrote: > > Fix some typos. Yeah, with units it's a disaster in software. Thus, perhaps good to add Link tag here in the commit message like Link: https://physics.nist.gov/cuu/Units/checklist.html > > Signed-off-by: Heinrich Schuchardt > --- > doc/README.dfu | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/doc/README.dfu b/doc/README.dfu > index 29230ec654..4b9f883540 100644 > --- a/doc/README.dfu > +++ b/doc/README.dfu > @@ -48,12 +48,12 @@ Configuration Options: >CONFIG_CMD_DFU > > Environment variables: > - the dfu command use 3 environments variables: > + the dfu command uses 3 environments variables: >"dfu_alt_info" : the DFU setting for the USB download gadget with a > semicolon > separated string of information on each alternate: > dfu_alt_info=";;;" > > - when only several device are used, the format is: > + when several devices are used, the format is: > - '='alternate list (';' separated) > - each interface is separated by '&' > dfu_alt_info=\ > @@ -63,7 +63,7 @@ Environment variables: > " =;;&" > >"dfu_bufsiz" : size of the DFU buffer, when absent, use > - CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default) > + CONFIG_SYS_DFU_DATA_BUF_SIZE (8 MiB by default) > >"dfu_hash_algo" : name of the hash algorithm to use > > -- > 2.26.2 > -- With Best Regards, Andy Shevchenko
[PATCH 1/1] doc: dfu: fix typos in README.dfu
Fix some typos. Signed-off-by: Heinrich Schuchardt --- doc/README.dfu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/README.dfu b/doc/README.dfu index 29230ec654..4b9f883540 100644 --- a/doc/README.dfu +++ b/doc/README.dfu @@ -48,12 +48,12 @@ Configuration Options: CONFIG_CMD_DFU Environment variables: - the dfu command use 3 environments variables: + the dfu command uses 3 environments variables: "dfu_alt_info" : the DFU setting for the USB download gadget with a semicolon separated string of information on each alternate: dfu_alt_info=";;;" - when only several device are used, the format is: + when several devices are used, the format is: - '='alternate list (';' separated) - each interface is separated by '&' dfu_alt_info=\ @@ -63,7 +63,7 @@ Environment variables: " =;;&" "dfu_bufsiz" : size of the DFU buffer, when absent, use - CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default) + CONFIG_SYS_DFU_DATA_BUF_SIZE (8 MiB by default) "dfu_hash_algo" : name of the hash algorithm to use -- 2.26.2
[PATCH 1/1] doc: dfu: add DFU to HTML documentation
Add the device firmware update functions to the generated HTML documentation. Signed-off-by: Heinrich Schuchardt --- doc/api/dfu.rst | 7 +++ doc/api/index.rst | 1 + include/dfu.h | 40 3 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 doc/api/dfu.rst diff --git a/doc/api/dfu.rst b/doc/api/dfu.rst new file mode 100644 index 00..5bd9e292a5 --- /dev/null +++ b/doc/api/dfu.rst @@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Device firmware update +== + +.. kernel-doc:: include/dfu.h + :internal: diff --git a/doc/api/index.rst b/doc/api/index.rst index 2578abd40e..fd3b5bdc82 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -6,6 +6,7 @@ U-Boot API documentation .. toctree:: :maxdepth: 2 + dfu efi linker_lists serial diff --git a/include/dfu.h b/include/dfu.h index 2f0e335ec0..00e1543944 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -188,23 +188,23 @@ int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num); int dfu_flush(struct dfu_entity *de, void *buf, int size, int blk_seq_num); /** - * dfu_initiated_callback - weak callback called on DFU transaction start + * dfu_initiated_callback() - weak callback called on DFU transaction start * * It is a callback function called by DFU stack when a DFU transaction is * initiated. This function allows to manage some board specific behavior on * DFU targets. * - * @param dfu - pointer to the dfu_entity, which should be initialized + * @dfu: pointer to the dfu_entity, which should be initialized * */ void dfu_initiated_callback(struct dfu_entity *dfu); /** - * dfu_flush_callback - weak callback called at the end of the DFU write + * dfu_flush_callback() - weak callback called at the end of the DFU write * * It is a callback function called by DFU stack after DFU manifestation. * This function allows to manage some board specific behavior on DFU targets * - * @param dfu - pointer to the dfu_entity, which should be flushed + * @dfu: pointer to the dfu_entity, which should be flushed * */ void dfu_flush_callback(struct dfu_entity *dfu); @@ -218,9 +218,9 @@ void dfu_transaction_cleanup(struct dfu_entity *dfu); */ extern struct dfu_entity *dfu_defer_flush; /** - * dfu_get_defer_flush - get current value of dfu_defer_flush pointer + * dfu_get_defer_flush() - get current value of dfu_defer_flush pointer * - * @return - value of the dfu_defer_flush pointer + * Return: value of the dfu_defer_flush pointer */ static inline struct dfu_entity *dfu_get_defer_flush(void) { @@ -228,9 +228,9 @@ static inline struct dfu_entity *dfu_get_defer_flush(void) } /** - * dfu_set_defer_flush - set the dfu_defer_flush pointer + * dfu_set_defer_flush() - set the dfu_defer_flush pointer * - * @param dfu - pointer to the dfu_entity, which should be written + * @dfu: pointer to the dfu_entity, which should be written */ static inline void dfu_set_defer_flush(struct dfu_entity *dfu) { @@ -238,16 +238,16 @@ static inline void dfu_set_defer_flush(struct dfu_entity *dfu) } /** - * dfu_write_from_mem_addr - write data from memory to DFU managed medium + * dfu_write_from_mem_addr() - write data from memory to DFU managed medium * * This function adds support for writing data starting from fixed memory * address (like $loadaddr) to dfu managed medium (e.g. NAND, MMC, file system) * - * @param dfu - dfu entity to which we want to store data - * @param buf - fixed memory addres from where data starts - * @param size - number of bytes to write + * @dfu: dfu entity to which we want to store data + * @buf: fixed memory addres from where data starts + * @size: number of bytes to write * - * @return - 0 on success, other value on failure + * Return: 0 on success, other value on failure */ int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size); @@ -324,17 +324,17 @@ static inline int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, #endif /** - * dfu_tftp_write - Write TFTP data to DFU medium + * dfu_tftp_write() - write TFTP data to DFU medium * * This function is storing data received via TFTP on DFU supported medium. * - * @param dfu_entity_name - name of DFU entity to write - * @param addr - address of data buffer to write - * @param len - number of bytes - * @param interface - destination DFU medium (e.g. "mmc") - * @param devstring - instance number of destination DFU medium (e.g. "1") + * @dfu_entity_name: name of DFU entity to write + * @addr: address of data buffer to write + * @len: number of bytes + * @interface: destination DFU medium (e.g. "mmc") + * @devstring: instance number of destination DFU medium (e.g. "1") * - * @return 0 on success, otherwise error code + * Return: 0 on success, otherwise error code */ #if CONFIG_IS_ENAB
[PATCH 1/1] doc: dfu: describe eMMC partition number parameter
In dfu_alt_info for eMMC the eMMC partition number can be specified. The separator in dfu_alt_info is a semicolon not a comma. Signed-off-by: Heinrich Schuchardt --- doc/README.dfu | 21 +++-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/README.dfu b/doc/README.dfu index caf1c9998c..29230ec654 100644 --- a/doc/README.dfu +++ b/doc/README.dfu @@ -49,7 +49,7 @@ Configuration Options: Environment variables: the dfu command use 3 environments variables: - "dfu_alt_info" : the DFU setting for the USB download gadget with a comma + "dfu_alt_info" : the DFU setting for the USB download gadget with a semicolon separated string of information on each alternate: dfu_alt_info=";;;" @@ -87,12 +87,21 @@ Commands: "mmc" (for eMMC and SD card) cmd: dfu 0 mmc each element in "dfu_alt_info" = - raw raw access to mmc device - partraw acces to partition - fat file in FAT partition - ext4file in EXT4 partition + raw [mmcpart ] raw access to mmc device + part [mmcpart ] raw access to partition + fat [mmcpart ] file in FAT partition + ext4 [mmcpart ] file in EXT4 partition + + with being the GPT or DOS partition index, + with being the eMMC hardware partition number. + +A value of environment variable dfu_alt_info for eMMC could be: + + "u-boot raw 0x3e 0x800 mmcpart 1;bl2 raw 0x1e 0x1d mmcpart 1" + +A value of environment variable dfu_alt_info for SD card could be: - with is the GPT or DOS partition index + "u-boot raw 0x80 0x800;uImage ext4 0 2" "nand" (raw slc nand device) cmd: dfu 0 nand -- 2.26.2
Re: [PATCH] tbs2910: migrate to DM_VIDEO
On 23.05.20 01:24, Anatolij Gustschin wrote: > Migration to DM_VIDEO driver is long overdue, configure it in > board config files. To enable the display set stdout like: > > setenv stdout serial,vidconsole And this exactly is the problem. There are some users of this board without serial console. They have no chance to set this after upgrading u-boot. What is the reason behind this incompatible change? In other words, why vga cannot be an alias for vidconsole, if this is the preferred name nowadays? Regards, Soeren > > Signed-off-by: Anatolij Gustschin > --- > This is only build tested. > > configs/tbs2910_defconfig | 7 ++- > include/configs/tbs2910.h | 2 -- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig > index 2ff0e160f7..b40641c17b 100644 > --- a/configs/tbs2910_defconfig > +++ b/configs/tbs2910_defconfig > @@ -1,6 +1,7 @@ > CONFIG_ARM=y > CONFIG_ARCH_MX6=y > CONFIG_SYS_TEXT_BASE=0x1780 > +CONFIG_SYS_MALLOC_F_LEN=0x4000 > CONFIG_ENV_SIZE=0x2000 > CONFIG_ENV_OFFSET=0x6 > CONFIG_TARGET_TBS2910=y > @@ -84,7 +85,11 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 > CONFIG_CI_UDC=y > CONFIG_USB_GADGET_DOWNLOAD=y > CONFIG_I2C_EDID=y > +CONFIG_DM_VIDEO=y > +# CONFIG_VIDEO_BPP8 is not set > +# CONFIG_VIDEO_BPP32 is not set > +# CONFIG_VIDEO_ANSI is not set > CONFIG_VIDEO_IPUV3=y > -CONFIG_VIDEO=y > +CONFIG_SYS_WHITE_ON_BLACK=y > CONFIG_OF_LIBFDT_ASSUME_MASK=0xff > # CONFIG_EFI_LOADER is not set > diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h > index 7376b91f55..8ab3fcfe3e 100644 > --- a/include/configs/tbs2910.h > +++ b/include/configs/tbs2910.h > @@ -37,11 +37,9 @@ > #define CONFIG_MXC_UART_BASE UART1_BASE /* select UART1/UART2 */ > > /* Framebuffer */ > -#ifdef CONFIG_VIDEO > #define CONFIG_VIDEO_BMP_RLE8 > #define CONFIG_IMX_HDMI > #define CONFIG_IMX_VIDEO_SKIP > -#endif > > /* PCI */ > #ifdef CONFIG_CMD_PCI