Esempio n. 1
0
static void davinci_source_power(struct musb *musb, int is_on, int immediate)
{
#if defined(CONFIG_MACH_DAVINCI_EVM) || defined(CONFIG_MACH_DAVINCI_DM6467_EVM)
	if (is_on)
		is_on = 1;

	if (vbus_state == is_on)
		return;
	vbus_state = !is_on;		/* 0/1 vs "-1 == unknown/init" */

	if (machine_is_davinci_evm() || machine_is_davinci_dm6467_evm()) {
		static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);

		if (immediate) {
			if (machine_is_davinci_evm())
				gpio_set_value_cansleep(GPIO_nVBUS_DRV,
							vbus_state);
			if (machine_is_davinci_dm6467_evm())
				usb_vbus_control(vbus_state);
		} else
			schedule_work(&evm_vbus_work);
	}
	if (immediate)
		vbus_state = is_on;
#endif
	if (cpu_is_davinci_dm365())
		gpio_set_value(33, is_on);
}
Esempio n. 2
0
static void davinci_source_power(struct musb *musb, int is_on, int immediate)
{
	if (is_on)
		is_on = 1;

	if (vbus_state == is_on)
		return;
	vbus_state = !is_on;		/* 0/1 vs "-1 == unknown/init" */

#ifdef CONFIG_MACH_DAVINCI_EVM
	if (machine_is_davinci_evm()) {
#ifdef CONFIG_MACH_DAVINCI_EVM_OTG
		/* modified EVM board switching VBUS with GPIO(6) not I2C
		 * NOTE:  PINMUX0.RGB888 (bit23) must be clear
		 */
		if (is_on)
			gpio_set(GPIO(6));
		else
			gpio_clear(GPIO(6));
		immediate = 1;
#else
		if (immediate)
			davinci_i2c_expander_op(0x3a, USB_DRVVBUS, !is_on);
		else
			schedule_work(&evm_vbus_work);
#endif
	}
#endif
	if (immediate)
		vbus_state = is_on;
}
Esempio n. 3
0
static int evm_rtc_init(void)
{
	if (!machine_is_davinci_evm() && !machine_is_davinci_dm357_evm())
		return -ENODEV;

	return platform_driver_register(&evm_rtc_driver);
}
Esempio n. 4
0
/* VBUS SWITCHING IS BOARD-SPECIFIC */
static void davinci_vbus_power(struct musb *musb, int is_on)
{
	if (is_on)
		is_on = 1;

	DBG(1, "vbus_state=>%d\n", is_on);

	if (is_on) {
		MUSB_HST_MODE(musb);
	} else {
		MUSB_DEV_MODE(musb);
	}
#if defined (CONFIG_MACH_DAVINCI_EVM) || (CONFIG_MACH_DAVINCI_HD_EVM)
	if (machine_is_davinci_evm()) {
#ifdef CONFIG_USB_MUSB_OTG

		/* modified EVM board switching VBUS with GPIO(6) not I2C
		 * NOTE:  PINMUX0.RGB888 (bit23) must be clear
		 */
		if (!is_on) {
			REG_DVEVM_GPIO45_SET |= DAVINCI_VBUS_OFF;
		} else {
			REG_DVEVM_GPIO45_CLR |= DAVINCI_VBUS_ON;
		}
#else
		vbus_state = is_on;
		DBG(2, "VBUS power %s\n", is_on ? "on" : "off");
		schedule_work(&evm_vbus_work);
#endif
	}
#endif
}
Esempio n. 5
0
static int __init evm_leds_init(void)
{
	if (!machine_is_davinci_evm())
		return 0;

	leds_event = evm_leds_event;
	leds_event(led_start);
	return 0;
}
Esempio n. 6
0
/* I2C operations are always synchronous, and require a task context.
 * With unloaded systems, using the shared workqueue seems to suffice
 * to satisfy the 100msec A_WAIT_VRISE timeout...
 */
static void evm_deferred_drvvbus(struct work_struct *ignored)
{
	if (machine_is_davinci_evm())
		gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);

	if (machine_is_davinci_dm6467_evm())
		usb_vbus_control(vbus_state);

	vbus_state = !vbus_state;
}
Esempio n. 7
0
static int evm_hw_params(struct snd_pcm_substream *substream,
			 struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai = rtd->codec_dai;
	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
	int ret = 0;
	unsigned sysclk;

	/* ASP1 on DM355 EVM is clocked by an external oscillator */
	if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
	    machine_is_davinci_dm365_evm())
		sysclk = 27000000;

	/* ASP0 in DM6446 EVM is clocked by U55, as configured by
	 * board-dm644x-evm.c using GPIOs from U18.  There are six
	 * options; here we "know" we use a 48 KHz sample rate.
	 */
	else if (machine_is_davinci_evm())
		sysclk = 12288000;

	else if (machine_is_davinci_da830_evm() ||
				machine_is_davinci_da850_evm())
		sysclk = 24576000;
	/* On AM335X, CODEC gets MCLK from external Xtal (12MHz). */
	else if (machine_is_am335xevm())
		sysclk = 12000000;

	else
		return -EINVAL;

	/* set codec DAI configuration */
	ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
	if (ret < 0)
		return ret;

	/* set cpu DAI configuration */
	ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
	if (ret < 0)
		return ret;

	/* set the codec system clock */
	ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
	if (ret < 0)
		return ret;

	return 0;
}
Esempio n. 8
0
static int __init evm_init(void)
{
	struct snd_soc_card *evm_snd_dev_data;
	int index;
	int ret;

	/*
	 * If dtb is there, the devices will be created dynamically.
	 * Only register platfrom driver structure.
	 */
#if defined(CONFIG_OF)
	if (of_have_populated_dt())
		return platform_driver_register(&davinci_evm_driver);
#endif

	if (machine_is_davinci_evm()) {
		evm_snd_dev_data = &dm6446_snd_soc_card_evm;
		index = 0;
	} else if (machine_is_davinci_dm355_evm()) {
		evm_snd_dev_data = &dm355_snd_soc_card_evm;
		index = 1;
	} else if (machine_is_davinci_dm365_evm()) {
		evm_snd_dev_data = &dm365_snd_soc_card_evm;
		index = 0;
	} else if (machine_is_davinci_dm6467_evm()) {
		evm_snd_dev_data = &dm6467_snd_soc_card_evm;
		index = 0;
	} else if (machine_is_davinci_da830_evm()) {
		evm_snd_dev_data = &da830_snd_soc_card;
		index = 1;
	} else if (machine_is_davinci_da850_evm()) {
		evm_snd_dev_data = &da850_snd_soc_card;
		index = 0;
	} else
		return -EINVAL;

	evm_snd_device = platform_device_alloc("soc-audio", index);
	if (!evm_snd_device)
		return -ENOMEM;

	platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
	ret = platform_device_add(evm_snd_device);
	if (ret)
		platform_device_put(evm_snd_device);

	return ret;
}
Esempio n. 9
0
static int __init evm_init(void)
{
	struct snd_soc_card *evm_snd_dev_data;
	int index;
	int ret;

	if (machine_is_davinci_evm()) {
		evm_snd_dev_data = &dm6446_snd_soc_card_evm;
		index = 0;
	} else if (machine_is_davinci_dm355_evm()) {
		evm_snd_dev_data = &dm355_snd_soc_card_evm;
		index = 1;
	} else if (machine_is_davinci_dm365_evm()) {
		evm_snd_dev_data = &dm365_snd_soc_card_evm;
		index = 0;
	} else if (machine_is_davinci_dm6467_evm()) {
		evm_snd_dev_data = &dm6467_snd_soc_card_evm;
		index = 0;
	} else if (machine_is_davinci_da830_evm()) {
		evm_snd_dev_data = &da830_snd_soc_card;
		index = 1;
	} else if (machine_is_davinci_da850_evm()) {
		evm_snd_dev_data = &da850_snd_soc_card;
		index = 0;
	} else if (machine_is_am335xevm()) {
		evm_snd_dev_data = &am335x_snd_soc_card;
		index = 0;
	} else
		return -EINVAL;

	evm_snd_device = platform_device_alloc("soc-audio", index);
	if (!evm_snd_device) {
		return -ENOMEM;
	}

	platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
	ret = platform_device_add(evm_snd_device);
	if (ret)
		platform_device_put(evm_snd_device);

	return ret;
}
Esempio n. 10
0
static void davinci_source_power(struct musb *musb, int is_on, int immediate)
{
    if (is_on)
        is_on = 1;

    if (vbus_state == is_on)
        return;
    vbus_state = !is_on;		/* 0/1 vs "-1 == unknown/init" */

#ifdef CONFIG_MACH_DAVINCI_EVM
    if (machine_is_davinci_evm()) {
        if (immediate)
            gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
        else
            schedule_work(&evm_vbus_work);
    }
#endif
    if (immediate)
        vbus_state = is_on;
}
Esempio n. 11
0
static int evm_hw_params(struct snd_pcm_substream *substream,
			 struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
	int ret = 0;
	unsigned sysclk;

	
	if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm())
		sysclk = 27000000;

	
	else if (machine_is_davinci_evm())
		sysclk = 12288000;

	else if (machine_is_davinci_da830_evm() ||
				machine_is_davinci_da850_evm())
		sysclk = 24576000;

	else
		return -EINVAL;

	
	ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
	if (ret < 0)
		return ret;

	
	ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
	if (ret < 0)
		return ret;

	
	ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
	if (ret < 0)
		return ret;

	return 0;
}
Esempio n. 12
0
static void davinci_musb_source_power(struct musb *musb, int is_on, int immediate)
{
#ifdef CONFIG_MACH_DAVINCI_EVM
	if (is_on)
		is_on = 1;

	if (vbus_state == is_on)
		return;
	vbus_state = !is_on;		

	if (machine_is_davinci_evm()) {
		static DECLARE_WORK(evm_vbus_work, evm_deferred_drvvbus);

		if (immediate)
			gpio_set_value_cansleep(GPIO_nVBUS_DRV, vbus_state);
		else
			schedule_work(&evm_vbus_work);
	}
	if (immediate)
		vbus_state = is_on;
#endif
}
Esempio n. 13
0
/* VBUS SWITCHING IS BOARD-SPECIFIC */
void davinci_vbus_power(struct musb *musb, int is_on, int sleeping)
{
	if (is_on)
		is_on = 1;

	DBG(1, "vbus_state=>%d\n", is_on);

	if (is_on) {
		MUSB_HST_MODE(musb);
	} else {
		MUSB_DEV_MODE(musb);
	}

#if defined (CONFIG_MACH_DAVINCI_EVM) || (CONFIG_MACH_DAVINCI_HD_EVM)        
	if (machine_is_davinci_evm()) {
#ifdef CONFIG_USB_MUSB_OTG

		/* modified EVM board switching VBUS with GPIO(6) not I2C
		 * NOTE:  PINMUX0.RGB888 (bit23) must be clear
		 */
		if (!is_on) {
			REG_DVEVM_GPIO45_SET |= DAVINCI_VBUS_OFF;
		} else {
			REG_DVEVM_GPIO45_CLR |= DAVINCI_VBUS_ON;
		}
#else
		/* Do not turn off the USB bus.  This results in the IDE HDD
		 * getting reset.
		 */
		vbus_state = is_on;
		DBG(2, "VBUS power %s, %s\n", is_on ? "on" : "off",
		    sleeping ? "immediate" : "deferred");
		schedule_work(&evm_vbus_work);
		return;
#endif
	}
#endif
}
Esempio n. 14
0
static int __init evm_init(void)
{
	struct snd_soc_device *evm_snd_dev_data;
	int index;
	int ret;

	if (machine_is_davinci_evm()) {
		evm_snd_dev_data = &evm_snd_devdata;
		index = 0;
	} else if (machine_is_davinci_dm355_evm()) {
		evm_snd_dev_data = &evm_snd_devdata;
		index = 1;
	} else if (machine_is_davinci_dm6467_evm()) {
		evm_snd_dev_data = &dm6467_evm_snd_devdata;
		index = 0;
	} else if (machine_is_davinci_da830_evm()) {
		evm_snd_dev_data = &da830_evm_snd_devdata;
		index = 1;
	} else if (machine_is_davinci_da850_evm()) {
		evm_snd_dev_data = &da850_evm_snd_devdata;
		index = 0;
	} else
		return -EINVAL;

	evm_snd_device = platform_device_alloc("soc-audio", index);
	if (!evm_snd_device)
		return -ENOMEM;

	platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
	evm_snd_dev_data->dev = &evm_snd_device->dev;
	ret = platform_device_add(evm_snd_device);
	if (ret)
		platform_device_put(evm_snd_device);

	return ret;
}
Esempio n. 15
0
static int __init i2c_davinci_init(void)
{
	int status;
	struct device 	*dev = NULL;

	DEB0("%s %s", __TIME__, __DATE__);

	DEB1("i2c_davinci_init()");

	if (cpu_is_davinci_dm6467())
		davinci_i2c_expander_op (0x3A, I2C_INT_DM646X, 0);

        /* 
	 * NOTE: On DaVinci EVM, the i2c bus frequency is set to 20kHz
	 *       so that the MSP430, which is doing software i2c, has
	 *       some extra processing time
	 */
	if (machine_is_davinci_evm())
		i2c_davinci_busFreq = 20;
	else if (machine_is_davinci_dm6467_evm())
		i2c_davinci_busFreq = 100;
	else if (i2c_davinci_busFreq > 200)
		i2c_davinci_busFreq = 400;	/*Fast mode */
	else
		i2c_davinci_busFreq = 100;	/*Standard mode */

	i2c_clock = clk_get (dev, "I2CCLK");

	if (IS_ERR(i2c_clock))
        	return -1;

	clk_use (i2c_clock);
	clk_enable (i2c_clock);
	i2c_davinci_inputClock = clk_get_rate (i2c_clock);

	DEB1 ("IP CLOCK = %ld", i2c_davinci_inputClock);

	memset(&i2c_davinci_dev, 0, sizeof(i2c_davinci_dev));
	init_waitqueue_head(&i2c_davinci_dev.cmd_wait);

	i2c_davinci_dev.regs = (davinci_i2cregsovly)I2C_BASE;

	status = (int)request_region(I2C_BASE, I2C_IOSIZE, MODULE_NAME);
	if (!status) {
		i2c_err("I2C is already in use\n");
		return -ENODEV;
	}

	status = request_irq(IRQ_I2C, i2c_davinci_isr, 0, "i2c",
			     &i2c_davinci_dev);
	if (status) {
		i2c_err("failed to request I2C IRQ");
		goto do_release_region;
	}

	i2c_set_adapdata(&i2c_davinci_adap, &i2c_davinci_dev);
	status = i2c_add_adapter(&i2c_davinci_adap);
	if (status) {
		i2c_err("failed to add adapter");
		goto do_free_irq;
	}

	i2c_davinci_reset(&i2c_davinci_dev);

	if (driver_register(&davinci_i2c_driver) != 0)
		printk(KERN_ERR "Driver register failed for davinci_i2c\n");
	if (platform_device_register(&davinci_i2c_device) != 0) {
		printk(KERN_ERR "Device register failed for i2c\n");
		driver_unregister(&davinci_i2c_driver);
	}

	return 0;

      do_free_irq:
	free_irq(IRQ_I2C, &i2c_davinci_dev);
      do_release_region:
	release_region(I2C_BASE, I2C_IOSIZE);

	return status;
}