In Raleigh: any Cup a Joe (so long as you're good with a gritty student vibe)
In Durham: Joe van Gogh and Market Street are always pretty quiet. Cocoa Cinnamon and Francesca's are livelier.
In Carrboro: Open Eye Cafe.
AFAIK the only place with free coffee refills and wifi is Mad Hatter's in Durham, but I'd love to hear I'm wrong.