コード例 #1
0
ファイル: rpaphp_pci.c プロジェクト: 513855417/linux
int rpaphp_get_sensor_state(struct slot *slot, int *state)
{
	int rc;
	int setlevel;

	rc = rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);

	if (rc < 0) {
		if (rc == -EFAULT || rc == -EEXIST) {
			dbg("%s: slot must be power up to get sensor-state\n",
			    __func__);

			/* some slots have to be powered up
			 * before get-sensor will succeed.
			 */
			rc = rtas_set_power_level(slot->power_domain, POWER_ON,
						  &setlevel);
			if (rc < 0) {
				dbg("%s: power on slot[%s] failed rc=%d.\n",
				    __func__, slot->name, rc);
			} else {
				rc = rtas_get_sensor(DR_ENTITY_SENSE,
						     slot->index, state);
			}
		} else if (rc == -ENODEV)
			info("%s: slot is unusable\n", __func__);
		else
			err("%s failed to get sensor state\n", __func__);
	}
	return rc;
}
コード例 #2
0
ファイル: ras.c プロジェクト: Red680812/DNA_kitkat
/* Handle environmental and power warning (EPOW) interrupts. */
static irqreturn_t ras_epow_interrupt(int irq, void *dev_id)
{
    int status;
    int state;
    int critical;

    status = rtas_get_sensor(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX, &state);

    if (state > 3)
        critical = 1;		/* Time Critical */
    else
        critical = 0;

    spin_lock(&ras_log_buf_lock);

    status = rtas_call(ras_check_exception_token, 6, 1, NULL,
                       RTAS_VECTOR_EXTERNAL_INTERRUPT,
                       virq_to_hw(irq),
                       RTAS_EPOW_WARNING,
                       critical, __pa(&ras_log_buf),
                       rtas_get_error_log_max());

    log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0);

    rtas_parse_epow_errlog((struct rtas_error_log *)ras_log_buf);

    spin_unlock(&ras_log_buf_lock);
    return IRQ_HANDLED;
}
コード例 #3
0
ファイル: rtas_calls.c プロジェクト: vaibhav92/powerpc-utils
/**
 * dr_entity_sense
 * @brief Determine if a PCI card is present in a hot plug slot.
 *
 * @param index slot index to check
 * @returns EMPTY if no card detected in slotor not a valid state for logical
 *		  resources
 * @returns PRESENT if a card was detected in the slot or logical connector
 *		    is owned by the partition.
 * @returns EXCHANGE Logical resource is unlicensed and is available for
 *		     sparing operations.
 * @returns NEED_POWER	Must power on slot before checking for card presence.
 * @returns PWR_ONLY	Power on slot, but leave isolated.
 * @returns STATE_UNUSABLE No DR operation will succeed
 * @returns HW_ERROR	Hardware error
 * @returns SW_ERROR	Other errors.
 */
int
dr_entity_sense(int index)
{
	int state;
	int rc;

	rc = rtas_get_sensor(DR_ENTITY_SENSE, index, &state);
	say(DEBUG, "get-sensor for %x: %d, %d\n", index, rc, state);

	return (rc >= 0) ? state : rc;
}
コード例 #4
0
ファイル: wdrtas.c プロジェクト: 0xroot/Blackphone-BP1-Kernel
/**
 * wdrtas_get_temperature - returns current temperature
 *
 * returns temperature or <0 on failures
 *
 * wdrtas_get_temperature returns the current temperature in Fahrenheit. It
 * uses the RTAS call get-sensor-state, token 3 to do so
 */
static int wdrtas_get_temperature(void)
{
	int result;
	int temperature = 0;

	result = rtas_get_sensor(WDRTAS_THERMAL_SENSOR, 0, &temperature);

	if (result < 0)
		pr_warn("reading the thermal sensor failed: %i\n", result);
	else
		temperature = ((temperature * 9) / 5) + 32; /* fahrenheit */

	return temperature;
}
コード例 #5
0
ファイル: wdrtas.c プロジェクト: nos1609/Chrono_Kernel-1
/**
 * wdrtas_get_temperature - returns current temperature
 *
 * returns temperature or <0 on failures
 *
 * wdrtas_get_temperature returns the current temperature in Fahrenheit. It
 * uses the RTAS call get-sensor-state, token 3 to do so
 */
static int wdrtas_get_temperature(void)
{
	int result;
	int temperature = 0;

	result = rtas_get_sensor(WDRTAS_THERMAL_SENSOR, 0, &temperature);

	if (result < 0)
#ifdef CONFIG_DEBUG_PRINTK
		printk(KERN_WARNING "wdrtas: reading the thermal sensor "
		       "failed: %i\n", result);
#else
		;
#endif
	else
コード例 #6
0
/**
 * get_rtas_sensor - Retrieve a sensor value from rtas
 *
 * Call the rtas_get_sensor or rtas_get_dynamic_sensor librtas calls,
 * depending on whether the index indicates that the sensor is dynamic.
 *
 * @indicator	identification or attention indicator
 * @loc		location code of the sensor
 * @state	return sensor state for the given loc
 *
 * Returns :
 *	rtas call return code
 */
static int
get_rtas_sensor(int indicator, struct loc_code *loc, int *state)
{
	int	rc;
	int	rtas_token;
	char	err_buf[RTAS_ERROR_BUF_SIZE];

	rtas_token = get_rtas_token(indicator);
	if (rtas_token == -1)
		return -3; /* No such sensor implemented */

	if (loc->index == DYNAMIC_INDICATOR)
		rc = rtas_get_dynamic_sensor(rtas_token,
					     (void *)loc, state);
	else
		rc = rtas_get_sensor(rtas_token, loc->index, state);

	switch (rc) {
	case 0:	/*success  */
		break;
	case -1:
		log_msg("Hardware error retrieving the indicator at %s",
			loc->code);
		break;
	case -2:
		log_msg("Busy while retrieving indicator at %s. "
			"Try again later", loc->code);
		break;
	case -3:
		log_msg("The indicator at %s is not implemented", loc->code);
		break;
	default:
		librtas_error(rc, err_buf, RTAS_ERROR_BUF_SIZE);

		log_msg("Could not get %ssensor %s indicators,\n%s",
			(loc->index == DYNAMIC_INDICATOR) ? "dynamic " : "",
			get_indicator_desc(indicator), err_buf);
		break;
	}

	return rc;
}
コード例 #7
0
/* Search all cpu device nodes for an offline logical cpu.  If a
 * device node has a "ibm,my-drc-index" property (meaning this is an
 * LPAR), paranoid-check whether we own the cpu.  For each "thread"
 * of a cpu, if it is offline and has the same hw index as before,
 * grab that in preference.
 */
static unsigned int find_physical_cpu_to_start(unsigned int old_hwindex)
{
	struct device_node *np = NULL;
	unsigned int best = -1U;

	while ((np = of_find_node_by_type(np, "cpu"))) {
		int nr_threads, len;
		u32 *index = (u32 *)get_property(np, "ibm,my-drc-index", NULL);
		u32 *tid = (u32 *)
			get_property(np, "ibm,ppc-interrupt-server#s", &len);

		if (!tid)
			tid = (u32 *)get_property(np, "reg", &len);

		if (!tid)
			continue;

		/* If there is a drc-index, make sure that we own
		 * the cpu.
		 */
		if (index) {
			int state;
			int rc = rtas_get_sensor(9003, *index, &state);
			if (rc != 0 || state != 1)
				continue;
		}

		nr_threads = len / sizeof(u32);

		while (nr_threads--) {
			if (0 == query_cpu_stopped(tid[nr_threads])) {
				best = tid[nr_threads];
				if (best == old_hwindex)
					goto out;
			}
		}
	}
out:
	of_node_put(np);
	return best;
}