All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 03/13] net: ftgmac100: convert to driver model
Date: Tue, 16 Oct 2018 07:39:20 +0200	[thread overview]
Message-ID: <b5ac2e20-90cc-41c6-c172-88e406a6e1be@kaod.org> (raw)
In-Reply-To: <CANr=Z=Y+dJjWvhx2oCMRXh366W1A9P7nVWUbhP_VVD3NdP7SSw@mail.gmail.com>

On 10/15/18 10:39 PM, Joe Hershberger wrote:
> On Wed, Oct 10, 2018 at 6:45 AM Cédric Le Goater <clg@kaod.org> wrote:
>>
>> The driver is based on the previous one and the code is only adapted
>> to fit the driver model. The support for the Faraday ftgmac100
>> controller is the same with MAC and MDIO bus support for RGMII/RMII
>> modes.
>>
>> Configuration is updated to enable compile again. At this stage, the
>> driver compiles but is not yet functional.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>  include/netdev.h        |   1 -
>>  drivers/net/ftgmac100.c | 223 +++++++++++++++++++++++-----------------
>>  drivers/net/Kconfig     |  26 +++++
>>  3 files changed, 157 insertions(+), 93 deletions(-)
>>
>> diff --git a/include/netdev.h b/include/netdev.h
>> index 55001625fb92..0a1a3a2d8da2 100644
>> --- a/include/netdev.h
>> +++ b/include/netdev.h
>> @@ -43,7 +43,6 @@ int ethoc_initialize(u8 dev_num, int base_addr);
>>  int fec_initialize (bd_t *bis);
>>  int fecmxc_initialize(bd_t *bis);
>>  int fecmxc_initialize_multi(bd_t *bis, int dev_id, int phy_id, uint32_t addr);
>> -int ftgmac100_initialize(bd_t *bits);
>>  int ftmac100_initialize(bd_t *bits);
>>  int ftmac110_initialize(bd_t *bits);
>>  void gt6426x_eth_initialize(bd_t *bis);
>> diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
>> index c996f5f4a167..67a7c73503c5 100644
>> --- a/drivers/net/ftgmac100.c
>> +++ b/drivers/net/ftgmac100.c
>> @@ -7,15 +7,16 @@
>>   *
>>   * (C) Copyright 2010 Andes Technology
>>   * Macpaul Lin <macpaul@andestech.com>
>> + *
>> + * Copyright (C) 2018, IBM Corporation.
>>   */
>>
>> -#include <config.h>
>> -#include <common.h>
>> +#include <dm.h>
>> +#include <miiphy.h>
>>  #include <malloc.h>
>>  #include <net.h>
>> -#include <asm/io.h>
>> +#include <linux/io.h>
>>  #include <asm/dma-mapping.h>
>> -#include <linux/mii.h>
>>
>>  #include "ftgmac100.h"
>>
>> @@ -28,7 +29,19 @@
>>  /* PKTBUFSTX/PKTBUFSRX must both be power of 2 */
>>  #define PKTBUFSTX      4       /* must be power of 2 */
>>
>> +/**
>> + * struct ftgmac100_data - private data for the FTGMAC100 driver
>> + *
>> + * @iobase: The base address of the hardware registers
>> + * @txdes: The array of transmit descriptors
>> + * @rxdes: The array of receive descriptors
>> + * @tx_index: Transmit descriptor index in @txdes
>> + * @rx_index: Receive descriptor index in @rxdes
>> + * @phy_addr: The PHY interface address to use
>> + */
>>  struct ftgmac100_data {
>> +       struct ftgmac100 *iobase;
>> +
>>         ulong txdes_dma;
>>         struct ftgmac100_txdes *txdes;
>>         ulong rxdes_dma;
>> @@ -41,10 +54,10 @@ struct ftgmac100_data {
>>  /*
>>   * struct mii_bus functions
>>   */
>> -static int ftgmac100_mdiobus_read(struct eth_device *dev, int phy_addr,
>> -       int regnum)
>> +static int ftgmac100_mdiobus_read(struct ftgmac100_data *priv, int phy_addr,
>> +                                 int regnum)
>>  {
>> -       struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
>> +       struct ftgmac100 *ftgmac100 = priv->iobase;
>>         int phycr;
>>         int i;
>>
>> @@ -76,10 +89,10 @@ static int ftgmac100_mdiobus_read(struct eth_device *dev, int phy_addr,
>>         return -1;
>>  }
>>
>> -static int ftgmac100_mdiobus_write(struct eth_device *dev, int phy_addr,
>> -       int regnum, u16 value)
>> +static int ftgmac100_mdiobus_write(struct ftgmac100_data *priv, int phy_addr,
>> +                                  int regnum, u16 value)
>>  {
>> -       struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
>> +       struct ftgmac100 *ftgmac100 = priv->iobase;
>>         int phycr;
>>         int data;
>>         int i;
>> @@ -114,9 +127,10 @@ static int ftgmac100_mdiobus_write(struct eth_device *dev, int phy_addr,
>>         return -1;
>>  }
>>
>> -int ftgmac100_phy_read(struct eth_device *dev, int addr, int reg, u16 *value)
>> +int ftgmac100_phy_read(struct ftgmac100_data *priv, int addr, int reg,
>> +                      u16 *value)
>>  {
>> -       *value = ftgmac100_mdiobus_read(dev , addr, reg);
>> +       *value = ftgmac100_mdiobus_read(priv, addr, reg);
>>
>>         if (*value == -1)
>>                 return -1;
>> @@ -124,31 +138,31 @@ int ftgmac100_phy_read(struct eth_device *dev, int addr, int reg, u16 *value)
>>         return 0;
>>  }
>>
>> -int  ftgmac100_phy_write(struct eth_device *dev, int addr, int reg, u16 value)
>> +int ftgmac100_phy_write(struct ftgmac100_data *priv, int addr, int reg,
>> +                       u16 value)
>>  {
>> -       if (ftgmac100_mdiobus_write(dev, addr, reg, value) == -1)
>> +       if (ftgmac100_mdiobus_write(priv, addr, reg, value) == -1)
>>                 return -1;
>>
>>         return 0;
>>  }
>>
>> -static int ftgmac100_phy_reset(struct eth_device *dev)
>> +static int ftgmac100_phy_reset(struct ftgmac100_data *priv, struct udevice *dev)
> 
> Why does this function get a dev parameter? Seems unused.

For the printf below. later on in the pachset, the function is
completely removed, so it didn't seem important to introduce 
more changes.
 
> 
>>  {
>> -       struct ftgmac100_data *priv = dev->priv;
>>         int i;
>>         u16 status, adv;
>>
>>         adv = ADVERTISE_CSMA | ADVERTISE_ALL;
>>
>> -       ftgmac100_phy_write(dev, priv->phy_addr, MII_ADVERTISE, adv);
>> +       ftgmac100_phy_write(priv, priv->phy_addr, MII_ADVERTISE, adv);
>>
>>         printf("%s: Starting autonegotiation...\n", dev->name);
> 
> Seems like a useless print. Remove dev?>
> 
>>
>> -       ftgmac100_phy_write(dev, priv->phy_addr,
>> -               MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
>> +       ftgmac100_phy_write(priv, priv->phy_addr,
>> +                           MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
>>
>>         for (i = 0; i < 100000 / 100; i++) {
>> -               ftgmac100_phy_read(dev, priv->phy_addr, MII_BMSR, &status);
>> +               ftgmac100_phy_read(priv, priv->phy_addr, MII_BMSR, &status);
>>
>>                 if (status & BMSR_ANEGCOMPLETE)
>>                         break;
>> @@ -166,19 +180,17 @@ static int ftgmac100_phy_reset(struct eth_device *dev)
>>         return 1;
>>  }
>>
>> -static int ftgmac100_phy_init(struct eth_device *dev)
>> +static int ftgmac100_phy_init(struct ftgmac100_data *priv, struct udevice *dev)
> 
> Same here, why dev parameter? Only passed to reset.

The MDIO (patch 5) adds : 

    phydev = phy_connect(priv->bus, priv->phy_addr, dev, priv->phy_mode);

Nevetheless, I think we can improve the prototype of ftgmac100_phy_init()
to :

    static int ftgmac100_phy_init(struct udevice *dev) 

same for ftgmac100_mdio_init()


> 
>>  {
>> -       struct ftgmac100_data *priv = dev->priv;
>> -
>>         int phy_addr;
>>         u16 phy_id, status, adv, lpa, stat_ge;
>>         int media, speed, duplex;
>>         int i;
>>
>>         /* Check if the PHY is up to snuff... */
>> -       for (phy_addr = 0; phy_addr < CONFIG_PHY_MAX_ADDR; phy_addr++) {
>> +       for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
>>
>> -               ftgmac100_phy_read(dev, phy_addr, MII_PHYSID1, &phy_id);
>> +               ftgmac100_phy_read(priv, phy_addr, MII_PHYSID1, &phy_id);
>>
>>                 /*
>>                  * When it is unable to found PHY,
>> @@ -197,15 +209,15 @@ static int ftgmac100_phy_init(struct eth_device *dev)
>>                 return 0;
>>         }
> 
> [ ... ]
> 
> Looks good otherwise.

I will propose the prototype changes in v4.

Thanks,

C.

  reply	other threads:[~2018-10-16  5:39 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 11:41 [U-Boot] [PATCH v3 00/13] Support for the Faraday ftgmac100 controller Cédric Le Goater
2018-10-10 11:41 ` [U-Boot] [PATCH v3 01/13] net: ftgmac100: use the BIT() macro Cédric Le Goater
2018-10-11 23:13   ` Joel Stanley
2018-10-15 20:29   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 02/13] net: ftgmac100: use the aligned() macro Cédric Le Goater
2018-10-11 23:13   ` Joel Stanley
2018-10-15 20:30   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 03/13] net: ftgmac100: convert to driver model Cédric Le Goater
2018-10-11 23:15   ` Joel Stanley
2018-10-12  6:19     ` Cédric Le Goater
2018-10-15 20:39   ` Joe Hershberger
2018-10-16  5:39     ` Cédric Le Goater [this message]
2018-10-10 11:41 ` [U-Boot] [PATCH v3 04/13] net: ftgmac100: use setbits_le32() in the reset method Cédric Le Goater
2018-10-11 23:15   ` Joel Stanley
2018-10-15 20:40   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 05/13] net: ftgmac100: add MDIO bus and phylib support Cédric Le Goater
2018-10-11 23:17   ` Joel Stanley
2018-10-15 20:46   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 06/13] net: ftgmac100: convert the RX/TX descriptor arrays Cédric Le Goater
2018-10-11 23:18   ` Joel Stanley
2018-10-15 20:54   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 07/13] net: ftgmac100: handle timeouts when transmitting Cédric Le Goater
2018-10-11 23:23   ` Joel Stanley
2018-10-15 20:58   ` Joe Hershberger
2018-10-16  5:47     ` Cédric Le Goater
2018-10-10 11:41 ` [U-Boot] [PATCH v3 08/13] net: ftgmac100: add clock support Cédric Le Goater
2018-10-11 23:24   ` Joel Stanley
2018-10-15 21:00   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 09/13] aspeed: ast2500: fix missing break in D2PLL clock enablement Cédric Le Goater
2018-10-15 21:01   ` Joe Hershberger
2018-10-10 11:41 ` [U-Boot] [PATCH v3 10/13] net: ftgmac100: Add support for the Aspeed SoC Cédric Le Goater
2018-10-11 23:25   ` Joel Stanley
2018-10-15 21:02   ` Joe Hershberger
2018-10-10 11:42 ` [U-Boot] [PATCH v3 11/13] aspeed: Update ast2500 SoC DTS file to Linux v4.17-rc6 level Cédric Le Goater
2018-10-10 11:42 ` [U-Boot] [PATCH v3 12/13] aspeed: Activate ethernet devices on the ast2500 Eval Board Cédric Le Goater
2018-10-11 23:27   ` Joel Stanley
2018-10-15 21:04   ` Joe Hershberger
2018-10-10 11:42 ` [U-Boot] [PATCH v3 13/13] aspeed: ast2500: fix D2-PLL clock setting in RGMII mode Cédric Le Goater
2018-10-11 23:28   ` Joel Stanley
2018-10-15 21:05   ` Joe Hershberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5ac2e20-90cc-41c6-c172-88e406a6e1be@kaod.org \
    --to=clg@kaod.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.