Re: [PATCH net-next 08/10] drivers: net: xgene: Poll link status via GPIO

2016-07-31 Thread Quan Nguyen
On Sat, Jul 30, 2016 at 7:34 AM, Iyappan Subramanian
 wrote:
> When 10GbE SFP+ module is not plugged in or cable is not connected,
> the link status register does not report the proper state due
> to floating signal. This patch checks the module present status via an
> GPIO to determine whether to ignore the link status register and report
> link down.
>
> Signed-off-by: Quan Nguyen 
> Signed-off-by: Iyappan Subramanian 
> Tested-by: Fushen Chen 
> ---
>  drivers/net/ethernet/apm/xgene/Kconfig|  1 +
>  drivers/net/ethernet/apm/xgene/xgene_enet_main.c  | 15 +++
>  drivers/net/ethernet/apm/xgene/xgene_enet_main.h  |  1 +
>  drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c |  6 ++
>  4 files changed, 23 insertions(+)
>
> diff --git a/drivers/net/ethernet/apm/xgene/Kconfig 
> b/drivers/net/ethernet/apm/xgene/Kconfig
> index 300e3b5..6c60a7d 100644
> --- a/drivers/net/ethernet/apm/xgene/Kconfig
> +++ b/drivers/net/ethernet/apm/xgene/Kconfig
> @@ -4,6 +4,7 @@ config NET_XGENE
> depends on ARCH_XGENE || COMPILE_TEST
> select PHYLIB
> select MDIO_XGENE
> +   select GPIO_XGENE_SB

I think this should change to GPIOLIB as we dont expected to work with
only gpio-xgene-sb.c. Other gpio drivers should be used as well.

> help
>   This is the Ethernet driver for the on-chip ethernet interface on 
> the
>   APM X-Gene SoC.
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c 
> b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> index 383e7ad..bda386d 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
> @@ -19,6 +19,7 @@
>   * along with this program.  If not, see .
>   */
>
> +#include 
>  #include "xgene_enet_main.h"
>  #include "xgene_enet_hw.h"
>  #include "xgene_enet_sgmac.h"
> @@ -1322,6 +1323,18 @@ static int xgene_enet_check_phy_handle(struct 
> xgene_enet_pdata *pdata)
> return 0;
>  }
>
> +static void xgene_enet_gpiod_get(struct xgene_enet_pdata *pdata)
> +{
> +   struct device *dev = >pdev->dev;
> +
> +   if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII)
> +   return;
> +
> +   pdata->sfp_rdy = gpiod_get(dev, "rxlos", GPIOD_IN);
> +   if (IS_ERR(pdata->sfp_rdy))
> +   pdata->sfp_rdy = gpiod_get(dev, "sfp", GPIOD_IN);
> +}
> +
>  static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
>  {
> struct platform_device *pdev;
> @@ -1411,6 +1424,8 @@ static int xgene_enet_get_resources(struct 
> xgene_enet_pdata *pdata)
> if (ret)
> return ret;
>
> +   xgene_enet_gpiod_get(pdata);
> +
> pdata->clk = devm_clk_get(>dev, NULL);
> if (IS_ERR(pdata->clk)) {
> /* Firmware may have set up the clock already. */
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h 
> b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
> index 53f4a16..b339fc1 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
> @@ -217,6 +217,7 @@ struct xgene_enet_pdata {
> u8 tx_delay;
> u8 rx_delay;
> bool mdio_driver;
> +   struct gpio_desc *sfp_rdy;
>  };
>
>  struct xgene_indirect_ctl {
> diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c 
> b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
> index 4087dba..d672e71 100644
> --- a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
> +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
> @@ -18,6 +18,8 @@
>   * along with this program.  If not, see .
>   */
>
> +#include 
> +#include 
>  #include "xgene_enet_main.h"
>  #include "xgene_enet_hw.h"
>  #include "xgene_enet_xgmac.h"
> @@ -399,10 +401,14 @@ static void xgene_enet_link_state(struct work_struct 
> *work)
>  {
> struct xgene_enet_pdata *pdata = container_of(to_delayed_work(work),
>  struct xgene_enet_pdata, link_work);
> +   struct gpio_desc *sfp_rdy = pdata->sfp_rdy;
> struct net_device *ndev = pdata->ndev;
> u32 link_status, poll_interval;
>
> link_status = xgene_enet_link_status(pdata);
> +   if (link_status && !IS_ERR(sfp_rdy) && !gpiod_get_value(sfp_rdy))
> +   link_status = 0;
> +
> if (link_status) {
> if (!netif_carrier_ok(ndev)) {
> netif_carrier_on(ndev);
> --
> 1.9.1
>


Re: [PATCH net-next 08/10] drivers: net: xgene: Poll link status via GPIO

2016-07-29 Thread kbuild test robot
Hi,

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Iyappan-Subramanian/Fix-warning-and-issues/20160730-083713
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   drivers/gpio/gpio-xgene-sb.c: In function 'xgene_gpio_sb_irq_set_type':
   drivers/gpio/gpio-xgene-sb.c:111:10: error: implicit declaration of function 
'irq_chip_set_type_parent' [-Werror=implicit-function-declaration]
  return irq_chip_set_type_parent(d, IRQ_TYPE_EDGE_RISING);
 ^
   drivers/gpio/gpio-xgene-sb.c: At top level:
   drivers/gpio/gpio-xgene-sb.c:118:13: error: 'irq_chip_eoi_parent' undeclared 
here (not in a function)
 .irq_eoi = irq_chip_eoi_parent,
^
   drivers/gpio/gpio-xgene-sb.c:119:20: error: 'irq_chip_mask_parent' 
undeclared here (not in a function)
 .irq_mask   = irq_chip_mask_parent,
   ^
   drivers/gpio/gpio-xgene-sb.c:120:20: error: 'irq_chip_unmask_parent' 
undeclared here (not in a function)
 .irq_unmask = irq_chip_unmask_parent,
   ^
   drivers/gpio/gpio-xgene-sb.c: In function 'xgene_gpio_sb_domain_alloc':
   drivers/gpio/gpio-xgene-sb.c:198:3: error: implicit declaration of function 
'irq_domain_set_hwirq_and_chip' [-Werror=implicit-function-declaration]
  irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
  ^
   drivers/gpio/gpio-xgene-sb.c:201:31: error: 'struct irq_domain' has no 
member named 'parent'
 parent_fwspec.fwnode = domain->parent->fwnode;
  ^
   drivers/gpio/gpio-xgene-sb.c:215:9: error: implicit declaration of function 
'irq_domain_alloc_irqs_parent' [-Werror=implicit-function-declaration]
 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
^
   drivers/gpio/gpio-xgene-sb.c: At top level:
   drivers/gpio/gpio-xgene-sb.c:220:2: error: unknown field 'translate' 
specified in initializer
 .translate  = xgene_gpio_sb_domain_translate,
 ^
>> drivers/gpio/gpio-xgene-sb.c:220:20: error: initialization from incompatible 
>> pointer type [-Werror=incompatible-pointer-types]
 .translate  = xgene_gpio_sb_domain_translate,
   ^
   drivers/gpio/gpio-xgene-sb.c:220:20: note: (near initialization for 
'xgene_gpio_sb_domain_ops.match')
   drivers/gpio/gpio-xgene-sb.c:221:2: error: unknown field 'alloc' specified 
in initializer
 .alloc  = xgene_gpio_sb_domain_alloc,
 ^
   drivers/gpio/gpio-xgene-sb.c:221:20: error: initialization from incompatible 
pointer type [-Werror=incompatible-pointer-types]
 .alloc  = xgene_gpio_sb_domain_alloc,
   ^
   drivers/gpio/gpio-xgene-sb.c:221:20: note: (near initialization for 
'xgene_gpio_sb_domain_ops.select')
   drivers/gpio/gpio-xgene-sb.c:222:2: error: unknown field 'free' specified in 
initializer
 .free   = irq_domain_free_irqs_common,
 ^
   drivers/gpio/gpio-xgene-sb.c:222:20: error: 'irq_domain_free_irqs_common' 
undeclared here (not in a function)
 .free   = irq_domain_free_irqs_common,
   ^
   drivers/gpio/gpio-xgene-sb.c:223:2: error: unknown field 'activate' 
specified in initializer
 .activate = xgene_gpio_sb_domain_activate,
 ^
   drivers/gpio/gpio-xgene-sb.c:223:14: error: initialization from incompatible 
pointer type [-Werror=incompatible-pointer-types]
 .activate = xgene_gpio_sb_domain_activate,
 ^
   drivers/gpio/gpio-xgene-sb.c:223:14: note: (near initialization for 
'xgene_gpio_sb_domain_ops.unmap')
   drivers/gpio/gpio-xgene-sb.c:224:2: error: unknown field 'deactivate' 
specified in initializer
 .deactivate = xgene_gpio_sb_domain_deactivate,
 ^
   drivers/gpio/gpio-xgene-sb.c:224:16: error: initialization from incompatible 
pointer type [-Werror=incompatible-pointer-types]
 .deactivate = xgene_gpio_sb_domain_deactivate,
   ^
   drivers/gpio/gpio-xgene-sb.c:224:16: note: (near initialization for 
'xgene_gpio_sb_domain_ops.xlate')
   drivers/gpio/gpio-xgene-sb.c: In function 'xgene_gpio_sb_probe':
   drivers/gpio/gpio-xgene-sb.c:293:21: error: implicit declaration of function 
'irq_domain_create_hierarchy' [-Werror=implicit-function-declaration]
 priv->irq_domain = irq_domain_create_hierarchy(parent_domain,
^
   drivers/gpio/gpio-xgene-sb.c:293:19: warning: assignment makes pointer from 
integer without a cast [-Wint-conversion]
 priv->irq_domain = irq_domain_create_hierarchy(parent_domain,
  ^
   cc1: some warnings being treated as errors

vim +220 

Re: [PATCH net-next 08/10] drivers: net: xgene: Poll link status via GPIO

2016-07-29 Thread kbuild test robot
Hi,

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Iyappan-Subramanian/Fix-warning-and-issues/20160730-083713
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All error/warnings (new ones prefixed by >>):

   drivers/gpio/gpio-xgene-sb.c: In function 'xgene_gpio_sb_irq_set_type':
>> drivers/gpio/gpio-xgene-sb.c:111:3: error: implicit declaration of function 
>> 'irq_chip_set_type_parent' [-Werror=implicit-function-declaration]
  return irq_chip_set_type_parent(d, IRQ_TYPE_EDGE_RISING);
  ^
   drivers/gpio/gpio-xgene-sb.c: At top level:
>> drivers/gpio/gpio-xgene-sb.c:118:13: error: 'irq_chip_eoi_parent' undeclared 
>> here (not in a function)
 .irq_eoi = irq_chip_eoi_parent,
^
>> drivers/gpio/gpio-xgene-sb.c:119:20: error: 'irq_chip_mask_parent' 
>> undeclared here (not in a function)
 .irq_mask   = irq_chip_mask_parent,
   ^
>> drivers/gpio/gpio-xgene-sb.c:120:20: error: 'irq_chip_unmask_parent' 
>> undeclared here (not in a function)
 .irq_unmask = irq_chip_unmask_parent,
   ^
   drivers/gpio/gpio-xgene-sb.c: In function 'xgene_gpio_sb_domain_alloc':
>> drivers/gpio/gpio-xgene-sb.c:198:3: error: implicit declaration of function 
>> 'irq_domain_set_hwirq_and_chip' [-Werror=implicit-function-declaration]
  irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
  ^
>> drivers/gpio/gpio-xgene-sb.c:201:31: error: 'struct irq_domain' has no 
>> member named 'parent'
 parent_fwspec.fwnode = domain->parent->fwnode;
  ^
>> drivers/gpio/gpio-xgene-sb.c:215:2: error: implicit declaration of function 
>> 'irq_domain_alloc_irqs_parent' [-Werror=implicit-function-declaration]
 return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
 ^
   drivers/gpio/gpio-xgene-sb.c: At top level:
>> drivers/gpio/gpio-xgene-sb.c:220:2: error: unknown field 'translate' 
>> specified in initializer
 .translate  = xgene_gpio_sb_domain_translate,
 ^
>> drivers/gpio/gpio-xgene-sb.c:220:2: warning: initialization from 
>> incompatible pointer type
   drivers/gpio/gpio-xgene-sb.c:220:2: warning: (near initialization for 
'xgene_gpio_sb_domain_ops.match')
>> drivers/gpio/gpio-xgene-sb.c:221:2: error: unknown field 'alloc' specified 
>> in initializer
 .alloc  = xgene_gpio_sb_domain_alloc,
 ^
   drivers/gpio/gpio-xgene-sb.c:221:2: warning: initialization from 
incompatible pointer type
   drivers/gpio/gpio-xgene-sb.c:221:2: warning: (near initialization for 
'xgene_gpio_sb_domain_ops.select')
>> drivers/gpio/gpio-xgene-sb.c:222:2: error: unknown field 'free' specified in 
>> initializer
 .free   = irq_domain_free_irqs_common,
 ^
>> drivers/gpio/gpio-xgene-sb.c:222:20: error: 'irq_domain_free_irqs_common' 
>> undeclared here (not in a function)
 .free   = irq_domain_free_irqs_common,
   ^
>> drivers/gpio/gpio-xgene-sb.c:223:2: error: unknown field 'activate' 
>> specified in initializer
 .activate = xgene_gpio_sb_domain_activate,
 ^
   drivers/gpio/gpio-xgene-sb.c:223:2: warning: initialization from 
incompatible pointer type
   drivers/gpio/gpio-xgene-sb.c:223:2: warning: (near initialization for 
'xgene_gpio_sb_domain_ops.unmap')
>> drivers/gpio/gpio-xgene-sb.c:224:2: error: unknown field 'deactivate' 
>> specified in initializer
 .deactivate = xgene_gpio_sb_domain_deactivate,
 ^
   drivers/gpio/gpio-xgene-sb.c:224:2: warning: initialization from 
incompatible pointer type
   drivers/gpio/gpio-xgene-sb.c:224:2: warning: (near initialization for 
'xgene_gpio_sb_domain_ops.xlate')
   drivers/gpio/gpio-xgene-sb.c: In function 'xgene_gpio_sb_probe':
>> drivers/gpio/gpio-xgene-sb.c:293:2: error: implicit declaration of function 
>> 'irq_domain_create_hierarchy' [-Werror=implicit-function-declaration]
 priv->irq_domain = irq_domain_create_hierarchy(parent_domain,
 ^
>> drivers/gpio/gpio-xgene-sb.c:293:19: warning: assignment makes pointer from 
>> integer without a cast
 priv->irq_domain = irq_domain_create_hierarchy(parent_domain,
  ^
   cc1: some warnings being treated as errors

vim +/irq_chip_set_type_parent +111 drivers/gpio/gpio-xgene-sb.c

1013fc417 Quan Nguyen2016-02-17  105gpio * 2, 1);
1013fc417 Quan Nguyen2016-02-17  106xgene_gpio_set_bit(>gc, 
priv->regs + MPA_GPIO_INT_LVL,
1013fc417 Quan Nguyen2016-02-17  107d->hwirq, 
lvl_type);
1013fc417 Quan Nguyen2016-02-17  108  
1013fc417 Quan Nguyen2016-02-17  109/* Propagate IRQ type setting 
to parent */

Re: [PATCH net-next 08/10] drivers: net: xgene: Poll link status via GPIO

2016-07-29 Thread kbuild test robot
Hi,

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Iyappan-Subramanian/Fix-warning-and-issues/20160730-083713
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

warning: (NET_XGENE) selects GPIO_XGENE_SB which has unmet direct dependencies 
(GPIOLIB && ARCH_XGENE && OF_GPIO)

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH net-next 08/10] drivers: net: xgene: Poll link status via GPIO

2016-07-29 Thread Iyappan Subramanian
When 10GbE SFP+ module is not plugged in or cable is not connected,
the link status register does not report the proper state due
to floating signal. This patch checks the module present status via an
GPIO to determine whether to ignore the link status register and report
link down.

Signed-off-by: Quan Nguyen 
Signed-off-by: Iyappan Subramanian 
Tested-by: Fushen Chen 
---
 drivers/net/ethernet/apm/xgene/Kconfig|  1 +
 drivers/net/ethernet/apm/xgene/xgene_enet_main.c  | 15 +++
 drivers/net/ethernet/apm/xgene/xgene_enet_main.h  |  1 +
 drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c |  6 ++
 4 files changed, 23 insertions(+)

diff --git a/drivers/net/ethernet/apm/xgene/Kconfig 
b/drivers/net/ethernet/apm/xgene/Kconfig
index 300e3b5..6c60a7d 100644
--- a/drivers/net/ethernet/apm/xgene/Kconfig
+++ b/drivers/net/ethernet/apm/xgene/Kconfig
@@ -4,6 +4,7 @@ config NET_XGENE
depends on ARCH_XGENE || COMPILE_TEST
select PHYLIB
select MDIO_XGENE
+   select GPIO_XGENE_SB
help
  This is the Ethernet driver for the on-chip ethernet interface on the
  APM X-Gene SoC.
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 383e7ad..bda386d 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -19,6 +19,7 @@
  * along with this program.  If not, see .
  */
 
+#include 
 #include "xgene_enet_main.h"
 #include "xgene_enet_hw.h"
 #include "xgene_enet_sgmac.h"
@@ -1322,6 +1323,18 @@ static int xgene_enet_check_phy_handle(struct 
xgene_enet_pdata *pdata)
return 0;
 }
 
+static void xgene_enet_gpiod_get(struct xgene_enet_pdata *pdata)
+{
+   struct device *dev = >pdev->dev;
+
+   if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII)
+   return;
+
+   pdata->sfp_rdy = gpiod_get(dev, "rxlos", GPIOD_IN);
+   if (IS_ERR(pdata->sfp_rdy))
+   pdata->sfp_rdy = gpiod_get(dev, "sfp", GPIOD_IN);
+}
+
 static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
 {
struct platform_device *pdev;
@@ -1411,6 +1424,8 @@ static int xgene_enet_get_resources(struct 
xgene_enet_pdata *pdata)
if (ret)
return ret;
 
+   xgene_enet_gpiod_get(pdata);
+
pdata->clk = devm_clk_get(>dev, NULL);
if (IS_ERR(pdata->clk)) {
/* Firmware may have set up the clock already. */
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h 
b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
index 53f4a16..b339fc1 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
@@ -217,6 +217,7 @@ struct xgene_enet_pdata {
u8 tx_delay;
u8 rx_delay;
bool mdio_driver;
+   struct gpio_desc *sfp_rdy;
 };
 
 struct xgene_indirect_ctl {
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
index 4087dba..d672e71 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
@@ -18,6 +18,8 @@
  * along with this program.  If not, see .
  */
 
+#include 
+#include 
 #include "xgene_enet_main.h"
 #include "xgene_enet_hw.h"
 #include "xgene_enet_xgmac.h"
@@ -399,10 +401,14 @@ static void xgene_enet_link_state(struct work_struct 
*work)
 {
struct xgene_enet_pdata *pdata = container_of(to_delayed_work(work),
 struct xgene_enet_pdata, link_work);
+   struct gpio_desc *sfp_rdy = pdata->sfp_rdy;
struct net_device *ndev = pdata->ndev;
u32 link_status, poll_interval;
 
link_status = xgene_enet_link_status(pdata);
+   if (link_status && !IS_ERR(sfp_rdy) && !gpiod_get_value(sfp_rdy))
+   link_status = 0;
+
if (link_status) {
if (!netif_carrier_ok(ndev)) {
netif_carrier_on(ndev);
-- 
1.9.1