ibm_emac_zmii.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/config.h>
  22. #include <linux/init.h>
  23. #include <asm/ocp.h>
  24. /* ZMII bridge registers */
  25. struct zmii_regs {
  26. u32 fer; /* Function enable reg */
  27. u32 ssr; /* Speed select reg */
  28. u32 smiirs; /* SMII status reg */
  29. };
  30. /* ZMII device */
  31. struct ibm_ocp_zmii {
  32. struct zmii_regs __iomem *base;
  33. int mode; /* subset of PHY_MODE_XXXX */
  34. int users; /* number of EMACs using this ZMII bridge */
  35. u32 fer_save; /* FER value left by firmware */
  36. };
  37. #ifdef CONFIG_IBM_EMAC_ZMII
  38. int zmii_attach(void *emac) __init;
  39. void __zmii_fini(struct ocp_device *ocpdev, int input) __exit;
  40. static inline void zmii_fini(struct ocp_device *ocpdev, int input)
  41. {
  42. if (ocpdev)
  43. __zmii_fini(ocpdev, input);
  44. }
  45. void __zmii_enable_mdio(struct ocp_device *ocpdev, int input);
  46. static inline void zmii_enable_mdio(struct ocp_device *ocpdev, int input)
  47. {
  48. if (ocpdev)
  49. __zmii_enable_mdio(ocpdev, input);
  50. }
  51. void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed);
  52. static inline void zmii_set_speed(struct ocp_device *ocpdev, int input,
  53. int speed)
  54. {
  55. if (ocpdev)
  56. __zmii_set_speed(ocpdev, input, speed);
  57. }
  58. int __zmii_get_regs_len(struct ocp_device *ocpdev);
  59. static inline int zmii_get_regs_len(struct ocp_device *ocpdev)
  60. {
  61. return ocpdev ? __zmii_get_regs_len(ocpdev) : 0;
  62. }
  63. void *zmii_dump_regs(struct ocp_device *ocpdev, void *buf);
  64. #else
  65. # define zmii_attach(x) 0
  66. # define zmii_fini(x,y) ((void)0)
  67. # define zmii_enable_mdio(x,y) ((void)0)
  68. # define zmii_set_speed(x,y,z) ((void)0)
  69. # define zmii_get_regs_len(x) 0
  70. # define zmii_dump_regs(x,buf) (buf)
  71. #endif /* !CONFIG_IBM_EMAC_ZMII */
  72. #endif /* _IBM_EMAC_ZMII_H_ */