mirror of
https://abf.rosa.ru/djam/kernel-5.15.git
synced 2025-02-23 10:32:54 +00:00

Information about config values was taken from: From 804820df7bcb3d53a33ecd074b1eac277e938f24 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov <asheplyakov@altlinux.org> Date: Thu, 4 Feb 2021 19:35:14 +0400 Subject: [PATCH] config-aarch64: adjusted for Baikal-M (MBM1.0 board) * DW_APB_TIMER=y, DW_APB_TIMER_OF=y: SoC clocks * SERIAL_8250_DW=y: serial console * I2C_DESIGNWARE_CORE=y, I2C_DESIGNWARE_PLATFORM=y: BMC (board management controller) and RTC (Real Time Clock) are connected via I2C. * GPIO_DWAPB=y: device (PCIe, PHY, etc) reset/configuration * RTC_DRV_PCF2127=y: RTC compiled in so the kernel automatically sets the system time from the hardware clock * TP_BMC=y: amongst other things handles the power button * DRM_BAIKAL_VDU=m, DRM_BAIKAL_HDMI=m: video unit and HDMI transmitter * CMA_SIZE_MBYTES=256: video display unit and GPU use system RAM, hence CMA should reserve enough (contiguous) memory. Note: CMA reserves memory during very early init, hence the size has to be hard-coded into CONFIG * MALI_MIDGARD=m: GPU driver, kernel side of proprietary mali blob. Note: kernel mode code is GPLv2, so it's fine to distribute it. * SENSORS_BT1_PVT=m: hardware temperature/voltage sensors * PCI_BAIKAL=m: PCIe root complex. Compiled as a module since takes ages (60 seconds or so) to probe the hardware. If compiled in substantially increases the boot time, and machine is completely unresponsive during probing PCIe. When built as a module probing executes concurrently with other boot activities (unless booting from a PCIe device) * STMMAC_ETH=m, STMMAC_PLATFORM=m, DWMAC_BAIKAL=m: Ethernet driver
251 lines
9.3 KiB
Diff
251 lines
9.3 KiB
Diff
From 750bd359f6fff79a3131f89c3bd9ad8a83a6356a Mon Sep 17 00:00:00 2001
|
|
From: Alexey Sheplyakov <asheplyakov@altlinux.org>
|
|
Date: Wed, 3 Feb 2021 16:58:16 +0400
|
|
Subject: [PATCH 611/625] dw-hdmi-ahb-audio: support BE-M1000 SoC
|
|
|
|
---
|
|
.../drm/bridge/synopsys/dw-hdmi-ahb-audio.c | 106 ++++++++++++------
|
|
.../gpu/drm/bridge/synopsys/dw-hdmi-audio.h | 1 +
|
|
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 6 +
|
|
3 files changed, 78 insertions(+), 35 deletions(-)
|
|
|
|
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
|
|
index d0db1acf11d7..3bb652e42718 100644
|
|
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
|
|
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
|
|
@@ -132,12 +132,45 @@ struct snd_dw_hdmi {
|
|
u8 cs[192][8];
|
|
};
|
|
|
|
-static void dw_hdmi_writel(u32 val, void __iomem *ptr)
|
|
+static inline void dw_hdmi_writeb_relaxed(u8 value, const struct dw_hdmi_audio_data *data, int offset)
|
|
{
|
|
- writeb_relaxed(val, ptr);
|
|
- writeb_relaxed(val >> 8, ptr + 1);
|
|
- writeb_relaxed(val >> 16, ptr + 2);
|
|
- writeb_relaxed(val >> 24, ptr + 3);
|
|
+ void __iomem *base = data->base;
|
|
+ if (data->reg_offset != 0)
|
|
+ offset <<= data->reg_offset;
|
|
+ writeb_relaxed(value, base + offset);
|
|
+}
|
|
+
|
|
+static inline void dw_hdmi_writeb(u8 value, const struct dw_hdmi_audio_data *data, int offset)
|
|
+{
|
|
+ void __iomem *base = data->base;
|
|
+ if (data->reg_offset != 0)
|
|
+ offset <<= data->reg_offset;
|
|
+ writeb(value, base + offset);
|
|
+}
|
|
+
|
|
+static inline u8 dw_hdmi_readb(const struct dw_hdmi_audio_data *data, int offset)
|
|
+{
|
|
+ void __iomem *base = data->base;
|
|
+ if (data->reg_offset != 0)
|
|
+ offset <<= data->reg_offset;
|
|
+ return readb(base + offset);
|
|
+
|
|
+}
|
|
+
|
|
+static inline u8 dw_hdmi_readb_relaxed(const struct dw_hdmi_audio_data *data, int offset)
|
|
+{
|
|
+ void __iomem *base = data->base;
|
|
+ if (data->reg_offset != 0)
|
|
+ offset <<= data->reg_offset;
|
|
+ return readb_relaxed(base + offset);
|
|
+}
|
|
+
|
|
+static void dw_hdmi_writel(u32 val, const struct dw_hdmi_audio_data *data, int offset)
|
|
+{
|
|
+ dw_hdmi_writeb_relaxed(val, data, offset);
|
|
+ dw_hdmi_writeb_relaxed(val >> 8, data, offset + 1);
|
|
+ dw_hdmi_writeb_relaxed(val >> 16, data, offset + 2);
|
|
+ dw_hdmi_writeb_relaxed(val >> 24, data, offset + 3);
|
|
}
|
|
|
|
/*
|
|
@@ -232,7 +265,6 @@ static void dw_hdmi_create_cs(struct snd_dw_hdmi *dw,
|
|
|
|
static void dw_hdmi_start_dma(struct snd_dw_hdmi *dw)
|
|
{
|
|
- void __iomem *base = dw->data.base;
|
|
unsigned offset = dw->buf_offset;
|
|
unsigned period = dw->buf_period;
|
|
u32 start, stop;
|
|
@@ -240,18 +272,18 @@ static void dw_hdmi_start_dma(struct snd_dw_hdmi *dw)
|
|
dw->reformat(dw, offset, period);
|
|
|
|
/* Clear all irqs before enabling irqs and starting DMA */
|
|
- writeb_relaxed(HDMI_IH_AHBDMAAUD_STAT0_ALL,
|
|
- base + HDMI_IH_AHBDMAAUD_STAT0);
|
|
+ dw_hdmi_writeb_relaxed(HDMI_IH_AHBDMAAUD_STAT0_ALL,
|
|
+ &dw->data, HDMI_IH_AHBDMAAUD_STAT0);
|
|
|
|
start = dw->buf_addr + offset;
|
|
stop = start + period - 1;
|
|
|
|
/* Setup the hardware start/stop addresses */
|
|
- dw_hdmi_writel(start, base + HDMI_AHB_DMA_STRADDR0);
|
|
- dw_hdmi_writel(stop, base + HDMI_AHB_DMA_STPADDR0);
|
|
+ dw_hdmi_writel(start, &dw->data, HDMI_AHB_DMA_STRADDR0);
|
|
+ dw_hdmi_writel(stop, &dw->data, HDMI_AHB_DMA_STPADDR0);
|
|
|
|
- writeb_relaxed((u8)~HDMI_AHB_DMA_MASK_DONE, base + HDMI_AHB_DMA_MASK);
|
|
- writeb(HDMI_AHB_DMA_START_START, base + HDMI_AHB_DMA_START);
|
|
+ dw_hdmi_writeb_relaxed((u8)~HDMI_AHB_DMA_MASK_DONE, &dw->data, HDMI_AHB_DMA_MASK);
|
|
+ dw_hdmi_writeb(HDMI_AHB_DMA_START_START, &dw->data, HDMI_AHB_DMA_START);
|
|
|
|
offset += period;
|
|
if (offset >= dw->buf_size)
|
|
@@ -262,8 +294,8 @@ static void dw_hdmi_start_dma(struct snd_dw_hdmi *dw)
|
|
static void dw_hdmi_stop_dma(struct snd_dw_hdmi *dw)
|
|
{
|
|
/* Disable interrupts before disabling DMA */
|
|
- writeb_relaxed(~0, dw->data.base + HDMI_AHB_DMA_MASK);
|
|
- writeb_relaxed(HDMI_AHB_DMA_STOP_STOP, dw->data.base + HDMI_AHB_DMA_STOP);
|
|
+ dw_hdmi_writeb_relaxed(~0, &dw->data, HDMI_AHB_DMA_MASK);
|
|
+ dw_hdmi_writeb_relaxed(HDMI_AHB_DMA_STOP_STOP, &dw->data, HDMI_AHB_DMA_STOP);
|
|
}
|
|
|
|
static irqreturn_t snd_dw_hdmi_irq(int irq, void *data)
|
|
@@ -272,11 +304,11 @@ static irqreturn_t snd_dw_hdmi_irq(int irq, void *data)
|
|
struct snd_pcm_substream *substream;
|
|
unsigned stat;
|
|
|
|
- stat = readb_relaxed(dw->data.base + HDMI_IH_AHBDMAAUD_STAT0);
|
|
+ stat = dw_hdmi_readb_relaxed(&dw->data, HDMI_IH_AHBDMAAUD_STAT0);
|
|
if (!stat)
|
|
return IRQ_NONE;
|
|
|
|
- writeb_relaxed(stat, dw->data.base + HDMI_IH_AHBDMAAUD_STAT0);
|
|
+ dw_hdmi_writeb_relaxed(stat, &dw->data, HDMI_IH_AHBDMAAUD_STAT0);
|
|
|
|
substream = dw->substream;
|
|
if (stat & HDMI_IH_AHBDMAAUD_STAT0_DONE && substream) {
|
|
@@ -319,7 +351,6 @@ static int dw_hdmi_open(struct snd_pcm_substream *substream)
|
|
{
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
struct snd_dw_hdmi *dw = substream->private_data;
|
|
- void __iomem *base = dw->data.base;
|
|
int ret;
|
|
|
|
runtime->hw = dw_hdmi_hw;
|
|
@@ -345,16 +376,16 @@ static int dw_hdmi_open(struct snd_pcm_substream *substream)
|
|
return ret;
|
|
|
|
/* Clear FIFO */
|
|
- writeb_relaxed(HDMI_AHB_DMA_CONF0_SW_FIFO_RST,
|
|
- base + HDMI_AHB_DMA_CONF0);
|
|
+ dw_hdmi_writeb_relaxed(HDMI_AHB_DMA_CONF0_SW_FIFO_RST,
|
|
+ &dw->data, HDMI_AHB_DMA_CONF0);
|
|
|
|
/* Configure interrupt polarities */
|
|
- writeb_relaxed(~0, base + HDMI_AHB_DMA_POL);
|
|
- writeb_relaxed(~0, base + HDMI_AHB_DMA_BUFFPOL);
|
|
+ dw_hdmi_writeb_relaxed(~0, &dw->data, HDMI_AHB_DMA_POL);
|
|
+ dw_hdmi_writeb_relaxed(~0, &dw->data, HDMI_AHB_DMA_BUFFPOL);
|
|
|
|
/* Keep interrupts masked, and clear any pending */
|
|
- writeb_relaxed(~0, base + HDMI_AHB_DMA_MASK);
|
|
- writeb_relaxed(~0, base + HDMI_IH_AHBDMAAUD_STAT0);
|
|
+ dw_hdmi_writeb_relaxed(~0, &dw->data, HDMI_AHB_DMA_MASK);
|
|
+ dw_hdmi_writeb_relaxed(~0, &dw->data, HDMI_IH_AHBDMAAUD_STAT0);
|
|
|
|
ret = request_irq(dw->data.irq, snd_dw_hdmi_irq, IRQF_SHARED,
|
|
"dw-hdmi-audio", dw);
|
|
@@ -362,9 +393,9 @@ static int dw_hdmi_open(struct snd_pcm_substream *substream)
|
|
return ret;
|
|
|
|
/* Un-mute done interrupt */
|
|
- writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL &
|
|
- ~HDMI_IH_MUTE_AHBDMAAUD_STAT0_DONE,
|
|
- base + HDMI_IH_MUTE_AHBDMAAUD_STAT0);
|
|
+ dw_hdmi_writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL &
|
|
+ ~HDMI_IH_MUTE_AHBDMAAUD_STAT0_DONE,
|
|
+ &dw->data, HDMI_IH_MUTE_AHBDMAAUD_STAT0);
|
|
|
|
return 0;
|
|
}
|
|
@@ -374,8 +405,8 @@ static int dw_hdmi_close(struct snd_pcm_substream *substream)
|
|
struct snd_dw_hdmi *dw = substream->private_data;
|
|
|
|
/* Mute all interrupts */
|
|
- writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL,
|
|
- dw->data.base + HDMI_IH_MUTE_AHBDMAAUD_STAT0);
|
|
+ dw_hdmi_writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL,
|
|
+ &dw->data, HDMI_IH_MUTE_AHBDMAAUD_STAT0);
|
|
|
|
free_irq(dw->data.irq, dw);
|
|
|
|
@@ -416,6 +447,11 @@ static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
|
|
HDMI_AHB_DMA_CONF0_INCR8;
|
|
threshold = 128;
|
|
break;
|
|
+ case 0x2a: /* this revision is used in Baikal-M SoC */
|
|
+ conf0 = HDMI_AHB_DMA_CONF0_BURST_MODE |
|
|
+ HDMI_AHB_DMA_CONF0_INCR16;
|
|
+ threshold = 128;
|
|
+ break;
|
|
default:
|
|
/* NOTREACHED */
|
|
return -EINVAL;
|
|
@@ -430,9 +466,9 @@ static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
|
|
conf1 = default_hdmi_channel_config[runtime->channels - 2].conf1;
|
|
ca = default_hdmi_channel_config[runtime->channels - 2].ca;
|
|
|
|
- writeb_relaxed(threshold, dw->data.base + HDMI_AHB_DMA_THRSLD);
|
|
- writeb_relaxed(conf0, dw->data.base + HDMI_AHB_DMA_CONF0);
|
|
- writeb_relaxed(conf1, dw->data.base + HDMI_AHB_DMA_CONF1);
|
|
+ dw_hdmi_writeb_relaxed(threshold, &dw->data, HDMI_AHB_DMA_THRSLD);
|
|
+ dw_hdmi_writeb_relaxed(conf0, &dw->data, HDMI_AHB_DMA_CONF0);
|
|
+ dw_hdmi_writeb_relaxed(conf1, &dw->data, HDMI_AHB_DMA_CONF1);
|
|
|
|
dw_hdmi_set_channel_count(dw->data.hdmi, runtime->channels);
|
|
dw_hdmi_set_channel_allocation(dw->data.hdmi, ca);
|
|
@@ -524,10 +560,10 @@ static int snd_dw_hdmi_probe(struct platform_device *pdev)
|
|
unsigned revision;
|
|
int ret;
|
|
|
|
- writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL,
|
|
- data->base + HDMI_IH_MUTE_AHBDMAAUD_STAT0);
|
|
- revision = readb_relaxed(data->base + HDMI_REVISION_ID);
|
|
- if (revision != 0x0a && revision != 0x1a) {
|
|
+ dw_hdmi_writeb_relaxed(HDMI_IH_MUTE_AHBDMAAUD_STAT0_ALL,
|
|
+ data, HDMI_IH_MUTE_AHBDMAAUD_STAT0);
|
|
+ revision = dw_hdmi_readb_relaxed(data, HDMI_REVISION_ID);
|
|
+ if (revision != 0x0a && revision != 0x1a && revision != 0x2a) {
|
|
dev_err(dev, "dw-hdmi-audio: unknown revision 0x%02x\n",
|
|
revision);
|
|
return -ENXIO;
|
|
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h
|
|
index cb07dc0da5a7..8fb5ebd5a169 100644
|
|
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h
|
|
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h
|
|
@@ -10,6 +10,7 @@ struct dw_hdmi_audio_data {
|
|
int irq;
|
|
struct dw_hdmi *hdmi;
|
|
u8 *eld;
|
|
+ unsigned reg_offset;
|
|
};
|
|
|
|
struct dw_hdmi_i2s_audio_data {
|
|
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
|
|
index 0c79a9ba48bb..d0580b7d7430 100644
|
|
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
|
|
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
|
|
@@ -3396,6 +3396,12 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
|
|
audio.irq = irq;
|
|
audio.hdmi = hdmi;
|
|
audio.eld = hdmi->connector.eld;
|
|
+ audio.reg_offset = 0;
|
|
+ if (of_device_is_compatible(np, "baikal,hdmi")) {
|
|
+ audio.reg_offset = 2;
|
|
+ dev_info(dev, "setting audio.reg_offset=%d for BE-M1000 SoC\n",
|
|
+ audio.reg_offset);
|
|
+ }
|
|
hdmi->enable_audio = dw_hdmi_ahb_audio_enable;
|
|
hdmi->disable_audio = dw_hdmi_ahb_audio_disable;
|
|
|
|
--
|
|
2.31.1
|
|
|