I was wondering whether it is possible to write Linux Drivers for the 3.5mm jack to use it for non-audio purposes. How does the linux kernel identify that a device is inserted into the 3.5mm slot? What are the interfaces in the linux kernel I could use for this purpose?
That jack is a part of your (possibly integrated) sound card, so you would have to write a driver for your sound card that treats it as something other than a sound card.
Not all 3.5mm jacks are capable of detecting that something is plugged in. It requires an extra hardware contact in the jack that is designed to become grounded if a plug is inserted, a pull-up resistor and a connection to a suitable GPIO input pin that can then be used for detection.
ALSA includes a programming interface for such detection, as most 3.5mm jacks tend to be connected to sound cards. If you are using such a jack for some other purpose (e.g. as an alternative serial port connector) and it has a plug detection contact, you might wire it into any suitable GPIO (General-Purpose Input/Output) input pin in your hardware. Then, if the chip the plug detection pin is wired to does not already have a GPIO driver, you might first write a generic GPIO driver for it, and then your design-specific plug detection driver on top of it.