Esempio n. 1
0
static int __init lirc_parallel_init(void)
{
	int result;

	result = platform_driver_register(&lirc_parallel_driver);
	if (result) {
		printk(KERN_NOTICE "platform_driver_register"
					" returned %d\n", result);
		return result;
	}

	lirc_parallel_dev = platform_device_alloc(LIRC_DRIVER_NAME, 0);
	if (!lirc_parallel_dev) {
		result = -ENOMEM;
		goto exit_driver_unregister;
	}

	result = platform_device_add(lirc_parallel_dev);
	if (result)
		goto exit_device_put;

	pport = parport_find_base(io);
	if (pport == NULL) {
		printk(KERN_NOTICE "%s: no port at %x found\n",
		       LIRC_DRIVER_NAME, io);
		result = -ENXIO;
		goto exit_device_put;
	}
	ppdevice = parport_register_device(pport, LIRC_DRIVER_NAME,
					   pf, kf, irq_handler, 0, NULL);
	parport_put_port(pport);
	if (ppdevice == NULL) {
		printk(KERN_NOTICE "%s: parport_register_device() failed\n",
		       LIRC_DRIVER_NAME);
		result = -ENXIO;
		goto exit_device_put;
	}
	if (parport_claim(ppdevice) != 0)
		goto skip_init;
	is_claimed = 1;
	out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP);

#ifdef LIRC_TIMER
	if (debug)
		out(LIRC_PORT_DATA, tx_mask);

	timer = init_lirc_timer();

#if 0	/* continue even if device is offline */
	if (timer == 0) {
		is_claimed = 0;
		parport_release(pport);
		parport_unregister_device(ppdevice);
		result = -EIO;
		goto exit_device_put;
	}

#endif
	if (debug)
		out(LIRC_PORT_DATA, 0);
#endif

	is_claimed = 0;
	parport_release(ppdevice);
 skip_init:
	driver.dev = &lirc_parallel_dev->dev;
	driver.minor = lirc_register_driver(&driver);
	if (driver.minor < 0) {
		printk(KERN_NOTICE "%s: register_chrdev() failed\n",
		       LIRC_DRIVER_NAME);
		parport_unregister_device(ppdevice);
		result = -EIO;
		goto exit_device_put;
	}
	printk(KERN_INFO "%s: installed using port 0x%04x irq %d\n",
	       LIRC_DRIVER_NAME, io, irq);
	return 0;

exit_device_put:
	platform_device_put(lirc_parallel_dev);
exit_driver_unregister:
	platform_driver_unregister(&lirc_parallel_driver);
	return result;
}
Esempio n. 2
0
static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo,
					int ctrl_nr)
{
	struct omap_hwmod *oh;
	struct omap_hwmod *ohs[1];
	struct omap_device *od;
	struct platform_device *pdev;
	char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
	struct omap_hsmmc_platform_data *mmc_data;
	struct omap_hsmmc_dev_attr *mmc_dev_attr;
	char *name;
	int res;

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

	res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
	if (res < 0)
		goto free_mmc;

	name = "omap_hsmmc";
	res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
		     "mmc%d", ctrl_nr);
	WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
	     "String buffer overflow in MMC%d device setup\n", ctrl_nr);

	oh = omap_hwmod_lookup(oh_name);
	if (!oh) {
		pr_err("Could not look up %s\n", oh_name);
		goto free_name;
	}
	ohs[0] = oh;
	if (oh->dev_attr != NULL) {
		mmc_dev_attr = oh->dev_attr;
		mmc_data->controller_flags = mmc_dev_attr->flags;
	}

	pdev = platform_device_alloc(name, ctrl_nr - 1);
	if (!pdev) {
		pr_err("Could not allocate pdev for %s\n", name);
		goto free_name;
	}
	dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);

	od = omap_device_alloc(pdev, ohs, 1);
	if (IS_ERR(od)) {
		pr_err("Could not allocate od for %s\n", name);
		goto put_pdev;
	}

	res = platform_device_add_data(pdev, mmc_data,
			      sizeof(struct omap_hsmmc_platform_data));
	if (res) {
		pr_err("Could not add pdata for %s\n", name);
		goto put_pdev;
	}

	hsmmcinfo->pdev = pdev;

	res = omap_device_register(pdev);
	if (res) {
		pr_err("Could not register od for %s\n", name);
		goto free_od;
	}

	goto free_mmc;

free_od:
	omap_device_delete(od);

put_pdev:
	platform_device_put(pdev);

free_name:
	kfree(mmc_data->name);

free_mmc:
	kfree(mmc_data);
}
Esempio n. 3
0
/**
 * wm8350_register_led - Register a WM8350 LED output
 *
 * @param wm8350 The WM8350 device to configure.
 * @param lednum LED device index to create.
 * @param dcdc The DCDC to use for the LED.
 * @param isink The ISINK to use for the LED.
 * @param pdata Configuration for the LED.
 *
 * The WM8350 supports the use of an ISINK together with a DCDC to
 * provide a power-efficient LED driver.  This function registers the
 * regulators and instantiates the platform device for a LED.  The
 * operating modes for the LED regulators must be configured using
 * wm8350_isink_set_flash(), wm8350_dcdc25_set_mode() and
 * wm8350_dcdc_set_slot() prior to calling this function.
 */
int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink,
			struct wm8350_led_platform_data *pdata)
{
	struct wm8350_led *led;
	struct platform_device *pdev;
	int ret;

	if (lednum >= ARRAY_SIZE(wm8350->pmic.led) || lednum < 0) {
		dev_err(wm8350->dev, "Invalid LED index %d\n", lednum);
		return -ENODEV;
	}

	led = &wm8350->pmic.led[lednum];

	if (led->pdev) {
		dev_err(wm8350->dev, "LED %d already allocated\n", lednum);
		return -EINVAL;
	}

	pdev = platform_device_alloc("wm8350-led", lednum);
	if (pdev == NULL) {
		dev_err(wm8350->dev, "Failed to allocate LED %d\n", lednum);
		return -ENOMEM;
	}

	led->isink_consumer.dev_name = dev_name(&pdev->dev);
	led->isink_consumer.supply = "led_isink";
	led->isink_init.num_consumer_supplies = 1;
	led->isink_init.consumer_supplies = &led->isink_consumer;
	led->isink_init.constraints.min_uA = 0;
	led->isink_init.constraints.max_uA = pdata->max_uA;
	led->isink_init.constraints.valid_ops_mask
		= REGULATOR_CHANGE_CURRENT | REGULATOR_CHANGE_STATUS;
	led->isink_init.constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
	ret = wm8350_register_regulator(wm8350, isink, &led->isink_init);
	if (ret != 0) {
		platform_device_put(pdev);
		return ret;
	}

	led->dcdc_consumer.dev_name = dev_name(&pdev->dev);
	led->dcdc_consumer.supply = "led_vcc";
	led->dcdc_init.num_consumer_supplies = 1;
	led->dcdc_init.consumer_supplies = &led->dcdc_consumer;
	led->dcdc_init.constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
	led->dcdc_init.constraints.valid_ops_mask =  REGULATOR_CHANGE_STATUS;
	ret = wm8350_register_regulator(wm8350, dcdc, &led->dcdc_init);
	if (ret != 0) {
		platform_device_put(pdev);
		return ret;
	}

	switch (isink) {
	case WM8350_ISINK_A:
		wm8350->pmic.isink_A_dcdc = dcdc;
		break;
	case WM8350_ISINK_B:
		wm8350->pmic.isink_B_dcdc = dcdc;
		break;
	}

	pdev->dev.platform_data = pdata;
	pdev->dev.parent = wm8350->dev;
	ret = platform_device_add(pdev);
	if (ret != 0) {
		dev_err(wm8350->dev, "Failed to register LED %d: %d\n",
			lednum, ret);
		platform_device_put(pdev);
		return ret;
	}

	led->pdev = pdev;

	return 0;
}
Esempio n. 4
0
static int __devinit dwc3_pci_probe(struct pci_dev *pci,
		const struct pci_device_id *id)
{
	struct resource		res[2];
	struct platform_device	*dwc3;
	struct dwc3_pci		*glue;
	int			ret = -ENOMEM;
	int			devid;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
		dev_err(&pci->dev, "not enough memory\n");
		goto err0;
	}

	glue->dev	= &pci->dev;

	ret = pci_enable_device(pci);
	if (ret) {
		dev_err(&pci->dev, "failed to enable pci device\n");
		goto err1;
	}

	pci_set_power_state(pci, PCI_D0);
	pci_set_master(pci);

	devid = dwc3_get_device_id();
	if (devid < 0)
		goto err2;

	dwc3 = platform_device_alloc("dwc3", devid);
	if (!dwc3) {
		dev_err(&pci->dev, "couldn't allocate dwc3 device\n");
		goto err3;
	}

	memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));

	res[0].start	= pci_resource_start(pci, 0);
	res[0].end	= pci_resource_end(pci, 0);
	res[0].name	= "dwc_usb3";
	res[0].flags	= IORESOURCE_MEM;

	res[1].start	= pci->irq;
	res[1].name	= "dwc_usb3";
	res[1].flags	= IORESOURCE_IRQ;

	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
	if (ret) {
		dev_err(&pci->dev, "couldn't add resources to dwc3 device\n");
		goto err4;
	}

	pci_set_drvdata(pci, glue);

	dma_set_coherent_mask(&dwc3->dev, pci->dev.coherent_dma_mask);

	dwc3->dev.dma_mask = pci->dev.dma_mask;
	dwc3->dev.dma_parms = pci->dev.dma_parms;
	dwc3->dev.parent = &pci->dev;
	glue->dwc3	= dwc3;

	ret = platform_device_add(dwc3);
	if (ret) {
		dev_err(&pci->dev, "failed to register dwc3 device\n");
		goto err4;
	}

	return 0;

err4:
	pci_set_drvdata(pci, NULL);
	platform_device_put(dwc3);

err3:
	dwc3_put_device_id(devid);

err2:
	pci_disable_device(pci);

err1:
	kfree(glue);

err0:
	return ret;
}
Esempio n. 5
0
static int tvenc_probe(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct platform_device *mdp_dev = NULL;
	struct msm_fb_panel_data *pdata = NULL;
	int rc, ret;
	struct clk *ebi1_clk = NULL;

	if (pdev->id == 0) {
		tvenc_base = ioremap(pdev->resource[0].start,
					pdev->resource[0].end -
					pdev->resource[0].start + 1);
		if (!tvenc_base) {
			pr_err("tvenc_base ioremap failed!\n");
			return -ENOMEM;
		}

		tvenc_clk = clk_get(&pdev->dev, "enc_clk");
		tvdac_clk = clk_get(&pdev->dev, "dac_clk");
		tvenc_pclk = clk_get(&pdev->dev, "iface_clk");
		mdp_tv_clk = clk_get(&pdev->dev, "mdp_clk");

#ifndef CONFIG_MSM_BUS_SCALING
		ebi1_clk = clk_get(&pdev->dev, "mem_clk");
		if (IS_ERR(ebi1_clk)) {
			rc = PTR_ERR(ebi1_clk);
			goto tvenc_probe_err;
		}
		clk_set_rate(ebi1_clk, MSM_SYSTEM_BUS_RATE);
#endif

#ifdef CONFIG_FB_MSM_MDP40
		tv_src_clk = clk_get(&pdev->dev, "src_clk");
		if (IS_ERR(tv_src_clk))
			tv_src_clk = tvenc_clk; /*                   */
#endif

		if (IS_ERR(tvenc_clk)) {
			pr_err("%s: error: can't get tvenc_clk!\n", __func__);
			return PTR_ERR(tvenc_clk);
		}

		if (IS_ERR(tvdac_clk)) {
			pr_err("%s: error: can't get tvdac_clk!\n", __func__);
			return PTR_ERR(tvdac_clk);
		}

		if (IS_ERR(tvenc_pclk)) {
			ret = PTR_ERR(tvenc_pclk);
			if (-ENOENT == ret)
				pr_info("%s: tvenc_pclk does not exist!\n",
								__func__);
			else {
				pr_err("%s: error: can't get tvenc_pclk!\n",
								__func__);
				return ret;
			}
		}

		if (IS_ERR(mdp_tv_clk)) {
			ret = PTR_ERR(mdp_tv_clk);
			if (-ENOENT == ret)
				pr_info("%s: mdp_tv_clk does not exist!\n",
								__func__);
			else {
				pr_err("%s: error: can't get mdp_tv_clk!\n",
								__func__);
				return ret;
			}
		}

		tvenc_pdata = pdev->dev.platform_data;
		tvenc_resource_initialized = 1;
		return 0;
	}

	if (!tvenc_resource_initialized)
		return -EPERM;

	mfd = platform_get_drvdata(pdev);
	mfd->ebi1_clk = ebi1_clk;

	if (!mfd)
		return -ENODEV;

	if (mfd->key != MFD_KEY)
		return -EINVAL;

	if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST)
		return -ENOMEM;

	if (tvenc_base == NULL)
		return -ENOMEM;

	mdp_dev = platform_device_alloc("mdp", pdev->id);
	if (!mdp_dev)
		return -ENOMEM;

	/*
                           
  */
	mfd->pdev = mdp_dev;
	mfd->dest = DISPLAY_TV;

	/*
                           
  */
	if (platform_device_add_data
	    (mdp_dev, pdev->dev.platform_data,
	     sizeof(struct msm_fb_panel_data))) {
		pr_err("tvenc_probe: platform_device_add_data failed!\n");
		platform_device_put(mdp_dev);
		return -ENOMEM;
	}
	/*
              
  */
	pdata = mdp_dev->dev.platform_data;
	pdata->on = tvenc_on;
	pdata->off = tvenc_off;
	pdata->next = pdev;

	/*
                                  
  */
	mfd->panel_info = pdata->panel_info;
#ifdef CONFIG_FB_MSM_MDP40
	mfd->fb_imgType = MDP_RGB_565;  /*            */
#else
	mfd->fb_imgType = MDP_YCRYCB_H2V1;
#endif

#ifdef CONFIG_MSM_BUS_SCALING
	if (!tvenc_bus_scale_handle && tvenc_pdata &&
		tvenc_pdata->bus_scale_table) {
		tvenc_bus_scale_handle =
			msm_bus_scale_register_client(
				tvenc_pdata->bus_scale_table);
		if (!tvenc_bus_scale_handle) {
			printk(KERN_ERR "%s not able to get bus scale\n",
				__func__);
		}
	}
#endif

	/*
                   
  */
	platform_set_drvdata(mdp_dev, mfd);

	/*
                          
  */
	rc = platform_device_add(mdp_dev);
	if (rc)
		goto tvenc_probe_err;

	pm_runtime_set_active(&pdev->dev);
	pm_runtime_enable(&pdev->dev);



	pdev_list[pdev_list_cnt++] = pdev;

	return 0;

tvenc_probe_err:
#ifdef CONFIG_MSM_BUS_SCALING
	if (tvenc_pdata && tvenc_pdata->bus_scale_table &&
		tvenc_bus_scale_handle > 0) {
		msm_bus_scale_unregister_client(tvenc_bus_scale_handle);
		tvenc_bus_scale_handle = 0;
	}
#endif
	platform_device_put(mdp_dev);
	return rc;
}
static int
ipc_bridge_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
	struct ipc_bridge *dev;
	struct usb_device *udev = interface_to_usbdev(intf);
	struct usb_host_interface *intf_desc;
	struct usb_endpoint_descriptor *ep;
	u16 wMaxPacketSize;
	int ret;

	intf_desc = intf->cur_altsetting;
	if (intf_desc->desc.bNumEndpoints != 1 || !usb_endpoint_is_int_in(
				&intf_desc->endpoint[0].desc)) {
		dev_err(&intf->dev, "driver expects only 1 int ep\n");
		return -ENODEV;
	}

	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev) {
		dev_err(&intf->dev, "fail to allocate dev\n");
		return -ENOMEM;
	}
	__ipc_bridge_dev = dev;

	dev->inturb = usb_alloc_urb(0, GFP_KERNEL);
	if (!dev->inturb) {
		dev_err(&intf->dev, "fail to allocate int urb\n");
		ret = -ENOMEM;
		goto free_dev;
	}

	ep = &intf->cur_altsetting->endpoint[0].desc;
	wMaxPacketSize = le16_to_cpu(ep->wMaxPacketSize);

	dev->intbuf = kmalloc(wMaxPacketSize, GFP_KERNEL);
	if (!dev->intbuf) {
		dev_err(&intf->dev, "%s: error allocating int buffer\n",
			__func__);
		ret = -ENOMEM;
		goto free_inturb;
	}

	usb_fill_int_urb(dev->inturb, udev,
			usb_rcvintpipe(udev, ep->bEndpointAddress),
			dev->intbuf, wMaxPacketSize,
			ipc_bridge_int_cb, dev, ep->bInterval);

	dev->in_ctlreq = kmalloc(sizeof(*dev->in_ctlreq), GFP_KERNEL);
	if (!dev->in_ctlreq) {
		dev_err(&intf->dev, "error allocating IN control req\n");
		ret = -ENOMEM;
		goto free_intbuf;
	}

	dev->in_ctlreq->bRequestType =
			(USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
	dev->in_ctlreq->bRequest  = USB_CDC_GET_ENCAPSULATED_RESPONSE;
	dev->in_ctlreq->wValue = 0;
	dev->in_ctlreq->wIndex = intf->cur_altsetting->desc.bInterfaceNumber;
	dev->in_ctlreq->wLength = cpu_to_le16(IPC_BRIDGE_MAX_READ_SZ);

	dev->readurb = usb_alloc_urb(0, GFP_KERNEL);
	if (!dev->readurb) {
		dev_err(&intf->dev, "fail to allocate read urb\n");
		ret = -ENOMEM;
		goto free_in_ctlreq;
	}

	dev->readbuf = kmalloc(IPC_BRIDGE_MAX_READ_SZ, GFP_KERNEL);
	if (!dev->readbuf) {
		dev_err(&intf->dev, "fail to allocate read buffer\n");
		ret = -ENOMEM;
		goto free_readurb;
	}

	dev->out_ctlreq = kmalloc(sizeof(*dev->out_ctlreq), GFP_KERNEL);
	if (!dev->out_ctlreq) {
		dev_err(&intf->dev, "error allocating OUT control req\n");
		ret = -ENOMEM;
		goto free_readbuf;
	}

	dev->out_ctlreq->bRequestType =
			(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE);
	dev->out_ctlreq->bRequest  = USB_CDC_SEND_ENCAPSULATED_COMMAND;
	dev->out_ctlreq->wValue = 0;
	dev->out_ctlreq->wIndex = intf->cur_altsetting->desc.bInterfaceNumber;

	dev->writeurb = usb_alloc_urb(0, GFP_KERNEL);
	if (!dev->writeurb) {
		dev_err(&intf->dev, "fail to allocate write urb\n");
		ret = -ENOMEM;
		goto free_out_ctlreq;
	}

	dev->udev = usb_get_dev(interface_to_usbdev(intf));
	dev->intf = intf;
	spin_lock_init(&dev->lock);
	init_completion(&dev->write_done);
	init_waitqueue_head(&dev->read_wait_q);
	INIT_LIST_HEAD(&dev->rx_list);
	mutex_init(&dev->open_mutex);
	mutex_init(&dev->read_mutex);
	mutex_init(&dev->write_mutex);
	usb_set_intfdata(intf, dev);
	usb_enable_autosuspend(udev);

	dev->pdev = platform_device_alloc("ipc_bridge", -1);
	if (!dev->pdev) {
		dev_err(&intf->dev, "fail to allocate pdev\n");
		ret = -ENOMEM;
		goto destroy_mutex;
	}

	ret = platform_device_add_data(dev->pdev, &ipc_bridge_pdata,
				sizeof(struct ipc_bridge_platform_data));
	if (ret) {
		dev_err(&intf->dev, "fail to add pdata\n");
		goto put_pdev;
	}

	ret = platform_device_add(dev->pdev);
	if (ret) {
		dev_err(&intf->dev, "fail to add pdev\n");
		goto put_pdev;
	}

	ret = ipc_bridge_submit_inturb(dev, GFP_KERNEL);
	if (ret) {
		dev_err(&intf->dev, "fail to start reading\n");
		goto del_pdev;
	}

	ipc_bridge_debugfs_init();
	return 0;

del_pdev:
	platform_device_del(dev->pdev);
put_pdev:
	platform_device_put(dev->pdev);
destroy_mutex:
	usb_disable_autosuspend(udev);
	mutex_destroy(&dev->write_mutex);
	mutex_destroy(&dev->read_mutex);
	mutex_destroy(&dev->open_mutex);
	usb_put_dev(dev->udev);
	usb_free_urb(dev->writeurb);
free_out_ctlreq:
	kfree(dev->out_ctlreq);
free_readbuf:
	kfree(dev->readbuf);
free_readurb:
	usb_free_urb(dev->readurb);
free_in_ctlreq:
	kfree(dev->in_ctlreq);
free_intbuf:
	kfree(dev->intbuf);
free_inturb:
	usb_free_urb(dev->inturb);
free_dev:
	kfree(dev);
	__ipc_bridge_dev = NULL;

	return ret;
}
static int msm8960_configure_headset_mic_gpios(void)
{
	int ret;
	struct pm_gpio param = {
		.direction      = PM_GPIO_DIR_OUT,
		.output_buffer  = PM_GPIO_OUT_BUF_CMOS,
		.output_value   = 1,
		.pull	   = PM_GPIO_PULL_NO,
		.vin_sel	= PM_GPIO_VIN_S4,
		.out_strength   = PM_GPIO_STRENGTH_MED,
		.function       = PM_GPIO_FUNC_NORMAL,
	};

	ret = gpio_request(PM8921_GPIO_PM_TO_SYS(23), "AV_SWITCH");
	if (ret) {
		pr_err("%s: Failed to request gpio %d\n", __func__,
			PM8921_GPIO_PM_TO_SYS(23));
		return ret;
	}

	ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(23), &param);
	if (ret)
		pr_err("%s: Failed to configure gpio %d\n", __func__,
			PM8921_GPIO_PM_TO_SYS(23));
	else
		gpio_direction_output(PM8921_GPIO_PM_TO_SYS(23), 0);

	ret = gpio_request(PM8921_GPIO_PM_TO_SYS(35), "US_EURO_SWITCH");
	if (ret) {
		pr_err("%s: Failed to request gpio %d\n", __func__,
			PM8921_GPIO_PM_TO_SYS(35));
		gpio_free(PM8921_GPIO_PM_TO_SYS(23));
		return ret;
	}
	ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(35), &param);
	if (ret)
		pr_err("%s: Failed to configure gpio %d\n", __func__,
			PM8921_GPIO_PM_TO_SYS(35));
	else
		gpio_direction_output(PM8921_GPIO_PM_TO_SYS(35), 0);

	return 0;
}
static void msm8960_free_headset_mic_gpios(void)
{
	if (msm8960_headset_gpios_configured) {
		gpio_free(PM8921_GPIO_PM_TO_SYS(23));
		gpio_free(PM8921_GPIO_PM_TO_SYS(35));
	}
}

static int __init msm8960_audio_init(void)
{
	int ret;

	if (!cpu_is_msm8960() && !cpu_is_msm8930()) {
		pr_err("%s: Not the right machine type\n", __func__);
		return -ENODEV ;
	}

	tabla_mbhc_cal = def_tabla_mbhc_cal();
	if (!tabla_mbhc_cal) {
		pr_err("Calibration data allocation failed\n");
		return -ENOMEM;
	}

	msm8960_snd_device = platform_device_alloc("soc-audio", 0);
	if (!msm8960_snd_device) {
		pr_err("Platform device allocation failed\n");
		kfree(tabla_mbhc_cal);
		return -ENOMEM;
	}

	platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960);
	ret = platform_device_add(msm8960_snd_device);
	if (ret) {
		platform_device_put(msm8960_snd_device);
		kfree(tabla_mbhc_cal);
		return ret;
	}

	if (msm8960_configure_headset_mic_gpios()) {
		pr_err("%s Fail to configure headset mic gpios\n", __func__);
		msm8960_headset_gpios_configured = 0;
	} else
		msm8960_headset_gpios_configured = 1;

	return ret;

}
Esempio n. 8
0
static int keyreset_probe(struct platform_device *pdev)
{
	int ret = -ENOMEM;
	struct keycombo_platform_data *pdata_child;
	struct keyreset_platform_data *pdata;
	int up_size = 0, down_size = 0, size;
	int key, *keyp;
	struct keyreset_state *state;

	KEY_LOGI("%s: +++\n", __func__);

	if (pdev->dev.of_node) {
		pdata = kzalloc(sizeof(struct keyreset_platform_data), GFP_KERNEL);
		if (!pdata) {
			KEY_LOGE("fail to allocate keyreset_platform_data\n");
			ret = -ENOMEM;
			goto err_get_pdata_fail;
		}
		ret = keyreset_parse_dt(pdev->dev.of_node, pdata);
		if (ret < 0) {
			KEY_LOGE("keyreset_parse_dt fail\n");
			ret = -ENOMEM;
			goto err_parse_fail;
		}
	} else {
		pdata = pdev->dev.platform_data;
		if(!pdata) {
			KEY_LOGE("keyreset_platform_data does not exist\n");
			ret = -ENOMEM;
			goto err_get_pdata_fail;
		}
	}

	state = devm_kzalloc(&pdev->dev, sizeof(*state), GFP_KERNEL);
	if (!state) {
		KEY_LOGE("fail to allocate state\n");
		ret = -ENOMEM;
		goto err_alloc_state;
	}

	state->pdev_child = platform_device_alloc(KEYCOMBO_NAME,
							PLATFORM_DEVID_AUTO);
	if (!state->pdev_child) {
		KEY_LOGE("fail to allocate pdev_child\n");
		ret = -ENOMEM;
		goto err_alloc_state;
	}
	state->pdev_child->dev.parent = &pdev->dev;
	INIT_WORK(&state->restart_work, do_restart);

	keyp = pdata->keys_down;
	while ((key = *keyp++)) {
		if (key >= KEY_MAX)
			continue;
		down_size++;
	}
	if (pdata->keys_up) {
		keyp = pdata->keys_up;
		while ((key = *keyp++)) {
			if (key >= KEY_MAX)
				continue;
			up_size++;
		}
	}
	size = sizeof(struct keycombo_platform_data);
	pdata_child = devm_kzalloc(&pdev->dev, sizeof(struct keycombo_platform_data),
				GFP_KERNEL);
	if (!pdata_child)
		goto error;

	pdata_child->keys_down = devm_kzalloc(&pdev->dev,
				sizeof(uint32_t) * (down_size + 1), GFP_KERNEL);
	if (!pdata_child->keys_down)
		goto error;

	memcpy(pdata_child->keys_down, pdata->keys_down,
						sizeof(uint32_t) * down_size);
	if (!pdata_child->keys_down)
		goto error;

	if (up_size > 0) {
		pdata_child->keys_up = devm_kzalloc(&pdev->dev,
					sizeof(uint32_t) * (up_size + 1), GFP_KERNEL);
		if (!pdata_child->keys_up)
			goto error;
		memcpy(pdata_child->keys_up, pdata->keys_up,
							sizeof(uint32_t) * up_size);
		if (!pdata_child->keys_up)
			goto error;
	}
	state->reset_fn = pdata->reset_fn;
	pdata_child->key_down_fn = do_reset_fn;
	pdata_child->priv = state;
	pdata_child->key_down_delay = pdata->key_down_delay;
	ret = platform_device_add_data(state->pdev_child, pdata_child, size);
	if (ret)
		goto error;
	platform_set_drvdata(pdev, state);

	KEY_LOGI("%s: ---\n", __func__);

	return platform_device_add(state->pdev_child);
error:
	platform_device_put(state->pdev_child);
err_alloc_state:
err_parse_fail:
	if (pdev->dev.of_node) {
		if(pdata->keys_up)
			kfree(pdata->keys_up);
		if(pdata->keys_down)
			kfree(pdata->keys_down);
		kfree(pdata);
	}
err_get_pdata_fail:
	return ret;
}
Esempio n. 9
0
int keyreset_remove(struct platform_device *pdev)
{
	struct keyreset_state *state = platform_get_drvdata(pdev);
	platform_device_put(state->pdev_child);
	return 0;
}
Esempio n. 10
0
static int __init omap3pandora_soc_init(void)
{
	int ret;

	if (!machine_is_omap3_pandora())
		return -ENODEV;

	pr_info("OMAP3 Pandora SoC init\n");

	ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power");
	if (ret) {
		pr_err(PREFIX "Failed to get DAC power GPIO\n");
		return ret;
	}

	ret = gpio_direction_output(OMAP3_PANDORA_DAC_POWER_GPIO, 0);
	if (ret) {
		pr_err(PREFIX "Failed to set DAC power GPIO direction\n");
		goto fail0;
	}

	ret = gpio_request(OMAP3_PANDORA_AMP_POWER_GPIO, "amp_power");
	if (ret) {
		pr_err(PREFIX "Failed to get amp power GPIO\n");
		goto fail0;
	}

	ret = gpio_direction_output(OMAP3_PANDORA_AMP_POWER_GPIO, 0);
	if (ret) {
		pr_err(PREFIX "Failed to set amp power GPIO direction\n");
		goto fail1;
	}

	omap3pandora_snd_device = platform_device_alloc("soc-audio", -1);
	if (omap3pandora_snd_device == NULL) {
		pr_err(PREFIX "Platform device allocation failed\n");
		ret = -ENOMEM;
		goto fail1;
	}

	platform_set_drvdata(omap3pandora_snd_device, &snd_soc_card_omap3pandora);

	ret = platform_device_add(omap3pandora_snd_device);
	if (ret) {
		pr_err(PREFIX "Unable to add platform device\n");
		goto fail2;
	}

	omap3pandora_dac_reg = regulator_get(&omap3pandora_snd_device->dev, "vcc");
	if (IS_ERR(omap3pandora_dac_reg)) {
		pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n",
			dev_name(&omap3pandora_snd_device->dev),
			PTR_ERR(omap3pandora_dac_reg));
		ret = PTR_ERR(omap3pandora_dac_reg);
		goto fail3;
	}

	return 0;

fail3:
	platform_device_del(omap3pandora_snd_device);
fail2:
	platform_device_put(omap3pandora_snd_device);
fail1:
	gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO);
fail0:
	gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO);
	return ret;
}
Esempio n. 11
0
static int __init t0_audio_init(void)
{
	struct wm1811_machine_priv *wm1811;
	const struct exynos_sound_platform_data *sound_pdata;
	int ret;

	wm1811 = kzalloc(sizeof *wm1811, GFP_KERNEL);
	if (!wm1811) {
		pr_err("Failed to allocate memory\n");
		ret = -ENOMEM;
		goto err_kzalloc;
	}
	snd_soc_card_set_drvdata(&t0_card, wm1811);

	t0_snd_device = platform_device_alloc("soc-audio", -1);
	if (!t0_snd_device) {
		ret = -ENOMEM;
		goto err_device_alloc;
	}

	ret = snd_soc_register_dais(&t0_snd_device->dev, t0_ext_dai,
						ARRAY_SIZE(t0_ext_dai));
	if (ret != 0)
		pr_err("Failed to register external DAIs: %d\n", ret);

	platform_set_drvdata(t0_snd_device, &t0_card);

	ret = platform_device_add(t0_snd_device);
	if (ret)
		platform_device_put(t0_snd_device);

	sound_pdata = exynos_sound_get_platform_data();
	if (!sound_pdata) {
		pr_info("%s: don't use sound pdata\n", __func__);
		goto err_out_free;
	}

	if (sound_pdata->set_lineout_switch)
		wm1811->lineout_switch_f = sound_pdata->set_lineout_switch;

	if (sound_pdata->set_ext_main_mic)
		wm1811->set_main_mic_f = sound_pdata->set_ext_main_mic;

	if (sound_pdata->set_ext_sub_mic)
		wm1811->set_sub_mic_f = sound_pdata->set_ext_sub_mic;
#if defined(CONFIG_SND_DUOS_MODEM_SWITCH)
	if (sound_pdata->set_modem_switch)
		wm1811->set_modem_switch_f = sound_pdata->set_modem_switch;
#endif
	if (sound_pdata->get_ground_det_value)
		wm1811->get_g_det_value_f = sound_pdata->get_ground_det_value;

	if (sound_pdata->get_ground_det_irq_num) {
		wm1811->get_g_det_irq_num_f =
				sound_pdata->get_ground_det_irq_num;
		ret = request_threaded_irq(wm1811->get_g_det_irq_num_f(), NULL,
					t0_g_det_thread, IRQF_TRIGGER_RISING |
					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
					"g_det irq", wm1811);
		if (ret != 0)
			pr_err("%s: Failed to register IRQ\n", __func__);

		/* to handle insert/removal when we're sleeping in a call */
		ret = enable_irq_wake(wm1811->get_g_det_irq_num_f());
		if (ret)
			pr_err("%s : Failed to enable_irq_wake\n", __func__);
	}

	return ret;

err_out_free:
	platform_device_put(t0_snd_device);
err_device_alloc:
	kfree(wm1811);
err_kzalloc:
	return ret;
}
Esempio n. 12
0
static int __init tcc_init_es8388(void)
{

	int ret;

    printk("%s() \n", __func__);

    if( !(machine_is_m801_88() || machine_is_m805_892x() || machine_is_tcc8920()) ) {
        alsa_dbg("\n\n\n\n%s() do not execution....\n\n", __func__);
        return 0;
    }

#if defined(CONFIG_ARCH_TCC88XX)
    alsa_dbg("TCC Board probe [%s]\n", __FUNCTION__);

    /* h/w mute control */
    if(machine_is_m801_88()) {
        tcc_gpio_config(TCC_GPG(6), GPIO_FN(0));
        tcc_gpio_config(TCC_GPD(11), GPIO_FN(0));
        gpio_request(TCC_GPG(6), "SPK_MUTE_CTL");
        gpio_request(TCC_GPD(11), "HP_MUTE_CTL");
        
        gpio_direction_output(TCC_GPG(6), 0);    // Speaker mute
        gpio_direction_output(TCC_GPD(11), 1);   // HeadPhone mute
        tcc_hp_hw_mute(false);
        tcc_spk_hw_mute(false);

        tcc_soc_card.name = "M801";
    }

#elif defined(CONFIG_ARCH_TCC892X)
	alsa_dbg("TCC Board probe [%s]\n", __FUNCTION__);

	/* h/w mute control */
	if(machine_is_m805_892x())
	{
		if(system_rev == 0x2002 || system_rev == 0x2003 || system_rev == 0x2004 || system_rev == 0x2005) {
			tcc_gpio_config(TCC_GPE(18), GPIO_FN(0));
			gpio_request(TCC_GPE(18), "SPK_MUTE_CTL");
			gpio_direction_output(TCC_GPE(18), 0);	 // Speaker mute
			
			tcc_gpio_config(TCC_GPE(17), GPIO_FN(0));
			gpio_request(TCC_GPE(17), "HP_MUTE_CTL");
			gpio_direction_output(TCC_GPE(17), 1);	 // HeadPhone mute
		}
		else {
			#if defined(CONFIG_M805S_8923_0XA)
			tcc_gpio_config(TCC_GPG(11), GPIO_FN(0));
			gpio_request(TCC_GPG(11), "SPK_MUTE_CTL");
			gpio_direction_output(TCC_GPG(11), 0);	 // Speaker mute
			#else
			tcc_gpio_config(TCC_GPF(27), GPIO_FN(0));
			gpio_request(TCC_GPF(27), "SPK_MUTE_CTL");
			gpio_direction_output(TCC_GPF(27), 0);	 // Speaker mute
			#endif

			tcc_gpio_config(TCC_GPG(5), GPIO_FN(0));
			gpio_request(TCC_GPG(5), "HP_MUTE_CTL");
			gpio_direction_output(TCC_GPG(5), 1);	 // HeadPhone mute
		}

		tcc_hp_hw_mute(false);
		tcc_spk_hw_mute(false);

        tcc_soc_card.name = "M805";
	}

#else
    alsa_dbg("TCC Board probe [%s]\n [Error] Don't support architecture..\n", __FUNCTION__);
	return 0;
#endif


    tcc_hp_hw_mute(true);
    tcc_spk_hw_mute(true);

    tca_tcc_initport();

    ret = es8388_i2c_register();

	tcc_snd_device = platform_device_alloc("soc-audio", -1);
	if (!tcc_snd_device)
		return -ENOMEM;

	platform_set_drvdata(tcc_snd_device, &tcc_soc_card);

	ret = platform_device_add(tcc_snd_device);
	if (ret) {
        printk(KERN_ERR "Unable to add platform device\n");\
		platform_device_put(tcc_snd_device);
	}

	return ret;
}
Esempio n. 13
0
static int uv_probe(struct platform_device *pdev)
{
	struct uv_info *uv;
	struct uv_platform_data *pdata = pdev->dev.platform_data;
	int ret = 0;

	pr_info("%s: is started\n", __func__);
	if (!pdata) {
		pr_err("%s: pdata is NULL\n", __func__);
		return -ENODEV;
	}

	/* allocate memory */
	uv = kzalloc(sizeof(struct uv_info), GFP_KERNEL);
	if (uv == NULL) {
		pr_err("%s: Failed to allocate memory\n", __func__);
		return -ENOMEM;
	}

	uv->pdata = pdata;

	/* Setup for ADC */
	/* alloc platform device for adc client */
	uv->pdev_uv_adc = platform_device_alloc("uv-adc", -1);
	if (!uv->pdev_uv_adc) {
		pr_err("%s: could not allocation uv-adc\n", __func__);
		goto err_alloc_pdev;
	}

	if (pdata->adc_ap_init && pdata->adc_ap_exit) {
		uv->pdata->adc_ap_init = pdata->adc_ap_init;
		uv->pdata->adc_ap_exit = pdata->adc_ap_exit;
		ret = pdata->adc_ap_init(uv->pdev_uv_adc);
		if (!ret) {
			ret = -1;
			goto err_setup_adc;
		}
	}

	if (pdata->power_on) {
		uv->pdata->power_on = pdata->power_on;
		uv->pdata->power_on(false);
	}
	uv->onoff = false;

	if (pdata->get_adc_value)
		uv->pdata->get_adc_value = pdata->get_adc_value;

	mutex_init(&uv->power_lock);
	mutex_init(&uv->read_lock);

	/* allocate uv input device */
	uv->uv_input_dev = input_allocate_device();
	if (!uv->uv_input_dev) {
		pr_err("%s: could not allocate input device\n",
			__func__);
		goto err_input_allocate_device_uv;
	}

	input_set_drvdata(uv->uv_input_dev, uv);
	uv->uv_input_dev->name = "uv_sensor";
	input_set_capability(uv->uv_input_dev, EV_REL, REL_MISC);

	ret = input_register_device(uv->uv_input_dev);
	if (ret < 0) {
		pr_err("%s: could not register input device\n",
			__func__);
		input_free_device(uv->uv_input_dev);
		goto err_input_register_device_uv;
	}

	ret = sysfs_create_group(&uv->uv_input_dev->dev.kobj,
				&uv_attribute_group);
	if (ret) {
		pr_err("%s: could not create sysfs group\n",
			__func__);
		goto err_sysfs_create_group_uv;
	}

	/* timer init */
	hrtimer_init(&uv->uv_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	uv->uv_poll_delay = ns_to_ktime(200 * NSEC_PER_MSEC);
	uv->uv_timer.function = uv_timer_func;

	/* workqueue init */
	uv->uv_wq = create_singlethread_workqueue("uv_wq");
	if (!uv->uv_wq) {
		ret = -ENOMEM;
		pr_err("%s: could not create uv workqueue\n",
			__func__);
		goto err_create_uv_workqueue;
	}
	INIT_WORK(&uv->work_uv, work_func_uv);

	/* sysfs for uv sensor */
	ret = sensors_register(uv->uv_dev, uv, uv_sensor_attrs,
		"uv_sensor");
	if (ret) {
		pr_err("%s: could not register uv device(%d)\n",
			__func__, ret);
		goto err_sensor_register_failed;
	}

	ret = sensors_create_symlink(&uv->uv_input_dev->dev.kobj,
		uv->uv_input_dev->name);
	if (ret < 0) {
		pr_err("%s, sensors_create_symlinks failed!(%d)\n",
			__func__, ret);
		goto err_uv_input__sysfs_create_link;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	uv->early_suspend.suspend = ssp_early_suspend;
	uv->early_suspend.resume = ssp_late_resume;
	register_early_suspend(&uv->early_suspend);
#endif

	platform_set_drvdata(pdev, uv);

	pr_info("%s, success\n", __func__);
	return 0;
err_uv_input__sysfs_create_link:
	sensors_unregister(uv->uv_dev, uv_sensor_attrs);
err_sensor_register_failed:
	destroy_workqueue(uv->uv_wq);
err_create_uv_workqueue:
	sysfs_remove_group(&uv->uv_input_dev->dev.kobj,
			   &uv_attribute_group);
err_sysfs_create_group_uv:
	input_unregister_device(uv->uv_input_dev);
err_input_register_device_uv:
err_input_allocate_device_uv:
	mutex_destroy(&uv->read_lock);
	mutex_destroy(&uv->power_lock);
	if (uv->pdata->adc_ap_exit)
		uv->pdata->adc_ap_exit(uv->pdev_uv_adc);
err_setup_adc:
	if (uv->pdev_uv_adc)
		platform_device_put(uv->pdev_uv_adc);
err_alloc_pdev:
	kfree(uv);
	return ret;
}
Esempio n. 14
0
static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo,
					int ctrl_nr)
{
	struct omap_hwmod *oh;
	struct omap_hwmod *ohs[1];
	struct omap_device *od;
	struct platform_device *pdev;
	char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
	struct omap_mmc_platform_data *mmc_data;
	struct omap_mmc_dev_attr *mmc_dev_attr;
	char *name;
	int res;

	mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
	if (!mmc_data) {
		pr_err("Cannot allocate memory for mmc device!\n");
		return;
	}

	res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
	if (res < 0)
		goto free_mmc;

	omap_hsmmc_mux(mmc_data, (ctrl_nr - 1));

	name = "omap_hsmmc";
	res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
		     "mmc%d", ctrl_nr);
	WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
	     "String buffer overflow in MMC%d device setup\n", ctrl_nr);

	oh = omap_hwmod_lookup(oh_name);
	if (!oh) {
		pr_err("Could not look up %s\n", oh_name);
		goto free_name;
	}
	ohs[0] = oh;
	if (oh->dev_attr != NULL) {
		mmc_dev_attr = oh->dev_attr;
		mmc_data->controller_flags = mmc_dev_attr->flags;
		/*
		 * erratum 2.1.1.128 doesn't apply if board has
		 * a transceiver is attached
		 */
		if (hsmmcinfo->transceiver)
			mmc_data->controller_flags &=
				~OMAP_HSMMC_BROKEN_MULTIBLOCK_READ;
	}

	pdev = platform_device_alloc(name, ctrl_nr - 1);
	if (!pdev) {
		pr_err("Could not allocate pdev for %s\n", name);
		goto free_name;
	}
	dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);

	od = omap_device_alloc(pdev, ohs, 1, NULL, 0);
	if (!od) {
		pr_err("Could not allocate od for %s\n", name);
		goto put_pdev;
	}

	res = platform_device_add_data(pdev, mmc_data,
			      sizeof(struct omap_mmc_platform_data));
	if (res) {
		pr_err("Could not add pdata for %s\n", name);
		goto put_pdev;
	}

	hsmmcinfo->pdev = pdev;

	if (hsmmcinfo->deferred)
		goto free_mmc;

	res = omap_device_register(pdev);
	if (res) {
		pr_err("Could not register od for %s\n", name);
		goto free_od;
	}

	goto free_mmc;

free_od:
	omap_device_delete(od);

put_pdev:
	platform_device_put(pdev);

free_name:
	kfree(mmc_data->slots[0].name);

free_mmc:
	kfree(mmc_data);
}
Esempio n. 15
0
static int __init dvblb_init(void)
{
	int i, j, ret, failed;
	dev_t dev = MKDEV(DVBSOFTWARECA_MAJOR, 0);
	char device_name[50];

	failed=0;

	if ((ret = register_chrdev_region(dev, MAX_CA_DEVICES, "DVBSOFTWARECSA")) != 0) {
		printk(KERN_ERR "dvbsoftwareca: unable to get major %d\n", DVBSOFTWARECA_MAJOR);
		return ret;
	}

	cdev_init(&ca_devices_cdev, &ca_device_fops);

	if ((ret = cdev_add(&ca_devices_cdev, dev, MAX_CA_DEVICES)) != 0) {
		printk(KERN_ERR "dvbsoftwareca: unable register character device\n");
		return ret;
	}

 	dvb_class = class_create(THIS_MODULE, "dvbsoftwareca");
	if (IS_ERR(dvb_class)) {
		printk("dvbsoftwareca: unable to create dvb_class\n");
		return PTR_ERR(dvb_class);
	}
	dvb_class->dev_uevent = dvb_uevent;
	dvb_class->devnode = dvb_devnode;

	info("frontend loopback driver v"DVBSOFTWARECA_VERSION);
	printk("dvbsoftwareca: registering adapters\n");

	dvblb_basedev = platform_device_alloc("dvbsoftwareca", -1);
	if (!dvblb_basedev) {
		return -ENOMEM;
	}
	ret = platform_device_add(dvblb_basedev);
	if (ret) {
		platform_device_put(dvblb_basedev);
		return ret;
	}

	ret = register_netlink();
	if (ret) {
		printk("dvbsoftwareca: unable to register netlink socket\n");
		return -EFAULT;
	}

	for(i=0; i < 8; i++) {
		for(j=0; (j<8 && devices_counter<MAX_CA_DEVICES); j++) {
			struct file *filp;
			
			snprintf(device_name, 50, "/dev/dvb/adapter%d/frontend%d", i, j);
			filp = filp_open(device_name,00,O_RDONLY);

			if (!IS_ERR(filp) && filp!=NULL) {
				filp_close(filp, NULL);

				ret = create_ca_device(i, j, devices_counter++);
				if (ret != 0) {
					printk("dvbsoftwareca: Failed to add CA%d device for adapter%d\n", j, i);
					failed = 1;
					break;
				}
				printk("dvbsoftwareca: registered CA%d device for adapter%d\n", j, i);
			}

		}

		if (failed)
			break;
	}

	if (!failed)
		printk("dvbsoftwareca: registered %d CA devices\n", devices_counter);
	
	if (failed) {
		for(i = 0; i < devices_counter; i++) {
			destroy_ca_device(ca_devices[i]);
		}
		platform_device_unregister(dvblb_basedev);
		cdev_del(&ca_devices_cdev);
		unregister_chrdev_region(dev, MAX_CA_DEVICES);

		return -EFAULT;
	}

	return 0;
}
Esempio n. 16
0
static int __init n810_soc_init(void)
{
	int err;
	struct device *dev;

	if (!(machine_is_nokia_n810() || machine_is_nokia_n810_wimax()))
		return -ENODEV;

	n810_snd_device = platform_device_alloc("soc-audio", -1);
	if (!n810_snd_device)
		return -ENOMEM;

	platform_set_drvdata(n810_snd_device, &snd_soc_n810);
	err = platform_device_add(n810_snd_device);
	if (err)
		goto err1;

	dev = &n810_snd_device->dev;

	sys_clkout2_src = clk_get(dev, "sys_clkout2_src");
	if (IS_ERR(sys_clkout2_src)) {
		dev_err(dev, "Could not get sys_clkout2_src clock\n");
		err = PTR_ERR(sys_clkout2_src);
		goto err2;
	}
	sys_clkout2 = clk_get(dev, "sys_clkout2");
	if (IS_ERR(sys_clkout2)) {
		dev_err(dev, "Could not get sys_clkout2\n");
		err = PTR_ERR(sys_clkout2);
		goto err3;
	}
	/*
	 * Configure 12 MHz output on SYS_CLKOUT2. Therefore we must use
	 * 96 MHz as its parent in order to get 12 MHz
	 */
	func96m_clk = clk_get(dev, "func_96m_ck");
	if (IS_ERR(func96m_clk)) {
		dev_err(dev, "Could not get func 96M clock\n");
		err = PTR_ERR(func96m_clk);
		goto err4;
	}
	clk_set_parent(sys_clkout2_src, func96m_clk);
	clk_set_rate(sys_clkout2, 12000000);

	if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) ||
		    (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) {
		err = -EINVAL;
		goto err4;
	}

	gpio_direction_output(N810_HEADSET_AMP_GPIO, 0);
	gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);

	return 0;
err4:
	clk_put(sys_clkout2);
err3:
	clk_put(sys_clkout2_src);
err2:
	platform_device_del(n810_snd_device);
err1:
	platform_device_put(n810_snd_device);

	return err;
}
Esempio n. 17
0
static int __init msi_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	dmi_check_system(msi_dmi_table);
	if (!quirks)
		/* quirks may be NULL if no match in DMI table */
		quirks = &quirk_load_scm_model;
	if (force)
		quirks = &quirk_old_ec_model;

	if (!quirks->old_ec_model)
		get_threeg_exists();

	if (auto_brightness < 0 || auto_brightness > 2)
		return -EINVAL;

	/* Register backlight stuff */

	if (!quirks->old_ec_model || acpi_video_backlight_support()) {
		pr_info("Brightness ignored, must be controlled by ACPI video driver\n");
	} else {
		struct backlight_properties props;
		memset(&props, 0, sizeof(struct backlight_properties));
		props.type = BACKLIGHT_PLATFORM;
		props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
		msibl_device = backlight_device_register("msi-laptop-bl", NULL,
							 NULL, &msibl_ops,
							 &props);
		if (IS_ERR(msibl_device))
			return PTR_ERR(msibl_device);
	}

	ret = platform_driver_register(&msipf_driver);
	if (ret)
		goto fail_backlight;

	/* Register platform stuff */

	msipf_device = platform_device_alloc("msi-laptop-pf", -1);
	if (!msipf_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(msipf_device);
	if (ret)
		goto fail_platform_device1;

	if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) {
		ret = -EINVAL;
		goto fail_platform_device1;
	}

	ret = sysfs_create_group(&msipf_device->dev.kobj,
				 &msipf_attribute_group);
	if (ret)
		goto fail_platform_device2;

	if (!quirks->old_ec_model) {
		if (threeg_exists)
			ret = device_create_file(&msipf_device->dev,
						&dev_attr_threeg);
		if (ret)
			goto fail_platform_device2;
	} else {
		ret = sysfs_create_group(&msipf_device->dev.kobj,
					 &msipf_old_attribute_group);
		if (ret)
			goto fail_platform_device2;

		/* Disable automatic brightness control by default because
		 * this module was probably loaded to do brightness control in
		 * software. */

		if (auto_brightness != 2)
			set_auto_brightness(auto_brightness);
	}

	pr_info("driver " MSI_DRIVER_VERSION " successfully loaded\n");

	return 0;

fail_platform_device2:

	if (quirks->load_scm_model) {
		i8042_remove_filter(msi_laptop_i8042_filter);
		cancel_delayed_work_sync(&msi_rfkill_dwork);
		cancel_work_sync(&msi_rfkill_work);
		rfkill_cleanup();
	}
	platform_device_del(msipf_device);

fail_platform_device1:

	platform_device_put(msipf_device);

fail_platform_driver:

	platform_driver_unregister(&msipf_driver);

fail_backlight:

	backlight_device_unregister(msibl_device);

	return ret;
}
Esempio n. 18
0
static int __init vega_audio_init(void)
{
	int ret;
	u32 val;

#ifdef USE_GPR
	val = __raw_readl(S5P64XX_GPRPUD);
	val &= ~((3<<8) | (3<<10) | (3<<14) | (3<<16) | (3<<18) | (3<<28) | (3<<30));
	val |= ((0<<8) | (0<<10) | (0<<14) | (0<<16) | (0<<18) | (0<<28) | (1<<30));
	__raw_writel(val, S5P64XX_GPRPUD);

	val = __raw_readl(S5P64XX_GPRCON0);
	val &= ~((0xf<<16) | (0xf<<20) | (0xf<<28));
	val |= (5<<16) | (5<<20) | (5<<28);
	__raw_writel(val, S5P64XX_GPRCON0);

	val = __raw_readl(S5P64XX_GPRCON1);
	val &= ~((0xf<<0) | (0xf<<4) | (0xf<<24) | (0xf<<28));
	val |= (5<<0) | (5<<4) | (5<<24) | (5<<28);
	__raw_writel(val, S5P64XX_GPRCON1);

#else
	val = __raw_readl(S5P64XX_GPCPUD);
	val &= ~((3<<8) | (3<<10) | (3<<14));
	val |= ((0<<8) | (0<<10) | (0<<14));
	__raw_writel(val, S5P64XX_GPCPUD);

	val = __raw_readl(S5P64XX_GPCCON);
	val &= ~((0xf<<16) | (0xf<<20) | (0xf<<28));
	val |= (5<<16) | (5<<20) | (5<<28);
	__raw_writel(val, S5P64XX_GPCCON);

	val = __raw_readl(S5P64XX_GPHPUD);
	val &= ~((3<<12) | (3<<14) | (3<<16) | (3<<18));
	val |= ((0<<12) | (1<<14) | (0<<16) | (0<18));
	__raw_writel(val, S5P64XX_GPHPUD);

	val = __raw_readl(S5P64XX_GPHCON0);
	val &= ~((0xf<<24) | (0xf<<28));
	val |= (5<<24) | (5<<28);
	__raw_writel(val, S5P64XX_GPHCON0);

	val = __raw_readl(S5P64XX_GPHCON1);
	val &= ~((0xf<<0) | (0xf<<4));
	val |= (5<<0) | (5<<4);
	__raw_writel(val, S5P64XX_GPHCON1);

	val = __raw_readl(S3C_CLK_OUT);
	val &= ~(0xff << 12);
	val |= (0x1<<12) | (0<<16);
	__raw_writel(val, S3C_CLK_OUT);
#endif

	smdk6440_snd_device = platform_device_alloc("soc-audio", 0);
	if (!smdk6440_snd_device)
		return -ENOMEM;

	platform_set_drvdata(smdk6440_snd_device, &smdk6440_snd_devdata);
	smdk6440_snd_devdata.dev = &smdk6440_snd_device->dev;
	ret = platform_device_add(smdk6440_snd_device);

	if (ret)
		platform_device_put(smdk6440_snd_device);
	
	return ret;
}
Esempio n. 19
0
static int __init omap2430_probe(struct platform_device *pdev)
{
	struct musb_hdrc_platform_data	*pdata = pdev->dev.platform_data;
	struct platform_device		*musb;
	struct omap2430_glue		*glue;
	int				ret = -ENOMEM;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
		dev_err(&pdev->dev, "failed to allocate glue context\n");
		goto err0;
	}

	musb = platform_device_alloc("musb-hdrc", -1);
	if (!musb) {
		dev_err(&pdev->dev, "failed to allocate musb device\n");
		goto err1;
	}

	musb->dev.parent		= &pdev->dev;
	musb->dev.dma_mask		= &omap2430_dmamask;
	musb->dev.coherent_dma_mask	= omap2430_dmamask;

	glue->dev			= &pdev->dev;
	glue->musb			= musb;

	pdata->platform_ops		= &omap2430_ops;

	platform_set_drvdata(pdev, glue);

	ret = platform_device_add_resources(musb, pdev->resource,
			pdev->num_resources);
	if (ret) {
		dev_err(&pdev->dev, "failed to add resources\n");
		goto err2;
	}

	ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
	if (ret) {
		dev_err(&pdev->dev, "failed to add platform_data\n");
		goto err2;
	}

	ret = platform_device_add(musb);
	if (ret) {
		dev_err(&pdev->dev, "failed to register musb device\n");
		goto err2;
	}

	pm_runtime_enable(&pdev->dev);

	return 0;

err2:
	platform_device_put(musb);

err1:
	kfree(glue);

err0:
	return ret;
}
Esempio n. 20
0
static int ebi2_lcd_probe(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct platform_device *mdp_dev = NULL;
	struct msm_fb_panel_data *pdata = NULL;
	int rc, i;

	if (pdev->id == 0) {
		for (i = 0; i < pdev->num_resources; i++) {
			if (!strncmp(pdev->resource[i].name, "base", 4)) {
				ebi2_base = ioremap(pdev->resource[i].start,
						pdev->resource[i].end -
						pdev->resource[i].start + 1);
				if (!ebi2_base) {
					printk(KERN_ERR
						"ebi2_base ioremap failed!\n");
					return -ENOMEM;
				}
				ebi2_lcd_cfg0 = (void *)(ebi2_base + 0x20);
				ebi2_lcd_cfg1 = (void *)(ebi2_base + 0x24);
			} else if (!strncmp(pdev->resource[i].name,
						"lcd01", 5)) {
				lcd01_base = ioremap(pdev->resource[i].start,
						pdev->resource[i].end -
						pdev->resource[i].start + 1);
				if (!lcd01_base) {
					printk(KERN_ERR
						"lcd01_base ioremap failed!\n");
					return -ENOMEM;
				}
			} else if (!strncmp(pdev->resource[i].name,
						"lcd02", 5)) {
				lcd02_base = ioremap(pdev->resource[i].start,
						pdev->resource[i].end -
						pdev->resource[i].start + 1);
				if (!lcd02_base) {
					printk(KERN_ERR
						"lcd02_base ioremap failed!\n");
					return -ENOMEM;
				}
			}
		}
		ebi2_lcd_resource_initialized = 1;
		return 0;
	}

	if (!ebi2_lcd_resource_initialized)
		return -EPERM;

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;

	if (mfd->key != MFD_KEY)
		return -EINVAL;

	if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST)
		return -ENOMEM;

	if (ebi2_base == NULL)
		return -ENOMEM;

	mdp_dev = platform_device_alloc("mdp", pdev->id);
	if (!mdp_dev)
		return -ENOMEM;

	/* link to the latest pdev */
	mfd->pdev = mdp_dev;
	mfd->dest = DISPLAY_LCD;

	/* add panel data */
	if (platform_device_add_data
	    (mdp_dev, pdev->dev.platform_data,
	     sizeof(struct msm_fb_panel_data))) {
		printk(KERN_ERR "ebi2_lcd_probe: platform_device_add_data failed!\n");
		platform_device_put(mdp_dev);
		return -ENOMEM;
	}

	/* data chain */
	pdata = mdp_dev->dev.platform_data;
	pdata->on = panel_next_on;
	pdata->off = panel_next_off;
	pdata->next = pdev;

	/* get/set panel specific fb info */
	mfd->panel_info = pdata->panel_info;

	if (mfd->panel_info.bpp == 24)
		mfd->fb_imgType = MDP_RGB_888;
	else
		mfd->fb_imgType = MDP_RGB_565;

	/* config msm ebi2 lcd register */
	if (mfd->panel_info.pdest == DISPLAY_1) {
		outp32(ebi2_base,
		       (inp32(ebi2_base) & (~(EBI2_PRIM_LCD_CLR))) |
		       EBI2_PRIM_LCD_SEL);
		/*
		 * current design has one set of cfg0/1 register to control
		 * both EBI2 channels. so, we're using the PRIM channel to
		 * configure both.
		 */
		outp32(ebi2_lcd_cfg0, mfd->panel_info.wait_cycle);
		if (mfd->panel_info.bpp == 18)
			outp32(ebi2_lcd_cfg1, 0x01000000);
		else
			outp32(ebi2_lcd_cfg1, 0x0);
	} else {
#ifdef DEBUG_EBI2_LCD
		/*
		 * confliting with QCOM SURF FPGA CS.
		 * OEM should enable below for their CS mapping
		 */
		 outp32(ebi2_base, (inp32(ebi2_base)&(~(EBI2_SECD_LCD_CLR)))
					|EBI2_SECD_LCD_SEL);
#endif
	}

	/*
	 * map cs (chip select) address
	 */
	if (mfd->panel_info.pdest == DISPLAY_1) {
		mfd->cmd_port = lcd01_base;
		mfd->data_port =
		    (void *)((uint32) mfd->cmd_port + EBI2_PRIM_LCD_RS_PIN);
		mfd->data_port_phys =
		    (void *)(LCD_PRIM_BASE_PHYS + EBI2_PRIM_LCD_RS_PIN);
	} else {
		mfd->cmd_port = lcd01_base;
		mfd->data_port =
		    (void *)((uint32) mfd->cmd_port + EBI2_SECD_LCD_RS_PIN);
		mfd->data_port_phys =
		    (void *)(LCD_SECD_BASE_PHYS + EBI2_SECD_LCD_RS_PIN);
	}

	/*
	 * set driver data
	 */
	platform_set_drvdata(mdp_dev, mfd);

	/*
	 * register in mdp driver
	 */
	rc = platform_device_add(mdp_dev);
	if (rc) {
		goto ebi2_lcd_probe_err;
	}

	pm_runtime_set_active(&pdev->dev);
	pm_runtime_enable(&pdev->dev);


	pdev_list[pdev_list_cnt++] = pdev;
	return 0;

      ebi2_lcd_probe_err:
	platform_device_put(mdp_dev);
	return rc;
}
Esempio n. 21
0
static int __init init_nsc(void)
{
	int rc = 0;
	int lo, hi, err;
	int nscAddrBase = TPM_ADDR;
	struct tpm_chip *chip;
	unsigned long base;

	/* verify that it is a National part (SID) */
	if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) {
		nscAddrBase = (tpm_read_index(TPM_SUPERIO_ADDR, 0x2C)<<8)|
			(tpm_read_index(TPM_SUPERIO_ADDR, 0x2B)&0xFE);
		if (tpm_read_index(nscAddrBase, NSC_SID_INDEX) != 0xF6)
			return -ENODEV;
	}

	err = platform_driver_register(&nsc_drv);
	if (err)
		return err;

	hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
	lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
	base = (hi<<8) | lo;

	/* enable the DPM module */
	tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);

	pdev = platform_device_alloc("tpm_nscl0", -1);
	if (!pdev) {
		rc = -ENOMEM;
		goto err_unreg_drv;
	}

	pdev->num_resources = 0;
	pdev->dev.driver = &nsc_drv.driver;
	pdev->dev.release = tpm_nsc_remove;

	if ((rc = platform_device_add(pdev)) < 0)
		goto err_put_dev;

	if (request_region(base, 2, "tpm_nsc0") == NULL ) {
		rc = -EBUSY;
		goto err_del_dev;
	}

	chip = tpmm_chip_alloc(&pdev->dev, &tpm_nsc);
	if (IS_ERR(chip)) {
		rc = -ENODEV;
		goto err_rel_reg;
	}

	rc = tpm_chip_register(chip);
	if (rc)
		goto err_rel_reg;

	dev_dbg(&pdev->dev, "NSC TPM detected\n");
	dev_dbg(&pdev->dev,
		"NSC LDN 0x%x, SID 0x%x, SRID 0x%x\n",
		tpm_read_index(nscAddrBase,0x07), tpm_read_index(nscAddrBase,0x20),
		tpm_read_index(nscAddrBase,0x27));
	dev_dbg(&pdev->dev,
		"NSC SIOCF1 0x%x SIOCF5 0x%x SIOCF6 0x%x SIOCF8 0x%x\n",
		tpm_read_index(nscAddrBase,0x21), tpm_read_index(nscAddrBase,0x25),
		tpm_read_index(nscAddrBase,0x26), tpm_read_index(nscAddrBase,0x28));
	dev_dbg(&pdev->dev, "NSC IO Base0 0x%x\n",
		(tpm_read_index(nscAddrBase,0x60) << 8) | tpm_read_index(nscAddrBase,0x61));
	dev_dbg(&pdev->dev, "NSC IO Base1 0x%x\n",
		(tpm_read_index(nscAddrBase,0x62) << 8) | tpm_read_index(nscAddrBase,0x63));
	dev_dbg(&pdev->dev, "NSC Interrupt number and wakeup 0x%x\n",
		tpm_read_index(nscAddrBase,0x70));
	dev_dbg(&pdev->dev, "NSC IRQ type select 0x%x\n",
		tpm_read_index(nscAddrBase,0x71));
	dev_dbg(&pdev->dev,
		"NSC DMA channel select0 0x%x, select1 0x%x\n",
		tpm_read_index(nscAddrBase,0x74), tpm_read_index(nscAddrBase,0x75));
	dev_dbg(&pdev->dev,
		"NSC Config "
		"0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
		tpm_read_index(nscAddrBase,0xF0), tpm_read_index(nscAddrBase,0xF1),
		tpm_read_index(nscAddrBase,0xF2), tpm_read_index(nscAddrBase,0xF3),
		tpm_read_index(nscAddrBase,0xF4), tpm_read_index(nscAddrBase,0xF5),
		tpm_read_index(nscAddrBase,0xF6), tpm_read_index(nscAddrBase,0xF7),
		tpm_read_index(nscAddrBase,0xF8), tpm_read_index(nscAddrBase,0xF9));

	dev_info(&pdev->dev,
		 "NSC TPM revision %d\n",
		 tpm_read_index(nscAddrBase, 0x27) & 0x1F);

	chip->vendor.base = base;

	return 0;

err_rel_reg:
	release_region(base, 2);
err_del_dev:
	platform_device_del(pdev);
err_put_dev:
	platform_device_put(pdev);
err_unreg_drv:
	platform_driver_unregister(&nsc_drv);
	return rc;
}
static int __init wmt_vibrate_init(void)
{
	int error = 0;

	/* get vibrator setting */
	get_vibratorset(&l_vibratedev);

	vibrate_gpio_init();

	/* other initial */
	mutex_init(&l_vibratedev.mlock);
	//INIT_WORK(&l_vibratedev.work, vib_work_handler);
	setup_timer(&vibrate_timer, wmt_disable_vibrator, 0);

	/* register char device */
	if (register_chrdev (WMT_VIBRATE_MAJOR, WMT_VIBRATE_DEVICE_NAME, &vibrate_fops)) {
		printk (KERN_ERR "wmt vibrate: unable to get major %d\n", WMT_VIBRATE_MAJOR);
		error = -EIO;
		goto initend;
	}
	/* (mknod /dev/wmt_vibrate c 37 0) */
	l_vibratedev.dev_class = class_create(THIS_MODULE, WMT_VIBRATE_DEVICE_NAME);
	if (IS_ERR(l_vibratedev.dev_class))
	{
		error = PTR_ERR(l_vibratedev.dev_class);
		printk(KERN_ERR "Can't class_create vibrate device !!\n");
		goto initend1;
	}
	/*
	if (class_create_file(l_vibratedev.dev_class, &class_attr_vibrate) < 0)
	{
		printk(KERN_ERR "Can't add class attr !\n");
		return -1;
	}
	*/

	l_vibratedev.device = device_create(l_vibratedev.dev_class, NULL, MKDEV(WMT_VIBRATE_MAJOR, 0), NULL, WMT_VIBRATE_DEVICE_NAME);
    if (IS_ERR(l_vibratedev.device))
    {
    	error = PTR_ERR(l_vibratedev.device);
    	printk(KERN_ERR "Failed to create device %s !!!",WMT_VIBRATE_DEVICE_NAME);
    	goto initend2;
    }
    /*
    if (device_create_file(l_vibratedev.device, &dev_attr_vibrate))
    {
    	printk(KERN_ERR "Can't add device attr!!!\n");
    	return -1;
    }
    */

	/* create '/sys/class/timed_output/vibrator/enable' */
	if ((error = timed_output_dev_register(&l_vibratedev.vibtimedev)) != 0)
	{
		goto initend3;
	}

	error = platform_driver_register(&vibrate_driver);
	if (error)
		goto exit_timed_unregsiter;

	vibrate_platform_device = platform_device_alloc(WMT_VIBRATE_DEVICE_NAME, -1);
	if (!vibrate_platform_device) {
		error = -ENOMEM;
		printk(KERN_ERR "Can't alloc vibrate_platform_device!!!\n");
		goto initend4;
	}

	error = platform_device_add(vibrate_platform_device);
	if (error)
		goto initend5;

	printk(KERN_ALERT"WMT vibrater driver load successfully!\n");
	return 0;

initend5:
	platform_device_put(vibrate_platform_device);
initend4:
	platform_driver_unregister(&vibrate_driver);
exit_timed_unregsiter:
	timed_output_dev_unregister(&l_vibratedev.vibtimedev);
initend3:
	device_destroy(l_vibratedev.dev_class, MKDEV(WMT_VIBRATE_MAJOR, 0));
initend2:
	class_destroy(l_vibratedev.dev_class);
initend1:
	unregister_chrdev(WMT_VIBRATE_MAJOR, WMT_VIBRATE_DEVICE_NAME);
initend:
	return error;
}
Esempio n. 23
0
static int gpiommc_probe(struct platform_device *pdev)
{
	struct gpiommc_platform_data *mmc_pdata = pdev->dev.platform_data;
	struct spi_gpio_platform_data spi_pdata;
	struct gpiommc_device *d;
	int err;

	err = -ENXIO;
	if (!mmc_pdata)
		goto error;

#ifdef CONFIG_MMC_SPI_MODULE
	err = request_module("mmc_spi");
	if (err) {
		printk(KERN_WARNING PFX
		       "Failed to request mmc_spi module.\n");
	}
#endif /* CONFIG_MMC_SPI_MODULE */

	/* Allocate the GPIO-MMC device */
	err = -ENOMEM;
	d = kzalloc(sizeof(*d), GFP_KERNEL);
	if (!d)
		goto error;
	d->pdev = pdev;

	/* Create the SPI-GPIO device */
	d->spi_pdev = platform_device_alloc(SPI_GPIO_PLATDEV_NAME,
					    spi_gpio_next_id());
	if (!d->spi_pdev)
		goto err_free_d;

	memset(&spi_pdata, 0, sizeof(spi_pdata));
	spi_pdata.pin_clk = mmc_pdata->pins.gpio_clk;
	spi_pdata.pin_miso = mmc_pdata->pins.gpio_do;
	spi_pdata.pin_mosi = mmc_pdata->pins.gpio_di;
	spi_pdata.pin_cs = mmc_pdata->pins.gpio_cs;
	spi_pdata.cs_activelow = mmc_pdata->pins.cs_activelow;
	spi_pdata.no_spi_delay = mmc_pdata->no_spi_delay;
	spi_pdata.boardinfo_setup = gpiommc_boardinfo_setup;
	spi_pdata.boardinfo_setup_data = d;

	err = platform_device_add_data(d->spi_pdev, &spi_pdata,
				       sizeof(spi_pdata));
	if (err)
		goto err_free_pdev;
	err = platform_device_add(d->spi_pdev);
	if (err)
		goto err_free_pdata;
	platform_set_drvdata(pdev, d);

	printk(KERN_INFO PFX "MMC-Card \"%s\" "
	       "attached to GPIO pins di=%u, do=%u, clk=%u, cs=%u\n",
	       mmc_pdata->name, mmc_pdata->pins.gpio_di,
	       mmc_pdata->pins.gpio_do,
	       mmc_pdata->pins.gpio_clk,
	       mmc_pdata->pins.gpio_cs);

	return 0;

err_free_pdata:
	kfree(d->spi_pdev->dev.platform_data);
	d->spi_pdev->dev.platform_data = NULL;
err_free_pdev:
	platform_device_put(d->spi_pdev);
err_free_d:
	kfree(d);
error:
	return err;
}
int __init pc8736x_gpio_init(void)
{
	int rc;
	dev_t devid;

	pdev = platform_device_alloc(DEVNAME, 0);
	if (!pdev)
		return -ENOMEM;

	rc = platform_device_add(pdev);
	if (rc) {
		rc = -ENODEV;
		goto undo_platform_dev_alloc;
	}
	dev_info(&pdev->dev, "NatSemi pc8736x GPIO Driver Initializing\n");

	if (!pc8736x_superio_present()) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "no device found\n");
		goto undo_platform_dev_add;
	}
	pc8736x_gpio_ops.dev = &pdev->dev;
        __VERIFIER_assert(pc8736x_gpio_ops.dev == &pdev->dev);

	/* Verify that chip and it's GPIO unit are both enabled.
	   My BIOS does this, so I take minimum action here
	 */
	rc = superio_inb(SIO_CF1);
	if (!(rc & 0x01)) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "device not enabled\n");
		goto undo_platform_dev_add;
	}
	device_select(SIO_GPIO_UNIT);
	if (!superio_inb(SIO_UNIT_ACT)) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "GPIO unit not enabled\n");
		goto undo_platform_dev_add;
	}

	/* read the GPIO unit base addr that chip responds to */
	pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8
			     | superio_inb(SIO_BASE_LADDR));

	if (!request_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE, DEVNAME)) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "GPIO ioport %x busy\n",
			pc8736x_gpio_base);
		goto undo_platform_dev_add;
	}
	dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base);

	if (major) {
		devid = MKDEV(major, 0);
		rc = register_chrdev_region(devid, PC8736X_GPIO_CT, DEVNAME);
	} else {
		rc = alloc_chrdev_region(&devid, 0, PC8736X_GPIO_CT, DEVNAME);
		major = MAJOR(devid);
	}

	if (rc < 0) {
		dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc);
		goto undo_request_region;
	}
	if (!major) {
		major = rc;
		dev_dbg(&pdev->dev, "got dynamic major %d\n", major);
	}

	pc8736x_init_shadow();

	/* ignore minor errs, and succeed */
	cdev_init(&pc8736x_gpio_cdev, &pc8736x_gpio_fileops);
	cdev_add(&pc8736x_gpio_cdev, devid, PC8736X_GPIO_CT);

	return 0;

undo_request_region:
	release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE);
undo_platform_dev_add:
	platform_device_del(pdev);
undo_platform_dev_alloc:
	platform_device_put(pdev);

	return rc;
}
static int mfd_add_device(struct device *parent, int id,
			  const struct mfd_cell *cell,
			  struct resource *mem_base,
			  int irq_base)
{
	struct resource *res;
	struct platform_device *pdev;
	int ret = -ENOMEM;
	int r;

	pdev = platform_device_alloc(cell->name, id + cell->id);
	if (!pdev)
		goto fail_alloc;

	res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL);
	if (!res)
		goto fail_device;

	pdev->dev.parent = parent;
	pdev->dev.type = &mfd_dev_type;

	if (cell->pdata_size) {
		ret = platform_device_add_data(pdev,
					cell->platform_data, cell->pdata_size);
		if (ret)
			goto fail_res;
	}

	ret = mfd_platform_add_cell(pdev, cell);
	if (ret)
		goto fail_res;

	for (r = 0; r < cell->num_resources; r++) {
		res[r].name = cell->resources[r].name;
		res[r].flags = cell->resources[r].flags;

		/* Find out base to use */
		if ((cell->resources[r].flags & IORESOURCE_MEM) && mem_base) {
			res[r].parent = mem_base;
			res[r].start = mem_base->start +
				cell->resources[r].start;
			res[r].end = mem_base->start +
				cell->resources[r].end;
		} else if (cell->resources[r].flags & IORESOURCE_IRQ) {
			res[r].start = irq_base +
				cell->resources[r].start;
			res[r].end   = irq_base +
				cell->resources[r].end;
		} else {
			res[r].parent = cell->resources[r].parent;
			res[r].start = cell->resources[r].start;
			res[r].end   = cell->resources[r].end;
		}

		if (!cell->ignore_resource_conflicts) {
			ret = acpi_check_resource_conflict(&res[r]);
			if (ret)
				goto fail_res;
		}
	}

	ret = platform_device_add_resources(pdev, res, cell->num_resources);
	if (ret)
		goto fail_res;

	ret = platform_device_add(pdev);
	if (ret)
		goto fail_res;

	if (cell->pm_runtime_no_callbacks)
		pm_runtime_no_callbacks(&pdev->dev);

	kfree(res);

	return 0;

fail_res:
	kfree(res);
fail_device:
	platform_device_put(pdev);
fail_alloc:
	return ret;
}
Esempio n. 26
0
static int lcdc_probe(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct fb_info *fbi;
	struct platform_device *mdp_dev = NULL;
	struct msm_fb_panel_data *pdata = NULL;
	int rc;

	if (pdev->id == 0) {
		lcdc_pdata = pdev->dev.platform_data;
		return 0;
	}

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;

	if (mfd->key != MFD_KEY)
		return -EINVAL;

	if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST)
		return -ENOMEM;

	mdp_dev = platform_device_alloc("mdp", pdev->id);
	if (!mdp_dev)
		return -ENOMEM;

	/*
	 * link to the latest pdev
	 */
	mfd->pdev = mdp_dev;
	mfd->dest = DISPLAY_LCDC;

	/*
	 * alloc panel device data
	 */
	if (platform_device_add_data
	    (mdp_dev, pdev->dev.platform_data,
	     sizeof(struct msm_fb_panel_data))) {
		printk(KERN_ERR "lcdc_probe: platform_device_add_data failed!\n");
		platform_device_put(mdp_dev);
		return -ENOMEM;
	}
	/*
	 * data chain
	 */
	pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data;
	pdata->on = lcdc_on;
	pdata->off = lcdc_off;
	pdata->next = pdev;

	/*
	 * get/set panel specific fb info
	 */
	mfd->panel_info = pdata->panel_info;

	if (mfd->index == 0)
		mfd->fb_imgType = MSMFB_DEFAULT_TYPE;
	else
		mfd->fb_imgType = MDP_RGB_565;

	fbi = mfd->fbi;
	fbi->var.pixclock = clk_round_rate(pixel_mdp_clk,
					mfd->panel_info.clk_rate);
	fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch;
	fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch;
	fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch;
	fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch;
	fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width;
	fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width;

#ifndef CONFIG_MSM_BUS_SCALING
	mfd->ebi1_clk = clk_get(NULL, "ebi1_lcdc_clk");
	if (IS_ERR(mfd->ebi1_clk))
		return PTR_ERR(mfd->ebi1_clk);
#endif
	/*
	 * set driver data
	 */
	platform_set_drvdata(mdp_dev, mfd);
	/*
	 * register in mdp driver
	 */
	rc = platform_device_add(mdp_dev);
	if (rc)
		goto lcdc_probe_err;

	pdev_list[pdev_list_cnt++] = pdev;

	return 0;

lcdc_probe_err:
	platform_device_put(mdp_dev);
	return rc;
}
Esempio n. 27
0
static int __init smsc47b397_device_add(unsigned short address)
{
	struct resource res = {
		.start	= address,
		.end	= address + SMSC_EXTENT - 1,
		.name	= DRVNAME,
		.flags	= IORESOURCE_IO,
	};
	int err;

	err = acpi_check_resource_conflict(&res);
	if (err)
		goto exit;

	pdev = platform_device_alloc(DRVNAME, address);
	if (!pdev) {
		err = -ENOMEM;
		pr_err("Device allocation failed\n");
		goto exit;
	}

	err = platform_device_add_resources(pdev, &res, 1);
	if (err) {
		pr_err("Device resource addition failed (%d)\n", err);
		goto exit_device_put;
	}

	err = platform_device_add(pdev);
	if (err) {
		pr_err("Device addition failed (%d)\n", err);
		goto exit_device_put;
	}

	return 0;

exit_device_put:
	platform_device_put(pdev);
exit:
	return err;
}

static int __init smsc47b397_find(void)
{
	u8 id, rev;
	char *name;
	unsigned short addr;

	superio_enter();
	id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);

	switch (id) {
	case 0x81:
		name = "SCH5307-NS";
		break;
	case 0x6f:
		name = "LPC47B397-NC";
		break;
	case 0x85:
	case 0x8c:
		name = "SCH5317";
		break;
	default:
		superio_exit();
		return -ENODEV;
	}

	rev = superio_inb(SUPERIO_REG_DEVREV);

	superio_select(SUPERIO_REG_LD8);
	addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8)
		 |  superio_inb(SUPERIO_REG_BASE_LSB);

	pr_info("found SMSC %s (base address 0x%04x, revision %u)\n",
		name, addr, rev);

	superio_exit();
	return addr;
}
static int dummy_codec_audio_probe(struct platform_device *pdev)
{
    int ret = 0;
		struct snd_soc_card *card = &snd_soc_dummy_codec;

    //printk(KERN_DEBUG "enter %s\n", __func__);
    printk("enter %s\n", __func__);
#ifdef CONFIG_USE_OF
		dummy_codec_pdata = kzalloc(sizeof(struct dummy_codec_platform_data), GFP_KERNEL);
		if(!dummy_codec_pdata){
           // kfree(dummy_codec_pdata);
			return -1;
		}

		if (pdev->dev.of_node) {
            np = pdev->dev.of_node;
            ret = of_property_match_string(np,"status","okay");
            if(ret){
                printk("the platform not register this codec\n");
				goto err1;
            }
		}
		dummy_codec_dev=&pdev->dev;
    dummy_codec_pdata->device_init = &dummy_codec_device_init;
    dummy_codec_pdata->device_uninit = &dummy_codec_device_deinit;

		pdev->dev.platform_data = dummy_codec_pdata;
		dummy_codec_snd_pdata = pdev->dev.platform_data;
#endif

#if 1
    card->dev = &pdev->dev;
		platform_set_drvdata(pdev, card);
		snd_soc_card_set_drvdata(card, dummy_codec_pdata);
		if (!(pdev->dev.of_node)) {
			dev_err(&pdev->dev, "Must be instantiated using device tree\n");
			ret = -EINVAL;
			goto err;
		}

    ret = snd_soc_register_card(card);
		if (ret) {
			dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
			ret);
		goto err;
	}

#endif
#if 0
    dummy_codec_snd_pdata = pdev->dev.platform_data;
    snd_BUG_ON(!dummy_codec_snd_pdata);
    dummy_codec_snd_device = platform_device_alloc("soc-audio", -1);
    if (!dummy_codec_snd_device) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        ret = -ENOMEM;
        goto err;
    }

    platform_set_drvdata(dummy_codec_snd_device, &snd_soc_dummy_codec);

    ret = platform_device_add(dummy_codec_snd_device);
    if (ret) {
        printk(KERN_ERR "ASoC: Platform device allocation failed\n");
        goto err_device_add;
    }
#endif

    dummy_codec_dev_init();

    return ret;

#if 0
err_device_add:
    platform_device_put(dummy_codec_snd_device);
#endif
err:
err1:
    kfree(dummy_codec_pdata);
    return ret;
}
static int __init pc8736x_gpio_init(void)
{
	int rc;
	dev_t devid;

	pdev = platform_device_alloc(DEVNAME, 0);
	if (!pdev)
		return -ENOMEM;

	rc = platform_device_add(pdev);
	if (rc) {
		rc = -ENODEV;
		goto undo_platform_dev_alloc;
	}
	dev_info(&pdev->dev, "NatSemi pc8736x GPIO Driver Initializing\n");

	if (!pc8736x_superio_present()) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "no device found\n");
		goto undo_platform_dev_add;
	}
	pc8736x_gpio_ops.dev = &pdev->dev;

	rc = superio_inb(SIO_CF1);
	if (!(rc & 0x01)) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "device not enabled\n");
		goto undo_platform_dev_add;
	}
	device_select(SIO_GPIO_UNIT);
	if (!superio_inb(SIO_UNIT_ACT)) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "GPIO unit not enabled\n");
		goto undo_platform_dev_add;
	}

	
	pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8
			     | superio_inb(SIO_BASE_LADDR));

	if (!request_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE, DEVNAME)) {
		rc = -ENODEV;
		dev_err(&pdev->dev, "GPIO ioport %x busy\n",
			pc8736x_gpio_base);
		goto undo_platform_dev_add;
	}
	dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base);

	if (major) {
		devid = MKDEV(major, 0);
		rc = register_chrdev_region(devid, PC8736X_GPIO_CT, DEVNAME);
	} else {
		rc = alloc_chrdev_region(&devid, 0, PC8736X_GPIO_CT, DEVNAME);
		major = MAJOR(devid);
	}

	if (rc < 0) {
		dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc);
		goto undo_request_region;
	}
	if (!major) {
		major = rc;
		dev_dbg(&pdev->dev, "got dynamic major %d\n", major);
	}

	pc8736x_init_shadow();

	
	cdev_init(&pc8736x_gpio_cdev, &pc8736x_gpio_fileops);
	cdev_add(&pc8736x_gpio_cdev, devid, PC8736X_GPIO_CT);

	return 0;

undo_request_region:
	release_region(pc8736x_gpio_base, PC8736X_GPIO_RANGE);
undo_platform_dev_add:
	platform_device_del(pdev);
undo_platform_dev_alloc:
	platform_device_put(pdev);

	return rc;
}
Esempio n. 30
0
static int wl1271_probe(struct sdio_func *func,
				  const struct sdio_device_id *id)
{
	struct wl12xx_platform_data *wlan_data;
	struct wl12xx_sdio_glue *glue;
	struct resource res[1];
	mmc_pm_flag_t mmcflags;
	int ret = -ENOMEM;
	const char *chip_family;

	/* We are only able to handle the wlan function */
	if (func->num != 0x02)
		return -ENODEV;

	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
	if (!glue) {
		dev_err(&func->dev, "can't allocate glue\n");
		goto out;
	}

	glue->dev = &func->dev;

	/* Grab access to FN0 for ELP reg. */
	func->card->quirks |= MMC_QUIRK_LENIENT_FN0;

	/* Use block mode for transferring over one block size of data */
	func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;

	wlan_data = wl12xx_get_platform_data();
	if (IS_ERR(wlan_data)) {
		ret = PTR_ERR(wlan_data);
		dev_err(glue->dev, "missing wlan platform data: %d\n", ret);
		goto out_free_glue;
	}

	/* if sdio can keep power while host is suspended, enable wow */
	mmcflags = sdio_get_host_pm_caps(func);
	dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags);

	if (mmcflags & MMC_PM_KEEP_POWER)
		wlan_data->pwr_in_suspend = true;

	wlan_data->ops = &sdio_ops;

	sdio_set_drvdata(func, glue);

	/* Tell PM core that we don't need the card to be powered now */
	pm_runtime_put_noidle(&func->dev);

	/*
	 * Due to a hardware bug, we can't differentiate wl18xx from
	 * wl12xx, because both report the same device ID.  The only
	 * way to differentiate is by checking the SDIO revision,
	 * which is 3.00 on the wl18xx chips.
	 */
	if (func->card->cccr.sdio_vsn == SDIO_SDIO_REV_3_00)
		chip_family = "wl18xx";
	else
		chip_family = "wl12xx";

	glue->core = platform_device_alloc(chip_family, -1);
	if (!glue->core) {
		dev_err(glue->dev, "can't allocate platform_device");
		ret = -ENOMEM;
		goto out_free_glue;
	}

	glue->core->dev.parent = &func->dev;

	memset(res, 0x00, sizeof(res));

	printk(KERN_ERR "IRQ is %d\n", wlan_data->irq);

	res[0].start = wlan_data->irq;
	res[0].flags = IORESOURCE_IRQ;
	res[0].name = "irq";

	ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res));
	if (ret) {
		dev_err(glue->dev, "can't add resources\n");
		goto out_dev_put;
	}

	ret = platform_device_add_data(glue->core, wlan_data,
				       sizeof(*wlan_data));
	if (ret) {
		dev_err(glue->dev, "can't add platform data\n");
		goto out_dev_put;
	}

	ret = platform_device_add(glue->core);
	if (ret) {
		dev_err(glue->dev, "can't add platform device\n");
		goto out_dev_put;
	}
	return 0;

out_dev_put:
	platform_device_put(glue->core);

out_free_glue:
	kfree(glue);

out:
	return ret;
}