From patchwork Wed Sep 7 10:22:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaccon Bastiaansen X-Patchwork-Id: 1127732 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p87GkKOQ000461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Sep 2011 16:46:48 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R1FnI-0005eS-33; Wed, 07 Sep 2011 10:55:53 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R1FlR-0005ZL-3P; Wed, 07 Sep 2011 10:53:53 +0000 Received: from mail-ey0-f171.google.com ([209.85.215.171]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R1FlM-0005YF-Re for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2011 10:53:50 +0000 Received: by eyg24 with SMTP id 24so7572669eyg.30 for ; Wed, 07 Sep 2011 03:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=fW73eKVacucXoTdJyhIlAUbUS3wZeY24K/4UWXQwzhI=; b=HD3pIJ61+TpPXikEat2QhQepbYupdnwsNNKQz8kltsVQ1qJlzlca8svkhIPL5JpIa/ 0Jq0bG/jFFbx3kwg75b5W47ybu0K7nZft6AqDaVGiysyF0ZVqeSuVg9B7LUxqOS9pvDz RkK1UQwmlN+e+B3r+X1/1vFeLV0+NHhBA3Kpc= Received: by 10.14.10.31 with SMTP id 31mr2369060eeu.146.1315391010762; Wed, 07 Sep 2011 03:23:30 -0700 (PDT) Received: from localhost.localdomain (s529d540e.adsl.wanadoo.nl [82.157.84.14]) by mx.google.com with ESMTPS id d59sm5862552eea.3.2011.09.07.03.23.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Sep 2011 03:23:29 -0700 (PDT) From: Jaccon Bastiaansen To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] Add platform driver support to the CS890x driver Date: Wed, 7 Sep 2011 12:22:47 +0200 Message-Id: <1315390967-6683-1-git-send-email-jaccon.bastiaansen@gmail.com> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110907_065349_185277_B5578532 X-CRM114-Status: GOOD ( 22.44 ) X-Spam-Score: 1.7 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (jaccon.bastiaansen[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.171 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 2.5 FREEMAIL_REPLY From and body contain different freemails 0.0 T_TO_NO_BRKTS_FREEMAIL To: misformatted and free email service Cc: s.hauer@pengutronix.de, Jaccon Bastiaansen , kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 07 Sep 2011 16:46:48 +0000 (UTC) The CS89x0 ethernet controller is used on a number of evaluation boards, such as the MX31ADS. The current driver has memory address and IRQ settings for each board on which this controller is used. Driver updates are therefore required to support other boards that also use the CS89x0. To avoid these driver updates, a better mechanism (platform driver support) is added to communicate the board dependent settings to the driver. Signed-off-by: Jaccon Bastiaansen --- drivers/net/Kconfig | 18 +++++++++-- drivers/net/Space.c | 2 +- drivers/net/cs89x0.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 93359fa..17be84f 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -1497,8 +1497,7 @@ config FORCEDETH config CS89x0 tristate "CS89x0 support" - depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \ - || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440) + depends on NET_ETHERNET ---help--- Support for CS89x0 chipset based Ethernet cards. If you have a network (Ethernet) card of this type, say Y and read the @@ -1509,10 +1508,23 @@ config CS89x0 To compile this driver as a module, choose M here. The module will be called cs89x0. +config CS89x0_PLATFORM + bool "CS89x0 platform driver support" + depends on CS89x0 + default n + help + Say Y to compile the cs890x0 driver as a platform driver. This + makes this driver suitable for use on certain evaluation boards + such as the IMX21ADS. + + If you are unsure, say N. + config CS89x0_NONISA_IRQ def_bool y depends on CS89x0 != n - depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440 + depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || \ + MACH_QQ2440 || CS89x0_PLATFORM + config TC35815 tristate "TOSHIBA TC35815 Ethernet support" diff --git a/drivers/net/Space.c b/drivers/net/Space.c index 068c356..3c53ab1 100644 --- a/drivers/net/Space.c +++ b/drivers/net/Space.c @@ -189,7 +189,7 @@ static struct devprobe2 isa_probes[] __initdata = { #ifdef CONFIG_SEEQ8005 {seeq8005_probe, 0}, #endif -#ifdef CONFIG_CS89x0 +#if defined(CONFIG_CS89x0) && !defined(CONFIG_CS89x0_PLATFORM) {cs89x0_probe, 0}, #endif #ifdef CONFIG_AT1700 diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index 537a4b2..604c828 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c @@ -98,6 +98,8 @@ Domenico Andreoli : cavokz@gmail.com : QQ2440 platform support + Jaccon Bastiaansen: jaccon.bastiaansen@gmail.com + : added platform driver support */ /* Always include 'config.h' first in case the user wants to turn on @@ -154,7 +156,9 @@ #if ALLOW_DMA #include #endif - +#ifdef CONFIG_CS89x0_PLATFORM +#include +#endif #include "cs89x0.h" static char version[] __initdata = @@ -189,6 +193,9 @@ static unsigned int netcard_portlist[] __used __initdata = { PBC_BASE_ADDRESS + PBC_CS8900A_IOBASE + 0x300, 0 }; static unsigned cs8900_irq_map[] = {EXPIO_INT_ENET_INT, 0, 0, 0}; +#elif defined(CONFIG_CS89x0_PLATFORM) +static unsigned int netcard_portlist[] __used __initdata = {0, 0}; +static unsigned int cs8900_irq_map[] = {0, 0, 0, 0}; #else static unsigned int netcard_portlist[] __used __initdata = { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; @@ -1746,7 +1753,7 @@ static int set_mac_address(struct net_device *dev, void *p) return 0; } -#ifdef MODULE +#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM) static struct net_device *dev_cs89x0; @@ -1900,7 +1907,77 @@ cleanup_module(void) release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT); free_netdev(dev_cs89x0); } -#endif /* MODULE */ +#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */ + +#ifdef CONFIG_CS89x0_PLATFORM +static int cs89x0_platform_probe(struct platform_device *pdev) +{ + struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); + struct resource *mem_res; + struct resource *irq_res; + int err; + + if (!dev) + return -ENODEV; + + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (mem_res == NULL || irq_res == NULL) { + printk(KERN_WARNING + DRV_NAME + ": memory and/or interrupt resource missing.\n"); + err = -ENOENT; + goto out; + } + + cs8900_irq_map[0] = irq_res->start; + err = cs89x0_probe1(dev, mem_res->start, 0); + if (err) { + printk(KERN_WARNING + DRV_NAME + ": no cs8900 or cs8920 detected.\n"); + goto out; + } + + platform_set_drvdata(pdev, dev); + return 0; +out: + free_netdev(dev); + return err; +} + +static int cs89x0_platform_remove(struct platform_device *pdev) +{ + struct net_device *dev = platform_get_drvdata(pdev); + + unregister_netdev(dev); + free_netdev(dev); + return 0; +} + +static struct platform_driver cs89x0_platform_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = cs89x0_platform_probe, + .remove = cs89x0_platform_remove, +}; + +static int __init cs89x0_init(void) +{ + return platform_driver_register(&cs89x0_platform_driver); +} + +static void __exit cs89x0_cleanup(void) +{ + platform_driver_unregister(&cs89x0_platform_driver); +} + +module_init(cs89x0_init); +module_exit(cs89x0_cleanup); + +#endif /* * Local variables: