lpass.h 2.7 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-only */
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
 *
 * lpass.h - Definitions for the QTi LPASS
 */

#ifndef __LPASS_H__
#define __LPASS_H__

#include <linux/clk.h>
#include <linux/compiler.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

#define LPASS_AHBIX_CLOCK_FREQUENCY		131072000
17
#define LPASS_MAX_MI2S_PORTS			(8)
18
#define LPASS_MAX_DMA_CHANNELS			(8)
19 20 21 22 23 24 25 26

/* Both the CPU DAI and platform drivers will access this data */
struct lpass_data {

	/* AHB-I/X bus clocks inside the low-power audio subsystem (LPASS) */
	struct clk *ahbix_clk;

	/* MI2S system clock */
27
	struct clk *mi2s_osr_clk[LPASS_MAX_MI2S_PORTS];
28 29

	/* MI2S bit clock (derived from system clock by a divider */
30
	struct clk *mi2s_bit_clk[LPASS_MAX_MI2S_PORTS];
31 32 33 34 35 36 37 38 39

	/* low-power audio interface (LPAIF) registers */
	void __iomem *lpaif;

	/* regmap backed by the low-power audio interface (LPAIF) registers */
	struct regmap *lpaif_map;

	/* interrupts from the low-power audio interface (LPAIF) */
	int lpaif_irq;
40 41 42

	/* SOC specific variations in the LPASS IP integration */
	struct lpass_variant *variant;
43

44
	/* bit map to keep track of static channel allocations */
45
	unsigned long dma_ch_bit_map;
46

47 48
	/* used it for handling interrupt per dma channel */
	struct snd_pcm_substream *substream[LPASS_MAX_DMA_CHANNELS];
49 50 51 52

	/* 8016 specific */
	struct clk *pcnoc_mport_clk;
	struct clk *pcnoc_sway_clk;
53

54 55 56 57 58 59 60 61 62 63 64 65 66
};

/* Vairant data per each SOC */
struct lpass_variant {
	u32	i2sctrl_reg_base;
	u32	i2sctrl_reg_stride;
	u32	i2s_ports;
	u32	irq_reg_base;
	u32	irq_reg_stride;
	u32	irq_ports;
	u32	rdma_reg_base;
	u32	rdma_reg_stride;
	u32	rdma_channels;
67 68 69
	u32	wrdma_reg_base;
	u32	wrdma_reg_stride;
	u32	wrdma_channels;
70

71 72 73 74
	/**
	 * on SOCs like APQ8016 the channel control bits start
	 * at different offset to ipq806x
	 **/
75
	u32	dmactl_audif_start;
76
	u32	wrdma_channel_start;
77
	/* SOC specific initialization like clocks */
78 79
	int (*init)(struct platform_device *pdev);
	int (*exit)(struct platform_device *pdev);
80
	int (*alloc_dma_channel)(struct lpass_data *data, int direction);
81
	int (*free_dma_channel)(struct lpass_data *data, int ch);
82 83 84 85

	/* SOC specific dais */
	struct snd_soc_dai_driver *dai_driver;
	int num_dai;
86 87
	const char * const *dai_osr_clk_names;
	const char * const *dai_bit_clk_names;
88 89 90 91
};

/* register the platform driver from the CPU DAI driver */
int asoc_qcom_lpass_platform_register(struct platform_device *);
92 93 94
int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev);
int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev);
int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai);
95
extern const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops;
96 97

#endif /* __LPASS_H__ */