The words funky "mouldy, old, musty; smelling strong or bad" and funk "a strong smell" were used in the 30s to refer to things that were satisfying or approved of - in other words "swinging, hip". Then in the 50s they came to be applied to a musical genre.
funk "a strong smell" is from funk "to blow smoke upon (a person)", which was probably borrowed in the late 1600s from Old French funkier/fungier "to smoke". This is from Latin fūmigāre "to smoke (of a candle)", from fūmus "smoke" (OED). fūmus is from Proto-Indo-European *dhuh₂-mo-, the zero-grade of *dheuh₂-, a root meaning "to rise in a cloud, as dust, vapour, or smoke", among other meanings (AHD). (Altho the AHD equivocates about the laryngeal, Fortson in Indo-European Language and Culture says it's *h₂.)
According to the AHD, *dhuh₂-mo- became Greek θύμον "thyme", from the sense "plant having a strong smell". This was borrowed into Latin as thymum and English as thyme. However, the OED says θύμον is from θύω "to burn sacrifice" - which could still be from *dheuh₂- maybe.