@@ -1,6 +1,20 @@
#ifndef _OMAP2_MCSPI_H
#define _OMAP2_MCSPI_H
+/**
+ * struct omap2_mcspi_csinfo - Chip Select description
+ * @line: Custom 'identity' of the CS line
+ * @set_level: Function to set the state of a given CS line
+ *
+ * This is to allow use of GPIO lines as CS lines. Allocate and initialize one
+ * in the machine init code and make spi_board_info.controller_data point to
+ * it.
+ */
+struct omap2_mcspi_csinfo {
+ unsigned line;
+ void (*set_level)(unsigned line_id, int lvl);
+};
+
struct omap2_mcspi_platform_config {
unsigned short num_cs;
};
@@ -35,6 +35,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
+#include <linux/gpio.h>
#include <plat/dma.h>
#include <plat/clock.h>
@@ -235,11 +236,14 @@ static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable)
static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active)
{
- u32 l;
-
- l = mcspi_cached_chconf0(spi);
- MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
- mcspi_write_chconf0(spi, l);
+ if (spi->controller_data) {
+ struct omap2_mcspi_csinfo *csinfo = spi->controller_data;
+ (*csinfo->set_level)(csinfo->line, cs_active);
+ } else {
+ u32 l = mcspi_cached_chconf0(spi);
+ MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
+ mcspi_write_chconf0(spi, l);
+ }
}
static void omap2_mcspi_set_master_mode(struct spi_master *master)