예제 #1
0
static int __init ezbrd_init(void)
{
	printk(KERN_INFO "%s(): registering device resources\n", __func__);
	i2c_register_board_info(0, bfin_i2c_board_info,
				ARRAY_SIZE(bfin_i2c_board_info));
	platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
	spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
	/* setup BF518-EZBRD GPIO pin PG11 to AMS2, PG15 to AMS3. */
	peripheral_request(P_AMS2, "ParaFlash");
#if !defined(CONFIG_SPI_BFIN5XX) && !defined(CONFIG_SPI_BFIN5XX_MODULE)
	peripheral_request(P_AMS3, "ParaFlash");
#endif
	return 0;
}
예제 #2
0
static void bf5xx_ac97_warm_reset(struct snd_ac97 *ac97)
{
#if defined(CONFIG_BF54x) || defined(CONFIG_BF561) || \
 (defined(BF537_FAMILY) && (CONFIG_SND_BF5XX_SPORT_NUM == 1))

#define CONCAT(a, b, c) a ## b ## c
#define BFIN_SPORT_RFS(x) CONCAT(P_SPORT, x, _RFS)

	u16 per = BFIN_SPORT_RFS(CONFIG_SND_BF5XX_SPORT_NUM);
	u16 gpio = P_IDENT(BFIN_SPORT_RFS(CONFIG_SND_BF5XX_SPORT_NUM));

	pr_debug("%s enter\n", __func__);

	peripheral_free(per);
	gpio_request(gpio, "bf5xx-ac97");
	gpio_direction_output(gpio, 1);
	udelay(2);
	gpio_set_value(gpio, 0);
	udelay(1);
	gpio_free(gpio);
	peripheral_request(per, "soc-audio");
#else
	pr_info("%s: Not implemented\n", __func__);
#endif
}
예제 #3
0
struct pwm_device *pwm_request(int pwm_id, const char *label)
{
	struct pwm_device *pwm;
	int ret;

	/*                                       */
	if (pwm_id < 0)
		return NULL;

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

	pwm->id = pwm_id;
	if (pwm->id >= ARRAY_SIZE(pwm_to_gptimer_per))
		goto err;

	pwm->pin = pwm_to_gptimer_per[pwm->id];
	ret = peripheral_request(pwm->pin, label);
	if (ret)
		goto err;

	return pwm;
 err:
	kfree(pwm);
	return NULL;
}
예제 #4
0
static int __init gptimer_example_init(void)
{
	int ret;

	
	ret = peripheral_request(P_TMR5, DRIVER_NAME);
	if (ret) {
		printk(KERN_NOTICE DRIVER_NAME ": peripheral request failed\n");
		return ret;
	}

	
	ret = request_irq(IRQ_TIMER5, gptimer_example_irq, IRQF_SHARED, DRIVER_NAME, &data);
	if (ret) {
		printk(KERN_NOTICE DRIVER_NAME ": IRQ request failed\n");
		peripheral_free(P_TMR5);
		return ret;
	}

	
	set_gptimer_config(TIMER5_id, WDTH_CAP | PULSE_HI | PERIOD_CNT | IRQ_ENA);
	enable_gptimers(TIMER5bit);

	return 0;
}
예제 #5
0
파일: gpio.c 프로젝트: 0s4l/u-boot-xlnx
int peripheral_request_list(const unsigned short per[], const char *label)
{
	u16 cnt;
	int ret;

	for (cnt = 0; per[cnt] != 0; cnt++) {

		ret = peripheral_request(per[cnt], label);

		if (ret < 0) {
			for ( ; cnt > 0; cnt--)
				peripheral_free(per[cnt - 1]);

			return ret;
		}
	}

	return 0;
}
예제 #6
0
static void init_tlv320aic31(void)
{
	puts("Audio: setup TIMER0 to enable 16.384 MHz clock for tlv320aic31\n");
	peripheral_request(P_TMR0, "tlv320aic31 clock");
	bfin_write_TIMER0_CONFIG(0x020d);
	bfin_write_TIMER0_PERIOD(0x0008);
	bfin_write_TIMER0_WIDTH(0x0008/2);
	bfin_write_TIMER_ENABLE(bfin_read_TIMER_ENABLE() | 1);
	SSYNC();
	udelay(10000);

	puts("       resetting tlv320aic31\n");

	gpio_request(GPIO_PF2, "tlv320aic31");
	gpio_direction_output(GPIO_PF2, 0);
	udelay(10000);
	gpio_direction_output(GPIO_PF2, 1);
	udelay(10000);
	gpio_free(GPIO_PF2);
}
예제 #7
0
파일: pwm-bfin.c 프로젝트: AllenDou/linux
static int bfin_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
{
	struct bfin_pwm *priv;
	int ret;

	if (pwm->hwpwm >= ARRAY_SIZE(pwm_to_gptimer_per))
		return -EINVAL;

	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	priv->pin = pwm_to_gptimer_per[pwm->hwpwm];

	ret = peripheral_request(priv->pin, NULL);
	if (ret) {
		kfree(priv);
		return ret;
	}

	pwm_set_chip_data(pwm, priv);

	return 0;
}
static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
{
	struct iio_bfin_timer_trigger_pdata *pdata = pdev->dev.platform_data;
	struct bfin_tmr_state *st;
	unsigned int config;
	int ret;

	st = kzalloc(sizeof(*st), GFP_KERNEL);
	if (st == NULL) {
		ret = -ENOMEM;
		goto out;
	}

	st->irq = platform_get_irq(pdev, 0);
	if (!st->irq) {
		dev_err(&pdev->dev, "No IRQs specified");
		ret = -ENODEV;
		goto out1;
	}

	ret = iio_bfin_tmr_get_number(st->irq);
	if (ret < 0)
		goto out1;

	st->timer_num = ret;
	st->t = &iio_bfin_timer_code[st->timer_num];

	st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
	if (!st->trig) {
		ret = -ENOMEM;
		goto out1;
	}

	st->trig->private_data = st;
	st->trig->ops = &iio_bfin_tmr_trigger_ops;
	st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
	ret = iio_trigger_register(st->trig);
	if (ret)
		goto out2;

	ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
			  0, st->trig->name, st);
	if (ret) {
		dev_err(&pdev->dev,
			"request IRQ-%d failed", st->irq);
		goto out4;
	}

	config = PWM_OUT | PERIOD_CNT | IRQ_ENA;

	if (pdata && pdata->output_enable) {
		unsigned long long val;

		st->output_enable = true;

		ret = peripheral_request(st->t->pin, st->trig->name);
		if (ret)
			goto out_free_irq;

		val = (unsigned long long)get_sclk() * pdata->duty_ns;
		do_div(val, NSEC_PER_SEC);
		st->duty = val;

		/**
		 * The interrupt will be generated at the end of the period,
		 * since we want the interrupt to be generated at end of the
		 * pulse we invert both polarity and duty cycle, so that the
		 * pulse will be generated directly before the interrupt.
		 */
		if (pdata->active_low)
			config |= PULSE_HI;
	} else {
		st->duty = 1;
		config |= OUT_DIS;
	}

	set_gptimer_config(st->t->id, config);

	dev_info(&pdev->dev, "iio trigger Blackfin TMR%d, IRQ-%d",
		 st->timer_num, st->irq);
	platform_set_drvdata(pdev, st);

	return 0;
out_free_irq:
	free_irq(st->irq, st);
out4:
	iio_trigger_unregister(st->trig);
out2:
	iio_trigger_put(st->trig);
out1:
	kfree(st);
out:
	return ret;
}