blob: d4f1374d19000ea0562d9c4c738e1ea56caffb4b [file] [log] [blame]
David Gibson1d3bb992007-08-23 13:56:01 +10001/*
Paul Gortmaker3396c782012-01-27 13:36:01 +00002 * drivers/net/ethernet/ibm/emac/rgmii.h
David Gibson1d3bb992007-08-23 13:56:01 +10003 *
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
Tony Breeds3b3bceef2011-08-18 21:33:49 -070057#ifdef CONFIG_IBM_EMAC_RGMII
David Gibson1d3bb992007-08-23 13:56:01 +100058
Joe Perchesd4cb2ee2013-09-23 11:37:59 -070059int rgmii_init(void);
60void rgmii_exit(void);
61int rgmii_attach(struct platform_device *ofdev, int input, int mode);
62void rgmii_detach(struct platform_device *ofdev, int input);
63void rgmii_get_mdio(struct platform_device *ofdev, int input);
64void rgmii_put_mdio(struct platform_device *ofdev, int input);
65void rgmii_set_speed(struct platform_device *ofdev, int input, int speed);
66int rgmii_get_regs_len(struct platform_device *ofdev);
67void *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)
Tony Breeds3b3bceef2011-08-18 21:33:49 -070080#endif /* !CONFIG_IBM_EMAC_RGMII */
David Gibson1d3bb992007-08-23 13:56:01 +100081
82#endif /* __IBM_NEWEMAC_RGMII_H */