Am I likely to struggle in a high-ranked PhD program, if I struggled to get GPA of 3.5 in my master's? I want to be realistic whether I am a material who can complete PhD at top universities such as Stanford, Princeton, Berkeley or Caltech. Grad school courses were hard. I scored 3.5 GPA in my specialization for MS with thesis. My overall GPA was 3.42.

Whether I will get in these universities or not, that is different question. My concern is: If I get into one of these universities, say because of other achievements like research, LOR, SOP etc., it will be harder to maintain this GPA at these universities. Given the fact that U of Michigan has its Electrical Engineering Grad program is ranked 6th in US.

Any suggestions? Reason I want to apply to these universities is because of my area of research. 

Course directly related to my research: I have A-, A.
Closely related to area of research, but in my specialization: I have B+, A-, B+, B.

I do not want to talk lot about my MS thesis, because I want to focus more on rigor of the course and qualifying exam at these universities.
Michigan's EECS department is basically in the same tier as the others you cited.  If you struggled but succeeded at Michigan, you should probably expect a similar experience at any of those other schools.