// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2022 MediaTek Inc. * Author: Jianjun Wang <[email protected]> */ #include <linux/bitfield.h> #include <linux/module.h> #include <linux/nvmem-consumer.h> #include <linux/of.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> #include <linux/slab.h> #include "phy-mtk-io.h" #define PEXTP_ANA_GLB_00_REG … /* Internal Resistor Selection of TX Bias Current */ #define EFUSE_GLB_INTR_SEL … #define PEXTP_ANA_LN0_TRX_REG … #define PEXTP_ANA_TX_REG … /* TX PMOS impedance selection */ #define EFUSE_LN_TX_PMOS_SEL … /* TX NMOS impedance selection */ #define EFUSE_LN_TX_NMOS_SEL … #define PEXTP_ANA_RX_REG … /* RX impedance selection */ #define EFUSE_LN_RX_SEL … #define PEXTP_ANA_LANE_OFFSET … /** * struct mtk_pcie_lane_efuse - eFuse data for each lane * @tx_pmos: TX PMOS impedance selection data * @tx_nmos: TX NMOS impedance selection data * @rx_data: RX impedance selection data * @lane_efuse_supported: software eFuse data is supported for this lane */ struct mtk_pcie_lane_efuse { … }; /** * struct mtk_pcie_phy_data - phy data for each SoC * @num_lanes: supported lane numbers * @sw_efuse_supported: support software to load eFuse data */ struct mtk_pcie_phy_data { … }; /** * struct mtk_pcie_phy - PCIe phy driver main structure * @dev: pointer to device * @phy: pointer to generic phy * @sif_base: IO mapped register base address of system interface * @data: pointer to SoC dependent data * @sw_efuse_en: software eFuse enable status * @efuse_glb_intr: internal resistor selection of TX bias current data * @efuse: pointer to eFuse data for each lane */ struct mtk_pcie_phy { … }; static void mtk_pcie_efuse_set_lane(struct mtk_pcie_phy *pcie_phy, unsigned int lane) { … } /** * mtk_pcie_phy_init() - Initialize the phy * @phy: the phy to be initialized * * Initialize the phy by setting the efuse data. * The hardware settings will be reset during suspend, it should be * reinitialized when the consumer calls phy_init() again on resume. */ static int mtk_pcie_phy_init(struct phy *phy) { … } static const struct phy_ops mtk_pcie_phy_ops = …; static int mtk_pcie_efuse_read_for_lane(struct mtk_pcie_phy *pcie_phy, unsigned int lane) { … } static int mtk_pcie_read_efuse(struct mtk_pcie_phy *pcie_phy) { … } static int mtk_pcie_phy_probe(struct platform_device *pdev) { … } static const struct mtk_pcie_phy_data mt8195_data = …; static const struct of_device_id mtk_pcie_phy_of_match[] = …; MODULE_DEVICE_TABLE(of, mtk_pcie_phy_of_match); static struct platform_driver mtk_pcie_phy_driver = …; module_platform_driver(…) …; MODULE_DESCRIPTION(…) …; MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;