although i am not a mazda tech, here are some things i have discovered :
Using a non oem air filter, such as a k&n air filter, the kind that you coat with oil, can damage the Air Flow Meter.
A fault in the air flow meter can cause: idle problems, poor performance and poor fuel economy.
This may be the reason you have a code p0170:
Of course you will need to check this component before you replace it.
You can use CRC Electronic Cleaner to clean the meter.
Remove the positive and negative battery cables from your cars battery, Before you disconnect the meter, remove the meter from the engine, gently spray the grid and sensor, allow to air dry for an hour, do not use compressed air to dry.
Here are some reasons for the code p0301: faulty spark plug (s), plug wire (s), coil pack (s), 0xygen sensor (s), fuel injector (s), catalytic converter (s), fuel pump, fuel filter, fuel regulator, low compression, faulty computer, burned exhaust valve (s).
Remember check all of the components and wires and connectors before replacing these components, yes it is time-consuming.
here are some reasons for code 1522, VRIS Variable Resonance Induction Solenoid, basicly this is a system that artificially increases the volumetic capacity of the intake maifold volume and regulates that volume to precisely control the engines ability to create torque at a specified RPM ( revolutions per minute ) range.
Mazda engineers in thier infinite wisdom or lack of, decided to use small displacement engines in otherwise heavier cars, kinda like the less is more mentality, and created the vris system to maximize the power and torque output potential of these small displacement engines and as such there are pros and cons, the pro is when it works, it works very well and the con is when it doesn't, it doesn't, added complexity comes at a price.
Here is how you check the vris: apply 12 volts to the solenoid terminals, the solenoid should open and close with a full stroke, less than a full stroke and the solenoid is faulty.
The vris solenoid is constructed like this, It is a electrical valve that uses a vacumm source to move a linkage that operates a butterfly valve, in this component there are several areas where a fault may exist, remember i said complex ?, the solenoid needs to open and close completely, the likage needs to move with no restrictions, the butterfly valves need to open and close with no restrictions and when the butterfly valve does close it cannot leak vacuum, the vacuum part of the vris must hold vacuum when the solenoid is in both the closed and fully open position and the vacuum line source must be stable and there can be no vacuum losses upstream from the vris solenoid valve..
I hope all this info doesn't give you a headache.