mii-fixed.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/config.h>
  15. #include <linux/module.h>
  16. #include <linux/types.h>
  17. #include <linux/kernel.h>
  18. #include <linux/sched.h>
  19. #include <linux/string.h>
  20. #include <linux/ptrace.h>
  21. #include <linux/errno.h>
  22. #include <linux/ioport.h>
  23. #include <linux/slab.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/pci.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/etherdevice.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/mii.h>
  33. #include <linux/ethtool.h>
  34. #include <linux/bitops.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/irq.h>
  37. #include <asm/uaccess.h>
  38. #include "fs_enet.h"
  39. static const u16 mii_regs[7] = {
  40. 0x3100,
  41. 0x786d,
  42. 0x0fff,
  43. 0x0fff,
  44. 0x01e1,
  45. 0x45e1,
  46. 0x0003,
  47. };
  48. static int mii_read(struct fs_enet_mii_bus *bus, int phy_id, int location)
  49. {
  50. int ret = 0;
  51. if ((unsigned int)location >= ARRAY_SIZE(mii_regs))
  52. return -1;
  53. if (location != 5)
  54. ret = mii_regs[location];
  55. else
  56. ret = bus->fixed.lpa;
  57. return ret;
  58. }
  59. static void mii_write(struct fs_enet_mii_bus *bus, int phy_id, int location, int val)
  60. {
  61. /* do nothing */
  62. }
  63. int fs_mii_fixed_init(struct fs_enet_mii_bus *bus)
  64. {
  65. const struct fs_mii_bus_info *bi = bus->bus_info;
  66. bus->fixed.lpa = 0x45e1; /* default 100Mb, full duplex */
  67. /* if speed is fixed at 10Mb, remove 100Mb modes */
  68. if (bi->i.fixed.speed == 10)
  69. bus->fixed.lpa &= ~LPA_100;
  70. /* if duplex is half, remove full duplex modes */
  71. if (bi->i.fixed.duplex == 0)
  72. bus->fixed.lpa &= ~LPA_DUPLEX;
  73. bus->mii_read = mii_read;
  74. bus->mii_write = mii_write;
  75. return 0;
  76. }