static int spm_talking_late_init(void)
{
	unsigned long flags;
	struct twam_sig twamsig = {
		.sig0 = 28,	/* md1_apsrc_req or md_ddr_en */
		.sig1 = 26,	/* md32_apsrc_req */
	};

	spin_lock_irqsave(&__spm_lock, flags);
	spm_write(SPM_AP_STANBY_CON, spm_read(SPM_AP_STANBY_CON) | ASC_MD_DDR_EN_SEL);
	spin_unlock_irqrestore(&__spm_lock, flags);

	spm_twam_register_handler(twam_handler);
	spm_twam_enable_monitor(&twamsig, true);

	return 0;
}

late_initcall(spm_talking_late_init);
#endif

void spm_talking_init(void)
{
	if (mt_get_chip_sw_ver() == CHIP_SW_VER_01 && SPM_CTRL_BIG_CPU)
		__spm_talking.pcmdesc = &talking_pcm_big;
}

MODULE_DESCRIPTION("SPM-Talking Driver v1.0");
int rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	/*
	 * Force update rtc year time to 2014
	 * (The release year of device)
	 */
	tm.tm_year = 114;

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	err = do_settimeofday(&tv);

	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
Example #3
0
static int suspend_time_debug_show(struct seq_file *s, void *data)
{
    int bin;
    seq_printf(s, "time (secs)  count\n");
    seq_printf(s, "------------------\n");

//LGE_CHANGES [Start]
#if 1
    for (bin = 0; bin < 33; bin++) {
#else
    for (bin = 0; bin < 32; bin++) {
#endif
//LGE_CNANGES
        if (time_in_suspend_bins[bin] == 0)
            continue;
        seq_printf(s, "%4d - %4d %4u\n",
                   bin ? 1 << (bin - 1) : 0, 1 << bin,
                   time_in_suspend_bins[bin]);
    }
    return 0;
}

static int suspend_time_debug_open(struct inode *inode, struct file *file)
{
    return single_open(file, suspend_time_debug_show, NULL);
}

static const struct file_operations suspend_time_debug_fops = {
    .open		= suspend_time_debug_open,
    .read		= seq_read,
    .llseek		= seq_lseek,
    .release	= single_release,
};

static int __init suspend_time_debug_init(void)
{
    struct dentry *d;

    d = debugfs_create_file("suspend_time", 0755, NULL, NULL,
                            &suspend_time_debug_fops);
    if (!d) {
        pr_err("Failed to create suspend_time debug file\n");
        return -ENOMEM;
    }

    return 0;
}

late_initcall(suspend_time_debug_init);
#endif

static int suspend_time_syscore_suspend(void)
{
    read_persistent_clock(&suspend_time_before);

    return 0;
}
Example #4
0
int rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	if (tv.tv_sec < 86400) {
		tv.tv_sec = 86400;
		pr_info("%s: Make sure the boot time starts from 86400 or more to avoid system server crash due to alarm trigger immediately\n", __FILE__);
	}
	do_settimeofday(&tv);

	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
Example #5
0
static int __init rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec64 tv64 = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_info("unable to open rtc device (%s)\n",
			CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	tv64.tv_sec = rtc_tm_to_time64(&tm);

#if BITS_PER_LONG == 32
	if (tv64.tv_sec > INT_MAX)
		goto err_read;
#endif

	err = do_settimeofday64(&tv64);

	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%lld)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(long long) tv64.tv_sec);

err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
static irqreturn_t tmu_irq(int irq, void *id)
{
	struct tmu_info *info = id;
	unsigned int status;

	disable_irq_nosync(irq);

	status = __raw_readl(info->tmu_base + INTSTAT);

	/* To handle multiple interrupt pending,
	* interrupt by high temperature are serviced with priority.
	*/

#if defined(CONFIG_TC_VOLTAGE)
	if (status & INTSTAT_FALL0) {
		pr_info("TC interrupt occured..!\n");
		__raw_writel(INTCLEAR_FALL0, info->tmu_base + INTCLEAR);
		info->tmu_state = TMU_STATUS_TC;
	} else if (status & INTSTAT_RISE2) {
#else
	if (status & INTSTAT_RISE2) {
#endif
		pr_info("Tripping interrupt occured..!\n");
		info->tmu_state = TMU_STATUS_TRIPPED;
		__raw_writel(INTCLEAR_RISE2, info->tmu_base + INTCLEAR);
	} else if (status & INTSTAT_RISE1) {
		pr_info("Warning interrupt occured..!\n");
		__raw_writel(INTCLEAR_RISE1, info->tmu_base + INTCLEAR);
		info->tmu_state = TMU_STATUS_WARNING;
	} else if (status & INTSTAT_RISE0) {
		pr_info("Throttling interrupt occured..!\n");
		__raw_writel(INTCLEAR_RISE0, info->tmu_base + INTCLEAR);
		info->tmu_state = TMU_STATUS_THROTTLED;
	} else {
		pr_err("%s: TMU interrupt error\n", __func__);
		return -ENODEV;
	}

	queue_delayed_work_on(0, tmu_monitor_wq,
			&info->polling, usecs_to_jiffies(1 * 1000));
	return IRQ_HANDLED;
}

static irqreturn_t exynos4210_tmu_irq(int irq, void *id)
{
	struct tmu_info *info = id;
	unsigned int status;

	disable_irq_nosync(irq);

	status = __raw_readl(info->tmu_base + INTSTAT);

	if (status & INTSTAT2) {
		pr_info("Tripping interrupt occured..!\n");
		info->tmu_state = TMU_STATUS_TRIPPED;
		__raw_writel(INTCLEAR2, info->tmu_base + INTCLEAR);
	} else if (status & INTSTAT1) {
		pr_info("Warning interrupt occured..!\n");
		__raw_writel(INTCLEAR1, info->tmu_base + INTCLEAR);
		info->tmu_state = TMU_STATUS_WARNING;
	} else if (status & INTSTAT0) {
		pr_info("Throttling interrupt occured..!\n");
		__raw_writel(INTCLEAR0, info->tmu_base + INTCLEAR);
		info->tmu_state = TMU_STATUS_THROTTLED;
	} else {
		pr_err("%s: TMU interrupt error\n", __func__);
		return -ENODEV;
	}

	queue_delayed_work_on(0, tmu_monitor_wq,
			&info->polling, usecs_to_jiffies(1000));
	return IRQ_HANDLED;
}

static int __devinit tmu_probe(struct platform_device *pdev)
{
	struct tmu_info *info;
	struct resource *res;
	int	ret = 0;

	pr_debug("%s: probe=%p\n", __func__, pdev);

	info = kzalloc(sizeof(struct tmu_info), GFP_KERNEL);
	if (!info) {
		dev_err(&pdev->dev, "failed to alloc memory!\n");
		ret = -ENOMEM;
		goto err_nomem;
	}
	pr_emerg("TMU: Memory Allocation Sucessful\n");
	
	platform_set_drvdata(pdev, info);
	pr_emerg("TMU: Platform data set\n");
	
	info->dev = &pdev->dev;
	pr_emerg("TMU: Copied the Dev access Information \n");
	
	info->irq = platform_get_irq(pdev, 0);
	if (info->irq < 0) {
		dev_err(&pdev->dev, "no irq for thermal\n");
		ret = -ENOENT;
		goto err_noirq;
	}
	if (soc_is_exynos4210())
		ret = request_irq(info->irq, exynos4210_tmu_irq,
				IRQF_DISABLED,  "tmu interrupt", info);
	else
		ret = request_irq(info->irq, tmu_irq,
				IRQF_DISABLED,  "tmu interrupt", info);
	if (ret) {
		dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq, ret);
		goto err_noirq;
	}
	pr_emerg("TMU: IRQ Granted!\n");
	
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "failed to get memory region resource\n");
		ret = -ENODEV;
		goto err_nores;
	}
	pr_emerg("TMU: IO Resource alloced on Memory\n");
	
	info->ioarea = request_mem_region(res->start,
			res->end-res->start+1, pdev->name);
	if (!(info->ioarea)) {
		dev_err(&pdev->dev, "failed to reserve memory region\n");
		ret = -EBUSY;
		goto err_nores;
	}
	pr_emerg("TMU: Memory area resersed\n");
	
	info->tmu_base = ioremap(res->start, (res->end - res->start) + 1);
	if (!(info->tmu_base)) {
		dev_err(&pdev->dev, "failed ioremap()\n");
		ret = -EINVAL;
		goto err_nomap;
	}
	pr_emerg("TMU: IO Memory Remapped\n");
	
	if (thermal_create_sysfs_file(&pdev->dev))
		goto err_sysfs;

	pr_emerg("TMU: Created Sysfs\n");
	
	tmu_monitor_wq = create_freezable_workqueue("tmu");
	if (!tmu_monitor_wq) {
		dev_err(&pdev->dev, "Creation of tmu_monitor_wq failed\n");
		ret = -EFAULT;
		goto err_wq;
	}
	pr_emerg("TMU: Workqueue Created\n");
	
	INIT_DELAYED_WORK_DEFERRABLE(&info->polling, tmu_monitor);
	pr_emerg("TMU: Work Created\n");
#ifdef CONFIG_TMU_DEBUG
	INIT_DELAYED_WORK_DEFERRABLE(&info->monitor, cur_temp_monitor);
#endif

	print_temperature_params(info);
	pr_emerg("TMU: Printed Parameters\n");
	
	ret = tmu_initialize(pdev);
	if (ret < 0)
		goto err_noinit;

#ifdef CONFIG_TMU_DEBUG
	queue_delayed_work_on(0, tmu_monitor_wq,
			&info->monitor, info->sampling_rate);
#endif
	pr_info("Tmu Initialization is sucessful...!\n");
	return ret;

err_noinit:
	destroy_workqueue(tmu_monitor_wq);
err_wq:
	thermal_remove_sysfs_file(&pdev->dev);
err_sysfs:
	iounmap(info->tmu_base);
err_nomap:
	release_resource(info->ioarea);
err_nores:
	free_irq(info->irq, info);
err_noirq:
	kfree(info);
	info = NULL;
err_nomem:
	dev_err(&pdev->dev, "initialization failed.\n");
	return ret;
}

static int __devinit tmu_remove(struct platform_device *pdev)
{
	struct tmu_info *info = platform_get_drvdata(pdev);

	cancel_delayed_work(&info->polling);
	destroy_workqueue(tmu_monitor_wq);

	thermal_remove_sysfs_file(&pdev->dev);

	iounmap(info->tmu_base);
	release_resource(info->ioarea);

	free_irq(info->irq, (void *)pdev);

	kfree(info);
	info = NULL;

	pr_info("%s is removed\n", dev_name(&pdev->dev));
	return 0;
}

#ifdef CONFIG_PM
static int tmu_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct tmu_info *info = platform_get_drvdata(pdev);
	pm_tmu_save(info);

	return 0;
}

static int tmu_resume(struct platform_device *pdev)
{
	struct tmu_info *info = platform_get_drvdata(pdev);
#if defined(CONFIG_TC_VOLTAGE)
	struct tmu_data *data = info->dev->platform_data;
#endif
	pm_tmu_restore(info);

#if defined(CONFIG_TC_VOLTAGE)
	/* s/w workaround for fast service when interrupt is not occured,
	* such as current temp is lower than tc interrupt temperature
	* or current temp is continuosly increased.
	*/
	mdelay(1);
	if (get_cur_temp(info) <= data->ts.start_tc) {
		disable_irq_nosync(info->irq);
		if (exynos_tc_volt(info, 1) < 0)
			pr_err("%s\n", __func__);

		info->tmu_state = TMU_STATUS_TC;
		already_limit = 1;
		queue_delayed_work_on(0, tmu_monitor_wq,
				&info->polling, usecs_to_jiffies(1 * 1000));
	}
#endif
	return 0;
}

#else
#define tmu_suspend	NULL
#define tmu_resume	NULL
#endif

static struct platform_driver tmu_driver = {
	.probe		= tmu_probe,
	.remove		= tmu_remove,
	.suspend	= tmu_suspend,
	.resume		= tmu_resume,
	.driver		= {
		.name	=	"tmu",
		.owner	=	THIS_MODULE,
		},
};

static int __init tmu_driver_init(void)
{
	return platform_driver_register(&tmu_driver);
}

late_initcall(tmu_driver_init);
Example #7
0
static int __init jet_audio_init(void)
{
	int ret = 0, rc = 0;
	struct pm_gpio param = {
		.direction	= PM_GPIO_DIR_OUT,
		.output_buffer	= PM_GPIO_OUT_BUF_CMOS,
		.output_value	= 0,
		.pull		= PM_GPIO_PULL_NO,
		.vin_sel	= PM_GPIO_VIN_L17,
		.out_strength	= PM_GPIO_STRENGTH_MED,
		.function	= PM_GPIO_FUNC_NORMAL,
	};

	if (!cpu_is_msm8960()) {
		pr_info("%s: Not the right machine type\n", __func__);
		return -ENODEV ;
	}

	pr_info("%s", __func__);

	msm8960_snd_device = platform_device_alloc("soc-audio", 0);
	if (!msm8960_snd_device) {
		pr_err("Platform device allocation failed\n");
		return -ENOMEM;
	}

	memcpy(msm8960_dai, msm8960_dai_common, sizeof(msm8960_dai_common));
	memcpy(msm8960_dai + ARRAY_SIZE(msm8960_dai_common),
		msm8960_dai_delta_tabla2x, sizeof(msm8960_dai_delta_tabla2x));

	platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960);
	ret = platform_device_add(msm8960_snd_device);
	if (ret) {
		platform_device_put(msm8960_snd_device);
		return ret;
	}

	msm8960_snd_tabla1x_device = platform_device_alloc("soc-audio", 1);
	if (!msm8960_snd_tabla1x_device) {
		pr_err("Platform device allocation failed\n");
		return -ENOMEM;
	}

	memcpy(msm8960_tabla1x_dai, msm8960_dai_common,
		sizeof(msm8960_dai_common));
	memcpy(msm8960_tabla1x_dai + ARRAY_SIZE(msm8960_dai_common),
		msm8960_dai_delta_tabla1x, sizeof(msm8960_dai_delta_tabla1x));

	platform_set_drvdata(msm8960_snd_tabla1x_device,
		&snd_soc_tabla1x_card_msm8960);
	ret = platform_device_add(msm8960_snd_tabla1x_device);
	if (ret) {
		platform_device_put(msm8960_snd_tabla1x_device);
		return ret;
	}

	rc = gpio_request(PM8921_GPIO_PM_TO_SYS(JET_PMGPIO_AUD_AMP_EN),
					"jet_en");
	rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(JET_PMGPIO_AUD_AMP_EN),
			&param);
	if (rc < 0)
		pr_aud_err("failed to configure tpa2051_en gpio\n");

	mutex_init(&cdc_mclk_mutex);
	htc_register_q6asm_ops(&qops);
	htc_register_pcm_routing_ops(&rops);
	acoustic_register_ops(&acoustic);
	return ret;

}
late_initcall(jet_audio_init);

static void __exit jet_audio_exit(void)
{

	if (!cpu_is_msm8960()) {
		pr_info("%s: Not the right machine type\n", __func__);
		return ;
	}
	pr_info("%s", __func__);

	platform_device_unregister(msm8960_snd_device);
	platform_device_unregister(msm8960_snd_tabla1x_device);
	gpio_free(PAMP_GPIO);
	mutex_destroy(&cdc_mclk_mutex);
}
module_exit(jet_audio_exit);

MODULE_DESCRIPTION("ALSA Platform Jet");
MODULE_LICENSE("GPL v2");
Example #8
0
static int __init multipdp_init(void)
{
	int ret;
	pdp_arg_t pdp_arg = { .id = 1, .ifname = "ttyCSD", };
	pdp_arg_t efs_arg = { .id = 8, .ifname = "ttyEFS", };
	pdp_arg_t gps_arg = { .id = 5, .ifname = "ttyGPS", };
	pdp_arg_t xtra_arg = { .id = 6, .ifname = "ttyXTRA", };
	pdp_arg_t smd_arg = { .id = 25, .ifname = "ttySMD", };
	pdp_arg_t pcm_arg = { .id = 30, .ifname = "ttyPCM", } ;
	
#ifdef LOOP_BACK_TEST	
	pdp_arg_t loopback_arg = { .id = 31, .ifname = "ttyLOBK", };
#endif

	/* run DPRAM I/O thread */
	ret = kernel_thread(dpram_thread, NULL, CLONE_FS | CLONE_FILES);
	if (ret < 0) {
		EPRINTK("kernel_thread() failed\n");
		return ret;
	}
	wait_for_completion(&dpram_complete);
	if (!dpram_task) {
		EPRINTK("DPRAM I/O thread error\n");
		return -EIO;
	}

	/* create serial device for Circuit Switched Data */
	ret = pdp_activate(&pdp_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for CSD\n");
		goto err0;
	}

	ret = pdp_activate(&efs_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for EFS\n");
		goto err1;
	}

	ret = pdp_activate(&gps_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for GPS\n");
		goto err2;
	}

	ret = pdp_activate(&xtra_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for XTRA\n");
		goto err3;
	}
	
	ret = pdp_activate(&smd_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for SMD\n");
		goto err4;
	}

	ret = pdp_activate(&pcm_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for SMD\n");
		goto err5;
	}

#ifdef LOOP_BACK_TEST	
	ret = pdp_activate(&loopback_arg, DEV_TYPE_SERIAL, DEV_FLAG_STICKY);
	if (ret < 0) {
		EPRINTK("failed to create a serial device for LoopBack\n");
		goto err6;
	}
#endif
	/* create app. interface device */
	ret = misc_register(&multipdp_dev);
	if (ret < 0) {
		EPRINTK("misc_register() failed\n");
		goto err1;
	}


#ifdef LOOP_BACK_TEST
	ret = device_create_file(multipdp_dev.this_device, &dev_attr_loopback);
#endif	

#ifdef CONFIG_PROC_FS
	create_proc_read_entry(APP_DEVNAME, 0, 0, 
			       multipdp_proc_read, NULL);
#endif

#ifdef	NO_TTY_DPRAM
	printk("multipdp_init:multipdp_rx_noti_regi calling");
	multipdp_rx_noti_regi(multipdp_rx_cback );	
#endif
//	printk(KERN_INFO 
//	       "$Id: multipdp.c,v 1.10 2008/01/11 05:40:56 melonzz Exp $\n");
	return 0;

#ifdef LOOP_BACK_TEST	
err6:
	pdp_deactivate(&loopback_arg, 1);
#endif	
err5:
	/* undo serial device for Circuit Switched Data */
	pdp_deactivate(&pcm_arg, 1);

err4:
	/* undo serial device for Circuit Switched Data */
	pdp_deactivate(&smd_arg, 1);

err3:
	/* undo serial device for Circuit Switched Data */
	pdp_deactivate(&xtra_arg, 1);
err2:
	/* undo serial device for Circuit Switched Data */
	pdp_deactivate(&gps_arg, 1);
err1:
	/* undo serial device for Circuit Switched Data */
	pdp_deactivate(&pdp_arg, 1);
err0:
	/* kill DPRAM I/O thread */
	if (dpram_task) {
		send_sig(SIGUSR1, dpram_task, 1);
		wait_for_completion(&dpram_complete);
	}
	return ret;
}

static void __exit multipdp_exit(void)
{
#ifdef CONFIG_PROC_FS
	remove_proc_entry(APP_DEVNAME, 0);
#endif

	/* remove app. interface device */
	misc_deregister(&multipdp_dev);

	/* clean up PDP context table */
	pdp_cleanup();

	/* kill DPRAM I/O thread */
	if (dpram_task) {
		send_sig(SIGUSR1, dpram_task, 1);
		wait_for_completion(&dpram_complete);
	}
}

//module_init(multipdp_init);
late_initcall(multipdp_init);
module_exit(multipdp_exit);

MODULE_AUTHOR("SAMSUNG ELECTRONICS CO., LTD");
MODULE_DESCRIPTION("Multiple PDP Muxer / Demuxer");
MODULE_LICENSE("GPL");
static int __init fighter_audio_init(void)
{
	int ret = 0, rc = 0;

	#ifdef CONFIG_AUDIO_USAGE_FOR_POWER_CONSUMPTION
	int retval = 0;
	#endif

	struct pm_gpio param = {
		.direction	= PM_GPIO_DIR_OUT,
		.output_buffer	= PM_GPIO_OUT_BUF_CMOS,
		.output_value	= 0,
		.pull		= PM_GPIO_PULL_NO,
		.vin_sel	= PM_GPIO_VIN_S4,
		.out_strength	= PM_GPIO_STRENGTH_MED,
		.function	= PM_GPIO_FUNC_NORMAL,
	};

	pr_debug("%s", __func__);

	msm8960_snd_device = platform_device_alloc("soc-audio", 0);
	if (!msm8960_snd_device) {
		pr_aud_err("%s, Platform device allocation failed\n", __func__);
		return -ENOMEM;
	}

	platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960);
	ret = platform_device_add(msm8960_snd_device);
	if (ret) {
		pr_aud_err("%s, Platform device add failed\n", __func__);
		platform_device_put(msm8960_snd_device);
		return ret;
	}

	#ifdef CONFIG_AUDIO_USAGE_FOR_POWER_CONSUMPTION
	/* Create two audio status file nodes, audio_speaker_t and
	 * audio_headset_t under /sys/audio_stats/					*/
	if (audio_stat_kobj == NULL)
	{
		audio_stat_kobj = kobject_create_and_add("audio_stats", NULL);
		retval = sysfs_create_file(audio_stat_kobj, attrs[0]);
		if (!retval)
		{
			pr_err("Speaker file node creation failed under kobject\n");
		}
		retval = sysfs_create_file(audio_stat_kobj, attrs[1]);
		if (!retval)
		{
			pr_err("Headset file node creation failed under kobject\n");
		}
	}
	#endif


	rc = gpio_request(PM8921_GPIO_PM_TO_SYS(FIGHTER_AUD_AMP_EN),
					"tpa2051_en");

	rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(FIGHTER_AUD_AMP_EN),
			&param);

	if (rc < 0)
		pr_aud_err("failed to configure tpa2051_en gpio\n");

	gpio_tlmm_config(msm_2051_gpio[0], GPIO_CFG_ENABLE);
	gpio_tlmm_config(msm_2051_gpio[1], GPIO_CFG_ENABLE);

	htc_8960_register_q6asm_ops(&qops);
	htc_8960_register_pcm_routing_ops(&rops);
	acoustic_register_ops(&acoustic);
	return ret;

}
late_initcall(fighter_audio_init);

static void __exit fighter_audio_exit(void)
{
	pr_debug("%s", __func__);
	platform_device_unregister(msm8960_snd_device);
}
Example #10
0
void  modem_time_sync(struct work_struct *work)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct timeval current_time;
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	do_gettimeofday(&current_time);

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	if((current_time.tv_sec - tv.tv_sec > 30) || (current_time.tv_sec - tv.tv_sec < -30) ) {
		do_settimeofday(&tv);
	}


err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	schedule_delayed_work(&time_sync_work, HZ*30);
}

int modem_time_sync_init(void)
{
	static bool first = true;
	if(first) {
		INIT_DELAYED_WORK(&time_sync_work, modem_time_sync);
		schedule_delayed_work(&time_sync_work, HZ*30);
		first = false;
	}
	return 0;
}
#endif
/*[ECID:000000] ZTEBSP zhangbo, sync time with modem, end*/


int rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	/*[ECID:000000] ZTEBSP zhangbo, sync time with modem, start*/
	#ifdef CONFIG_ZTE_TIME_SYNC_WITH_MODEM
	modem_time_sync_init();
	#endif
	/*[ECID:000000] ZTEBSP zhangbo, sync time with modem, end*/
	
	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	do_settimeofday(&tv);
	//[ECID:0000]ZTE_BSP maxiaoping 20121030 modify PLATFORM 8064 RTC alarm driver for power_off alarm,start.
	#ifdef CONFIG_ZTE_FIX_ALARM_SYNC
		fix_sync_alarm();
	#endif
	//[ECID:0000]ZTE_BSP maxiaoping 20121030 modify PLATFORM 8064 RTC alarm driver for power_off alarm,end.
	
	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
Example #11
0
static int __init rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	do_settimeofday(&tv);

	//                                                              
	#if 1
	{
		struct timespec ts;
		getnstimeofday(&ts);
		printk(KERN_UTC_BOOT "%d-%02d-%02d %02d:%02d:%02d.%06lu\n",
			tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
			tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec/1000);
	}
	#else
	//                                                            
	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);
	#endif

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
static int __init rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
	        .tv_nsec = NSEC_PER_SEC >> 1,
	    };
	    struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	    if (rtc == NULL) {
	            pr_err("%s: unable to open rtc device (%s)\n",
	                    __FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
	            goto err_open;
	    }

	    {
	            if(!strcmp("rtc1",CONFIG_RTC_HCTOSYS_DEVICE))
	            {
	                    struct rtc_device *rtc0 = rtc_class_open("rtc0");
	                    if(rtc0 == NULL)
	                    {
	                            pr_err("!!!!!!Robin: %s: unable to open rtc0 device!!!!!\n",
	                      __FILE__);
	                    }
				printk("read rtc1 time\n");	
	                    err = rtc_read_time(rtc, &tm);
				printk("set  rtc1 time 2 rtc0\n");	
	                    rtc_set_time(rtc0,&tm);
	                    rtc_class_close(rtc0);
	            }
	    }
	    if (err)
	    {
	            err = rtc_read_time(rtc, &tm);
			printk("rtc_read_time error\n");	
	
	            if (err) {
	                    dev_err(rtc->dev.parent,
	                                    "hctosys: unable to read the hardware clock\n");
	                    goto err_read;

	            }
	    }

	    err = rtc_valid_tm(&tm);
	    if (err) {
	            dev_err(rtc->dev.parent,
	                    "hctosys: invalid date/time\n");
	            goto err_invalid;
	    }

	    rtc_tm_to_time(&tm, &tv.tv_sec);

	    do_settimeofday(&tv);

	    dev_info(rtc->dev.parent,
	            "setting system clock to "
	            "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
	            tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,

	            tm.tm_hour, tm.tm_min, tm.tm_sec,
	            (unsigned int) tv.tv_sec);

	err_invalid:
	err_read:
	    rtc_class_close(rtc);

	err_open:
	    rtc_hctosys_ret = err;

	    return err;
}



#else
static int __init rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	{
		if(strcmp("rtc0",CONFIG_RTC_HCTOSYS_DEVICE))
		{
			struct rtc_device *rtc0 = rtc_class_open("rtc0");
			if(rtc0 == NULL)
			{
				pr_err("!!!!!!Robin: %s: unable to open rtc0 device!!!!!\n",
			  __FILE__);
			}
			err = rtc_read_time(rtc, &tm);
			rtc_set_time(rtc0,&tm);
			rtc_class_close(rtc0);
		}	
	}
	if (err)
	{
		err = rtc_read_time(rtc, &tm);
		if (err) {
			dev_err(rtc->dev.parent,
					"hctosys: unable to read the hardware clock\n");
			goto err_read;

		}
	}

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	do_settimeofday(&tv);

	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}
#endif
late_initcall(rtc_hctosys);