Beispiel #1
0
static int mrst_set_time(struct device *dev, struct rtc_time *time)
{
	int ret;
	unsigned long flags;
	unsigned char mon, day, hrs, min, sec;
	unsigned int yrs;

	yrs = time->tm_year;
	mon = time->tm_mon + 1;   /* tm_mon starts at zero */
	day = time->tm_mday;
	hrs = time->tm_hour;
	min = time->tm_min;
	sec = time->tm_sec;

	if (yrs < 72 || yrs > 138)
		return -EINVAL;
	yrs -= 72;

	spin_lock_irqsave(&rtc_lock, flags);

	vrtc_cmos_write(yrs, RTC_YEAR);
	vrtc_cmos_write(mon, RTC_MONTH);
	vrtc_cmos_write(day, RTC_DAY_OF_MONTH);
	vrtc_cmos_write(hrs, RTC_HOURS);
	vrtc_cmos_write(min, RTC_MINUTES);
	vrtc_cmos_write(sec, RTC_SECONDS);

	spin_unlock_irqrestore(&rtc_lock, flags);

	ret = intel_scu_ipc_simple_command(IPCMSG_VRTC, IPC_CMD_VRTC_SETTIME);
	return ret;
}
/* FIXME: Need to start the counter only if debug is
 * needed. This will save SCU cycles if debug is
 * disabled
 */
static int __init start_scu_s0ix_res_counters(void)
{
	int ret;

	ret = intel_scu_ipc_simple_command(START_RES_COUNTER, 0);
	if (ret) {
		pr_err("IPC command to start res counter failed\n");
		BUG();
		return ret;
	}
	return 0;
}
Beispiel #3
0
int update_persistent_clock(struct timespec now)
{
	unsigned long flags;
	int retval;

	spin_lock_irqsave(&rtc_lock, flags);
	retval = x86_platform.set_wallclock(now.tv_sec);
	spin_unlock_irqrestore(&rtc_lock, flags);

#ifdef CONFIG_X86_INTEL_MID
	if (!retval)
		retval = intel_scu_ipc_simple_command(
				IPCMSG_VRTC, IPC_CMD_VRTC_SETTIME);
#endif
	return retval;
}
Beispiel #4
0
static int mrst_set_alarm(struct device *dev, struct rtc_wkalrm *t)
{
	struct mrst_rtc	*mrst = dev_get_drvdata(dev);
	unsigned char hrs, min, sec;
	int ret = 0;

	if (!mrst->irq)
		return -EIO;

	hrs = t->time.tm_hour;
	min = t->time.tm_min;
	sec = t->time.tm_sec;

	spin_lock_irq(&rtc_lock);
	/* Next rtc irq must not be from previous alarm setting */
	mrst_irq_disable(mrst, RTC_AIE);

	/* Update alarm */
	vrtc_cmos_write(hrs, RTC_HOURS_ALARM);
	vrtc_cmos_write(min, RTC_MINUTES_ALARM);
	vrtc_cmos_write(sec, RTC_SECONDS_ALARM);

	spin_unlock_irq(&rtc_lock);

	ret = intel_scu_ipc_simple_command(IPCMSG_VRTC, IPC_CMD_VRTC_SETALARM);
	if (ret)
		return ret;

	spin_lock_irq(&rtc_lock);
	if (t->enabled)
		mrst_irq_enable(mrst, RTC_AIE);

	spin_unlock_irq(&rtc_lock);

	return 0;
}
static int __init intel_fw_logging_init(void)
{
	int length = 0;

	oshob_base = get_oshob_addr();

	if (oshob_base == NULL)
		return -EINVAL;

	length = create_fwerr_log(log_buffer, oshob_base);
	if (length != 0) {

#ifdef CONFIG_PROC_FS
		ipanic_faberr = create_proc_entry("ipanic_fabric_err",
						S_IFREG | S_IRUGO, NULL);
		if (ipanic_faberr == 0) {
			pr_err("Fail creating procfile ipanic_fabric_err\n");
			return -ENOMEM;
		}

		ipanic_faberr->read_proc = intel_fw_logging_proc_read;
		ipanic_faberr->write_proc = NULL;
		ipanic_faberr->size = length;

#endif /* CONFIG_PROC_FS */

		/* Dump log as error to console */
		pr_err("%s", log_buffer);

		/* Clear fabric error region inside OSHOB if neccessary */
		intel_scu_ipc_simple_command(IPCMSG_CLEAR_FABERROR, 0);
	}

	iounmap(oshob_base);
	return 0;
}
static int pmic_scu_ipc_set_charger(int charger)
{
	return intel_scu_ipc_simple_command(IPCMSG_BATTERY, charger);
}
Beispiel #7
0
static void mrst_reboot(void)
{
	intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
}
static void __noreturn intel_mid_reboot(void)
{
	intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
	BUG();
}
Beispiel #9
0
void intel_mid_power_off(void)
{
	intel_scu_ipc_simple_command(IPCMSG_COLD_RESET, 1);
}
Beispiel #10
0
static int __init intel_fw_logging_init(void)
{
	int length = 0;
	int err = 0;
	u32 scu_trace_size;
	u32 trace_size;

	oshob_base = get_oshob_addr();

	if (oshob_base == NULL)
		return -EINVAL;

	/*
	 * Calculate size of SCU extra trace buffer. Size of the buffer
	 * is given by SCU. Make sanity check in case of incorrect data.
	 * We don't want to allocate all of the memory for trace dump.
	 */
	trace_size = intel_scu_ipc_get_scu_trace_buffer_size();
	if (trace_size > MAX_SCU_EXTRA_DUMP_SIZE)
		trace_size = 0;

	/*
	 * Buffer size is in bytes. We will dump 32-bit hex values + header.
	 * Calculate number of lines and assume constant number of
	 * characters per line.
	 */
	scu_trace_size = ((trace_size / sizeof(u32)) + 2) *
		CHAR_PER_LINE_EXTRA_TRACE;

	/* Allocate buffer for traditional trace and extra trace */
	log_buffer = vzalloc(MAX_FULL_SIZE + scu_trace_size);
	if (!log_buffer) {
		err = -ENOMEM;
		goto err_nomem;
	}

	length = create_fwerr_log(log_buffer, oshob_base);
	if (!length)
		goto err_nolog;

	length = dump_scu_extented_trace(log_buffer, length,
					 trace_size);

#ifdef CONFIG_PROC_FS
	ipanic_faberr = create_proc_entry("ipanic_fabric_err",
					  S_IFREG | S_IRUGO, NULL);
	if (ipanic_faberr == 0) {
		pr_err("Fail creating procfile ipanic_fabric_err\n");
		err = -ENOMEM;
		goto err_procfail;
	}

	ipanic_faberr->read_proc = intel_fw_logging_proc_read;
	ipanic_faberr->write_proc = NULL;
	ipanic_faberr->size = length;

#endif /* CONFIG_PROC_FS */

	/* Dump log as error to console */
	pr_err("%s", log_buffer);

	/* Clear fabric error region inside OSHOB if neccessary */
	intel_scu_ipc_simple_command(IPCMSG_CLEAR_FABERROR, 0);
	goto leave;

err_procfail:
err_nolog:
	vfree(log_buffer);
err_nomem:
leave:
	iounmap(oshob_base);
	return err;
}