You need to get to Mardino's cave. It's on the cliff right above Frederick, inside a hatch hidden in the bushes. Probably need some decent Perception for it.
Once inside, there's a series of simple puzzles and key-getting, then you can make your way into Mardino's secret room, where you'll find a book that tells how to free the Troll King.