Madrid was given permission to talk to him, I believe a fee of 20M€ was accepted by Milan, however that was not confirmed by the club.
Regardless, they were still given consent to talk to him, made contact, which he declined.
Kaka' also never denied that he would like to move to Madrid, infact he made a point of saying its the only club he would ever move to from Milan. Silva has repeatedly said he isn't interested in moving to Madrid. Its a totally different scenario.