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

phy: rockchip-emmc: output tap delay dt property

Update the rockchip-emmc phy to set the otapdlysec register with
a dt property. This was mentioned from Brian Norris when he sent
the path to set the default value in the driver.
This patch add a dt property 'output-tapdelay-select' u32 and allow
to set the 0x0-0xf. If not set in dts, the old default 0x4 applies.

Tested with our customized rk3399 to tune the eMMC.

Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
Link: https://lore.kernel.org/r/20201202082507.3536-2-chris.ruehl@gtsys.com.hk
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Chris Ruehl and committed by
Vinod Koul
a8cef928 31de313d

+12 -1
+12 -1
drivers/phy/rockchip/phy-rockchip-emmc.c
··· 65 65 #define PHYCTRL_OTAPDLYENA 0x1 66 66 #define PHYCTRL_OTAPDLYENA_MASK 0x1 67 67 #define PHYCTRL_OTAPDLYENA_SHIFT 0xb 68 + #define PHYCTRL_OTAPDLYSEL_DEFAULT 0x4 69 + #define PHYCTRL_OTAPDLYSEL_MAXVALUE 0xf 68 70 #define PHYCTRL_OTAPDLYSEL_MASK 0xf 69 71 #define PHYCTRL_OTAPDLYSEL_SHIFT 0x7 70 72 #define PHYCTRL_REN_STRB_DISABLE 0x0 ··· 87 85 struct clk *emmcclk; 88 86 unsigned int drive_impedance; 89 87 unsigned int enable_strobe_pulldown; 88 + unsigned int output_tapdelay_select; 90 89 }; 91 90 92 91 static int rockchip_emmc_phy_power(struct phy *phy, bool on_off) ··· 299 296 /* Output tap delay */ 300 297 regmap_write(rk_phy->reg_base, 301 298 rk_phy->reg_offset + GRF_EMMCPHY_CON0, 302 - HIWORD_UPDATE(4, 299 + HIWORD_UPDATE(rk_phy->output_tapdelay_select, 303 300 PHYCTRL_OTAPDLYSEL_MASK, 304 301 PHYCTRL_OTAPDLYSEL_SHIFT)); 305 302 ··· 375 372 rk_phy->reg_base = grf; 376 373 rk_phy->drive_impedance = PHYCTRL_DR_50OHM; 377 374 rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_DISABLE; 375 + rk_phy->output_tapdelay_select = PHYCTRL_OTAPDLYSEL_DEFAULT; 378 376 379 377 if (!of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val)) 380 378 rk_phy->drive_impedance = convert_drive_impedance_ohm(pdev, val); 381 379 382 380 if (of_property_read_bool(dev->of_node, "enable-strobe-pulldown")) 383 381 rk_phy->enable_strobe_pulldown = PHYCTRL_REN_STRB_ENABLE; 382 + 383 + if (!of_property_read_u32(dev->of_node, "output-tapdelay-select", &val)) { 384 + if (val <= PHYCTRL_OTAPDLYSEL_MAXVALUE) 385 + rk_phy->output_tapdelay_select = val; 386 + else 387 + dev_err(dev, "output-tapdelay-select exceeds limit, apply default\n"); 388 + } 384 389 385 390 generic_phy = devm_phy_create(dev, dev->of_node, &ops); 386 391 if (IS_ERR(generic_phy)) {