Created
February 3, 2016 21:21
-
-
Save FantomJAC/69c3e963580e939b0615 to your computer and use it in GitHub Desktop.
Enable SPI CS0 (spidev5.0) on Intel Edison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig | |
index 82b8dca..e1a4789 100644 | |
--- a/arch/x86/Kconfig | |
+++ b/arch/x86/Kconfig | |
@@ -457,6 +457,9 @@ config X86_INTEL_MID | |
nor standard legacy replacement devices/features. e.g. It does not | |
contain i8259, i8254, HPET, legacy BIOS, most of the io ports. | |
+config INTEL_MID_FORCE_SPIDEV | |
+ bool "Force spidev" | |
+ | |
config X86_MDFLD | |
bool "Medfield MID platform" | |
depends on X86_INTEL_MID | |
diff --git a/arch/x86/configs/i386_edison_defconfig b/arch/x86/configs/i386_edison_defconfig | |
index 4e68b91..da0f0a0 100644 | |
--- a/arch/x86/configs/i386_edison_defconfig | |
+++ b/arch/x86/configs/i386_edison_defconfig | |
@@ -322,6 +322,7 @@ CONFIG_X86_EXTENDED_PLATFORM=y | |
# CONFIG_X86_GOLDFISH is not set | |
CONFIG_X86_WANT_INTEL_MID=y | |
CONFIG_X86_INTEL_MID=y | |
+CONFIG_INTEL_MID_FORCE_SPIDEV=y | |
# CONFIG_X86_MDFLD is not set | |
CONFIG_ATOM_SOC_POWER=y | |
# CONFIG_REMOVEME_INTEL_ATOM_MDFLD_POWER is not set | |
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_ads7955.c b/arch/x86/platform/intel-mid/device_libs/platform_ads7955.c | |
index c0d07aa..b0daafa 100644 | |
--- a/arch/x86/platform/intel-mid/device_libs/platform_ads7955.c | |
+++ b/arch/x86/platform/intel-mid/device_libs/platform_ads7955.c | |
@@ -17,13 +17,53 @@ | |
#include <asm/intel-mid.h> | |
#include "platform_ads7955.h" | |
+#ifdef CONFIG_INTEL_MID_FORCE_SPIDEV | |
+static void tng_ssp_spi_cs_control(u32 command); | |
+static void tng_ssp_spi_platform_pinmux(void); | |
+ | |
+static int tng_ssp_spi2_FS_gpio = 110; | |
+#endif | |
+ | |
static struct intel_mid_ssp_spi_chip chip = { | |
.burst_size = DFLT_FIFO_BURST_SIZE, | |
.timeout = DFLT_TIMEOUT_VAL, | |
+#ifdef CONFIG_INTEL_MID_FORCE_SPIDEV | |
+ /* SPI DMA is currently usable on Tangier */ | |
+ .dma_enabled = true, | |
+ .cs_control = tng_ssp_spi_cs_control, | |
+ .platform_pinmux = tng_ssp_spi_platform_pinmux, | |
+#else | |
/* SPI DMA is current not usable on Tangier */ | |
.dma_enabled = false, | |
+#endif | |
}; | |
+#ifdef CONFIG_INTEL_MID_FORCE_SPIDEV | |
+static void tng_ssp_spi_cs_control(u32 command) | |
+{ | |
+ gpio_set_value(tng_ssp_spi2_FS_gpio, (command != 0) ? 1 : 0); | |
+} | |
+ | |
+static void tng_ssp_spi_platform_pinmux(void) | |
+{ | |
+ int err; | |
+ int saved_muxing; | |
+ /* Request Chip Select gpios */ | |
+ saved_muxing = gpio_get_alt(tng_ssp_spi2_FS_gpio); | |
+ | |
+ lnw_gpio_set_alt(tng_ssp_spi2_FS_gpio, LNW_GPIO); | |
+ err = gpio_request_one(tng_ssp_spi2_FS_gpio, | |
+ GPIOF_DIR_OUT|GPIOF_INIT_HIGH, "Minibreakout FS0"); | |
+ if (err) { | |
+ pr_err("%s: unable to get Chip Select GPIO,\ | |
+ fallback to legacy CS mode \n", __func__); | |
+ lnw_gpio_set_alt(tng_ssp_spi2_FS_gpio, saved_muxing); | |
+ chip.cs_control = NULL; | |
+ chip.platform_pinmux = NULL; | |
+ } | |
+} | |
+#endif | |
+ | |
void __init *ads7955_platform_data(void *info) | |
{ | |
struct spi_board_info *spi_info = info; | |
@@ -32,6 +72,9 @@ void __init *ads7955_platform_data(void *info) | |
spi_info->controller_data = &chip; | |
spi_info->bus_num = FORCE_SPI_BUS_NUM; | |
+#ifdef CONFIG_INTEL_MID_FORCE_SPIDEV | |
+ spi_info->chip_select = FORCE_CHIP_SELECT; | |
+#endif | |
return NULL; | |
} | |
diff --git a/arch/x86/platform/intel-mid/intel_mid_sfi.c b/arch/x86/platform/intel-mid/intel_mid_sfi.c | |
index f73b84e..429c1bf 100644 | |
--- a/arch/x86/platform/intel-mid/intel_mid_sfi.c | |
+++ b/arch/x86/platform/intel-mid/intel_mid_sfi.c | |
@@ -375,6 +375,12 @@ static void __init sfi_handle_spi_dev(struct sfi_device_table_entry *pentry, | |
memset(&spi_info, 0, sizeof(spi_info)); | |
strncpy(spi_info.modalias, pentry->name, SFI_NAME_LEN); | |
+#ifdef CONFIG_INTEL_MID_FORCE_SPIDEV | |
+ if (strncmp(spi_info.modalias, "ads7955", SFI_NAME_LEN) == 0) { | |
+ pr_info("Use ads7955 as spidev\n"); | |
+ strncpy(spi_info.modalias, "spidev", SFI_NAME_LEN); | |
+ } | |
+#endif | |
spi_info.irq = ((pentry->irq == (u8)0xff) ? 0 : pentry->irq); | |
spi_info.bus_num = pentry->host_num; | |
spi_info.chip_select = pentry->addr; |
@ecc1, I started doing such for upstream, but realized, that is waste of time since we are working on open connected board. And thus I postponed such until we will have ACPI in place. Regarding to the topic, the idea as I can see just to override ADS7955 file to mimic spidev. Have you enabled config option for that?
UPDATE. Have got an ACPI excerpt to enable it. Though don't know how to test it yet. (It required couple of patches to the driver still)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to use this in a rebuild of linux-yocto kernel from edison-src-ww25.5-15.tgz. But when I boot I still only see /dev/spidev5.1. Is there anything else I need to configure so that I see both spidev5.0 and spidev5.1? Thanks