All of lore.kernel.org
 help / color / mirror / Atom feed
From: cavokz@gmail.com (Domenico Andreoli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: QQ2440 networking support
Date: Wed, 2 Feb 2011 22:06:37 +0000	[thread overview]
Message-ID: <20110202220637.GC2808@dandreoli.com> (raw)
In-Reply-To: <20110202220530.GB2808@dandreoli.com>

From: Domenico Andreoli <cavokz@gmail.com>

Add networking support for QQ2440.

Signed-off-by: Domenico Andreoli <cavokz@gmail.com>

---
 arch/arm/mach-s3c2440/include/mach/qq2440.h |   22 ++++++++++++
 arch/arm/mach-s3c2440/mach-qq2440.c         |   16 ++++++++
 drivers/net/Kconfig                         |    4 +-
 drivers/net/cs89x0.c                        |   33 ++++++++++++------
 4 files changed, 61 insertions(+), 14 deletions(-)

Index: arm-2.6.git/arch/arm/mach-s3c2440/include/mach/qq2440.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ arm-2.6.git/arch/arm/mach-s3c2440/include/mach/qq2440.h	2011-02-02 18:32:38.000000000 +0000
@@ -0,0 +1,22 @@
+/*
+ * arch/arm/mach-s3c2440/include/mach/qq2440.h
+ *
+ * Copyright (c) 2011 Domenico Andreoli <cavokz@gmail.com>
+ *
+ * QQ2440 - platform definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_MACH_QQ2440_H
+#define __ASM_MACH_QQ2440_H
+
+#define QQ2440_CS8900_IRQ         IRQ_EINT9
+
+#define QQ2440_CS8900_VIRT_BASE   S3C_ADDR(0x00500000)
+#define QQ2440_CS8900_PA          (S3C2410_CS3 + 0x1000000)
+#define QQ2440_CS8900_SZ          SZ_1M
+
+#endif /* __ASM_MACH_QQ2440_H */
Index: arm-2.6.git/drivers/net/cs89x0.c
===================================================================
--- arm-2.6.git.orig/drivers/net/cs89x0.c	2011-02-02 18:28:01.000000000 +0000
+++ arm-2.6.git/drivers/net/cs89x0.c	2011-02-02 18:32:38.000000000 +0000
@@ -95,6 +95,9 @@
   Dmitry Pervushin  : dpervushin at ru.mvista.com
                     : PNX010X platform support
 
+  Domenico Andreoli : cavokz at gmail.com
+                    : QQ2440 platform support
+
 */
 
 /* Always include 'config.h' first in case the user wants to turn on
@@ -117,7 +120,7 @@
  * Set this to zero to remove all the debug statements via
  * dead code elimination
  */
-#define DEBUGGING	1
+#define DEBUGGING	0
 
 /*
   Sources:
@@ -173,6 +176,10 @@
 #if defined(CONFIG_MACH_IXDP2351)
 static unsigned int netcard_portlist[] __used __initdata = {IXDP2351_VIRT_CS8900_BASE, 0};
 static unsigned int cs8900_irq_map[] = {IRQ_IXDP2351_CS8900, 0, 0, 0};
+#elif defined(CONFIG_MACH_QQ2440)
+#include <mach/qq2440.h>
+static unsigned int netcard_portlist[] __used __initdata = {QQ2440_CS8900_VIRT_BASE + 0x300, 0};
+static unsigned int cs8900_irq_map[] = {QQ2440_CS8900_IRQ, 0, 0, 0};
 #elif defined(CONFIG_ARCH_IXDP2X01)
 static unsigned int netcard_portlist[] __used __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0};
 static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0};
@@ -521,6 +528,10 @@
 #endif
 		lp->force = g_cs89x0_media__force;
 #endif
+
+#if defined(CONFIG_MACH_QQ2440)
+		lp->force |= FORCE_RJ45 | FORCE_FULL;
+#endif
         }
 
 	/* Grab the region so we can find another board if autoIRQ fails. */
@@ -608,7 +619,7 @@
 		        dev->dev_addr[i*2+1] = Addr >> 8;
 		}
 
-	   	/* Load the Adapter Configuration.
+		/* Load the Adapter Configuration.
 		   Note:  Barring any more specific information from some
 		   other source (ie EEPROM+Schematics), we would not know
 		   how to operate a 10Base2 interface on the AUI port.
@@ -655,7 +666,7 @@
 	if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0)
 		printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n");
 	else if (get_eeprom_data(dev, START_EEPROM_DATA,CHKSUM_LEN,eeprom_buff) < 0) {
-		printk(KERN_WARNING "\ncs89x0: EEPROM read failed, relying on command line.\n");
+		printk(KERN_WARNING "cs89x0: EEPROM read failed, relying on command line.\n");
         } else if (get_eeprom_cksum(START_EEPROM_DATA,CHKSUM_LEN,eeprom_buff) < 0) {
 		/* Check if the chip was able to read its own configuration starting
 		  @0 in the EEPROM*/
@@ -709,7 +720,7 @@
         /* FIXME: we don't set the Ethernet address on the command line.  Use
            ifconfig IFACE hw ether AABBCCDDEEFF */
 
-	printk(KERN_INFO "cs89x0 media %s%s%s",
+	printk(KERN_INFO "cs89x0: media %s%s%s",
 	       (lp->adapter_cnf & A_CNF_10B_T)?"RJ-45,":"",
 	       (lp->adapter_cnf & A_CNF_AUI)?"AUI,":"",
 	       (lp->adapter_cnf & A_CNF_10B_2)?"BNC,":"");
@@ -943,7 +954,7 @@
 static void __init reset_chip(struct net_device *dev)
 {
 #if !defined(CONFIG_MACH_MX31ADS)
-#if !defined(CONFIG_MACH_IXDP2351) && !defined(CONFIG_ARCH_IXDP2X01)
+#if !defined(CS89x0_NONISA_IRQ)
 	struct net_local *lp = netdev_priv(dev);
 	int ioaddr = dev->base_addr;
 #endif
@@ -954,18 +965,18 @@
 	/* wait 30 ms */
 	msleep(30);
 
-#if !defined(CONFIG_MACH_IXDP2351) && !defined(CONFIG_ARCH_IXDP2X01)
+#if !defined(CS89x0_NONISA_IRQ)
 	if (lp->chip_type != CS8900) {
 		/* Hardware problem requires PNP registers to be reconfigured after a reset */
 		writeword(ioaddr, ADD_PORT, PP_CS8920_ISAINT);
-		outb(dev->irq, ioaddr + DATA_PORT);
-		outb(0,      ioaddr + DATA_PORT + 1);
+		writeword(ioaddr, DATA_PORT, dev->irq);
+		writeword(ioaddr, DATA_PORT + 1, 0);
 
 		writeword(ioaddr, ADD_PORT, PP_CS8920_ISAMemB);
-		outb((dev->mem_start >> 16) & 0xff, ioaddr + DATA_PORT);
-		outb((dev->mem_start >> 8) & 0xff,   ioaddr + DATA_PORT + 1);
+		writeword(ioaddr, DATA_PORT, (dev->mem_start >> 16) & 0xff);
+		writeword(ioaddr, DATA_PORT + 1, (dev->mem_start >> 8) & 0xff);
 	}
-#endif	/* IXDP2x01 */
+#endif
 
 	/* Wait until the chip is reset */
 	reset_start_time = jiffies;
Index: arm-2.6.git/drivers/net/Kconfig
===================================================================
--- arm-2.6.git.orig/drivers/net/Kconfig	2011-02-02 18:28:01.000000000 +0000
+++ arm-2.6.git/drivers/net/Kconfig	2011-02-02 18:32:38.000000000 +0000
@@ -1498,7 +1498,7 @@
 config CS89x0
 	tristate "CS89x0 support"
 	depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
-		|| ARCH_IXDP2X01 || MACH_MX31ADS)
+		|| ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440)
 	---help---
 	  Support for CS89x0 chipset based Ethernet cards. If you have a
 	  network (Ethernet) card of this type, say Y and read the
@@ -1512,7 +1512,7 @@
 config CS89x0_NONISA_IRQ
 	def_bool y
 	depends on CS89x0 != n
-	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS
+	depends on MACH_IXDP2351 || ARCH_IXDP2X01 || MACH_MX31ADS || MACH_QQ2440
 
 config TC35815
 	tristate "TOSHIBA TC35815 Ethernet support"
Index: arm-2.6.git/arch/arm/mach-s3c2440/mach-qq2440.c
===================================================================
--- arm-2.6.git.orig/arch/arm/mach-s3c2440/mach-qq2440.c	2011-02-02 18:29:48.000000000 +0000
+++ arm-2.6.git/arch/arm/mach-s3c2440/mach-qq2440.c	2011-02-02 18:32:38.000000000 +0000
@@ -36,6 +36,7 @@
 #include <mach/leds-gpio.h>
 #include <mach/regs-mem.h>
 #include <mach/irqs.h>
+#include <mach/qq2440.h>
 #include <plat/nand.h>
 #include <plat/iic.h>
 #include <plat/mci.h>
@@ -54,7 +55,12 @@
 #include <sound/s3c24xx_uda134x.h>
 
 static struct map_desc qq2440_iodesc[] __initdata = {
-	/* nothing to declare, move along */
+	{
+		.virtual  = QQ2440_CS8900_VIRT_BASE,
+		.pfn      = __phys_to_pfn(QQ2440_CS8900_PA),
+		.length   = QQ2440_CS8900_SZ,
+		.type     = MT_DEVICE
+	}
 };
 
 #define UCON S3C2410_UCON_DEFAULT
@@ -325,10 +331,18 @@
 	s3c24xx_init_uarts(qq2440_uartcfgs, ARRAY_SIZE(qq2440_uartcfgs));
 }
 
+#define QQ2440_CS8900_BANKCON  (S3C2410_BANKCON_Tacp6 | S3C2410_BANKCON_Tcah4 | S3C2410_BANKCON_Tcoh1 | \
+                                S3C2410_BANKCON_Tacc14 | S3C2410_BANKCON_Tcos4)
+
 static void __init qq2440_init(void)
 {
 	int i;
 
+	/* Ethernet */
+	__raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_WS3 | S3C2410_BWSCON_ST3, S3C2410_BWSCON);
+	__raw_writel(QQ2440_CS8900_BANKCON, S3C2410_BANKCON3);
+	set_irq_type(QQ2440_CS8900_IRQ, IRQ_TYPE_EDGE_RISING);
+
 	/* Make sure the D+ pullup pin is output */
 	WARN_ON(gpio_request(S3C2410_GPG(12), "udc pup"));
 	gpio_direction_output(S3C2410_GPG(12), 0);

  reply	other threads:[~2011-02-02 22:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 22:03 [PATCH 0/2] ARM: add support for QQ2440 board Domenico Andreoli
2011-02-02 22:05 ` [PATCH 1/2] ARM: QQ2440 machine architecture Domenico Andreoli
2011-02-02 22:06   ` Domenico Andreoli [this message]
2011-02-03  9:41     ` [PATCH 2/2] ARM: QQ2440 networking support Jamie Iles
2011-02-03 10:34       ` Domenico Andreoli
2011-02-03  9:25   ` [PATCH 1/2] ARM: QQ2440 machine architecture Jamie Iles
2011-02-06 12:12   ` Ramax Lo
2011-02-09 10:07     ` Domenico Andreoli

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=20110202220637.GC2808@dandreoli.com \
    --to=cavokz@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.