You wrote:
> The DDR4 will be configured through SPD.
In this case, if DDR interface PCB layout will be implemented exactly as described in the AN5097 - Hardware and Layout Design Considerations for DDR4 SDRAM, then, normally, no additional optimization will be needed.
> Is there an application note explaining the algorithm to use to tune up the DDR4?
There is no such document.