RobertCNelson / stable-kernel

MIT License
74 stars 39 forks source link

[PATCH] add spidev for panda using buddy=spidev #22

Closed aferre closed 11 years ago

aferre commented 11 years ago

Hello Robert,

I've made a patch to enable spidev on pandaboards using buddy=spidev just like for beagle.

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index 92bb6b4..6463eea 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -22,6 +22,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/leds.h>
+#include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/usb/otg.h>
 #include <linux/i2c/twl.h>
@@ -37,6 +38,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <video/omapdss.h>
+#include <linux/spi/spi.h>

 #include "common.h"
 #include <plat/usb.h>
@@ -57,6 +59,8 @@
 #define HDMI_GPIO_LS_OE 41 /* Level shifter for HDMI */
 #define HDMI_GPIO_HPD  63 /* Hotplug detect */

+char expboard_name[16];
+
 /* wl127x BT, FM, GPS connectivity chip */
 static struct ti_st_plat_data wilink_platform_data = {
    .nshutdown_gpio = 46,
@@ -102,6 +106,25 @@ static struct platform_device leds_gpio = {
    },
 };

+static struct spi_board_info panda_mcspi_board_info[] = {
+   /* spi 1.0 */
+   {
+       .modalias   = "spidev",
+       .max_speed_hz   = 48000000, //48 Mbps
+       .bus_num    = 1,
+       .chip_select    = 0,
+       .mode = SPI_MODE_1,
+   },
+   /* spi 1.1 */
+   {
+       .modalias   = "spidev",
+       .max_speed_hz   = 48000000, //48 Mbps
+       .bus_num    = 1,
+       .chip_select    = 1,
+       .mode = SPI_MODE_1,
+   },
+};
+
 static struct omap_abe_twl6040_data panda_abe_audio_data = {
    /* Audio out */
    .has_hs     = ABE_TWL6040_LEFT | ABE_TWL6040_RIGHT,
@@ -159,6 +182,18 @@ static struct gpio panda_ehci_gpios[] __initdata = {
    { GPIO_HUB_NRESET,  GPIOF_OUT_INIT_LOW,  "hub_nreset" },
 };

+static int __init expansionboard_setup(char *str)
+{
+   if (!machine_is_omap4_panda())
+       return 0;
+
+   if (!str)
+       return -EINVAL;
+   strncpy(expboard_name, str, 16);
+   pr_info("Panda expansionboard: %s\n", expboard_name);
+   return 0;
+}
+
 static void __init omap4_ehci_init(void)
 {
    int ret;
@@ -514,10 +549,17 @@ static void __init omap4_panda_init(void)
    omap_sdrc_init(NULL, NULL);
    omap4_twl6030_hsmmc_init(mmc);
    omap4_ehci_init();
+   if (!strcmp(expboard_name, "spidev"))
+   {
+       pr_info("Panda expansionboard: spidev: enabling spi3/spi4\n");
+       spi_register_board_info(panda_mcspi_board_info, ARRAY_SIZE(panda_mcspi_board_info));
+   }
    usb_musb_init(&musb_board_data);
    omap4_panda_display_init();
 }

+early_param("buddy", expansionboard_setup);
+
 MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
    /* Maintainer: David Anders - Texas Instruments Inc */
    .atag_offset    = 0x100,
RobertCNelson commented 11 years ago

Thanks Adrien!!

Just pushed the patch out and queued it on the build farm, so it'll be enabled for friday's image.. ;)

https://github.com/RobertCNelson/stable-kernel/commit/f9cbc99210bdd68b4c147851c82ed62f3b672262