public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Purna Chandra Mandal <purna.mandal@microchip.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 12/13] drivers: net: add Microchip PIC32 ethernet controller driver.
Date: Wed, 6 Jan 2016 16:31:27 +0530	[thread overview]
Message-ID: <568CF407.4000400@microchip.com> (raw)
In-Reply-To: <CACUy__UF0Dq+ugGo9vbR4VdcW8tiO=DNLhKxv4FapzUoeH4Mvw@mail.gmail.com>

On 01/06/2016 02:32 AM, Daniel Schwierzeck wrote:

> [...]
> +
> +static int _pic32eth_init(struct pic32eth_device *pedev, u8 *macaddr)
> +{
> +       int ret;
> +
> +       /* configure controller */
> +       _eth_ctrl_reset(pedev);
> +
> +       /* reset mac_regs */
> +       _mac_reset(pedev);
> +
> +       /* configure the PHY */
> +       phy_config(pedev->phydev);
> +
> +       /* initialize MAC */
> +       _mac_init(pedev, macaddr);
> +
> +       /* init RX descriptor; TX descriptors are handled in xmit */
> +       _eth_desc_init(pedev);
> I am not sure if there is a convention but I would replace all
> function names with a leading underscore to pic32_*
>
ack. Rename functions accordingly.

>> +
>> +       /* Start up & update link status of PHY */
>> +       phy_startup(pedev->phydev);
>> +
>> +       /* adjust mac with phy link status */
>> +       ret = _mac_adjust_link(pedev);
>> +       if (ret) {
>> +               _pic32eth_halt(pedev);
>> +               return ret;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>> [...]
>> +
>> +static int pic32_eth_probe(struct udevice *dev)
>> +{
>> +       struct eth_pdata *pdata = dev_get_platdata(dev);
>> +       struct pic32eth_device *priv = dev_get_priv(dev);
>> +       void __iomem *iobase;
>> +       int phy_addr = 0;
>> +
>> +#if defined(CONFIG_PHY_ADDR)
>> +       phy_addr = CONFIG_PHY_ADDR;
>> +#endif
>> +       iobase = pic32_ioremap((ulong)pdata->iobase);
>> +
>> +       /* initialize */
>> +       priv->phy_addr  = phy_addr;
>> +       priv->phyif     = pdata->phy_interface;
>> +       priv->ectl_regs = (struct pic32_ectl_regs *)(iobase);
>> +       priv->emac_regs = (struct pic32_emac_regs *)(iobase + PIC32_EMAC1CFG1);
>> +
>> +       gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
>> +                                  "reset-gpios", 0,
>> +                                  &priv->rst_gpio, GPIOD_IS_OUT);
>> +       _mdio_init(priv);
>> +
>> +       return _phy_init(priv, dev);
>> +}
>> +
>> +static int pic32_eth_remove(struct udevice *dev)
>> +{
>> +       struct pic32eth_device *priv = dev_get_priv(dev);
>> +       struct mii_dev *bus;
>> +
>> +       dm_gpio_free(dev, &priv->rst_gpio);
>> +       phy_shutdown(priv->phydev);
>> +       free(priv->phydev);
>> +       bus = miiphy_get_dev_by_name(PIC32_MDIO_NAME);
>> +       mdio_unregister(bus);
>> +       mdio_free(bus);
>> +
>> +       return 0;
>> +}
>> +
>> +static int pic32_eth_ofdata_to_platdata(struct udevice *dev)
>> +{
>> +       struct eth_pdata *pdata = dev_get_platdata(dev);
>> +       const char *phy_mode;
>> +
>> +       pdata->iobase = dev_get_addr(dev);
>> +       pdata->phy_interface = -1;
>> +       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
>> +       if (phy_mode)
>> +               pdata->phy_interface = phy_get_interface_by_name(phy_mode);
>> +
>> +       if (pdata->phy_interface == -1) {
>> +               debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
>> +               return -EINVAL;
>> +       }
>> +
>> +       return 0;
> all that code could be moved to pic32_eth_probe()

ack. Will update.

>> +}
>> +
>> +static const struct udevice_id pic32_eth_ids[] = {
>> +       { .compatible = "microchip,pic32mzda-eth" },
>> +       { }
>> +};
>> +
>> +U_BOOT_DRIVER(pic32_ethernet) = {
>> +       .name                   = "pic32_ethernet",
>> +       .id                     = UCLASS_ETH,
>> +       .of_match               = pic32_eth_ids,
>> +       .ofdata_to_platdata     = pic32_eth_ofdata_to_platdata,
>> +       .probe                  = pic32_eth_probe,
>> +       .remove                 = pic32_eth_remove,
>> +       .ops                    = &pic32_eth_ops,
>> +       .priv_auto_alloc_size   = sizeof(struct pic32eth_device),
>> +       .platdata_auto_alloc_size       = sizeof(struct eth_pdata),
>> +};
>> diff --git a/drivers/net/pic32_eth.h b/drivers/net/pic32_eth.h
>> new file mode 100644
>> index 0000000..5933661

[...]

  reply	other threads:[~2016-01-06 11:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 14:02 [U-Boot] [PATCH v2 12/13] drivers: net: add Microchip PIC32 ethernet controller driver Purna Chandra Mandal
2016-01-05 21:02 ` Daniel Schwierzeck
2016-01-06 11:01   ` Purna Chandra Mandal [this message]
2016-01-05 23:00 ` Joe Hershberger
2016-01-06 11:56   ` Purna Chandra Mandal
2016-01-06 18:41     ` Joe Hershberger
2016-01-07  5:14       ` Purna Chandra Mandal

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=568CF407.4000400@microchip.com \
    --to=purna.mandal@microchip.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox