Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[pandora-kernel.git] / drivers / net / ibm_emac / ibm_emac_zmii.h
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
22 #include <linux/config.h>
23 #include <linux/init.h>
24 #include <asm/ocp.h>
25
26 /* ZMII bridge registers */
27 struct zmii_regs {
28         u32 fer;                /* Function enable reg */
29         u32 ssr;                /* Speed select reg */
30         u32 smiirs;             /* SMII status reg */
31 };
32
33 /* ZMII device */
34 struct ibm_ocp_zmii {
35         struct zmii_regs __iomem *base;
36         int mode;               /* subset of PHY_MODE_XXXX */
37         int users;              /* number of EMACs using this ZMII bridge */
38         u32 fer_save;           /* FER value left by firmware */
39 };
40
41 #ifdef CONFIG_IBM_EMAC_ZMII
42 int zmii_attach(void *emac) __init;
43
44 void __zmii_fini(struct ocp_device *ocpdev, int input) __exit;
45 static inline void zmii_fini(struct ocp_device *ocpdev, int input)
46 {
47         if (ocpdev)
48                 __zmii_fini(ocpdev, input);
49 }
50
51 void __zmii_enable_mdio(struct ocp_device *ocpdev, int input);
52 static inline void zmii_enable_mdio(struct ocp_device *ocpdev, int input)
53 {
54         if (ocpdev)
55                 __zmii_enable_mdio(ocpdev, input);
56 }
57
58 void __zmii_set_speed(struct ocp_device *ocpdev, int input, int speed);
59 static 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 }
65
66 int __zmii_get_regs_len(struct ocp_device *ocpdev);
67 static inline int zmii_get_regs_len(struct ocp_device *ocpdev)
68 {
69         return ocpdev ? __zmii_get_regs_len(ocpdev) : 0;
70 }
71
72 void *zmii_dump_regs(struct ocp_device *ocpdev, void *buf);
73
74 #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 */
82
83 #endif                          /* _IBM_EMAC_ZMII_H_ */