コード例 #1
0
ファイル: at32ap7000.c プロジェクト: PennPanda/linux-repo
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;
}
コード例 #2
0
ファイル: at32ap700x.c プロジェクト: LeonMagnus/linux
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;
}
コード例 #3
0
ファイル: mrmt.c プロジェクト: 01org/KVMGT-kernel
static int __init mrmt1_init(void)
{
	gpio_set_value( PIN_PWR_ON, 1 );	/* Ensure PWR_ON is enabled */

	pm_power_off = mrmt_power_off;

	/* Setup USARTS (other than console) */
	at32_map_usart(2, 1, 0);	/* USART 2: /dev/ttyS1, RMT1:DB9M */
	at32_map_usart(3, 2, ATMEL_USART_RTS | ATMEL_USART_CTS);
			/* USART 3: /dev/ttyS2, RMT1:Wireless, w/ RTS/CTS */
	at32_add_device_usart(1);
	at32_add_device_usart(2);

	/* Select GPIO Key pins */
	at32_select_gpio( PIN_PWR_SW_N, AT32_GPIOF_DEGLITCH);
	at32_select_gpio( PIN_PB_LEFT, AT32_GPIOF_DEGLITCH);
	at32_select_gpio( PIN_PB_RIGHT, AT32_GPIOF_DEGLITCH);
	platform_device_register(&rmt_gpio_keys);

#ifdef CONFIG_BOARD_MRMT_RTC_I2C
	i2c_register_board_info(0, &mrmt1_i2c_rtc, 1);
#endif

#ifndef CONFIG_BOARD_MRMT_LCD_DISABLE
	/* User "alternate" LCDC inferface on Port E & D */
	/* NB: exclude LCDC_CC pin, as NGW100 reserves it for other use */
	at32_add_device_lcdc(0, &rmt_lcdc_data,
		fbmem_start, fbmem_size,
		(ATMEL_LCDC_ALT_24BIT | ATMEL_LCDC_PE_DVAL ) );
#endif

#ifdef CONFIG_BOARD_MRMT_AC97
	at32_add_device_ac97c(0, &ac97c0_data, AC97C_BOTH);
#endif

#ifdef CONFIG_BOARD_MRMT_ADS7846_TS
	/* Select the Touchscreen interrupt pin mode */
	at32_select_periph( GPIO_PIOB_BASE, 1 << (PB_EXTINT_BASE+TS_IRQ),
			GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);
	irq_set_irq_type(AT32_EXTINT(TS_IRQ), IRQ_TYPE_EDGE_FALLING);
	at32_spi_setup_slaves(0,spi01_board_info,ARRAY_SIZE(spi01_board_info));
	spi_register_board_info(spi01_board_info,ARRAY_SIZE(spi01_board_info));
#endif

#ifdef CONFIG_BOARD_MRMT_UCB1400_TS
	/* Select the Touchscreen interrupt pin mode */
	at32_select_periph( GPIO_PIOB_BASE, 1 << (PB_EXTINT_BASE+TS_IRQ),
			GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);
	platform_device_register(&rmt_ts_device);
#endif

	at32_select_gpio( PIN_LCD_DISP, AT32_GPIOF_OUTPUT );
	gpio_request( PIN_LCD_DISP, "LCD_DISP" );
	gpio_direction_output( PIN_LCD_DISP, 0 );	/* LCD DISP */
#ifdef CONFIG_BOARD_MRMT_LCD_DISABLE
	/* Keep Backlight and DISP off */
	at32_select_gpio( PIN_LCD_BL, AT32_GPIOF_OUTPUT );
	gpio_request( PIN_LCD_BL, "LCD_BL" );
	gpio_direction_output( PIN_LCD_BL, 0 );		/* Backlight */
#else
	gpio_set_value( PIN_LCD_DISP, 1 );	/* DISP asserted first */
#ifdef CONFIG_BOARD_MRMT_BL_PWM
	/* Use PWM for Backlight controls */
	at32_add_device_pwm(1 << PWM_CH_BL);
	platform_device_register(&rmt_pwm_led_dev);
#else
	/* Backlight always on */
	udelay( 1 );
	at32_select_gpio( PIN_LCD_BL, AT32_GPIOF_OUTPUT );
	gpio_request( PIN_LCD_BL, "LCD_BL" );
	gpio_direction_output( PIN_LCD_BL, 1 );
#endif
#endif

	/* Make sure BT and Zigbee modules in reset */
	at32_select_gpio( PIN_BT_RST, AT32_GPIOF_OUTPUT );
	gpio_request( PIN_BT_RST, "BT_RST" );
	gpio_direction_output( PIN_BT_RST, 1 );
	/* BT Module in Reset */

	at32_select_gpio( PIN_ZB_RST_N, AT32_GPIOF_OUTPUT );
	gpio_request( PIN_ZB_RST_N, "ZB_RST_N" );
	gpio_direction_output( PIN_ZB_RST_N, 0 );
	/* XBee Module in Reset */

#ifdef CONFIG_BOARD_MRMT_WIRELESS_ZB
	udelay( 1000 );
	/* Unreset the XBee Module */
	gpio_set_value( PIN_ZB_RST_N, 1 );
#endif
#ifdef CONFIG_BOARD_MRMT_WIRELESS_BT
	udelay( 1000 );
	/* Unreset the BT Module */
	gpio_set_value( PIN_BT_RST, 0 );
#endif

	return 0;
}