162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * drivers/net/ethernet/ibm/emac/zmii.h
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
862306a36Sopenharmony_ci *                <benh@kernel.crashing.org>
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * Based on the arch/ppc version of the driver:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci * Copyright (c) 2004, 2005 Zultys Technologies.
1362306a36Sopenharmony_ci * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci * Based on original work by
1662306a36Sopenharmony_ci *      Armin Kuster <akuster@mvista.com>
1762306a36Sopenharmony_ci * 	Copyright 2001 MontaVista Softare Inc.
1862306a36Sopenharmony_ci */
1962306a36Sopenharmony_ci#ifndef __IBM_NEWEMAC_ZMII_H
2062306a36Sopenharmony_ci#define __IBM_NEWEMAC_ZMII_H
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/* ZMII bridge registers */
2362306a36Sopenharmony_cistruct zmii_regs {
2462306a36Sopenharmony_ci	u32 fer;		/* Function enable reg */
2562306a36Sopenharmony_ci	u32 ssr;		/* Speed select reg */
2662306a36Sopenharmony_ci	u32 smiirs;		/* SMII status reg */
2762306a36Sopenharmony_ci};
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* ZMII device */
3062306a36Sopenharmony_cistruct zmii_instance {
3162306a36Sopenharmony_ci	struct zmii_regs __iomem	*base;
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci	/* Only one EMAC whacks us at a time */
3462306a36Sopenharmony_ci	struct mutex			lock;
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci	/* subset of PHY_MODE_XXXX */
3762306a36Sopenharmony_ci	int				mode;
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci	/* number of EMACs using this ZMII bridge */
4062306a36Sopenharmony_ci	int				users;
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci	/* FER value left by firmware */
4362306a36Sopenharmony_ci	u32				fer_save;
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci	/* OF device instance */
4662306a36Sopenharmony_ci	struct platform_device		*ofdev;
4762306a36Sopenharmony_ci};
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#ifdef CONFIG_IBM_EMAC_ZMII
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ciint zmii_init(void);
5262306a36Sopenharmony_civoid zmii_exit(void);
5362306a36Sopenharmony_ciint zmii_attach(struct platform_device *ofdev, int input,
5462306a36Sopenharmony_ci		phy_interface_t *mode);
5562306a36Sopenharmony_civoid zmii_detach(struct platform_device *ofdev, int input);
5662306a36Sopenharmony_civoid zmii_get_mdio(struct platform_device *ofdev, int input);
5762306a36Sopenharmony_civoid zmii_put_mdio(struct platform_device *ofdev, int input);
5862306a36Sopenharmony_civoid zmii_set_speed(struct platform_device *ofdev, int input, int speed);
5962306a36Sopenharmony_ciint zmii_get_regs_len(struct platform_device *ocpdev);
6062306a36Sopenharmony_civoid *zmii_dump_regs(struct platform_device *ofdev, void *buf);
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#else
6362306a36Sopenharmony_ci# define zmii_init()		0
6462306a36Sopenharmony_ci# define zmii_exit()		do { } while(0)
6562306a36Sopenharmony_ci# define zmii_attach(x,y,z)	(-ENXIO)
6662306a36Sopenharmony_ci# define zmii_detach(x,y)	do { } while(0)
6762306a36Sopenharmony_ci# define zmii_get_mdio(x,y)	do { } while(0)
6862306a36Sopenharmony_ci# define zmii_put_mdio(x,y)	do { } while(0)
6962306a36Sopenharmony_ci# define zmii_set_speed(x,y,z)	do { } while(0)
7062306a36Sopenharmony_ci# define zmii_get_regs_len(x)	0
7162306a36Sopenharmony_ci# define zmii_dump_regs(x,buf)	(buf)
7262306a36Sopenharmony_ci#endif				/* !CONFIG_IBM_EMAC_ZMII */
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#endif /* __IBM_NEWEMAC_ZMII_H */
75