board: artik5: initialize ax88796c spi ethernet
authorChanho Park <chanho61.park@samsung.com>
Tue, 8 Dec 2015 01:15:11 +0000 (10:15 +0900)
committerChanho Park <chanho61.park@samsung.com>
Tue, 8 Dec 2015 01:51:08 +0000 (10:51 +0900)
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 <jaeyong2.lee@samsung.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
board/samsung/espresso3250/espresso3250.c
drivers/spi/exynos_spi.c

index 46a1a8de6b07e1be0eb0b9d8d2cb91aaa5b0ef34..28f3debabe7c219e6462eb081186997e8b84ab67 100644 (file)
@@ -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)
index 3e6c18f87f1819cc85c93684fe8215cdb3d3c64b..3560bb419dfb8a5de8a9865bdda021566e0c7ea9 100644 (file)
@@ -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);
 }