Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: mediatek: svs: Add support for MT8195 SoC

MT8195 svs gpu uses 2-line high bank and low bank to optimize the
voltage of opp table for higher and lower frequency respectively.

Signed-off-by: Mark Tseng <chun-jen.tseng@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

authored by

Mark Tseng and committed by
AngeloGioacchino Del Regno
8ccda5ce b85ea95d

+136
+136
drivers/soc/mediatek/mtk-svs.c
··· 1792 1792 return 0; 1793 1793 } 1794 1794 1795 + static bool svs_mt8195_efuse_parsing(struct svs_platform *svsp) 1796 + { 1797 + struct svs_bank *svsb; 1798 + u32 idx, i, ft_pgm, vmin, golden_temp; 1799 + int ret; 1800 + 1801 + for (i = 0; i < svsp->efuse_max; i++) 1802 + if (svsp->efuse[i]) 1803 + dev_info(svsp->dev, "M_HW_RES%d: 0x%08x\n", 1804 + i, svsp->efuse[i]); 1805 + 1806 + if (!svsp->efuse[10]) { 1807 + dev_notice(svsp->dev, "svs_efuse[10] = 0x0?\n"); 1808 + return false; 1809 + } 1810 + 1811 + /* Svs efuse parsing */ 1812 + ft_pgm = svsp->efuse[0] & GENMASK(7, 0); 1813 + vmin = (svsp->efuse[19] >> 4) & GENMASK(1, 0); 1814 + 1815 + for (idx = 0; idx < svsp->bank_max; idx++) { 1816 + svsb = &svsp->banks[idx]; 1817 + 1818 + if (vmin == 0x1) 1819 + svsb->vmin = 0x1e; 1820 + 1821 + if (ft_pgm == 0) 1822 + svsb->volt_flags |= SVSB_INIT01_VOLT_IGNORE; 1823 + 1824 + if (svsb->type == SVSB_LOW) { 1825 + svsb->mtdes = svsp->efuse[10] & GENMASK(7, 0); 1826 + svsb->bdes = (svsp->efuse[10] >> 16) & GENMASK(7, 0); 1827 + svsb->mdes = (svsp->efuse[10] >> 24) & GENMASK(7, 0); 1828 + svsb->dcbdet = (svsp->efuse[8]) & GENMASK(7, 0); 1829 + svsb->dcmdet = (svsp->efuse[8] >> 8) & GENMASK(7, 0); 1830 + } else if (svsb->type == SVSB_HIGH) { 1831 + svsb->mtdes = svsp->efuse[9] & GENMASK(7, 0); 1832 + svsb->bdes = (svsp->efuse[9] >> 16) & GENMASK(7, 0); 1833 + svsb->mdes = (svsp->efuse[9] >> 24) & GENMASK(7, 0); 1834 + svsb->dcbdet = (svsp->efuse[8]) & GENMASK(7, 0); 1835 + svsb->dcmdet = (svsp->efuse[8] >> 8) & GENMASK(7, 0); 1836 + } 1837 + 1838 + svsb->vmax += svsb->dvt_fixed; 1839 + } 1840 + 1841 + ret = svs_get_efuse_data(svsp, "t-calibration-data", 1842 + &svsp->tefuse, &svsp->tefuse_max); 1843 + if (ret) 1844 + return false; 1845 + 1846 + for (i = 0; i < svsp->tefuse_max; i++) 1847 + if (svsp->tefuse[i] != 0) 1848 + break; 1849 + 1850 + if (i == svsp->tefuse_max) 1851 + golden_temp = 50; /* All thermal efuse data are 0 */ 1852 + else 1853 + golden_temp = (svsp->tefuse[0] >> 24) & GENMASK(7, 0); 1854 + 1855 + for (idx = 0; idx < svsp->bank_max; idx++) { 1856 + svsb = &svsp->banks[idx]; 1857 + svsb->mts = 500; 1858 + svsb->bts = (((500 * golden_temp + 250460) / 1000) - 25) * 4; 1859 + } 1860 + 1861 + return true; 1862 + } 1863 + 1795 1864 static bool svs_mt8192_efuse_parsing(struct svs_platform *svsp) 1796 1865 { 1797 1866 struct svs_bank *svsb; ··· 2291 2222 return 0; 2292 2223 } 2293 2224 2225 + static struct svs_bank svs_mt8195_banks[] = { 2226 + { 2227 + .sw_id = SVSB_GPU, 2228 + .type = SVSB_LOW, 2229 + .set_freq_pct = svs_set_bank_freq_pct_v3, 2230 + .get_volts = svs_get_bank_volts_v3, 2231 + .volt_flags = SVSB_REMOVE_DVTFIXED_VOLT, 2232 + .mode_support = SVSB_MODE_INIT02, 2233 + .opp_count = MAX_OPP_ENTRIES, 2234 + .freq_base = 640000000, 2235 + .turn_freq_base = 640000000, 2236 + .volt_step = 6250, 2237 + .volt_base = 400000, 2238 + .vmax = 0x38, 2239 + .vmin = 0x14, 2240 + .age_config = 0x555555, 2241 + .dc_config = 0x1, 2242 + .dvt_fixed = 0x1, 2243 + .vco = 0x18, 2244 + .chk_shift = 0x87, 2245 + .core_sel = 0x0fff0100, 2246 + .int_st = BIT(0), 2247 + .ctl0 = 0x00540003, 2248 + }, 2249 + { 2250 + .sw_id = SVSB_GPU, 2251 + .type = SVSB_HIGH, 2252 + .set_freq_pct = svs_set_bank_freq_pct_v3, 2253 + .get_volts = svs_get_bank_volts_v3, 2254 + .tzone_name = "gpu1", 2255 + .volt_flags = SVSB_REMOVE_DVTFIXED_VOLT | 2256 + SVSB_MON_VOLT_IGNORE, 2257 + .mode_support = SVSB_MODE_INIT02 | SVSB_MODE_MON, 2258 + .opp_count = MAX_OPP_ENTRIES, 2259 + .freq_base = 880000000, 2260 + .turn_freq_base = 640000000, 2261 + .volt_step = 6250, 2262 + .volt_base = 400000, 2263 + .vmax = 0x38, 2264 + .vmin = 0x14, 2265 + .age_config = 0x555555, 2266 + .dc_config = 0x1, 2267 + .dvt_fixed = 0x6, 2268 + .vco = 0x18, 2269 + .chk_shift = 0x87, 2270 + .core_sel = 0x0fff0101, 2271 + .int_st = BIT(1), 2272 + .ctl0 = 0x00540003, 2273 + .tzone_htemp = 85000, 2274 + .tzone_htemp_voffset = 0, 2275 + .tzone_ltemp = 25000, 2276 + .tzone_ltemp_voffset = 7, 2277 + }, 2278 + }; 2279 + 2294 2280 static struct svs_bank svs_mt8192_banks[] = { 2295 2281 { 2296 2282 .sw_id = SVSB_GPU, ··· 2565 2441 }, 2566 2442 }; 2567 2443 2444 + static const struct svs_platform_data svs_mt8195_platform_data = { 2445 + .name = "mt8195-svs", 2446 + .banks = svs_mt8195_banks, 2447 + .efuse_parsing = svs_mt8195_efuse_parsing, 2448 + .probe = svs_mt8192_platform_probe, 2449 + .regs = svs_regs_v2, 2450 + .bank_max = ARRAY_SIZE(svs_mt8195_banks), 2451 + }; 2452 + 2568 2453 static const struct svs_platform_data svs_mt8192_platform_data = { 2569 2454 .name = "mt8192-svs", 2570 2455 .banks = svs_mt8192_banks, ··· 2603 2470 2604 2471 static const struct of_device_id svs_of_match[] = { 2605 2472 { 2473 + .compatible = "mediatek,mt8195-svs", 2474 + .data = &svs_mt8195_platform_data, 2475 + }, { 2606 2476 .compatible = "mediatek,mt8192-svs", 2607 2477 .data = &svs_mt8192_platform_data, 2608 2478 }, {