drm: include kernel list header file in hashtab header
[safe/jmp/linux-2.6] / drivers / net / fs_enet / mac-scc.c
index 6f32674..008cdd9 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/bitops.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/8xx_immap.h>
 #include <asm/pgtable.h>
 #include <asm/mpc8xx.h>
-#include <asm/commproc.h>
+#include <asm/cpm1.h>
 #endif
 
 #include "fs_enet.h"
 
 /*************************************************/
-
 #if defined(CONFIG_CPM1)
 /* for a 8xx __raw_xxx's are sufficient */
 #define __fs_out32(addr, x)    __raw_writel(x, addr)
@@ -61,6 +61,8 @@
 #define __fs_out16(addr, x)    out_be16(addr, x)
 #define __fs_in32(addr)        in_be32(addr)
 #define __fs_in16(addr)        in_be16(addr)
+#define __fs_out8(addr, x)     out_8(addr, x)
+#define __fs_in8(addr) in_8(addr)
 #endif
 
 /* write, read, set bits, clear bits */
  * Delay to wait for SCC reset command to complete (in us)
  */
 #define SCC_RESET_DELAY                50
-#define MAX_CR_CMD_LOOPS       10000
 
 static inline int scc_cr_cmd(struct fs_enet_private *fep, u32 op)
 {
-       cpm8xx_t *cpmp = &((immap_t *)fs_enet_immap)->im_cpm;
-       u32 v, ch;
-       int i = 0;
-
-       ch = fep->scc.idx << 2;
-       v = mk_cr_cmd(ch, op);
-       W16(cpmp, cp_cpcr, v | CPM_CR_FLG);
-       for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
-               if ((R16(cpmp, cp_cpcr) & CPM_CR_FLG) == 0)
-                       break;
-
-       if (i >= MAX_CR_CMD_LOOPS) {
-               printk(KERN_ERR "%s(): Not able to issue CPM command\n",
-                       __FUNCTION__);
-               return 1;
-       }
-       return 0;
+       const struct fs_platform_info *fpi = fep->fpi;
+
+       return cpm_command(fpi->cp_command, op);
 }
 
 static int do_pd_setup(struct fs_enet_private *fep)
 {
-       struct platform_device *pdev = to_platform_device(fep->dev);
-       struct resource *r;
+       struct of_device *ofdev = to_of_device(fep->dev);
 
-       /* Fill out IRQ field */
-       fep->interrupt = platform_get_irq_byname(pdev, "interrupt");
-       if (fep->interrupt < 0)
+       fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL);
+       if (fep->interrupt == NO_IRQ)
                return -EINVAL;
 
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
-       fep->scc.sccp = ioremap(r->start, r->end - r->start + 1);
-
-       if (fep->scc.sccp == NULL)
+       fep->scc.sccp = of_iomap(ofdev->node, 0);
+       if (!fep->scc.sccp)
                return -EINVAL;
 
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pram");
-       fep->scc.ep = ioremap(r->start, r->end - r->start + 1);
-
-       if (fep->scc.ep == NULL)
+       fep->scc.ep = of_iomap(ofdev->node, 1);
+       if (!fep->scc.ep) {
+               iounmap(fep->scc.sccp);
                return -EINVAL;
+       }
 
        return 0;
 }
@@ -141,11 +124,6 @@ static int do_pd_setup(struct fs_enet_private *fep)
 static int setup_data(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       const struct fs_platform_info *fpi = fep->fpi;
-
-       fep->scc.idx = fs_get_scc_index(fpi->fs_no);
-       if ((unsigned int)fep->fcc.idx > 4)     /* max 4 SCCs */
-               return -EINVAL;
 
        do_pd_setup(fep);
 
@@ -154,7 +132,7 @@ static int setup_data(struct net_device *dev)
 
        fep->ev_napi_rx = SCC_NAPI_RX_EVENT_MSK;
        fep->ev_rx = SCC_RX_EVENT;
-       fep->ev_tx = SCC_TX_EVENT;
+       fep->ev_tx = SCC_TX_EVENT | SCCE_ENET_TXE;
        fep->ev_err = SCC_ERR_EVENT_MSK;
 
        return 0;
@@ -170,7 +148,8 @@ static int allocate_bd(struct net_device *dev)
        if (IS_ERR_VALUE(fep->ring_mem_addr))
                return -ENOMEM;
 
-       fep->ring_base = cpm_dpram_addr(fep->ring_mem_addr);
+       fep->ring_base = (void __iomem __force*)
+               cpm_dpram_addr(fep->ring_mem_addr);
 
        return 0;
 }
@@ -191,7 +170,7 @@ static void cleanup_data(struct net_device *dev)
 static void set_promiscuous_mode(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
 
        S16(sccp, scc_psmr, SCC_PSMR_PRO);
 }
@@ -199,7 +178,7 @@ static void set_promiscuous_mode(struct net_device *dev)
 static void set_multicast_start(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_enet_t *ep = fep->scc.ep;
+       scc_enet_t __iomem *ep = fep->scc.ep;
 
        W16(ep, sen_gaddr1, 0);
        W16(ep, sen_gaddr2, 0);
@@ -210,7 +189,7 @@ static void set_multicast_start(struct net_device *dev)
 static void set_multicast_one(struct net_device *dev, const u8 * mac)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_enet_t *ep = fep->scc.ep;
+       scc_enet_t __iomem *ep = fep->scc.ep;
        u16 taddrh, taddrm, taddrl;
 
        taddrh = ((u16) mac[5] << 8) | mac[4];
@@ -226,8 +205,8 @@ static void set_multicast_one(struct net_device *dev, const u8 * mac)
 static void set_multicast_finish(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
-       scc_enet_t *ep = fep->scc.ep;
+       scc_t __iomem *sccp = fep->scc.sccp;
+       scc_enet_t __iomem *ep = fep->scc.ep;
 
        /* clear promiscuous always */
        C16(sccp, scc_psmr, SCC_PSMR_PRO);
@@ -264,8 +243,8 @@ static void set_multicast_list(struct net_device *dev)
 static void restart(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
-       scc_enet_t *ep = fep->scc.ep;
+       scc_t __iomem *sccp = fep->scc.sccp;
+       scc_enet_t __iomem *ep = fep->scc.ep;
        const struct fs_platform_info *fpi = fep->fpi;
        u16 paddrh, paddrm, paddrl;
        const unsigned char *mac;
@@ -275,7 +254,7 @@ static void restart(struct net_device *dev)
 
        /* clear everything (slow & steady does it) */
        for (i = 0; i < sizeof(*ep); i++)
-               __fs_out8((char *)ep + i, 0);
+               __fs_out8((u8 __iomem *)ep + i, 0);
 
        /* point to bds */
        W16(ep, sen_genscc.scc_rbase, fep->ring_mem_addr);
@@ -284,8 +263,13 @@ static void restart(struct net_device *dev)
 
        /* Initialize function code registers for big-endian.
         */
+#ifndef CONFIG_NOT_COHERENT_CACHE
+       W8(ep, sen_genscc.scc_rfcr, SCC_EB | SCC_GBL);
+       W8(ep, sen_genscc.scc_tfcr, SCC_EB | SCC_GBL);
+#else
        W8(ep, sen_genscc.scc_rfcr, SCC_EB);
        W8(ep, sen_genscc.scc_tfcr, SCC_EB);
+#endif
 
        /* Set maximum bytes per receive buffer.
         * This appears to be an Ethernet frame size, not the buffer
@@ -376,7 +360,7 @@ static void restart(struct net_device *dev)
 static void stop(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
        int i;
 
        for (i = 0; (R16(sccp, scc_sccm) == 0) && i < SCC_RESET_DELAY; i++)
@@ -393,34 +377,10 @@ static void stop(struct net_device *dev)
        fs_cleanup_bds(dev);
 }
 
-static void pre_request_irq(struct net_device *dev, int irq)
-{
-#ifndef CONFIG_PPC_MERGE
-       immap_t *immap = fs_enet_immap;
-       u32 siel;
-
-       /* SIU interrupt */
-       if (irq >= SIU_IRQ0 && irq < SIU_LEVEL7) {
-
-               siel = in_be32(&immap->im_siu_conf.sc_siel);
-               if ((irq & 1) == 0)
-                       siel |= (0x80000000 >> irq);
-               else
-                       siel &= ~(0x80000000 >> (irq & ~1));
-               out_be32(&immap->im_siu_conf.sc_siel, siel);
-       }
-#endif
-}
-
-static void post_free_irq(struct net_device *dev, int irq)
-{
-       /* nothing */
-}
-
 static void napi_clear_rx_event(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
 
        W16(sccp, scc_scce, SCC_NAPI_RX_EVENT_MSK);
 }
@@ -428,7 +388,7 @@ static void napi_clear_rx_event(struct net_device *dev)
 static void napi_enable_rx(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
 
        S16(sccp, scc_sccm, SCC_NAPI_RX_EVENT_MSK);
 }
@@ -436,7 +396,7 @@ static void napi_enable_rx(struct net_device *dev)
 static void napi_disable_rx(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
 
        C16(sccp, scc_sccm, SCC_NAPI_RX_EVENT_MSK);
 }
@@ -454,7 +414,7 @@ static void tx_kickstart(struct net_device *dev)
 static u32 get_int_events(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
 
        return (u32) R16(sccp, scc_scce);
 }
@@ -462,7 +422,7 @@ static u32 get_int_events(struct net_device *dev)
 static void clear_int_events(struct net_device *dev, u32 int_events)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       scc_t *sccp = fep->scc.sccp;
+       scc_t __iomem *sccp = fep->scc.sccp;
 
        W16(sccp, scc_scce, int_events & 0xffff);
 }
@@ -477,20 +437,20 @@ static int get_regs(struct net_device *dev, void *p, int *sizep)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
 
-       if (*sizep < sizeof(scc_t) + sizeof(scc_enet_t))
+       if (*sizep < sizeof(scc_t) + sizeof(scc_enet_t __iomem *))
                return -EINVAL;
 
        memcpy_fromio(p, fep->scc.sccp, sizeof(scc_t));
        p = (char *)p + sizeof(scc_t);
 
-       memcpy_fromio(p, fep->scc.ep, sizeof(scc_enet_t));
+       memcpy_fromio(p, fep->scc.ep, sizeof(scc_enet_t __iomem *));
 
        return 0;
 }
 
 static int get_regs_len(struct net_device *dev)
 {
-       return sizeof(scc_t) + sizeof(scc_enet_t);
+       return sizeof(scc_t) + sizeof(scc_enet_t __iomem *);
 }
 
 static void tx_restart(struct net_device *dev)
@@ -510,8 +470,6 @@ const struct fs_ops fs_scc_ops = {
        .set_multicast_list     = set_multicast_list,
        .restart                = restart,
        .stop                   = stop,
-       .pre_request_irq        = pre_request_irq,
-       .post_free_irq          = post_free_irq,
        .napi_clear_rx_event    = napi_clear_rx_event,
        .napi_enable_rx         = napi_enable_rx,
        .napi_disable_rx        = napi_disable_rx,