Preheat oven to 425F. Butter a 9x13 casserole dish or equivalent.
Bring the wine to a boil in a medium saucepan and let it reduce by half, about 2-3 minutes. Take the wine off the heat and add the cream, butter, and smashed garlic cloves. Let garlic steep while you slice all the vegetables.
Once the potatoes, squash, and onions are sliced, cut the rind off the brie and chop it into chunks. Then remove the garlic from the cream mixture and discard it.
Begin layering the gratin, taking handfuls of potato and squash and intermixing them in the bottom of the gratin dish. Continue until you've added about 1/3 in a layer. Then top with half of the onion and brie and 1/3 of the parmesan cheese. Sprinkle on some thyme and rosemary. Pour over 1/3 of the cream mixture. Then make the next layer - 1/3 of the potato and squash, the other half of the onion and brie, 1/3 of the parmesan, and some more thyme and rosemary. Pour over some more cream. Then make the final layer of potato and squash, sprinkle it with parmesan, and then pour in the rest of the cream.
Cover the gratin with aluminum foil and bake for 45 minutes. Then uncover and continue baking for 20-25 minutes, until the top is nicely browned and the vegetables are completely tender when you stick a knife into the gratin.