blob: d69799049865c9ab8c3861208ca201c5bbe14494 [file] [log] [blame]
David Gibson1d3bb992007-08-23 13:56:01 +10001/*
2 * drivers/net/ibm_newemac/rgmii.h
3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII 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 * Based on ocp_zmii.h/ibm_emac_zmii.h
12 * Armin Kuster akuster@mvista.com
13 *
14 * Copyright 2004 MontaVista Software, Inc.
15 * Matt Porter <mporter@kernel.crashing.org>
16 *
17 * Copyright (c) 2004, 2005 Zultys Technologies.
18 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
19 *
20 * This program is free software; you can redistribute it and/or modify it
21 * under the terms of the GNU General Public License as published by the
22 * Free Software Foundation; either version 2 of the License, or (at your
23 * option) any later version.
24 */
25
26#ifndef __IBM_NEWEMAC_RGMII_H
27#define __IBM_NEWEMAC_RGMII_H
28
29/* RGMII bridge type */
30#define RGMII_STANDARD 0
31#define RGMII_AXON 1
32
33/* RGMII bridge */
34struct rgmii_regs {
35 u32 fer; /* Function enable register */
36 u32 ssr; /* Speed select register */
37};
38
39/* RGMII device */
40struct rgmii_instance {
41 struct rgmii_regs __iomem *base;
42
Benjamin Herrenschmidt1f578772007-12-05 11:14:28 +110043 /* RGMII bridge flags */
44 int flags;
45#define EMAC_RGMII_FLAG_HAS_MDIO 0x00000001
David Gibson1d3bb992007-08-23 13:56:01 +100046
47 /* Only one EMAC whacks us at a time */
48 struct mutex lock;
49
50 /* number of EMACs using this RGMII bridge */
51 int users;
52
53 /* OF device instance */
Grant Likely2dc11582010-08-06 09:25:50 -060054 struct platform_device *ofdev;
David Gibson1d3bb992007-08-23 13:56:01 +100055};
56
57#ifdef CONFIG_IBM_NEW_EMAC_RGMII
58
59extern int rgmii_init(void);
60extern void rgmii_exit(void);
Grant Likely2dc11582010-08-06 09:25:50 -060061extern int rgmii_attach(struct platform_device *ofdev, int input, int mode);
62extern void rgmii_detach(struct platform_device *ofdev, int input);
63extern void rgmii_get_mdio(struct platform_device *ofdev, int input);
64extern void rgmii_put_mdio(struct platform_device *ofdev, int input);
65extern void rgmii_set_speed(struct platform_device *ofdev, int input, int speed);
66extern int rgmii_get_regs_len(struct platform_device *ofdev);
67extern void *rgmii_dump_regs(struct platform_device *ofdev, void *buf);
David Gibson1d3bb992007-08-23 13:56:01 +100068
69#else
70
71# define rgmii_init() 0
72# define rgmii_exit() do { } while(0)
73# define rgmii_attach(x,y,z) (-ENXIO)
74# define rgmii_detach(x,y) do { } while(0)
75# define rgmii_get_mdio(o,i) do { } while (0)
76# define rgmii_put_mdio(o,i) do { } while (0)
77# define rgmii_set_speed(x,y,z) do { } while(0)
78# define rgmii_get_regs_len(x) 0
79# define rgmii_dump_regs(x,buf) (buf)
80#endif /* !CONFIG_IBM_NEW_EMAC_RGMII */
81
82#endif /* __IBM_NEWEMAC_RGMII_H */