Subject: Re: [PATCH] final mv643xx_eth pegasos patch set ...

From: Sven Luther <[email-masked]>
Date: Tue, 8 Mar 2005 20:52:40 +0100

On Tue, Mar 08, 2005 at 08:28:05PM +0100, luther wrote:
> Hello,
> 
> Ok, thanks for your help, here is the final (hopefully) and cleaned up version
> of my patches :
> 
>   1) mv643xx-eth-pegasos.diff
>   This is the arch/ppc/platform diff, benh, could you look it over, and merge
>   it in ? It is not really usefull without the mv643xx_eth.c changes, but dale
>   is going to move those in together with his patches.
> 
>   2) linux-2.5-mv643xx-enet-pegasos.diff
>   This is just two small hunks against dale's linux-2.5-mv643xx-enet tree,
>   which include the SA_INTERRUPT -> SA_IRQ and the Kconfig change. Dale said
>   he would merge them with his stuff, hopefully for 2.6.12.
> 
>   3) mv643xx-eth.diff
>   This is the linux-2.5-mv643xx-enet diff against 2.6.11, together with the
>   linux-2.5-mv643xx-enet-pegasos.diff changes, for those who want to build
>   against 2.6.11.
> 
> So to build against the linux-2.5-mv643xx-enet tree, you need 1) and 2) and to
> build against 2.6.11 you need 1) and 3).
> 
> I am currently running the patches included in these changes, and will include
> them in the debian 2.6.11 kernels unless i hear otherwise. 

Oh well, with the patches this time :/

Friendly,

Sven Luther
--- linux-dale/arch/ppc/platforms/Makefile	2005-03-08 09:52:44.000000000 +0100
+++ kernel-source-2.6.11-marvell/arch/ppc/platforms/Makefile	2005-03-08 17:33:29.000000000 +0100
@@ -12,7 +12,7 @@
 obj-$(CONFIG_PPC_PMAC)		+= pmac_pic.o pmac_setup.o pmac_time.o \
 					pmac_feature.o pmac_pci.o pmac_sleep.o \
 					pmac_low_i2c.o pmac_cache.o
-obj-$(CONFIG_PPC_CHRP)		+= chrp_setup.o chrp_time.o chrp_pci.o
+obj-$(CONFIG_PPC_CHRP)		+= chrp_setup.o chrp_time.o chrp_pci.o mv643xx_eth_pegasos.o
 obj-$(CONFIG_PPC_PREP)		+= prep_pci.o prep_setup.o
 ifeq ($(CONFIG_PPC_PMAC),y)
 obj-$(CONFIG_NVRAM)		+= pmac_nvram.o
--- linux-dale/arch/ppc/platforms/mv643xx_eth_pegasos.c	1970-01-01 01:00:00.000000000 +0100
+++ kernel-source-2.6.11-marvell/arch/ppc/platforms/mv643xx_eth_pegasos.c	2005-03-08 20:21:33.000000000 +0100
@@ -0,0 +1,112 @@
+/*
+ *  arch/ppc/platforms/mv643xx_eth_pegasos.c
+ *
+ *  Copyright (C) 2005 Sven Luther <[email-masked]> 
+ *  Thanks to :
+ *	Dale Farnsworth <[email-masked]>
+ *	Mark A. Greer <[email-masked]>
+ *	Nicolas DET <[email-masked]>
+ *	Benjamin Herrenschmidt <[email-masked]>
+ *  And anyone else who helped me on this.
+ */
+
+#include <linux/types.h>
+#include <asm/prom.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/mv643xx.h>
+#include <linux/pci_ids.h>
+
+/* Pegasos 2 specific Marvell MV 64361 gigabit ethernet port setup */
+static struct resource mv643xx_eth_shared_resources[] = {
+	[0] = {
+		.name	= "ethernet shared base",
+		.start	= 0xf1000000 + MV643XX_ETH_SHARED_REGS,
+		.end	= 0xf1000000 + MV643XX_ETH_SHARED_REGS +
+					MV643XX_ETH_SHARED_REGS_SIZE - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device mv643xx_eth_shared_device = {
+	.name		= MV643XX_ETH_SHARED_NAME,
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(mv643xx_eth_shared_resources),
+	.resource	= mv643xx_eth_shared_resources,
+};
+
+#ifdef CONFIG_MV643XX_ETH_0
+static struct resource mv643xx_eth0_resources[] = {
+	[0] = {
+		.name	= "eth0 irq",
+		.start	= 9,
+		.end	= 9,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct mv643xx_eth_platform_data eth0_pd;
+
+static struct platform_device eth0_device = {
+	.name		= MV643XX_ETH_NAME,
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(mv643xx_eth0_resources),
+	.resource	= mv643xx_eth0_resources,
+	.dev = {
+		.platform_data = &eth0_pd,
+	},
+};
+#endif
+
+#ifdef CONFIG_MV643XX_ETH_1
+static struct resource mv643xx_eth1_resources[] = {
+	[0] = {
+		.name	= "eth1 irq",
+		.start	= 9,
+		.end	= 9,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct mv643xx_eth_platform_data eth1_pd;
+
+static struct platform_device eth1_device = {
+	.name		= MV643XX_ETH_NAME,
+	.id		= 1,
+	.num_resources	= ARRAY_SIZE(mv643xx_eth1_resources),
+	.resource	= mv643xx_eth1_resources,
+	.dev = {
+		.platform_data = &eth1_pd,
+	},
+};
+#endif
+
+static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
+	&mv643xx_eth_shared_device,
+#ifdef CONFIG_MV643XX_ETH_0
+	&eth0_device,
+#endif
+#ifdef CONFIG_MV643XX_ETH_1
+	&eth1_device,
+#endif
+};
+
+static int __init
+mv643xx_eth_add_pds(void)
+{
+	int ret = 0;
+	struct device_node *np;
+	np = find_devices("host");
+	if (np != NULL) {
+		unsigned short *vendorid = (unsigned short *) get_property (np, "vendor-id", NULL);
+		unsigned short *deviceid = (unsigned short *) get_property (np, "device-id", NULL);
+		
+		if (vendorid && *vendorid == PCI_VENDOR_ID_MARVELL &&
+		    deviceid && *deviceid == PCI_DEVICE_ID_MARVELL_MV64360)
+			ret = platform_add_devices(mv643xx_eth_pd_devs,
+				ARRAY_SIZE(mv643xx_eth_pd_devs));
+	}
+	return ret;
+}
+arch_initcall(mv643xx_eth_add_pds);
--- linux-dale/arch/ppc/platforms/Makefile	2005-03-08 09:52:44.000000000 +0100
+++ kernel-source-2.6.11-marvell/arch/ppc/platforms/Makefile	2005-03-08 17:33:29.000000000 +0100
@@ -12,7 +12,7 @@
 obj-$(CONFIG_PPC_PMAC)		+= pmac_pic.o pmac_setup.o pmac_time.o \
 					pmac_feature.o pmac_pci.o pmac_sleep.o \
 					pmac_low_i2c.o pmac_cache.o
-obj-$(CONFIG_PPC_CHRP)		+= chrp_setup.o chrp_time.o chrp_pci.o
+obj-$(CONFIG_PPC_CHRP)		+= chrp_setup.o chrp_time.o chrp_pci.o mv643xx_eth_pegasos.o
 obj-$(CONFIG_PPC_PREP)		+= prep_pci.o prep_setup.o
 ifeq ($(CONFIG_PPC_PMAC),y)
 obj-$(CONFIG_NVRAM)		+= pmac_nvram.o
--- linux-dale/arch/ppc/platforms/mv643xx_eth_pegasos.c	1970-01-01 01:00:00.000000000 +0100
+++ kernel-source-2.6.11-marvell/arch/ppc/platforms/mv643xx_eth_pegasos.c	2005-03-08 20:21:33.000000000 +0100
@@ -0,0 +1,112 @@
+/*
+ *  arch/ppc/platforms/mv643xx_eth_pegasos.c
+ *
+ *  Copyright (C) 2005 Sven Luther <[email-masked]> 
+ *  Thanks to :
+ *	Dale Farnsworth <[email-masked]>
+ *	Mark A. Greer <[email-masked]>
+ *	Nicolas DET <[email-masked]>
+ *	Benjamin Herrenschmidt <[email-masked]>
+ *  And anyone else who helped me on this.
+ */
+
+#include <linux/types.h>
+#include <asm/prom.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/mv643xx.h>
+#include <linux/pci_ids.h>
+
+/* Pegasos 2 specific Marvell MV 64361 gigabit ethernet port setup */
+static struct resource mv643xx_eth_shared_resources[] = {
+	[0] = {
+		.name	= "ethernet shared base",
+		.start	= 0xf1000000 + MV643XX_ETH_SHARED_REGS,
+		.end	= 0xf1000000 + MV643XX_ETH_SHARED_REGS +
+					MV643XX_ETH_SHARED_REGS_SIZE - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device mv643xx_eth_shared_device = {
+	.name		= MV643XX_ETH_SHARED_NAME,
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(mv643xx_eth_shared_resources),
+	.resource	= mv643xx_eth_shared_resources,
+};
+
+#ifdef CONFIG_MV643XX_ETH_0
+static struct resource mv643xx_eth0_resources[] = {
+	[0] = {
+		.name	= "eth0 irq",
+		.start	= 9,
+		.end	= 9,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct mv643xx_eth_platform_data eth0_pd;
+
+static struct platform_device eth0_device = {
+	.name		= MV643XX_ETH_NAME,
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(mv643xx_eth0_resources),
+	.resource	= mv643xx_eth0_resources,
+	.dev = {
+		.platform_data = &eth0_pd,
+	},
+};
+#endif
+
+#ifdef CONFIG_MV643XX_ETH_1
+static struct resource mv643xx_eth1_resources[] = {
+	[0] = {
+		.name	= "eth1 irq",
+		.start	= 9,
+		.end	= 9,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct mv643xx_eth_platform_data eth1_pd;
+
+static struct platform_device eth1_device = {
+	.name		= MV643XX_ETH_NAME,
+	.id		= 1,
+	.num_resources	= ARRAY_SIZE(mv643xx_eth1_resources),
+	.resource	= mv643xx_eth1_resources,
+	.dev = {
+		.platform_data = &eth1_pd,
+	},
+};
+#endif
+
+static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
+	&mv643xx_eth_shared_device,
+#ifdef CONFIG_MV643XX_ETH_0
+	&eth0_device,
+#endif
+#ifdef CONFIG_MV643XX_ETH_1
+	&eth1_device,
+#endif
+};
+
+static int __init
+mv643xx_eth_add_pds(void)
+{
+	int ret = 0;
+	struct device_node *np;
+	np = find_devices("host");
+	if (np != NULL) {
+		unsigned short *vendorid = (unsigned short *) get_property (np, "vendor-id", NULL);
+		unsigned short *deviceid = (unsigned short *) get_property (np, "device-id", NULL);
+		
+		if (vendorid && *vendorid == PCI_VENDOR_ID_MARVELL &&
+		    deviceid && *deviceid == PCI_DEVICE_ID_MARVELL_MV64360)
+			ret = platform_add_devices(mv643xx_eth_pd_devs,
+				ARRAY_SIZE(mv643xx_eth_pd_devs));
+	}
+	return ret;
+}
+arch_initcall(mv643xx_eth_add_pds);