Unverified Commit 55688b05 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1873 [openEuler-1.0-LTS] Add Phytium hda driver support

Merge Pull Request from: @tian_wei0822 
 
HDA driver support for Phytium desktop, such as D2000. 
 
Link:https://gitee.com/openeuler/kernel/pulls/1873

 

Reviewed-by: default avatarMao HongBo <maohongbo@phytium.com.cn>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents 9c9924e4 f828b65a
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
* Phytium HDA controller

The HDA bus (High Definition Audio sound bus) is a serial link for digital
audio data transfer between devices in the system.

Required properties:

- compatible: should be "phytium,hda"
- reg: physical base address and length of HDA controller.
- interrupts: interrupt for the hda controller.
- clocks: phandle to clock provider with the clock number in the second cell.
- clock-name: the name of the device clock.

Example for D2000 HDA controller:

hda: hda@28206000 {
	compatible = "phytium,hda";
	reg = <0 0x28206000 0x0 0x1000>;
	interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&sysclk_48mhz>;
	clock-names = "phytium_hda_clk";
};
+1 −0
Original line number Diff line number Diff line
@@ -354,6 +354,7 @@ struct hdac_bus {
	bool align_bdle_4k:1;		/* BDLE align 4K boundary */
	bool reverse_assign:1;		/* assign devices in reverse order */
	bool corbrp_self_clear:1;	/* CORBRP clears itself after reset */
	bool cmd_resend;		/* command resend */

	int bdl_pos_adj;		/* BDL position adjustment */

+37 −0
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val)
{
	unsigned int addr = azx_command_addr(val);
	unsigned int wp, rp;
	unsigned long timeout;
	unsigned int rirb_wp;
	int i = 0;

	spin_lock_irq(&bus->reg_lock);

@@ -165,6 +168,40 @@ int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val)
	bus->corb.buf[wp] = cpu_to_le32(val);
	snd_hdac_chip_writew(bus, CORBWP, wp);

	if (bus->cmd_resend) {
		timeout = jiffies + msecs_to_jiffies(1000);
		udelay(80);
		rirb_wp = snd_hdac_chip_readw(bus, RIRBWP);
		while (rirb_wp == bus->rirb.wp) {
			udelay(80);
			rirb_wp = snd_hdac_chip_readw(bus, RIRBWP);
			if (rirb_wp != bus->rirb.wp)
				break;
			if (i > 5)
				break;
			if (time_after(jiffies, timeout))
				break;

			/* add command to corb */
			wp = snd_hdac_chip_readw(bus, CORBWP);
			if (wp == 0xffff) {
			/* something wrong, controller likely turned to D3 */
				spin_unlock_irq(&bus->reg_lock);
				return -EIO;
			}
			wp++;
			wp %= AZX_MAX_CORB_ENTRIES;
			rp = snd_hdac_chip_readw(bus, CORBRP);
			if (wp == rp) {
			/* oops, it's full */
				spin_unlock_irq(&bus->reg_lock);
				return -EAGAIN;
			}
			bus->corb.buf[wp] = cpu_to_le32(val);
			snd_hdac_chip_writew(bus, CORBWP, wp);
			i++;
		}
	}
	spin_unlock_irq(&bus->reg_lock);

	return 0;
+15 −0
Original line number Diff line number Diff line
@@ -21,6 +21,21 @@ config SND_HDA_INTEL
	  To compile this driver as a module, choose M here: the module
	  will be called snd-hda-intel.

config SND_HDA_PHYTIUM
	tristate "PHYTIUM HD Audio"
	depends on SOUND
	select SND_HDA
	help
	  Say Y here to support the HDA controller present in PHYTIUM
	  SoCs

	  This options enables support for the HD Audio controller
	  present in some PHYTIUM SoCs, used to communicate audio
	  to the "High Definition Audio" codec.

	  To compile this driver as a module, choose M here: the module
	  will be called snd-hda-phytium.

config SND_HDA_TEGRA
	tristate "NVIDIA Tegra HD Audio"
	depends on ARCH_TEGRA
+2 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
snd-hda-intel-objs := hda_intel.o
snd-hda-phytium-objs := hda_phytium.o
snd-hda-tegra-objs := hda_tegra.o

snd-hda-codec-y := hda_bind.o hda_codec.o hda_jack.o hda_auto_parser.o hda_sysfs.o
@@ -48,3 +49,4 @@ obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o
# when built in kernel
obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
obj-$(CONFIG_SND_HDA_TEGRA) += snd-hda-tegra.o
obj-$(CONFIG_SND_HDA_PHYTIUM) += snd-hda-phytium.o
Loading