km/spi: overwrite kirkwood_spi weak functions for KM Kirkwood boards
[oweals/u-boot.git] / board / keymile / km_arm / km_arm.c
index ea03be9eb37cf30c5223ae81d31cb7543bd438b4..7087cc520fdb04b6755cfe2219c0c19e61ab26ef 100644 (file)
@@ -322,6 +322,37 @@ void board_spi_release_bus(struct spi_slave *slave)
        kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1);
 }
 
+static const u32 spi_mpp_config[] = {
+       MPP1_SPI_MOSI,
+       MPP2_SPI_SCK,
+       MPP3_SPI_MISO,
+       0
+};
+
+static u32 spi_mpp_backup[4];
+
+int mvebu_board_spi_claim_bus(struct udevice *dev)
+{
+       spi_mpp_backup[3] = 0;
+
+       /* set new spi mpp config and save current one */
+       kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
+
+       kw_gpio_set_value(KM_FLASH_GPIO_PIN, 0);
+
+       return 0;
+}
+
+int mvebu_board_spi_release_bus(struct udevice *dev)
+{
+       /* restore saved mpp config */
+       kirkwood_mpp_conf(spi_mpp_backup, NULL);
+
+       kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1);
+
+       return 0;
+}
+
 #if (defined(CONFIG_KM_PIGGY4_88E6061))
 
 #define        PHY_LED_SEL_REG         0x18