Musk has alleged in the lawsuit that the companies are violating the terms of his foundational contributions to the charity.