Lines Matching +full:mt8195 +full:- +full:efuse
1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/nvmem-consumer.h>
15 #include "phy-mtk-io.h"
36 * struct mtk_pcie_lane_efuse - eFuse data for each lane
40 * @lane_efuse_supported: software eFuse data is supported for this lane
50 * struct mtk_pcie_phy_data - phy data for each SoC
52 * @sw_efuse_supported: support software to load eFuse data
60 * struct mtk_pcie_phy - PCIe phy driver main structure
65 * @sw_efuse_en: software eFuse enable status
67 * @efuse: pointer to eFuse data for each lane
77 struct mtk_pcie_lane_efuse *efuse; member
83 struct mtk_pcie_lane_efuse *data = &pcie_phy->efuse[lane]; in mtk_pcie_efuse_set_lane()
86 if (!data->lane_efuse_supported) in mtk_pcie_efuse_set_lane()
89 addr = pcie_phy->sif_base + PEXTP_ANA_LN0_TRX_REG + in mtk_pcie_efuse_set_lane()
93 data->tx_pmos); in mtk_pcie_efuse_set_lane()
96 data->tx_nmos); in mtk_pcie_efuse_set_lane()
99 data->rx_data); in mtk_pcie_efuse_set_lane()
103 * mtk_pcie_phy_init() - Initialize the phy
106 * Initialize the phy by setting the efuse data.
115 if (!pcie_phy->sw_efuse_en) in mtk_pcie_phy_init()
119 mtk_phy_update_field(pcie_phy->sif_base + PEXTP_ANA_GLB_00_REG, in mtk_pcie_phy_init()
120 EFUSE_GLB_INTR_SEL, pcie_phy->efuse_glb_intr); in mtk_pcie_phy_init()
122 for (i = 0; i < pcie_phy->data->num_lanes; i++) in mtk_pcie_phy_init()
136 struct mtk_pcie_lane_efuse *efuse = &pcie_phy->efuse[lane]; in mtk_pcie_efuse_read_for_lane() local
137 struct device *dev = pcie_phy->dev; in mtk_pcie_efuse_read_for_lane()
142 ret = nvmem_cell_read_variable_le_u32(dev, efuse_id, &efuse->tx_pmos); in mtk_pcie_efuse_read_for_lane()
147 ret = nvmem_cell_read_variable_le_u32(dev, efuse_id, &efuse->tx_nmos); in mtk_pcie_efuse_read_for_lane()
152 ret = nvmem_cell_read_variable_le_u32(dev, efuse_id, &efuse->rx_data); in mtk_pcie_efuse_read_for_lane()
156 if (!(efuse->tx_pmos || efuse->tx_nmos || efuse->rx_data)) in mtk_pcie_efuse_read_for_lane()
157 return dev_err_probe(dev, -EINVAL, in mtk_pcie_efuse_read_for_lane()
158 "No eFuse data found for lane%d, but dts enable it\n", in mtk_pcie_efuse_read_for_lane()
161 efuse->lane_efuse_supported = true; in mtk_pcie_efuse_read_for_lane()
168 struct device *dev = pcie_phy->dev; in mtk_pcie_read_efuse()
173 nvmem_enabled = device_property_present(dev, "nvmem-cells"); in mtk_pcie_read_efuse()
178 &pcie_phy->efuse_glb_intr); in mtk_pcie_read_efuse()
182 pcie_phy->sw_efuse_en = true; in mtk_pcie_read_efuse()
184 pcie_phy->efuse = devm_kzalloc(dev, pcie_phy->data->num_lanes * in mtk_pcie_read_efuse()
185 sizeof(*pcie_phy->efuse), GFP_KERNEL); in mtk_pcie_read_efuse()
186 if (!pcie_phy->efuse) in mtk_pcie_read_efuse()
187 return -ENOMEM; in mtk_pcie_read_efuse()
189 for (i = 0; i < pcie_phy->data->num_lanes; i++) { in mtk_pcie_read_efuse()
200 struct device *dev = &pdev->dev; in mtk_pcie_phy_probe()
207 return -ENOMEM; in mtk_pcie_phy_probe()
209 pcie_phy->sif_base = devm_platform_ioremap_resource_byname(pdev, "sif"); in mtk_pcie_phy_probe()
210 if (IS_ERR(pcie_phy->sif_base)) in mtk_pcie_phy_probe()
211 return dev_err_probe(dev, PTR_ERR(pcie_phy->sif_base), in mtk_pcie_phy_probe()
212 "Failed to map phy-sif base\n"); in mtk_pcie_phy_probe()
214 pcie_phy->phy = devm_phy_create(dev, dev->of_node, &mtk_pcie_phy_ops); in mtk_pcie_phy_probe()
215 if (IS_ERR(pcie_phy->phy)) in mtk_pcie_phy_probe()
216 return dev_err_probe(dev, PTR_ERR(pcie_phy->phy), in mtk_pcie_phy_probe()
219 pcie_phy->dev = dev; in mtk_pcie_phy_probe()
220 pcie_phy->data = of_device_get_match_data(dev); in mtk_pcie_phy_probe()
221 if (!pcie_phy->data) in mtk_pcie_phy_probe()
222 return dev_err_probe(dev, -EINVAL, "Failed to get phy data\n"); in mtk_pcie_phy_probe()
224 if (pcie_phy->data->sw_efuse_supported) { in mtk_pcie_phy_probe()
226 * Failed to read the efuse data is not a fatal problem, in mtk_pcie_phy_probe()
230 if (ret == -EPROBE_DEFER || ret == -ENOMEM) in mtk_pcie_phy_probe()
234 phy_set_drvdata(pcie_phy->phy, pcie_phy); in mtk_pcie_phy_probe()
250 { .compatible = "mediatek,mt8195-pcie-phy", .data = &mt8195_data },
258 .name = "mtk-pcie-phy",