Example #1
0
static int anatop_thermal_probe(struct platform_device *pdev)
{
	int retval = 0;
	struct resource *res;
	void __iomem *base;
	struct anatop_device *device;

	device = kzalloc(sizeof(*device), GFP_KERNEL);
	if (!device) {
		retval = -ENOMEM;
		goto device_alloc_failed;
	}

	platform_set_drvdata(pdev, device);

	/* ioremap the base address */
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "No anatop base address provided!\n");
		goto anatop_failed;
	}

	base = ioremap(res->start, res->end - res->start);
	if (base == NULL) {
		dev_err(&pdev->dev, "failed to remap anatop base address!\n");
		goto anatop_failed;
	}
	anatop_base = (unsigned long)base;
	raw_n25c = DEFAULT_N25C;

	anatop_thermal_add(device);
	anatop_thermal_cpufreq_init();
	pr_info("%s: default cooling device is cpufreq!\n", __func__);

	goto success;
anatop_failed:
	kfree(device);
device_alloc_failed:
success:

	return retval;
}
Example #2
0
static int anatop_thermal_probe(struct platform_device *pdev)
{
	int retval = 0;
	struct resource *res_io, *res_irq, *res_calibration;
	void __iomem *base, *calibration_addr;
	struct anatop_device *device;

	device = kzalloc(sizeof(*device), GFP_KERNEL);
	if (!device) {
		retval = -ENOMEM;
		goto device_alloc_failed;
	}

	platform_set_drvdata(pdev, device);

	/* ioremap the base address */
	res_io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res_io == NULL) {
		dev_err(&pdev->dev, "No anatop base address provided!\n");
		goto anatop_failed;
	}

	base = ioremap(res_io->start, res_io->end - res_io->start);
	if (base == NULL) {
		dev_err(&pdev->dev, "failed to remap anatop base address!\n");
		goto anatop_failed;
	}
	anatop_base = (unsigned long)base;
	/* ioremap the calibration data address */
	res_calibration = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	if (res_calibration == NULL) {
		dev_err(&pdev->dev, "No anatop calibration data address provided!\n");
		goto anatop_failed;
	}

	calibration_addr = ioremap(res_calibration->start,
		res_calibration->end - res_calibration->start);
	if (calibration_addr == NULL) {
		dev_err(&pdev->dev, "failed to remap anatop calibration data address!\n");
		goto anatop_failed;
	}

	pll3_clk = clk_get(NULL, "pll3_main_clk");
	if (IS_ERR(pll3_clk)) {
		retval = -ENOENT;
		goto anatop_failed;
	}

	raw_n40c = DEFAULT_N40C;
	/* use calibration data to get ratio */
	anatop_thermal_counting_ratio(__raw_readl(calibration_addr));

	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (res_irq == NULL) {
		dev_err(&pdev->dev, "No anatop thermal irq provided!\n");
		goto anatop_failed;
	}
	retval = request_irq(res_irq->start, anatop_thermal_alarm_handler, 0, "THERMAL_ALARM_IRQ",
			  NULL);
	thermal_irq = res_irq->start;


	anatop_thermal_add(device);
	anatop_thermal_cpufreq_init();
	retval = device_create_file(&pdev->dev, &anatop_thermal_flag_dev_attr);
	if (retval)
		dev_err(&pdev->dev, "create device file failed!\n");
	pr_info("%s: default cooling device is cpufreq!\n", __func__);

	goto success;
anatop_failed:
	kfree(device);
device_alloc_failed:
success:

	return retval;
}