driver/kmd/armchina-aipu/aipu.c
/**
 * @armchina_aipu_probe() - probe operation for platfom driver provided by ArmChina
 * @p_dev: pointer to the AIPU platform device struct.
 * @soc:   pointer to aipu SoC struct contains soc specific data.
 *         this argument can be NULL if SoC vendor has no AIPU related soc data structure.
 * @ops:   pointer to aipu SoC operation struct.
 *         this argument can be NULL if SoC vendor does not provide any soc operation. In
 *         this case the SoC related operations in AIPU driver are unavailable.
 *
 * This function should be called in a SoC vendor provided xx_aipu_probe() function,
 * which is registered to the platfom_driver struct; if no such xx_aipu_probe() is provided,
 * SoC vendor should directly register this function to the platfom_driver struct.
 *
 * Return: 0 on success and error code otherwise.
 */
@armchina_aipu_probe() - probe operation for platfom driver provided by ArmChina
@p_dev: pointer to the AIPU platform device struct.
@soc:   pointer to aipu SoC struct contains soc specific data.
this argument can be NULL if SoC vendor has no AIPU related soc data structure.
@ops:   pointer to aipu SoC operation struct.
this argument can be NULL if SoC vendor does not provide any soc operation. In
this case the SoC related operations in AIPU driver are unavailable.

This function should be called in a SoC vendor provided xx_aipu_probe() function,
which is registered to the platfom_driver struct; if no such xx_aipu_probe() is provided,
SoC vendor should directly register this function to the platfom_driver struct.

0 on success and error code otherwise.
@armchina_aipu_probe () - probe operation for platfom driver provided by ArmChina @p_dev : pointer to the AIPU platform device struct . @soc : pointer to aipu SoC struct contains soc specific data . this argument can be NULL if SoC vendor has no AIPU related soc data structure . @ops : pointer to aipu SoC operation struct . this argument can be NULL if SoC vendor does not provide any soc operation . In this case the SoC related operations in AIPU driver are unavailable . This function should be called in a SoC vendor provided xx_aipu_probe () function which is registered to the platfom_driver struct ; if no such xx_aipu_probe () is provided SoC vendor should directly register this function to the platfom_driver struct . 0 on success and error code otherwise .
int armchina_aipu_probe(struct platform_device *p_dev, struct aipu_soc *soc,
			struct aipu_soc_operations *ops)
{
	int ret = 0;
	struct device *dev = &p_dev->dev;
	struct aipu_core *core = NULL;
	int version = 0;
	int config = 0;
	int id = 0;
	if (!aipu) {
		aipu = devm_kzalloc(dev, sizeof(*aipu), GFP_KERNEL);
		if (!aipu)
			return -ENOMEM;
		dev_info(dev, "AIPU KMD probe start...\n");
		ret = init_aipu_priv(aipu, p_dev, &aipu_fops, soc, ops);
		if (ret)
			return ret;
	}
	zhouyi_detect_aipu_version(p_dev, &version, &config);
	of_property_read_u32(dev->of_node, "core-id", &id);
	if (version == AIPU_ISA_VERSION_ZHOUYI_V1 ||
	    version == AIPU_ISA_VERSION_ZHOUYI_V2 ||
	    version == AIPU_ISA_VERSION_ZHOUYI_V3) {
		dev_info(dev, "AIPU core #%d detected: zhouyi-v%d-%04d\n", id, version, config);
	} else {
		dev_err(dev, "unsupported AIPU core detected (id %d, version 0x%x)\n",
			id, version);
		ret = -EINVAL;
		goto out_clean;
	}
	core = devm_kzalloc(dev, sizeof(*core), GFP_KERNEL);
	if (!core) {
		ret = -ENOMEM;
		goto out_clean;
	}
	ret = aipu_priv_add_core(aipu, core, version, id, p_dev);
	if (ret)
		goto out_clean;
	dev_info(dev, "initialize AIPU core #%d done\n", id);
	platform_set_drvdata(p_dev, core);
	goto finish;
out_clean:
	armchina_aipu_remove(p_dev);
finish:
	return ret;
}
int armchina_aipu_probe ( struct platform_device * p_dev , struct aipu_soc * soc , struct aipu_soc_operations * ops ) { int ret = 0 ; struct device * dev = & p_dev -> dev ; struct aipu_core * core = NULL ; int version = 0 ; int config = 0 ; int id = 0 ; if ( ! aipu ) { aipu = devm_kzalloc ( dev , sizeof ( * aipu ) , GFP_KERNEL ) ; if ( ! aipu ) return - ENOMEM ; dev_info ( dev , " \n " ) ; ret = init_aipu_priv ( aipu , p_dev , & aipu_fops , soc , ops ) ; if ( ret ) return ret ; } zhouyi_detect_aipu_version ( p_dev , & version , & config ) ; of_property_read_u32 ( dev -> of_node , " " , & id ) ; if ( version == AIPU_ISA_VERSION_ZHOUYI_V1 || version == AIPU_ISA_VERSION_ZHOUYI_V2 || version == AIPU_ISA_VERSION_ZHOUYI_V3 ) { dev_info ( dev , " \n " , id , version , config ) ; } else { dev_err ( dev , " \n " , id , version ) ; ret = - EINVAL ; goto out_clean ; } core = devm_kzalloc ( dev , sizeof ( * core ) , GFP_KERNEL ) ; if ( ! core ) { ret = - ENOMEM ; goto out_clean ; } ret = aipu_priv_add_core ( aipu , core , version , id , p_dev ) ; if ( ret ) goto out_clean ; dev_info ( dev , " \n " , id ) ; platform_set_drvdata ( p_dev , core ) ; goto finish ; out_clean : armchina_aipu_remove ( p_dev ) ; finish : return ret ; }
@armchina_aipu_probe() - probe operation for platfom driver provided by ArmChina
 @p_dev: pointer to the AIPU platform device struct.
@armchina_aipu_probe () - probe operation for platfom driver provided by ArmChina @p_dev : pointer to the AIPU platform device struct .
/* create & init aipu priv struct shared by all cores */