The driver is implemented as an ALSA sound driver. There is an input device that is integrated into the ASLA driver to provide a system beep (e.g. ^G). There are also extra attributes for manually controlling tone mode since the input device required root privileges when used from a remote terminal (i.e. ssh).
We use the PWM in 2 different ways to produce sound. In Tone mode, the PWM is set to an audible frequency (< 20kHz). The sound you hear is the square wave produced by the PWM output. In PCM Playback mode, the PWM is set to a ultrasonic frequency (>20kHz). The output is passed through a low-pass filter, so the input to the amplifier is a voltage proportional to the duty cycle of the PWM.