コード例 #1
0
static void configPIO(void)
{
	/* Setup PIO of ASC device */
#if CFG_STM_ASC_BASE == ST40_ASC2_REGS_BASE	/* UART #2 */
	SET_PIO_ASC(PIO_PORT(4), 3, 2, 4, 5);	/* UART2 - AS0 */
#else
#error Unsure which UART to configure!
#endif	/* CFG_STM_ASC_BASE == ST40_ASC2_REGS_BASE */

	/* Configure & Reset the Ethernet PHY */
	configEthernet();

#if defined(CONFIG_SPI)
	/* Configure for SPI Serial Flash */
	configSpi();
#endif	/* CONFIG_SPI */
}
コード例 #2
0
ファイル: fldb.c プロジェクト: Blagus/STB8000-U-Boot
extern int checkboard (void)
{
	printf ("\n\nBoard: FLI7510 Development Board"
#ifdef CONFIG_ST40_SE_MODE
		"  [32-bit mode]"
#else
		"  [29-bit mode]"
#endif
		"\n");

#if defined(CONFIG_SPI)
	/*
	 * Configure for the SPI Serial Flash.
	 * Note: for CONFIG_SYS_BOOT_FROM_SPI + CONFIG_ENV_IS_IN_EEPROM, this
	 * needs to be done after env_init(), hence it is done
	 * here, and not in board_init().
	 */
	configSpi();
#endif	/* CONFIG_SPI */

	return 0;
}
コード例 #3
0
/*
 * initialise the SSC to talk to the slave SPI device.
 */
extern void spi_init(void)
{
	//DECLARE_GLOBAL_DATA_PTR;
	spi_chipsel_type const chipsel = spi_chipsel[0];	/* SPI Device #0 */

#if !defined(CONFIG_SOFT_SPI)			/* Use SSC for SPI */
	unsigned long reg;
	const unsigned long bits_per_word = 8;	/* one word == 8-bits */
	const unsigned long mode = CFG_STM_SPI_MODE /* | SPI_LOOP */;
	//const unsigned long fcomms = gd->bd->bi_emifrq*1000*1000;
	const unsigned long hz = CFG_STM_SPI_FREQUENCY;
       //unsigned long sscbrg = fcomms/(2*hz);

#endif	/* CONFIG_SOFT_SPI */

      /*init pio15.0-pio15.3*/
      configSpi();

	/* de-assert SPI CS */
	(*chipsel)(0);

#if !defined(CONFIG_SOFT_SPI)			/* Use SSC for SPI */
	/* program the SSC's Baud-Rate Generator */
	if ((sscbrg < 0x07u) || (sscbrg > (0x1u << 16)))
	{
		printk("ERROR: Unable to set SSC buad-rate generator to 0x%04x\n",
			sscbrg);
		return;
	}
	/* TODO: program pre-scaler for slower baud rates */
	if (sscbrg == (0x1 << 16)) /* 16-bit counter wraps */
	{
		sscbrg = 0x0;	/* slowest possible clock frequency */
	}
	ssc_write(SSC_BRG,sscbrg);
#if 0	/* QQQ */
	printk("info: fcomms=%uMHz, SPI=%uHz, brg=0x%04x\n",
		fcomms/1000/1000, hz, sscbrg);
#endif

	/* Disable I2C sub-system */
	ssc_write( SSC_I2C, 0x0);

	/* Perform a S/W reset the SSC */
	reg = ssc_read( SSC_CON);
	reg |= SSC_CON_SR;		/* enable software reset */
	ssc_write( SSC_CON, reg);
	udelay(1);			/* let reset propagate */
	reg = ssc_read( SSC_CON);
	reg &= ~SSC_CON_SR;		/* disable software reset */
	ssc_write( SSC_CON, reg);

	/* Configure & enable the SSC's control register */
	reg = ssc_read(SSC_CON);
	reg |= SSC_CON_EN;		/* Enable the SSC */
	reg |= SSC_CON_MS;		/* set SSC as the SPI master */
	if (mode & SPI_CPOL)
		reg |= SSC_CON_PO;	/* Clock idles at logic 1 */
	else
		reg &= ~SSC_CON_PO;	/* Clock idles at logic 0 */
	if (mode & SPI_CPHA)
		reg |= SSC_CON_PH;	/* Pulse in first half-cycle */
	else
		reg &= ~SSC_CON_PH;	/* Pulse in second half-cycle */
	if (mode & SPI_LSB_FIRST)
		reg &= ~SSC_CON_HB;	/* LSB first */
	else
		reg |= SSC_CON_HB;	/* MSB first */
	if (mode & SPI_LOOP)
		reg |= SSC_CON_LPB;	/* put SSC in loop-back mode */
	else
		reg &= ~SSC_CON_LPB;	/* remove SSC from loop-back mode */
	reg &= ~0x0ful;			/* set bit width */
	reg |= (bits_per_word - 1ul);	/* set bit width */
	ssc_write(SSC_CON,reg);

	/* clear the status register */
	(void)ssc_read(SSC_RBUF);
#endif	/* CONFIG_SOFT_SPI */

	/* now probe the serial flash, to ensure it is the correct one */
	spi_probe_serial_flash(chipsel);
}