Exemple #1
0
static int __devinit bfin_tdm_probe(struct platform_device *pdev)
{
	int ret = 0;

	if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) {
		pr_err("Requesting Peripherals failed\n");
		return -EFAULT;
	}

	/* request DMA for SPORT */
	sport_handle = sport_init(&sport_params[sport_num], 4, \
		8 * sizeof(u32), NULL);
	if (!sport_handle) {
		peripheral_free_list(&sport_req[sport_num][0]);
		return -ENODEV;
	}

	/* SPORT works in TDM mode */
	ret = sport_set_multichannel(sport_handle, 8, 0xFF, 1);
	if (ret) {
		pr_err("SPORT is busy!\n");
		ret = -EBUSY;
		goto sport_config_err;
	}

	ret = sport_config_rx(sport_handle, IRFS, 0x1F, 0, 0);
	if (ret) {
		pr_err("SPORT is busy!\n");
		ret = -EBUSY;
		goto sport_config_err;
	}

	ret = sport_config_tx(sport_handle, ITFS, 0x1F, 0, 0);
	if (ret) {
		pr_err("SPORT is busy!\n");
		ret = -EBUSY;
		goto sport_config_err;
	}

	ret = snd_soc_register_dai(&bf5xx_tdm_dai);
	if (ret) {
		pr_err("Failed to register DAI: %d\n", ret);
		goto sport_config_err;
	}

	sport_handle->private_data = &bf5xx_tdm;
	return 0;

sport_config_err:
	peripheral_free_list(&sport_req[sport_num][0]);
	return ret;
}
Exemple #2
0
static void free_ports(void)
{
	u16 tmr_req[] = TIMERS;

	peripheral_free_list(ppi_pins);
	peripheral_free_list(tmr_req);

#if defined(UD) && defined(LBR)
	gpio_free(LBR);
	gpio_free(UD);
#endif
	gpio_free(MOD);
}
Exemple #3
0
static int __devexit bfin_tdm_remove(struct platform_device *pdev)
{
	peripheral_free_list(&sport_req[sport_num][0]);
	snd_soc_unregister_dai(&bf5xx_tdm_dai);

	return 0;
}
Exemple #4
0
static void sport_free_resource(struct sport_device *sport)
{
	free_irq(sport->rx_err_irq, sport);
	free_irq(sport->tx_err_irq, sport);
	free_dma(sport->rx_dma_chan);
	free_dma(sport->tx_dma_chan);
	peripheral_free_list(sport->pin_req);
}
Exemple #5
0
static int bfin_kpad_remove(struct platform_device *pdev)
{
	struct bfin_kpad_platform_data *pdata = dev_get_platdata(&pdev->dev);
	struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);

	del_timer_sync(&bf54x_kpad->timer);
	free_irq(bf54x_kpad->irq, pdev);

	input_unregister_device(bf54x_kpad->input);

	peripheral_free_list((u16 *)&per_rows[MAX_RC - pdata->rows]);
	peripheral_free_list((u16 *)&per_cols[MAX_RC - pdata->cols]);

	kfree(bf54x_kpad->keycode);
	kfree(bf54x_kpad);

	return 0;
}
static int __devexit bfin_mii_bus_remove(struct platform_device *pdev)
{
	struct mii_bus *miibus = platform_get_drvdata(pdev);
	platform_set_drvdata(pdev, NULL);
	mdiobus_unregister(miibus);
	mdiobus_free(miibus);
	peripheral_free_list(pin_req);
	return 0;
}
static void bf5xx_ac97_remove(struct platform_device *pdev,
			      struct snd_soc_dai *dai)
{
	free_page((unsigned long)cmd_count);
	cmd_count = NULL;
	peripheral_free_list(sport_req[sport_num]);
#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
	gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
#endif
}
Exemple #8
0
static int request_ports(void)
{

	u16 ppi_req[] = PPI0_16;
	u16 tmr_req[] = TIMERS;

	/*
		UD:      PF13
		MOD:     PF10
		LBR:     PF14
		PPI_CLK: PF15
	*/

	if (peripheral_request_list(ppi_req, DRIVER_NAME)) {
		printk(KERN_ERR "Requesting Peripherals PPI faild\n");
		return -EFAULT;
	}

	if (peripheral_request_list(tmr_req, DRIVER_NAME)) {
		peripheral_free_list(ppi_req);
		printk(KERN_ERR "Requesting Peripherals TMR faild\n");
		return -EFAULT;
	}

#if (defined(UD) &&  defined(LBR))
	if (gpio_request(UD, DRIVER_NAME)) {
		printk(KERN_ERR"Requesting GPIO %d faild\n",UD);
		return -EFAULT;
	}

	if (gpio_request(LBR, DRIVER_NAME)) {
		printk(KERN_ERR"Requesting GPIO %d faild\n",LBR);
		gpio_free(UD);
		return -EFAULT;
	}

	gpio_direction_output(UD, 0);
	gpio_direction_output(LBR, 1);

#endif

	if (gpio_request(MOD, DRIVER_NAME)) {
		printk(KERN_ERR"Requesting GPIO %d faild\n",MOD);
#if (defined(UD) &&  defined(LBR))
		gpio_free(LBR);
		gpio_free(UD);
#endif
		return -EFAULT;
	}

	gpio_direction_output(MOD, 1);

	SSYNC();
	return 0;
}
Exemple #9
0
/*
 * FUNCTION NAME: ppifcd_uninit / cleanup_module
 *
 * INPUTS/OUTPUTS:
 *
 * RETURN:
 *
 * FUNCTION(S) CALLED:
 *
 * GLOBAL VARIABLES REFERENCED: ppiinfo
 *
 * GLOBAL VARIABLES MODIFIED: NIL
 *
 * DESCRIPTION: It will be invoked when using 'rmmod' command.
 *              or, you invoke it directly when it needs remove
 *              ppi module.
 *
 * CAUTION:
 */
void __exit ppifcd_uninit(void)
{

	if (ppiinfo.ppi_trigger_gpio != NO_TRIGGER)
		gpio_free(ppiinfo.ppi_trigger_gpio);

	peripheral_free_list(ppifcd_ppi_req);

	misc_deregister(&bfin_ppi_dev);
	printk(KERN_ALERT "Goodbye PPI\n");
}
Exemple #10
0
static int __devinit request_ports(void)
{
	u16 tmr_req[] = TIMERS;

	/*
		UD:      PF13
		MOD:     PF10
		LBR:     PF14
		PPI_CLK: PF15
	*/

	if (peripheral_request_list(ppi_pins, KBUILD_MODNAME)) {
		pr_err("requesting PPI peripheral failed\n");
		return -EBUSY;
	}

	if (peripheral_request_list(tmr_req, KBUILD_MODNAME)) {
		peripheral_free_list(ppi_pins);
		pr_err("requesting timer peripheral failed\n");
		return -EBUSY;
	}

#if (defined(UD) && defined(LBR))
	if (gpio_request(UD, KBUILD_MODNAME)) {
		pr_err("requesting GPIO %d failed\n", UD);
		return -EBUSY;
	}

	if (gpio_request(LBR, KBUILD_MODNAME)) {
		pr_err("requesting GPIO %d failed\n", LBR);
		gpio_free(UD);
		return -EBUSY;
	}

	gpio_direction_output(UD, 0);
	gpio_direction_output(LBR, 1);

#endif

	if (gpio_request(MOD, KBUILD_MODNAME)) {
		pr_err("requesting GPIO %d failed\n", MOD);
#if (defined(UD) && defined(LBR))
		gpio_free(LBR);
		gpio_free(UD);
#endif
		return -EBUSY;
	}

	gpio_direction_output(MOD, 1);

	SSYNC();
	return 0;
}
Exemple #11
0
void bf609_nor_flash_exit(struct platform_device *dev)
{
	const unsigned short pins[] = {
		P_A3, P_A4, P_A5, P_A6, P_A7, P_A8, P_A9, P_A10, P_A11, P_A12,
		P_A13, P_A14, P_A15, P_A16, P_A17, P_A18, P_A19, P_A20, P_A21,
		P_A22, P_A23, P_A24, P_A25, P_NORCK, 0,
	};

	peripheral_free_list(pins);

	bfin_write32(SMC_GCTL, 0);
}
Exemple #12
0
void spi_release_bus(struct spi_slave *slave)
{
	struct bfin_spi_slave *bss = to_bfin_spi_slave(slave);

	debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs);

	peripheral_free_list(pins[slave->bus]);
	if (is_gpio_cs(slave->cs))
		gpio_free(gpio_cs(slave->cs));

	write_SPI_CTL(bss, 0);
	SSYNC();
}
static int bf5xx_tdm_suspend(struct snd_soc_dai *dai)
{
	struct sport_device *sport = snd_soc_dai_get_drvdata(dai);

	if (dai->playback_active)
		sport_tx_stop(sport);
	if (dai->capture_active)
		sport_rx_stop(sport);

	/* isolate sync/clock pins from codec while sports resume */
	peripheral_free_list(sport->pin_req);

	return 0;
}
Exemple #14
0
static int sport_request_resource(struct sport_device *sport)
{
	struct device *dev = &sport->pdev->dev;
	int ret;

	ret = peripheral_request_list(sport->pin_req, "soc-audio");
	if (ret) {
		dev_err(dev, "Unable to request sport pin\n");
		return ret;
	}

	ret = request_dma(sport->tx_dma_chan, "SPORT TX Data");
	if (ret) {
		dev_err(dev, "Unable to allocate DMA channel for sport tx\n");
		goto err_tx_dma;
	}
	set_dma_callback(sport->tx_dma_chan, sport_tx_irq, sport);

	ret = request_dma(sport->rx_dma_chan, "SPORT RX Data");
	if (ret) {
		dev_err(dev, "Unable to allocate DMA channel for sport rx\n");
		goto err_rx_dma;
	}
	set_dma_callback(sport->rx_dma_chan, sport_rx_irq, sport);

	ret = request_irq(sport->tx_err_irq, sport_err_irq,
			0, "SPORT TX ERROR", sport);
	if (ret) {
		dev_err(dev, "Unable to allocate tx error IRQ for sport\n");
		goto err_tx_irq;
	}

	ret = request_irq(sport->rx_err_irq, sport_err_irq,
			0, "SPORT RX ERROR", sport);
	if (ret) {
		dev_err(dev, "Unable to allocate rx error IRQ for sport\n");
		goto err_rx_irq;
	}

	return 0;
err_rx_irq:
	free_irq(sport->tx_err_irq, sport);
err_tx_irq:
	free_dma(sport->rx_dma_chan);
err_rx_dma:
	free_dma(sport->tx_dma_chan);
err_tx_dma:
	peripheral_free_list(sport->pin_req);
	return ret;
}
Exemple #15
0
static int bf5xx_probe(struct platform_device *pdev)
{

	u16 sport_req[][7] = {PIN_REQ_SPORT_0, PIN_REQ_SPORT_1};

	if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) {
		printk(KERN_ERR "Requesting Peripherals faild\n");
		return -EFAULT;
		}

#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
	/* Request PB3 as reset pin */
	if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) {
		printk(KERN_ERR "Failed to request GPIO_%d for reset\n",
				CONFIG_SND_BF5XX_RESET_GPIO_NUM);
		peripheral_free_list(&sport_req[sport_num][0]);
		return -1;
	}
	gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
	gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1);
#endif
	sport_handle = sport_init(&sport_params[sport_num], 2, \
			10 * sizeof(struct ac97_frame), NULL);
	if (!sport_handle) {
		peripheral_free_list(&sport_req[sport_num][0]);
#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
		gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
#endif
		return -ENODEV;
	}

	sport_set_multichannel(sport_handle, 16, 0x1F, 1);
	sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1));
	sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1));

	return 0;
}
Exemple #16
0
static int request_ports(int action)
{
	u16 ppi_req[] = PPI0_16;
	u16 tmr_req[] = TIMERS;

	if (action) {
		if (peripheral_request_list(ppi_req, DRIVER_NAME)) {
			printk(KERN_ERR DRIVER_NAME
			       ": Requesting Peripherals PPI faild\n");
			return -EFAULT;
		}

		if (peripheral_request_list(tmr_req, DRIVER_NAME)) {
			peripheral_free_list(ppi_req);
			printk(KERN_ERR DRIVER_NAME
			       ": Requesting Peripherals TMR faild\n");
			return -EFAULT;
		}

		if (gpio_request(PCI_PIN, DRIVER_NAME)) {
			peripheral_free_list(ppi_req);
			peripheral_free_list(tmr_req);
			printk(KERN_ERR ": Requesting GPIO %d faild\n", PCI_PIN);
			return -EFAULT;
		}

		gpio_direction_output(PCI_PIN, 0);
		SSYNC();
	} else {
		peripheral_free_list(ppi_req);
		peripheral_free_list(tmr_req);

		gpio_free(PCI_PIN);
	}
	return 0;
}
void spi_release_bus(struct spi_slave *slave)
{
	struct bfin_spi_slave *bss = to_bfin_spi_slave(slave);

	debug("%s: bus:%i cs:%i\n", __func__, slave->bus, slave->cs);

	peripheral_free_list(pins[slave->bus]);
	if (is_gpio_cs(slave->cs))
		gpio_free(gpio_cs(slave->cs));

	bfin_write32(&bss->regs->rx_control, 0x0);
	bfin_write32(&bss->regs->tx_control, 0x0);
	bfin_write32(&bss->regs->control, 0x0);
	SSYNC();
}
Exemple #18
0
static int __devinit bfin_mii_bus_probe(struct platform_device *pdev)
{
	struct mii_bus *miibus;
	int rc, i;

	/*
	 * We are setting up a network card,
	 * so set the GPIO pins to Ethernet mode
	 */
	rc = peripheral_request_list(pin_req, DRV_NAME);
	if (rc) {
		dev_err(&pdev->dev, "Requesting peripherals failed!\n");
		return rc;
	}

	rc = -ENOMEM;
	miibus = mdiobus_alloc();
	if (miibus == NULL)
		goto out_err_alloc;
	miibus->read = bfin_mdiobus_read;
	miibus->write = bfin_mdiobus_write;
	miibus->reset = bfin_mdiobus_reset;

	miibus->parent = &pdev->dev;
	miibus->name = "bfin_mii_bus";
	snprintf(miibus->id, MII_BUS_ID_SIZE, "0");
	miibus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
	if (miibus->irq == NULL)
		goto out_err_alloc;
	for (i = 0; i < PHY_MAX_ADDR; ++i)
		miibus->irq[i] = PHY_POLL;

	rc = mdiobus_register(miibus);
	if (rc) {
		dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
		goto out_err_mdiobus_register;
	}

	platform_set_drvdata(pdev, miibus);
	return 0;

out_err_mdiobus_register:
	mdiobus_free(miibus);
out_err_alloc:
	peripheral_free_list(pin_req);

	return rc;
}
static void bf5xx_ac97_warm_reset(struct snd_ac97 *ac97)
{
	struct sport_device *sport_handle = ac97_sport_handle;
	u16 gpio = P_IDENT(sport_handle->pin_req[3]);

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

	peripheral_free_list(sport_handle->pin_req);
	gpio_request(gpio, "bf5xx-ac97");
	gpio_direction_output(gpio, 1);
	udelay(2);
	gpio_set_value(gpio, 0);
	udelay(1);
	gpio_free(gpio);
	peripheral_request_list(sport_handle->pin_req, "soc-audio");
}
static int __devexit bfin_rotary_remove(struct platform_device *pdev)
{
	struct bfin_rot *rotary = platform_get_drvdata(pdev);

	bfin_write_CNT_CONFIG(0);
	bfin_write_CNT_IMASK(0);

	free_irq(rotary->irq, pdev);
	input_unregister_device(rotary->input);
	peripheral_free_list(per_cnt);

	kfree(rotary);
	platform_set_drvdata(pdev, NULL);

	return 0;
}
Exemple #21
0
static int request_ports(void)
{
	u16 tmr_req[] = TIMERS;

	/*
		UD:      PF13
		MOD:     PF10
		LBR:     PF14
		PPI_CLK: PF15
	*/

	if (peripheral_request_list(ppi_pins, KBUILD_MODNAME)) {
		pr_err("requesting PPI peripheral failed\n");
		return -EBUSY;
	}

	if (peripheral_request_list(tmr_req, KBUILD_MODNAME)) {
		peripheral_free_list(ppi_pins);
		pr_err("requesting timer peripheral failed\n");
		return -EBUSY;
	}

#if (defined(UD) && defined(LBR))
	if (gpio_request_one(UD, GPIOF_OUT_INIT_LOW, KBUILD_MODNAME)) {
		pr_err("requesting GPIO %d failed\n", UD);
		return -EBUSY;
	}

	if (gpio_request_one(LBR, GPIOF_OUT_INIT_HIGH, KBUILD_MODNAME)) {
		pr_err("requesting GPIO %d failed\n", LBR);
		gpio_free(UD);
		return -EBUSY;
	}
#endif

	if (gpio_request_one(MOD, GPIOF_OUT_INIT_HIGH, KBUILD_MODNAME)) {
		pr_err("requesting GPIO %d failed\n", MOD);
#if (defined(UD) && defined(LBR))
		gpio_free(LBR);
		gpio_free(UD);
#endif
		return -EBUSY;
	}

	SSYNC();
	return 0;
}
Exemple #22
0
/*
 * Memory can't be allocated dynamically during earlyprink init stage.
 * So, do individual probe for earlyprink with a static uart port variable.
 */
static int bfin_earlyprintk_probe(struct platform_device *pdev)
{
	struct resource *res;
	int ret;

	if (pdev->id < 0 || pdev->id >= BFIN_UART_NR_PORTS) {
		dev_err(&pdev->dev, "Wrong earlyprintk platform device id.\n");
		return -ENOENT;
	}

	ret = peripheral_request_list(
		(unsigned short *)pdev->dev.platform_data, DRIVER_NAME);
	if (ret) {
		dev_err(&pdev->dev,
				"fail to request bfin serial peripherals\n");
			return ret;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
		ret = -ENOENT;
		goto out_error_free_peripherals;
	}

	bfin_earlyprintk_port.port.membase = ioremap(res->start,
			res->end - res->start);
	if (!bfin_earlyprintk_port.port.membase) {
		dev_err(&pdev->dev, "Cannot map uart IO\n");
		ret = -ENXIO;
		goto out_error_free_peripherals;
	}
	bfin_earlyprintk_port.port.mapbase = res->start;
	bfin_earlyprintk_port.port.line = pdev->id;
	bfin_earlyprintk_port.port.uartclk = get_sclk();
	bfin_earlyprintk_port.port.fifosize  = BFIN_UART_TX_FIFO_SIZE;
	spin_lock_init(&bfin_earlyprintk_port.port.lock);

	return 0;

out_error_free_peripherals:
	peripheral_free_list(
		(unsigned short *)pdev->dev.platform_data);

	return ret;
}
Exemple #23
0
static int __devexit bfin_mac_remove(struct platform_device *pdev)
{
	struct net_device *ndev = platform_get_drvdata(pdev);
	struct bfin_mac_local *lp = netdev_priv(ndev);

	platform_set_drvdata(pdev, NULL);

	lp->mii_bus->priv = NULL;

	unregister_netdev(ndev);

	free_irq(IRQ_MAC_RX, ndev);

	free_netdev(ndev);

	peripheral_free_list(pin_req);

	return 0;
}
Exemple #24
0
static int __devexit bfin_serial_remove(struct platform_device *pdev)
{
	struct bfin_serial_port *uart = platform_get_drvdata(pdev);

	dev_set_drvdata(&pdev->dev, NULL);

	if (uart) {
		uart_remove_one_port(&bfin_serial_reg, &uart->port);
#ifdef CONFIG_SERIAL_BFIN_CTSRTS
		if (uart->rts_pin >= 0)
			gpio_free(uart->rts_pin);
#endif
		iounmap(uart->port.membase);
		peripheral_free_list(
			(unsigned short *)pdev->dev.platform_data);
		kfree(uart);
		bfin_serial_ports[pdev->id] = NULL;
	}

	return 0;
}
Exemple #25
0
static int __devinit bfin_mac_probe(struct platform_device *pdev)
{
	struct net_device *ndev;
	struct bfin_mac_local *lp;
	struct platform_device *pd;
	int rc;

	ndev = alloc_etherdev(sizeof(struct bfin_mac_local));
	if (!ndev) {
		dev_err(&pdev->dev, "Cannot allocate net device!\n");
		return -ENOMEM;
	}

	SET_NETDEV_DEV(ndev, &pdev->dev);
	platform_set_drvdata(pdev, ndev);
	lp = netdev_priv(ndev);

	
	*(__le32 *) (&(ndev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO());
	*(__le16 *) (&(ndev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI());

	
	
	bfin_write_EMAC_ADDRLO(0x12345678);
	if (bfin_read_EMAC_ADDRLO() != 0x12345678) {
		dev_err(&pdev->dev, "Cannot detect Blackfin on-chip ethernet MAC controller!\n");
		rc = -ENODEV;
		goto out_err_probe_mac;
	}


	
	if (!is_valid_ether_addr(ndev->dev_addr))
		bfin_get_ether_addr(ndev->dev_addr);

	
	if (!is_valid_ether_addr(ndev->dev_addr))
		random_ether_addr(ndev->dev_addr);

	setup_mac_addr(ndev->dev_addr);

	if (!pdev->dev.platform_data) {
		dev_err(&pdev->dev, "Cannot get platform device bfin_mii_bus!\n");
		rc = -ENODEV;
		goto out_err_probe_mac;
	}
	pd = pdev->dev.platform_data;
	lp->mii_bus = platform_get_drvdata(pd);
	lp->mii_bus->priv = ndev;

	rc = mii_probe(ndev);
	if (rc) {
		dev_err(&pdev->dev, "MII Probe failed!\n");
		goto out_err_mii_probe;
	}

	
	ether_setup(ndev);

	ndev->netdev_ops = &bfin_mac_netdev_ops;
	ndev->ethtool_ops = &bfin_mac_ethtool_ops;

	spin_lock_init(&lp->lock);

	
	
	rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt,
			IRQF_DISABLED, "EMAC_RX", ndev);
	if (rc) {
		dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n");
		rc = -EBUSY;
		goto out_err_request_irq;
	}

	rc = register_netdev(ndev);
	if (rc) {
		dev_err(&pdev->dev, "Cannot register net device!\n");
		goto out_err_reg_ndev;
	}

	
	dev_info(&pdev->dev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);

	return 0;

out_err_reg_ndev:
	free_irq(IRQ_MAC_RX, ndev);
out_err_request_irq:
out_err_mii_probe:
	mdiobus_unregister(lp->mii_bus);
	mdiobus_free(lp->mii_bus);
	peripheral_free_list(pin_req);
out_err_probe_mac:
	platform_set_drvdata(pdev, NULL);
	free_netdev(ndev);

	return rc;
}
Exemple #26
0
static int __devinit bfin_mac_probe(struct platform_device *pdev)
{
	struct net_device *ndev;
	struct bfin_mac_local *lp;
	struct platform_device *pd;
	int rc;

	ndev = alloc_etherdev(sizeof(struct bfin_mac_local));
	if (!ndev) {
		dev_err(&pdev->dev, "Cannot allocate net device!\n");
		return -ENOMEM;
	}

	SET_NETDEV_DEV(ndev, &pdev->dev);
	platform_set_drvdata(pdev, ndev);
	lp = netdev_priv(ndev);

	/* Grab the MAC address in the MAC */
	*(__le32 *) (&(ndev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO());
	*(__le16 *) (&(ndev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI());

	/* probe mac */
	/*todo: how to proble? which is revision_register */
	bfin_write_EMAC_ADDRLO(0x12345678);
	if (bfin_read_EMAC_ADDRLO() != 0x12345678) {
		dev_err(&pdev->dev, "Cannot detect Blackfin on-chip ethernet MAC controller!\n");
		rc = -ENODEV;
		goto out_err_probe_mac;
	}


	/*
	 * Is it valid? (Did bootloader initialize it?)
	 * Grab the MAC from the board somehow
	 * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c
	 */
	if (!is_valid_ether_addr(ndev->dev_addr))
		bfin_get_ether_addr(ndev->dev_addr);

	/* If still not valid, get a random one */
	if (!is_valid_ether_addr(ndev->dev_addr))
		random_ether_addr(ndev->dev_addr);

	setup_mac_addr(ndev->dev_addr);

	if (!pdev->dev.platform_data) {
		dev_err(&pdev->dev, "Cannot get platform device bfin_mii_bus!\n");
		rc = -ENODEV;
		goto out_err_probe_mac;
	}
	pd = pdev->dev.platform_data;
	lp->mii_bus = platform_get_drvdata(pd);
	lp->mii_bus->priv = ndev;

	rc = mii_probe(ndev);
	if (rc) {
		dev_err(&pdev->dev, "MII Probe failed!\n");
		goto out_err_mii_probe;
	}

	/* Fill in the fields of the device structure with ethernet values. */
	ether_setup(ndev);

	ndev->netdev_ops = &bfin_mac_netdev_ops;
	ndev->ethtool_ops = &bfin_mac_ethtool_ops;

	spin_lock_init(&lp->lock);

	/* now, enable interrupts */
	/* register irq handler */
	rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt,
			IRQF_DISABLED, "EMAC_RX", ndev);
	if (rc) {
		dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n");
		rc = -EBUSY;
		goto out_err_request_irq;
	}

	rc = register_netdev(ndev);
	if (rc) {
		dev_err(&pdev->dev, "Cannot register net device!\n");
		goto out_err_reg_ndev;
	}

	/* now, print out the card info, in a short format.. */
	dev_info(&pdev->dev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);

	return 0;

out_err_reg_ndev:
	free_irq(IRQ_MAC_RX, ndev);
out_err_request_irq:
out_err_mii_probe:
	mdiobus_unregister(lp->mii_bus);
	mdiobus_free(lp->mii_bus);
	peripheral_free_list(pin_req);
out_err_probe_mac:
	platform_set_drvdata(pdev, NULL);
	free_netdev(ndev);

	return rc;
}
Exemple #27
0
static int __devinit bfin_kpad_probe(struct platform_device *pdev)
{
    struct bf54x_kpad *bf54x_kpad;
    struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data;
    struct input_dev *input;
    int i, error;

    if (!pdata->rows || !pdata->cols || !pdata->keymap) {
        printk(KERN_ERR DRV_NAME
               ": No rows, cols or keymap from pdata\n");
        return -EINVAL;
    }

    if (!pdata->keymapsize ||
            pdata->keymapsize > (pdata->rows * pdata->cols)) {
        printk(KERN_ERR DRV_NAME ": Invalid keymapsize\n");
        return -EINVAL;
    }

    bf54x_kpad = kzalloc(sizeof(struct bf54x_kpad), GFP_KERNEL);
    if (!bf54x_kpad)
        return -ENOMEM;

    platform_set_drvdata(pdev, bf54x_kpad);

    /* Allocate memory for keymap followed by private LUT */
    bf54x_kpad->keycode = kmalloc(pdata->keymapsize *
                                  sizeof(unsigned short) * 2, GFP_KERNEL);
    if (!bf54x_kpad->keycode) {
        error = -ENOMEM;
        goto out;
    }

    if (!pdata->debounce_time || pdata->debounce_time > MAX_MULT ||
            !pdata->coldrive_time || pdata->coldrive_time > MAX_MULT) {
        printk(KERN_WARNING DRV_NAME
               ": Invalid Debounce/Columndrive Time in platform data\n");
        bfin_write_KPAD_MSEL(0xFF0);	/* Default MSEL	*/
    } else {
        bfin_write_KPAD_MSEL(
            ((pdata->debounce_time / TIME_SCALE)
             & DBON_SCALE) |
            (((pdata->coldrive_time / TIME_SCALE) << 8)
             & COLDRV_SCALE));

    }

    if (!pdata->keyup_test_interval)
        bf54x_kpad->keyup_test_jiffies = msecs_to_jiffies(50);
    else
        bf54x_kpad->keyup_test_jiffies =
            msecs_to_jiffies(pdata->keyup_test_interval);

    if (peripheral_request_list((u16 *)&per_rows[MAX_RC - pdata->rows],
                                DRV_NAME)) {
        printk(KERN_ERR DRV_NAME
               ": Requesting Peripherals failed\n");
        error = -EFAULT;
        goto out0;
    }

    if (peripheral_request_list((u16 *)&per_cols[MAX_RC - pdata->cols],
                                DRV_NAME)) {
        printk(KERN_ERR DRV_NAME
               ": Requesting Peripherals failed\n");
        error = -EFAULT;
        goto out1;
    }

    bf54x_kpad->irq = platform_get_irq(pdev, 0);
    if (bf54x_kpad->irq < 0) {
        error = -ENODEV;
        goto out2;
    }

    error = request_irq(bf54x_kpad->irq, bfin_kpad_isr,
                        0, DRV_NAME, pdev);
    if (error) {
        printk(KERN_ERR DRV_NAME
               ": unable to claim irq %d; error %d\n",
               bf54x_kpad->irq, error);
        goto out2;
    }

    input = input_allocate_device();
    if (!input) {
        error = -ENOMEM;
        goto out3;
    }

    bf54x_kpad->input = input;

    input->name = pdev->name;
    input->phys = "bf54x-keys/input0";
    input->dev.parent = &pdev->dev;

    input_set_drvdata(input, bf54x_kpad);

    input->id.bustype = BUS_HOST;
    input->id.vendor = 0x0001;
    input->id.product = 0x0001;
    input->id.version = 0x0100;

    input->keycodesize = sizeof(unsigned short);
    input->keycodemax = pdata->keymapsize;
    input->keycode = bf54x_kpad->keycode;

    bfin_keycodecpy(bf54x_kpad->keycode, pdata->keymap, pdata->keymapsize);

    /* setup input device */
    __set_bit(EV_KEY, input->evbit);

    if (pdata->repeat)
        __set_bit(EV_REP, input->evbit);

    for (i = 0; i < input->keycodemax; i++)
        __set_bit(bf54x_kpad->keycode[i] & KEY_MAX, input->keybit);
    __clear_bit(KEY_RESERVED, input->keybit);

    error = input_register_device(input);
    if (error) {
        printk(KERN_ERR DRV_NAME
               ": Unable to register input device (%d)\n", error);
        goto out4;
    }

    /* Init Keypad Key Up/Release test timer */

    setup_timer(&bf54x_kpad->timer, bfin_kpad_timer, (unsigned long) pdev);

    bfin_write_KPAD_PRESCALE(bfin_kpad_get_prescale(TIME_SCALE));

    bfin_write_KPAD_CTL((((pdata->cols - 1) << 13) & KPAD_COLEN) |
                        (((pdata->rows - 1) << 10) & KPAD_ROWEN) |
                        (2 & KPAD_IRQMODE));

    bfin_write_KPAD_CTL(bfin_read_KPAD_CTL() | KPAD_EN);

    device_init_wakeup(&pdev->dev, 1);

    printk(KERN_ERR DRV_NAME
           ": Blackfin BF54x Keypad registered IRQ %d\n", bf54x_kpad->irq);

    return 0;

out4:
    input_free_device(input);
out3:
    free_irq(bf54x_kpad->irq, pdev);
out2:
    peripheral_free_list((u16 *)&per_cols[MAX_RC - pdata->cols]);
out1:
    peripheral_free_list((u16 *)&per_rows[MAX_RC - pdata->rows]);
out0:
    kfree(bf54x_kpad->keycode);
out:
    kfree(bf54x_kpad);
    platform_set_drvdata(pdev, NULL);

    return error;
}
Exemple #28
0
static int __devinit bfin_sir_probe(struct platform_device *pdev)
{
	struct net_device *dev;
	struct bfin_sir_self *self;
	unsigned int baudrate_mask;
	struct bfin_sir_port *sir_port;
	int err;

	if (pdev->id >= 0 && pdev->id < ARRAY_SIZE(per) && \
				per[pdev->id][3] == pdev->id) {
		err = peripheral_request_list(per[pdev->id], DRIVER_NAME);
		if (err)
			return err;
	} else {
		dev_err(&pdev->dev, "Invalid pdev id, please check board file\n");
		return -ENODEV;
	}

	err = -ENOMEM;
	sir_port = kmalloc(sizeof(*sir_port), GFP_KERNEL);
	if (!sir_port)
		goto err_mem_0;

	bfin_sir_init_ports(sir_port, pdev);

	dev = alloc_irdadev(sizeof(*self));
	if (!dev)
		goto err_mem_1;

	self = netdev_priv(dev);
	self->dev = &pdev->dev;
	self->sir_port = sir_port;
	sir_port->dev = dev;

	err = bfin_sir_init_iobuf(&self->rx_buff, IRDA_SKB_MAX_MTU);
	if (err)
		goto err_mem_2;
	err = bfin_sir_init_iobuf(&self->tx_buff, IRDA_SIR_MAX_FRAME);
	if (err)
		goto err_mem_3;

	dev->netdev_ops = &bfin_sir_ndo;
	dev->irq = sir_port->irq;

	irda_init_max_qos_capabilies(&self->qos);

	baudrate_mask = IR_9600;

	switch (max_rate) {
	case 115200:
		baudrate_mask |= IR_115200;
	case 57600:
		baudrate_mask |= IR_57600;
	case 38400:
		baudrate_mask |= IR_38400;
	case 19200:
		baudrate_mask |= IR_19200;
	case 9600:
		break;
	default:
		dev_warn(&pdev->dev, "Invalid maximum baud rate, using 9600\n");
	}

	self->qos.baud_rate.bits &= baudrate_mask;

	self->qos.min_turn_time.bits = 1; /* 10 ms or more */

	irda_qos_bits_to_value(&self->qos);

	err = register_netdev(dev);

	if (err) {
		kfree(self->tx_buff.head);
err_mem_3:
		kfree(self->rx_buff.head);
err_mem_2:
		free_netdev(dev);
err_mem_1:
		kfree(sir_port);
err_mem_0:
		peripheral_free_list(per[pdev->id]);
	} else
		platform_set_drvdata(pdev, sir_port);

	return err;
}
static int bf5xx_ac97_probe(struct platform_device *pdev,
			    struct snd_soc_dai *dai)
{
	int ret = 0;
	cmd_count = (int *)get_zeroed_page(GFP_KERNEL);
	if (cmd_count == NULL)
		return -ENOMEM;

	if (peripheral_request_list(sport_req[sport_num], "soc-audio")) {
		pr_err("Requesting Peripherals failed\n");
		ret =  -EFAULT;
		goto peripheral_err;
	}

#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
	/* Request PB3 as reset pin */
	if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) {
		pr_err("Failed to request GPIO_%d for reset\n",
				CONFIG_SND_BF5XX_RESET_GPIO_NUM);
		ret =  -1;
		goto gpio_err;
	}
	gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1);
#endif
	sport_handle = sport_init(&sport_params[sport_num], 2, \
			sizeof(struct ac97_frame), NULL);
	if (!sport_handle) {
		ret = -ENODEV;
		goto sport_err;
	}
	/*SPORT works in TDM mode to simulate AC97 transfers*/
#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT)
	ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 1);
#else
	ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1);
#endif
	if (ret) {
		pr_err("SPORT is busy!\n");
		ret = -EBUSY;
		goto sport_config_err;
	}

	ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1));
	if (ret) {
		pr_err("SPORT is busy!\n");
		ret = -EBUSY;
		goto sport_config_err;
	}

	ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1));
	if (ret) {
		pr_err("SPORT is busy!\n");
		ret = -EBUSY;
		goto sport_config_err;
	}

	return 0;

sport_config_err:
	kfree(sport_handle);
sport_err:
#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
	gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
gpio_err:
#endif
	peripheral_free_list(sport_req[sport_num]);
peripheral_err:
	free_page((unsigned long)cmd_count);
	cmd_count = NULL;

	return ret;
}
static int __devinit bfin_rotary_probe(struct platform_device *pdev)
{
	struct bfin_rotary_platform_data *pdata = pdev->dev.platform_data;
	struct bfin_rot *rotary;
	struct input_dev *input;
	int error;

	/* Basic validation */
	if ((pdata->rotary_up_key && !pdata->rotary_down_key) ||
	    (!pdata->rotary_up_key && pdata->rotary_down_key)) {
		return -EINVAL;
	}

	error = peripheral_request_list(per_cnt, dev_name(&pdev->dev));
	if (error) {
		dev_err(&pdev->dev, "requesting peripherals failed\n");
		return error;
	}

	rotary = kzalloc(sizeof(struct bfin_rot), GFP_KERNEL);
	input = input_allocate_device();
	if (!rotary || !input) {
		error = -ENOMEM;
		goto out1;
	}

	rotary->input = input;

	rotary->up_key = pdata->rotary_up_key;
	rotary->down_key = pdata->rotary_down_key;
	rotary->button_key = pdata->rotary_button_key;
	rotary->rel_code = pdata->rotary_rel_code;

	error = rotary->irq = platform_get_irq(pdev, 0);
	if (error < 0)
		goto out1;

	input->name = pdev->name;
	input->phys = "bfin-rotary/input0";
	input->dev.parent = &pdev->dev;

	input_set_drvdata(input, rotary);

	input->id.bustype = BUS_HOST;
	input->id.vendor = 0x0001;
	input->id.product = 0x0001;
	input->id.version = 0x0100;

	if (rotary->up_key) {
		__set_bit(EV_KEY, input->evbit);
		__set_bit(rotary->up_key, input->keybit);
		__set_bit(rotary->down_key, input->keybit);
	} else {
		__set_bit(EV_REL, input->evbit);
		__set_bit(rotary->rel_code, input->relbit);
	}

	if (rotary->button_key) {
		__set_bit(EV_KEY, input->evbit);
		__set_bit(rotary->button_key, input->keybit);
	}

	error = request_irq(rotary->irq, bfin_rotary_isr,
			    0, dev_name(&pdev->dev), pdev);
	if (error) {
		dev_err(&pdev->dev,
			"unable to claim irq %d; error %d\n",
			rotary->irq, error);
		goto out1;
	}

	error = input_register_device(input);
	if (error) {
		dev_err(&pdev->dev,
			"unable to register input device (%d)\n", error);
		goto out2;
	}

	if (pdata->rotary_button_key)
		bfin_write_CNT_IMASK(CZMIE);

	if (pdata->mode & ROT_DEBE)
		bfin_write_CNT_DEBOUNCE(pdata->debounce & DPRESCALE);

	if (pdata->mode)
		bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() |
					(pdata->mode & ~CNTE));

	bfin_write_CNT_IMASK(bfin_read_CNT_IMASK() | UCIE | DCIE);
	bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() | CNTE);

	platform_set_drvdata(pdev, rotary);
	device_init_wakeup(&pdev->dev, 1);

	return 0;

out2:
	free_irq(rotary->irq, pdev);
out1:
	input_free_device(input);
	kfree(rotary);
	peripheral_free_list(per_cnt);

	return error;
}