blob: fad6d8bf983a2f2130e32a9f562df1d5c453c565 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Eugene Surovegin37448f72005-10-10 16:58:14 -07002 * drivers/net/ibm_emac/ibm_emac_zmii.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07004 * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07006 * Copyright (c) 2004, 2005 Zultys Technologies.
7 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07009 * Based on original work by
10 * Armin Kuster <akuster@mvista.com>
11 * Copyright 2001 MontaVista Softare Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 *
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.
Eugene Surovegin37448f72005-10-10 16:58:14 -070017 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#ifndef _IBM_EMAC_ZMII_H_
20#define _IBM_EMAC_ZMII_H_
21
Eugene Surovegin37448f72005-10-10 16:58:14 -070022#include <linux/init.h>
23#include <asm/ocp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25/* ZMII bridge registers */
26struct zmii_regs {
27 u32 fer; /* Function enable reg */
28 u32 ssr; /* Speed select reg */
29 u32 smiirs; /* SMII status reg */
30};
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032/* ZMII device */
33struct ibm_ocp_zmii {
Al Virob43de2d2005-12-01 10:15:21 -050034 struct zmii_regs __iomem *base;
Eugene Surovegin37448f72005-10-10 16:58:14 -070035 int mode; /* subset of PHY_MODE_XXXX */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 int users; /* number of EMACs using this ZMII bridge */
Eugene Surovegin37448f72005-10-10 16:58:14 -070037 u32 fer_save; /* FER value left by firmware */
Linus Torvalds1da177e2005-04-16 15:20:36 -070038};
39
Eugene Surovegin37448f72005-10-10 16:58:14 -070040#ifdef CONFIG_IBM_EMAC_ZMII
41int zmii_attach(void *emac) __init;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Eugene Surovegin0ec6d952007-05-16 11:57:37 -070043void __zmii_fini(struct ocp_device *ocpdev, int input);
Eugene Surovegin37448f72005-10-10 16:58:14 -070044static inline void zmii_fini(struct ocp_device *ocpdev, int input)
45{
46 if (ocpdev)
47 __zmii_fini(ocpdev, input);
48}
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Eugene Surovegin37448f72005-10-10 16:58:14 -070050void __zmii_enable_mdio(struct ocp_device *ocpdev, int input);
51static inline void zmii_enable_mdio(struct ocp_device *ocpdev, int input)
52{
53 if (ocpdev)
54 __zmii_enable_mdio(ocpdev, input);
55}
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Eugene Surovegin37448f72005-10-10 16:58:14 -070057void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed);
58static inline void zmii_set_speed(struct ocp_device *ocpdev, int input,
59 int speed)
60{
61 if (ocpdev)
62 __zmii_set_speed(ocpdev, input, speed);
63}
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Eugene Surovegin37448f72005-10-10 16:58:14 -070065int __zmii_get_regs_len(struct ocp_device *ocpdev);
66static inline int zmii_get_regs_len(struct ocp_device *ocpdev)
67{
68 return ocpdev ? __zmii_get_regs_len(ocpdev) : 0;
69}
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Eugene Surovegin37448f72005-10-10 16:58:14 -070071void *zmii_dump_regs(struct ocp_device *ocpdev, void *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Eugene Surovegin37448f72005-10-10 16:58:14 -070073#else
74# define zmii_attach(x) 0
75# define zmii_fini(x,y) ((void)0)
76# define zmii_enable_mdio(x,y) ((void)0)
77# define zmii_set_speed(x,y,z) ((void)0)
78# define zmii_get_regs_len(x) 0
79# define zmii_dump_regs(x,buf) (buf)
80#endif /* !CONFIG_IBM_EMAC_ZMII */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82#endif /* _IBM_EMAC_ZMII_H_ */