hancock: prepare spi driver for ethernet switch configuration

- enable spi1 unit peripheral clock
- add test function for hw integration
This commit is contained in:
Rene Straub 2018-06-07 08:52:47 +02:00
parent 6ec76da94a
commit b85f04e84a
4 changed files with 46 additions and 7 deletions

View File

@ -171,6 +171,7 @@ void enable_basic_clocks(void)
&cmper->emiffwclkctrl,
&cmper->emifclkctrl,
&cmper->i2c2clkctrl,
&cmper->spi1clkctrl,
0
};

View File

@ -27,6 +27,7 @@
#include <asm/emif.h>
#include <asm/gpio.h>
#include <i2c.h>
#include <spi.h>
#include <pca953x.h>
#include <miiphy.h>
#include <cpsw.h>
@ -72,6 +73,7 @@ DECLARE_GLOBAL_DATA_PTR;
#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
/* TODO: Rename -> Remove NETBIRD */
#define NETBIRD_LED0_RED GPIO_TO_PIN(0, 30)
#define NETBIRD_LED0_GREEN GPIO_TO_PIN(1, 28)
#define NETBIRD_LED1_RED GPIO_TO_PIN(1, 24)
@ -117,8 +119,8 @@ DECLARE_GLOBAL_DATA_PTR;
* I2C IO Extender (On UI Interface)
*/
#define IOEXT_LED1_GREEN_MASK (1U << 6)
#define IOEXT_LED1_RED_MASK (1U << 7)
#define IOEXT_LED1_GREEN_MASK (1U << 6)
#define IOEXT_LED2_RED_MASK (1U << 8)
#define IOEXT_LED2_GREEN_MASK (1U << 9)
#define IOEXT_LEDS_ALL_MASK (0x03C0)
@ -196,6 +198,7 @@ static void init_indicator_leds(void)
}
#endif
/* TODO: Remove from SPL build */
static void set_indicator(unsigned led, int red, int green)
{
#if 0
@ -238,7 +241,7 @@ struct serial_device *default_serial_console(void)
}
else {
enable_uart2_pin_mux();
return &eserial2_device;
return &eserial3_device;
}
}
@ -709,6 +712,31 @@ static void check_reset_button(void)
#endif /* !defined(CONFIG_SPL_BUILD) */
static void spi_test1(void)
{
const uint8_t data[] = { 0xFF, 0xAA, 0x00 };
struct spi_slave *spi;
int rc;
printf("SPI test\n");
spi_init();
spi = spi_setup_slave(CONFIG_SJA1105_SPI_BUS /*bus*/,
CONFIG_SJA1105_SPI_CS /*cs*/,
1000000 /*max_hz*/,
SPI_MODE_0 /*spi_mode*/);
/* TODO: Check SPI_MODE */
spi_claim_bus(spi);
rc = spi_xfer(spi, 8*sizeof(data) /*bitlen*/, data, NULL /*din*/, SPI_XFER_BEGIN | SPI_XFER_END /*flags*/);
printf("spi_xfer %d\n", rc);
spi_release_bus(spi);
}
int board_late_init(void)
{
#if !defined(CONFIG_SPL_BUILD)

View File

@ -17,7 +17,6 @@
* is required on the board.
*/
void enable_uart0_pin_mux(void);
/*void disable_uart0_pin_mux(void);*/
/*
* void enable_uart1_pin_mux(void);
*/

View File

@ -105,12 +105,14 @@
#endif
/* UART Configuration */
#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot, Shield */
#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: eMMC Boot, User UART */
#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot */
#define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2: eMMC Boot, User UART */
/* TODO: Check COM3 register address, Check COM3/UART2 clock enable !! */
#define CONFIG_I2C
#define CONFIG_I2C_MULTI_BUS
/* TODO: Check I2C Bus for EEPROM */
#define CONFIG_CMD_EEPROM
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* Main EEPROM */
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
@ -119,7 +121,7 @@
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 50 /* TODO: Can this be reduced to 20ms */
#define CONFIG_PCA953X
#define CONFIG_SYS_I2C_PCA953X_BUS 2
#define CONFIG_SYS_I2C_PCA953X_BUS 1
#define CONFIG_SYS_I2C_PCA953X_ADDR 0x74
#define CONFIG_SYS_I2C_PCA953X_WIDTH { {0x74, 16} }
#define CONFIG_CMD_PCA953X
@ -144,6 +146,13 @@
#undef CONFIG_SPL_ONENAND_SUPPORT
/* We need to disable SPI to not confuse the eeprom env driver */
/* TODO: Double check */
/* SPI IP Block */
#define CONFIG_OMAP3_SPI /* Already define in ti_armv7_omap.h, included by ti_am335x_common.h */
#define CONFIG_SJA1105_SPI_BUS 1 /* bus 1 = spi1 = McSPI2 */
#define CONFIG_SJA1105_SPI_CS 1 /* SJA1105 uses CS1~ */
#undef CONFIG_SPI
#undef CONFIG_SPI_BOOT
#undef CONFIG_SPL_OS_BOOT
@ -216,10 +225,12 @@
#define CONFIG_PHYLIB
/* Ethernet Switch Support */
/* TODO: Revert to SMSC 8720 PHY */
#if 0
#define CONFIG_MV88E60XX_SWITCH
#define CONFIG_MV88E60XX_PHY_PORTS 0x0F
#define CONFIG_MV88E60XX_CPU_PORT 5
#endif
#define CONFIG_SYS_MEMTEST_START 0x80000000
#define CONFIG_SYS_MEMTEST_END 0x87900000