void __init at32_spi_setup_slaves(unsigned int bus_num, 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 spi_pins[][4] = { { GPIO_PIN_PA(3), GPIO_PIN_PA(4), GPIO_PIN_PA(5), GPIO_PIN_PA(20) }, { GPIO_PIN_PB(2), GPIO_PIN_PB(3), GPIO_PIN_PB(4), GPIO_PIN_PA(27) }, }; unsigned int pin, mode; /* There are only 2 SPI controllers */ if (bus_num > 1) return; for (; n; n--, b++) { b->bus_num = bus_num; if (b->chip_select >= 4) continue; pin = (unsigned)b->controller_data; if (!pin) { pin = spi_pins[bus_num][b->chip_select]; b->controller_data = (void *)pin; } mode = AT32_GPIOF_OUTPUT; if (!(b->mode & SPI_CS_HIGH)) mode |= AT32_GPIOF_HIGH; at32_select_gpio(pin, mode); } }
static void __init atstk1003_setup_extdac(void) { struct clk *gclk; struct clk *pll; gclk = clk_get(NULL, "gclk0"); if (IS_ERR(gclk)) goto err_gclk; pll = clk_get(NULL, "pll0"); if (IS_ERR(pll)) goto err_pll; if (clk_set_parent(gclk, pll)) { pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n"); goto err_set_clk; } at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0); at73c213_data.dac_clk = gclk; err_set_clk: clk_put(pll); err_pll: clk_put(gclk); err_gclk: return; }
static int __init merisc_init(void) { detect_merisc_board_id(); printk(KERN_NOTICE "BOARD: Merisc %s revision %s\n", merisc_model(), merisc_revision()); /* Reserve pins for SDRAM */ at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL | (1 << 26)); if (merisc_board_id >= 1) at32_map_usart(2, 2, 0); at32_add_device_usart(0); at32_add_device_usart(1); if (merisc_board_id >= 1) at32_add_device_usart(2); at32_add_device_usart(3); set_hw_addr(at32_add_device_eth(0, ð_data[0])); /* ADS7846 PENIRQ */ if (merisc_board_id == 0) { ads7846_data.get_pendown_state = ads7846_get_pendown_state_PB26; at32_select_periph(GPIO_PIOB_BASE, 1 << 26, GPIO_PERIPH_A, AT32_GPIOF_PULLUP); spi0_board_info[0].irq = AT32_EXTINT(1); } else { ads7846_data.get_pendown_state = ads7846_get_pendown_state_PB28; at32_select_periph(GPIO_PIOB_BASE, 1 << 28, GPIO_PERIPH_A, AT32_GPIOF_PULLUP); spi0_board_info[0].irq = AT32_EXTINT(3); } /* ADS7846 busy pin */ at32_select_gpio(GPIO_PIN_PA(4), AT32_GPIOF_PULLUP); at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info)); at32_add_device_mci(0, &mci0_data); #ifdef CONFIG_LEDS_ATMEL_PWM at32_add_device_pwm((1 << 0) | (1 << 2)); platform_device_register(&stk_pwm_led_dev); #else at32_add_device_pwm((1 << 2)); #endif at32_select_gpio(i2c_gpio_data.sda_pin, AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); at32_select_gpio(i2c_gpio_data.scl_pin, AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); platform_device_register(&i2c_gpio_device); i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info)); return 0; }
static void detect_merisc_board_id(void) { /* Board ID pins MUST be set as input or the board may be damaged */ at32_select_gpio(GPIO_PIN_PA(24), AT32_GPIOF_PULLUP); at32_select_gpio(GPIO_PIN_PA(25), AT32_GPIOF_PULLUP); at32_select_gpio(GPIO_PIN_PA(26), AT32_GPIOF_PULLUP); at32_select_gpio(GPIO_PIN_PA(27), AT32_GPIOF_PULLUP); merisc_board_id = !gpio_get_value(GPIO_PIN_PA(24)) + !gpio_get_value(GPIO_PIN_PA(25)) * 2 + !gpio_get_value(GPIO_PIN_PA(26)) * 4 + !gpio_get_value(GPIO_PIN_PA(27)) * 8; }
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; }
{SHIFT_DR, EXIT1_DR}, {PAUSE_DR, UPDATE_DR}, {PAUSE_DR, EXIT2_DR}, {SHIFT_DR, UPDATE_DR}, {RUN_TEST_IDLE, SELECT_DR}, {CAPTURE_IR, TEST_LOGIC_RESET}, {SHIFT_IR, EXIT1_IR}, {SHIFT_IR, EXIT1_IR}, {PAUSE_IR, UPDATE_IR}, {PAUSE_IR, EXIT2_IR}, {SHIFT_IR, UPDATE_IR}, {RUN_TEST_IDLE, SELECT_DR} }; static const int tap_pin[][2] = { {GPIO_PIN_PA(10), GPIO_PIN_PA(0)}, // TDI {GPIO_PIN_PA(11), GPIO_PIN_PA(1)}, // TCK {GPIO_PIN_PA(12), GPIO_PIN_PA(2)}, // TMS {GPIO_PIN_PA(13), GPIO_PIN_PA(3)}, // TRST {GPIO_PIN_PA(14), GPIO_PIN_PA(4)} // TDO }; static const int tap_input[] = { GPIO_PIN_PA(5), // IO0 (INPUT 0) GPIO_PIN_PA(15), // IO1 (INPUT 1) }; static const int tap_output[] = { GPIO_PIN_PA(16), // IO2 (OUTPUT 0) GPIO_PIN_PA(19) // IO3 (OUTPUT 1) };
regs = (void __iomem __force *)res->start; pclk = clk_get(&pdev->dev, "pclk"); if (IS_ERR(pclk)) return; clk_enable(pclk); __raw_writel((addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | addr[0], regs + 0x98); __raw_writel((addr[5] << 8) | addr[4], regs + 0x9c); clk_disable(pclk); clk_put(pclk); } static struct i2c_gpio_platform_data i2c_gpio_data = { .sda_pin = GPIO_PIN_PA(6), .scl_pin = GPIO_PIN_PA(7), .sda_is_open_drain = 1, .scl_is_open_drain = 1, .udelay = 2, }; static struct platform_device i2c_gpio_device = { .name = "i2c-gpio", .id = 0, .dev = { .platform_data = &i2c_gpio_data, }, }; static struct i2c_board_info __initdata i2c_info[] = {
static int __init hammerhead_usbh_init(void) { struct clk *gclk; struct clk *osc; int ret; /* setup smc for usbh */ smc_set_timing(&isp1160_config, &isp1160_timing); ret = smc_set_configuration(2, &isp1160_config); if (ret < 0) { printk(KERN_ERR "hammerhead: failed to set ISP1160 USBH timing\n"); return ret; } /* setup gclk0 to run from osc1 */ gclk = clk_get(NULL, "gclk0"); if (IS_ERR(gclk)) { ret = PTR_ERR(gclk); goto err_gclk; } osc = clk_get(NULL, "osc1"); if (IS_ERR(osc)) { ret = PTR_ERR(osc); goto err_osc; } ret = clk_set_parent(gclk, osc); if (ret < 0) { pr_debug("hammerhead: failed to set osc1 for USBH clock\n"); goto err_set_clk; } /* set clock to 6MHz */ clk_set_rate(gclk, 6000000); /* and enable */ clk_enable(gclk); /* select GCLK0 peripheral function */ at32_select_periph(GPIO_PIOA_BASE, HAMMERHEAD_USB_PERIPH_GCLK0, GPIO_PERIPH_A, 0); /* enable CS2 peripheral function */ at32_select_periph(GPIO_PIOE_BASE, HAMMERHEAD_USB_PERIPH_CS2, GPIO_PERIPH_A, 0); /* H_WAKEUP must be driven low */ at32_select_gpio(GPIO_PIN_PA(8), AT32_GPIOF_OUTPUT); /* Select EXTINT0 for PB25 */ at32_select_periph(GPIO_PIOB_BASE, HAMMERHEAD_USB_PERIPH_EXTINT0, GPIO_PERIPH_A, 0); /* register usbh device driver */ platform_device_register(&isp1160_device); err_set_clk: clk_put(osc); err_osc: clk_put(gclk); err_gclk: return ret; }
__raw_writel((addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | addr[0], regs + 0x98); __raw_writel((addr[5] << 8) | addr[4], regs + 0x9c); clk_disable(pclk); clk_put(pclk); } void __init setup_board(void) { at32_map_usart(1, 0, 0); /* USART 1: /dev/ttyS0, DB9 */ at32_setup_serial_console(0); } static struct i2c_gpio_platform_data i2c_gpio_data = { .sda_pin = GPIO_PIN_PA(6), .scl_pin = GPIO_PIN_PA(7), .sda_is_open_drain = 1, .scl_is_open_drain = 1, .udelay = 2, /* close to 100 kHz */ }; static struct platform_device i2c_gpio_device = { .name = "i2c-gpio", .id = 0, .dev = { .platform_data = &i2c_gpio_data, }, }; static struct i2c_board_info __initdata i2c_info[] = {}; #ifdef CONFIG_BOARD_HAMMERHEAD_SND