Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b219108c authored by Kumar Gala's avatar Kumar Gala
Browse files

fs_enet: Remove !CONFIG_PPC_CPM_NEW_BINDING code



Now that arch/ppc is gone we always define CONFIG_PPC_CPM_NEW_BINDING so
we can remove all the code associated with !CONFIG_PPC_CPM_NEW_BINDING.

Also fixed some asm/of_platform.h to linux/of_platform.h (and of_device.h)

Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent 00262986
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -8,12 +8,7 @@ fs_enet-$(CONFIG_FS_ENET_HAS_SCC) += mac-scc.o
fs_enet-$(CONFIG_FS_ENET_HAS_FEC) += mac-fec.o
fs_enet-$(CONFIG_FS_ENET_HAS_FCC) += mac-fcc.o

ifeq ($(CONFIG_PPC_CPM_NEW_BINDING),y)
obj-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o
obj-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o
else
fs_enet-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o
fs_enet-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o
endif

fs_enet-objs := fs_enet-main.o $(fs_enet-m)
+1 −309
Original line number Diff line number Diff line
@@ -36,25 +36,17 @@
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <linux/phy.h>
#include <linux/of_platform.h>

#include <linux/vmalloc.h>
#include <asm/pgtable.h>
#include <asm/irq.h>
#include <asm/uaccess.h>

#ifdef CONFIG_PPC_CPM_NEW_BINDING
#include <linux/of_platform.h>
#endif

#include "fs_enet.h"

/*************************************************/

#ifndef CONFIG_PPC_CPM_NEW_BINDING
static char version[] __devinitdata =
    DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")" "\n";
#endif

MODULE_AUTHOR("Pantelis Antoniou <panto@intracom.gr>");
MODULE_DESCRIPTION("Freescale Ethernet Driver");
MODULE_LICENSE("GPL");
@@ -957,190 +949,6 @@ static int fs_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
extern int fs_mii_connect(struct net_device *dev);
extern void fs_mii_disconnect(struct net_device *dev);

#ifndef CONFIG_PPC_CPM_NEW_BINDING
static struct net_device *fs_init_instance(struct device *dev,
		struct fs_platform_info *fpi)
{
	struct net_device *ndev = NULL;
	struct fs_enet_private *fep = NULL;
	int privsize, i, r, err = 0, registered = 0;

	fpi->fs_no = fs_get_id(fpi);
	/* guard */
	if ((unsigned int)fpi->fs_no >= FS_MAX_INDEX)
		return ERR_PTR(-EINVAL);

	privsize = sizeof(*fep) + (sizeof(struct sk_buff **) *
			    (fpi->rx_ring + fpi->tx_ring));

	ndev = alloc_etherdev(privsize);
	if (!ndev) {
		err = -ENOMEM;
		goto err;
	}

	fep = netdev_priv(ndev);

	fep->dev = dev;
	dev_set_drvdata(dev, ndev);
	fep->fpi = fpi;
	if (fpi->init_ioports)
		fpi->init_ioports((struct fs_platform_info *)fpi);

#ifdef CONFIG_FS_ENET_HAS_FEC
	if (fs_get_fec_index(fpi->fs_no) >= 0)
		fep->ops = &fs_fec_ops;
#endif

#ifdef CONFIG_FS_ENET_HAS_SCC
	if (fs_get_scc_index(fpi->fs_no) >=0)
		fep->ops = &fs_scc_ops;
#endif

#ifdef CONFIG_FS_ENET_HAS_FCC
	if (fs_get_fcc_index(fpi->fs_no) >= 0)
		fep->ops = &fs_fcc_ops;
#endif

	if (fep->ops == NULL) {
		printk(KERN_ERR DRV_MODULE_NAME
		       ": %s No matching ops found (%d).\n",
		       ndev->name, fpi->fs_no);
		err = -EINVAL;
		goto err;
	}

	r = (*fep->ops->setup_data)(ndev);
	if (r != 0) {
		printk(KERN_ERR DRV_MODULE_NAME
		       ": %s setup_data failed\n",
			ndev->name);
		err = r;
		goto err;
	}

	/* point rx_skbuff, tx_skbuff */
	fep->rx_skbuff = (struct sk_buff **)&fep[1];
	fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring;

	/* init locks */
	spin_lock_init(&fep->lock);
	spin_lock_init(&fep->tx_lock);

	/*
	 * Set the Ethernet address.
	 */
	for (i = 0; i < 6; i++)
		ndev->dev_addr[i] = fpi->macaddr[i];

	r = (*fep->ops->allocate_bd)(ndev);

	if (fep->ring_base == NULL) {
		printk(KERN_ERR DRV_MODULE_NAME
		       ": %s buffer descriptor alloc failed (%d).\n", ndev->name, r);
		err = r;
		goto err;
	}

	/*
	 * Set receive and transmit descriptor base.
	 */
	fep->rx_bd_base = fep->ring_base;
	fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring;

	/* initialize ring size variables */
	fep->tx_ring = fpi->tx_ring;
	fep->rx_ring = fpi->rx_ring;

	/*
	 * The FEC Ethernet specific entries in the device structure.
	 */
	ndev->open = fs_enet_open;
	ndev->hard_start_xmit = fs_enet_start_xmit;
	ndev->tx_timeout = fs_timeout;
	ndev->watchdog_timeo = 2 * HZ;
	ndev->stop = fs_enet_close;
	ndev->get_stats = fs_enet_get_stats;
	ndev->set_multicast_list = fs_set_multicast_list;

#ifdef CONFIG_NET_POLL_CONTROLLER
	ndev->poll_controller = fs_enet_netpoll;
#endif

	netif_napi_add(ndev, &fep->napi,
		       fs_enet_rx_napi, fpi->napi_weight);

	ndev->ethtool_ops = &fs_ethtool_ops;
	ndev->do_ioctl = fs_ioctl;

	init_timer(&fep->phy_timer_list);

	netif_carrier_off(ndev);

	err = register_netdev(ndev);
	if (err != 0) {
		printk(KERN_ERR DRV_MODULE_NAME
		       ": %s register_netdev failed.\n", ndev->name);
		goto err;
	}
	registered = 1;


	return ndev;

err:
	if (ndev != NULL) {
		if (registered)
			unregister_netdev(ndev);

		if (fep && fep->ops) {
			(*fep->ops->free_bd)(ndev);
			(*fep->ops->cleanup_data)(ndev);
		}

		free_netdev(ndev);
	}

	dev_set_drvdata(dev, NULL);

	return ERR_PTR(err);
}

static int fs_cleanup_instance(struct net_device *ndev)
{
	struct fs_enet_private *fep;
	const struct fs_platform_info *fpi;
	struct device *dev;

	if (ndev == NULL)
		return -EINVAL;

	fep = netdev_priv(ndev);
	if (fep == NULL)
		return -EINVAL;

	fpi = fep->fpi;

	unregister_netdev(ndev);

	dma_free_coherent(fep->dev, (fpi->tx_ring + fpi->rx_ring) * sizeof(cbd_t),
			  (void __force *)fep->ring_base, fep->ring_mem_addr);

	/* reset it */
	(*fep->ops->cleanup_data)(ndev);

	dev = fep->dev;
	if (dev != NULL) {
		dev_set_drvdata(dev, NULL);
		fep->dev = NULL;
	}

	free_netdev(ndev);

	return 0;
}
#endif

/**************************************************************************************/

/* handy pointer to the immap */
@@ -1167,7 +975,6 @@ static void cleanup_immap(void)

/**************************************************************************************/

#ifdef CONFIG_PPC_CPM_NEW_BINDING
static int __devinit find_phy(struct device_node *np,
                              struct fs_platform_info *fpi)
{
@@ -1399,121 +1206,6 @@ static void __exit fs_cleanup(void)
	of_unregister_platform_driver(&fs_enet_driver);
	cleanup_immap();
}
#else
static int __devinit fs_enet_probe(struct device *dev)
{
	struct net_device *ndev;

	/* no fixup - no device */
	if (dev->platform_data == NULL) {
		printk(KERN_INFO "fs_enet: "
				"probe called with no platform data; "
				"remove unused devices\n");
		return -ENODEV;
	}

	ndev = fs_init_instance(dev, dev->platform_data);
	if (IS_ERR(ndev))
		return PTR_ERR(ndev);
	return 0;
}

static int fs_enet_remove(struct device *dev)
{
	return fs_cleanup_instance(dev_get_drvdata(dev));
}

static struct device_driver fs_enet_fec_driver = {
	.name	  	= "fsl-cpm-fec",
	.bus		= &platform_bus_type,
	.probe		= fs_enet_probe,
	.remove		= fs_enet_remove,
#ifdef CONFIG_PM
/*	.suspend	= fs_enet_suspend,	TODO */
/*	.resume		= fs_enet_resume,	TODO */
#endif
};

static struct device_driver fs_enet_scc_driver = {
	.name	  	= "fsl-cpm-scc",
	.bus		= &platform_bus_type,
	.probe		= fs_enet_probe,
	.remove		= fs_enet_remove,
#ifdef CONFIG_PM
/*	.suspend	= fs_enet_suspend,	TODO */
/*	.resume		= fs_enet_resume,	TODO */
#endif
};

static struct device_driver fs_enet_fcc_driver = {
	.name	  	= "fsl-cpm-fcc",
	.bus		= &platform_bus_type,
	.probe		= fs_enet_probe,
	.remove		= fs_enet_remove,
#ifdef CONFIG_PM
/*	.suspend	= fs_enet_suspend,	TODO */
/*	.resume		= fs_enet_resume,	TODO */
#endif
};

static int __init fs_init(void)
{
	int r;

	printk(KERN_INFO
			"%s", version);

	r = setup_immap();
	if (r != 0)
		return r;

#ifdef CONFIG_FS_ENET_HAS_FCC
	/* let's insert mii stuff */
	r = fs_enet_mdio_bb_init();

	if (r != 0) {
		printk(KERN_ERR DRV_MODULE_NAME
			"BB PHY init failed.\n");
		return r;
	}
	r = driver_register(&fs_enet_fcc_driver);
	if (r != 0)
		goto err;
#endif

#ifdef CONFIG_FS_ENET_HAS_FEC
	r =  fs_enet_mdio_fec_init();
	if (r != 0) {
		printk(KERN_ERR DRV_MODULE_NAME
			"FEC PHY init failed.\n");
		return r;
	}

	r = driver_register(&fs_enet_fec_driver);
	if (r != 0)
		goto err;
#endif

#ifdef CONFIG_FS_ENET_HAS_SCC
	r = driver_register(&fs_enet_scc_driver);
	if (r != 0)
		goto err;
#endif

	return 0;
err:
	cleanup_immap();
	return r;
}

static void __exit fs_cleanup(void)
{
	driver_unregister(&fs_enet_fec_driver);
	driver_unregister(&fs_enet_fcc_driver);
	driver_unregister(&fs_enet_scc_driver);
	cleanup_immap();
}
#endif

#ifdef CONFIG_NET_POLL_CONTROLLER
static void fs_enet_netpoll(struct net_device *dev)
+0 −4
Original line number Diff line number Diff line
@@ -138,10 +138,6 @@ struct fs_enet_private {
};

/***************************************************************************/
#ifndef CONFIG_PPC_CPM_NEW_BINDING
int fs_enet_mdio_bb_init(void);
int fs_enet_mdio_fec_init(void);
#endif

void fs_init_bds(struct net_device *dev);
void fs_cleanup_bds(struct net_device *dev);
+1 −66
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <linux/phy.h>
#include <linux/of_device.h>

#include <asm/immap_cpm2.h>
#include <asm/mpc8260.h>
@@ -42,10 +43,6 @@
#include <asm/irq.h>
#include <asm/uaccess.h>

#ifdef CONFIG_PPC_CPM_NEW_BINDING
#include <asm/of_device.h>
#endif

#include "fs_enet.h"

/*************************************************/
@@ -87,7 +84,6 @@ static inline int fcc_cr_cmd(struct fs_enet_private *fep, u32 op)

static int do_pd_setup(struct fs_enet_private *fep)
{
#ifdef CONFIG_PPC_CPM_NEW_BINDING
	struct of_device *ofdev = to_of_device(fep->dev);
	struct fs_platform_info *fpi = fep->fpi;
	int ret = -EINVAL;
@@ -125,44 +121,6 @@ out_fccp:
	iounmap(fep->fcc.fccp);
out:
	return ret;
#else
	struct platform_device *pdev = to_platform_device(fep->dev);
	struct resource *r;

	/* Fill out IRQ field */
	fep->interrupt = platform_get_irq(pdev, 0);
	if (fep->interrupt < 0)
		return -EINVAL;

	/* Attach the memory for the FCC Parameter RAM */
	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_pram");
	fep->fcc.ep = ioremap(r->start, r->end - r->start + 1);
	if (fep->fcc.ep == NULL)
		return -EINVAL;

	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_regs");
	fep->fcc.fccp = ioremap(r->start, r->end - r->start + 1);
	if (fep->fcc.fccp == NULL)
		return -EINVAL;

	if (fep->fpi->fcc_regs_c) {
		fep->fcc.fcccp = (void __iomem *)fep->fpi->fcc_regs_c;
	} else {
		r = platform_get_resource_byname(pdev, IORESOURCE_MEM,
				"fcc_regs_c");
		fep->fcc.fcccp = ioremap(r->start,
				r->end - r->start + 1);
	}

	if (fep->fcc.fcccp == NULL)
		return -EINVAL;

	fep->fcc.mem = (void __iomem *)fep->fpi->mem_offset;
	if (fep->fcc.mem == NULL)
		return -EINVAL;

	return 0;
#endif
}

#define FCC_NAPI_RX_EVENT_MSK	(FCC_ENET_RXF | FCC_ENET_RXB)
@@ -173,17 +131,6 @@ out:
static int setup_data(struct net_device *dev)
{
	struct fs_enet_private *fep = netdev_priv(dev);
#ifndef CONFIG_PPC_CPM_NEW_BINDING
	struct fs_platform_info *fpi = fep->fpi;

	fpi->cp_command = (fpi->cp_page << 26) |
	                  (fpi->cp_block << 21) |
	                  (12 << 6);

	fep->fcc.idx = fs_get_fcc_index(fpi->fs_no);
	if ((unsigned int)fep->fcc.idx >= 3)	/* max 3 FCCs */
		return -EINVAL;
#endif

	if (do_pd_setup(fep) != 0)
		return -EINVAL;
@@ -304,9 +251,6 @@ static void restart(struct net_device *dev)
	fcc_enet_t __iomem *ep = fep->fcc.ep;
	dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
	u16 paddrh, paddrm, paddrl;
#ifndef CONFIG_PPC_CPM_NEW_BINDING
	u16 mem_addr;
#endif
	const unsigned char *mac;
	int i;

@@ -338,19 +282,10 @@ static void restart(struct net_device *dev)
	 * this area.
	 */

#ifdef CONFIG_PPC_CPM_NEW_BINDING
	W16(ep, fen_genfcc.fcc_riptr, fpi->dpram_offset);
	W16(ep, fen_genfcc.fcc_tiptr, fpi->dpram_offset + 32);

	W16(ep, fen_padptr, fpi->dpram_offset + 64);
#else
	mem_addr = (u32) fep->fcc.mem;	/* de-fixup dpram offset */

	W16(ep, fen_genfcc.fcc_riptr, (mem_addr & 0xffff));
	W16(ep, fen_genfcc.fcc_tiptr, ((mem_addr + 32) & 0xffff));

	W16(ep, fen_padptr, mem_addr + 64);
#endif

	/* fill with special symbol...  */
	memset_io(fep->fcc.mem + fpi->dpram_offset + 64, 0x88, 32);
+1 −22
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <linux/bitops.h>
#include <linux/fs.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>

#include <asm/irq.h>
#include <asm/uaccess.h>
@@ -43,10 +44,6 @@
#include <asm/cpm1.h>
#endif

#ifdef CONFIG_PPC_CPM_NEW_BINDING
#include <asm/of_device.h>
#endif

#include "fs_enet.h"
#include "fec.h"

@@ -99,7 +96,6 @@ static int whack_reset(fec_t __iomem *fecp)

static int do_pd_setup(struct fs_enet_private *fep)
{
#ifdef CONFIG_PPC_CPM_NEW_BINDING
	struct of_device *ofdev = to_of_device(fep->dev);

	fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL);
@@ -111,23 +107,6 @@ static int do_pd_setup(struct fs_enet_private *fep)
		return -EINVAL;

	return 0;
#else
	struct platform_device *pdev = to_platform_device(fep->dev);
	struct resource	*r;

	/* Fill out IRQ field */
	fep->interrupt = platform_get_irq_byname(pdev,"interrupt");
	if (fep->interrupt < 0)
		return -EINVAL;

	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
	fep->fec.fecp = ioremap(r->start, r->end - r->start + 1);

	if(fep->fec.fecp == NULL)
		return -EINVAL;

	return 0;
#endif
}

#define FEC_NAPI_RX_EVENT_MSK	(FEC_ENET_RXF | FEC_ENET_RXB)
Loading