platform_drv: add HDAUDIO PCI quirks

Ref genodelabs/genode#4578
This commit is contained in:
Stefan Kalkowski 2022-09-09 11:46:27 +02:00 committed by Christian Helmuth
parent b85b3abe20
commit c583446ade
3 changed files with 65 additions and 10 deletions

View File

@ -44,16 +44,17 @@ struct Pci::Config : Genode::Mmio
struct Command : Register<0x4, 16>
{
struct Io_space_enable : Bitfield<0, 1> {};
struct Memory_space_enable : Bitfield<1, 1> {};
struct Bus_master_enable : Bitfield<2, 1> {};
struct Special_cycle_enable : Bitfield<3, 1> {};
struct Memory_write_invalidate : Bitfield<4, 1> {};
struct Vga_palette_snoop : Bitfield<5, 1> {};
struct Parity_error_response : Bitfield<6, 1> {};
struct Idsel : Bitfield<7, 1> {};
struct Serror_enable : Bitfield<8, 1> {};
struct Interrupt_enable : Bitfield<10, 1> {};
struct Io_space_enable : Bitfield<0, 1> {};
struct Memory_space_enable : Bitfield<1, 1> {};
struct Bus_master_enable : Bitfield<2, 1> {};
struct Special_cycle_enable : Bitfield<3, 1> {};
struct Memory_write_invalidate : Bitfield<4, 1> {};
struct Vga_palette_snoop : Bitfield<5, 1> {};
struct Parity_error_response : Bitfield<6, 1> {};
struct Idsel : Bitfield<7, 1> {};
struct Serror_enable : Bitfield<8, 1> {};
struct Fast_back_to_back_enable : Bitfield<9, 1> {};
struct Interrupt_enable : Bitfield<10, 1> {};
};
struct Status : Register<0x6, 16>

View File

@ -20,6 +20,7 @@
#include <pci.h>
#include <pci_uhci.h>
#include <pci_intel_graphics.h>
#include <pci_hd_audio.h>
using namespace Genode;
using namespace Pci;
@ -62,6 +63,7 @@ struct Config_helper
/* apply different PCI quirks, bios handover etc. */
Driver::pci_uhci_quirks(_cfg, _config.base());
Driver::pci_hd_audio_quirks(_cfg, _config);
}
void disable()

View File

@ -0,0 +1,52 @@
/*
* \brief Platform driver - PCI HD AUDIO utilities
* \author Stefan Kalkowski
* \date 2022-09-09
*/
/*
* Copyright (C) 2022 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#include <pci/config.h>
#include <device.h>
namespace Driver {
static void pci_hd_audio_quirks(Device::Pci_config cfg,
Pci::Config & config);
}
void Driver::pci_hd_audio_quirks(Device::Pci_config cfg,
Pci::Config & config)
{
enum { HDAUDIO_CLASS_CODE = 0x40300 };
if ((cfg.class_code & 0xffff00) != HDAUDIO_CLASS_CODE)
return;
/* PCI configuration register for HDAUDIO */
struct Hdaudio : Mmio
{
struct Traffic_class_select : Register<0x44, 8> {};
struct Intel_device_control : Register<0x78, 16>
{
struct No_snoop : Bitfield<11,1> {};
};
using Mmio::Mmio;
};
config.write<Pci::Config::Command::Fast_back_to_back_enable>(1);
Hdaudio audio(config.base());
audio.write<Hdaudio::Traffic_class_select>(0);
if (cfg.vendor_id == 0x8086)
audio.write<Hdaudio::Intel_device_control::No_snoop>(0);
}