static int mfc_probe(struct platform_device *pdev) { struct s3c_platform_mfc *pdata; struct resource *res; size_t size; int ret; unsigned int mfc_port1_alloc_paddr; if (!pdev || !pdev->dev.platform_data) { dev_err(&pdev->dev, "Unable to probe mfc!\n"); return -1; } pdata = pdev->dev.platform_data; /* mfc clock enable should be here */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get memory region resource\n"); ret = -ENOENT; goto probe_out; } /* 60K is required for mfc register (0x0 ~ 0xe008) */ size = (res->end - res->start) + 1; mfc_mem = request_mem_region(res->start, size, pdev->name); if (mfc_mem == NULL) { dev_err(&pdev->dev, "failed to get memory region\n"); ret = -ENOENT; goto err_mem_req; } mfc_sfr_base_vaddr = ioremap(mfc_mem->start, mfc_mem->end - mfc_mem->start + 1); if (mfc_sfr_base_vaddr == NULL) { dev_err(&pdev->dev, "failed to ioremap address region\n"); ret = -ENOENT; goto err_mem_map; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get irq resource\n"); ret = -ENOENT; goto err_irq_res; } #if !defined(MFC_POLLING) ret = request_irq(res->start, mfc_irq, IRQF_DISABLED, pdev->name, pdev); if (ret != 0) { dev_err(&pdev->dev, "failed to install irq (%d)\n", ret); goto err_irq_req; } #endif mutex_init(&mfc_mutex); /* * buffer memory secure */ mfc_port0_base_paddr =(unsigned int)pdata->buf_phy_base[0]; mfc_port0_memsize = (unsigned int)pdata->buf_phy_size[0]; mfc_debug(" mfc_port0_base_paddr= 0x%x \n", mfc_port0_base_paddr); mfc_debug(" mfc_port0_memsize = 0x%x \n", mfc_port0_memsize); mfc_port0_base_paddr = ALIGN_TO_128KB(mfc_port0_base_paddr); mfc_port0_base_vaddr = phys_to_virt(mfc_port0_base_paddr); if (mfc_port0_base_vaddr == NULL) { mfc_err("fail to mapping port0 buffer\n"); ret = -EPERM; goto err_vaddr_map; } mfc_port1_alloc_paddr = (unsigned int)pdata->buf_phy_base[1]; mfc_port1_memsize = (unsigned int)pdata->buf_phy_size[1]; mfc_port1_base_paddr = (unsigned int)s5p_get_media_membase_bank(1); mfc_port1_base_paddr = ALIGN_TO_128KB(mfc_port1_base_paddr); mfc_debug(" mfc_port1_base_paddr= 0x%x \n", mfc_port1_base_paddr); mfc_debug(" mfc_port1_memsize = 0x%x \n", mfc_port1_memsize); mfc_port1_alloc_paddr = ALIGN_TO_128KB(mfc_port1_alloc_paddr); mfc_port1_base_vaddr = phys_to_virt(mfc_port1_alloc_paddr); if (mfc_port1_base_vaddr == NULL) { mfc_err("fail to mapping port1 buffer\n"); ret = -EPERM; goto err_vaddr_map; } mfc_set_port1_buff_paddr(mfc_port1_alloc_paddr); mfc_debug("mfc_port0_base_paddr = 0x%08x, mfc_port1_base_paddr = 0x%08x <<\n", (unsigned int)mfc_port0_base_paddr, (unsigned int)mfc_port1_base_paddr); mfc_debug("mfc_port0_base_vaddr = 0x%08x, mfc_port1_base_vaddr = 0x%08x <<\n", (unsigned int)mfc_port0_base_vaddr, (unsigned int)mfc_port1_base_vaddr); mfc_debug("mfc_port1_alloc_paddr = 0x%08x <<\n", (unsigned int)mfc_port1_alloc_paddr); /* Get mfc power domain regulator */ mfc_pd_regulator = regulator_get(&pdev->dev, "pd"); if (IS_ERR(mfc_pd_regulator)) { mfc_err("failed to find mfc power domain\n"); ret = PTR_ERR(mfc_pd_regulator); goto err_regulator_get; } mfc_sclk = clk_get(&pdev->dev, "sclk_mfc"); if (IS_ERR(mfc_sclk)) { mfc_err("failed to find mfc clock source\n"); ret = PTR_ERR(mfc_sclk); goto err_clk_get; } mfc_init_mem_inst_no(); mfc_init_buffer(); ret = misc_register(&mfc_miscdev); if (ret) { mfc_err("MFC can't misc register on minor\n"); goto err_misc_reg; } /* * MFC FW downloading */ ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, MFC_FW_NAME, &pdev->dev, GFP_KERNEL, pdev, mfc_firmware_request_complete_handler); if (ret) { mfc_err("MFCINST_ERR_FW_INIT_FAIL\n"); ret = -EPERM; goto err_req_fw; } return 0; err_req_fw: misc_deregister(&mfc_miscdev); err_misc_reg: clk_put(mfc_sclk); err_clk_get: regulator_put(mfc_pd_regulator); err_regulator_get: err_vaddr_map: free_irq(res->start, pdev); mutex_destroy(&mfc_mutex); err_irq_req: err_irq_res: iounmap(mfc_sfr_base_vaddr); err_mem_map: release_mem_region(mfc_mem, size); err_mem_req: probe_out: dev_err(&pdev->dev, "not found (%d).\n", ret); return ret; }
static int mfc_probe(struct platform_device *pdev) { struct resource *res; size_t size; int ret; #if ENABLE_MONITORING_MFC_DD mfc_info("MFC mfc_probe..dev_id(%d)\n",S5P_MDEV_MFC); #endif /* mfc clock enable should be here */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get memory region resource\n"); ret = -ENOENT; goto probe_out; } // 60K is required for mfc register (0x0 ~ 0xe008) size = (res->end - res->start) + 1; mfc_mem = request_mem_region(res->start, size, pdev->name); if (mfc_mem == NULL) { dev_err(&pdev->dev, "failed to get memory region\n"); ret = -ENOENT; goto probe_out; } mfc_sfr_base_vaddr = ioremap(mfc_mem->start, mfc_mem->end - mfc_mem->start + 1); if (mfc_sfr_base_vaddr == NULL) { dev_err(&pdev->dev, "failed to ioremap address region\n"); ret = -ENOENT; goto probe_out; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get irq resource\n"); ret = -ENOENT; goto probe_out; } #if !defined(MFC_POLLING) ret = request_irq(res->start, mfc_irq, IRQF_DISABLED, pdev->name, pdev); if (ret != 0) { dev_err(&pdev->dev, "failed to install irq (%d)\n", ret); goto probe_out; } #endif mutex_init(&mfc_mutex); /* * buffer memory secure */ mfc_port0_base_paddr = s5p_get_media_memory_bank(S5P_MDEV_MFC, 0); mfc_port0_base_paddr = ALIGN_TO_128KB(mfc_port0_base_paddr); mfc_port0_base_vaddr = phys_to_virt(mfc_port0_base_paddr); if (mfc_port0_base_vaddr == NULL) { mfc_err("fail to mapping port0 buffer\n"); ret = -EPERM; goto probe_out; } mfc_port1_base_paddr = s5p_get_media_memory_bank(S5P_MDEV_MFC, 1); mfc_port1_base_paddr = ALIGN_TO_128KB(mfc_port1_base_paddr); mfc_port1_base_vaddr = phys_to_virt(mfc_port1_base_paddr); if (mfc_port1_base_vaddr == NULL) { mfc_err("fail to mapping port1 buffer\n"); ret = -EPERM; goto probe_out; } // mfc_debug("mfc_port0_base_paddr = 0x%08x, mfc_port1_base_paddr = 0x%08x <<\n", // (unsigned int)mfc_port0_base_paddr, (unsigned int)mfc_port1_base_paddr); // mfc_debug("mfc_port0_base_vaddr = 0x%08x, mfc_port1_base_vaddr = 0x%08x <<\n", // (unsigned int)mfc_port0_base_vaddr, (unsigned int)mfc_port1_base_vaddr); /* * MFC FW downloading */ if (mfc_load_firmware() < 0) { mfc_err("MFCINST_ERR_FW_INIT_FAIL\n"); ret = -EPERM; goto probe_out; } mfc_init_mem_inst_no(); mfc_init_buffer(); mfc_clk = clk_get(&pdev->dev, "mfc"); if (mfc_clk == NULL) { printk(KERN_ERR "failed to find mfc clock source\n"); return -ENOENT; } ret = misc_register(&mfc_miscdev); return 0; probe_out: dev_err(&pdev->dev, "not found (%d). \n", ret); return ret; }