Example #1
0
static void __init ds_setup(void)
{
#ifdef DS2_PREV_RESET_PIN
	u32 t;
#endif
	ds_common_setup();

	ath79_register_leds_gpio(-1, ARRAY_SIZE(ds_leds_gpio),
				 ds_leds_gpio);
	ath79_register_gpio_keys_polled(-1, DS_KEYS_POLL_INTERVAL,
					ARRAY_SIZE(ds_gpio_keys),
					ds_gpio_keys);
	ath79_register_usb();

	//Disable the Function for some pins to have GPIO functionality active
	// GPIO6-7-8 and GPIO11
	ath79_gpio_function_setup(AR933X_GPIO_FUNC_JTAG_DISABLE | AR933X_GPIO_FUNC_I2S_MCK_EN, 0);

	ath79_gpio_function2_setup(AR933X_GPIO_FUNC2_JUMPSTART_DISABLE, 0);

	printk("Setting DogStick2 GPIO\n");
#ifdef DS2_PREV_RESET_PIN
	t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
	t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
	ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
        
	// Put the avr reset to high 
	if (gpio_request_one(DS_GPIO_AVR_RESET_DS2,
                 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
                 "OE-1") != 0)
                printk("Error setting GPIO OE\n");
	gpio_unexport(DS_GPIO_AVR_RESET_DS2);
	gpio_free(DS_GPIO_AVR_RESET_DS2);
#endif

	// enable OE of level shifter
	if (gpio_request_one(DS_GPIO_OE,
		 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
		 "OE-1") != 0)
		printk("Error setting GPIO OE\n");

#ifdef DS1
	if (gpio_request_one(DS_GPIO_OE2,
		 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
		 "OE-2") != 0)
		printk("Error setting GPIO OE2\n");
#else
        if (gpio_request_one(DS_GPIO_UART_ENA,
                 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
                 "UART-ENA") != 0)
                printk("Error setting GPIO Uart Enable\n");
        
	// enable OE of level shifter
        if (gpio_request_one(DS_GPIO_OE2,
                 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
                 "OE-2") != 0)
                printk("Error setting GPIO OE2\n");
#endif
}
Example #2
0
static void __init ds_setup(void)
{
	u32 t=0;

	ds_common_setup();

	ath79_register_leds_gpio(-1, ARRAY_SIZE(ds_leds_gpio), ds_leds_gpio);
	ath79_register_gpio_keys_polled(-1, DS_KEYS_POLL_INTERVAL,
			ARRAY_SIZE(ds_gpio_keys), ds_gpio_keys);
	ath79_register_usb();

	// use the swtich_led directly form sysfs
	ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
	                            AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
	                            AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
	                            AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN);

	/*
	 * Disable the Function for some pins to have GPIO functionality active
	 * GPIO6-7-8 and GPIO11
	 */
	ath79_gpio_function_setup(GPIO_FUNC_SET, GPIO_FUNC_CLEAR);

	ath79_gpio_function2_setup(GPIO_FUNC2_SET, GPIO_FUNC2_CLEAR);

	pr_info("mach-linino: setting GPIO\n");

	/* Enable GPIO26 instead of MDC function */
	t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
	t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
	ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);

	/* enable OE of level shifters */
	ds_setup_level_shifter_oe();
	/* enable uart */
	ds_setup_uart_enable();

	/* Register Software SPI controller */
	ds_register_spi();
}