The definition of the melachah of tochen is to grind up into small pieces any solid substance which grows from the ground, in order to use those small pieces. For example, grinding wheat kernels into flour is the melachah of tochen, as is grinding medicinal herbs into a medicine or colored vegetation in order to make dyes. (In the Mishkan they ground spices in order to make the dyes for the various types and colors of cloth.) It is also forbidden to grind metal down into filings, as well as grinding dried mud or clay. Even sawing wood into tiny pieces so that they can be burnt easily is considered the melachah of tochen.
If someone needs to grind a food such as a chili pepper on Shabbos, he may do so with two shinuim (alterations) in the method of grinding. Normally one would use two utensils in a (forbidden) act of grinding – the grinding tool (pestle) and the container for the food (the mortar). To use both of these utensils would be a Torah prohibition. If one used only one of them and took a different utensil not designed for grinding for the other job then it would be rabbinically prohibited, but with two shinuim Chazal permitted grinding when it is for the sake of making Shabbos food. An example of doing two shinuim is to use the back of a knife to grind on the underside of a bowl. Even though one is not normally permitted to do two shinuim in order to achieve a melachah on Shabbos, in this instance Chazal allowed it because it does not look like a melachah – it looks like food preparation.
There is no prohibition on grinding things which have already been ground up and were then artificially reconstituted into solid objects. Therefore, one may crumble bread, matzah, cookies, chocolate and sugar that has clumped together. Similarly, someone who is ill and is allowed to take medicine on Shabbos may crush the pill in order to make it easier to swallow, since originally all of the ingredients were ground up and then combined to make the pill. Some opinions hold that even in such cases where two shinuim are acceptable, one may only grind such items if they will be eaten shortly after, and it is proper to follow these opinions. One should note that even in such cases when it is permissible to grind, one may not use a utensil specifically designed for grinding, such as a grater.
One may not grind mud or clay that has dried, since it became solid in a natural way. Therefore, if someone got mud or clay stuck to his shoe and it dried up, he may not remove it if it will certainly be crumbled into little pieces. However, if it is uncertain if removing the mud or clay will cause them to crumble then he may remove them.
Notes and Sources
 Gemara Shabbos 74b
 Shulchan Aruch 321:7
 Rema 321:12
 Shemiras Shabbos 33:4
 Chayei Adam 17:4
 Shulchan Aruch 321:10, Mishnah Berurah 36
 Some are lenient about this. The Chid’a rules in line with the lenient opinions, and Yalkut Yosef 302:17 and 321:22 concurs.