This depends on the way of connection between device and PC. For PCI boards there is set of Linux kernel mode API. Another set of kernel mode API is used to communicate with device connected through USB port. For Ethernet and WiFi connection you can use sockets API, communication is done completely in user mode. Devices, connected through serial port are also handled with user-mode API - they are treated as files in the Linux OS.
Generally, device firmware does not depend on the host system OS. It depends, however, on the OS (if any) running on the device itself. Firmware code may be written in plain C without any OS, or running under real-time OS. Modern devices may contain full-featured OS like embedded Linux or Windows. In this case, the whole OS with the programs specific to this device, are considered device firmware. For example, Android OS for specific mobile device.