First hard brush his legs
then, I would try sponging (with warm water) his legs.
Then rub heavy duty conditioner into his legs(the kind with a kangaroos is good)
Get a comb or tail brush and see if you can comb through the matting
You may have to cut some hair off because the matting is too bad
Hope this helps!