Exemplo n.º 1
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		tps659038_vsel_to_uv
 * @BRIEF		for a given rail, convert SMPS vsel command into voltage
 *			in microvolts. Take into account SMPS voltage offset.
 * @RETURNS		voltage in microvolts corresponding to SMPS vsel command
 * @param[in]		smps_id: voltage rail
 * @param[in]		vsel: SMPS vsel command (in microvolts)
 * @DESCRIPTION		for a given rail, convert SMPS vsel command into voltage
 *			in microvolts. Take into account SMPS voltage offset.
 *//*------------------------------------------------------------------------ */
unsigned long tps659038_vsel_to_uv(unsigned char vsel)
{
	unsigned long uv;
	unsigned int range;

	/* VSEL = 7-bit + range (MSB) */
	range = extract_bit(vsel, 7);
	vsel = extract_bitfield(vsel, 0, TPS659038_VSEL_LEN);

	if (vsel == 0) {
		uv = 0;
	} else if (vsel <= 0x06) {
		uv = TPS659038_VOLT_MIN_UV;
	} else if (vsel >= 0x79) {
		uv = 1650000;
	} else {
		uv = TPS659038_VOLT_MIN_UV +
			(TPS659038_VSTEP_UV * (vsel - 6));
	}

	/* Apply range multiplier */
	uv = uv << range;

	dprintf("%s(%d, %d (0x%02X))=%lduV\n", __func__,
		smps_id, vsel, vsel, uv);
	return uv;
}
Exemplo n.º 2
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		emu44xx_dependency_show
 * @BRIEF		analyse dependency configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]		stream: output file stream
 * @DESCRIPTION		analyse dependency configuration
 *//*------------------------------------------------------------------------ */
int emu44xx_dependency_show(FILE *stream)
{
	unsigned int cm_dynamicdep;

	CHECK_CPU(44xx, OMAPCONF_ERR_CPU);

	if (!init_done)
		emu44xx_regtable_init();

	if (mem_read(OMAP4430_CM_EMU_DYNAMICDEP, &cm_dynamicdep) != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	dprintf("OMAP4430_CM_EMU_DYNAMICDEP = 0x%08X\n", cm_dynamicdep);
	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream,
		"| EMU Domain Dependency Configuration | Static | Dynamic |\n");
	fprintf(stream,
		"|-------------------------------------|------------------|\n");
	fprintf(stream,
		"| %-35s | %-6s | %-7s |\n", "L3_2",
		"",
		((extract_bit(cm_dynamicdep, 6) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream,
		"| %-44s | %-7d |\n", "Window Size",
		extract_bitfield(cm_dynamicdep, 24, 4));
	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream,
		"\n");

	return 0;
}
Exemplo n.º 3
0
static void parse_lookup_table(uint8_t* lookup_table, uint8_t* bitmap, uint32_t num_bytes)
{
    //Assumes the lookup table is in the correct size, and no overflow will happen.
    for(int i = 0; i < num_bytes * 8; i++)
    {
        lookup_table[i] = extract_bit(bitmap[(i / 8)], i % 8);
    }
}
Exemplo n.º 4
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		vc44xx_cmdra_get
 * @BRIEF		return Command Register Address (CMDRA)
 * @RETURNS		>0 Command Register Address (CMDRA)
 *			OMAPCONF_ERR_ARG
 * @param[in]		id: voltage domain ID
 * @param[in]		prm_vc_cfg_channel: PRM_VC_CFG_CHANNEL register content
 * @param[in]		prm_vc_val_smps_ra_cmd: PRM_VC_VAL_SMPS_RA_CMD register
 *			content
 * @DESCRIPTION		return Command Register Address (CMDRA)
 *//*------------------------------------------------------------------------ */
short int vc44xx_cmdra_get(voltdm44xx_id id,
	unsigned int prm_vc_cfg_channel, unsigned int prm_vc_val_smps_ra_cmd)
{
	short int cmdra;

	switch (id) {
	case OMAP4_VDD_MPU:
		cmdra = extract_bitfield(prm_vc_val_smps_ra_cmd,
			VC_CMDRA_VDD_MPU_L_POS, VC_CMDRA_VDD_MPU_L_LEN);
		break;

	case OMAP4_VDD_IVA:
		if (extract_bit(prm_vc_cfg_channel,
			VC_CFG_CHANNEL_RAC_VDD_IVA_L_POS) == 1)
			cmdra = extract_bitfield(prm_vc_val_smps_ra_cmd,
				VC_CMDRA_VDD_IVA_L_POS, VC_CMDRA_VDD_IVA_L_LEN);
		else
			cmdra = extract_bitfield(prm_vc_val_smps_ra_cmd,
				VC_CMDRA_VDD_CORE_L_POS,
				VC_CMDRA_VDD_CORE_L_LEN);
		break;

	case OMAP4_VDD_CORE:
		if (extract_bit(prm_vc_cfg_channel,
			VC_CFG_CHANNEL_RAC_VDD_CORE_L_POS) == 1)
			cmdra = extract_bitfield(prm_vc_val_smps_ra_cmd,
				VC_CMDRA_VDD_CORE_L_POS,
				VC_CMDRA_VDD_CORE_L_LEN);
		else
			cmdra = extract_bitfield(prm_vc_val_smps_ra_cmd,
				VC_CMDRA_VDD_MPU_L_POS,
				VC_CMDRA_VDD_MPU_L_LEN);
		break;

	default:
		cmdra = OMAPCONF_ERR_ARG;
	}

	return cmdra;
}
Exemplo n.º 5
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		vc44xx_sa_get
 * @BRIEF		return Slave Address (SA)
 * @RETURNS		>0 Slave Address (SA)
 *			OMAPCONF_ERR_ARG
 * @param[in]		id: voltage domain ID
 * @param[in]		prm_vc_smps_sa: PRM_VC_SMPS_SA register content
 * @param[in]		prm_vc_cfg_channel: PRM_VC_CFG_CHANNEL register content
 * @DESCRIPTION		return Slave Address (SA)
 *//*------------------------------------------------------------------------ */
short int vc44xx_sa_get(voltdm44xx_id id,
	unsigned int prm_vc_smps_sa, unsigned int prm_vc_cfg_channel)
{
	short int sa;

	switch (id) {
	case OMAP4_VDD_MPU:
		sa = extract_bitfield(prm_vc_smps_sa,
			VC_SA_VDD_MPU_L_POS, VC_SA_VDD_MPU_L_LEN);
		break;

	case OMAP4_VDD_IVA:
		if (extract_bit(prm_vc_cfg_channel,
			VC_CFG_CHANNEL_SA_VDD_IVA_L_POS) == 1)
			sa = extract_bitfield(prm_vc_smps_sa,
				VC_SA_VDD_IVA_L_POS, VC_SA_VDD_IVA_L_LEN);
		else
			sa = extract_bitfield(prm_vc_smps_sa,
				VC_SA_VDD_CORE_L_POS, VC_SA_VDD_CORE_L_LEN);
		break;

	case OMAP4_VDD_CORE:
		if (extract_bit(prm_vc_cfg_channel,
			VC_CFG_CHANNEL_SA_VDD_CORE_L_POS) == 1)
			sa = extract_bitfield(prm_vc_smps_sa,
				VC_SA_VDD_CORE_L_POS, VC_SA_VDD_CORE_L_LEN);
		else
			sa = extract_bitfield(prm_vc_smps_sa,
				VC_SA_VDD_MPU_L_POS, VC_SA_VDD_MPU_L_LEN);
		break;

	default:
		sa = OMAPCONF_ERR_ARG;
	}

	return sa;
}
Exemplo n.º 6
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		gfx44xx_dependency_show
 * @BRIEF		analyse GFX dependency configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]		stream: output file stream
 * @DESCRIPTION		analyse GFX dependency configuration
 *//*------------------------------------------------------------------------ */
int gfx44xx_dependency_show(FILE *stream)
{
	unsigned int cm_staticdep;
	unsigned int cm_dynamicdep;

	CHECK_CPU(44xx, OMAPCONF_ERR_CPU);

	if (!init_done)
		gfx44xx_regtable_init();

	if (mem_read(OMAP4430_CM_GFX_STATICDEP, &cm_staticdep) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_GFX_DYNAMICDEP, &cm_dynamicdep) != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream,
		"| GFX Domain Dependency Configuration | Static | Dynamic |\n");
	fprintf(stream,
		"|-------------------------------------|------------------|\n");
	fprintf(stream,
		"| %-35s | %-6s | %-7s |\n", "IVAHD",
		((extract_bit(cm_staticdep, 2) == 1) ? "En" : "Dis"), "");
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "MEM IF",
		((extract_bit(cm_staticdep, 4) == 1) ? "En" : "Dis"), "");
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L3_1",
		((extract_bit(cm_staticdep, 5) == 1) ? "En" : "Dis"),
		((extract_bit(cm_dynamicdep, 5) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L3_2",
		((extract_bit(cm_staticdep, 6) == 1) ? "En" : "Dis"), "");
	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream, "\n");

	return 0;
}
Exemplo n.º 7
0
/*Add a single (at least 8x over-) sampling of the data and clock
lines to the circular buffer.

Note: dataVal and clockVal represent a single bit, but need not
actually be 0 or 1-- they can be 0 and 15, or 0 and 3, or whatever.
Analog signals (0,1,2, or 3) are even OK.
*/
void JRS_PCM_add_sample(JRS_PCM *p,int clockVal,int dataVal)
{
	p->data_bits[p->end]=dataVal;
	p->clk_bits[p->end]=clockVal;
	p->end++;p->len++;
	p->end&=PCM_bit_mask;

	if (p->len>16)
	{/*We have a long string of data and clock bits-- cut them back a bit*/
		int trough=clock_trough(p);
		setBit(p,extract_bit(p,trough));
		p->len=PCM_bit_mask&(p->end-trough);/*Set the new end-of-buffer to the clock trough*/
		p->prevTrough=trough;
	}
}
Exemplo n.º 8
0
/* Called from syscall or from eBPF program */
static void *trie_lookup_elem(struct bpf_map *map, void *_key)
{
	struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
	struct lpm_trie_node *node, *found = NULL;
	struct bpf_lpm_trie_key *key = _key;

	/* Start walking the trie from the root node ... */

	for (node = rcu_dereference(trie->root); node;) {
		unsigned int next_bit;
		size_t matchlen;

		/* Determine the longest prefix of @node that matches @key.
		 * If it's the maximum possible prefix for this trie, we have
		 * an exact match and can return it directly.
		 */
		matchlen = longest_prefix_match(trie, node, key);
		if (matchlen == trie->max_prefixlen) {
			found = node;
			break;
		}

		/* If the number of bits that match is smaller than the prefix
		 * length of @node, bail out and return the node we have seen
		 * last in the traversal (ie, the parent).
		 */
		if (matchlen < node->prefixlen)
			break;

		/* Consider this node as return candidate unless it is an
		 * artificially added intermediate one.
		 */
		if (!(node->flags & LPM_TREE_NODE_FLAG_IM))
			found = node;

		/* If the node match is fully satisfied, let's see if we can
		 * become more specific. Determine the next bit in the key and
		 * traverse down.
		 */
		next_bit = extract_bit(key->data, node->prefixlen);
		node = rcu_dereference(node->child[next_bit]);
	}

	if (!found)
		return NULL;

	return found->data + trie->data_size;
}
Exemplo n.º 9
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		twl603x_vsel_to_uv
 * @BRIEF		for a given rail, convert SMPS vsel command into voltage
 *			in microvolts. Take into account SMPS voltage offset.
 * @RETURNS		voltage in microvolts corresponding to SMPS vsel command
 * @param[in]		vdd_id: voltage rail
 * @param[in]		vsel: SMPS vsel command (in microvolts)
 * @DESCRIPTION		for a given rail, convert SMPS vsel command into voltage
 *			in microvolts. Take into account SMPS voltage offset.
 *//*------------------------------------------------------------------------ */
unsigned long twl603x_vsel_to_uv(unsigned int vdd_id, unsigned char vsel)
{
	unsigned long smps_offset, uv;
	unsigned int range;

	if (!twl603x_is_twl6035()) {
		if (vsel == 0) {
			uv = 0;
		} else if (vsel > 0x3E) {
			fprintf(stderr, "%s(): warning vsel (0x%02X) "
				"is reserved value, use max (0x3E) instead!\n",
				__func__, vsel);
			vsel = 0x3E;
		}

		smps_offset = twl603x_smps_offset_get(vdd_id);

		if (vsel >= 0x3A)
			uv = twl603x_data.smps_voltage_uv[vsel - 0x3A];
		else
			uv =  smps_offset + ((vsel - 1) * twl603x_data.vstep);
	} else {
		/* VSEL = 7-bit + range (MSB) */
		range = extract_bit(vsel, 7);
		vsel = extract_bitfield(vsel, 0, 7);

		if (vsel == 0) {
			uv = 0;
		} else if (vsel <= 0x06) {
			uv = TWL6035_VOFFSET_UV;
		} else if (vsel >= 0x79) {
			uv = 1650000;
		} else {
			uv = TWL6035_VOFFSET_UV +
				(TWL6035_VSTEP_UV * (vsel - 6));
		}

		/* Apply range multiplier */
		uv = uv << range;
	}

	dprintf("%s(%d, %d (0x%02X))=%lduV\n", __func__,
		vdd_id, vsel, vsel, uv);
	return uv;
}
Exemplo n.º 10
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		vc44xx_raw_cmd_values_get
 * @BRIEF		return ON/ONLP/RET/OFF command values
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_ARG
 * @param[in]		id: voltage domain ID
 * @param[in,out]	vc_regs: Voltage Controller registers content
 * @param[in,out]	cmd_on: ON command value (RETURNED)
 * @param[in,out]	cmd_onlp: ONLP command value (RETURNED)
 * @param[in,out]	cmd_ret: RET command value (RETURNED)
 * @param[in,out]	cmd_off: OFF command value (RETURNED)
 * @DESCRIPTION		return ON/ONLP/RET/OFF command values
 *			WARNING: DO NOT CONSIDER PMIC-SPECIFIC SIZE OF COMMAND.
 *//*------------------------------------------------------------------------ */
short int vc44xx_raw_cmd_values_get(voltdm44xx_id id, vc44xx_registers *vc_regs,
	unsigned char *cmd_on, unsigned char *cmd_onlp,
	unsigned char *cmd_ret, unsigned char *cmd_off)
{
	unsigned int vc_val_cmd;

	CHECK_NULL_ARG(cmd_on, OMAPCONF_ERR_ARG);
	CHECK_NULL_ARG(cmd_onlp, OMAPCONF_ERR_ARG);
	CHECK_NULL_ARG(cmd_ret, OMAPCONF_ERR_ARG);
	CHECK_NULL_ARG(cmd_off, OMAPCONF_ERR_ARG);

	/* Command Values Set Selection */
	switch (id) {
	case OMAP4_VDD_MPU:
		vc_val_cmd = vc_regs->prm_vc_val_cmd_vdd_mpu_l;
		break;

	case OMAP4_VDD_IVA:
		if (extract_bit(vc_regs->prm_vc_cfg_channel,
			VC_CFG_CHANNEL_CMD_VDD_IVA_L_POS) == 1)
			vc_val_cmd = vc_regs->prm_vc_val_cmd_vdd_iva_l;
		else
			vc_val_cmd = vc_regs->prm_vc_val_cmd_vdd_core_l;
		break;

	case OMAP4_VDD_CORE:
		vc_val_cmd = vc_regs->prm_vc_val_cmd_vdd_core_l;
		break;

	default:
		return OMAPCONF_ERR_ARG;
	}

	/* Retrieve commands from registers */
	vc_cmd_values_get(vc_val_cmd,
		cmd_on, cmd_onlp, cmd_ret, cmd_off);

	return 0;
}
Exemplo n.º 11
0
/* Called from syscall or from eBPF program */
static int trie_update_elem(struct bpf_map *map,
			    void *_key, void *value, u64 flags)
{
	struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
	struct lpm_trie_node *node, *im_node = NULL, *new_node = NULL;
	struct lpm_trie_node __rcu **slot;
	struct bpf_lpm_trie_key *key = _key;
	unsigned long irq_flags;
	unsigned int next_bit;
	size_t matchlen = 0;
	int ret = 0;

	if (unlikely(flags > BPF_EXIST))
		return -EINVAL;

	if (key->prefixlen > trie->max_prefixlen)
		return -EINVAL;

	raw_spin_lock_irqsave(&trie->lock, irq_flags);

	/* Allocate and fill a new node */

	if (trie->n_entries == trie->map.max_entries) {
		ret = -ENOSPC;
		goto out;
	}

	new_node = lpm_trie_node_alloc(trie, value);
	if (!new_node) {
		ret = -ENOMEM;
		goto out;
	}

	trie->n_entries++;

	new_node->prefixlen = key->prefixlen;
	RCU_INIT_POINTER(new_node->child[0], NULL);
	RCU_INIT_POINTER(new_node->child[1], NULL);
	memcpy(new_node->data, key->data, trie->data_size);

	/* Now find a slot to attach the new node. To do that, walk the tree
	 * from the root and match as many bits as possible for each node until
	 * we either find an empty slot or a slot that needs to be replaced by
	 * an intermediate node.
	 */
	slot = &trie->root;

	while ((node = rcu_dereference_protected(*slot,
					lockdep_is_held(&trie->lock)))) {
		matchlen = longest_prefix_match(trie, node, key);

		if (node->prefixlen != matchlen ||
		    node->prefixlen == key->prefixlen ||
		    node->prefixlen == trie->max_prefixlen)
			break;

		next_bit = extract_bit(key->data, node->prefixlen);
		slot = &node->child[next_bit];
	}

	/* If the slot is empty (a free child pointer or an empty root),
	 * simply assign the @new_node to that slot and be done.
	 */
	if (!node) {
		rcu_assign_pointer(*slot, new_node);
		goto out;
	}

	/* If the slot we picked already exists, replace it with @new_node
	 * which already has the correct data array set.
	 */
	if (node->prefixlen == matchlen) {
		new_node->child[0] = node->child[0];
		new_node->child[1] = node->child[1];

		if (!(node->flags & LPM_TREE_NODE_FLAG_IM))
			trie->n_entries--;

		rcu_assign_pointer(*slot, new_node);
		kfree_rcu(node, rcu);

		goto out;
	}

	/* If the new node matches the prefix completely, it must be inserted
	 * as an ancestor. Simply insert it between @node and *@slot.
	 */
	if (matchlen == key->prefixlen) {
		next_bit = extract_bit(node->data, matchlen);
		rcu_assign_pointer(new_node->child[next_bit], node);
		rcu_assign_pointer(*slot, new_node);
		goto out;
	}

	im_node = lpm_trie_node_alloc(trie, NULL);
	if (!im_node) {
		ret = -ENOMEM;
		goto out;
	}

	im_node->prefixlen = matchlen;
	im_node->flags |= LPM_TREE_NODE_FLAG_IM;
	memcpy(im_node->data, node->data, trie->data_size);

	/* Now determine which child to install in which slot */
	if (extract_bit(key->data, matchlen)) {
		rcu_assign_pointer(im_node->child[0], node);
		rcu_assign_pointer(im_node->child[1], new_node);
	} else {
		rcu_assign_pointer(im_node->child[0], new_node);
		rcu_assign_pointer(im_node->child[1], node);
	}

	/* Finally, assign the intermediate node to the determined spot */
	rcu_assign_pointer(*slot, im_node);

out:
	if (ret) {
		if (new_node)
			trie->n_entries--;

		kfree(new_node);
		kfree(im_node);
	}

	raw_spin_unlock_irqrestore(&trie->lock, irq_flags);

	return ret;
}
Exemplo n.º 12
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		clk_am335x_rate_get
 * @BRIEF		convert bitfield value from register into string
 * @RETURNS		> 0 clock speed in MHz
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 * @param[in]		clk_id: am335x clock id
 * @param[in]		ignore: do not consider DPLL stop status.
 *			Useful for functions that needs the DPLL output
 *			frequencies whatever its status
 *			(e.g. audit, clock tree, etc)
 * @DESCRIPTION		convert bitfield value from register into string
 *//*------------------------------------------------------------------------ */
double clk_am335x_rate_get(clk_am335x_id clk_id,
	unsigned short ignore)
{
	unsigned int reg_val;
	double src_clk_speed, out_clk_speed;
	clk_am335x_id src_clk_id;
	double div;

	if (!cpu_is_am335x())
		return (double) OMAPCONF_ERR_CPU;

	switch (clk_id) {
	/* 32K CLKS */
	case CLK_AM335X_CLK_32KHZ:
		mem_read(AM335X_CLK32K_DIVRATIO_CTRL, &reg_val);
		if (extract_bit(reg_val, 0) == 0)
			div = 732.4219;
		else
			div = 366.2109;

		src_clk_id = CLK_AM335X_CLK_24;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / div;
		DPRINT_CLK_SPEED3(clk_id, src_clk_id, src_clk_speed, div,
				out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CLK_RC32K:
		out_clk_speed = AM335X_SYS_32K_SPEED;
		DPRINT_CLK_SPEED1(clk_id, out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CLK_32K_RTC:
		out_clk_speed = AM335X_EXT_32K_SPEED;
		DPRINT_CLK_SPEED1(clk_id, out_clk_speed);
		return out_clk_speed;
	/* SYS CLKS */
	case CLK_AM335X_SYS_CLK:
		/* Listed as M_OSC (Master Oscillator) in TRM */
		out_clk_speed = clk_am335x_sysclk_rate_get();
		DPRINT_CLK_SPEED1(clk_id, out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_TCLKIN:
		out_clk_speed = AM335X_TCLKIN_SPEED;
		DPRINT_CLK_SPEED1(clk_id, out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CLK_48:
		src_clk_id = CLK_AM335X_PER_CLKOUTM2;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 4;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CLK_24:
		src_clk_id = CLK_AM335X_CLK_48;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_MHZ_250_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM5;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_MHZ_125_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM5;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_MHZ_50_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM5;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 5;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_MHZ_5_CLK:
		src_clk_id = CLK_AM335X_MHZ_50_CLK;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 10;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	/* DPLL CORE OUTPUT CLKS */
	case CLK_AM335X_CORE_CLKOUTM4:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_CORE, DPLL_AM335X_CORE_CLKOUT_M4, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_CORE CORE_CLKOUT_M4",
			src_clk_speed, out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CORE_CLKOUTM5:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_CORE, DPLL_AM335X_CORE_CLKOUT_M5, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_CORE CORE_CLKOUT_M5",
			src_clk_speed, out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CORE_CLKOUTM6:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_CORE, DPLL_AM335X_CORE_CLKOUT_M6, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_CORE CORE_CLKOUT_M6",
			src_clk_speed, out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_SGX_CORECLK:
		reg_val = reg_read(&am335x_clksel_gfx_fclk);
		if (extract_bit(reg_val, 1) == 0)
			src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		else
			src_clk_id = CLK_AM335X_PER_CLKOUTM2;

		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		div = (double) (1 << extract_bit(reg_val, 0));
		out_clk_speed = src_clk_speed / div;
		DPRINT_CLK_SPEED3(clk_id, src_clk_id, src_clk_speed, div,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_L3S_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_L4_PER_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_L4_WKUPCLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_L3F_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_L4F_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_PRU_ICSS_IEP_CLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_DEBUGSS_CLKA:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_PRU_ICSS_OCP_CLKL:
		reg_val = reg_read(&am335x_clksel_pru_icss_ocp_clk);
		if (extract_bit(reg_val, 0) == 0)
			src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		else
			src_clk_id = CLK_AM335X_DISP_CLKOUT;

		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_CPTS_RFT_CLK:
		reg_val = reg_read(&am335x_cm_cpts_rft_clksel);
		if (extract_bit(reg_val, 0) == 0)
			src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		else
			src_clk_id = CLK_AM335X_CORE_CLKOUTM5;

		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	/* DPLL PER OUTPUT CLKS */
	case CLK_AM335X_USB_PHY_CLK:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_PER, DPLL_AM335X_CLKDCOLDO, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_PER CLKOUT", src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_PER_CLKOUTM2:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_PER, DPLL_AM335X_CLKOUT, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_PER CLKOUT", src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_PRU_ICSS_UART_CLK:
		src_clk_id = CLK_AM335X_PER_CLKOUTM2;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_MMC_CLK:
		src_clk_id = CLK_AM335X_PER_CLKOUTM2;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_SPI_CLK:
		src_clk_id = CLK_AM335X_CLK_48;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_UART_CLK:
		src_clk_id = CLK_AM335X_CLK_48;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_I2C_CLK:
		src_clk_id = CLK_AM335X_CLK_48;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	/* DPLL MPU OUTPUT CLKS */
	case CLK_AM335X_MPU_CLK:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_MPU, DPLL_AM335X_CLKOUT, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_MPU CLKOUT", src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	/* DPLL DISP OUTPUT CLKS */
	case CLK_AM335X_DISP_CLKOUT:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_DISP, DPLL_AM335X_CLKOUT, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_DISP CLKOUT", src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_LCD_CLK:
		reg_val = reg_read(&am335x_clksel_lcdc_pixel_clk);
		if (extract_bitfield(reg_val, 0, 2) == 2)
			src_clk_id = CLK_AM335X_PER_CLKOUTM2;
		else if (extract_bitfield(reg_val, 0, 2) == 1)
			src_clk_id = CLK_AM335X_CORE_CLKOUTM5;
		else
			src_clk_id = CLK_AM335X_DISP_CLKOUT;

		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	/* DPLL DDR OUTPUT CLKS */
	case CLK_AM335X_DDR_CLKOUTM2:
		src_clk_speed = dpll_am335x_output_rate_get(
			DPLL_AM335X_DDR, DPLL_AM335X_CLKOUT, ignore);
		out_clk_speed = src_clk_speed;
		DPRINT_CLK_SPEED2_DPLL(clk_id, "DPLL_DDR CLKOUT", src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_EMIF_M_CLK:
		src_clk_id = CLK_AM335X_DDR_CLKOUTM2;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_GFX_SYSCLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_GFX_MEMCLK:
		src_clk_id = CLK_AM335X_CORE_CLKOUTM4;
		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		out_clk_speed = src_clk_speed / 2;
		DPRINT_CLK_SPEED2(clk_id, src_clk_id, src_clk_speed,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_GFX_CORECLK:
		reg_val = reg_read(&am335x_clksel_gfx_fclk);
		if (extract_bit(reg_val, 1))
			src_clk_id = CLK_AM335X_PER_CLKOUTM2;
		else
			src_clk_id = CLK_AM335X_CORE_CLKOUTM4;

		src_clk_speed = clk_am335x_rate_get(src_clk_id, ignore);
		if (extract_bit(reg_val, 0))
			div = 2;
		else
			div = 1;

		out_clk_speed = src_clk_speed / div;
		DPRINT_CLK_SPEED3(clk_id, src_clk_id, src_clk_speed, div,
			out_clk_speed);
		return out_clk_speed;

	case CLK_AM335X_ID_MAX:
		out_clk_speed = 0;
		DPRINT_CLK_SPEED1(clk_id, out_clk_speed);
		return out_clk_speed;

	default:
		fprintf(stderr, "%s(): invalid clock id %s(%u)!\n",
			__func__, clk_am335x_name_table[clk_id], clk_id);
		return (double) OMAPCONF_ERR_ARG;
	}

	return 0;
}
Exemplo n.º 13
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		tps65217x_vsel_get
 * @BRIEF		return vsel-encoded voltage of a given SMPS voltage rail
 * @RETURNS		VSEL-encoded voltage (8-bit, >= 0) in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_REG_ACCESS
 *			OMAPCONF_ERR_INTERNAL
 * @param[in]		smps_id: voltage domain ID
 * @DESCRIPTION		return vsel-encoded voltage of a given SMPS voltage rail
 *//*------------------------------------------------------------------------ */
int tps65217x_vsel_get(unsigned int smps_id)
{
	int ret;
	unsigned int val, vsel, stat_bit;
	const tps65217x_smps_registers **vdd_smps_regs;
	const tps65217x_smps_registers *smps_regs;

	CHECK_ARG_LESS_THAN(smps_id, 5, OMAPCONF_ERR_ARG);

	/* Retrive SMPS registers addresses */
	vdd_smps_regs = tps65217x_smps_vdd_am335x[smps_id];
	if (vdd_smps_regs == NULL)
		return OMAPCONF_ERR_INTERNAL;
	smps_regs = *vdd_smps_regs;
	if (smps_regs == NULL)
		return OMAPCONF_ERR_INTERNAL;

	dprintf("%s(): smps_id=%u  ADDR: ctrl=0x%02X tstep=0x%02X "
		"voltage=0x%02X\n", __func__, smps_id, smps_regs->ctrl,
		smps_regs->tstep, smps_regs->voltage);

	/* Check SMPS Status */
	if (smps_regs->ctrl == -1) {
		dprintf("%s(): SMPSxx_CTRL addr=-1!!!\n", __func__);
		return OMAPCONF_ERR_INTERNAL;
	}
	ret = i2cget(TPS65217X_I2C_BUS, TPS65217X_ID0_ADDR,
		smps_regs->ctrl, &val);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	/* MPU and CORE share same enable register */
	switch (chip_type) {
	case 6:
		/*
		 * TPS65217A is for AM335X ZCE package
		 * MPU and CORE are combined for this package
		 */
		stat_bit = 3;
		break;
	case 7:
		if (smps_id == 0)
			stat_bit = 4;
		else
			stat_bit = 3;
		break;
	case 8:
	case 9:
		if (smps_id == 0)
			stat_bit = 3;
		else
			stat_bit = 4;
		break;
	default:
		fprintf(stderr, "%s(): should not reach here?!\n", __func__);
		return OMAPCONF_ERR_INTERNAL;
	}
	dprintf("%s(): SMPSxx_CTRL=0x%02X\n", __func__, val);
	if (extract_bit(val, stat_bit) == 0) {
		dprintf("(%s(): warning SMPS is OFF\n", __func__);
		return 0;
	}

	/* Check SMPS voltage controlled by registers, not resource pins */
	ret = i2cget(TPS65217X_I2C_BUS, TPS65217X_ID0_ADDR,
		smps_regs->voltage, &val);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (extract_bit(val, 7) == 1) {
		dprintf("%s(): SMPS voltage controlled by resource pins\n",
			__func__);
		return OMAPCONF_ERR_NOT_AVAILABLE;
	}

	/* Retrieve VSEL (6-bits) from relevant register */
	if (smps_regs->voltage != -1) {
		ret = i2cget(TPS65217X_I2C_BUS, TPS65217X_ID0_ADDR,
			smps_regs->voltage, &val);
		if (ret != 0)
			return OMAPCONF_ERR_REG_ACCESS;
		dprintf("%s(): SMPSxx_VOLTAGE=0x%02X\n", __func__, val);
	} else {
		dprintf("%s(): SMPSxx_VOLTAGE addr=-1!!!\n", __func__);
		return OMAPCONF_ERR_INTERNAL;
	}
	vsel = extract_bitfield(val, 0, TPS65217X_VSEL_LEN);
	dprintf("%s(): SMPSxx_VOLTAGE=0x%02X SMPSxx_VOLTAGE.VSEL=0x%02X\n",
		__func__, val, vsel);

	return vsel;
}
Exemplo n.º 14
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		core44xx_dependency_show
 * @BRIEF		analyse CORE dependency configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in, out]	stream: output file stream
 * @DESCRIPTION		analyse CORE dependency configuration
 *//*------------------------------------------------------------------------ */
int core44xx_dependency_show(FILE *stream)
{
	unsigned int cm_l3_1_dynamicdep;
	unsigned int cm_l3_2_dynamicdep;
	unsigned int cm_mpu_m3_staticdep;
	unsigned int cm_mpu_m3_dynamicdep;
	unsigned int cm_sdma_staticdep;
	unsigned int cm_sdma_dynamicdep;
	unsigned int cm_c2c_staticdep;
	unsigned int cm_c2c_dynamicdep;
	unsigned int cm_l4cfg_dynamicdep;
	int ret;

	CHECK_CPU(44xx, OMAPCONF_ERR_CPU);

	if (!init_done)
		core44xx_regtable_init();

	ret = mem_read(OMAP4430_CM_L3_1_DYNAMICDEP, &cm_l3_1_dynamicdep);
	ret += mem_read(OMAP4430_CM_L3_2_DYNAMICDEP, &cm_l3_2_dynamicdep);
	ret += mem_read(OMAP4430_CM_MPU_M3_STATICDEP, &cm_mpu_m3_staticdep);
	ret += mem_read(OMAP4430_CM_MPU_M3_DYNAMICDEP, &cm_mpu_m3_dynamicdep);
	ret += mem_read(OMAP4430_CM_SDMA_STATICDEP, &cm_sdma_staticdep);
	ret += mem_read(OMAP4430_CM_SDMA_DYNAMICDEP, &cm_sdma_dynamicdep);
	ret += mem_read(OMAP4430_CM_C2C_STATICDEP, &cm_c2c_staticdep);
	ret += mem_read(OMAP4430_CM_C2C_DYNAMICDEP, &cm_c2c_dynamicdep);
	ret += mem_read(OMAP4430_CM_L4CFG_DYNAMICDEP, &cm_l4cfg_dynamicdep);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	fprintf(stream,
		"|-------------------------------------------------------------"
		"-------------|\n");
	fprintf(stream,
		"| CORE Domain Dependency Configuration (Static/Dynamic)       "
		"             |\n");
	fprintf(stream,
		"|-------------------------------------------------------------"
		"-------------|\n");
	fprintf(stream,
		"|              |                           FROM:              "
		"             |\n");
	fprintf(stream,
		"|              |  L3_1   |  L3_2   | MPU_M3  |  SDMA   |   C2C"
		"   |  L4CFG  |\n");
	fprintf(stream,
		"|              |Stat|Dyn |Stat|Dyn |Stat|Dyn |Stat|Dyn |Stat|"
		"Dyn |Stat|Dyn |\n");
	fprintf(stream,
		"|-------------------------------------------------------------"
		"-------------|\n");
	fprintf(stream,
		"|    TOWARDS:  |    |    |    |    |    |    |    |    |    | "
		"   |    |    |\n");
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"MPU_M3",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 0) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 0) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"DSP",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 1) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 1) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"IVAHD",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 2) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 2) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 2) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 2) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"ABE",
		"", /* not implemented */
		((extract_bit(cm_l3_1_dynamicdep, 3) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 3) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 3) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 3) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"MEM IF",
		"", /* not implemented */
		((extract_bit(cm_l3_1_dynamicdep, 4) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 4) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 4) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 4) == 1) ? "En" : "Dis"),
		((extract_bit(cm_c2c_dynamicdep, 4) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 4) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L3_1",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 5) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 5) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 5) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 5) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 5) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L3_2",
		"", /* not implemented */
		((extract_bit(cm_l3_1_dynamicdep, 6) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 6) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_dynamicdep, 6) == 1) ? "En" : "Dis"),
		((extract_bit(cm_sdma_staticdep, 6) == 1) ? "En" : "Dis"),
		((extract_bit(cm_sdma_dynamicdep, 6) == 1) ? "En" : "Dis"),
		((extract_bit(cm_c2c_staticdep, 6) == 1) ? "En" : "Dis"),
		((extract_bit(cm_c2c_dynamicdep, 6) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 6) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L3INIT",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 7) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 7) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 7) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 7) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 7) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"DSS",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 8) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 8) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 8) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 8) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"ISS",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 9) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 9) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_dynamicdep, 9) == 1) ? "En" : "Dis"),
		((extract_bit(cm_sdma_staticdep, 9) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 9) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"GFX",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 10) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 10) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"SDMA",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 11) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 11) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L4CFG",
		"", /* not implemented */
		((extract_bit(cm_l3_1_dynamicdep, 12) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 12) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 12) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 12) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L4PER",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 13) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 13) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 13) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_c2c_staticdep, 13) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L4SEC",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 14) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_m3_staticdep, 14) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 14) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"" /* not implemented */);
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"L4WKUP",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 15) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		((extract_bit(cm_sdma_staticdep, 15) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 15) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"ALWONCORE",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 16) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 16) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"CEFUSE",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_mpu_m3_staticdep, 17) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 17) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s"
		"|%-3s | %-3s|%-3s |\n",
		"C2C",
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l3_2_dynamicdep, 18) == 1) ? "En" : "Dis"),
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		"", /* not implemented */
		((extract_bit(cm_l4cfg_dynamicdep, 18) == 1) ? "En" : "Dis"));
	if (!cpu_is_omap4430())
		fprintf(stream,
			"| %-12s | %-3s|%-3s | %-3s|%-3s | %-3s|%-3s | %-3s|"
			"%-3s | %-3s|%-3s | %-3s|%-3s |\n",
			"MPU",
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			"", /* not implemented */
			((extract_bit(cm_l4cfg_dynamicdep, 19) == 1) ?
				"En" : "Dis"));

	fprintf(stream,
		"|-------------------------------------------------------------"
		"-------------|\n");
	fprintf(stream,
		"| Dynamic Dep  |         |         |         |         |      "
		"   |         |\n");
	fprintf(stream,
		"| %-12s |      %-2d |      %-2d |     %-2d  |         |      "
		"%-2d |      %-2d |\n",
		"Window Size",
		extract_bitfield(cm_l3_1_dynamicdep, 24, 4),
		extract_bitfield(cm_l3_2_dynamicdep, 24, 4),
		extract_bitfield(cm_mpu_m3_dynamicdep, 24, 4),
		extract_bitfield(cm_c2c_dynamicdep, 24, 4),
		extract_bitfield(cm_l4cfg_dynamicdep, 24, 4));
	fprintf(stream,
		"|------------------------------------------------------------"
		"--------------|\n\n");

	return 0;
}
Exemplo n.º 15
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		dpll_settings_extract
 * @BRIEF		extract DPLL settings from registers
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]		id: valid DPLL ID
 * @param[in]		type: DPLL type
 * @param[in]		dpll_regs: dpll registers to extract settings from
 * @param[in,out]	settings: struct with extracted DPLL settings
 * @DESCRIPTION		extract DPLL settings from registers
 *//*------------------------------------------------------------------------ */
int dpll_settings_extract(unsigned int id, dpll_type type,
	dpll_settings_regs *dpll_regs, dpll_settings *settings)
{
	unsigned int val;
	CHECK_NULL_ARG(dpll_regs, OMAPCONF_ERR_ARG);
	CHECK_NULL_ARG(settings, OMAPCONF_ERR_ARG);

	settings->id = id;
	settings->type = type;

	/* Extract data from CM_CLKMODE_DPLL_xyz */
	val = reg_read(dpll_regs->cm_clkmode_dpll);
	dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
		(dpll_regs->cm_clkmode_dpll)->name, val);

	settings->mode = extract_bitfield(val, 0, 3);
	(settings->ramp).ramp_level = extract_bitfield(val, 3, 2);
	(settings->ramp).ramp_rate = 1 << (extract_bitfield(val,
		5, 3) + 1);
	settings->driftguard_en = extract_bit(val, 8);
	(settings->ramp).relock_ramp_en = extract_bit(val, 9);
	settings->lpmode_en = extract_bit(val, 10);
	settings->regm4xen = extract_bit(val, 11);
	(settings->SSC).mode = extract_bit(val, 12);
	(settings->SSC).ack = extract_bit(val, 13);
	(settings->SSC).downspread = extract_bit(val, 14);

	dprintf("%s():   mode=0x%X (%s), lp_mode=%u, REGM4XEN=%u, "
		"DRIFTGUARD_EN=%u\n", __func__, settings->mode,
		dpll_mode_name_get(settings->mode), settings->lpmode_en,
		settings->regm4xen, settings->driftguard_en);
	dprintf("%s():   RAMP_EN=%u, RAMP_RATE=%uxREFCLK, RAMP_LEVEL=%u (%s)\n",
		__func__, (settings->ramp).relock_ramp_en,
		(settings->ramp).ramp_rate, (settings->ramp).ramp_level,
		dpll_ramp_level_name_get((settings->ramp).ramp_level));
	dprintf("%s():   SSC_EN=%u, SSC_ACK=%u, SSC_DOWNSPREAD=%u\n",
		__func__, (settings->SSC).mode,
		(settings->SSC).ack, (settings->SSC).downspread);

	/* Extract data from CM_IDLEST_DPLL_xyz */
	val = reg_read(dpll_regs->cm_idlest_dpll);
	dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
		(dpll_regs->cm_idlest_dpll)->name, val);

	settings->lock_status = extract_bit(val, 0);
	settings->mn_bypass_status = extract_bit(val, 8);

	dprintf("%s():   ST_DPLL_CLK=%u, ST_MN_BYPASS=%u\n",
		__func__, settings->lock_status, settings->mn_bypass_status);

	/* Extract data from CM_AUTOIDLE_DPLL_xyz */
	val = reg_read(dpll_regs->cm_autoidle_dpll);
	dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
		(dpll_regs->cm_autoidle_dpll)->name, val);

	settings->autoidle_mode = extract_bitfield(val, 0, 3);

	dprintf("%s():   AUTO_DPLL_MODE=%u (%s)\n", __func__,
		settings->autoidle_mode,
		dpll_autoidle_mode_name_get(settings->autoidle_mode));

	/* Extract data from CM_CLKSEL_DPLL_xyz */
	val = reg_read(dpll_regs->cm_clksel_dpll);
	dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
		(dpll_regs->cm_clksel_dpll)->name, val);

	if (settings->type == DPLL_TYPE_A) {
		(settings->MN).N = extract_bitfield(val, 0, 7);
		(settings->MN).M = extract_bitfield(val, 8, 11);
		settings->clkouthif_src = extract_bit(val, 20);
		if (!cpu_is_omap4430()) {
			(settings->DCC).en = extract_bit(val, 22);
			(settings->DCC).count = extract_bitfield(val, 24, 8);
		} else {
			(settings->DCC).en = 0;
			(settings->DCC).count = 0;
		}
		settings->bypass_clk = extract_bit(val, 23);
	} else {
		(settings->MN).N = extract_bitfield(val, 0, 8);
		(settings->MN).M = extract_bitfield(val, 8, 12);
		settings->selfreqdco = extract_bit(val, 21);
		settings->sd_div = extract_bitfield(val, 24, 8);
		dprintf("%s():   SELFREQDCO=%u, SD_DIV=%u\n", __func__,
			settings->selfreqdco, settings->sd_div);
	}
	dprintf("%s():   M=%u, N=%u, CLKOUTHIF_CLK=%u, BP_CLK=%u\n", __func__,
		(settings->MN).M, (settings->MN).N, settings->clkouthif_src,
		settings->bypass_clk);
	dprintf("%s():   DCC_EN=%u, DCC_COUNT=%u\n", __func__,
		(settings->DCC).en, (settings->DCC).count);

	/* Extract data from CM_BYPCLK_DPLL_XYZ */
	if ((void *) dpll_regs->cm_bypclk_dpll != NULL) {
		val = reg_read(dpll_regs->cm_bypclk_dpll);
		dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
			(dpll_regs->cm_bypclk_dpll)->name, val);

		settings->bypass_clk_div = 1 << extract_bitfield(val, 0, 2);

		dprintf("%s():   BP_CLK_DIV=%u\n", __func__,
			settings->bypass_clk_div);

	} else {
		settings->bypass_clk_div = 1;

		dprintf("%s(): BYPCLK register does not exist.\n", __func__);
	}

	/* Extract data from CM_DIV_M2_DPLL_XYZ */
	if ((void *) dpll_regs->cm_div_m2_dpll != NULL) {
		val = reg_read(dpll_regs->cm_div_m2_dpll);
		dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
			(dpll_regs->cm_div_m2_dpll)->name, val);

		(settings->MN).M2_present = 1;
		if (settings->type == DPLL_TYPE_A) {
			(settings->MN).M2 = extract_bitfield(val, 0, 5);
			(settings->MN).X2_M2_autogating =
				!extract_bit(val, 10);
			(settings->MN).X2_M2_clkout_st = extract_bit(val, 11);
		} else {
			(settings->MN).M2 = extract_bitfield(val, 0, 7);
		}
		(settings->MN).M2_autogating = !extract_bit(val, 8);
		(settings->MN).M2_clkout_st = extract_bit(val, 9);

		dprintf("%s():   M2 DIV=%u, AUTOGATING=%u, CLKST=%u\n",
			__func__, (settings->MN).M2,
			(settings->MN).M2_autogating,
			(settings->MN).M2_clkout_st);
		if (settings->type == DPLL_TYPE_A) {
			dprintf("%s():   X2_M2 AUTOGATING=%u, CLKST=%u\n",
				__func__, (settings->MN).X2_M2_autogating,
				(settings->MN).X2_M2_clkout_st);
		}
	} else {
		(settings->MN).M2_present = 0;

		dprintf("%s(): DIV_M2 register does not exist.\n", __func__);
	}

	/* Extract data from CM_DIV_M3_DPLL_XYZ */
	if ((void *) dpll_regs->cm_div_m3_dpll != NULL) {
		val = reg_read(dpll_regs->cm_div_m3_dpll);
		dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
			(dpll_regs->cm_div_m3_dpll)->name, val);

		(settings->MN).M3_present = 1;
		(settings->MN).M3 = extract_bitfield(val, 0, 5);
		(settings->MN).X2_M3_autogating = !extract_bit(val, 8);
		(settings->MN).X2_M3_clkout_st = extract_bit(val, 9);

		dprintf("%s():   X2_M3 DIV=%u, AUTOGATING=%u, CLKST=%u\n",
			__func__, (settings->MN).M3,
			(settings->MN).X2_M3_autogating,
			(settings->MN).X2_M3_clkout_st);
	} else {
		(settings->MN).M3_present = 0;

		dprintf("%s(): DIV_M3 register does not exist.\n", __func__);
	}

	/* Extract data from CM_DELTAMSTEP_DPLL_xyz */
	val = reg_read(dpll_regs->cm_ssc_deltamstep_dpll);
	dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
		(dpll_regs->cm_ssc_deltamstep_dpll)->name, val);

	(settings->SSC).deltaMStep = extract_bitfield(val, 0, 20);

	dprintf("%s():   deltaMStep=0x%X\n", __func__,
		(settings->SSC).deltaMStep);

	/* Extract data from CM_MODFREQDIV_DPLL_xyz */
	val = reg_read(dpll_regs->cm_ssc_modfreqdiv_dpll);
	dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
		(dpll_regs->cm_ssc_modfreqdiv_dpll)->name, val);

	(settings->SSC).mantissa = extract_bitfield(val, 0, 7);
	(settings->SSC).exponent = extract_bitfield(val, 8, 3);

	dprintf("%s():   mantissa=0x%X, exponent=0x%X\n", __func__,
		(settings->SSC).mantissa, (settings->SSC).exponent);

	/* Extract data from CM_CLKDCOLDO_DPLL_xyz */
	if ((void *) dpll_regs->cm_clkdcoldo_dpll != NULL) {
		val = reg_read(dpll_regs->cm_clkdcoldo_dpll);
		dprintf("%s(): DPLL reg: %s = 0x%08X\n", __func__,
			(dpll_regs->cm_clkdcoldo_dpll)->name, val);

		(settings->MN).clkdcoldo_autogating = !extract_bit(val, 8);
		(settings->MN).clkdcoldo_clkout_st = extract_bit(val, 9);

		dprintf("%s():   CLKDCOLDO AUTOGATING=%u, CLKST=%u\n",
			__func__,
			(settings->MN).clkdcoldo_autogating,
			(settings->MN).clkdcoldo_clkout_st);
	}
	return 0;
}
Exemplo n.º 16
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		pwrdm54xx_config_show
 * @BRIEF		decode and display power domain configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 * @param[in,out]	stream: output file
 * @param[in]		id: valid power domain ID
 * @DESCRIPTION		decode and display power domain configuration
 *//*------------------------------------------------------------------------ */
int pwrdm54xx_config_show(FILE *stream, pwrdm54xx_id id)
{
	pwrdm_state st_last, st_curr, st_tgt;

	CHECK_CPU(54xx, OMAPCONF_ERR_CPU);
	CHECK_NULL_ARG(stream, OMAPCONF_ERR_ARG);
	CHECK_ARG_LESS_THAN(id, PWRDM54XX_ID_MAX, OMAPCONF_ERR_ARG);
	char s1[32], s2[32];
	reg *pm_pwrstctrl_reg;
	reg *pm_pwrstst_reg;
	unsigned int pm_pwrstctrl;
	unsigned int pm_pwrstst;
	char s[64];

	fprintf(stream, "|---------------------------------------------------"
		"-------------|\n");
	strcpy(s, pwrdm54xx_name_get(id));
	strcat(s, " Power Domain Configuration");
	fprintf(stream, "| %-62s |\n", s);
	fprintf(stream, "|---------------------------------------------------"
		"-------------|\n");
	fprintf(stream, "| %-32s | %-7s | %-7s | %-7s |\n", "Power State",
		"Current", "Target", "Last");
	fprintf(stream, "|----------------------------------|---------|------"
		"---|---------|\n");

	st_last = pwrdm54xx_state_get(id, PWRDM_STATE_PREVIOUS);
	st_curr = pwrdm54xx_state_get(id, PWRDM_STATE_CURRENT);
	st_tgt = pwrdm54xx_state_get(id, PWRDM_STATE_TARGET);
	fprintf(stream, "| %-32s | %-7s | %-7s | %-7s |\n",
		"Domain", pwrdm_state_name_get(st_curr),
		pwrdm_state_name_get(st_tgt), pwrdm_state_name_get(st_last));

	if ((!pwrdm54xx_has_logic_ret_state_ctrl_bit(id)) &&
		(!pwrdm54xx_has_pwrstst_reg(id)))
		goto pwrdm54xx_config_show_mem;

	st_tgt = pwrdm54xx_target_logic_ret_state_get(id);
	if (st_tgt != PWRDM_STATE_MAX)
		strcpy(s1, pwrdm_state_name_get(st_tgt));
	else
		strcpy(s1, "");
	st_curr = pwrdm54xx_logic_state_get(id);
	if (st_curr != PWRDM_STATE_MAX)
		strcpy(s2, pwrdm_state_name_get(st_curr));
	else
		strcpy(s2, "");
	fprintf(stream, "| %-32s | %-7s | %-7s |         |\n", "Logic", s2, s1);

pwrdm54xx_config_show_mem:
	if (pwrdm54xx_has_pwrstctrl_reg(id)) {
		pm_pwrstctrl_reg = pwrdm54xx_pwrstctrl_reg_get(id);
		pm_pwrstctrl = reg_read(pm_pwrstctrl_reg);
	}
	if (pwrdm54xx_has_pwrstst_reg(id)) {
		pm_pwrstst_reg = pwrdm54xx_pwrstst_reg_get(id);
		pm_pwrstst = reg_read(pm_pwrstst_reg);
	}

	switch (id) {
	case PWRDM54XX_EMU:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    EMU bank", pwrdm_state_name_get(st_curr), "");
		break;
	case PWRDM54XX_CAM:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    MEM", pwrdm_state_name_get(st_curr), "");
		break;
	case PWRDM54XX_CORE:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 12, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 12);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    OCP_WP/UNIPRO1/DMM bank2",
			pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 10, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 11);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    IPU S$", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 8, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 10);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    IPU L2RAM", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 6, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 9);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    OCMRAM", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 8);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    DMA/ICR/DMM bank1", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_DSS:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 8, 2);
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    MEM", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_L3_INIT:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 6, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 9);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    L3INIT bank2", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 8);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    L3INIT bank1", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_L4_PER:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 6, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 9);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    NONRETAINED bank", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 8);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    RETAINED bank", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_ABE:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 8);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    AESS", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 8, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 10);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    PERIPH", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_DSP:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 8, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 10);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    EDMA", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 6, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 9);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    L2$", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 8);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    L1$", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_GPU:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    MEM", pwrdm_state_name_get(st_curr), "");
		break;
	case PWRDM54XX_IVA:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 10, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 11);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    TCM2", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 8, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 10);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    TCM1", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 6, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 9);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    SL2", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));

		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 4, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 8);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    HWA", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;
	case PWRDM54XX_MPU:
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"Memory", "", "");
		st_curr = (pwrdm_state) extract_bitfield(pm_pwrstst, 6, 2);
		st_tgt = (pwrdm_state) extract_bit(pm_pwrstctrl, 9);
		fprintf(stream, "| %-32s | %-7s | %-7s |         |\n",
			"    L2$", pwrdm_state_name_get(st_curr),
			pwrdm_state_name_get(st_tgt));
		break;

	default:
		/* Nothing to print */
		break;
	}

	if (pwrdm54xx_has_pwrstst_reg(id)) {
		fprintf(stream, "|---------------------------------------------"
			"-------------------|\n");

		fprintf(stream, "| %-32s | %-27s |\n",
			"Ongoing Power Transition?",
			((pwrdm54xx_in_transition(id) == 1) ? "YES" : "NO"));
	}
	fprintf(stream, "|---------------------------------------------------"
		"-------------|\n\n");
	return 0;
}
Exemplo n.º 17
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		mpu44xx_dependency_show
 * @BRIEF		analyse MPU dependency configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]		stream: output file stream
 * @DESCRIPTION		analyse MPU dependency configuration
 *//*------------------------------------------------------------------------ */
int mpu44xx_dependency_show(FILE *stream)
{
	unsigned int cm_mpu_staticdep;
	unsigned int cm_mpu_dynamicdep;

	CHECK_CPU(44xx, OMAPCONF_ERR_CPU);

	if (!init_done)
		mpu44xx_regtable_init();

	if (mem_read(OMAP4430_CM_MPU_STATICDEP, &cm_mpu_staticdep) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_MPU_DYNAMICDEP, &cm_mpu_dynamicdep) != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream,
		"| MPU Domain Dependency Configuration | Static | Dynamic |\n");
	fprintf(stream,
		"|-------------------------------------|------------------|\n");
	fprintf(stream,
		"| %-35s | %-6s | %-7s |\n", "MPU_M3",
		((extract_bit(cm_mpu_staticdep, 0) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 0) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "DSP",
		((extract_bit(cm_mpu_staticdep, 1) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 1) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "IVAHD",
		((extract_bit(cm_mpu_staticdep, 2) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 2) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "ABE",
		((extract_bit(cm_mpu_staticdep, 3) == 1) ? "En" : "Dis"),
		"En");
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "MEM IF",
		((extract_bit(cm_mpu_staticdep, 4) == 1) ? "En" : "Dis"),
		"En");
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L3_1",
		((extract_bit(cm_mpu_staticdep, 5) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 5) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L3_2",
		((extract_bit(cm_mpu_staticdep, 6) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 6) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L3INIT",
		((extract_bit(cm_mpu_staticdep, 7) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 7) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "DSS",
		((extract_bit(cm_mpu_staticdep, 8) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 8) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "ISS",
		((extract_bit(cm_mpu_staticdep, 9) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 9) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "GFX",
		((extract_bit(cm_mpu_staticdep, 10) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 10) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "SDMA",
		"Dis",
		((extract_bit(cm_mpu_dynamicdep, 11) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L4CFG",
		((extract_bit(cm_mpu_staticdep, 12) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 12) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L4PER",
		((extract_bit(cm_mpu_staticdep, 13) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 13) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L4SEC",
		((extract_bit(cm_mpu_staticdep, 14) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 14) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "L4WKUP",
		((extract_bit(cm_mpu_staticdep, 15) == 1) ? "En" : "Dis"),
		((extract_bit(cm_mpu_dynamicdep, 15) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "ALWONCORE",
		"Dis",
		((extract_bit(cm_mpu_dynamicdep, 16) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "CEFUSE",
		"Dis",
		((extract_bit(cm_mpu_dynamicdep, 17) == 1) ? "En" : "Dis"));
	fprintf(stream, "| %-35s | %-6s | %-7s |\n", "C2C",
		"Dis",
		((extract_bit(cm_mpu_dynamicdep, 18) == 1) ? "En" : "Dis"));
	fprintf(stream,
		"|--------------------------------------------------------|\n");
	fprintf(stream,
		"| %-44s | %-7d |\n", "Window Size",
		extract_bitfield(cm_mpu_dynamicdep, 24, 4));
	fprintf(stream,
		"|--------------------------------------------------------|\n");

	fprintf(stream, "\n");
	return 0;
}
Exemplo n.º 18
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		mpu44xx_irq_show
 * @BRIEF		analyse MPU PRM IRQ configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]
 * @DESCRIPTION		analyse MPU PRM IRQ configuration
 *//*------------------------------------------------------------------------ */
int mpu44xx_irq_show(FILE *stream)
{
	unsigned int prm_irqstatus_mpu;
	unsigned int prm_irqstatus_mpu_2;
	unsigned int prm_irqenable_mpu;
	unsigned int prm_irqenable_mpu_2;
	int ret = 0;
	unsigned short i;
	char mode[8], status[8];

	CHECK_CPU(44xx, OMAPCONF_ERR_CPU);

	if (!init_done)
		mpu44xx_regtable_init();

	ret += mem_read(OMAP4430_PRM_IRQSTATUS_MPU, &prm_irqstatus_mpu);
	ret += mem_read(OMAP4430_PRM_IRQSTATUS_MPU_2, &prm_irqstatus_mpu_2);
	ret += mem_read(OMAP4430_PRM_IRQENABLE_MPU, &prm_irqenable_mpu);
	ret += mem_read(OMAP4430_PRM_IRQENABLE_MPU_2, &prm_irqenable_mpu_2);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	dprintf("OMAP4430_PRM_IRQSTATUS_MPU = 0x%x\n", prm_irqstatus_mpu);
	dprintf("OMAP4430_PRM_IRQSTATUS_MPU_2 = 0x%x\n", prm_irqstatus_mpu_2);
	dprintf("OMAP4430_PRM_IRQENABLE_MPU = 0x%x\n", prm_irqenable_mpu);
	dprintf("OMAP4430_PRM_IRQENABLE_MPU_2 = 0x%x\n", prm_irqenable_mpu_2);

	fprintf(stream, "|------------------------------------------------|\n");
	fprintf(stream, "| MPU PRM IRQ Configuration                      |\n");
	fprintf(stream, "|------------------------------------------------|\n");
	fprintf(stream, "| PRM IRQ Name               | Mode    | Status  |\n");
	fprintf(stream, "|------------------------------------------------|\n");
	for (i = 0; i < 32; i++) {
		if (strcmp("RESERVED", omap44xx_prm_irq_names[i]) != 0) {
			OMAPCONF_COND_STRCPY(extract_bit(prm_irqstatus_mpu,
				i) == 1, status, "Pending", "");
			OMAPCONF_COND_STRCPY(extract_bit(prm_irqenable_mpu,
				i) == 1, mode, "Enabled", "Masked");
			fprintf(stream, "| (%2d) %-21s | %-7s | %-7s |\n", i,
				omap44xx_prm_irq_names[i],
				mode,
				status);
		}
	}
	for (i = 32; i < OMAP44XX_PRM_IRQ_MAX_NBR; i++) {
		if (strcmp("RESERVED", omap44xx_prm_irq_names[i]) != 0) {
			OMAPCONF_COND_STRCPY(extract_bit(prm_irqstatus_mpu_2,
				i - 32) == 1, status, "Pending", "");
			OMAPCONF_COND_STRCPY(extract_bit(prm_irqenable_mpu_2,
				i - 32) == 1, mode, "Enabled", "Masked");
			fprintf(stream, "| (%2d) %-21s | %-7s | %-7s |\n", i,
				omap44xx_prm_irq_names[i],
				mode,
				status);
		}
	}
	fprintf(stream,
		"|------------------------------------------------|\n\n");

	return 0;
}
Exemplo n.º 19
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		twl603x_uvoltage_set
 * @BRIEF		set voltage of a given SMPS voltage rail.
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_REG_ACCESS
 *			OMAPCONF_ERR_INTERNAL
 * @param[in]		vdd_id: voltage domain ID
 * @param[in]		uv: voltage to be set (in micro-volt)
 * @DESCRIPTION		set voltage of a given SMPS voltage rail, in micro-volt.
 *			NB: not supported by TWL6030/TWL6032.
 *//*------------------------------------------------------------------------ */
int twl603x_uvoltage_set(unsigned int vdd_id, unsigned long uv)
{
	int ret;
	unsigned int val;
	unsigned char vsel;
	const twl6035_smps_registers **vdd_smps_regs;
	const twl6035_smps_registers *smps_regs;

	if (!twl603x_is_twl6035())
		return OMAPCONF_ERR_CPU;
	CHECK_ARG_LESS_THAN(vdd_id, 3, OMAPCONF_ERR_ARG);

	/* Retrive SMPS registers addresses */
	vdd_smps_regs = twl6035_smps_vdd54xx[vdd_id];
	if (vdd_smps_regs == NULL)
		return OMAPCONF_ERR_INTERNAL;
	smps_regs = *vdd_smps_regs;
	if (smps_regs == NULL)
		return OMAPCONF_ERR_INTERNAL;

	dprintf("%s(): vdd_id=%u  ADDR: ctrl=0x%02X tstep=0x%02X force=0x%02X "
		"voltage=0x%02X\n", __func__, vdd_id, smps_regs->ctrl,
		smps_regs->tstep, smps_regs->force, smps_regs->voltage);

	/* Check SMPS Status */
	/* FIXME: create dedicated API */
	if (smps_regs->ctrl == -1) {
		dprintf("%s(): SMPSxx_CTRL addr=-1!!!\n", __func__);
		return OMAPCONF_ERR_INTERNAL;
	}
	ret = i2cget(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
		smps_regs->ctrl, &val);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	dprintf("%s(): SMPSxx_CTRL=0x%02X\n", __func__, val);
	if (extract_bitfield(val, 4, 2) == 0) {
		dprintf("(%s(): SMPS is OFF\n", __func__);
		return OMAPCONF_ERR_NOT_AVAILABLE;
	}

	/* Make sure SMPSxx_CTRL.ROOF_FLOOR_EN=0 */
	/* FIXME: create dedicated API */
	if (extract_bit(val, 6) == 1) {
		dprintf("%s(): SMPS voltage controlled by resource pins, "
			"clearing ROOF_FLOOR_EN bit.\n", __func__);
		/* Clear ROOF_FLOOR_EN bit (6) */
		val = val & 0xBF;
		ret = i2cset(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
			smps_regs->ctrl, (unsigned int) val);
		if (ret != 0)
			return OMAPCONF_ERR_REG_ACCESS;
		dprintf("%s(): SMPS voltage now controlled by "
			"SMPS12_FORCE.CMD bit.\n", __func__);
	} else {
		dprintf("%s(): SMPS voltage controlled by "
			"SMPS12_FORCE.CMD bit.\n", __func__);
	}

	/* Convert voltage to VSEL */
	vsel = twl603x_uv_to_vsel(vdd_id, uv);
	dprintf("%s(): uv=%lu vsel=0x%02X\n", __func__, uv, vsel);

	/* Write VSEL to SMPSxx_VOLTAGE */
	ret = i2cset(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
			smps_regs->voltage, (unsigned int) vsel);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	/*
	 * Try to switch voltage control to SMPSxx_FORCE register (if exists)
	 * so that voltage will not be overriden by kernel during
	 * DVFS, AVS or power transition.
	 */
	if (smps_regs->force != -1) {
		dprintf("%s(): SMPSxx_FORCE exists, switching control.\n",
			__func__);
		/* Clear bit 7 (CMD) */
		val = vsel & 0x7F;
		ret = i2cset(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
			smps_regs->force, (unsigned int) val);
	} else {
		dprintf("%s(): SMPSxx_FORCE does not exist.\n", __func__);
		ret = 0;
	}

	return ret;
}
Exemplo n.º 20
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		mpu44xx_config_show
 * @BRIEF		analyze MPU power configuration
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]		stream: output file stream
 * @DESCRIPTION		analyze MPU power configuration
 *//*------------------------------------------------------------------------ */
int mpu44xx_config_show(FILE *stream)
{
	unsigned int pm_pda_cpu0_pwrstctrl;
	unsigned int pm_pda_cpu0_pwrstst;
	unsigned int rm_pda_cpu0_context;
	unsigned int cm_pda_cpu0_clkctrl;
	unsigned int cm_pda_cpu0_clkstctrl;
	unsigned int pm_pda_cpu1_pwrstctrl;
	unsigned int pm_pda_cpu1_pwrstst;
	unsigned int rm_pda_cpu1_context;
	unsigned int cm_pda_cpu1_clkctrl;
	unsigned int cm_pda_cpu1_clkstctrl;
	unsigned int scu_cpu_power_status;
	char s0[32], s1[32];
	unsigned int cm_clkmode_dpll_mpu;
	unsigned int cm_idlest_dpll_mpu;
	unsigned int cm_autoidle_dpll_mpu;
	omap4_dpll_params dpll_mpu_params;
	unsigned int pm_pwstctrl;
	unsigned int pm_pwstst;
	unsigned int cm_clkstctrl;
	unsigned int rm_context;
	unsigned int cm_clkctrl;
	int ret;

	CHECK_CPU(44xx, OMAPCONF_ERR_CPU);

	if (!init_done)
		mpu44xx_regtable_init();

	if (mem_read(OMAP4430_PM_PDA_CPU0_PWRSTCTRL,
		&pm_pda_cpu0_pwrstctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_PM_PDA_CPU0_PWRSTST, &pm_pda_cpu0_pwrstst) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_RM_PDA_CPU0_CPU0_CONTEXT,
		&rm_pda_cpu0_context) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_PDA_CPU0_CPU0_CLKCTRL,
		&cm_pda_cpu0_clkctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_PDA_CPU0_CLKSTCTRL,
		&cm_pda_cpu0_clkstctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_PM_PDA_CPU1_PWRSTCTRL,
		&pm_pda_cpu1_pwrstctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_PM_PDA_CPU1_PWRSTST,
		&pm_pda_cpu1_pwrstst) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_RM_PDA_CPU1_CPU1_CONTEXT,
		&rm_pda_cpu1_context) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_PDA_CPU1_CPU1_CLKCTRL,
		&cm_pda_cpu1_clkctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_PDA_CPU1_CLKSTCTRL,
		&cm_pda_cpu1_clkstctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_SCU_CPU_POWER_STATUS,
		&scu_cpu_power_status) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_CLKMODE_DPLL_MPU,
		&cm_clkmode_dpll_mpu) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_IDLEST_DPLL_MPU,
		&cm_idlest_dpll_mpu) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_CM_AUTOIDLE_DPLL_MPU,
		&cm_autoidle_dpll_mpu) != 0)
		return OMAPCONF_ERR_REG_ACCESS;

	ret = dpll44xx_dpll_params_get(DPLL44XX_MPU,
		&dpll_mpu_params, 0);
	if (ret < 0)
		return ret;

	/* MPU LPRM config */
	fprintf(stream, "|----------------------------------------------------"
		"----|\n");
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "MPU LPRM Configuration",
		"CPU0",	"CPU1");
	fprintf(stream, "|--------------------------------|-----------|-------"
		"----|\n");
	pwrdm_state2string(s0,
		(pwrdm_state) extract_bitfield(pm_pda_cpu0_pwrstst, 0, 2));
	pwrdm_state2string(s1,
		(pwrdm_state) extract_bitfield(pm_pda_cpu1_pwrstst, 0, 2));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Current Power State",
		s0, s1);
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Current Logic State",
		((extract_bit(pm_pda_cpu0_pwrstst, 2) == 1) ? "ON" : "OFF"),
		((extract_bit(pm_pda_cpu1_pwrstst, 2) == 1) ? "ON" : "OFF"));
	pwrdm_state2string(s0,
		(pwrdm_state) extract_bitfield(pm_pda_cpu0_pwrstst, 4, 2));
	pwrdm_state2string(s1,
		(pwrdm_state) extract_bitfield(pm_pda_cpu1_pwrstst, 4, 2));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n",
		"Current L1$ State", s0, s1);
	pwrdm_state2string(s0,
		(pwrdm_state)extract_bitfield(pm_pda_cpu0_pwrstctrl, 0, 2));
	pwrdm_state2string(s1,
		(pwrdm_state) extract_bitfield(pm_pda_cpu1_pwrstctrl, 0, 2));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n",
		"Standby Status",
		((extract_bit(cm_pda_cpu0_clkctrl, 0) == 1) ?
			"STANDBY" : "RUNNING"),
		((extract_bit(cm_pda_cpu1_clkctrl, 0) == 1) ?
			"STANDBY" : "RUNNING"));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "", "", "");
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Target Power State",
		s0, s1);
	fprintf(stream, "| %-30s | %-9s | %-9s |\n",
		"Logic State When Domain is RET",
		((extract_bit(pm_pda_cpu0_pwrstctrl, 2) == 1) ? "RET" : "OFF"),
		((extract_bit(pm_pda_cpu1_pwrstctrl, 2) == 1) ? "RET" : "OFF"));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Clock Control",
		clkdm_ctrl_mode_name_get((clkdm_ctrl_mode)
			extract_bitfield(cm_pda_cpu0_clkstctrl, 0, 2)),
		clkdm_ctrl_mode_name_get((clkdm_ctrl_mode)
			extract_bitfield(cm_pda_cpu1_clkstctrl, 0, 2)));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "", "", "");
	if ((cpu_is_omap4430() && (cpu_revision_get() != REV_ES1_0)) ||
		cpu_is_omap4460() || cpu_is_omap4470()) {
		pwrdm_state2string(s0, (pwrdm_state)
			extract_bitfield(pm_pda_cpu0_pwrstst, 24, 2));
		pwrdm_state2string(s1, (pwrdm_state)
			extract_bitfield(pm_pda_cpu1_pwrstst, 24, 2));
		fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Last Power State",
			s0, s1);
	}
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Last L1$ Context",
		((extract_bit(rm_pda_cpu0_context, 8) == 1) ?
			"LOST" : "RETAINED"),
		((extract_bit(rm_pda_cpu1_context, 8) == 1) ?
			"LOST" : "RETAINED"));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "Last CPU Context",
		((extract_bit(rm_pda_cpu0_context, 0) == 1) ?
			"LOST" : "RETAINED"),
		((extract_bit(rm_pda_cpu1_context, 0) == 1) ?
			"LOST" : "RETAINED"));
	fprintf(stream, "|----------------------------------------------------"
		"----|\n");
	fprintf(stream, "\n");

	/* SCU Configuration */
	fprintf(stream, "|----------------------------------------------------"
	"----|\n");
	fprintf(stream, "| %-30s | %-9s | %-9s |\n",
		"SCU Configuration", "CPU0", "CPU1");
	fprintf(stream, "|--------------------------------|-----------|-------"
		"----|\n");
	OMAPCONF_SCU_CPU_POWER_STATUS_2_STRING(s0,
		extract_bitfield(scu_cpu_power_status, 0, 2));
	OMAPCONF_SCU_CPU_POWER_STATUS_2_STRING(s1,
		extract_bitfield(scu_cpu_power_status, 8, 2));
	fprintf(stream, "| %-30s | %-9s | %-9s |\n", "CPU Power Status",
		s0, s1);
	fprintf(stream, "|---------------------------------------------------"
		"-----|\n");
	fprintf(stream, "\n");

	/* MPU Power Domain Configuration */
	if (mem_read(OMAP4430_PM_MPU_PWRSTCTRL, &pm_pwstctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_PM_MPU_PWRSTST, &pm_pwstst) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	ret = pwrdm44xx_config_show(stream, "MPU",
		OMAP4430_PM_MPU_PWRSTCTRL, pm_pwstctrl,
		OMAP4430_PM_MPU_PWRSTST, pm_pwstst);
	if (ret != 0)
		return ret;

	/* MPU Clock Domain Configuration */
	if (mem_read(OMAP4430_CM_MPU_CLKSTCTRL, &cm_clkstctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	ret = clkdm44xx_config_show(stream, "MPU",
		OMAP4430_CM_MPU_CLKSTCTRL, cm_clkstctrl);
	if (ret != 0)
		return ret;

	/* MPU Module Power Configuration */
	if (mem_read(OMAP4430_CM_MPU_MPU_CLKCTRL, &cm_clkctrl) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	if (mem_read(OMAP4430_RM_MPU_MPU_CONTEXT, &rm_context) != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	ret = mod44xx_config_show(stream, "MPU",
		OMAP4430_CM_MPU_MPU_CLKCTRL, cm_clkctrl,
		OMAP4430_RM_MPU_MPU_CONTEXT, rm_context);
	if (ret != 0)
		return ret;

	/* MPU DPLL Configuration */
	fprintf(stream, "|----------------------------------------------------"
		"----|\n");
	fprintf(stream, "| MPU DPLL Configuration                             "
		"    |\n");
	fprintf(stream, "|--------------------------------|-------------------"
		"----|\n");
	fprintf(stream, "| %-30s | %-21s |\n", "Status",
		dpll_status_name_get((dpll_status) dpll_mpu_params.status));
	sprintf(s0, "%d", (unsigned int) dpll_mpu_params.M2_speed);
	fprintf(stream, "| %-30s | %-21s |\n", "Clock Speed (MHz)", s0);
	fprintf(stream, "| %-30s | %-21s |\n", "Mode",
		dpll_mode_name_get((dpll_mode) dpll_mpu_params.mode));
	fprintf(stream, "| %-30s | %-21s |\n", "Low-Power Mode",
		(dpll_mpu_params.lpmode == 1) ? "Enabled" : "Disabled");
	fprintf(stream, "| %-30s | %-21s |\n", "Autoidle Mode",
		dpll_autoidle_mode_name_get((dpll_autoidle_mode)
			dpll_mpu_params.autoidle_mode));
	fprintf(stream, "| %-30s | %-21s |\n", "M2 Output Autogating",
		(dpll_mpu_params.M2_autogating == 1) ? "Enabled" : "Disabled");
	fprintf(stream, "|----------------------------------------------------"
		"----|\n");
	fprintf(stream, "\nNB: type \"omapconf dplls cfg\" "
		"for detailed DPLL configuration.\n\n");

	return 0;
}
Exemplo n.º 21
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		twl603x_vsel_get
 * @BRIEF		return vsel-encoded voltage of a given SMPS voltage rail
 * @RETURNS		VSEL-encoded voltage (8-bit, >= 0) in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_REG_ACCESS
 *			OMAPCONF_ERR_INTERNAL
 * @param[in]		vdd_id: voltage domain ID
 * @DESCRIPTION		return vsel-encoded voltage of a given SMPS voltage rail
 *			NB: not supported by TWL6030/TWL6032.
 *//*------------------------------------------------------------------------ */
int twl603x_vsel_get(unsigned int vdd_id)
{
	int ret;
	unsigned int val, vsel_addr, vsel, range;
	const twl6035_smps_registers **vdd_smps_regs;
	const twl6035_smps_registers *smps_regs;

	if (!twl603x_is_twl6035())
		return OMAPCONF_ERR_CPU;
	CHECK_ARG_LESS_THAN(vdd_id, 3, OMAPCONF_ERR_ARG);

	/* Retrive SMPS registers addresses */
	vdd_smps_regs = twl6035_smps_vdd54xx[vdd_id];
	if (vdd_smps_regs == NULL)
		return OMAPCONF_ERR_INTERNAL;
	smps_regs = *vdd_smps_regs;
	if (smps_regs == NULL)
		return OMAPCONF_ERR_INTERNAL;

	dprintf("%s(): vdd_id=%u  ADDR: ctrl=0x%02X tstep=0x%02X force=0x%02X "
		"voltage=0x%02X\n", __func__, vdd_id, smps_regs->ctrl,
		smps_regs->tstep, smps_regs->force, smps_regs->voltage);

	/* Check SMPS Status */
	/* FIXME: create dedicated API */
	if (smps_regs->ctrl == -1) {
		dprintf("%s(): SMPSxx_CTRL addr=-1!!!\n", __func__);
		return OMAPCONF_ERR_INTERNAL;
	}
	ret = i2cget(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
		smps_regs->ctrl, &val);
	if (ret != 0)
		return OMAPCONF_ERR_REG_ACCESS;
	dprintf("%s(): SMPSxx_CTRL=0x%02X\n", __func__, val);
	if (extract_bitfield(val, 4, 2) == 0) {
		dprintf("(%s(): warning SMPS is OFF\n", __func__);
		return 0;
	}

	/* Check SMPS voltage controlled by registers, not resource pins */
	/* FIXME: create dedicated API */
	if (extract_bit(val, 6) == 1) {
		dprintf("%s(): SMPS voltage controlled by resource pins\n",
			__func__);
		return OMAPCONF_ERR_NOT_AVAILABLE;
	}

	/*
	 * Retrieve if voltage is controlled via
	 * SMPSxx_FORCE.VSEL or SMPSxx_VOLTAGE.VSEL
	 */
	if (smps_regs->force == -1) {
		dprintf("%s(): SMPSxx_FORCE register does not exist, "
			"use SMPSxx_VOLTAGE register.\n", __func__);
		vsel_addr = smps_regs->voltage;
	} else {
		ret = i2cget(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
			smps_regs->force, &val);
		if (ret != 0)
			return OMAPCONF_ERR_REG_ACCESS;
		dprintf("%s(): SMPSxx_FORCE=0x%02X\n", __func__, val);
		if (extract_bit(val, 7) == 1) {
			dprintf("%s(): CMD=1 => use SMPSxx_VOLTAGE register.\n",
				__func__);
			vsel_addr = smps_regs->voltage;
		} else {
			dprintf("%s(): CMD=0 => use SMPSxx_FORCE register.\n",
				__func__);
			vsel_addr = smps_regs->force;
		}
	}

	/* Retrieve VSEL (7-bit LSB) from relevant register */
	if (vsel_addr == (unsigned int) smps_regs->voltage) {
		if (smps_regs->voltage == -1) {
			dprintf("%s(): SMPSxx_VOLTAGE addr=-1!!!\n", __func__);
			return OMAPCONF_ERR_INTERNAL;
		}
		ret = i2cget(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
			smps_regs->voltage, &val);
		if (ret != 0)
			return OMAPCONF_ERR_REG_ACCESS;
		dprintf("%s(): SMPSxx_VOLTAGE=0x%02X\n", __func__, val);
	}
	vsel = extract_bitfield(val, 0, 7);
	dprintf("%s(): SMPSxx_VOLTAGE=0x%02X SMPSxx_VOLTAGE.VSEL=0x%02X\n",
		__func__, val, vsel);

	/* Retrieve VSEL range from SMPSxx_VOLTAGE register (bit 7) */
	if (vsel_addr != (unsigned int) smps_regs->voltage) {
		if (smps_regs->voltage == -1) {
			dprintf("%s(): SMPSxx_VOLTAGE addr=-1!!!\n", __func__);
			return OMAPCONF_ERR_INTERNAL;
		}
		ret = i2cget(TWL6035_I2C_BUS, TWL6035_ID1_ADDR,
			smps_regs->voltage, &val);
		if (ret != 0)
			return OMAPCONF_ERR_REG_ACCESS;
	}
	range = extract_bit(val, 7);
	dprintf("%s(): SMPSxx_VOLTAGE=0x%02X SMPSxx_VOLTAGE.RANGE=%u\n",
		__func__, val, range);

	/* Return VSEL (7-bit LSB), including range (MSB) */
	vsel = vsel | (range << 7);
	dprintf("%s(): vsel=0x%02X\n", __func__, vsel);
	return vsel;
}
Exemplo n.º 22
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		pwrdm44xx_config_show
 * @BRIEF		analyze power domain configuration
 * @RETURNS		0 in case of error
 * @param[in,out]	stream: output file
 * @param[in,out]	name: domain name
 * @param[in]		pm_pwstctrl_addr: PM_xyz_PWSTCTRL register address
 * @param[in]		pm_pwstctrl: PM_xyz_PWSTCTRL register content
 * @param[in]		pm_pwstst_addr: PM_xyz_PWSTST register address
 * @param[in]		pm_pwstst: PM_xyz_PWSTST register content
 * @DESCRIPTION		analyze power domain configuration
 *//*------------------------------------------------------------------------ */
int pwrdm44xx_config_show(FILE *stream, const char name[11],
	unsigned int pm_pwstctrl_addr, unsigned int pm_pwstctrl,
	unsigned int pm_pwstst_addr, unsigned int pm_pwstst)
{
	char curr[32], tgt[32], last[32];

	dprintf("%s(): name=%s\n", __func__, name);
	dprintf("%s(): pm_pwstctrl addr=0x%08X\n", __func__, pm_pwstctrl_addr);
	dprintf("%s(): pm_pwstctrl=0x%08X\n", __func__, pm_pwstctrl);
	dprintf("%s(): pm_pwstst addr=0x%08X\n", __func__, pm_pwstst_addr);
	dprintf("%s(): pm_pwstst=0x%08X\n", __func__, pm_pwstst);
	dprintf("\n");

	fprintf(stream, "|---------------------------------------------------"
		"-----------|\n");
	fprintf(stream, "| %-10s Power Domain Configuration                  "
		"      |\n", name);
	fprintf(stream, "|---------------------------------------------------"
		"-----------|\n");
	fprintf(stream, "| %-30s | %-7s | %-7s | %-7s |\n", "Power State",
		"Current", "Target", "Last");
	fprintf(stream, "|--------------------------------|---------|--------"
		"-|---------|\n");
	pwrdm_state2string(curr,
		(pwrdm_state) extract_bitfield(pm_pwstst, 0, 2));
	pwrdm_state2string(tgt,
		(pwrdm_state) extract_bitfield(pm_pwstctrl, 0, 2));
	if ((cpu_is_omap4430() && (cpu_revision_get() != REV_ES1_0)) ||
		cpu_is_omap4460() || cpu_is_omap4470()) {
		switch (pm_pwstst_addr) {
		case OMAP4430_PM_MPU_PWRSTST:
		case OMAP4430_PM_DSP_PWRSTST:
		case OMAP4430_PM_ABE_PWRSTST:
		case OMAP4430_PM_CORE_PWRSTST:
		case OMAP4430_PM_IVAHD_PWRSTST:
		case OMAP4430_PM_L3INIT_PWRSTST:
		case OMAP4430_PM_L4PER_PWRSTST:
			pwrdm_state2string(last, (pwrdm_state)
				extract_bitfield(pm_pwstst, 24, 2));
			break;
		case OMAP4430_PM_CAM_PWRSTST:
		case OMAP4430_PM_DSS_PWRSTST:
		case OMAP4430_PM_GFX_PWRSTST:
		case OMAP4430_PM_EMU_PWRSTST:
			if (!cpu_is_omap4430())
				pwrdm_state2string(last, (pwrdm_state)
					extract_bitfield(pm_pwstst, 24, 2));
			else
				strcpy(last, "");
			break;
		default:
			strcpy(last, "");
		}
	} else {
		strcpy(last, "");
	}
	fprintf(stream, "| %-30s | %-7s | %-7s | %-7s |\n",
		"Domain", curr, tgt, last);

	if ((pm_pwstctrl_addr == OMAP4430_PM_CAM_PWRSTCTRL) ||
			(pm_pwstctrl_addr == OMAP4430_PM_EMU_PWRSTCTRL) ||
			(pm_pwstctrl_addr == OMAP4430_PM_GFX_PWRSTCTRL)) {
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n", "Logic",
			((extract_bit(pm_pwstst, 2) == 1) ? "ON" : "OFF"),
			"");
	} else {
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n", "Logic",
			((extract_bit(pm_pwstst, 2) == 1) ? "ON" : "OFF"),
			((extract_bit(pm_pwstctrl, 2) == 1) ? "RET" : "OFF"));
	}
	fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
		"Memory", "", "");
	switch (pm_pwstctrl_addr) {
	case OMAP4430_PM_CORE_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 12, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 12));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    OCP_WP Bank & DMM Bank2", curr, tgt);
		break;
	default:
		break;
	}

	switch (pm_pwstctrl_addr) {
	case OMAP4430_PM_IVAHD_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 10, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 11));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    TCM2", curr, tgt);
		break;
	case OMAP4430_PM_CORE_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 10, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 11));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    MPU_M3 Unicache", curr, tgt);
	default:
		break;
	}

	switch (pm_pwstctrl_addr) {
	case OMAP4430_PM_MPU_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 8, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 10));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    RAM", curr, tgt);
		break;
	case OMAP4430_PM_DSP_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 8, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 10));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    EDMA", curr, tgt);
		break;
	case OMAP4430_PM_DSS_PWRSTCTRL:
	case OMAP4430_PM_CAM_PWRSTCTRL:
	case OMAP4430_PM_GFX_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    MEM", curr, tgt);
		break;
	case OMAP4430_PM_IVAHD_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 8, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 10));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    TCM1", curr, tgt);
	case OMAP4430_PM_CORE_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 8, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 10));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    MPU_M3 L2 RAM", curr, tgt);
	default:
		break;
	}

	switch (pm_pwstctrl_addr) {
	case OMAP4430_PM_ABE_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 8, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 10));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    PERIPHMEM", curr, tgt);
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    AESSMEM", curr, tgt);
		break;
	case OMAP4430_PM_MPU_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 6, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 9));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    L2$", curr, tgt);
		if (cpu_is_omap4430())
			pwrdm_state2string(curr,
				extract_bitfield(pm_pwstst, 4, 2));
		else
			strcpy(curr, ""); /* not available on OMAP44[60-70] */
		pwrdm_state2string(tgt,
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    L1$", curr, tgt);
		break;
	case OMAP4430_PM_DSP_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 6, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 9));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    L2$", curr, tgt);
		pwrdm_state2string(curr,
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt,
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    L1$", curr, tgt);
		break;
	case OMAP4430_PM_IVAHD_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 6, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 9));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    SL2", curr, tgt);
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    HWA", curr, tgt);
		break;
	case OMAP4430_PM_L4PER_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 6, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 9));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    NONRETAINED", curr, tgt);
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    RETAINED", curr, tgt);
		break;
	case OMAP4430_PM_CORE_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 6, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 9));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    OCM RAM", curr, tgt);
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    DMA/ICR Bank & DMM Bank1", curr, tgt);
		break;
	case OMAP4430_PM_L3INIT_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bit(pm_pwstctrl, 8));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    L3INIT Bank1", curr, tgt);
		break;
	case OMAP4430_PM_EMU_PWRSTCTRL:
		pwrdm_state2string(curr, (pwrdm_state)
			extract_bitfield(pm_pwstst, 4, 2));
		pwrdm_state2string(tgt, (pwrdm_state)
			extract_bitfield(pm_pwstctrl, 16, 2));
		fprintf(stream, "| %-30s | %-7s | %-7s |         |\n",
			"    EMU Bank", curr, tgt);
		break;
	default:
		break;
	}
	fprintf(stream, "|---------------------------------------------------"
		"-----------|\n");
	fprintf(stream, "| %-30s | %-27s |\n", "Ongoing Power Transition?",
		((extract_bit(pm_pwstst, 20) == 1) ? "YES" : "NO"));
	fprintf(stream, "|---------------------------------------------------"
		"-----------|\n");
	fprintf(stream, "\n");

	return 0;
}
Exemplo n.º 23
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		mod44xx_get_standby_status
 * @BRIEF		retrieve module standby status from CM_xxx_xxx_CLKCTRL
 * @RETURNS		module standby status
 *			MOD_STANDBY_STATUS_MAX in case of error
 * @param[in]		id: module ID
 * @param[in,out]	st: returned module standby status (string)
 * @DESCRIPTION		retrieve module standby status from CM_xxx_xxx_CLKCTRL
 *//*------------------------------------------------------------------------ */
mod_standby_status mod44xx_get_standby_status(mod44xx_id id,
	char st[11])
{
	mod_standby_status ret = MOD_STANDBY_STATUS_MAX;
	unsigned int cm_clkctrl;
	#ifdef MODULE44XX_DEBUG
	char name[MOD44XX_MAX_NAME_LENGTH];
	#endif

	if (st == NULL) {
		fprintf(stderr, "%s(): idlest == NULL!\n", __func__);
		goto mod44xx_get_standby_status_end;
	}

	*st = '\0';
	if (id >= OMAP4_MODULE_ID_MAX) {
		fprintf(stderr, "%s(): id (%u) >= OMAP4_MODULE_ID_MAX!\n",
			__func__, id);
		goto mod44xx_get_standby_status_end;
	}

	if (mod44xx_info_table[id].cm_clkctrl_addr == NULL) {
		dprintf("%s(): %s has no CLKCTRL register\n",
			__func__, mod44xx_get_name(id, name));
		goto mod44xx_get_standby_status_end;
	}

	switch (id) {
	case OMAP4_DEBUGSS:
	case OMAP4_MPU:
	case OMAP4_DSP:
	case OMAP4_AESS:
	case OMAP4_MPU_M3:
	case OMAP4_SDMA:
	case OMAP4_C2C:
	case OMAP4_IVAHD:
	case OMAP4_ISS:
	case OMAP4_FDIF:
	case OMAP4_DISPC:
	case OMAP4_GFX:
	case OMAP4_MMC1:
	case OMAP4_MMC1_HL:
	case OMAP4_MMC2:
	case OMAP4_MMC2_HL:
	case OMAP4_HSI:
	case OMAP4_UNIPRO1:
	case OMAP4_HSUSBHOST:
	case OMAP4_HSUSBOTG:
	case OMAP4_FSUSBHOST:
		break;
	default:
		dprintf("%s(): module %s has no standby status bit\n",
			__func__, mod44xx_get_name(id, name));
		goto mod44xx_get_standby_status_end;
	}

	if (mem_read((unsigned int)
			mod44xx_info_table[id].cm_clkctrl_addr,
		&cm_clkctrl) != 0) {
		fprintf(stderr, "%s(): error reading CLKCTRL reg (@0x%08X)!\n",
			__func__,
			(unsigned int) mod44xx_info_table[id].cm_clkctrl_addr);
		goto mod44xx_get_standby_status_end;
	}

	dprintf(
		"%s(): CM_CLKCTRL ADDR = 0x%08X, CM_CLKCTRL = 0x%08X, STBYST = %u\n",
		__func__, (unsigned int) mod44xx_info_table[id].cm_clkctrl_addr,
		cm_clkctrl, extract_bit(cm_clkctrl, 18));

	switch (extract_bit(cm_clkctrl, 18)) {
	case 0:
		strcpy(st, "Functional");
		ret = MOD_FUNCTIONAL;
		break;
	case 1:
		strcpy(st, "In Standby");
		ret = MOD_IN_STANDBY;
		break;
	default:
		fprintf(stderr, "%s(): error decoding standby status!\n",
			__func__);
	}
	dprintf("%s(): %s standby status is %s (%u)\n",
		__func__, mod44xx_get_name(id, name), st,
		extract_bit(cm_clkctrl, 18));

mod44xx_get_standby_status_end:
	return ret;
}
Exemplo n.º 24
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		mod44xx_get_autoidle_mode
 * @BRIEF		retrieve omap module's autoidle mode
 * @RETURNS		1 if success
 *			0 if omap module's registers NOT accessible
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_REG_ACCESS
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_INTERNAL
 * @param[in]		module_id: omap module ID
 * @param[in,out]	mode: returned omap module's autoidle mode
 * @DESCRIPTION		retrieve omap module's autoidle mode
 *//*------------------------------------------------------------------------ */
int mod44xx_get_autoidle_mode(mod44xx_id module_id,
	mod_autoidle_mode *mode)
{
	int ret_val = 0;
	unsigned int sysconfig;
	char name[MOD44XX_MAX_NAME_LENGTH];

	mod_interface_type type;

	*mode = MOD_AUTOIDLE_MODE_MAX;

	if (!cpu_is_omap44xx())
		return OMAPCONF_ERR_CPU;

	if (module_id >= OMAP4_MODULE_ID_MAX)
		return OMAPCONF_ERR_ARG;

	mod44xx_get_interface_type(module_id, &type);
	if (type == MOD_INTERFACE_NONE) {
		dprintf("%s(): module #%d name = %s has no SYSCONFIG\n",
			__func__, module_id,
			mod44xx_get_name(module_id, name));
		return OMAPCONF_ERR_NOT_AVAILABLE;
	}

	ret_val = mod44xx_is_accessible(module_id);
	if (ret_val == 1) {
		/* Module is accessible */
		dprintf("%s(): module #%d name = %s is accessible\n",
			__func__, module_id,
			mod44xx_get_name(module_id, name));

		if (mod44xx_info_table[module_id].sysconfig_addr != NULL) {
			OMAP_READREG((unsigned int)
				mod44xx_info_table[module_id].sysconfig_addr,
				sysconfig);
			dprintf(
				"%s(): SYSCONFIG ADDR = 0x%08X SYSCONFIG = 0x%08X\n",
				__func__,
				(unsigned int)
				mod44xx_info_table[module_id].sysconfig_addr,
				sysconfig);

			/* Check module's autoidle bit */
			switch (module_id) {
			case OMAP4_CONTROL_GEN_WKUP:
			case OMAP4_CONTROL_PADCONF_WKUP:
			case OMAP4_SYNCTIMER:
			case OMAP4_WDT2:
			case OMAP4_WDT3:
			case OMAP4_TIMER3:
			case OMAP4_TIMER4:
			case OMAP4_TIMER5:
			case OMAP4_TIMER6:
			case OMAP4_TIMER7:
			case OMAP4_TIMER8:
			case OMAP4_TIMER9:
			case OMAP4_TIMER11:
			case OMAP4_MCASP:
			case OMAP4_IVAHD:
			case OMAP4_ICONT1:
			case OMAP4_ICONT2:
			case OMAP4_VDMA:
			case OMAP4_IME3:
			case OMAP4_ILF3:
			case OMAP4_MC3:
			case OMAP4_CALC3:
			case OMAP4_ECD3:
			case OMAP4_SMARTREFLEX_CORE:
			case OMAP4_SMARTREFLEX_MPU:
			case OMAP4_SMARTREFLEX_IVA:
			case OMAP4_CONTROL_GEN_CORE:
			case OMAP4_CONTROL_PADCONF_CORE:
			case OMAP4_SYSTEM_MAILBOX:
			case OMAP4_DMM:
			case OMAP4_AESS:
			case OMAP4_SIMCOP:
			case OMAP4_SIMCOP_DMA:
			case OMAP4_FDIF:
			case OMAP4_HDMI:
			case OMAP4_GFX:
			case OMAP4_MMC1_HL:
			case OMAP4_MMC2_HL:
			case OMAP4_MMC3_HL:
			case OMAP4_MMC4_HL:
			case OMAP4_MMC5_HL:
			case OMAP4_UNIPRO1:
			case OMAP4_FSUSBHOST:
			case OMAP4_HSUSBHOST:
			case OMAP4_MCSPI1_HL:
			case OMAP4_MCSPI2_HL:
			case OMAP4_MCSPI3_HL:
			case OMAP4_MCSPI4_HL:
			case OMAP4_DMIC:
			case OMAP4_MCBSP1:
			case OMAP4_MCBSP2:
			case OMAP4_MCBSP3:
			case OMAP4_MCPDM:
			case OMAP4_SDMA:
			case OMAP4_ISS:
			case OMAP4_BTE:
			case OMAP4_CBUFF:
				ret_val = OMAPCONF_ERR_NOT_AVAILABLE;
				dprintf("%s(): module %s has no AUTOIDLE bit\n",
					__func__,
					mod44xx_get_name(module_id, name));
				break;
			case OMAP4_SLIMBUS1:
			case OMAP4_SLIMBUS2:
				/*
				 * NB: AUTOGATINGDISABLE instead of AUTOGATING,
				 * bit is inverted compared to other modules
				 */
				*mode = (mod_autoidle_mode)
					!extract_bit(sysconfig, 8);
				ret_val = 1;
				dprintf("%s(): module %s AUTOIDLE bit 8 = %d\n",
					__func__,
					mod44xx_get_name(module_id, name),
					*mode);
				break;
			case OMAP4_SIMCOP_DCT:
				*mode = (mod_autoidle_mode)
					extract_bit(sysconfig, 5);
				ret_val = 1;
				dprintf("%s(): module %s AUTOIDLE bit 5 = %d\n",
					__func__,
					mod44xx_get_name(module_id, name),
					*mode);
				break;
			case OMAP4_SIMCOP_VLCDJ:
				*mode = (mod_autoidle_mode)
					extract_bit(sysconfig, 3);
				ret_val = 1;
				dprintf("%s(): module %s AUTOIDLE bit 3 = %d\n",
					__func__,
					mod44xx_get_name(module_id, name),
					*mode);
				break;
			case OMAP4_SIMCOP_ROT:
				*mode = (mod_autoidle_mode)
					extract_bit(sysconfig, 9);
				ret_val = 1;
				dprintf("%s(): module %s AUTOIDLE bit 9 = %d\n",
					mod44xx_get_name(module_id, name),
					*mode);
				break;
			default:
				*mode = (mod_autoidle_mode)
					extract_bit(sysconfig, 0);
				ret_val = 1;
				dprintf("%s(): module %s AUTOIDLE bit 0 = %d\n",
					__func__,
					mod44xx_get_name(module_id, name),
					*mode);
			}
		} else {
			fprintf(stderr,
				"omapconf (%s): error module's %s interface type is not NONE but SYSCONFIG ADDR == NULL\n",
				__func__, mod44xx_get_name(module_id, name));
			ret_val = OMAPCONF_ERR_INTERNAL;
		}
	} else if (ret_val == 0) {
		/* Module is NOT accessible */
		ret_val = 0;
		dprintf("%s(): module is NOT accessible\n", __func__);
	} else {
		/* internal error */
		dprintf("%s(): mod44xx_is_accessible() returned with %d\n",
			__func__, ret_val);
	}

	return ret_val;
}
Exemplo n.º 25
0
/* ------------------------------------------------------------------------*//**
 * @FUNCTION		mod44xx_get_clock_activity_mode
 * @BRIEF		retrieve omap module's clockactivity mode
 * @RETURNS		1 if success
 *			0 if omap module's registers NOT accessible
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_REG_ACCESS
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_INTERNAL
 * @param[in]		module_id: omap module ID
 * @param[in,out]	mode: returned omap module's clockactivity mode
 * @DESCRIPTION		retrieve omap module's clockactivity mode
 *//*------------------------------------------------------------------------ */
int mod44xx_get_clock_activity_mode(mod44xx_id module_id,
	mod_clock_activity_mode *mode)
{
	int ret_val = 0;
	unsigned int sysconfig;
	char name[MOD44XX_MAX_NAME_LENGTH];

	*mode = MOD_CLOCK_ACTIVITY_MODE_MAX;

	if (!cpu_is_omap44xx())
		return OMAPCONF_ERR_CPU;

	if (module_id >= OMAP4_MODULE_ID_MAX)
		return OMAPCONF_ERR_ARG;

	if (mod44xx_has_clockactivity_bit(module_id) != 1)
		return OMAPCONF_ERR_NOT_AVAILABLE;

	ret_val = mod44xx_is_accessible(module_id);
	if (ret_val == 1) {
		/* Module is accessible */
		dprintf("%s(): module #%d name = %s is accessible\n",
			__func__, module_id,
			mod44xx_get_name(module_id, name));

		if (mod44xx_info_table[module_id].sysconfig_addr != NULL) {
			OMAP_READREG((unsigned int)
				mod44xx_info_table[module_id].sysconfig_addr,
				sysconfig);
			dprintf(
				"%s(): SYSCONFIG ADDR = 0x%08X SYSCONFIG = 0x%08X\n",
				__func__, (unsigned int)
				mod44xx_info_table[module_id].sysconfig_addr,
				sysconfig);

			/* Check module's idle mode */
			switch (module_id) {
			case OMAP4_SPINLOCK:
			case OMAP4_ELM:
				*mode = (mod_clock_activity_mode)
					extract_bit(sysconfig, 8);
				ret_val = 1;
				dprintf(
					"%s(): module %s clockactivity bit 8 = %d\n",
					__func__,
					mod44xx_get_name(module_id, name),
					*mode);
				break;
			default:
				*mode = (mod_clock_activity_mode)
					extract_bitfield(sysconfig, 8, 2);
				ret_val = 1;
				dprintf(
					"%s(): module %s clockactivity (bits [9:8]) = %d\n",
					__func__,
					mod44xx_get_name(module_id, name),
					*mode);
			}
		} else {
			fprintf(stderr,
				"%s(): error module's %s interface type is not NONE but SYSCONFIG ADDR == NULL\n",
				__func__, mod44xx_get_name(module_id, name));
			ret_val = OMAPCONF_ERR_INTERNAL;
		}
	} else if (ret_val == 0) {
		/* Module is NOT accessible */
		ret_val = 0;
		dprintf("%s(): module is NOT accessible\n", __func__);
	} else {
		/* internal error */
		dprintf("%s(): mod44xx_is_accessible() returned with %d\n",
			__func__, ret_val);
	}

	return ret_val;
}