18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * drivers/net/ethernet/ibm/emac/rgmii.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
88c2ecf20Sopenharmony_ci *                <benh@kernel.crashing.org>
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Based on the arch/ppc version of the driver:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Based on ocp_zmii.h/ibm_emac_zmii.h
138c2ecf20Sopenharmony_ci * Armin Kuster akuster@mvista.com
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * Copyright 2004 MontaVista Software, Inc.
168c2ecf20Sopenharmony_ci * Matt Porter <mporter@kernel.crashing.org>
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * Copyright (c) 2004, 2005 Zultys Technologies.
198c2ecf20Sopenharmony_ci * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#ifndef __IBM_NEWEMAC_RGMII_H
238c2ecf20Sopenharmony_ci#define __IBM_NEWEMAC_RGMII_H
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* RGMII bridge type */
268c2ecf20Sopenharmony_ci#define RGMII_STANDARD		0
278c2ecf20Sopenharmony_ci#define RGMII_AXON		1
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* RGMII bridge */
308c2ecf20Sopenharmony_cistruct rgmii_regs {
318c2ecf20Sopenharmony_ci	u32 fer;		/* Function enable register */
328c2ecf20Sopenharmony_ci	u32 ssr;		/* Speed select register */
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* RGMII device */
368c2ecf20Sopenharmony_cistruct rgmii_instance {
378c2ecf20Sopenharmony_ci	struct rgmii_regs __iomem	*base;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	/* RGMII bridge flags */
408c2ecf20Sopenharmony_ci	int				flags;
418c2ecf20Sopenharmony_ci#define EMAC_RGMII_FLAG_HAS_MDIO	0x00000001
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	/* Only one EMAC whacks us at a time */
448c2ecf20Sopenharmony_ci	struct mutex			lock;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	/* number of EMACs using this RGMII bridge */
478c2ecf20Sopenharmony_ci	int				users;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	/* OF device instance */
508c2ecf20Sopenharmony_ci	struct platform_device		*ofdev;
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#ifdef CONFIG_IBM_EMAC_RGMII
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciint rgmii_init(void);
568c2ecf20Sopenharmony_civoid rgmii_exit(void);
578c2ecf20Sopenharmony_ciint rgmii_attach(struct platform_device *ofdev, int input, int mode);
588c2ecf20Sopenharmony_civoid rgmii_detach(struct platform_device *ofdev, int input);
598c2ecf20Sopenharmony_civoid rgmii_get_mdio(struct platform_device *ofdev, int input);
608c2ecf20Sopenharmony_civoid rgmii_put_mdio(struct platform_device *ofdev, int input);
618c2ecf20Sopenharmony_civoid rgmii_set_speed(struct platform_device *ofdev, int input, int speed);
628c2ecf20Sopenharmony_ciint rgmii_get_regs_len(struct platform_device *ofdev);
638c2ecf20Sopenharmony_civoid *rgmii_dump_regs(struct platform_device *ofdev, void *buf);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#else
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci# define rgmii_init()		0
688c2ecf20Sopenharmony_ci# define rgmii_exit()		do { } while(0)
698c2ecf20Sopenharmony_ci# define rgmii_attach(x,y,z)	(-ENXIO)
708c2ecf20Sopenharmony_ci# define rgmii_detach(x,y)	do { } while(0)
718c2ecf20Sopenharmony_ci# define rgmii_get_mdio(o,i)	do { } while (0)
728c2ecf20Sopenharmony_ci# define rgmii_put_mdio(o,i)	do { } while (0)
738c2ecf20Sopenharmony_ci# define rgmii_set_speed(x,y,z)	do { } while(0)
748c2ecf20Sopenharmony_ci# define rgmii_get_regs_len(x)	0
758c2ecf20Sopenharmony_ci# define rgmii_dump_regs(x,buf)	(buf)
768c2ecf20Sopenharmony_ci#endif				/* !CONFIG_IBM_EMAC_RGMII */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#endif /* __IBM_NEWEMAC_RGMII_H */
79