示例#1
0
struct platform_device *__init at32_add_device_abdac(unsigned int id)
{
	struct platform_device *pdev;

	if (id != 0)
		return NULL;

	pdev = platform_device_alloc("abdac", id);
	if (!pdev)
		return NULL;

	if (platform_device_add_resources(pdev, abdac0_resource,
				ARRAY_SIZE(abdac0_resource)))
		goto err_add_resources;

	select_peripheral(PB(20), PERIPH_A, 0);	/* DATA1	*/
	select_peripheral(PB(21), PERIPH_A, 0);	/* DATA0	*/
	select_peripheral(PB(22), PERIPH_A, 0);	/* DATAN1	*/
	select_peripheral(PB(23), PERIPH_A, 0);	/* DATAN0	*/

	abdac0_pclk.dev = &pdev->dev;
	abdac0_sample_clk.dev = &pdev->dev;

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
示例#2
0
struct platform_device *__init at32_add_device_ac97c(unsigned int id)
{
	struct platform_device *pdev;

	if (id != 0)
		return NULL;

	pdev = platform_device_alloc("atmel_ac97c", id);
	if (!pdev)
		return NULL;

	if (platform_device_add_resources(pdev, atmel_ac97c0_resource,
				ARRAY_SIZE(atmel_ac97c0_resource)))
		goto err_add_resources;

	select_peripheral(PB(20), PERIPH_B, 0);	/* SYNC	*/
	select_peripheral(PB(21), PERIPH_B, 0);	/* SDO	*/
	select_peripheral(PB(22), PERIPH_B, 0);	/* SDI	*/
	select_peripheral(PB(23), PERIPH_B, 0);	/* SCLK	*/

	atmel_ac97c0_pclk.dev = &pdev->dev;

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
示例#3
0
struct platform_device *__init at32_add_device_twi(unsigned int id)
{
	struct platform_device *pdev;

	if (id != 0)
		return NULL;

	pdev = platform_device_alloc("atmel_twi", id);
	if (!pdev)
		return NULL;

	if (platform_device_add_resources(pdev, atmel_twi0_resource,
				ARRAY_SIZE(atmel_twi0_resource)))
		goto err_add_resources;

	select_peripheral(PA(6),  PERIPH_A, 0);	/* SDA	*/
	select_peripheral(PA(7),  PERIPH_A, 0);	/* SDL	*/

	atmel_twi0_pclk.dev = &pdev->dev;

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
示例#4
0
struct platform_device *__init at32_add_device_twi(unsigned int id,
						    struct i2c_board_info *b,
						    unsigned int n)
{
	struct platform_device *pdev;
	u32 pin_mask;

	if (id != 0)
		return NULL;

	pdev = platform_device_alloc("atmel_twi", id);
	if (!pdev)
		return NULL;

	if (platform_device_add_resources(pdev, atmel_twi0_resource,
				ARRAY_SIZE(atmel_twi0_resource)))
		goto err_add_resources;

	pin_mask  = (1 << 6) | (1 << 7);	/* SDA & SDL */

	select_peripheral(PIOA, pin_mask, PERIPH_A, 0);

	atmel_twi0_pclk.dev = &pdev->dev;

	if (b)
		i2c_register_board_info(id, b, n);

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
示例#5
0
static inline void configure_usart1_pins(int flags)
{
	u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */
	if (flags & ATMEL_USART_RTS)	pin_mask |= (1 << 19);
	if (flags & ATMEL_USART_CTS)	pin_mask |= (1 << 20);
	if (flags & ATMEL_USART_CLK)	pin_mask |= (1 << 16);

	select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP);
}
示例#6
0
static inline void configure_usart2_pins(int flags)
{
	u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */
	if (flags & ATMEL_USART_RTS)	pin_mask |= (1 << 30);
	if (flags & ATMEL_USART_CTS)	pin_mask |= (1 << 29);
	if (flags & ATMEL_USART_CLK)	pin_mask |= (1 << 28);

	select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
}
示例#7
0
struct platform_device *__init at32_add_device_psif(unsigned int id)
{
	struct platform_device *pdev;
	u32 pin_mask;

	if (!(id == 0 || id == 1))
		return NULL;

	pdev = platform_device_alloc("atmel_psif", id);
	if (!pdev)
		return NULL;

	switch (id) {
	case 0:
		pin_mask  = (1 << 8) | (1 << 9); /* CLOCK & DATA */

		if (platform_device_add_resources(pdev, atmel_psif0_resource,
					ARRAY_SIZE(atmel_psif0_resource)))
			goto err_add_resources;
		atmel_psif0_pclk.dev = &pdev->dev;
		select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
		break;
	case 1:
		pin_mask  = (1 << 11) | (1 << 12); /* CLOCK & DATA */

		if (platform_device_add_resources(pdev, atmel_psif1_resource,
					ARRAY_SIZE(atmel_psif1_resource)))
			goto err_add_resources;
		atmel_psif1_pclk.dev = &pdev->dev;
		select_peripheral(PIOB, pin_mask, PERIPH_A, 0);
		break;
	default:
		return NULL;
	}

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
示例#8
0
struct platform_device *__init at32_add_device_mci(unsigned int id)
{
	struct platform_device *pdev;

	if (id != 0)
		return NULL;

	pdev = platform_device_alloc("atmel_mci", id);
	if (!pdev)
		return NULL;

	if (platform_device_add_resources(pdev, atmel_mci0_resource,
				ARRAY_SIZE(atmel_mci0_resource)))
		goto err_add_resources;

	select_peripheral(PA(10), PERIPH_A, 0);	/* CLK	 */
	select_peripheral(PA(11), PERIPH_A, 0);	/* CMD	 */
	select_peripheral(PA(12), PERIPH_A, 0);	/* DATA0 */
	select_peripheral(PA(13), PERIPH_A, 0);	/* DATA1 */
	select_peripheral(PA(14), PERIPH_A, 0);	/* DATA2 */
	select_peripheral(PA(15), PERIPH_A, 0);	/* DATA3 */

	atmel_mci0_pclk.dev = &pdev->dev;

	platform_device_add(pdev);
	return pdev;

err_add_resources:
	platform_device_put(pdev);
	return NULL;
}
示例#9
0
static int __init at32_init_ide_or_cf(struct platform_device *pdev,
		unsigned int cs, unsigned int extint)
{
	static unsigned int extint_pin_map[4] __initdata = {
		GPIO_PIN_PB(25),
		GPIO_PIN_PB(26),
		GPIO_PIN_PB(27),
		GPIO_PIN_PB(28),
	};
	static bool common_pins_initialized __initdata = false;
	unsigned int extint_pin;
	int ret;

	if (extint >= ARRAY_SIZE(extint_pin_map))
		return -EINVAL;
	extint_pin = extint_pin_map[extint];

	switch (cs) {
	case 4:
		ret = platform_device_add_resources(pdev,
				at32_smc_cs4_resource,
				ARRAY_SIZE(at32_smc_cs4_resource));
		if (ret)
			return ret;

		select_peripheral(PE(21), PERIPH_A, 0); /* NCS4   -> OE_N  */
		set_ebi_sfr_bits(HMATRIX_BIT(CS4A));
		break;
	case 5:
		ret = platform_device_add_resources(pdev,
				at32_smc_cs5_resource,
				ARRAY_SIZE(at32_smc_cs5_resource));
		if (ret)
			return ret;

		select_peripheral(PE(22), PERIPH_A, 0); /* NCS5   -> OE_N  */
		set_ebi_sfr_bits(HMATRIX_BIT(CS5A));
		break;
	default:
		return -EINVAL;
	}

	if (!common_pins_initialized) {
		select_peripheral(PE(19), PERIPH_A, 0);	/* CFCE1  -> CS0_N */
		select_peripheral(PE(20), PERIPH_A, 0);	/* CFCE2  -> CS1_N */
		select_peripheral(PE(23), PERIPH_A, 0); /* CFRNW  -> DIR   */
		select_peripheral(PE(24), PERIPH_A, 0); /* NWAIT  <- IORDY */
		common_pins_initialized = true;
	}

	at32_select_periph(extint_pin, GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);

	pdev->resource[1].start = EIM_IRQ_BASE + extint;
	pdev->resource[1].end = pdev->resource[1].start;

	return 0;
}
示例#10
0
struct platform_device *__init
at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
{
	struct platform_device *pdev;
	u32 pin_mask;

	switch (id) {
	case 0:
		pdev = &atmel_spi0_device;
		pin_mask  = (1 << 1) | (1 << 2);	/* MOSI & SCK */

		/* pullup MISO so a level is always defined */
		select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP);
		select_peripheral(PIOA, pin_mask, PERIPH_A, 0);

		at32_spi_setup_slaves(0, b, n);
		break;

	case 1:
		pdev = &atmel_spi1_device;
		pin_mask  = (1 << 1) | (1 << 5);	/* MOSI */

		/* pullup MISO so a level is always defined */
		select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP);
		select_peripheral(PIOB, pin_mask, PERIPH_B, 0);

		at32_spi_setup_slaves(1, b, n);
		break;

	default:
		return NULL;
	}

	spi_register_board_info(b, n);
	platform_device_register(pdev);
	return pdev;
}
示例#11
0
struct platform_device *__init
at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
{
	/*
	 * Manage the chipselects as GPIOs, normally using the same pins
	 * the SPI controller expects; but boards can use other pins.
	 */
	static u8 __initdata spi0_pins[] =
		{ GPIO_PIN_PA(3), GPIO_PIN_PA(4),
		  GPIO_PIN_PA(5), GPIO_PIN_PA(20), };
	static u8 __initdata spi1_pins[] =
		{ GPIO_PIN_PB(2), GPIO_PIN_PB(3),
		  GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
	struct platform_device *pdev;

	switch (id) {
	case 0:
		pdev = &atmel_spi0_device;
		select_peripheral(PA(0),  PERIPH_A, 0);	/* MISO	 */
		select_peripheral(PA(1),  PERIPH_A, 0);	/* MOSI	 */
		select_peripheral(PA(2),  PERIPH_A, 0);	/* SCK	 */
		at32_spi_setup_slaves(0, b, n, spi0_pins);
		break;

	case 1:
		pdev = &atmel_spi1_device;
		select_peripheral(PB(0),  PERIPH_B, 0);	/* MISO  */
		select_peripheral(PB(1),  PERIPH_B, 0);	/* MOSI  */
		select_peripheral(PB(5),  PERIPH_B, 0);	/* SCK   */
		at32_spi_setup_slaves(1, b, n, spi1_pins);
		break;

	default:
		return NULL;
	}

	spi_register_board_info(b, n);
	platform_device_register(pdev);
	return pdev;
}
示例#12
0
struct platform_device *__init
at32_add_device_ssc(unsigned int id, unsigned int flags)
{
	struct platform_device *pdev;

	switch (id) {
	case 0:
		pdev = &ssc0_device;
		if (flags & ATMEL_SSC_RF)
			select_peripheral(PA(21), PERIPH_A, 0);	/* RF */
		if (flags & ATMEL_SSC_RK)
			select_peripheral(PA(22), PERIPH_A, 0);	/* RK */
		if (flags & ATMEL_SSC_TK)
			select_peripheral(PA(23), PERIPH_A, 0);	/* TK */
		if (flags & ATMEL_SSC_TF)
			select_peripheral(PA(24), PERIPH_A, 0);	/* TF */
		if (flags & ATMEL_SSC_TD)
			select_peripheral(PA(25), PERIPH_A, 0);	/* TD */
		if (flags & ATMEL_SSC_RD)
			select_peripheral(PA(26), PERIPH_A, 0);	/* RD */
		break;
	case 1:
		pdev = &ssc1_device;
		if (flags & ATMEL_SSC_RF)
			select_peripheral(PA(0), PERIPH_B, 0);	/* RF */
		if (flags & ATMEL_SSC_RK)
			select_peripheral(PA(1), PERIPH_B, 0);	/* RK */
		if (flags & ATMEL_SSC_TK)
			select_peripheral(PA(2), PERIPH_B, 0);	/* TK */
		if (flags & ATMEL_SSC_TF)
			select_peripheral(PA(3), PERIPH_B, 0);	/* TF */
		if (flags & ATMEL_SSC_TD)
			select_peripheral(PA(4), PERIPH_B, 0);	/* TD */
		if (flags & ATMEL_SSC_RD)
			select_peripheral(PA(5), PERIPH_B, 0);	/* RD */
		break;
	case 2:
		pdev = &ssc2_device;
		if (flags & ATMEL_SSC_TD)
			select_peripheral(PB(13), PERIPH_A, 0);	/* TD */
		if (flags & ATMEL_SSC_RD)
			select_peripheral(PB(14), PERIPH_A, 0);	/* RD */
		if (flags & ATMEL_SSC_TK)
			select_peripheral(PB(15), PERIPH_A, 0);	/* TK */
		if (flags & ATMEL_SSC_TF)
			select_peripheral(PB(16), PERIPH_A, 0);	/* TF */
		if (flags & ATMEL_SSC_RF)
			select_peripheral(PB(17), PERIPH_A, 0);	/* RF */
		if (flags & ATMEL_SSC_RK)
			select_peripheral(PB(18), PERIPH_A, 0);	/* RK */
		break;
	default:
		return NULL;
	}

	platform_device_register(pdev);
	return pdev;
}
示例#13
0
struct platform_device *__init
at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
{
	struct platform_device		*pdev;
	struct mci_dma_data	        *slave;
	u32				pioa_mask;
	u32				piob_mask;

	if (id != 0 || !data)
		return NULL;

	/* Must have at least one usable slot */
	if (!data->slot[0].bus_width && !data->slot[1].bus_width)
		return NULL;

	pdev = platform_device_alloc("atmel_mci", id);
	if (!pdev)
		goto fail;

	if (platform_device_add_resources(pdev, atmel_mci0_resource,
				ARRAY_SIZE(atmel_mci0_resource)))
		goto fail;

	slave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
	if (!slave)
		goto fail;

	slave->sdata.dma_dev = &dw_dmac0_device.dev;
	slave->sdata.cfg_hi = (DWC_CFGH_SRC_PER(0)
				| DWC_CFGH_DST_PER(1));
	slave->sdata.cfg_lo &= ~(DWC_CFGL_HS_DST_POL
				| DWC_CFGL_HS_SRC_POL);

	data->dma_slave = slave;

	if (platform_device_add_data(pdev, data,
				sizeof(struct mci_platform_data)))
		goto fail_free;

	/* CLK line is common to both slots */
	pioa_mask = 1 << 10;

	switch (data->slot[0].bus_width) {
	case 4:
		pioa_mask |= 1 << 13;		/* DATA1 */
		pioa_mask |= 1 << 14;		/* DATA2 */
		pioa_mask |= 1 << 15;		/* DATA3 */
		/* fall through */
	case 1:
		pioa_mask |= 1 << 11;		/* CMD	 */
		pioa_mask |= 1 << 12;		/* DATA0 */

		if (gpio_is_valid(data->slot[0].detect_pin))
			at32_select_gpio(data->slot[0].detect_pin, 0);
		if (gpio_is_valid(data->slot[0].wp_pin))
			at32_select_gpio(data->slot[0].wp_pin, 0);
		break;
	case 0:
		/* Slot is unused */
		break;
	default:
		goto fail_free;
	}

	select_peripheral(PIOA, pioa_mask, PERIPH_A, 0);
	piob_mask = 0;

	switch (data->slot[1].bus_width) {
	case 4:
		piob_mask |= 1 <<  8;		/* DATA1 */
		piob_mask |= 1 <<  9;		/* DATA2 */
		piob_mask |= 1 << 10;		/* DATA3 */
		/* fall through */
	case 1:
		piob_mask |= 1 <<  6;		/* CMD	 */
		piob_mask |= 1 <<  7;		/* DATA0 */
		select_peripheral(PIOB, piob_mask, PERIPH_B, 0);

		if (gpio_is_valid(data->slot[1].detect_pin))
			at32_select_gpio(data->slot[1].detect_pin, 0);
		if (gpio_is_valid(data->slot[1].wp_pin))
			at32_select_gpio(data->slot[1].wp_pin, 0);
		break;
	case 0:
		/* Slot is unused */
		break;
	default:
		if (!data->slot[0].bus_width)
示例#14
0
static inline void configure_usart0_pins(void)
{
	select_peripheral(PA(8),  PERIPH_B, 0);	/* RXD	*/
	select_peripheral(PA(9),  PERIPH_B, 0);	/* TXD	*/
}
示例#15
0
struct platform_device *__init
at32_add_device_eth(unsigned int id, struct macb_platform_data *data)
{
	struct platform_device *pdev;
	u32 pin_mask;

	switch (id) {
	case 0:
		pdev = &macb0_device;

		pin_mask  = (1 << 3);	/* TXD0 */
		pin_mask |= (1 << 4);	/* TXD1 */
		pin_mask |= (1 << 7);	/* TXEN */
		pin_mask |= (1 << 8);	/* TXCK */
		pin_mask |= (1 << 9);	/* RXD0 */
		pin_mask |= (1 << 10);	/* RXD1 */
		pin_mask |= (1 << 13);	/* RXER */
		pin_mask |= (1 << 15);	/* RXDV */
		pin_mask |= (1 << 16);	/* MDC  */
		pin_mask |= (1 << 17);	/* MDIO */

		if (!data->is_rmii) {
			pin_mask |= (1 << 0);	/* COL  */
			pin_mask |= (1 << 1);	/* CRS  */
			pin_mask |= (1 << 2);	/* TXER */
			pin_mask |= (1 << 5);	/* TXD2 */
			pin_mask |= (1 << 6);	/* TXD3 */
			pin_mask |= (1 << 11);	/* RXD2 */
			pin_mask |= (1 << 12);	/* RXD3 */
			pin_mask |= (1 << 14);	/* RXCK */
#ifndef CONFIG_BOARD_MIMC200
			pin_mask |= (1 << 18);	/* SPD  */
#endif
		}

		select_peripheral(PIOC, pin_mask, PERIPH_A, 0);

		break;

	case 1:
		pdev = &macb1_device;

		pin_mask  = (1 << 13);	/* TXD0 */
		pin_mask |= (1 << 14);	/* TXD1 */
		pin_mask |= (1 << 11);	/* TXEN */
		pin_mask |= (1 << 12);	/* TXCK */
		pin_mask |= (1 << 10);	/* RXD0 */
		pin_mask |= (1 << 6);	/* RXD1 */
		pin_mask |= (1 << 5);	/* RXER */
		pin_mask |= (1 << 4);	/* RXDV */
		pin_mask |= (1 << 3);	/* MDC  */
		pin_mask |= (1 << 2);	/* MDIO */

#ifndef CONFIG_BOARD_MIMC200
		if (!data->is_rmii)
			pin_mask |= (1 << 15);	/* SPD  */
#endif

		select_peripheral(PIOD, pin_mask, PERIPH_B, 0);

		if (!data->is_rmii) {
			pin_mask  = (1 << 19);	/* COL  */
			pin_mask |= (1 << 23);	/* CRS  */
			pin_mask |= (1 << 26);	/* TXER */
			pin_mask |= (1 << 27);	/* TXD2 */
			pin_mask |= (1 << 28);	/* TXD3 */
			pin_mask |= (1 << 29);	/* RXD2 */
			pin_mask |= (1 << 30);	/* RXD3 */
			pin_mask |= (1 << 24);	/* RXCK */

			select_peripheral(PIOC, pin_mask, PERIPH_B, 0);
		}
		break;

	default:
		return NULL;
	}

	memcpy(pdev->dev.platform_data, data, sizeof(struct macb_platform_data));
	platform_device_register(pdev);

	return pdev;
}
示例#16
0
static inline void configure_usart3_pins(void)
{
	select_peripheral(PB(18), PERIPH_B, 0);	/* RXD	*/
	select_peripheral(PB(17), PERIPH_B, 0);	/* TXD	*/
}
示例#17
0
struct platform_device *__init
at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
		     unsigned long fbmem_start, unsigned long fbmem_len)
{
	struct platform_device *pdev;
	struct atmel_lcdfb_info *info;
	struct fb_monspecs *monspecs;
	struct fb_videomode *modedb;
	unsigned int modedb_size;

	/*
	 * Do a deep copy of the fb data, monspecs and modedb. Make
	 * sure all allocations are done before setting up the
	 * portmux.
	 */
	monspecs = kmemdup(data->default_monspecs,
			   sizeof(struct fb_monspecs), GFP_KERNEL);
	if (!monspecs)
		return NULL;

	modedb_size = sizeof(struct fb_videomode) * monspecs->modedb_len;
	modedb = kmemdup(monspecs->modedb, modedb_size, GFP_KERNEL);
	if (!modedb)
		goto err_dup_modedb;
	monspecs->modedb = modedb;

	switch (id) {
	case 0:
		pdev = &atmel_lcdfb0_device;
		select_peripheral(PC(19), PERIPH_A, 0);	/* CC	  */
		select_peripheral(PC(20), PERIPH_A, 0);	/* HSYNC  */
		select_peripheral(PC(21), PERIPH_A, 0);	/* PCLK	  */
		select_peripheral(PC(22), PERIPH_A, 0);	/* VSYNC  */
		select_peripheral(PC(23), PERIPH_A, 0);	/* DVAL	  */
		select_peripheral(PC(24), PERIPH_A, 0);	/* MODE	  */
		select_peripheral(PC(25), PERIPH_A, 0);	/* PWR	  */
		select_peripheral(PC(26), PERIPH_A, 0);	/* DATA0  */
		select_peripheral(PC(27), PERIPH_A, 0);	/* DATA1  */
		select_peripheral(PC(28), PERIPH_A, 0);	/* DATA2  */
		select_peripheral(PC(29), PERIPH_A, 0);	/* DATA3  */
		select_peripheral(PC(30), PERIPH_A, 0);	/* DATA4  */
		select_peripheral(PC(31), PERIPH_A, 0);	/* DATA5  */
		select_peripheral(PD(0),  PERIPH_A, 0);	/* DATA6  */
		select_peripheral(PD(1),  PERIPH_A, 0);	/* DATA7  */
		select_peripheral(PD(2),  PERIPH_A, 0);	/* DATA8  */
		select_peripheral(PD(3),  PERIPH_A, 0);	/* DATA9  */
		select_peripheral(PD(4),  PERIPH_A, 0);	/* DATA10 */
		select_peripheral(PD(5),  PERIPH_A, 0);	/* DATA11 */
		select_peripheral(PD(6),  PERIPH_A, 0);	/* DATA12 */
		select_peripheral(PD(7),  PERIPH_A, 0);	/* DATA13 */
		select_peripheral(PD(8),  PERIPH_A, 0);	/* DATA14 */
		select_peripheral(PD(9),  PERIPH_A, 0);	/* DATA15 */
		select_peripheral(PD(10), PERIPH_A, 0);	/* DATA16 */
		select_peripheral(PD(11), PERIPH_A, 0);	/* DATA17 */
		select_peripheral(PD(12), PERIPH_A, 0);	/* DATA18 */
		select_peripheral(PD(13), PERIPH_A, 0);	/* DATA19 */
		select_peripheral(PD(14), PERIPH_A, 0);	/* DATA20 */
		select_peripheral(PD(15), PERIPH_A, 0);	/* DATA21 */
		select_peripheral(PD(16), PERIPH_A, 0);	/* DATA22 */
		select_peripheral(PD(17), PERIPH_A, 0);	/* DATA23 */

		clk_set_parent(&atmel_lcdfb0_pixclk, &pll0);
		clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0));
		break;

	default:
		goto err_invalid_id;
	}

	if (fbmem_len) {
		pdev->resource[2].start = fbmem_start;
		pdev->resource[2].end = fbmem_start + fbmem_len - 1;
		pdev->resource[2].flags = IORESOURCE_MEM;
	}

	info = pdev->dev.platform_data;
	memcpy(info, data, sizeof(struct atmel_lcdfb_info));
	info->default_monspecs = monspecs;

	platform_device_register(pdev);
	return pdev;

err_invalid_id:
	kfree(modedb);
err_dup_modedb:
	kfree(monspecs);
	return NULL;
}
示例#18
0
struct platform_device *__init
at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
{
	struct platform_device *pdev;

	switch (id) {
	case 0:
		pdev = &macb0_device;

		select_peripheral(PC(3),  PERIPH_A, 0);	/* TXD0	*/
		select_peripheral(PC(4),  PERIPH_A, 0);	/* TXD1	*/
		select_peripheral(PC(7),  PERIPH_A, 0);	/* TXEN	*/
		select_peripheral(PC(8),  PERIPH_A, 0);	/* TXCK */
		select_peripheral(PC(9),  PERIPH_A, 0);	/* RXD0	*/
		select_peripheral(PC(10), PERIPH_A, 0);	/* RXD1	*/
		select_peripheral(PC(13), PERIPH_A, 0);	/* RXER	*/
		select_peripheral(PC(15), PERIPH_A, 0);	/* RXDV	*/
		select_peripheral(PC(16), PERIPH_A, 0);	/* MDC	*/
		select_peripheral(PC(17), PERIPH_A, 0);	/* MDIO	*/

		if (!data->is_rmii) {
			select_peripheral(PC(0),  PERIPH_A, 0);	/* COL	*/
			select_peripheral(PC(1),  PERIPH_A, 0);	/* CRS	*/
			select_peripheral(PC(2),  PERIPH_A, 0);	/* TXER	*/
			select_peripheral(PC(5),  PERIPH_A, 0);	/* TXD2	*/
			select_peripheral(PC(6),  PERIPH_A, 0);	/* TXD3 */
			select_peripheral(PC(11), PERIPH_A, 0);	/* RXD2	*/
			select_peripheral(PC(12), PERIPH_A, 0);	/* RXD3	*/
			select_peripheral(PC(14), PERIPH_A, 0);	/* RXCK	*/
			select_peripheral(PC(18), PERIPH_A, 0);	/* SPD	*/
		}
		break;

	case 1:
		pdev = &macb1_device;

		select_peripheral(PD(13), PERIPH_B, 0);		/* TXD0	*/
		select_peripheral(PD(14), PERIPH_B, 0);		/* TXD1	*/
		select_peripheral(PD(11), PERIPH_B, 0);		/* TXEN	*/
		select_peripheral(PD(12), PERIPH_B, 0);		/* TXCK */
		select_peripheral(PD(10), PERIPH_B, 0);		/* RXD0	*/
		select_peripheral(PD(6),  PERIPH_B, 0);		/* RXD1	*/
		select_peripheral(PD(5),  PERIPH_B, 0);		/* RXER	*/
		select_peripheral(PD(4),  PERIPH_B, 0);		/* RXDV	*/
		select_peripheral(PD(3),  PERIPH_B, 0);		/* MDC	*/
		select_peripheral(PD(2),  PERIPH_B, 0);		/* MDIO	*/

		if (!data->is_rmii) {
			select_peripheral(PC(19), PERIPH_B, 0);	/* COL	*/
			select_peripheral(PC(23), PERIPH_B, 0);	/* CRS	*/
			select_peripheral(PC(26), PERIPH_B, 0);	/* TXER	*/
			select_peripheral(PC(27), PERIPH_B, 0);	/* TXD2	*/
			select_peripheral(PC(28), PERIPH_B, 0);	/* TXD3 */
			select_peripheral(PC(29), PERIPH_B, 0);	/* RXD2	*/
			select_peripheral(PC(30), PERIPH_B, 0);	/* RXD3	*/
			select_peripheral(PC(24), PERIPH_B, 0);	/* RXCK	*/
			select_peripheral(PD(15), PERIPH_B, 0);	/* SPD	*/
		}
		break;

	default:
		return NULL;
	}

	memcpy(pdev->dev.platform_data, data, sizeof(struct eth_platform_data));
	platform_device_register(pdev);

	return pdev;
}