blob: 92c8544107537d34d59ad595272463d87e0ba10f [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
22#include <linux/config.h>
Eugene Surovegin37448f72005-10-10 16:58:14 -070023#include <linux/init.h>
24#include <asm/ocp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26/* ZMII bridge registers */
27struct zmii_regs {
28 u32 fer; /* Function enable reg */
29 u32 ssr; /* Speed select reg */
30 u32 smiirs; /* SMII status reg */
31};
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033/* ZMII device */
34struct ibm_ocp_zmii {
Al Virob43de2d2005-12-01 10:15:21 -050035 struct zmii_regs __iomem *base;
Eugene Surovegin37448f72005-10-10 16:58:14 -070036 int mode; /* subset of PHY_MODE_XXXX */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 int users; /* number of EMACs using this ZMII bridge */
Eugene Surovegin37448f72005-10-10 16:58:14 -070038 u32 fer_save; /* FER value left by firmware */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039};
40
Eugene Surovegin37448f72005-10-10 16:58:14 -070041#ifdef CONFIG_IBM_EMAC_ZMII
42int zmii_attach(void *emac) __init;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Eugene Surovegin37448f72005-10-10 16:58:14 -070044void __zmii_fini(struct ocp_device *ocpdev, int input) __exit;
45static inline void zmii_fini(struct ocp_device *ocpdev, int input)
46{
47 if (ocpdev)
48 __zmii_fini(ocpdev, input);
49}
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Eugene Surovegin37448f72005-10-10 16:58:14 -070051void __zmii_enable_mdio(struct ocp_device *ocpdev, int input);
52static inline void zmii_enable_mdio(struct ocp_device *ocpdev, int input)
53{
54 if (ocpdev)
55 __zmii_enable_mdio(ocpdev, input);
56}
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Eugene Surovegin37448f72005-10-10 16:58:14 -070058void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed);
59static inline void zmii_set_speed(struct ocp_device *ocpdev, int input,
60 int speed)
61{
62 if (ocpdev)
63 __zmii_set_speed(ocpdev, input, speed);
64}
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Eugene Surovegin37448f72005-10-10 16:58:14 -070066int __zmii_get_regs_len(struct ocp_device *ocpdev);
67static inline int zmii_get_regs_len(struct ocp_device *ocpdev)
68{
69 return ocpdev ? __zmii_get_regs_len(ocpdev) : 0;
70}
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Eugene Surovegin37448f72005-10-10 16:58:14 -070072void *zmii_dump_regs(struct ocp_device *ocpdev, void *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Eugene Surovegin37448f72005-10-10 16:58:14 -070074#else
75# define zmii_attach(x) 0
76# define zmii_fini(x,y) ((void)0)
77# define zmii_enable_mdio(x,y) ((void)0)
78# define zmii_set_speed(x,y,z) ((void)0)
79# define zmii_get_regs_len(x) 0
80# define zmii_dump_regs(x,buf) (buf)
81#endif /* !CONFIG_IBM_EMAC_ZMII */
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83#endif /* _IBM_EMAC_ZMII_H_ */