mii-fixed.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Combined Ethernet driver for Motorola MPC8xx and MPC82xx.
  3. *
  4. * Copyright (c) 2003 Intracom S.A.
  5. * by Pantelis Antoniou <panto@intracom.gr>
  6. *
  7. * 2005 (c) MontaVista Software, Inc.
  8. * Vitaly Bordug <vbordug@ru.mvista.com>
  9. *
  10. * This file is licensed under the terms of the GNU General Public License
  11. * version 2. This program is licensed "as is" without any warranty of any
  12. * kind, whether express or implied.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/kernel.h>
  17. #include <linux/sched.h>
  18. #include <linux/string.h>
  19. #include <linux/ptrace.h>
  20. #include <linux/errno.h>
  21. #include <linux/ioport.h>
  22. #include <linux/slab.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/pci.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/mii.h>
  32. #include <linux/ethtool.h>
  33. #include <linux/bitops.h>
  34. #include <asm/pgtable.h>
  35. #include <asm/irq.h>
  36. #include <asm/uaccess.h>
  37. #include "fs_enet.h"
  38. static const u16 mii_regs[7] = {
  39. 0x3100,
  40. 0x786d,
  41. 0x0fff,
  42. 0x0fff,
  43. 0x01e1,
  44. 0x45e1,
  45. 0x0003,
  46. };
  47. static int mii_read(struct fs_enet_mii_bus *bus, int phy_id, int location)
  48. {
  49. int ret = 0;
  50. if ((unsigned int)location >= ARRAY_SIZE(mii_regs))
  51. return -1;
  52. if (location != 5)
  53. ret = mii_regs[location];
  54. else
  55. ret = bus->fixed.lpa;
  56. return ret;
  57. }
  58. static void mii_write(struct fs_enet_mii_bus *bus, int phy_id, int location, int val)
  59. {
  60. /* do nothing */
  61. }
  62. int fs_mii_fixed_init(struct fs_enet_mii_bus *bus)
  63. {
  64. const struct fs_mii_bus_info *bi = bus->bus_info;
  65. bus->fixed.lpa = 0x45e1; /* default 100Mb, full duplex */
  66. /* if speed is fixed at 10Mb, remove 100Mb modes */
  67. if (bi->i.fixed.speed == 10)
  68. bus->fixed.lpa &= ~LPA_100;
  69. /* if duplex is half, remove full duplex modes */
  70. if (bi->i.fixed.duplex == 0)
  71. bus->fixed.lpa &= ~LPA_DUPLEX;
  72. bus->mii_read = mii_read;
  73. bus->mii_write = mii_write;
  74. return 0;
  75. }