There are a couple rules that play into this. The main ones that you are looking for, however, are rules 53 - Throwing Equipment and 56 - Interference.
Rule 53 states that no player can throw, shoot, or knock any piece of equipment towards any opponent, or they will be given a minor penalty. The rule specifically states that moving or shooting the equipment off to the side of the ice so that it does not interfere with play is allowed.
If the equipment shooting/throwing occurs in the offending player's defensive zone, a penalty shot is awarded instead of a minor penalty. If the goalie is pulled when this occurs, it results in an awarded goal.
I didn't quote the rule here since it would be too lengthy.
Rule 56 states that you are not allowed to prevent an opposing player from picking up their equipment by knocking it away, in addition to not being allowed to hit equipment towards an opponent who is carrying the puck.
56.2 ...A minor penalty shall be imposed on a player who deliberately knocks a stick out of an opponent's hand, or who prevents a player who has dropped his stick or any other piece of equipment from regaining possession of it.
A minor penalty shall be imposed on a player who knocks or shoots any abandoned or broken stick or illegal pick or other debris towards an opposing puck carrier in a manner that could cause him to be distracted.
Other relevant rules are as follows:
For one, the goalie is not allowed to place an object in such a way to try to prevent goals. This is covered in rule 67.3:
67.3 ...A goalkeeper shall be assessed a minor penalty when he deliberately piles up snow or obstacles at or near his net that, in the opinion of the referee, would tend to prevent the scoring of the goal.
One part of Rule 53 that I didn't detail above is that if you lose your stick, you may only get a replacement from the bench or a teammate by being handed the stick. If the bench or a player tosses the stick to the player, that results in a penalty.
Somewhat related, but a player is not allowed to toss equipment onto the ice from the bench, covered in rule 75.2:
75.2 ...A minor penalty for unsportsmanlike conduct shall be assessed under this rule for the following infractions:
...(iii) Any player who throws any object onto the ice from the players' or penalty bench
This rule also applies to coaches via rule 75.3, for which a bench minor is assessed.
Rule 75.4 also details a bit of what you are asking:
75.4 Misconduct penalties shall be assessed under this rule for the following infractions:
...(ii) Any player who deliberately throws any equipment out of the playing area. At the discretion of the Referee, a game misconduct may be imposed.
That basically covers all you can do with discarded equipment!