Exemplo n.º 1
0
int __init cbus_bus_init(void)
{
	struct cbus_host *chost;
	int ret;

	chost = kmalloc(sizeof (*chost), GFP_KERNEL);
	if (chost == NULL)
		return -ENOMEM;

	memset(chost, 0, sizeof (*chost));

	spin_lock_init(&chost->lock);

	/* REVISIT: Pass these from board-*.c files in platform_data */
	if (machine_is_nokia770()) {
		chost->clk_gpio = OMAP_MPUIO(11);
		chost->dat_gpio = OMAP_MPUIO(10);
		chost->sel_gpio = OMAP_MPUIO(9);
	} else if (machine_is_nokia_n800() || machine_is_nokia_n810() ||
			machine_is_nokia_n810_wimax()) {
		chost->clk_gpio = 66;
		chost->dat_gpio = 65;
		chost->sel_gpio = 64;
	} else {
		printk(KERN_ERR "cbus: Unsupported board\n");
		ret = -ENODEV;
		goto exit1;
	}

#ifdef CONFIG_ARCH_OMAP1
	if (!OMAP_GPIO_IS_MPUIO(chost->clk_gpio) ||
	    !OMAP_GPIO_IS_MPUIO(chost->dat_gpio) ||
	    !OMAP_GPIO_IS_MPUIO(chost->sel_gpio)) {
		printk(KERN_ERR "cbus: Only MPUIO pins supported\n");
		ret = -ENODEV;
		goto exit1;
	}
#endif

	if ((ret = gpio_request(chost->clk_gpio, "CBUS clk")) < 0)
		goto exit1;

	if ((ret = gpio_request(chost->dat_gpio, "CBUS data")) < 0)
		goto exit2;

	if ((ret = gpio_request(chost->sel_gpio, "CBUS sel")) < 0)
		goto exit3;

	gpio_direction_output(chost->clk_gpio, 0);
	gpio_direction_input(chost->dat_gpio);
	gpio_direction_output(chost->sel_gpio, 1);

	gpio_set_value(chost->clk_gpio, 1);
	gpio_set_value(chost->clk_gpio, 0);

	cbus_host = chost;

	return 0;
exit3:
	gpio_free(chost->dat_gpio);
exit2:
	gpio_free(chost->clk_gpio);
exit1:
	kfree(chost);
	return ret;
}
Exemplo n.º 2
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, &n810_snd_devdata);
	n810_snd_devdata.dev = &n810_snd_device->dev;
	*(unsigned int *)n810_dai.cpu_dai->private_data = 1; /* McBSP2 */
	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 (gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0)
		BUG();
	if (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0)
		BUG();
	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;
}
Exemplo n.º 3
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;

	i2c_register_board_info(1, i2c_device, ARRAY_SIZE(i2c_device));

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

	platform_set_drvdata(n810_snd_device, &n810_snd_devdata);
	n810_snd_devdata.dev = &n810_snd_device->dev;
	*(unsigned int *)n810_dai.cpu_dai->private_data = 1; 
	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;
	}
	
	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);

	BUG_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) ||
	       (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0));

	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;
}