Implement software (mode page) and hardware (config) write protection.

(cherry picked from commit c561a7a0862e17e6c7c2cd76ed43f98dc7893d33)