예제 #1
0
static void check_usb_vbus_state(int state)
{
	struct device_node *np = NULL;
	struct platform_device *pdev = NULL;

	pr_info("%s vbus state = %d\n", __func__, state);

	np = of_find_compatible_node(NULL, NULL, "samsung,exynos5-dwusb3");
	if (np) {
		pdev = of_find_device_by_node(np);
		of_node_put(np);
		if (pdev) {
			pr_info("%s: get the %s platform_device\n",
			__func__, pdev->name);
			dwc3_exynos_vbus_event(&pdev->dev, state);
			goto end;
		}
	}

	np = of_find_compatible_node(NULL, NULL, "samsung,exynos_udc");
	if (np) {
		pdev = of_find_device_by_node(np);
		of_node_put(np);
		if (pdev) {
			pr_info("%s: get the %s platform_device\n",
			__func__, pdev->name);
			exynos_otg_vbus_event(pdev, state);
			goto end;
		}
	}
	pr_err("%s: failed to get the platform_device\n", __func__);
end:
	return;
}
예제 #2
0
static struct bbc_i2c_bus * __init attach_one_i2c(struct of_device *op, int index)
{
	struct bbc_i2c_bus *bp;
	struct device_node *dp;
	int entry;

	bp = kzalloc(sizeof(*bp), GFP_KERNEL);
	if (!bp)
		return NULL;

	bp->i2c_control_regs = of_ioremap(&op->resource[0], 0, 0x2, "bbc_i2c_regs");
	if (!bp->i2c_control_regs)
		goto fail;

	bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel");
	if (!bp->i2c_bussel_reg)
		goto fail;

	bp->waiting = 0;
	init_waitqueue_head(&bp->wq);
	if (request_irq(op->irqs[0], bbc_i2c_interrupt,
			IRQF_SHARED, "bbc_i2c", bp))
		goto fail;

	bp->index = index;
	bp->op = op;

	spin_lock_init(&bp->lock);

	entry = 0;
	for (dp = op->node->child;
	     dp && entry < 8;
	     dp = dp->sibling, entry++) {
		struct of_device *child_op;

		child_op = of_find_device_by_node(dp);
		bp->devs[entry].device = child_op;
		bp->devs[entry].client_claimed = 0;
	}

	writeb(I2C_PCF_PIN, bp->i2c_control_regs + 0x0);
	bp->own = readb(bp->i2c_control_regs + 0x01);
	writeb(I2C_PCF_PIN | I2C_PCF_ES1, bp->i2c_control_regs + 0x0);
	bp->clock = readb(bp->i2c_control_regs + 0x01);

	printk(KERN_INFO "i2c-%d: Regs at %p, %d devices, own %02x, clock %02x.\n",
	       bp->index, bp->i2c_control_regs, entry, bp->own, bp->clock);

	reset_one_i2c(bp);

	return bp;

fail:
	if (bp->i2c_bussel_reg)
		of_iounmap(&op->resource[1], bp->i2c_bussel_reg, 1);
	if (bp->i2c_control_regs)
		of_iounmap(&op->resource[0], bp->i2c_control_regs, 2);
	kfree(bp);
	return NULL;
}
예제 #3
0
파일: of_gpio.c 프로젝트: bmourit/barebox
/**
 * of_get_named_gpio_flags() - Get a GPIO number and flags to use with GPIO API
 * @np:		device node to get GPIO from
 * @propname:	property name containing gpio specifier(s)
 * @index:	index of the GPIO
 * @flags:	a flags pointer to fill in
 *
 * Returns GPIO number to use with GPIO API, or one of the errno value on the
 * error condition. If @flags is not NULL the function also fills in flags for
 * the GPIO.
 */
int of_get_named_gpio_flags(struct device_node *np, const char *propname,
			   int index, enum of_gpio_flags *flags)
{
	struct of_phandle_args out_args;
	struct device_d *dev;
	int ret;

	ret = of_parse_phandle_with_args(np, propname, "#gpio-cells",
					index, &out_args);
	if (ret) {
		pr_debug("%s: cannot parse %s property: %d\n",
			__func__, propname, ret);
		return ret;
	}

	dev = of_find_device_by_node(out_args.np);
	if (!dev) {
		pr_err("%s: unable to find device of node %s: %d\n",
			__func__, out_args.np->full_name, ret);
		return ret;
	}

	ret = gpio_get_num(dev, out_args.args[0]);
	if (ret < 0) {
		pr_err("%s: unable to get gpio num of device %s: %d\n",
			__func__, dev_name(dev), ret);
		return ret;
	}

	if (flags)
		*flags = out_args.args[1];

	return ret;
}
static int mhl_tx_get_dt_data(struct device *dev_)
{
	int rc = 0;
	struct device_node *of_node = NULL;
	struct platform_device *op = NULL;

	of_node = dev_->of_node;
	if (!of_node) {
		pr_err("%s: invalid of_node\n", __func__);
		goto error;
	}

	op = of_find_device_by_node(of_node->parent);
	if (!op) {
		pr_err("%s: invalid op\n", __func__);
		goto error;
	}

	mhl_clk = clk_get(&op->dev, "");
	if (!mhl_clk) {
		pr_err("%s: invalid clk\n", __func__);
		goto error;
	}

	rc = get_gpios_from_device_tree(of_node);
	if (rc) {
		pr_err("%s: error gpio init\n", __func__);
		goto error;
	}

	return 0;
error:
	pr_err("%s: ret due to err\n", __func__);
	return rc;
} /* mhl_tx_get_dt_data */
static int tegra132_ccplex_suspend(void)
{
	int i;
	struct device_node *node;

	pll_x_rate = clk_get_rate(clks[TEGRA132_PLL_X]);

	for (i = 0; i < BURST_POLICY_REG_SIZE; i++)
		cclk_burst_policy_ctx[i] = car_readl(CCLK_BURST_POLICY, i);

	if (!dfll_pdev) {
		node = of_find_compatible_node(NULL, NULL,
					       "nvidia,tegra132-dfll");
		if (node)
			dfll_pdev = of_find_device_by_node(node);
		of_node_put(node);

		if (!dfll_pdev)
			pr_err("dfll node not found. no suspend for dfll\n");
	}

	if (dfll_pdev)
		tegra_dfll_suspend(dfll_pdev);

	return 0;
}
예제 #6
0
static int stm32_sai_set_sync(struct stm32_sai_data *sai_client,
			      struct device_node *np_provider,
			      int synco, int synci)
{
	struct platform_device *pdev = of_find_device_by_node(np_provider);
	struct stm32_sai_data *sai_provider;
	int ret;

	if (!pdev) {
		dev_err(&sai_client->pdev->dev,
			"Device not found for node %pOFn\n", np_provider);
		return -ENODEV;
	}

	sai_provider = platform_get_drvdata(pdev);
	if (!sai_provider) {
		dev_err(&sai_client->pdev->dev,
			"SAI sync provider data not found\n");
		return -EINVAL;
	}

	/* Configure sync client */
	ret = stm32_sai_sync_conf_client(sai_client, synci);
	if (ret < 0)
		return ret;

	/* Configure sync provider */
	return stm32_sai_sync_conf_provider(sai_provider, synco);
}
예제 #7
0
static int dpaa_get_ts_info(struct net_device *net_dev,
			    struct ethtool_ts_info *info)
{
	struct device *dev = net_dev->dev.parent;
	struct device_node *mac_node = dev->of_node;
	struct device_node *fman_node = NULL, *ptp_node = NULL;
	struct platform_device *ptp_dev = NULL;
	struct qoriq_ptp *ptp = NULL;

	info->phc_index = -1;

	fman_node = of_get_parent(mac_node);
	if (fman_node)
		ptp_node = of_parse_phandle(fman_node, "ptimer-handle", 0);

	if (ptp_node)
		ptp_dev = of_find_device_by_node(ptp_node);

	if (ptp_dev)
		ptp = platform_get_drvdata(ptp_dev);

	if (ptp)
		info->phc_index = ptp->phc_index;

	info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
				SOF_TIMESTAMPING_RX_HARDWARE |
				SOF_TIMESTAMPING_RAW_HARDWARE;
	info->tx_types = (1 << HWTSTAMP_TX_OFF) |
			 (1 << HWTSTAMP_TX_ON);
	info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
			   (1 << HWTSTAMP_FILTER_ALL);

	return 0;
}
예제 #8
0
static int __init caam_sm_test_init(void)
{
	struct device_node *dev_node;
	struct platform_device *pdev;

	/*
	 * Do of_find_compatible_node() then of_find_device_by_node()
	 * once a functional device tree is available
	 */
	dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0");
	if (!dev_node) {
		dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0");
		if (!dev_node)
			return -ENODEV;
	}

	pdev = of_find_device_by_node(dev_node);
	if (!pdev)
		return -ENODEV;

	of_node_put(dev_node);

	caam_sm_example_init(pdev);

	return 0;
}
예제 #9
0
파일: dsi.c 프로젝트: ezequielgarcia/linux
static int dsi_get_phy(struct msm_dsi *msm_dsi)
{
	struct platform_device *pdev = msm_dsi->pdev;
	struct platform_device *phy_pdev;
	struct device_node *phy_node;

	phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0);
	if (!phy_node) {
		dev_err(&pdev->dev, "cannot find phy device\n");
		return -ENXIO;
	}

	phy_pdev = of_find_device_by_node(phy_node);
	if (phy_pdev)
		msm_dsi->phy = platform_get_drvdata(phy_pdev);

	of_node_put(phy_node);

	if (!phy_pdev || !msm_dsi->phy) {
		dev_err(&pdev->dev, "%s: phy driver is not ready\n", __func__);
		return -EPROBE_DEFER;
	}

	msm_dsi->phy_dev = get_device(&phy_pdev->dev);

	return 0;
}
예제 #10
0
파일: secvio.c 프로젝트: aimybbe/linux-imx6
static int __init caam_secvio_init(void)
{
	struct device_node *dev_node;
	struct platform_device *pdev;

	/*
	 * Do of_find_compatible_node() then of_find_device_by_node()
	 * once a functional device tree is available
	 */
	dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0");
	if (!dev_node) {
		dev_node = of_find_compatible_node(NULL, NULL,
				"arm,imx6-caam-secvio");
		if (!dev_node)
			return -ENODEV;
	}

	pdev = of_find_device_by_node(dev_node);
	if (!pdev)
		return -ENODEV;

	of_node_put(dev_node);

	return caam_secvio_startup(pdev);
}
예제 #11
0
int setup_opps(void)
{
	struct device_node *np;
	struct platform_device *pdev;
	int err;

	np = of_find_node_by_name(NULL, "gpu");
	if (!np) {
		pr_err("Failed to find DT entry for Mali\n");
		return -EFAULT;
	}

	pdev = of_find_device_by_node(np);
	if (!pdev) {
		pr_err("Failed to find device for Mali\n");
		of_node_put(np);
		return -EFAULT;
	}

	err = init_juno_opps_from_scpi(&pdev->dev);

	of_node_put(np);

	return err;
}
예제 #12
0
/* Register FIMC, FIMC-LITE and CSIS media entities */
static int fimc_md_register_platform_entities(struct fimc_md *fmd,
					      struct device_node *parent)
{
	struct device_node *node;
	int ret = 0;

	for_each_available_child_of_node(parent, node) {
		struct platform_device *pdev;
		int plat_entity = -1;

		pdev = of_find_device_by_node(node);
		if (!pdev)
			continue;

		/* If driver of any entity isn't ready try all again later. */
		if (!strcmp(node->name, CSIS_OF_NODE_NAME))
			plat_entity = IDX_CSIS;
		else if	(!strcmp(node->name, FIMC_IS_OF_NODE_NAME))
			plat_entity = IDX_IS_ISP;
		else if (!strcmp(node->name, FIMC_LITE_OF_NODE_NAME))
			plat_entity = IDX_FLITE;
		else if	(!strcmp(node->name, FIMC_OF_NODE_NAME) &&
			 !of_property_read_bool(node, "samsung,lcd-wb"))
			plat_entity = IDX_FIMC;

		if (plat_entity >= 0)
			ret = fimc_md_register_platform_entity(fmd, pdev,
							plat_entity);
		put_device(&pdev->dev);
		if (ret < 0)
			break;
	}

	return ret;
}
예제 #13
0
파일: slimport.c 프로젝트: MrJwiz/UBER-M
/* Link integrity check is sometimes failed without external the power.
 * This is a workaround for this failure. Enabling the USB clk help
 * this issue.
 */
static void anx7808_get_usb_clk(struct i2c_client *client)
{
	struct anx7808_data *anx7808 = i2c_get_clientdata(client);
	struct device_node *dev_node = client->dev.of_node;
	struct device_node *node;
	struct platform_device *pdev;

	node = of_parse_phandle(dev_node, "analogix,usb", 0);
	if (!node) {
		pr_warn("can't find dwc-usb3-msm phandle\n");
		return;
	}

	pdev = of_find_device_by_node(node);
	if (!pdev) {
		pr_warn("can't find the device by node\n");
		return;
	}

	anx7808->usb_clk = clk_get(&pdev->dev, "ref_clk");
	if (IS_ERR(anx7808->usb_clk)) {
		pr_warn("can't get usb3 ref_clk\n");
		return;
	}

	atomic_set(&anx7808->usb_clk_count, 0);
	pr_info("clk: %d\n", (int)clk_get_rate(anx7808->usb_clk));
}
예제 #14
0
unsigned int irq_of_parse_and_map(struct device_node *node, int index)
{
	struct of_device *op = of_find_device_by_node(node);

	if (!op || index >= op->num_irqs)
		return 0;

	return op->irqs[index];
}
예제 #15
0
int of_address_to_resource(struct device_node *node, int index,
			   struct resource *r)
{
	struct platform_device *op = of_find_device_by_node(node);

	if (!op || index >= op->num_resources)
		return -EINVAL;

	memcpy(r, &op->archdata.resource[index], sizeof(*r));
	return 0;
}
예제 #16
0
void __iomem *of_iomap(struct device_node *node, int index)
{
	struct platform_device *op = of_find_device_by_node(node);
	struct resource *r;

	if (!op || index >= op->num_resources)
		return NULL;

	r = &op->archdata.resource[index];

	return of_ioremap(r, 0, resource_size(r), (char *) r->name);
}
static int hdmi_i2c2_hack_init(struct device *dev)
{
	struct device_node *node;

	node = of_parse_phandle(dev->of_node, "mcasp-gpio", 0);

	if (!node)
		return -ENODEV;

	mcasp = of_find_device_by_node(node);

	return 0;
}
예제 #18
0
파일: bcm2835_smi.c 프로젝트: EvanHa/rbp
struct bcm2835_smi_instance *bcm2835_smi_get(struct device_node *node)
{
	struct platform_device *pdev;

	if (!node)
		return NULL;

	pdev = of_find_device_by_node(node);
	if (!pdev)
		return NULL;

	return platform_get_drvdata(pdev);
}
예제 #19
0
int __init init_common(struct tsens_device *tmdev)
{
	void __iomem *tm_base, *srot_base;
	struct resource *res;
	u32 code;
	int ret;
	struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node);
	u16 ctrl_offset = tmdev->reg_offsets[SROT_CTRL_OFFSET];

	if (!op)
		return -EINVAL;

	if (op->num_resources > 1) {
		/* DT with separate SROT and TM address space */
		tmdev->tm_offset = 0;
		res = platform_get_resource(op, IORESOURCE_MEM, 1);
		srot_base = devm_ioremap_resource(&op->dev, res);
		if (IS_ERR(srot_base))
			return PTR_ERR(srot_base);

		tmdev->srot_map = devm_regmap_init_mmio(tmdev->dev, srot_base,
							&tsens_srot_config);
		if (IS_ERR(tmdev->srot_map))
			return PTR_ERR(tmdev->srot_map);

	} else {
		/* old DTs where SROT and TM were in a contiguous 2K block */
		tmdev->tm_offset = 0x1000;
	}

	res = platform_get_resource(op, IORESOURCE_MEM, 0);
	tm_base = devm_ioremap_resource(&op->dev, res);
	if (IS_ERR(tm_base))
		return PTR_ERR(tm_base);

	tmdev->tm_map = devm_regmap_init_mmio(tmdev->dev, tm_base, &tsens_config);
	if (IS_ERR(tmdev->tm_map))
		return PTR_ERR(tmdev->tm_map);

	if (tmdev->srot_map) {
		ret = regmap_read(tmdev->srot_map, ctrl_offset, &code);
		if (ret)
			return ret;
		if (!(code & TSENS_EN)) {
			dev_err(tmdev->dev, "tsens device is not enabled\n");
			return -ENODEV;
		}
	}

	return 0;
}
예제 #20
0
static int __init lirc_rpi_init(void)
{
	struct device_node *node;
	int result;

	/* Init read buffer. */
	result = lirc_buffer_init(&rbuf, sizeof(int), RBUF_LEN);
	if (result < 0)
		return -ENOMEM;

	result = platform_driver_register(&lirc_rpi_driver);
	if (result) {
		printk(KERN_ERR LIRC_DRIVER_NAME
		       ": lirc register returned %d\n", result);
		goto exit_buffer_free;
	}

	node = of_find_compatible_node(NULL, NULL,
				       lirc_rpi_of_match[0].compatible);

	if (node) {
		/* DT-enabled */
		lirc_rpi_dev = of_find_device_by_node(node);
		WARN_ON(lirc_rpi_dev->dev.of_node != node);
		of_node_put(node);
	}
	else {
		lirc_rpi_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0);
		if (!lirc_rpi_dev) {
			result = -ENOMEM;
			goto exit_driver_unregister;
		}

		result = platform_device_add(lirc_rpi_dev);
		if (result)
			goto exit_device_put;
	}

	return 0;

	exit_device_put:
	platform_device_put(lirc_rpi_dev);

	exit_driver_unregister:
	platform_driver_unregister(&lirc_rpi_driver);

	exit_buffer_free:
	lirc_buffer_free(&rbuf);

	return result;
}
예제 #21
0
/*
**************************************************************************
* FunctionName: k3_socgpio_get_id_value;
* Description : get sensor id value;
* Input         :gpio_name:camera senor id_pin's name;
* Output       :value:camera sensor id_pin's value,ether 0 or 1,if ret < 0 ,it can not get id_pin value   ;
* ReturnValue:ret:if ret < 0 means error ,can not get right id_pin's value,if not ,means the value is right;
* Other         :NA;
**************************************************************************
*/
int k3_socgpio_get_id_value(char *gpio_name)
{
	int ret = -EINVAL;
	struct device_node *np = NULL;
	struct platform_device *pdev =NULL;
	int gpio_pin;
	enum of_gpio_flags gpio_flags;

	print_debug("enter %s", __func__);

	np = of_find_compatible_node(NULL, NULL, "hisi,hisi_isp");

	if (NULL == np) {
		print_error("the device node hisi_isp is null\n");
		return -1;
	}

	pdev = of_find_device_by_node(np);
	if (NULL == pdev) {
		print_error("the device hisi_isp is null\n");
		return -1;
	}

	gpio_pin = of_get_gpio_by_prop(np, gpio_name, 0, 0, &gpio_flags);
	if (!gpio_is_valid(gpio_pin)) {
		print_error("%s:huawei, pin read %s error.\n", __FUNCTION__, gpio_name);
		return -1;
	}

	print_info("%s: huawei, pin read %s:%d.\n", __FUNCTION__, gpio_name, gpio_pin);

	ret = gpio_request(gpio_pin, gpio_name);
	if (ret < 0) {
		print_error("%s: request camera gpio - %d(%s) failed, result = %d.",
			__func__, gpio_pin, gpio_name, ret);
		return -EINVAL;
	}

	ret = gpio_get_value(gpio_pin);
	if (ret < 0) {
		print_error("%s: fail to get value on gpio - %d(%s), result = %d.",
			__func__, gpio_pin, gpio_name, ret);
	}

	gpio_free(gpio_pin);

	print_debug("leave %s", __func__);

	return ret;
}
예제 #22
0
/* Public Key Cryptography module initialization handler */
static int __init caam_pkc_init(void)
{
	struct device_node *dev_node;
	struct platform_device *pdev;
	struct device *ctrldev;
	struct caam_drv_private *priv;
	u32 cha_inst, pk_inst;
	int err;

	dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0");
	if (!dev_node) {
		dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0");
		if (!dev_node)
			return -ENODEV;
	}

	pdev = of_find_device_by_node(dev_node);
	if (!pdev) {
		of_node_put(dev_node);
		return -ENODEV;
	}

	ctrldev = &pdev->dev;
	priv = dev_get_drvdata(ctrldev);
	of_node_put(dev_node);

	/*
	 * If priv is NULL, it's probably because the caam driver wasn't
	 * properly initialized (e.g. RNG4 init failed). Thus, bail out here.
	 */
	if (!priv)
		return -ENODEV;

	/* Determine public key hardware accelerator presence. */
	cha_inst = rd_reg32(&priv->ctrl->perfmon.cha_num_ls);
	pk_inst = (cha_inst & CHA_ID_LS_PK_MASK) >> CHA_ID_LS_PK_SHIFT;

	/* Do not register algorithms if PKHA is not present. */
	if (!pk_inst)
		return -ENODEV;

	err = crypto_register_akcipher(&caam_rsa);
	if (err)
		dev_warn(ctrldev, "%s alg registration failed\n",
			 caam_rsa.base.cra_driver_name);
	else
		dev_info(ctrldev, "caam pkc algorithms registered in /proc/crypto\n");

	return err;
}
예제 #23
0
/**
 * zynq_pm_remap_ocm() - Remap OCM
 * Returns a pointer to the mapped memory or NULL.
 *
 * Remap the OCM.
 */
static void __iomem *zynq_pm_remap_ocm(void)
{
	struct device_node *np;
	const char *comp = "xlnx,zynq-ocmc-1.0";
	void __iomem *base = NULL;

	np = of_find_compatible_node(NULL, NULL, comp);
	if (np) {
		struct device *dev;
		unsigned long pool_addr;
		unsigned long pool_addr_virt;
		struct gen_pool *pool;

		of_node_put(np);

		dev = &(of_find_device_by_node(np)->dev);

		/* Get OCM pool from device tree or platform data */
		pool = dev_get_gen_pool(dev);
		if (!pool) {
			pr_warn("%s: OCM pool is not available\n", __func__);
			return NULL;
		}

		pool_addr_virt = gen_pool_alloc(pool, zynq_sys_suspend_sz);
		if (!pool_addr_virt) {
			pr_warn("%s: Can't get OCM poll\n", __func__);
			return NULL;
		}
		pool_addr = gen_pool_virt_to_phys(pool, pool_addr_virt);
		if (!pool_addr) {
			pr_warn("%s: Can't get physical address of OCM pool\n",
				__func__);
			return NULL;
		}
		base = __arm_ioremap(pool_addr, zynq_sys_suspend_sz,
				     MT_MEMORY_RWX);
		if (!base) {
			pr_warn("%s: IOremap OCM pool failed\n", __func__);
			return NULL;
		}
		pr_debug("%s: Remap OCM %s from %lx to %lx\n", __func__, comp,
			 pool_addr_virt, (unsigned long)base);
	} else {
		pr_warn("%s: no compatible node found for '%s'\n", __func__,
				comp);
	}

	return base;
}
static int msm_hdmi_audio_codec_rx_probe(struct snd_soc_codec *codec)
{
	struct msm_hdmi_audio_codec_rx_data *codec_data;
	struct device_node *of_node_parent = NULL;

	codec_data = kzalloc(sizeof(struct msm_hdmi_audio_codec_rx_data),
		GFP_KERNEL);
	pr_info("%s++\n",__func__);
	if (!codec_data) {
		dev_err(codec->dev, "%s(): fail to allocate dai data\n",
				__func__);
		return -ENOMEM;
	}

	of_node_parent = of_get_parent(codec->dev->of_node);
	if (!of_node_parent) {
		dev_err(codec->dev, "%s(): Parent device tree node not found\n",
				__func__);
		kfree(codec_data);
		return -ENODEV;
	}

	codec_data->hdmi_core_pdev = of_find_device_by_node(of_node_parent);
	if (!codec_data->hdmi_core_pdev) {
		dev_err(codec->dev, "%s(): can't get parent pdev\n", __func__);
		kfree(codec_data);
		return -ENODEV;
	}

	if (msm_hdmi_register_audio_codec(codec_data->hdmi_core_pdev,
				&codec_data->hdmi_ops)) {
		dev_err(codec->dev, "%s(): can't register with hdmi core",
				__func__);
		kfree(codec_data);
		return -ENODEV;
	}

	dev_set_drvdata(codec->dev, codec_data);

	dev_dbg(codec->dev, "%s(): registerd %s with HDMI core\n",
		__func__, codec->name);

	if(codec_data->hdmi_ops.hdmi_cable_status)
		pr_info("%s: hdmi_cable_status is ok\n",__func__);
	else
		pr_info("%s: hdmi_cable_status is null\n",__func__);
	pr_info("%s--\n",__func__);
	return 0;
}
예제 #25
0
파일: oxnas_nand.c 프로젝트: freak0r/oxnas
/*
 * Try to find the node inside the DT. If it is available attach out
 * platform_nand_data
 */
static int __init oxnas_register_nand(void)
{
	struct device_node *node;
	struct platform_device *pdev;

	node = of_find_compatible_node(NULL, NULL, "plxtech,nand-nas782x");
	if (!node)
		return -ENOENT;
	pdev = of_find_device_by_node(node);
	if (!pdev)
		return -EINVAL;
	pdev->dev.platform_data = &oxnas_nand_data;
	of_node_put(node);
	return 0;
}
예제 #26
0
static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
					   struct of_dma *ofdma)
{
	struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
	struct ti_am335x_xbar_data *xbar = platform_get_drvdata(pdev);
	struct ti_am335x_xbar_map *map;

	if (dma_spec->args_count != 3)
		return ERR_PTR(-EINVAL);

	if (dma_spec->args[2] >= xbar->xbar_events) {
		dev_err(&pdev->dev, "Invalid XBAR event number: %d\n",
			dma_spec->args[2]);
		return ERR_PTR(-EINVAL);
	}

	if (dma_spec->args[0] >= xbar->dma_requests) {
		dev_err(&pdev->dev, "Invalid DMA request line number: %d\n",
			dma_spec->args[0]);
		return ERR_PTR(-EINVAL);
	}

	/* The of_node_put() will be done in the core for the node */
	dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
	if (!dma_spec->np) {
		dev_err(&pdev->dev, "Can't get DMA master\n");
		return ERR_PTR(-EINVAL);
	}

	map = kzalloc(sizeof(*map), GFP_KERNEL);
	if (!map) {
		of_node_put(dma_spec->np);
		return ERR_PTR(-ENOMEM);
	}

	map->dma_line = (u16)dma_spec->args[0];
	map->mux_val = (u16)dma_spec->args[2];

	dma_spec->args[2] = 0;
	dma_spec->args_count = 2;

	dev_dbg(&pdev->dev, "Mapping XBAR event%u to DMA%u\n",
		map->mux_val, map->dma_line);

	ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val);

	return map;
}
예제 #27
0
static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec,
					 struct of_dma *ofdma)
{
	struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
	struct ti_dra7_xbar_data *xbar = platform_get_drvdata(pdev);
	struct ti_dra7_xbar_map *map;

	if (dma_spec->args[0] >= xbar->xbar_requests) {
		dev_err(&pdev->dev, "Invalid XBAR request number: %d\n",
			dma_spec->args[0]);
		return ERR_PTR(-EINVAL);
	}

	/* The of_node_put() will be done in the core for the node */
	dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
	if (!dma_spec->np) {
		dev_err(&pdev->dev, "Can't get DMA master\n");
		return ERR_PTR(-EINVAL);
	}

	map = kzalloc(sizeof(*map), GFP_KERNEL);
	if (!map) {
		of_node_put(dma_spec->np);
		return ERR_PTR(-ENOMEM);
	}

	mutex_lock(&xbar->mutex);
	map->xbar_out = find_first_zero_bit(xbar->dma_inuse,
					    xbar->dma_requests);
	mutex_unlock(&xbar->mutex);
	if (map->xbar_out == xbar->dma_requests) {
		dev_err(&pdev->dev, "Run out of free DMA requests\n");
		kfree(map);
		return ERR_PTR(-ENOMEM);
	}
	set_bit(map->xbar_out, xbar->dma_inuse);

	map->xbar_in = (u16)dma_spec->args[0];

	dma_spec->args[0] = map->xbar_out + xbar->dma_offset;

	dev_dbg(&pdev->dev, "Mapping XBAR%u to DMA%d\n",
		map->xbar_in, map->xbar_out);

	ti_dra7_xbar_write(xbar->iomem, map->xbar_out, map->xbar_in);

	return map;
}
예제 #28
0
static int fimc_is_register_subdevs(struct fimc_is *is)
{
	struct device_node *adapter, *child;
	int ret;

	ret = fimc_isp_subdev_create(&is->isp);
	if (ret < 0)
		return ret;

	for_each_compatible_node(adapter, NULL, FIMC_IS_I2C_COMPATIBLE) {
		if (!of_find_device_by_node(adapter)) {
			of_node_put(adapter);
			return -EPROBE_DEFER;
		}

		for_each_available_child_of_node(adapter, child) {
			struct i2c_client *client;
			struct v4l2_subdev *sd;

			client = of_find_i2c_device_by_node(child);
			if (!client)
				goto e_retry;

			sd = i2c_get_clientdata(client);
			if (!sd)
				goto e_retry;

			/* FIXME: Add support for multiple sensors. */
			if (WARN_ON(is->sensor))
				continue;

			is->sensor = sd_to_fimc_is_sensor(sd);

			if (fimc_is_parse_sensor_config(is->sensor, child)) {
				dev_warn(&is->pdev->dev, "DT parse error: %s\n",
							 child->full_name);
			}
			pr_debug("%s(): registered subdev: %p\n",
				 __func__, sd->name);
		}
	}
	return 0;

e_retry:
	of_node_put(child);
	return -EPROBE_DEFER;
}
예제 #29
0
파일: mipi.c 프로젝트: grate-driver/linux
struct tegra_mipi_device *tegra_mipi_request(struct device *device)
{
	struct device_node *np = device->of_node;
	struct tegra_mipi_device *dev;
	struct of_phandle_args args;
	int err;

	err = of_parse_phandle_with_args(np, "nvidia,mipi-calibrate",
					 "#nvidia,mipi-calibrate-cells", 0,
					 &args);
	if (err < 0)
		return ERR_PTR(err);

	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev) {
		err = -ENOMEM;
		goto out;
	}

	dev->pdev = of_find_device_by_node(args.np);
	if (!dev->pdev) {
		err = -ENODEV;
		goto free;
	}

	dev->mipi = platform_get_drvdata(dev->pdev);
	if (!dev->mipi) {
		err = -EPROBE_DEFER;
		goto put;
	}

	of_node_put(args.np);

	dev->pads = args.args[0];
	dev->device = device;

	return dev;

put:
	platform_device_put(dev->pdev);
free:
	kfree(dev);
out:
	of_node_put(args.np);
	return ERR_PTR(err);
}
예제 #30
0
/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
 * BUS and propagate to all child of_device objects.
 */
void of_propagate_archdata(struct of_device *bus)
{
	struct dev_archdata *bus_sd = &bus->dev.archdata;
	struct device_node *bus_dp = bus->node;
	struct device_node *dp;

	for (dp = bus_dp->child; dp; dp = dp->sibling) {
		struct of_device *op = of_find_device_by_node(dp);

		op->dev.archdata.iommu = bus_sd->iommu;
		op->dev.archdata.stc = bus_sd->stc;
		op->dev.archdata.host_controller = bus_sd->host_controller;
		op->dev.archdata.numa_node = bus_sd->numa_node;

		if (dp->child)
			of_propagate_archdata(op);
	}
}