sound/soc/renesas/rcar/adg.c

Source file repositories/reference/linux-study-clean/sound/soc/renesas/rcar/adg.c

File Facts

System
Linux kernel
Corpus path
sound/soc/renesas/rcar/adg.c
Extension
.c
Size
21726 bytes
Lines
982
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct rsnd_adg {
	struct clk *adg;
	struct clk *clkin[CLKINMAX];
	struct clk *clkout[CLKOUTMAX];
	/* RZ/G3E: per-SSI ADG clocks (adg-ssi-0 through adg-ssi-9) */
	struct clk *clk_adg_ssi[ADG_SSI_MAX];
	struct clk *clk_ssif_supply;
	struct clk *null_clk;
	struct clk_onecell_data onecell;
	struct rsnd_mod mod;
	int clkin_rate[CLKINMAX];
	bool ssi_clk_prepared;
	int clkin_size;
	int clkout_size;
	u32 ckr;
	u32 brga;
	u32 brgb;

	int brg_rate[ADG_HZ_SIZE]; /* BRGA / BRGB */
};

#define for_each_rsnd_clkin(pos, adg, i)	\
	for (i = 0;				\
	     (i < adg->clkin_size) &&		\
	     ((pos) = adg->clkin[i]);		\
	     i++)
#define for_each_rsnd_clkout(pos, adg, i)	\
	for (i = 0;				\
	     (i < adg->clkout_size) &&		\
	     ((pos) = adg->clkout[i]);	\
	     i++)
#define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg)

static const char * const clkin_name_gen4[] = {
	[CLKA]	= "clkin",
};

static const char * const clkin_name_gen2[] = {
	[CLKA]	= "clk_a",
	[CLKB]	= "clk_b",
	[CLKC]	= "clk_c",
	[CLKI]	= "clk_i",
};

static const char * const clkin_name_rzg3e[] = {
	[CLKA]	= "audio-clka",
	[CLKB]	= "audio-clkb",
	[CLKC]	= "audio-clkc",
	[CLKI]	= "audio-clki",
};

static const char * const clkout_name_gen2[] = {
	[CLKOUT]  = "audio_clkout",
	[CLKOUT1] = "audio_clkout1",
	[CLKOUT2] = "audio_clkout2",
	[CLKOUT3] = "audio_clkout3",
};

static u32 rsnd_adg_calculate_brgx(unsigned long div)
{
	int i;

	if (!div)
		return 0;

	for (i = 3; i >= 0; i--) {
		int ratio = 2 << (i * 2);
		if (0 == (div % ratio))
			return (u32)((i << 8) | ((div / ratio) - 1));
	}

	return ~0;
}

static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io)
{
	struct rsnd_mod *ssi_mod = rsnd_io_to_mod_ssi(io);
	int id = rsnd_mod_id(ssi_mod);
	int ws = id;

	if (rsnd_ssi_is_pin_sharing(io)) {
		switch (id) {
		case 1:
		case 2:
		case 9:
			ws = 0;
			break;
		case 4:
			ws = 3;
			break;

Annotation

Implementation Notes