blob: 0959c55b14591dc7f2d58b1946585eeb0da04d68 [file] [log] [blame]
David Gibson1d3bb992007-08-23 13:56:01 +10001/*
Paul Gortmaker3396c782012-01-27 13:36:01 +00002 * drivers/net/ethernet/ibm/emac/zmii.h
David Gibson1d3bb992007-08-23 13:56:01 +10003 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
5 *
Benjamin Herrenschmidt17cf8032007-12-05 11:14:33 +11006 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
7 * <benh@kernel.crashing.org>
8 *
9 * Based on the arch/ppc version of the driver:
10 *
David Gibson1d3bb992007-08-23 13:56:01 +100011 * Copyright (c) 2004, 2005 Zultys Technologies.
12 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
13 *
14 * Based on original work by
15 * Armin Kuster <akuster@mvista.com>
16 * Copyright 2001 MontaVista Softare Inc.
17 *
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 2 of the License, or (at your
21 * option) any later version.
22 *
23 */
24#ifndef __IBM_NEWEMAC_ZMII_H
25#define __IBM_NEWEMAC_ZMII_H
26
27/* ZMII bridge registers */
28struct zmii_regs {
29 u32 fer; /* Function enable reg */
30 u32 ssr; /* Speed select reg */
31 u32 smiirs; /* SMII status reg */
32};
33
34/* ZMII device */
35struct zmii_instance {
36 struct zmii_regs __iomem *base;
37
38 /* Only one EMAC whacks us at a time */
39 struct mutex lock;
40
41 /* subset of PHY_MODE_XXXX */
42 int mode;
43
44 /* number of EMACs using this ZMII bridge */
45 int users;
46
47 /* FER value left by firmware */
48 u32 fer_save;
49
50 /* OF device instance */
Grant Likely2dc11582010-08-06 09:25:50 -060051 struct platform_device *ofdev;
David Gibson1d3bb992007-08-23 13:56:01 +100052};
53
Tony Breeds3b3bceef2011-08-18 21:33:49 -070054#ifdef CONFIG_IBM_EMAC_ZMII
David Gibson1d3bb992007-08-23 13:56:01 +100055
Joe Perchesd4cb2ee2013-09-23 11:37:59 -070056int zmii_init(void);
57void zmii_exit(void);
58int zmii_attach(struct platform_device *ofdev, int input, int *mode);
59void zmii_detach(struct platform_device *ofdev, int input);
60void zmii_get_mdio(struct platform_device *ofdev, int input);
61void zmii_put_mdio(struct platform_device *ofdev, int input);
62void zmii_set_speed(struct platform_device *ofdev, int input, int speed);
63int zmii_get_regs_len(struct platform_device *ocpdev);
64void *zmii_dump_regs(struct platform_device *ofdev, void *buf);
David Gibson1d3bb992007-08-23 13:56:01 +100065
66#else
67# define zmii_init() 0
68# define zmii_exit() do { } while(0)
69# define zmii_attach(x,y,z) (-ENXIO)
70# define zmii_detach(x,y) do { } while(0)
71# define zmii_get_mdio(x,y) do { } while(0)
72# define zmii_put_mdio(x,y) do { } while(0)
73# define zmii_set_speed(x,y,z) do { } while(0)
74# define zmii_get_regs_len(x) 0
75# define zmii_dump_regs(x,buf) (buf)
Tony Breeds3b3bceef2011-08-18 21:33:49 -070076#endif /* !CONFIG_IBM_EMAC_ZMII */
David Gibson1d3bb992007-08-23 13:56:01 +100077
78#endif /* __IBM_NEWEMAC_ZMII_H */