diff options
author | Tom Rini <trini@konsulko.com> | 2022-04-15 15:09:52 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-04-15 15:10:32 +0300 |
commit | 7f418ea59852945eeb9e5d2555d306f09643d555 (patch) | |
tree | 069dbaf3a1f62b68251189e9acdbd9affcbd98c5 /include | |
parent | 239fe55a6ce516f329687c0680428ca2acfc73ca (diff) | |
parent | 0154e6de37e8bbaac837939391f6d4a8f0b3fd18 (diff) | |
download | u-boot-7f418ea59852945eeb9e5d2555d306f09643d555.tar.xz |
Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-net
- DM9000 DM support
- tftp server bug fix
- mdio ofnode support functions
- Various phy fixes and improvements.
[trini: Fixup merge conflicts in drivers/net/phy/ethernet_id.c
drivers/net/phy/phy.c include/phy.h]
Diffstat (limited to 'include')
-rw-r--r-- | include/_exports.h | 3 | ||||
-rw-r--r-- | include/configs/M5253DEMO.h | 1 | ||||
-rw-r--r-- | include/configs/at91sam9261ek.h | 1 | ||||
-rw-r--r-- | include/configs/ci20.h | 1 | ||||
-rw-r--r-- | include/configs/colibri_pxa270.h | 1 | ||||
-rw-r--r-- | include/configs/devkit8000.h | 1 | ||||
-rw-r--r-- | include/dm/ofnode.h | 27 | ||||
-rw-r--r-- | include/dm/read.h | 36 | ||||
-rw-r--r-- | include/dm9000.h | 16 | ||||
-rw-r--r-- | include/exports.h | 3 | ||||
-rw-r--r-- | include/fm_eth.h | 2 | ||||
-rw-r--r-- | include/miiphy.h | 31 | ||||
-rw-r--r-- | include/phy.h | 40 | ||||
-rw-r--r-- | include/phy_interface.h | 11 | ||||
-rw-r--r-- | include/vsc9953.h | 2 |
15 files changed, 113 insertions, 63 deletions
diff --git a/include/_exports.h b/include/_exports.h index 8030d70c0b..f6df8b6107 100644 --- a/include/_exports.h +++ b/include/_exports.h @@ -77,8 +77,7 @@ EXPORT_FUNC(mdio_get_current_dev, struct mii_dev *, mdio_get_current_dev, void) EXPORT_FUNC(phy_find_by_mask, struct phy_device *, phy_find_by_mask, - struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface) + struct mii_dev *bus, unsigned phy_mask) EXPORT_FUNC(mdio_phydev_for_ethname, struct phy_device *, mdio_phydev_for_ethname, const char *ethname) EXPORT_FUNC(miiphy_set_current_dev, int, miiphy_set_current_dev, diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h index b7fdd7135f..079675be5b 100644 --- a/include/configs/M5253DEMO.h +++ b/include/configs/M5253DEMO.h @@ -25,7 +25,6 @@ # undef CONFIG_LBA48 #endif -#define CONFIG_DRIVER_DM9000 #ifdef CONFIG_DRIVER_DM9000 # define CONFIG_DM9000_BASE (CONFIG_SYS_CS1_BASE | 0x300) # define DM9000_IO CONFIG_DM9000_BASE diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h index 55ddb38c70..2089fe52e4 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -44,7 +44,6 @@ #endif /* Ethernet */ -#define CONFIG_DRIVER_DM9000 #define CONFIG_DM9000_BASE 0x30000000 #define DM9000_IO CONFIG_DM9000_BASE #define DM9000_DATA (CONFIG_DM9000_BASE + 4) diff --git a/include/configs/ci20.h b/include/configs/ci20.h index ea9440dac0..cc70a59e72 100644 --- a/include/configs/ci20.h +++ b/include/configs/ci20.h @@ -24,7 +24,6 @@ #define CONFIG_SYS_NS16550_CLK 48000000 /* Ethernet: davicom DM9000 */ -#define CONFIG_DRIVER_DM9000 1 #define CONFIG_DM9000_BASE 0xb6000000 #define DM9000_IO CONFIG_DM9000_BASE #define DM9000_DATA (CONFIG_DM9000_BASE + 2) diff --git a/include/configs/colibri_pxa270.h b/include/configs/colibri_pxa270.h index a5ba916279..809afb77f2 100644 --- a/include/configs/colibri_pxa270.h +++ b/include/configs/colibri_pxa270.h @@ -43,7 +43,6 @@ */ #ifdef CONFIG_CMD_NET -#define CONFIG_DRIVER_DM9000 1 #define CONFIG_DM9000_BASE 0x08000000 #define DM9000_IO (CONFIG_DM9000_BASE) #define DM9000_DATA (CONFIG_DM9000_BASE + 4) diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h index 16b3650132..5dbd126a2a 100644 --- a/include/configs/devkit8000.h +++ b/include/configs/devkit8000.h @@ -35,7 +35,6 @@ /* Hardware drivers */ /* DM9000 */ -#define CONFIG_DRIVER_DM9000 1 #define CONFIG_DM9000_BASE 0x2c000000 #define DM9000_IO CONFIG_DM9000_BASE #define DM9000_DATA (CONFIG_DM9000_BASE + 0x400) diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 6a996d9521..2c4d72d77f 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -12,6 +12,7 @@ #include <dm/of.h> #include <dm/of_access.h> #include <log.h> +#include <phy_interface.h> /* Enable checks to protect against invalid calls */ #undef OF_CHECKS @@ -1217,4 +1218,30 @@ int ofnode_conf_read_int(const char *prop_name, int default_val); */ const char *ofnode_conf_read_str(const char *prop_name); +/** + * ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link) + * + * This function parses PHY handle from the Ethernet controller's ofnode + * (trying all possible PHY handle property names), and returns the PHY ofnode. + * + * Before this is used, ofnode_phy_is_fixed_link() should be checked first, and + * if the result to that is true, this function should not be called. + * + * @eth_node: ofnode belonging to the Ethernet controller + * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode + */ +ofnode ofnode_get_phy_node(ofnode eth_node); + +/** + * ofnode_read_phy_mode() - Read PHY connection type from a MAC node + * + * This function parses the "phy-mode" / "phy-connection-type" property and + * returns the corresponding PHY interface type. + * + * @mac_node: ofnode containing the property + * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on + * error + */ +phy_interface_t ofnode_read_phy_mode(ofnode mac_node); + #endif diff --git a/include/dm/read.h b/include/dm/read.h index 233af3c063..1b54b69acf 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -743,6 +743,32 @@ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res); int dev_decode_display_timing(const struct udevice *dev, int index, struct display_timing *config); +/** + * dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) + * + * This function parses PHY handle from the Ethernet controller's ofnode + * (trying all possible PHY handle property names), and returns the PHY ofnode. + * + * Before this is used, ofnode_phy_is_fixed_link() should be checked first, and + * if the result to that is true, this function should not be called. + * + * @dev: device representing the MAC + * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode + */ +ofnode dev_get_phy_node(const struct udevice *dev); + +/** + * dev_read_phy_mode() - Read PHY connection type from a MAC + * + * This function parses the "phy-mode" / "phy-connection-type" property and + * returns the corresponding PHY interface type. + * + * @dev: device representing the MAC + * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on + * error + */ +phy_interface_t dev_read_phy_mode(const struct udevice *dev); + #else /* CONFIG_DM_DEV_READ_INLINE is enabled */ #include <asm/global_data.h> @@ -1092,6 +1118,16 @@ static inline int dev_decode_display_timing(const struct udevice *dev, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +static inline ofnode dev_get_phy_node(const struct udevice *dev) +{ + return ofnode_get_phy_node(dev_ofnode(dev)); +} + +static inline phy_interface_t dev_read_phy_mode(const struct udevice *dev) +{ + return ofnode_read_phy_mode(dev_ofnode(dev)); +} + #endif /* CONFIG_DM_DEV_READ_INLINE */ /** diff --git a/include/dm9000.h b/include/dm9000.h deleted file mode 100644 index f780e513f6..0000000000 --- a/include/dm9000.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * NOTE: DAVICOM DM9000 ethernet driver interface - * - * Authors: Remy Bohmer <linux@bohmer.net> - */ -#ifndef __DM9000_H__ -#define __DM9000_H__ - -/****************** function prototypes **********************/ -#if !defined(CONFIG_DM9000_NO_SROM) -void dm9000_write_srom_word(int offset, u16 val); -void dm9000_read_srom_word(int offset, u8 *to); -#endif - -#endif /* __DM9000_H__ */ diff --git a/include/exports.h b/include/exports.h index 550cafdc7a..6f8c9cf451 100644 --- a/include/exports.h +++ b/include/exports.h @@ -55,8 +55,7 @@ int i2c_read (uchar, uint, int , uchar* , int); #endif #ifdef CONFIG_PHY_AQUANTIA struct mii_dev *mdio_get_current_dev(void); -struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface); +struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask); struct phy_device *mdio_phydev_for_ethname(const char *ethname); int miiphy_set_current_dev(const char *devname); #endif diff --git a/include/fm_eth.h b/include/fm_eth.h index 44da014c66..bf9570679d 100644 --- a/include/fm_eth.h +++ b/include/fm_eth.h @@ -72,7 +72,7 @@ enum fm_eth_type { #define FM_ETH_INFO_INITIALIZER(idx, pregs) \ .fm = idx, \ .phy_regs = (void *)pregs, \ - .enet_if = PHY_INTERFACE_MODE_NONE, \ + .enet_if = PHY_INTERFACE_MODE_NA, \ #ifdef CONFIG_SYS_FMAN_V3 #define FM_DTSEC_INFO_INITIALIZER(idx, n) \ diff --git a/include/miiphy.h b/include/miiphy.h index 235ae066dd..110921f20d 100644 --- a/include/miiphy.h +++ b/include/miiphy.h @@ -158,6 +158,37 @@ struct mdio_ops { void dm_mdio_probe_devices(void); /** + * dm_mdio_read - Wrapper over .read() operation for DM MDIO + * + * @mdiodev: mdio device + * @addr: PHY address on MDIO bus + * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22 + * @reg: register address + * Return: register value if non-negative, -error code otherwise + */ +int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg); + +/** + * dm_mdio_write - Wrapper over .write() operation for DM MDIO + * + * @mdiodev: mdio device + * @addr: PHY address on MDIO bus + * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22 + * @reg: register address + * @val: value to write + * Return: 0 on success, -error code otherwise + */ +int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 val); + +/** + * dm_mdio_reset - Wrapper over .reset() operation for DM MDIO + * + * @mdiodev: mdio device + * Return: 0 on success, -error code otherwise + */ +int dm_mdio_reset(struct udevice *mdio_dev); + +/** * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO * * @mdiodev: mdio device the PHY is accesible on diff --git a/include/phy.h b/include/phy.h index 528839a33d..b329595710 100644 --- a/include/phy.h +++ b/include/phy.h @@ -359,18 +359,6 @@ static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad, #ifdef CONFIG_PHYLIB_10G extern struct phy_driver gen10g_driver; - -/* - * List all 10G interfaces here, the assumption being that PHYs on these - * interfaces are C45 - */ -static inline int is_10g_interface(phy_interface_t interface) -{ - return interface == PHY_INTERFACE_MODE_XGMII || - interface == PHY_INTERFACE_MODE_USXGMII || - interface == PHY_INTERFACE_MODE_10GBASER; -} - #endif /** @@ -400,11 +388,9 @@ int phy_reset(struct phy_device *phydev); * * @bus: MII/MDIO bus to scan * @phy_mask: bitmap of PYH addresses to scan - * @interface: type of MAC-PHY interface * @return: pointer to phy_device if a PHY is found, or NULL otherwise */ -struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface); +struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask); #ifdef CONFIG_PHY_FIXED @@ -433,8 +419,10 @@ static inline struct phy_device *fixed_phy_create(ofnode node) * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device * @dev: Ethernet device + * @interface: type of MAC-PHY interface */ -void phy_connect_dev(struct phy_device *phydev, struct udevice *dev); +void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, + phy_interface_t interface); /** * phy_connect() - Creates a PHY device for the Ethernet interface @@ -461,12 +449,10 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, * @addr: PHY address on MDIO bus * @phy_id: where to store the ID retrieved * @is_c45: Device Identifiers if is_c45 - * @interface: interface between the MAC and PHY * @return: pointer to phy_device if a PHY is found, or NULL otherwise */ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, - u32 phy_id, bool is_c45, - phy_interface_t interface); + u32 phy_id, bool is_c45); /** * phy_connect_phy_id() - Connect to phy device by reading PHY id @@ -474,12 +460,11 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, * * @bus: MII/MDIO bus that hosts the PHY * @dev: Ethernet device to associate to the PHY - * @interface: Interface between the MAC and PHY * @return: pointer to phy_device if a PHY is found, * or NULL otherwise */ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, - int phyaddr, phy_interface_t interface); + int phyaddr); static inline ofnode phy_get_ofnode(struct phy_device *phydev) { @@ -494,8 +479,10 @@ static inline ofnode phy_get_ofnode(struct phy_device *phydev) * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device * @dev: Ethernet device + * @interface: type of MAC-PHY interface */ -void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev); +void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev, + phy_interface_t interface); /** * phy_connect() - Creates a PHY device for the Ethernet interface @@ -542,6 +529,7 @@ int gen10g_discover_mmds(struct phy_device *phydev); int phy_b53_init(void); int phy_mv88e61xx_init(void); +int phy_adin_init(void); int phy_aquantia_init(void); int phy_atheros_init(void); int phy_broadcom_init(void); @@ -572,14 +560,6 @@ int board_phy_config(struct phy_device *phydev); int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id); /** - * phy_get_interface_by_name() - Look up a PHY interface name - * - * @str: PHY interface name, e.g. "mii" - * @return: PHY_INTERFACE_MODE_... value, or -1 if not found - */ -int phy_get_interface_by_name(const char *str); - -/** * phy_interface_is_rgmii - Convenience function for testing if a PHY interface * is RGMII (all variants) * @phydev: the phy_device struct diff --git a/include/phy_interface.h b/include/phy_interface.h index f075abe9c9..ce3b5004ec 100644 --- a/include/phy_interface.h +++ b/include/phy_interface.h @@ -13,6 +13,7 @@ #include <string.h> typedef enum { + PHY_INTERFACE_MODE_NA, /* don't touch */ PHY_INTERFACE_MODE_MII, PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_SGMII, @@ -39,12 +40,11 @@ typedef enum { PHY_INTERFACE_MODE_NCSI, PHY_INTERFACE_MODE_10GBASER, PHY_INTERFACE_MODE_USXGMII, - PHY_INTERFACE_MODE_NONE, /* Must be last */ - - PHY_INTERFACE_MODE_COUNT, + PHY_INTERFACE_MODE_MAX, } phy_interface_t; static const char * const phy_interface_strings[] = { + [PHY_INTERFACE_MODE_NA] = "", [PHY_INTERFACE_MODE_MII] = "mii", [PHY_INTERFACE_MODE_GMII] = "gmii", [PHY_INTERFACE_MODE_SGMII] = "sgmii", @@ -71,7 +71,6 @@ static const char * const phy_interface_strings[] = { [PHY_INTERFACE_MODE_NCSI] = "NC-SI", [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r", [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", - [PHY_INTERFACE_MODE_NONE] = "", }; /* Backplane modes: @@ -86,8 +85,8 @@ static const char * const backplane_mode_strings[] = { static inline const char *phy_string_for_interface(phy_interface_t i) { /* Default to unknown */ - if (i > PHY_INTERFACE_MODE_NONE) - i = PHY_INTERFACE_MODE_NONE; + if (i > PHY_INTERFACE_MODE_NA) + i = PHY_INTERFACE_MODE_NA; return phy_interface_strings[i]; } diff --git a/include/vsc9953.h b/include/vsc9953.h index a9c84b4b50..fd52c93044 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -691,7 +691,7 @@ struct vsc9953_vcap { .phyaddr = 0, \ .index = idx, \ .phy_regs = NULL, \ - .enet_if = PHY_INTERFACE_MODE_NONE, \ + .enet_if = PHY_INTERFACE_MODE_NA, \ .bus = NULL, \ .phydev = NULL, \ } |