ibm_emac_zmii.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * drivers/net/ibm_emac/ibm_emac_zmii.h
  3. *
  4. * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
  5. *
  6. * Copyright (c) 2004, 2005 Zultys Technologies.
  7. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  8. *
  9. * Based on original work by
  10. * Armin Kuster <akuster@mvista.com>
  11. * Copyright 2001 MontaVista Softare Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. */
  19. #ifndef _IBM_EMAC_ZMII_H_
  20. #define _IBM_EMAC_ZMII_H_
  21. #include <linux/init.h>
  22. #include <asm/ocp.h>
  23. /* ZMII bridge registers */
  24. struct zmii_regs {
  25. u32 fer; /* Function enable reg */
  26. u32 ssr; /* Speed select reg */
  27. u32 smiirs; /* SMII status reg */
  28. };
  29. /* ZMII device */
  30. struct ibm_ocp_zmii {
  31. struct zmii_regs __iomem *base;
  32. int mode; /* subset of PHY_MODE_XXXX */
  33. int users; /* number of EMACs using this ZMII bridge */
  34. u32 fer_save; /* FER value left by firmware */
  35. };
  36. #ifdef CONFIG_IBM_EMAC_ZMII
  37. int zmii_attach(void *emac) __init;
  38. void __zmii_fini(struct ocp_device *ocpdev, int input) __exit;
  39. static inline void zmii_fini(struct ocp_device *ocpdev, int input)
  40. {
  41. if (ocpdev)
  42. __zmii_fini(ocpdev, input);
  43. }
  44. void __zmii_enable_mdio(struct ocp_device *ocpdev, int input);
  45. static inline void zmii_enable_mdio(struct ocp_device *ocpdev, int input)
  46. {
  47. if (ocpdev)
  48. __zmii_enable_mdio(ocpdev, input);
  49. }
  50. void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed);
  51. static inline void zmii_set_speed(struct ocp_device *ocpdev, int input,
  52. int speed)
  53. {
  54. if (ocpdev)
  55. __zmii_set_speed(ocpdev, input, speed);
  56. }
  57. int __zmii_get_regs_len(struct ocp_device *ocpdev);
  58. static inline int zmii_get_regs_len(struct ocp_device *ocpdev)
  59. {
  60. return ocpdev ? __zmii_get_regs_len(ocpdev) : 0;
  61. }
  62. void *zmii_dump_regs(struct ocp_device *ocpdev, void *buf);
  63. #else
  64. # define zmii_attach(x) 0
  65. # define zmii_fini(x,y) ((void)0)
  66. # define zmii_enable_mdio(x,y) ((void)0)
  67. # define zmii_set_speed(x,y,z) ((void)0)
  68. # define zmii_get_regs_len(x) 0
  69. # define zmii_dump_regs(x,buf) (buf)
  70. #endif /* !CONFIG_IBM_EMAC_ZMII */
  71. #endif /* _IBM_EMAC_ZMII_H_ */