aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fs_enet/mac-scc.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-10-02 11:55:58 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:54:03 -0400
commit976de6a8c304dcc43e38efcb8a0bace7866b6242 (patch)
treebae132693bbcfa65c03cf44c7db924fdebf13158 /drivers/net/fs_enet/mac-scc.c
parent0d0d9c150c046cbd3e507adcfa2d78db82f1f452 (diff)
fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.
The existing OF glue code was crufty and broken. Rather than fix it, it will be removed, and the ethernet driver now talks to the device tree directly. The old, non-CONFIG_PPC_CPM_NEW_BINDING code can go away once CPM platforms are dropped from arch/ppc (which will hopefully be soon), and existing arch/powerpc boards that I wasn't able to test on for this patchset get converted (which should be even sooner). Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/fs_enet/mac-scc.c')
-rw-r--r--drivers/net/fs_enet/mac-scc.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index 6f32674a78e9..add9e32d4f47 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -43,6 +43,10 @@
43#include <asm/commproc.h> 43#include <asm/commproc.h>
44#endif 44#endif
45 45
46#ifdef CONFIG_PPC_CPM_NEW_BINDING
47#include <asm/of_platform.h>
48#endif
49
46#include "fs_enet.h" 50#include "fs_enet.h"
47 51
48/*************************************************/ 52/*************************************************/
@@ -89,27 +93,38 @@
89 93
90static inline int scc_cr_cmd(struct fs_enet_private *fep, u32 op) 94static inline int scc_cr_cmd(struct fs_enet_private *fep, u32 op)
91{ 95{
92 cpm8xx_t *cpmp = &((immap_t *)fs_enet_immap)->im_cpm; 96 const struct fs_platform_info *fpi = fep->fpi;
93 u32 v, ch; 97 int i;
94 int i = 0;
95 98
96 ch = fep->scc.idx << 2; 99 W16(cpmp, cp_cpcr, fpi->cp_command | CPM_CR_FLG | (op << 8));
97 v = mk_cr_cmd(ch, op);
98 W16(cpmp, cp_cpcr, v | CPM_CR_FLG);
99 for (i = 0; i < MAX_CR_CMD_LOOPS; i++) 100 for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
100 if ((R16(cpmp, cp_cpcr) & CPM_CR_FLG) == 0) 101 if ((R16(cpmp, cp_cpcr) & CPM_CR_FLG) == 0)
101 break; 102 return 0;
102 103
103 if (i >= MAX_CR_CMD_LOOPS) { 104 printk(KERN_ERR "%s(): Not able to issue CPM command\n",
104 printk(KERN_ERR "%s(): Not able to issue CPM command\n", 105 __FUNCTION__);
105 __FUNCTION__); 106 return 1;
106 return 1;
107 }
108 return 0;
109} 107}
110 108
111static int do_pd_setup(struct fs_enet_private *fep) 109static int do_pd_setup(struct fs_enet_private *fep)
112{ 110{
111#ifdef CONFIG_PPC_CPM_NEW_BINDING
112 struct of_device *ofdev = to_of_device(fep->dev);
113
114 fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL);
115 if (fep->interrupt == NO_IRQ)
116 return -EINVAL;
117
118 fep->scc.sccp = of_iomap(ofdev->node, 0);
119 if (!fep->scc.sccp)
120 return -EINVAL;
121
122 fep->scc.ep = of_iomap(ofdev->node, 1);
123 if (!fep->scc.ep) {
124 iounmap(fep->scc.sccp);
125 return -EINVAL;
126 }
127#else
113 struct platform_device *pdev = to_platform_device(fep->dev); 128 struct platform_device *pdev = to_platform_device(fep->dev);
114 struct resource *r; 129 struct resource *r;
115 130
@@ -129,6 +144,7 @@ static int do_pd_setup(struct fs_enet_private *fep)
129 144
130 if (fep->scc.ep == NULL) 145 if (fep->scc.ep == NULL)
131 return -EINVAL; 146 return -EINVAL;
147#endif
132 148
133 return 0; 149 return 0;
134} 150}
@@ -141,12 +157,17 @@ static int do_pd_setup(struct fs_enet_private *fep)
141static int setup_data(struct net_device *dev) 157static int setup_data(struct net_device *dev)
142{ 158{
143 struct fs_enet_private *fep = netdev_priv(dev); 159 struct fs_enet_private *fep = netdev_priv(dev);
144 const struct fs_platform_info *fpi = fep->fpi; 160
161#ifdef CONFIG_PPC_CPM_NEW_BINDING
162 struct fs_platform_info *fpi = fep->fpi;
145 163
146 fep->scc.idx = fs_get_scc_index(fpi->fs_no); 164 fep->scc.idx = fs_get_scc_index(fpi->fs_no);
147 if ((unsigned int)fep->fcc.idx > 4) /* max 4 SCCs */ 165 if ((unsigned int)fep->fcc.idx >= 4) /* max 4 SCCs */
148 return -EINVAL; 166 return -EINVAL;
149 167
168 fpi->cp_command = fep->fcc.idx << 6;
169#endif
170
150 do_pd_setup(fep); 171 do_pd_setup(fep);
151 172
152 fep->scc.hthi = 0; 173 fep->scc.hthi = 0;
@@ -154,7 +175,7 @@ static int setup_data(struct net_device *dev)
154 175
155 fep->ev_napi_rx = SCC_NAPI_RX_EVENT_MSK; 176 fep->ev_napi_rx = SCC_NAPI_RX_EVENT_MSK;
156 fep->ev_rx = SCC_RX_EVENT; 177 fep->ev_rx = SCC_RX_EVENT;
157 fep->ev_tx = SCC_TX_EVENT; 178 fep->ev_tx = SCC_TX_EVENT | SCCE_ENET_TXE;
158 fep->ev_err = SCC_ERR_EVENT_MSK; 179 fep->ev_err = SCC_ERR_EVENT_MSK;
159 180
160 return 0; 181 return 0;