Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Freescale PowerQUICC Ethernet Driver -- MIIM bus implementation |
| 3 | * Provides Bus interface for MIIM regs |
| 4 | * |
| 5 | * Author: Andy Fleming <afleming@freescale.com> |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 6 | * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 7 | * |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 8 | * Copyright 2002-2004, 2008-2009 Freescale Semiconductor, Inc. |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 9 | * |
| 10 | * Based on gianfar_mii.c and ucc_geth_mii.c (Li Yang, Kim Phillips) |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the |
| 14 | * Free Software Foundation; either version 2 of the License, or (at your |
| 15 | * option) any later version. |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/string.h> |
| 21 | #include <linux/errno.h> |
| 22 | #include <linux/unistd.h> |
| 23 | #include <linux/slab.h> |
| 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/delay.h> |
| 27 | #include <linux/netdevice.h> |
| 28 | #include <linux/etherdevice.h> |
| 29 | #include <linux/skbuff.h> |
| 30 | #include <linux/spinlock.h> |
| 31 | #include <linux/mm.h> |
| 32 | #include <linux/module.h> |
| 33 | #include <linux/platform_device.h> |
| 34 | #include <linux/crc32.h> |
| 35 | #include <linux/mii.h> |
| 36 | #include <linux/phy.h> |
| 37 | #include <linux/of.h> |
Grant Likely | 324931b | 2009-04-25 12:53:07 +0000 | [diff] [blame] | 38 | #include <linux/of_mdio.h> |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 39 | #include <linux/of_platform.h> |
| 40 | |
| 41 | #include <asm/io.h> |
| 42 | #include <asm/irq.h> |
| 43 | #include <asm/uaccess.h> |
| 44 | #include <asm/ucc.h> |
| 45 | |
| 46 | #include "gianfar.h" |
| 47 | #include "fsl_pq_mdio.h" |
| 48 | |
| 49 | /* |
| 50 | * Write value to the PHY at mii_id at register regnum, |
| 51 | * on the bus attached to the local interface, which may be different from the |
| 52 | * generic mdio bus (tied to a single interface), waiting until the write is |
| 53 | * done before returning. This is helpful in programming interfaces like |
| 54 | * the TBI which control interfaces like onchip SERDES and are always tied to |
| 55 | * the local mdio pins, which may not be the same as system mdio bus, used for |
| 56 | * controlling the external PHYs, for example. |
| 57 | */ |
| 58 | int fsl_pq_local_mdio_write(struct fsl_pq_mdio __iomem *regs, int mii_id, |
| 59 | int regnum, u16 value) |
| 60 | { |
| 61 | /* Set the PHY address and the register address we want to write */ |
| 62 | out_be32(®s->miimadd, (mii_id << 8) | regnum); |
| 63 | |
| 64 | /* Write out the value we want */ |
| 65 | out_be32(®s->miimcon, value); |
| 66 | |
| 67 | /* Wait for the transaction to finish */ |
| 68 | while (in_be32(®s->miimind) & MIIMIND_BUSY) |
| 69 | cpu_relax(); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | /* |
| 75 | * Read the bus for PHY at addr mii_id, register regnum, and |
| 76 | * return the value. Clears miimcom first. All PHY operation |
| 77 | * done on the bus attached to the local interface, |
| 78 | * which may be different from the generic mdio bus |
| 79 | * This is helpful in programming interfaces like |
| 80 | * the TBI which, in turn, control interfaces like onchip SERDES |
| 81 | * and are always tied to the local mdio pins, which may not be the |
| 82 | * same as system mdio bus, used for controlling the external PHYs, for eg. |
| 83 | */ |
| 84 | int fsl_pq_local_mdio_read(struct fsl_pq_mdio __iomem *regs, |
| 85 | int mii_id, int regnum) |
| 86 | { |
| 87 | u16 value; |
| 88 | |
| 89 | /* Set the PHY address and the register address we want to read */ |
| 90 | out_be32(®s->miimadd, (mii_id << 8) | regnum); |
| 91 | |
| 92 | /* Clear miimcom, and then initiate a read */ |
| 93 | out_be32(®s->miimcom, 0); |
| 94 | out_be32(®s->miimcom, MII_READ_COMMAND); |
| 95 | |
| 96 | /* Wait for the transaction to finish */ |
| 97 | while (in_be32(®s->miimind) & (MIIMIND_NOTVALID | MIIMIND_BUSY)) |
| 98 | cpu_relax(); |
| 99 | |
| 100 | /* Grab the value of the register from miimstat */ |
| 101 | value = in_be32(®s->miimstat); |
| 102 | |
| 103 | return value; |
| 104 | } |
| 105 | |
Anton Vorontsov | 6748f60 | 2009-11-04 12:52:57 +0000 | [diff] [blame^] | 106 | static struct fsl_pq_mdio __iomem *fsl_pq_mdio_get_regs(struct mii_bus *bus) |
| 107 | { |
| 108 | return (void __iomem __force *)bus->priv; |
| 109 | } |
| 110 | |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 111 | /* |
| 112 | * Write value to the PHY at mii_id at register regnum, |
| 113 | * on the bus, waiting until the write is done before returning. |
| 114 | */ |
| 115 | int fsl_pq_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value) |
| 116 | { |
Anton Vorontsov | 6748f60 | 2009-11-04 12:52:57 +0000 | [diff] [blame^] | 117 | struct fsl_pq_mdio __iomem *regs = fsl_pq_mdio_get_regs(bus); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 118 | |
| 119 | /* Write to the local MII regs */ |
| 120 | return(fsl_pq_local_mdio_write(regs, mii_id, regnum, value)); |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * Read the bus for PHY at addr mii_id, register regnum, and |
| 125 | * return the value. Clears miimcom first. |
| 126 | */ |
| 127 | int fsl_pq_mdio_read(struct mii_bus *bus, int mii_id, int regnum) |
| 128 | { |
Anton Vorontsov | 6748f60 | 2009-11-04 12:52:57 +0000 | [diff] [blame^] | 129 | struct fsl_pq_mdio __iomem *regs = fsl_pq_mdio_get_regs(bus); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 130 | |
| 131 | /* Read the local MII regs */ |
| 132 | return(fsl_pq_local_mdio_read(regs, mii_id, regnum)); |
| 133 | } |
| 134 | |
| 135 | /* Reset the MIIM registers, and wait for the bus to free */ |
| 136 | static int fsl_pq_mdio_reset(struct mii_bus *bus) |
| 137 | { |
Anton Vorontsov | 6748f60 | 2009-11-04 12:52:57 +0000 | [diff] [blame^] | 138 | struct fsl_pq_mdio __iomem *regs = fsl_pq_mdio_get_regs(bus); |
David S. Miller | 508827f | 2009-03-05 02:06:47 -0800 | [diff] [blame] | 139 | int timeout = PHY_INIT_TIMEOUT; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 140 | |
| 141 | mutex_lock(&bus->mdio_lock); |
| 142 | |
| 143 | /* Reset the management interface */ |
| 144 | out_be32(®s->miimcfg, MIIMCFG_RESET); |
| 145 | |
| 146 | /* Setup the MII Mgmt clock speed */ |
| 147 | out_be32(®s->miimcfg, MIIMCFG_INIT_VALUE); |
| 148 | |
| 149 | /* Wait until the bus is free */ |
| 150 | while ((in_be32(®s->miimind) & MIIMIND_BUSY) && timeout--) |
| 151 | cpu_relax(); |
| 152 | |
| 153 | mutex_unlock(&bus->mdio_lock); |
| 154 | |
David S. Miller | 508827f | 2009-03-05 02:06:47 -0800 | [diff] [blame] | 155 | if (timeout < 0) { |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 156 | printk(KERN_ERR "%s: The MII Bus is stuck!\n", |
| 157 | bus->name); |
| 158 | return -EBUSY; |
| 159 | } |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 164 | void fsl_pq_mdio_bus_name(char *name, struct device_node *np) |
| 165 | { |
Anton Vorontsov | 18f2738 | 2009-03-19 06:48:08 +0000 | [diff] [blame] | 166 | const u32 *addr; |
| 167 | u64 taddr = OF_BAD_ADDR; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 168 | |
Anton Vorontsov | 18f2738 | 2009-03-19 06:48:08 +0000 | [diff] [blame] | 169 | addr = of_get_address(np, 0, NULL, NULL); |
| 170 | if (addr) |
| 171 | taddr = of_translate_address(np, addr); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 172 | |
Anton Vorontsov | 18f2738 | 2009-03-19 06:48:08 +0000 | [diff] [blame] | 173 | snprintf(name, MII_BUS_ID_SIZE, "%s@%llx", np->name, |
| 174 | (unsigned long long)taddr); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 175 | } |
Segher Boessenkool | b6bc978 | 2009-04-02 13:57:30 -0700 | [diff] [blame] | 176 | EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 177 | |
| 178 | /* Scan the bus in reverse, looking for an empty spot */ |
| 179 | static int fsl_pq_mdio_find_free(struct mii_bus *new_bus) |
| 180 | { |
| 181 | int i; |
| 182 | |
| 183 | for (i = PHY_MAX_ADDR; i > 0; i--) { |
| 184 | u32 phy_id; |
| 185 | |
| 186 | if (get_phy_id(new_bus, i, &phy_id)) |
| 187 | return -1; |
| 188 | |
| 189 | if (phy_id == 0xffffffff) |
| 190 | break; |
| 191 | } |
| 192 | |
| 193 | return i; |
| 194 | } |
| 195 | |
| 196 | |
Ionut Nicu | e2a61fa | 2009-06-24 22:23:39 +0000 | [diff] [blame] | 197 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 198 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 199 | { |
| 200 | struct gfar __iomem *enet_regs; |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 201 | u32 __iomem *ioremap_tbipa; |
| 202 | u64 addr, size; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 203 | |
| 204 | /* |
| 205 | * This is mildly evil, but so is our hardware for doing this. |
| 206 | * Also, we have to cast back to struct gfar because of |
| 207 | * definition weirdness done in gianfar.h. |
| 208 | */ |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 209 | if(of_device_is_compatible(np, "fsl,gianfar-mdio") || |
| 210 | of_device_is_compatible(np, "fsl,gianfar-tbi") || |
| 211 | of_device_is_compatible(np, "gianfar")) { |
| 212 | enet_regs = (struct gfar __iomem *)regs; |
| 213 | return &enet_regs->tbipa; |
| 214 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || |
| 215 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { |
| 216 | addr = of_translate_address(np, of_get_address(np, 1, &size, NULL)); |
| 217 | ioremap_tbipa = ioremap(addr, size); |
| 218 | return ioremap_tbipa; |
| 219 | } else |
| 220 | return NULL; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 221 | } |
| 222 | #endif |
| 223 | |
| 224 | |
Ionut Nicu | e2a61fa | 2009-06-24 22:23:39 +0000 | [diff] [blame] | 225 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 226 | static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) |
| 227 | { |
| 228 | struct device_node *np = NULL; |
| 229 | int err = 0; |
| 230 | |
| 231 | for_each_compatible_node(np, NULL, "ucc_geth") { |
| 232 | struct resource tempres; |
| 233 | |
| 234 | err = of_address_to_resource(np, 0, &tempres); |
| 235 | if (err) |
| 236 | continue; |
| 237 | |
| 238 | /* if our mdio regs fall within this UCC regs range */ |
| 239 | if ((start >= tempres.start) && (end <= tempres.end)) { |
| 240 | /* Find the id of the UCC */ |
| 241 | const u32 *id; |
| 242 | |
| 243 | id = of_get_property(np, "cell-index", NULL); |
| 244 | if (!id) { |
| 245 | id = of_get_property(np, "device-id", NULL); |
| 246 | if (!id) |
| 247 | continue; |
| 248 | } |
| 249 | |
| 250 | *ucc_id = *id; |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | if (err) |
| 257 | return err; |
| 258 | else |
| 259 | return -EINVAL; |
| 260 | } |
| 261 | #endif |
| 262 | |
| 263 | |
| 264 | static int fsl_pq_mdio_probe(struct of_device *ofdev, |
| 265 | const struct of_device_id *match) |
| 266 | { |
| 267 | struct device_node *np = ofdev->node; |
| 268 | struct device_node *tbi; |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 269 | struct fsl_pq_mdio __iomem *regs = NULL; |
Anton Vorontsov | 2951d64 | 2009-11-04 12:52:56 +0000 | [diff] [blame] | 270 | void __iomem *map; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 271 | u32 __iomem *tbipa; |
| 272 | struct mii_bus *new_bus; |
| 273 | int tbiaddr = -1; |
Anton Vorontsov | 2951d64 | 2009-11-04 12:52:56 +0000 | [diff] [blame] | 274 | u64 addr = 0, size = 0; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 275 | int err = 0; |
| 276 | |
| 277 | new_bus = mdiobus_alloc(); |
| 278 | if (NULL == new_bus) |
| 279 | return -ENOMEM; |
| 280 | |
| 281 | new_bus->name = "Freescale PowerQUICC MII Bus", |
| 282 | new_bus->read = &fsl_pq_mdio_read, |
| 283 | new_bus->write = &fsl_pq_mdio_write, |
| 284 | new_bus->reset = &fsl_pq_mdio_reset, |
| 285 | fsl_pq_mdio_bus_name(new_bus->id, np); |
| 286 | |
| 287 | /* Set the PHY base address */ |
Anton Vorontsov | 2951d64 | 2009-11-04 12:52:56 +0000 | [diff] [blame] | 288 | addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); |
| 289 | map = ioremap(addr, size); |
| 290 | if (!map) { |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 291 | err = -ENOMEM; |
| 292 | goto err_free_bus; |
| 293 | } |
| 294 | |
Anton Vorontsov | 2951d64 | 2009-11-04 12:52:56 +0000 | [diff] [blame] | 295 | if (of_device_is_compatible(np, "fsl,gianfar-mdio") || |
| 296 | of_device_is_compatible(np, "fsl,gianfar-tbi") || |
| 297 | of_device_is_compatible(np, "fsl,ucc-mdio") || |
| 298 | of_device_is_compatible(np, "ucc_geth_phy")) |
| 299 | map -= offsetof(struct fsl_pq_mdio, miimcfg); |
| 300 | regs = map; |
| 301 | |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 302 | new_bus->priv = (void __force *)regs; |
| 303 | |
Grant Likely | 324931b | 2009-04-25 12:53:07 +0000 | [diff] [blame] | 304 | new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 305 | |
| 306 | if (NULL == new_bus->irq) { |
| 307 | err = -ENOMEM; |
| 308 | goto err_unmap_regs; |
| 309 | } |
| 310 | |
| 311 | new_bus->parent = &ofdev->dev; |
| 312 | dev_set_drvdata(&ofdev->dev, new_bus); |
| 313 | |
| 314 | if (of_device_is_compatible(np, "fsl,gianfar-mdio") || |
Anton Vorontsov | 3019684 | 2009-03-21 13:30:05 -0700 | [diff] [blame] | 315 | of_device_is_compatible(np, "fsl,gianfar-tbi") || |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 316 | of_device_is_compatible(np, "fsl,etsec2-mdio") || |
| 317 | of_device_is_compatible(np, "fsl,etsec2-tbi") || |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 318 | of_device_is_compatible(np, "gianfar")) { |
Ionut Nicu | e2a61fa | 2009-06-24 22:23:39 +0000 | [diff] [blame] | 319 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 320 | tbipa = get_gfar_tbipa(regs, np); |
| 321 | if (!tbipa) { |
| 322 | err = -EINVAL; |
| 323 | goto err_free_irqs; |
| 324 | } |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 325 | #else |
| 326 | err = -ENODEV; |
| 327 | goto err_free_irqs; |
| 328 | #endif |
| 329 | } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || |
| 330 | of_device_is_compatible(np, "ucc_geth_phy")) { |
Ionut Nicu | e2a61fa | 2009-06-24 22:23:39 +0000 | [diff] [blame] | 331 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 332 | u32 id; |
Haiying Wang | fbcc0e2 | 2009-06-02 04:04:14 +0000 | [diff] [blame] | 333 | static u32 mii_mng_master; |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 334 | |
| 335 | tbipa = ®s->utbipar; |
| 336 | |
| 337 | if ((err = get_ucc_id_for_range(addr, addr + size, &id))) |
| 338 | goto err_free_irqs; |
| 339 | |
Haiying Wang | fbcc0e2 | 2009-06-02 04:04:14 +0000 | [diff] [blame] | 340 | if (!mii_mng_master) { |
| 341 | mii_mng_master = id; |
| 342 | ucc_set_qe_mux_mii_mng(id - 1); |
| 343 | } |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 344 | #else |
| 345 | err = -ENODEV; |
| 346 | goto err_free_irqs; |
| 347 | #endif |
| 348 | } else { |
| 349 | err = -ENODEV; |
| 350 | goto err_free_irqs; |
| 351 | } |
| 352 | |
| 353 | for_each_child_of_node(np, tbi) { |
| 354 | if (!strncmp(tbi->type, "tbi-phy", 8)) |
| 355 | break; |
| 356 | } |
| 357 | |
| 358 | if (tbi) { |
| 359 | const u32 *prop = of_get_property(tbi, "reg", NULL); |
| 360 | |
| 361 | if (prop) |
| 362 | tbiaddr = *prop; |
| 363 | } |
| 364 | |
| 365 | if (tbiaddr == -1) { |
| 366 | out_be32(tbipa, 0); |
| 367 | |
| 368 | tbiaddr = fsl_pq_mdio_find_free(new_bus); |
| 369 | } |
| 370 | |
| 371 | /* |
| 372 | * We define TBIPA at 0 to be illegal, opting to fail for boards that |
| 373 | * have PHYs at 1-31, rather than change tbipa and rescan. |
| 374 | */ |
| 375 | if (tbiaddr == 0) { |
| 376 | err = -EBUSY; |
| 377 | |
| 378 | goto err_free_irqs; |
| 379 | } |
| 380 | |
| 381 | out_be32(tbipa, tbiaddr); |
| 382 | |
Grant Likely | 324931b | 2009-04-25 12:53:07 +0000 | [diff] [blame] | 383 | err = of_mdiobus_register(new_bus, np); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 384 | if (err) { |
| 385 | printk (KERN_ERR "%s: Cannot register as MDIO bus\n", |
| 386 | new_bus->name); |
| 387 | goto err_free_irqs; |
| 388 | } |
| 389 | |
| 390 | return 0; |
| 391 | |
| 392 | err_free_irqs: |
| 393 | kfree(new_bus->irq); |
| 394 | err_unmap_regs: |
| 395 | iounmap(regs); |
| 396 | err_free_bus: |
| 397 | kfree(new_bus); |
| 398 | |
| 399 | return err; |
| 400 | } |
| 401 | |
| 402 | |
| 403 | static int fsl_pq_mdio_remove(struct of_device *ofdev) |
| 404 | { |
| 405 | struct device *device = &ofdev->dev; |
| 406 | struct mii_bus *bus = dev_get_drvdata(device); |
| 407 | |
| 408 | mdiobus_unregister(bus); |
| 409 | |
| 410 | dev_set_drvdata(device, NULL); |
| 411 | |
Anton Vorontsov | 6748f60 | 2009-11-04 12:52:57 +0000 | [diff] [blame^] | 412 | iounmap(fsl_pq_mdio_get_regs(bus)); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 413 | bus->priv = NULL; |
| 414 | mdiobus_free(bus); |
| 415 | |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | static struct of_device_id fsl_pq_mdio_match[] = { |
| 420 | { |
| 421 | .type = "mdio", |
| 422 | .compatible = "ucc_geth_phy", |
| 423 | }, |
| 424 | { |
| 425 | .type = "mdio", |
| 426 | .compatible = "gianfar", |
| 427 | }, |
| 428 | { |
| 429 | .compatible = "fsl,ucc-mdio", |
| 430 | }, |
| 431 | { |
| 432 | .compatible = "fsl,gianfar-tbi", |
| 433 | }, |
| 434 | { |
| 435 | .compatible = "fsl,gianfar-mdio", |
| 436 | }, |
Sandeep Gopalpet | 1d2397d | 2009-11-02 07:03:22 +0000 | [diff] [blame] | 437 | { |
| 438 | .compatible = "fsl,etsec2-tbi", |
| 439 | }, |
| 440 | { |
| 441 | .compatible = "fsl,etsec2-mdio", |
| 442 | }, |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 443 | {}, |
| 444 | }; |
Anton Vorontsov | e72701a | 2009-10-14 14:54:52 -0700 | [diff] [blame] | 445 | MODULE_DEVICE_TABLE(of, fsl_pq_mdio_match); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 446 | |
| 447 | static struct of_platform_driver fsl_pq_mdio_driver = { |
| 448 | .name = "fsl-pq_mdio", |
| 449 | .probe = fsl_pq_mdio_probe, |
| 450 | .remove = fsl_pq_mdio_remove, |
| 451 | .match_table = fsl_pq_mdio_match, |
| 452 | }; |
| 453 | |
| 454 | int __init fsl_pq_mdio_init(void) |
| 455 | { |
| 456 | return of_register_platform_driver(&fsl_pq_mdio_driver); |
| 457 | } |
Grant Likely | 434e7b0d | 2009-04-25 12:53:44 +0000 | [diff] [blame] | 458 | module_init(fsl_pq_mdio_init); |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 459 | |
| 460 | void fsl_pq_mdio_exit(void) |
| 461 | { |
| 462 | of_unregister_platform_driver(&fsl_pq_mdio_driver); |
| 463 | } |
Andy Fleming | 1577ece | 2009-02-04 16:42:12 -0800 | [diff] [blame] | 464 | module_exit(fsl_pq_mdio_exit); |