int register_tx_isp_vic_device(struct platform_device *pdev, struct v4l2_device *v4l2_dev)
{
	struct tx_isp_subdev_platform_data *pdata = pdev->dev.platform_data;
	struct tx_isp_vic_driver *vsd = NULL;
	struct resource *res = NULL;
	struct v4l2_subdev *sd = NULL;
	struct media_pad *pads = NULL;
	struct media_entity *me = NULL;
	struct proc_dir_entry *proc;
	int ret;

	if(!pdata){
		v4l2_err(v4l2_dev, "The platform_data of csi is NULL!\n");
		ret = -ISP_ERROR;
		goto exit;
	};
	vsd = (struct tx_isp_vic_driver *)kzalloc(sizeof(*vsd), GFP_KERNEL);
	if(!vsd){
		v4l2_err(v4l2_dev, "Failed to allocate sensor device\n");
		ret = -ISP_ERROR;
		goto exit;
	}
	vsd->pdata = pdata;
	vsd->dev = &pdev->dev;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if(res){
		res = request_mem_region(res->start,
				res->end - res->start + 1, dev_name(&pdev->dev));
		if (!res) {
			v4l2_err(v4l2_dev, "Not enough memory for resources\n");
			ret = -EBUSY;
			goto mem_region_failed;
		}
		vsd->base = ioremap(res->start, res->end - res->start + 1);
		if (!vsd->base) {
			v4l2_err(v4l2_dev, "Unable to ioremap registers!\n");
			ret = -ENXIO;
			goto ioremap_failed;
		}
	}
	vsd->res = res;
	sd = &vsd->sd;
	pads = vsd->pads;
	me = &sd->entity;

	v4l2_subdev_init(sd, &vic_subdev_ops);
	strlcpy(sd->name, "TX-ISP-VIC-SUBDEV ", sizeof(sd->name));

	sd->grp_id = pdata->grp_id ;	/* group ID for isp subdevs */
	v4l2_set_subdevdata(sd, vsd);

	pads[TX_ISP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
	pads[TX_ISP_PAD_LINK].flags = MEDIA_PAD_FL_SINK;

	me->ops = &vic_media_ops;
//	me->parent = v4l2_dev->mdev;
	ret = media_entity_init(me, TX_ISP_PADS_NUM, pads, 0);
	if (ret < 0){
		v4l2_err(v4l2_dev, "Failed to init media entity!\n");
		ret = -ISP_ERROR;
		goto entity_init_failed;
	}
	ret = v4l2_device_register_subdev(v4l2_dev, sd);
	if (ret < 0){
		v4l2_err(v4l2_dev, "Failed to register vic-subdev!\n");
		ret = -ISP_ERROR;
		goto register_failed;
	}

	ret = isp_vic_init_clk(vsd);
	if(ret < 0){
		v4l2_err(v4l2_dev, "Failed to init isp's clks!\n");
		ret = -ISP_ERROR;
	}
	dump_vsd=vsd;

	/* creat the node of printing isp info */
	proc = jz_proc_mkdir("vic");
	if (!proc) {
		vsd->proc_vic = NULL;
		v4l2_err(v4l2_dev, "create dev_attr_isp_info failed!\n");
	} else {
		vsd->proc_vic = proc;
	}
	proc_create_data("isp_vic_frd", S_IRUGO, proc, &isp_vic_frd_fops, (void *)vsd);

	return ISP_SUCCESS;
register_failed:
	media_entity_cleanup(me);
entity_init_failed:
	if(vsd->base)
		iounmap(vsd->base);
ioremap_failed:
	if(res)
		release_mem_region(res->start,res->end - res->start + 1);
mem_region_failed:
	kfree(vsd);
exit:
	return ret;
}
Beispiel #2
0
/*
 * /proc/jz/xxx entry
 *
 */
static int __init jz_proc_init(void)
{
	struct proc_dir_entry *res;
	struct proc_dir_entry *jz_proc;
	unsigned int virt_addr, i;
#ifndef CONFIG_USE_JZ_ROOT_DIR
	jz_proc = jz_proc_mkdir("mem");
#else
	jz_proc = get_jz_proc_root();
#endif
	/*
	 * Reserve a 16MB memory for IPU on JZ.
	 */
	jz_imem_base = (unsigned int)__get_free_pages(GFP_KERNEL, IMEM_MAX_ORDER);
	if (jz_imem_base) {
		/* imem (IPU memory management) */
		res = create_proc_entry("imem", 0644, jz_proc);
		if (res) {
			res->read_proc = imem_read_proc;
			res->write_proc = imem_write_proc;
			res->data = NULL;
		}

		/* Set page reserved */
		virt_addr = jz_imem_base;
		for (i = 0; i < (1 << IMEM_MAX_ORDER); i++) {
			SetPageReserved(virt_to_page((void *)virt_addr));
			virt_addr += PAGE_SIZE;
		}

		/* Convert to physical address */
		jz_imem_base = virt_to_phys((void *)jz_imem_base);

		printk("Total %dMB memory at 0x%x was reserved for IPU\n",
		       (unsigned int)((1 << IMEM_MAX_ORDER) * PAGE_SIZE)/1000000, jz_imem_base);
	}
        else
           printk("NOT enough memory for imem\n");

        jz_imem1_base = (unsigned int)__get_free_pages(GFP_KERNEL, IMEM1_MAX_ORDER);
        if (jz_imem1_base) {
                /* imem (IPU memory management) */
                res = create_proc_entry("imem1", 0644, jz_proc);
                if (res) {
                        res->read_proc = imem1_read_proc;
                        res->write_proc = imem1_write_proc;
                        res->data = NULL;
                }

                /* Set page reserved */
                virt_addr = jz_imem1_base;
                for (i = 0; i < (1 << IMEM1_MAX_ORDER); i++) {
                        SetPageReserved(virt_to_page((void *)virt_addr));
                        virt_addr += PAGE_SIZE;
                }

                /* Convert to physical address */
                jz_imem1_base = virt_to_phys((void *)jz_imem1_base);

                printk("Total %dMB memory1 at 0x%x was reserved for IPU\n",
                       (unsigned int)((1 << IMEM1_MAX_ORDER) * PAGE_SIZE)/1000000, jz_imem1_base);
        }
        else
           printk("NOT enough memory for imem1\n");

	return 0;
}