netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] ne: Add h8300 support.
@ 2015-10-02  6:04 Yoshinori Sato
  2015-10-02  6:04 ` [PATCH v2 2/2] ne: DeviceTree support Yoshinori Sato
  2015-10-08  8:28 ` [PATCH v3 1/2] ne: Add h8300 support Yoshinori Sato
  0 siblings, 2 replies; 6+ messages in thread
From: Yoshinori Sato @ 2015-10-02  6:04 UTC (permalink / raw)
  To: netdev; +Cc: Yoshinori Sato

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 drivers/net/ethernet/8390/Kconfig | 2 +-
 drivers/net/ethernet/8390/ne.c    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index edf7225..44d7167 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -88,7 +88,7 @@ config MCF8390
 config NE2000
 	tristate "NE2000/NE1000 support"
 	depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX || \
-		    ATARI_ETHERNEC)
+		    ATARI_ETHERNEC || H8300)
 	select CRC32
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y here.
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index c063b41..90bf71b 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -422,7 +422,8 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
 		stop_page  = NE1SM_STOP_PG;
 	}
 
-#if  defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R)
+#if  defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R) || \
+	defined(CONFIG_H8300)
 	neX000 = ((SA_prom[14] == 0x57  &&  SA_prom[15] == 0x57)
 		|| (SA_prom[14] == 0x42 && SA_prom[15] == 0x42));
 #else
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] ne: DeviceTree support.
  2015-10-02  6:04 [PATCH v2 1/2] ne: Add h8300 support Yoshinori Sato
@ 2015-10-02  6:04 ` Yoshinori Sato
  2015-10-05 13:38   ` David Miller
  2015-10-08  8:28 ` [PATCH v3 1/2] ne: Add h8300 support Yoshinori Sato
  1 sibling, 1 reply; 6+ messages in thread
From: Yoshinori Sato @ 2015-10-02  6:04 UTC (permalink / raw)
  To: netdev; +Cc: Yoshinori Sato

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 Documentation/devicetree/bindings/net/ne2000.txt | 17 +++++++++++++++++
 drivers/net/ethernet/8390/ne.c                   | 20 +++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/ne2000.txt

diff --git a/Documentation/devicetree/bindings/net/ne2000.txt b/Documentation/devicetree/bindings/net/ne2000.txt
new file mode 100644
index 0000000..8b0dfbf
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ne2000.txt
@@ -0,0 +1,17 @@
+NE2000 compatible network controller
+
+Required properties:
+- compatible: "national,ne2000"
+- reg: base address and length of NE2000.
+- interrupts: interrupt specifier for the sole interrupt.
+- national,dcr: DCR setting value.
+
+Example
+
+	ne2000: ethernet@200000 {
+		compatible = "national,ne2000";
+		reg = <0x200000 32>;
+		interrupts = <17 0>;
+		national,dcr = <0x48>;
+	};
+
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 90bf71b..38d78ab 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -52,6 +52,7 @@ static const char version2[] =
 #include <linux/etherdevice.h>
 #include <linux/jiffies.h>
 #include <linux/platform_device.h>
+#include <linux/of.h>
 
 #include <asm/io.h>
 
@@ -72,6 +73,7 @@ static int io[MAX_NE_CARDS];
 static int irq[MAX_NE_CARDS];
 static int bad[MAX_NE_CARDS];
 static u32 ne_msg_enable;
+static unsigned int of_dcr_val;
 
 #ifdef MODULE
 module_param_array(io, int, NULL, 0);
@@ -171,6 +173,8 @@ bad_clone_list[] __initdata = {
 #  define DCR_VAL 0x48		/* 8-bit mode */
 #elif defined(CONFIG_ATARI)	/* 8-bit mode on Atari, normal on Q40 */
 #  define DCR_VAL (MACH_IS_ATARI ? 0x48 : 0x49)
+#elif defined(CONFIG_OF_NET)
+#  define DCR_VAL of_dcr_val
 #else
 #  define DCR_VAL 0x49
 #endif
@@ -304,7 +308,8 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
 	struct ei_device *ei_local = netdev_priv(dev);
 
 	if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
-		return -EBUSY;
+		if (!request_mem_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
+			return -EBUSY;
 
 	reg0 = inb_p(ioaddr);
 	if (reg0 == 0xFF) {
@@ -809,11 +814,18 @@ static int __init ne_drv_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
+	if (dev->dev.of_node)
+		of_property_read_u32(dev->dev.of_node,
+				     "national,dcr", &of_dcr_val);
+
 	/* ne.c doesn't populate resources in platform_device, but
 	 * rbtx4927_ne_init and rbtx4938_ne_init do register devices
 	 * with resources.
 	 */
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
 	if (res) {
 		dev->base_addr = res->start;
 		dev->irq = platform_get_irq(pdev, 0);
@@ -915,12 +927,18 @@ static int ne_drv_resume(struct platform_device *pdev)
 #define ne_drv_resume NULL
 #endif
 
+static const struct of_device_id ne2000_of_table[] __maybe_unused = {
+	{ .compatible = "national,ne2000" },
+	{ }
+};
+
 static struct platform_driver ne_driver = {
 	.remove		= ne_drv_remove,
 	.suspend	= ne_drv_suspend,
 	.resume		= ne_drv_resume,
 	.driver		= {
 		.name	= DRV_NAME,
+		.of_match_table = of_match_ptr(ne2000_of_table),
 	},
 };
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] ne: DeviceTree support.
  2015-10-02  6:04 ` [PATCH v2 2/2] ne: DeviceTree support Yoshinori Sato
@ 2015-10-05 13:38   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-10-05 13:38 UTC (permalink / raw)
  To: ysato; +Cc: netdev

From: Yoshinori Sato <ysato@users.sourceforge.jp>
Date: Fri,  2 Oct 2015 15:04:51 +0900

> +	if (dev->dev.of_node)

Please use "dev_of_node()".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] ne: Add h8300 support.
  2015-10-02  6:04 [PATCH v2 1/2] ne: Add h8300 support Yoshinori Sato
  2015-10-02  6:04 ` [PATCH v2 2/2] ne: DeviceTree support Yoshinori Sato
@ 2015-10-08  8:28 ` Yoshinori Sato
  2015-10-08  8:28   ` [PATCH v3 2/2] ne: DeviceTree support Yoshinori Sato
  1 sibling, 1 reply; 6+ messages in thread
From: Yoshinori Sato @ 2015-10-08  8:28 UTC (permalink / raw)
  To: netdev; +Cc: Yoshinori Sato

Changes v3
none
Changes v2
Use CONFIG_H8300

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 drivers/net/ethernet/8390/Kconfig | 2 +-
 drivers/net/ethernet/8390/ne.c    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index edf7225..44d7167 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -88,7 +88,7 @@ config MCF8390
 config NE2000
 	tristate "NE2000/NE1000 support"
 	depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX || \
-		    ATARI_ETHERNEC)
+		    ATARI_ETHERNEC || H8300)
 	select CRC32
 	---help---
 	  If you have a network (Ethernet) card of this type, say Y here.
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index c063b41..90bf71b 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -422,7 +422,8 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
 		stop_page  = NE1SM_STOP_PG;
 	}
 
-#if  defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R)
+#if  defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R) || \
+	defined(CONFIG_H8300)
 	neX000 = ((SA_prom[14] == 0x57  &&  SA_prom[15] == 0x57)
 		|| (SA_prom[14] == 0x42 && SA_prom[15] == 0x42));
 #else
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] ne: DeviceTree support.
  2015-10-08  8:28 ` [PATCH v3 1/2] ne: Add h8300 support Yoshinori Sato
@ 2015-10-08  8:28   ` Yoshinori Sato
  2015-10-08  8:43     ` kbuild test robot
  0 siblings, 1 reply; 6+ messages in thread
From: Yoshinori Sato @ 2015-10-08  8:28 UTC (permalink / raw)
  To: netdev; +Cc: Yoshinori Sato

Changes v3
Use dev_of_node
Changes v2
none

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 Documentation/devicetree/bindings/net/ne2000.txt | 17 +++++++++++++++++
 drivers/net/ethernet/8390/ne.c                   | 20 +++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/ne2000.txt

diff --git a/Documentation/devicetree/bindings/net/ne2000.txt b/Documentation/devicetree/bindings/net/ne2000.txt
new file mode 100644
index 0000000..8b0dfbf
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ne2000.txt
@@ -0,0 +1,17 @@
+NE2000 compatible network controller
+
+Required properties:
+- compatible: "national,ne2000"
+- reg: base address and length of NE2000.
+- interrupts: interrupt specifier for the sole interrupt.
+- national,dcr: DCR setting value.
+
+Example
+
+	ne2000: ethernet@200000 {
+		compatible = "national,ne2000";
+		reg = <0x200000 32>;
+		interrupts = <17 0>;
+		national,dcr = <0x48>;
+	};
+
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 90bf71b..82a4ec3 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -52,6 +52,7 @@ static const char version2[] =
 #include <linux/etherdevice.h>
 #include <linux/jiffies.h>
 #include <linux/platform_device.h>
+#include <linux/of.h>
 
 #include <asm/io.h>
 
@@ -72,6 +73,7 @@ static int io[MAX_NE_CARDS];
 static int irq[MAX_NE_CARDS];
 static int bad[MAX_NE_CARDS];
 static u32 ne_msg_enable;
+static unsigned int of_dcr_val;
 
 #ifdef MODULE
 module_param_array(io, int, NULL, 0);
@@ -171,6 +173,8 @@ bad_clone_list[] __initdata = {
 #  define DCR_VAL 0x48		/* 8-bit mode */
 #elif defined(CONFIG_ATARI)	/* 8-bit mode on Atari, normal on Q40 */
 #  define DCR_VAL (MACH_IS_ATARI ? 0x48 : 0x49)
+#elif defined(CONFIG_OF_NET)
+#  define DCR_VAL of_dcr_val
 #else
 #  define DCR_VAL 0x49
 #endif
@@ -304,7 +308,8 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
 	struct ei_device *ei_local = netdev_priv(dev);
 
 	if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
-		return -EBUSY;
+		if (!request_mem_region(ioaddr, NE_IO_EXTENT, DRV_NAME))
+			return -EBUSY;
 
 	reg0 = inb_p(ioaddr);
 	if (reg0 == 0xFF) {
@@ -809,11 +814,18 @@ static int __init ne_drv_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
+	if (dev_of_node(dev))
+		of_property_read_u32(dev_of_node(dev),
+				     "national,dcr", &of_dcr_val);
+
 	/* ne.c doesn't populate resources in platform_device, but
 	 * rbtx4927_ne_init and rbtx4938_ne_init do register devices
 	 * with resources.
 	 */
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
 	if (res) {
 		dev->base_addr = res->start;
 		dev->irq = platform_get_irq(pdev, 0);
@@ -915,12 +927,18 @@ static int ne_drv_resume(struct platform_device *pdev)
 #define ne_drv_resume NULL
 #endif
 
+static const struct of_device_id ne2000_of_table[] __maybe_unused = {
+	{ .compatible = "national,ne2000" },
+	{ }
+};
+
 static struct platform_driver ne_driver = {
 	.remove		= ne_drv_remove,
 	.suspend	= ne_drv_suspend,
 	.resume		= ne_drv_resume,
 	.driver		= {
 		.name	= DRV_NAME,
+		.of_match_table = of_match_ptr(ne2000_of_table),
 	},
 };
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 2/2] ne: DeviceTree support.
  2015-10-08  8:28   ` [PATCH v3 2/2] ne: DeviceTree support Yoshinori Sato
@ 2015-10-08  8:43     ` kbuild test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2015-10-08  8:43 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: kbuild-all, netdev, Yoshinori Sato

[-- Attachment #1: Type: text/plain, Size: 2612 bytes --]

Hi Yoshinori,

[auto build test WARNING on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: m68k-multi_defconfig (attached as .config)
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=m68k 

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/8390/ne.c: In function 'ne_drv_probe':
>> drivers/net/ethernet/8390/ne.c:817:6: warning: passing argument 1 of 'dev_of_node' from incompatible pointer type
     if (dev_of_node(dev))
         ^
   In file included from include/linux/pnp.h:11:0,
                    from include/linux/isapnp.h:26,
                    from drivers/net/ethernet/8390/ne.c:47:
   include/linux/device.h:967:35: note: expected 'struct device *' but argument is of type 'struct net_device *'
    static inline struct device_node *dev_of_node(struct device *dev)
                                      ^
   drivers/net/ethernet/8390/ne.c:818:24: warning: passing argument 1 of 'dev_of_node' from incompatible pointer type
      of_property_read_u32(dev_of_node(dev),
                           ^
   In file included from include/linux/pnp.h:11:0,
                    from include/linux/isapnp.h:26,
                    from drivers/net/ethernet/8390/ne.c:47:
   include/linux/device.h:967:35: note: expected 'struct device *' but argument is of type 'struct net_device *'
    static inline struct device_node *dev_of_node(struct device *dev)
                                      ^

vim +/dev_of_node +817 drivers/net/ethernet/8390/ne.c

   801			}
   802	
   803		outb_p(ENISR_RDC, nic_base + EN0_ISR);	/* Ack intr. */
   804		ei_status.dmaing &= ~0x01;
   805	}
   806	
   807	static int __init ne_drv_probe(struct platform_device *pdev)
   808	{
   809		struct net_device *dev;
   810		int err, this_dev = pdev->id;
   811		struct resource *res;
   812	
   813		dev = alloc_eip_netdev();
   814		if (!dev)
   815			return -ENOMEM;
   816	
 > 817		if (dev_of_node(dev))
   818			of_property_read_u32(dev_of_node(dev),
   819					     "national,dcr", &of_dcr_val);
   820	
   821		/* ne.c doesn't populate resources in platform_device, but
   822		 * rbtx4927_ne_init and rbtx4938_ne_init do register devices
   823		 * with resources.
   824		 */
   825		res = platform_get_resource(pdev, IORESOURCE_IO, 0);

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

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 12569 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-08  8:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02  6:04 [PATCH v2 1/2] ne: Add h8300 support Yoshinori Sato
2015-10-02  6:04 ` [PATCH v2 2/2] ne: DeviceTree support Yoshinori Sato
2015-10-05 13:38   ` David Miller
2015-10-08  8:28 ` [PATCH v3 1/2] ne: Add h8300 support Yoshinori Sato
2015-10-08  8:28   ` [PATCH v3 2/2] ne: DeviceTree support Yoshinori Sato
2015-10-08  8:43     ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).