You cannot ally with your own codex. The limits are you need 1 hq, 1 troop, and they have to be (not-red square ones) on the chart. You never get a third army, you double the current detachments when you hit 2k+ points, so your allies can have 2 hq etc...
So if you take CSM as a primary you get:
1 fortification
and can ally with one of these OTHER books (in order of happiness and from memory):
demons
guard
necrons
orks
dark eldar?
when you hit 2,000 or more points (and TO/opponent is cool with it) your charts double so it becomes:
PRIMARY:
1-4 hq (need 2 min if you want more than 6 troops)
2-12 troops (need 4 min if you want more than 2 hq)
0-6 everything else (see above)
ALLY:
1-2 hq
1-4 troop
0-2 else
0-2 FORTIFICATION