コード例 #1
0
ファイル: rtc-wm8350.c プロジェクト: 020gzh/linux
static int wm8350_rtc_alarm_irq_enable(struct device *dev,
				       unsigned int enabled)
{
	struct wm8350 *wm8350 = dev_get_drvdata(dev);

	if (enabled)
		return wm8350_rtc_start_alarm(wm8350);
	else
		return wm8350_rtc_stop_alarm(wm8350);
}
コード例 #2
0
ファイル: rtc-wm8350.c プロジェクト: 020gzh/linux
static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	struct wm8350 *wm8350 = dev_get_drvdata(dev);
	struct rtc_time *tm = &alrm->time;
	u16 time[3];
	int ret;

	memset(time, 0, sizeof(time));

	if (tm->tm_sec != -1)
		time[0] |= tm->tm_sec;
	else
		time[0] |= WM8350_RTC_ALMSECS_MASK;

	if (tm->tm_min != -1)
		time[0] |= tm->tm_min << WM8350_RTC_ALMMINS_SHIFT;
	else
		time[0] |= WM8350_RTC_ALMMINS_MASK;

	if (tm->tm_hour != -1)
		time[1] |= tm->tm_hour;
	else
		time[1] |= WM8350_RTC_ALMHRS_MASK;

	if (tm->tm_wday != -1)
		time[1] |= (tm->tm_wday + 1) << WM8350_RTC_ALMDAY_SHIFT;
	else
		time[1] |= WM8350_RTC_ALMDAY_MASK;

	if (tm->tm_mday != -1)
		time[2] |= tm->tm_mday;
	else
		time[2] |= WM8350_RTC_ALMDATE_MASK;

	if (tm->tm_mon != -1)
		time[2] |= (tm->tm_mon + 1) << WM8350_RTC_ALMMTH_SHIFT;
	else
		time[2] |= WM8350_RTC_ALMMTH_MASK;

	ret = wm8350_rtc_stop_alarm(wm8350);
	if (ret < 0)
		return ret;

	/* Write time to RTC */
	ret = wm8350_block_write(wm8350, WM8350_ALARM_SECONDS_MINUTES,
				 3, time);
	if (ret < 0)
		return ret;

	if (alrm->enabled)
		ret = wm8350_rtc_start_alarm(wm8350);

	return ret;
}
コード例 #3
0
ファイル: rtc-wm8350.c プロジェクト: johnny/CobraDroidBeta
static int wm8350_rtc_resume(struct platform_device *pdev)
{
	struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev);
	int ret;

	if (wm8350->rtc.alarm_enabled) {
		ret = wm8350_rtc_start_alarm(wm8350);
		if (ret != 0)
			dev_err(&pdev->dev,
				"Failed to restart RTC alarm: %d\n", ret);
	}

	return 0;
}
コード例 #4
0
ファイル: rtc-wm8350.c プロジェクト: johnny/CobraDroidBeta
/*
 * Handle commands from user-space
 */
static int wm8350_rtc_ioctl(struct device *dev, unsigned int cmd,
			    unsigned long arg)
{
	struct wm8350 *wm8350 = dev_get_drvdata(dev);

	switch (cmd) {
	case RTC_AIE_OFF:
		return wm8350_rtc_stop_alarm(wm8350);
	case RTC_AIE_ON:
		return wm8350_rtc_start_alarm(wm8350);

	case RTC_UIE_OFF:
		wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC);
		break;
	case RTC_UIE_ON:
		wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_SEC);
		break;

	default:
		return -ENOIOCTLCMD;
	}

	return 0;
}