Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 2 | /* |
Paul Gortmaker | 3396c78 | 2012-01-27 13:36:01 +0000 | [diff] [blame] | 3 | * drivers/net/ethernet/ibm/emac/zmii.h |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 4 | * |
| 5 | * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. |
| 6 | * |
Benjamin Herrenschmidt | 17cf803 | 2007-12-05 11:14:33 +1100 | [diff] [blame] | 7 | * Copyright 2007 Benjamin Herrenschmidt, IBM Corp. |
| 8 | * <benh@kernel.crashing.org> |
| 9 | * |
| 10 | * Based on the arch/ppc version of the driver: |
| 11 | * |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 12 | * Copyright (c) 2004, 2005 Zultys Technologies. |
| 13 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> |
| 14 | * |
| 15 | * Based on original work by |
| 16 | * Armin Kuster <akuster@mvista.com> |
| 17 | * Copyright 2001 MontaVista Softare Inc. |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 18 | */ |
| 19 | #ifndef __IBM_NEWEMAC_ZMII_H |
| 20 | #define __IBM_NEWEMAC_ZMII_H |
| 21 | |
| 22 | /* ZMII bridge registers */ |
| 23 | struct zmii_regs { |
| 24 | u32 fer; /* Function enable reg */ |
| 25 | u32 ssr; /* Speed select reg */ |
| 26 | u32 smiirs; /* SMII status reg */ |
| 27 | }; |
| 28 | |
| 29 | /* ZMII device */ |
| 30 | struct zmii_instance { |
| 31 | struct zmii_regs __iomem *base; |
| 32 | |
| 33 | /* Only one EMAC whacks us at a time */ |
| 34 | struct mutex lock; |
| 35 | |
| 36 | /* subset of PHY_MODE_XXXX */ |
| 37 | int mode; |
| 38 | |
| 39 | /* number of EMACs using this ZMII bridge */ |
| 40 | int users; |
| 41 | |
| 42 | /* FER value left by firmware */ |
| 43 | u32 fer_save; |
| 44 | |
| 45 | /* OF device instance */ |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 46 | struct platform_device *ofdev; |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 47 | }; |
| 48 | |
Tony Breeds | 3b3bceef | 2011-08-18 21:33:49 -0700 | [diff] [blame] | 49 | #ifdef CONFIG_IBM_EMAC_ZMII |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 50 | |
Joe Perches | d4cb2ee | 2013-09-23 11:37:59 -0700 | [diff] [blame] | 51 | int zmii_init(void); |
| 52 | void zmii_exit(void); |
Andrew Lunn | f921861 | 2019-11-05 18:53:23 +0100 | [diff] [blame] | 53 | int zmii_attach(struct platform_device *ofdev, int input, |
| 54 | phy_interface_t *mode); |
Joe Perches | d4cb2ee | 2013-09-23 11:37:59 -0700 | [diff] [blame] | 55 | void zmii_detach(struct platform_device *ofdev, int input); |
| 56 | void zmii_get_mdio(struct platform_device *ofdev, int input); |
| 57 | void zmii_put_mdio(struct platform_device *ofdev, int input); |
| 58 | void zmii_set_speed(struct platform_device *ofdev, int input, int speed); |
| 59 | int zmii_get_regs_len(struct platform_device *ocpdev); |
| 60 | void *zmii_dump_regs(struct platform_device *ofdev, void *buf); |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 61 | |
| 62 | #else |
| 63 | # define zmii_init() 0 |
| 64 | # define zmii_exit() do { } while(0) |
| 65 | # define zmii_attach(x,y,z) (-ENXIO) |
| 66 | # define zmii_detach(x,y) do { } while(0) |
| 67 | # define zmii_get_mdio(x,y) do { } while(0) |
| 68 | # define zmii_put_mdio(x,y) do { } while(0) |
| 69 | # define zmii_set_speed(x,y,z) do { } while(0) |
| 70 | # define zmii_get_regs_len(x) 0 |
| 71 | # define zmii_dump_regs(x,buf) (buf) |
Tony Breeds | 3b3bceef | 2011-08-18 21:33:49 -0700 | [diff] [blame] | 72 | #endif /* !CONFIG_IBM_EMAC_ZMII */ |
David Gibson | 1d3bb99 | 2007-08-23 13:56:01 +1000 | [diff] [blame] | 73 | |
| 74 | #endif /* __IBM_NEWEMAC_ZMII_H */ |