And if not, what is the difference between being ordered to confess and being ordered to produce evidence harmful to yourself?
Courts should have the right to seek evidence, no one is disputing that, nor is anyone disputing the rights of the court to seek that evidence unmolested, but there is a difference between seeking evidence and mandating compliance.
As far as I am concerned courts should not have any right to compel any action, particularly specific action. They should only have a right to compel inaction. In short, the court can issue warrants that permit their officers to conduct actions that would otherwise be illegal, for example entering my house without my permission, and they may even compel me to stand outside and not interfere while they do so, but they should never be able to compel me to open the door for them.
If they have a warrant and don’t open the door, they will break it down with a sledge hammer.
One has constitutional protection from the fifth amendment and the other doesn't.
Remember, it's up to the prosecutor to build on the evidence they have. If they don't have your phone they don't have much evidence. And it is my belief your passcode is your thoughts.
What if he gave them the codes? They would have noodled around his phone until they found something else. That traffic stop could have become felony possession and that felony possession could have been upgraded to felony distribution if someone had sent him a message to pick up something on the way back.