From dc15a203ee335805b26687bef48202a25690dbce Mon Sep 17 00:00:00 2001 From: Chanho Park Date: Tue, 8 Dec 2015 10:15:11 +0900 Subject: [PATCH] board: artik5: initialize ax88796c spi ethernet This patsh supports initialization of ax88796c spi ethernet driver for artik5. It requires to control a cs gpio pin according to cs activation/deactivation. Change-Id: I6ac0dbcad20ae46ee1f217e47e31252d176a0b4b Signed-off-by: Jaeyong Lee Signed-off-by: Chanho Park --- board/samsung/espresso3250/espresso3250.c | 59 +++++++++++++++++++++++ drivers/spi/exynos_spi.c | 10 ++++ 2 files changed, 69 insertions(+) diff --git a/board/samsung/espresso3250/espresso3250.c b/board/samsung/espresso3250/espresso3250.c index 46a1a8de6..28f3debab 100644 --- a/board/samsung/espresso3250/espresso3250.c +++ b/board/samsung/espresso3250/espresso3250.c @@ -171,10 +171,69 @@ void dram_init_banksize(void) PHYS_SDRAM_8_SIZE); } +#ifdef CONFIG_DRIVER_AX88796C_SPI +static int artik5_ax88796c_gpio_reset(void) +{ + struct exynos3_gpio_part2 *gpio2 = + (struct exynos3_gpio_part2 *) samsung_get_base_gpio_part2(); + struct s5p_gpio_bank *bank; + + /* set reset */ + bank = &gpio2->e0; + s5p_gpio_direction_output(bank, 2, 0); + mdelay(10); + s5p_gpio_direction_output(bank, 2, 1); + mdelay(10); + + return 0; +} + +#define CS_HIGH (0) /* 0: low active, 1: high active */ + +int artik5_ax88796c_cs_activate(void) +{ + struct exynos3_gpio_part2 *gpio2 = + (struct exynos3_gpio_part2 *) samsung_get_base_gpio_part2(); + struct s5p_gpio_bank *bank; + + bank = &gpio2->x3; + s5p_gpio_direction_output(bank, 4, CS_HIGH ? 1 : 0); + + return 0; +} + +int artik5_ax88796c_cs_deactivate(void) +{ + struct exynos3_gpio_part2 *gpio2 = + (struct exynos3_gpio_part2 *) samsung_get_base_gpio_part2(); + struct s5p_gpio_bank *bank; + + bank = &gpio2->x3; + s5p_gpio_direction_output(bank, 4, CS_HIGH ? 0 : 1); + + return 0; +} + +int board_eth_init(bd_t *bis) +{ + int rc = 0; + int num = 0; + + artik5_ax88796c_gpio_reset(); + + rc = ax88796c_spi_initialize(AX88796C_SPI_BUS, AX88796C_SPI_CS, + AX88796C_MAX_HZ, AX88796C_SPI_MODE); + if (!rc) + num++; + + return num; +} +#else /* CONFIG_DRIVER_AX88796C_SPI */ int board_eth_init(bd_t *bis) { return 0; } +#endif /* CONFIG_DRIVER_AX88796C_SPI */ #ifdef CONFIG_DISPLAY_BOARDINFO int checkboard(void) diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index 3e6c18f87..3560bb419 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -310,6 +310,9 @@ int spi_cs_is_valid(unsigned int bus, unsigned int cs) return spi_get_bus(bus) && cs == 0; } +extern int artik5_ax88796c_cs_activate(void); +extern int artik5_ax88796c_cs_deactivate(void); + /** * Activate the CS by driving it LOW * @@ -320,6 +323,10 @@ void spi_cs_activate(struct spi_slave *slave) { struct exynos_spi_slave *spi_slave = to_exynos_spi(slave); +#ifdef CONFIG_MACH_ARTIK5 + artik5_ax88796c_cs_activate(); +#endif + clrbits_le32(&spi_slave->regs->cs_reg, SPI_SLAVE_SIG_INACT); debug("Activate CS, bus %d\n", spi_slave->slave.bus); } @@ -334,6 +341,9 @@ void spi_cs_deactivate(struct spi_slave *slave) { struct exynos_spi_slave *spi_slave = to_exynos_spi(slave); +#ifdef CONFIG_MACH_ARTIK5 + artik5_ax88796c_cs_deactivate(); +#endif setbits_le32(&spi_slave->regs->cs_reg, SPI_SLAVE_SIG_INACT); debug("Deactivate CS, bus %d\n", spi_slave->slave.bus); } -- 2.34.1