static int tmu_initialize(struct platform_device *pdev) { struct tmu_info *info = platform_get_drvdata(pdev); unsigned int en; int ret; en = (__raw_readl(info->tmu_base + TMU_STATUS) & 0x1); if (!en) { dev_err(&pdev->dev, "failed to start tmu drvier\n"); return -ENOENT; } if (soc_is_exynos4210()) ret = exynos4210_tmu_init(info); else ret = exynos_tmu_init(info); return ret; }
static int __devinit tmu_probe(struct platform_device *pdev) { struct tmu_info *info; struct resource *res; int ret; if (dev_get_platdata(&pdev->dev) == NULL) { dev_err(&pdev->dev, "No platform data\n"); ret = -ENODEV; goto err_out; } info = devm_kzalloc(&pdev->dev, sizeof(struct tmu_info), GFP_KERNEL); if (info == NULL) { dev_err(&pdev->dev, "failed to alloc memory!\n"); ret = -ENOMEM; goto err_out; } info->dev = &pdev->dev; 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_out; } info->tmu_base = devm_request_and_ioremap(&pdev->dev, res); if (info->tmu_base == NULL) { dev_err(&pdev->dev, "failed ioremap()\n"); ret = -ENOMEM; goto err_out; } INIT_DELAYED_WORK_DEFERRABLE(&info->polling, tmu_monitor); 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_out; } info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) { dev_err(&pdev->dev, "no irq for thermal\n"); ret = info->irq; goto err_wq; } platform_set_drvdata(pdev, info); ret = exynos_tmu_init(info); if (ret < 0) goto err_noinit; ret = request_irq(info->irq, tmu_irq, IRQF_DISABLED, "tmu", info); if (ret) { dev_err(&pdev->dev, "IRQ%d error %d\n", info->irq, ret); ret = -EBUSY; goto err_noinit; } tmu_debugfs = debugfs_create_file("tmu_dev_status", S_IRUGO, NULL, info, &tmu_dev_status_fops); if (IS_ERR_OR_NULL(tmu_debugfs)) { tmu_debugfs = NULL; dev_err(&pdev->dev, "%s: debugfs_create_file() failed\n", __func__); goto err_nodbgfs; } dev_info(&pdev->dev, "Tmu Initialization is sucessful...!\n"); return 0; err_nodbgfs: free_irq(info->irq, NULL); err_noinit: platform_set_drvdata(pdev, NULL); err_wq: destroy_workqueue(tmu_monitor_wq); err_out: dev_err(&pdev->dev, "initialization failed.\n"); return ret; }