Here is the procedure for the CX-5, same for the CX-9
Switching On Maintenance Mode
1. Switch the ignition ON (engine off). (you have to press the start button TWICE) pressing once only gives you ACC power, (do not press on brake otherwise engine will start, engine must be off)
2. Release the electric parking brake. (to release the parking brake, you have to have your foot on the brake pedal, then press down on EPB switch to release it, you will hear the motor releasing and the light on the EPB switch light goes off)
• (I'll simplify remaining steps here: after step 2, release foot from brake pedal, and move over and press accelerator pedal down fully and press down on the EPB switch at the same time and hold, then press the start button 3 times quickly, you will hear the motor moving and the yellow parking brake with exclamation point light up) you are now in maintenance mode.
Now go do whatever you need to do on the brakes, for the rear brake pistons DO NOT TURN THE PISTONS, compress them straight back like you would do the fronts. After they are compressed back make sure the grooves are lined up in perfect North South orientation per Mazda instructions use Lisle #28600 for minor adjustments only.
Even if you don't plan to do your own brakes, it would be a good idea to let your mechanic know about the maintenance mode. They might not be aware and turn the piston which may damage the EPB motor.
Ending Maintenance Mode
1. Switch the ignition ON (engine off). (you have to press the start button TWICE (do not press on brake otherwise engine will start, engine must be off) pressing once only gives you ACC power
(I'll simplify the remaining steps here: press accelerator pedal down fully and pull up on the EPB switch at the same time and hold, then press the start button 3 times quickly, you will hear the motor moving back and the yellow parking brake with exclamation point goes out)
you can then move your foot and press on the brake pedal and pull up the EPB, you will see the normal red brake light light up and you're done.
Make sure you do this before you take the brake caliper off the pads - I tried after they were off and it ended up extending the caliper piston all the way out. (Maybe user error, but...)
The only way to get it to go back in was to disconnect it from the brake line and disassemble it (shooting compressed air in the fluid port to push the piston out, re-aligning it, and putting it back together). I didn’t trust my “re-built” caliper completely (even though it drove fine), so I bit the bullet and purchased a new one (only available from Mazda for ~$200).