Partial write protection for SD cards
SD cards have co-operative hardware write protection, which is a switch on the side of the card sensed by the OS driver.

The SD cards also support:


Permanent write protection, PERM_WRITE_PROTECT
Temporary write protection, TMP_WRITE_PROTECT first
Write protect group size, WP_GRP_SIZE (set aside strings of sectors/blocks that are write protected)


All of these settings are in the CSD register which is read by the OS driver using CMD's when your media is first mounted.

You can read all about the registers here. The specification applies to all media up to, but not including UHS cards.

The driver supports a serial CMD structure for the SD cards, and the password protection is included here. You have to read the physical layer specification to understand how to read and write to the card.