Exemple #1
0
/**
 * Output BAM register content
 * including the TEST_BUS register content under
 * different TEST_BUS_SEL values.
 */
static void bam_output_register_content(void *base)
{
	u32 num_pipes;
	u32 test_bus_selection[] = {0x1, 0x2, 0x3, 0x4, 0xD, 0x10,
			0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
	u32 i;
	u32 size = sizeof(test_bus_selection) / sizeof(u32);

	for (i = 0; i < size; i++) {
		bam_write_reg_field(base, TEST_BUS_SEL, BAM_TESTBUS_SEL,
					test_bus_selection[i]);

		SPS_INFO("sps:bam 0x%x(va);BAM_TEST_BUS_REG is"
			"0x%x when BAM_TEST_BUS_SEL is 0x%x.",
			(u32) base, bam_read_reg(base, TEST_BUS_REG),
			bam_read_reg_field(base, TEST_BUS_SEL,
					BAM_TESTBUS_SEL));
	}

	print_bam_reg(base);

	num_pipes = bam_read_reg_field(base, NUM_PIPES,
					BAM_NUM_PIPES);
	SPS_INFO("sps:bam 0x%x(va) has %d pipes.",
			(u32) base, num_pipes);

	for (i = 0; i < num_pipes; i++)
		print_bam_pipe_reg(base, i);

}
Exemple #2
0
/* output BAM_TEST_BUS_REG with specified TEST_BUS_SEL */
void print_bam_test_bus_reg(void *base, u32 tb_sel)
{
	u32 i;
	u32 test_bus_selection[] = {0x1, 0x2, 0x3, 0x4, 0xD, 0x10,
			0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
	u32 size = sizeof(test_bus_selection) / sizeof(u32);

	if ((base == NULL) || (tb_sel == 0))
		return;

	SPS_INFO("\nsps:Specified TEST_BUS_SEL value: 0x%x\n", tb_sel);
	bam_write_reg_field(base, TEST_BUS_SEL, BAM_TESTBUS_SEL, tb_sel);
	SPS_INFO("sps:BAM_TEST_BUS_REG: 0x%x when TEST_BUS_SEL: 0x%x\n\n",
		bam_read_reg(base, TEST_BUS_REG),
		bam_read_reg_field(base, TEST_BUS_SEL, BAM_TESTBUS_SEL));

	/* output other selections */
	for (i = 0; i < size; i++) {
		bam_write_reg_field(base, TEST_BUS_SEL, BAM_TESTBUS_SEL,
					test_bus_selection[i]);

		SPS_INFO("sps:bam 0x%x(va);TEST_BUS_REG:0x%x;TEST_BUS_SEL:0x%x",
			(u32) base, bam_read_reg(base, TEST_BUS_REG),
			bam_read_reg_field(base, TEST_BUS_SEL,
					BAM_TESTBUS_SEL));
	}
}
/**
 * Get BAM IRQ source and clear global IRQ status
 */
u32 bam_check_irq_source(void *base, u32 ee, u32 mask,
				enum sps_callback_case *cb_case)
{
	u32 source = bam_read_reg(base, IRQ_SRCS_EE(ee));
	u32 clr = source & (1UL << 31);

	if (clr) {
		u32 status = 0;
		status = bam_read_reg(base, IRQ_STTS);

		if (status & IRQ_STTS_BAM_ERROR_IRQ) {
			SPS_ERR("sps:bam 0x%x(va);bam irq status="
				"0x%x.\nsps: BAM_ERROR_IRQ\n",
				(u32) base, status);
			bam_output_register_content(base);
			*cb_case = SPS_CALLBACK_BAM_ERROR_IRQ;
		} else if (status & IRQ_STTS_BAM_HRESP_ERR_IRQ) {
			SPS_ERR("sps:bam 0x%x(va);bam irq status="
				"0x%x.\nsps: BAM_HRESP_ERR_IRQ\n",
				(u32) base, status);
			bam_output_register_content(base);
			*cb_case = SPS_CALLBACK_BAM_HRESP_ERR_IRQ;
		} else
			SPS_INFO("sps:bam 0x%x(va);bam irq status="
				"0x%x.", (u32) base, status);

		bam_write_reg(base, IRQ_CLR, status);
	}

	source &= (mask|(1UL << 31));
	return source;
}
/**
 * Initialize a BAM device
 *
 */
int bam_init(void *base, u32 ee,
		u16 summing_threshold,
		u32 irq_mask, u32 *version, u32 *num_pipes)
{
	/* disable bit#11 because of HW bug */
	u32 cfg_bits = 0xffffffff & ~(1 << 11);
	u32 ver = 0;

	SPS_DBG2("sps:%s:bam=0x%x(va).ee=%d.", __func__, (u32) base, ee);

	ver = bam_read_reg_field(base, REVISION, BAM_REVISION);

	if ((ver < BAM_MIN_VERSION) || (ver > BAM_MAX_VERSION)) {
		SPS_ERR("sps:bam 0x%x(va) Invalid BAM REVISION 0x%x.\n",
				(u32) base, ver);
		return -ENODEV;
	} else
		SPS_INFO("sps:REVISION of BAM 0x%x is 0x%x.\n",
				(u32) base, ver);

	if (summing_threshold == 0) {
		summing_threshold = 4;
		SPS_ERR("sps:bam 0x%x(va) summing_threshold is zero , "
				"use default 4.\n", (u32) base);
	}

	bam_write_reg_field(base, CTRL, BAM_SW_RST, 1);
	/* No delay needed */
	bam_write_reg_field(base, CTRL, BAM_SW_RST, 0);

	bam_write_reg_field(base, CTRL, BAM_EN, 1);

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	bam_write_reg_field(base, CTRL, CACHE_MISS_ERR_RESP_EN, 1);

	bam_write_reg_field(base, CTRL, LOCAL_CLK_GATING, 1);
#endif

	bam_write_reg(base, DESC_CNT_TRSHLD, summing_threshold);

	bam_write_reg(base, CNFG_BITS, cfg_bits);

	/*
	 *  Enable Global BAM Interrupt - for error reasons ,
	 *  filter with mask.
	 *  Note: Pipes interrupts are disabled until BAM_P_IRQ_enn is set
	 */
	bam_write_reg_field(base, IRQ_SRCS_MSK_EE(ee), BAM_IRQ, 1);

	bam_write_reg(base, IRQ_EN, irq_mask);

	*num_pipes = bam_read_reg_field(base, NUM_PIPES, BAM_NUM_PIPES);

	*version = ver;

	return 0;
}
Exemple #5
0
/* output descriptor FIFO of a pipe */
void print_bam_pipe_desc_fifo(void *virt_addr, u32 pipe_index)
{
	void *base = virt_addr;
	u32 pipe = pipe_index;
	u32 desc_fifo_addr;
	u32 desc_fifo_size;
	u32 *desc_fifo;
	int i;

	if (base == NULL)
		return;

	desc_fifo_addr = bam_read_reg(base, P_DESC_FIFO_ADDR(pipe));
	desc_fifo_size = bam_read_reg_field(base, P_FIFO_SIZES(pipe),
						P_DESC_FIFO_SIZE);

	if (desc_fifo_addr == 0) {
		SPS_ERR("sps:%s:desc FIFO address of Pipe %d is NULL.\n",
			__func__, pipe);
		return;
	} else if (desc_fifo_size == 0) {
		SPS_ERR("sps:%s:desc FIFO size of Pipe %d is 0.\n",
			__func__, pipe);
		return;
	}

	SPS_INFO("\nsps:----- descriptor FIFO of Pipe %d -----\n", pipe);

	SPS_INFO("BAM_P_DESC_FIFO_ADDR: 0x%x\n"
		"BAM_P_DESC_FIFO_SIZE: 0x%x (%d)\n\n",
		desc_fifo_addr, desc_fifo_size, desc_fifo_size);

	desc_fifo = (u32 *) phys_to_virt(desc_fifo_addr);

	SPS_INFO("-------------------- begin of FIFO --------------------\n");

	for (i = 0; i < desc_fifo_size; i += 0x10)
		SPS_INFO("addr 0x%x: 0x%x, 0x%x, 0x%x, 0x%x.\n",
			desc_fifo_addr + i,
			desc_fifo[i / 4], desc_fifo[(i / 4) + 1],
			desc_fifo[(i / 4) + 2], desc_fifo[(i / 4) + 3]);

	SPS_INFO("--------------------  end of FIFO  --------------------\n");
}
Exemple #6
0
int bam_init(void *base, u32 ee,
		u16 summing_threshold,
		u32 irq_mask, u32 *version, u32 *num_pipes)
{
	
	u32 cfg_bits = 0xffffffff & ~(1 << 11);
	u32 ver = 0;

	SPS_DBG2("sps:%s:bam=0x%x(va).ee=%d.", __func__, (u32) base, ee);

	ver = bam_read_reg_field(base, REVISION, BAM_REVISION);

	if ((ver < BAM_MIN_VERSION) || (ver > BAM_MAX_VERSION)) {
		SPS_ERR("sps:bam 0x%x(va) Invalid BAM REVISION 0x%x.\n",
				(u32) base, ver);
		return -ENODEV;
	} else
		SPS_INFO("sps:REVISION of BAM 0x%x is 0x%x.\n",
				(u32) base, ver);

	if (summing_threshold == 0) {
		summing_threshold = 4;
		SPS_ERR("sps:bam 0x%x(va) summing_threshold is zero , "
				"use default 4.\n", (u32) base);
	}

	bam_write_reg_field(base, CTRL, BAM_SW_RST, 1);
	
	bam_write_reg_field(base, CTRL, BAM_SW_RST, 0);

	bam_write_reg_field(base, CTRL, BAM_EN, 1);

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	bam_write_reg_field(base, CTRL, CACHE_MISS_ERR_RESP_EN, 1);

	bam_write_reg_field(base, CTRL, LOCAL_CLK_GATING, 1);
#endif

	bam_write_reg(base, DESC_CNT_TRSHLD, summing_threshold);

	bam_write_reg(base, CNFG_BITS, cfg_bits);

	bam_write_reg_field(base, IRQ_SRCS_MSK_EE(ee), BAM_IRQ, 1);

	bam_write_reg(base, IRQ_EN, irq_mask);

	*num_pipes = bam_read_reg_field(base, NUM_PIPES, BAM_NUM_PIPES);

	*version = ver;

	return 0;
}
Exemple #7
0
/* output the content of selected BAM-level registers */
void print_bam_selected_reg(void *virt_addr)
{
	void *base = virt_addr;

	if (base == NULL)
		return;

	SPS_INFO("\nsps:----- Content of BAM-level registers <begin> -----\n");

	SPS_INFO("BAM_CTRL: 0x%x\n"
		"BAM_REVISION: 0x%x\n"
		"BAM_NUM_EES: %d\n"
#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
		"BAM_CMD_DESC_EN: 0x%x\n"
#endif
		"BAM_NUM_PIPES: %d\n"
		"BAM_DESC_CNT_TRSHLD: 0x%x (%d)\n"
		"BAM_IRQ_SRCS: 0x%x\n"
		"BAM_IRQ_SRCS_MSK: 0x%x\n"
		"BAM_EE: %d\n"
		"BAM_CNFG_BITS: 0x%x\n",
		bam_read_reg(base, CTRL),
		bam_read_reg_field(base, REVISION, BAM_REVISION),
		bam_read_reg_field(base, REVISION, BAM_NUM_EES),
#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
		bam_read_reg_field(base, REVISION, BAM_CMD_DESC_EN),
#endif
		bam_read_reg_field(base, NUM_PIPES, BAM_NUM_PIPES),
		bam_read_reg_field(base, DESC_CNT_TRSHLD, BAM_DESC_CNT_TRSHLD),
		bam_read_reg_field(base, DESC_CNT_TRSHLD, BAM_DESC_CNT_TRSHLD),
		bam_read_reg(base, IRQ_SRCS),
		bam_read_reg(base, IRQ_SRCS_MSK),
		bam_read_reg_field(base, TRUST_REG, BAM_EE),
		bam_read_reg(base, CNFG_BITS));

	SPS_INFO("\nsps:----- Content of BAM-level registers <end> -----\n");
}
Exemple #8
0
/* output the content of BAM-level registers */
void print_bam_reg(void *virt_addr)
{
	int i, n;
	u32 *bam = (u32 *) virt_addr;
	u32 ctrl;
	u32 ver;
	u32 pipes;

	if (bam == NULL)
		return;

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	ctrl = bam[0x0 / 4];
	ver = bam[0x4 / 4];
	pipes = bam[0x3c / 4];
#else
	ctrl = bam[0xf80 / 4];
	ver = bam[0xf84 / 4];
	pipes = bam[0xfbc / 4];
#endif

	SPS_INFO("\nsps:----- Content of BAM-level registers <begin> -----\n");

	SPS_INFO("BAM_CTRL: 0x%x.\n", ctrl);
	SPS_INFO("BAM_REVISION: 0x%x.\n", ver);
	SPS_INFO("NUM_PIPES: 0x%x.\n", pipes);

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	for (i = 0x0; i < 0x80; i += 0x10)
#else
	for (i = 0xf80; i < 0x1000; i += 0x10)
#endif
		SPS_INFO("bam addr 0x%x: 0x%x,0x%x,0x%x,0x%x.\n", i,
			bam[i / 4], bam[(i / 4) + 1],
			bam[(i / 4) + 2], bam[(i / 4) + 3]);

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	for (i = 0x800, n = 0; n++ < 8; i += 0x80)
#else
	for (i = 0x1800, n = 0; n++ < 4; i += 0x80)
#endif
		SPS_INFO("bam addr 0x%x: 0x%x,0x%x,0x%x,0x%x.\n", i,
			bam[i / 4], bam[(i / 4) + 1],
			bam[(i / 4) + 2], bam[(i / 4) + 3]);

	SPS_INFO("\nsps:----- Content of BAM-level registers <end> -----\n");
}
Exemple #9
0
/**
 * Get BAM IRQ source and clear global IRQ status
 */
u32 bam_check_irq_source(void *base, u32 ee, u32 mask)
{
	u32 source = bam_read_reg(base, IRQ_SRCS_EE(ee));
	u32 clr = source & (1UL << 31);

	if (clr) {
		u32 status = 0;
		status = bam_read_reg(base, IRQ_STTS);
		bam_write_reg(base, IRQ_CLR, status);
		if (printk_ratelimit()) {
			if (status & IRQ_STTS_BAM_ERROR_IRQ)
				SPS_ERR("sps:bam 0x%x(va);bam irq status="
					"0x%x.\nsps: BAM_ERROR_IRQ\n",
					(u32) base, status);
			else
				SPS_INFO("sps:bam 0x%x(va);bam irq status="
					"0x%x.", (u32) base, status);
		}
	}

	source &= mask;
	return source;
}
Exemple #10
0
/* output the content of BAM pipe registers */
void print_bam_pipe_reg(void *virt_addr, u32 pipe_index)
{
	int i;
	u32 *bam = (u32 *) virt_addr;
	u32 pipe = pipe_index;

	if (bam == NULL)
		return;

	SPS_INFO("\nsps:----- Content of Pipe %d registers <begin> -----\n",
			pipe);

	SPS_INFO("-- Pipe Management Registers --\n");

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	for (i = 0x1000 + 0x1000 * pipe; i < 0x1000 + 0x1000 * pipe + 0x80;
	    i += 0x10)
#else
	for (i = 0x0000 + 0x80 * pipe; i < 0x0000 + 0x80 * (pipe + 1);
	    i += 0x10)
#endif
		SPS_INFO("bam addr 0x%x: 0x%x,0x%x,0x%x,0x%x.\n", i,
			bam[i / 4], bam[(i / 4) + 1],
			bam[(i / 4) + 2], bam[(i / 4) + 3]);

	SPS_INFO("-- Pipe Configuration and Internal State Registers --\n");

#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
	for (i = 0x1800 + 0x1000 * pipe; i < 0x1800 + 0x1000 * pipe + 0x40;
	    i += 0x10)
#else
	for (i = 0x1000 + 0x40 * pipe; i < 0x1000 + 0x40 * (pipe + 1);
	    i += 0x10)
#endif
		SPS_INFO("bam addr 0x%x: 0x%x,0x%x,0x%x,0x%x.\n", i,
			bam[i / 4], bam[(i / 4) + 1],
			bam[(i / 4) + 2], bam[(i / 4) + 3]);

	SPS_INFO("\nsps:----- Content of Pipe %d registers <end> -----\n",
			pipe);
}
Exemple #11
0
/* output the content of selected BAM pipe registers */
void print_bam_pipe_selected_reg(void *virt_addr, u32 pipe_index)
{
	void *base = virt_addr;
	u32 pipe = pipe_index;

	if (base == NULL)
		return;

	SPS_INFO("\nsps:----- Registers of Pipe %d -----\n", pipe);

	SPS_INFO("BAM_P_CTRL: 0x%x\n"
		"BAM_P_SYS_MODE: %d\n"
		"BAM_P_DIRECTION: %d\n"
#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
		"BAM_P_LOCK_GROUP: 0x%x (%d)\n"
#endif
		"BAM_P_EE: %d\n"
		"BAM_P_IRQ_STTS: 0x%x\n"
		"BAM_P_IRQ_STTS_P_TRNSFR_END_IRQ: 0x%x\n"
		"BAM_P_IRQ_STTS_P_PRCSD_DESC_IRQ: 0x%x\n"
		"BAM_P_IRQ_EN: %d\n"
		"BAM_P_PRDCR_SDBNDn_BAM_P_BYTES_FREE: 0x%x (%d)\n"
		"BAM_P_CNSMR_SDBNDn_BAM_P_BYTES_AVAIL: 0x%x (%d)\n"
		"BAM_P_SW_DESC_OFST: 0x%x\n"
		"BAM_P_DESC_FIFO_PEER_OFST: 0x%x\n"
		"BAM_P_EVNT_DEST_ADDR: 0x%x\n"
		"BAM_P_DESC_FIFO_ADDR: 0x%x\n"
		"BAM_P_DESC_FIFO_SIZE: 0x%x (%d)\n"
		"BAM_P_DATA_FIFO_ADDR: 0x%x\n"
		"BAM_P_DATA_FIFO_SIZE: 0x%x (%d)\n"
		"BAM_P_EVNT_GEN_TRSHLD: 0x%x (%d)\n",
		bam_read_reg(base, P_CTRL(pipe)),
		bam_read_reg_field(base, P_CTRL(pipe), P_SYS_MODE),
		bam_read_reg_field(base, P_CTRL(pipe), P_DIRECTION),
#ifdef CONFIG_SPS_SUPPORT_NDP_BAM
		bam_read_reg_field(base, P_CTRL(pipe), P_LOCK_GROUP),
		bam_read_reg_field(base, P_CTRL(pipe), P_LOCK_GROUP),
#endif
		bam_read_reg_field(base, P_TRUST_REG(pipe), BAM_P_EE),
		bam_read_reg(base, P_IRQ_STTS(pipe)),
		bam_read_reg_field(base, P_IRQ_STTS(pipe),
					P_IRQ_STTS_P_TRNSFR_END_IRQ),
		bam_read_reg_field(base, P_IRQ_STTS(pipe),
					P_IRQ_STTS_P_PRCSD_DESC_IRQ),
		bam_read_reg(base, P_IRQ_EN(pipe)),
		bam_read_reg_field(base, P_PRDCR_SDBND(pipe),
					P_PRDCR_SDBNDn_BAM_P_BYTES_FREE),
		bam_read_reg_field(base, P_PRDCR_SDBND(pipe),
					P_PRDCR_SDBNDn_BAM_P_BYTES_FREE),
		bam_read_reg_field(base, P_CNSMR_SDBND(pipe),
					P_CNSMR_SDBNDn_BAM_P_BYTES_AVAIL),
		bam_read_reg_field(base, P_CNSMR_SDBND(pipe),
					P_CNSMR_SDBNDn_BAM_P_BYTES_AVAIL),
		bam_read_reg_field(base, P_SW_OFSTS(pipe), SW_DESC_OFST),
		bam_read_reg_field(base, P_EVNT_REG(pipe),
					P_DESC_FIFO_PEER_OFST),
		bam_read_reg(base, P_EVNT_DEST_ADDR(pipe)),
		bam_read_reg(base, P_DESC_FIFO_ADDR(pipe)),
		bam_read_reg_field(base, P_FIFO_SIZES(pipe), P_DESC_FIFO_SIZE),
		bam_read_reg_field(base, P_FIFO_SIZES(pipe), P_DESC_FIFO_SIZE),
		bam_read_reg(base, P_DATA_FIFO_ADDR(pipe)),
		bam_read_reg_field(base, P_FIFO_SIZES(pipe), P_DATA_FIFO_SIZE),
		bam_read_reg_field(base, P_FIFO_SIZES(pipe), P_DATA_FIFO_SIZE),
		bam_read_reg_field(base, P_EVNT_GEN_TRSHLD(pipe),
					P_EVNT_GEN_TRSHLD_P_TRSHLD),
		bam_read_reg_field(base, P_EVNT_GEN_TRSHLD(pipe),
					P_EVNT_GEN_TRSHLD_P_TRSHLD));
}