Re: [U-Boot] [PATCH 2/7] net: mvpp2: Replace SMI implementation with marvell MDIO API

2019-08-14 Thread Joe Hershberger
On Wed, Aug 14, 2019 at 12:09 PM Nevo Hed  wrote:
>
> On Wed, Aug 14, 2019 at 11:39 AM Joe Hershberger
>  wrote:
> >
> > On Fri, Aug 2, 2019 at 12:54 PM  wrote:
> > >
> > > From: Ken Ma 
> > >
>
> > > -
> > > -static int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
> > > +int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
> >
> > Why does this need to be visible outside of this translation unit?
>
> Hi Joe
>
> Yes you are right, it should remain static.  This was in the
> downstream commit from Ken I pulled in - I reversed that and made it
> static again in my later commit in same patchset
>
> https://patchwork.ozlabs.org/patch/1142905/
>
> let me know if it is preferred to rewrite this commit  (I just don't
> know what the right way when submitting changes by others where the
> others' org instructed them to abandoned them)

When it is something minor like this, it's reasonable to simply make
the small adjustment and a brief comment in the commit log and leave
the author attribution.

Cheers,
-Joe
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/7] net: mvpp2: Replace SMI implementation with marvell MDIO API

2019-08-14 Thread Nevo Hed
On Wed, Aug 14, 2019 at 11:39 AM Joe Hershberger
 wrote:
>
> On Fri, Aug 2, 2019 at 12:54 PM  wrote:
> >
> > From: Ken Ma 
> >

> > -
> > -static int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
> > +int mvpp2_recv(struct udevice *dev, int flags, uchar **packetp)
>
> Why does this need to be visible outside of this translation unit?

Hi Joe

Yes you are right, it should remain static.  This was in the
downstream commit from Ken I pulled in - I reversed that and made it
static again in my later commit in same patchset

https://patchwork.ozlabs.org/patch/1142905/

let me know if it is preferred to rewrite this commit  (I just don't
know what the right way when submitting changes by others where the
others' org instructed them to abandoned them)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/7] net: mvpp2: Replace SMI implementation with marvell MDIO API

2019-08-14 Thread Joe Hershberger
On Fri, Aug 2, 2019 at 12:54 PM  wrote:
>
> From: Ken Ma 
>
> Since marvell MDIO driver is added, SMI function implementation in
> mvpp2 driver can be removed and NETA driver can use marvell MDIO API
> directly.
> This replacement also fixes 2 old issues:
> 1. Each pp2 port device should have its own mdio bus field member since
>some pp2 ports may use SMI mdio bus while some other pp2 ports may
>use XSMI mdio bus, but the old mvpp2_base device has a shared bus
>for its all pp2 ports; this patch moves mdio bus field member from
>struct mvpp2 to struct mvpp2_port;
> 2. Old code uses mvpp2_base device name as mdio bus name, but for
>Armada80x0, cp0 ethernet device and cp1 ethernet device have the
>same device name - "ethernet@0"; and because mdio_register() checks
>unique name, then the second probed mvpp2_base device fails to
>register mdio bus; since new marvell MDIO driver has resolved the
>unique name issue - different mdio names can be set in fdt and if
>a mdio name is not set, the default mdio name will be generated from
>the mdio bus base address, so this issue is fixed by this
>replacement.
>
> Signed-off-by: Ken Ma 
> Reviewed-by: Igal Liberman 
> Tested-by: Igal Liberman 
> Signed-off-by: Nevo Hed 
> ---
>
>  drivers/net/Kconfig |   1 +
>  drivers/net/mvpp2.c | 158 
>  2 files changed, 13 insertions(+), 146 deletions(-)
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 5fd31b03cf..d8c4dd6f4d 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -297,6 +297,7 @@ config MVPP2
> bool "Marvell Armada 375/7K/8K network interface support"
> depends on ARMADA_375 || ARMADA_8K
> select PHYLIB
> +   select MVMDIO
> help
>   This driver supports the network interface units in the
>   Marvell ARMADA 375, 7K and 8K SoCs.
> diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
> index f36c8236b1..b6dfed5c54 100644
> --- a/drivers/net/mvpp2.c
> +++ b/drivers/net/mvpp2.c
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -62,8 +63,6 @@ do {
>   \
>  #define MTU1500
>  #define RX_BUFFER_SIZE (ALIGN(MTU + WRAP, ARCH_DMA_MINALIGN))
>
> -#define MVPP2_SMI_TIMEOUT  1
> -
>  /* RX Fifo Registers */
>  #define MVPP2_RX_DATA_FIFO_SIZE_REG(port)  (0x00 + 4 * (port))
>  #define MVPP2_RX_ATTR_FIFO_SIZE_REG(port)  (0x20 + 4 * (port))
> @@ -490,23 +489,8 @@ do { 
>   \
>  #define MVPP2_QUEUE_NEXT_DESC(q, index) \
> (((index) < (q)->last_desc) ? ((index) + 1) : 0)
>
> -/* SMI: 0xc0054 -> offset 0x54 to lms_base */
> -#define MVPP21_SMI 0x0054
>  /* PP2.2: SMI: 0x12a200 -> offset 0x1200 to iface_base */
>  #define MVPP22_SMI 0x1200
> -#define MVPP2_PHY_REG_MASK 0x1f
> -/* SMI register fields */
> -#define MVPP2_SMI_DATA_OFFS0   /* Data */
> -#define MVPP2_SMI_DATA_MASK(0x << 
> MVPP2_SMI_DATA_OFFS)
> -#define MVPP2_SMI_DEV_ADDR_OFFS16  /* PHY device address 
> */
> -#define MVPP2_SMI_REG_ADDR_OFFS21  /* PHY device reg 
> addr*/
> -#define MVPP2_SMI_OPCODE_OFFS  26  /* Write/Read opcode 
> */
> -#define MVPP2_SMI_OPCODE_READ  (1 << MVPP2_SMI_OPCODE_OFFS)
> -#define MVPP2_SMI_READ_VALID   (1 << 27)   /* Read Valid 
> */
> -#define MVPP2_SMI_BUSY (1 << 28)   /* Busy */
> -
> -#define MVPP2_PHY_ADDR_MASK0x1f
> -#define MVPP2_PHY_REG_MASK 0x1f
>
>  /* Additional PPv2.2 offsets */
>  #define MVPP22_MPCS0x007000
> @@ -973,7 +957,6 @@ struct mvpp2_port {
>
> struct phy_device *phy_dev;
> phy_interface_t phy_interface;
> -   int phy_node;
> int phyaddr;
> struct mii_dev *bus;
>  #ifdef CONFIG_DM_GPIO
> @@ -4562,7 +4545,7 @@ static int mvpp2_open(struct udevice *dev, struct 
> mvpp2_port *port)
> return err;
> }
>
> -   if (port->phy_node) {
> +   if (port->phyaddr < PHY_MAX_ADDR) {
> mvpp2_phy_connect(dev, port);
> mvpp2_link_event(port);
> } else {
> @@ -4701,6 +4684,7 @@ static int phy_info_parse(struct udevice *dev, struct 
> mvpp2_port *port)
> u32 id;
> u32 phyaddr = 0;
> int phy_mode = -1;
> +   int ret;
>
> /* Default mdio_base from the same eth base */
> if (port->priv->hw_version == MVPP21)
> @@ -4719,17 +4703,12 @@ static int phy_info_parse(struct udevice *dev, struct 
> mvpp2_port *port)
> 

[U-Boot] [PATCH 2/7] net: mvpp2: Replace SMI implementation with marvell MDIO API

2019-08-02 Thread nhed+uboot
From: Ken Ma 

Since marvell MDIO driver is added, SMI function implementation in
mvpp2 driver can be removed and NETA driver can use marvell MDIO API
directly.
This replacement also fixes 2 old issues:
1. Each pp2 port device should have its own mdio bus field member since
   some pp2 ports may use SMI mdio bus while some other pp2 ports may
   use XSMI mdio bus, but the old mvpp2_base device has a shared bus
   for its all pp2 ports; this patch moves mdio bus field member from
   struct mvpp2 to struct mvpp2_port;
2. Old code uses mvpp2_base device name as mdio bus name, but for
   Armada80x0, cp0 ethernet device and cp1 ethernet device have the
   same device name - "ethernet@0"; and because mdio_register() checks
   unique name, then the second probed mvpp2_base device fails to
   register mdio bus; since new marvell MDIO driver has resolved the
   unique name issue - different mdio names can be set in fdt and if
   a mdio name is not set, the default mdio name will be generated from
   the mdio bus base address, so this issue is fixed by this
   replacement.

Signed-off-by: Ken Ma 
Reviewed-by: Igal Liberman 
Tested-by: Igal Liberman 
Signed-off-by: Nevo Hed 
---

 drivers/net/Kconfig |   1 +
 drivers/net/mvpp2.c | 158 
 2 files changed, 13 insertions(+), 146 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 5fd31b03cf..d8c4dd6f4d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -297,6 +297,7 @@ config MVPP2
bool "Marvell Armada 375/7K/8K network interface support"
depends on ARMADA_375 || ARMADA_8K
select PHYLIB
+   select MVMDIO
help
  This driver supports the network interface units in the
  Marvell ARMADA 375, 7K and 8K SoCs.
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index f36c8236b1..b6dfed5c54 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -62,8 +63,6 @@ do {  
\
 #define MTU1500
 #define RX_BUFFER_SIZE (ALIGN(MTU + WRAP, ARCH_DMA_MINALIGN))
 
-#define MVPP2_SMI_TIMEOUT  1
-
 /* RX Fifo Registers */
 #define MVPP2_RX_DATA_FIFO_SIZE_REG(port)  (0x00 + 4 * (port))
 #define MVPP2_RX_ATTR_FIFO_SIZE_REG(port)  (0x20 + 4 * (port))
@@ -490,23 +489,8 @@ do {   
\
 #define MVPP2_QUEUE_NEXT_DESC(q, index) \
(((index) < (q)->last_desc) ? ((index) + 1) : 0)
 
-/* SMI: 0xc0054 -> offset 0x54 to lms_base */
-#define MVPP21_SMI 0x0054
 /* PP2.2: SMI: 0x12a200 -> offset 0x1200 to iface_base */
 #define MVPP22_SMI 0x1200
-#define MVPP2_PHY_REG_MASK 0x1f
-/* SMI register fields */
-#define MVPP2_SMI_DATA_OFFS0   /* Data */
-#define MVPP2_SMI_DATA_MASK(0x << 
MVPP2_SMI_DATA_OFFS)
-#define MVPP2_SMI_DEV_ADDR_OFFS16  /* PHY device address */
-#define MVPP2_SMI_REG_ADDR_OFFS21  /* PHY device reg addr*/
-#define MVPP2_SMI_OPCODE_OFFS  26  /* Write/Read opcode */
-#define MVPP2_SMI_OPCODE_READ  (1 << MVPP2_SMI_OPCODE_OFFS)
-#define MVPP2_SMI_READ_VALID   (1 << 27)   /* Read Valid */
-#define MVPP2_SMI_BUSY (1 << 28)   /* Busy */
-
-#define MVPP2_PHY_ADDR_MASK0x1f
-#define MVPP2_PHY_REG_MASK 0x1f
 
 /* Additional PPv2.2 offsets */
 #define MVPP22_MPCS0x007000
@@ -973,7 +957,6 @@ struct mvpp2_port {
 
struct phy_device *phy_dev;
phy_interface_t phy_interface;
-   int phy_node;
int phyaddr;
struct mii_dev *bus;
 #ifdef CONFIG_DM_GPIO
@@ -4562,7 +4545,7 @@ static int mvpp2_open(struct udevice *dev, struct 
mvpp2_port *port)
return err;
}
 
-   if (port->phy_node) {
+   if (port->phyaddr < PHY_MAX_ADDR) {
mvpp2_phy_connect(dev, port);
mvpp2_link_event(port);
} else {
@@ -4701,6 +4684,7 @@ static int phy_info_parse(struct udevice *dev, struct 
mvpp2_port *port)
u32 id;
u32 phyaddr = 0;
int phy_mode = -1;
+   int ret;
 
/* Default mdio_base from the same eth base */
if (port->priv->hw_version == MVPP21)
@@ -4719,17 +4703,12 @@ static int phy_info_parse(struct udevice *dev, struct 
mvpp2_port *port)
dev_err(>dev, "could not find phy address\n");
return -1;
}
-
-   phy_ofnode = ofnode_get_parent(offset_to_ofnode(phy_node));
-   phy_base = ofnode_get_addr(phy_ofnode);
-   port->mdio_base = (void