Jeff Gordon wins at Martinsville, punches ticket to championship battle at Homestead