Hello and welcome to JustAnswer!
Does the speedometer work? Do the boxes on the shifter display show the correct gear position?
Your trans is fully electrically controlled by a module. When the transmission controller sees a problem it thinks can cause potential damage to the trans it will shut off the relay that powers the shift solenoids, and it locks you in second gear. This is called limp-in.
When the trans goes into limp-in it will set fault codes in the TCM. The first thing you need to do for this is have the codes read that are stored in the TCM. They will point in the right direction for diagnosis. The codes will need to be read through the data link connector under the dash using a capable scan tool, this can be done for free at most large parts stores.
There are many possible causes for limp-in. The most common and cheapest cause would be either the input or output speed sensors that are screwed into the front of the trans. These run about $20, are easy to change, and will be in stock at any parts store or dealer. If the speedometer always works ok when the trans won't shift you can rule out the output speed sensor, it's signal is also used for the speedometer.
The next most common cause would be a failed solenoid or clutch pressure switch. These are all inside the solenoid pack mounted to the front of the trans. If any of the solenoids or pressure switches are bad it requires solenoid pack replacement.
Other possible causes include internal trans problems, wiring from the trans to the TCM, or even the TCM itself. The stored fault codes will tell you where to start