ltib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Ltib] SPI missing


From: Kevin Wells
Subject: RE: [Ltib] SPI missing
Date: Wed, 1 Sep 2010 00:43:03 +0200

Hi Jorge,

 

You can try this patch for FDI and 2.6.27.8. It adds SPIDEV support and fixes a few other things.

If you do use it, you’ll need to add the ethaddr=00:01:02:03:04:05 parameters to bootargs in u-boot. Pick your own MAC address.

 

thanks,

Kevin

 

diff -Naur -X linux-2.6.27.8/Documentation/dontdiff linux-2.6.27.8-orig/arch/arm/mach-lpc32xx/board-arm9dimm3250.c linux-2.6.27.8/arch/arm/mach-lpc32xx/board-arm9dimm3250.c

--- linux-2.6.27.8-orig/arch/arm/mach-lpc32xx/board-arm9dimm3250.c 2010-08-31 08:20:09.411260348 -0700

+++ linux-2.6.27.8/arch/arm/mach-lpc32xx/board-arm9dimm3250.c       2010-08-31 08:32:26.769260136 -0700

@@ -29,6 +29,7 @@

 #include <linux/input.h>

 #include <linux/device.h>

 #include <linux/delay.h>

+#include <linux/spi/spi.h>

 

 #include <mach/hardware.h>

 #include <asm/setup.h>

@@ -51,23 +52,6 @@

 #define BOARDDEBUG

 

 /*

- * Structure used to define the hardware for the Phytec board. This

- * is obtained from index (SOM9DIMM3250_SEEPROM_CFGOFS) in the AT25 serial

- * EEPROM. The .fieldval value must be checked for the correct value

- * (ARM9DIMM_HW_VER_VAL) or the sturcture is invalid.

- */

-typedef struct

-{

-  u32 dramcfg;    /* DRAM config word */

-  u32 syscfg;     /* Configuration word */

-  /* MAC address, use lower 6 bytes only, index 0 is first byte */

-  u8  mac[8];     /* Only the first 6 are used */

-  u32 rsvd [5];   /* Reserved, must be 0 */

-  u32 fieldvval;  /* Must be ARM9DIMM_HW_VER_VAL */

-} ARM9DIMM_HW_T;

-static ARM9DIMM_HW_T arm9dimmhwdata;

-

-/*

  * Serial EEPROM support

  */

 #define ARM9DIMM_HW_VER_VAL 0x000A3250

@@ -264,11 +248,14 @@

                },

 

 };

+static u64 lpc32xx_slc_dma_mask = 0xffffffffUL;

 static struct platform_device slc_nand_device = {

                .name                   = "lpc32xx-nand",

                .id                           = 0,

                .dev                       = {

                                                                .platform_data = &lpc32xx_nandcfg,

+                                .dma_mask    = &lpc32xx_slc_dma_mask,

+                                .coherent_dma_mask = ~0UL,

                },

                .num_resources               = ARRAY_SIZE(slc_nand_resources),

                .resource             = slc_nand_resources,

@@ -436,25 +423,41 @@

  * Network configuration structure

  */

 #if defined (CONFIG_LPC32XX_MII)

-static int return_mac_address(u8 *mac)

+/* MAC address is provided as a boot paramter (ethaddr) via u-boot */

+static u8 mac_address[6] = {0x00, 0x1a, 0xf1, 0x00, 0x00, 0x00};

+

+static int __init set_ethaddr(char *str)

 {

-              int ret = 0;

+             char *s, *e;

                int i;

 

-              if (arm9dimmhwdata.fieldvval != ARM9DIMM_HW_VER_VAL)

-              {

-                              /* Field has garbage in it */

-                              printk(KERN_ERR "Invalid ethernet MAC address\n");

-                              ret = -ENODEV;

-              }

+             s = str;

 

-              /* Use MAC address from hardware descriptor */

-              for (i = 0; i < 6; i++)

-              {

-                              mac [i] = arm9dimmhwdata.mac [i];

+             for (i = 0; i < 6; ++i) {

+                             mac_address[i] = s ? simple_strtoul (s, &e, 16) : 0;

+                             if (s)

+                                             s = (*e) ? e + 1 : e;

                }

 

-              return ret;

+             return 1;

+}

+

+static int __init ea_ethaddr_new(char *str)

+{

+             return set_ethaddr(str);

+}

+__setup("ethaddr=", ea_ethaddr_new);

+

+static int return_mac_address(u8 *mac)

+{

+             mac[0] = mac_address[0];

+             mac[1] = mac_address[1];

+             mac[2] = mac_address[2];

+             mac[3] = mac_address[3];

+             mac[4] = mac_address[4];

+             mac[5] = mac_address[5];

+

+             return 0;

 }

 

 struct lpc32xx_net_cfg lpc32xx_netdata =

@@ -550,58 +553,89 @@

 };

 #endif

 

-#if defined(CONFIG_RTC_DRV_PCF8563)

-static struct i2c_board_info __initdata arm9dimm3250_i2c_board_info [] = {

-              {

-                              I2C_BOARD_INFO("rtc-pcf8563", 0x51),

-              },

-};

-#endif

-

-static struct i2c_board_info __initdata armtskit_i2c2_board_info[] = {

-              {

-                              I2C_BOARD_INFO("pca24s08", 0x54),

-              },

-};

-

-/*

- * Load the board hardware descriptor from the serial EEPROM

- */

-static void __init arm9dimm3250_load_hw_desc(void)

+#if defined(CONFIG_SPI_LPC32XX)

+static void fdi_spi_cs_setup(int cs)

 {

-              u32 svclk, tmp, addr;

-              int i, len;

-              u8 *p8, cmd [4], in [4];

-

-    // Setup default values for the arm9dimmhwdata structure

-    arm9dimmhwdata.dramcfg = 1;

-    arm9dimmhwdata.syscfg = 2;

-    arm9dimmhwdata.mac[0] = 0x00;

-    arm9dimmhwdata.mac[1] = 0x11;

-    arm9dimmhwdata.mac[2] = 0x22;

-    arm9dimmhwdata.mac[3] = 0x33;

-    arm9dimmhwdata.mac[4] = 0x44;

-    arm9dimmhwdata.mac[5] = 0x55;

-    arm9dimmhwdata.fieldvval = ARM9DIMM_HW_VER_VAL;

+             /* Setup SPI CS0 as an output on GPIO5 */

+             __raw_writel((1 << 5), GPIO_P2_MUX_CLR(GPIO_IOBASE));

 

-              if (arm9dimmhwdata.fieldvval != ARM9DIMM_HW_VER_VAL)

+             /* Set chip select high */

+             __raw_writel(OUTP_STATE_GPIO(5),

+                             GPIO_P3_OUTP_SET(GPIO_IOBASE));

+}

+static int fdi_spi_cs_set(int cs, int state)

+{

+             if (cs == 0)

                {

-                              printk(KERN_ERR "Invalid board descriptor!\n");

+                             if (state != 0)

+                             {

+                                             /* Set chip select high */

+                                             __raw_writel(OUTP_STATE_GPIO(5),

+                                                             GPIO_P3_OUTP_SET(GPIO_IOBASE));

+                             }

+                             else

+                             {

+                                             /* Set chip select low */

+                                             __raw_writel(OUTP_STATE_GPIO(5),

+                                                             GPIO_P3_OUTP_CLR(GPIO_IOBASE));

+                             }

                }

-#if defined (BOARDDEBUG)

                else

                {

-                              printk(KERN_INFO "Hardware descriptor info:\n");

-                              printk(KERN_INFO " DRAM config word: 0x%08x\n", arm9dimmhwdata.dramcfg);

-                              printk(KERN_INFO " syscfg word:      0x%08x\n", arm9dimmhwdata.syscfg);

-                              printk(KERN_INFO " fieldval word:    0x%08x\n", arm9dimmhwdata.fieldvval);

-                              printk(KERN_INFO " MAC address:      ");

-                              printk(KERN_INFO "%02x:%02x:%02x:%02x:%02x:%02x\n",

-                                              arm9dimmhwdata.mac [0], arm9dimmhwdata.mac [1], arm9dimmhwdata.mac [2],

-                                              arm9dimmhwdata.mac [3], arm9dimmhwdata.mac [4], arm9dimmhwdata.mac [5]);

+                             /* Invalid chip select */

+                             return -ENODEV;

                }

+

+             return 0;

+}

+

+struct lpc32xx_spi_cfg lpc32xx_spi0data =

+{

+             .num_cs                               = 1, /* Only 1 chip select */

+             .spi_cs_setup    = &fdi_spi_cs_setup,

+             .spi_cs_set         = &fdi_spi_cs_set,

+};

+

+/* SPI driver registration */

+static int __init fdi_spi_board_register(void)

+{

+#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)

+             struct spi_board_info info =

+             {

+                             .modalias = "spidev",

+                             .max_speed_hz = 5000000,

+                             .bus_num = 0,

+                             .chip_select = 0,

+             };

+

+             return spi_register_board_info(&info, 1);

 #endif

 }

+arch_initcall(fdi_spi_board_register);

+

+static struct resource ssp0_resources[] = {

+             [0] = {

+                             .start     = SSP0_BASE,

+                             .end       = SSP0_BASE + SZ_4K - 1,

+                             .flags     = IORESOURCE_MEM,

+             },

+             [1] = {

+                             .start     = IRQ_SSP0,

+                             .end       = IRQ_SSP0,

+                             .flags     = IORESOURCE_IRQ,

+             },

+

+};

+static struct platform_device ssp0_device = {

+             .name                   = "spi_lpc32xx",

+             .id                           = 0,

+             .dev                       = {

+                             .platform_data = &lpc32xx_spi0data,

+             },

+             .num_resources               = ARRAY_SIZE(ssp0_resources),

+             .resource             = ssp0_resources,

+};

+#endif

 

 static struct platform_device* arm9dimm3250_devs[] __initdata = {

 #if defined(CONFIG_SPI_LPC32XX)

@@ -669,22 +703,12 @@

                tmp |= CLKPWR_I2CCLK_USBI2CHI_DRIVE | CLKPWR_I2CCLK_I2C2HI_DRIVE | CLKPWR_I2CCLK_I2C1HI_DRIVE;

                __raw_writel(tmp, CLKPWR_I2C_CLK_CTRL(CLKPWR_IOBASE));

 

-              /* Enable DMA for I2S1 channel */

-              tmp = __raw_readl(CLKPWR_I2S_CLK_CTRL(CLKPWR_IOBASE));

-              tmp = CLKPWR_I2SCTRL_I2S1_USE_DMA;

-              __raw_writel(tmp, CLKPWR_I2S_CLK_CTRL(CLKPWR_IOBASE));

-

-              /* Load the board hardware descriptor, as some other board functions

-                 require it's data */

-              arm9dimm3250_load_hw_desc();

-

                /* Call chip specific init */

                lpc32xx_init();

 

                /* Add board platform devices */

                platform_add_devices (arm9dimm3250_devs, ARRAY_SIZE (arm9dimm3250_devs));

 

-

 #if defined(CONFIG_MMC_ARMMMCI)

                /* Enable SD card clock so AMBA driver will work correctly. The

                   AMBA driver needs the clock before the SD card controller

@@ -712,20 +736,6 @@

                tmp = __raw_readl(UARTCTL_CTRL(io_p2v(UART_CTRL_BASE)));

                tmp &= ~UART_U5_ROUTE_TO_USB;

                __raw_writel(tmp, UARTCTL_CTRL(io_p2v(UART_CTRL_BASE)));

-

-#if defined (CONFIG_SND_LPC3XXX_SOC)

-              /* Test clock needed for UDA1380 */

-              __raw_writel((CLKPWR_TESTCLK2_SEL_MOSC | CLKPWR_TESTCLK_TESTCLK2_EN),

-                              CLKPWR_TEST_CLK_SEL(CLKPWR_IOBASE));

-#endif

-

-#if defined(CONFIG_RTC_DRV_PCF8563)

-              /* I2C based RTC device on I2C1 */

-//          i2c_register_board_info(0, arm9dimm3250_i2c_board_info,

-//                                                          ARRAY_SIZE(arm9dimm3250_i2c_board_info));

-#endif

-//          i2c_register_board_info(1, armtskit_i2c2_board_info,

-//                                                          ARRAY_SIZE(armtskit_i2c2_board_info));

 }

 

 MACHINE_START (LPC3XXX, "FDI ARM-TS-KIT 3250 board with the LPC3250 Microcontroller")

 

 

 

From: Jorge A. Castro [mailto:address@hidden
Sent: Thursday, August 26, 2010 9:25 AM
To: Kevin Wells
Cc: address@hidden
Subject: Re: [Ltib] SPI missing

 

Hi Kevin,

It sounds awesome! Thanks a lot Kevin.

Regards

Jorge

On 08/26/2010 09:57 AM, Kevin Wells wrote:

 

Hi Jorge,

 

I’ll (try to) post a patch for this later today. Better yet, I’ll post a patch that adds full 2.6.34 support on the LTIB menu for the FDI board next week!

 

thanks,

Kevin

 

 

Subject: Re: [Ltib] SPI missing

 

Hi Kevin,

That it's remarkable! What I'm not pretty sure is when you refer to "Add the necessary SPI support file". I saw the board-phy3250.c file and I found several lines of code with stuff referring to SPI. Do I need to add all of them? And what about registering the SPI devices, do you mean the hardware wich is in the board?

Thank a lot for your answers and help!!!

Regards

Jorge Castro

On 08/25/2010 12:22 PM, Kevin Wells wrote:

 

Hi Jorge,

 

I just looked at the FDI support for SPI and it’s not in the board-arm9dimm3250.c file.

The SPI interface won’t work without a platform driver registered for it.

 

This is what I found in the file…

606 static struct platform_device* arm9dimm3250_devs[] __initdata = {

 607 #if defined(CONFIG_SPI_LPC32XX)

 608         &ssp0_device,

 609 #endif

 610 #if defined(CONFIG_KEYBOARD_LPC32XX)

 611         &kscan_device,

 612 #endif

 

But there is no matching ssp0_device platform structure for it. I would expect this to generate a compilation error on failure, so the CONFIG_SPI_LPC32XX macro check might be a suspect too.

Try removing the #id/#endif check and recompiling..

 

606 static struct platform_device* arm9dimm3250_devs[] __initdata = {

608         &ssp0_device,

610 #if defined(CONFIG_KEYBOARD_LPC32XX)

 611         &kscan_device,

 612 #endif

 

Also add the necessary SPI support above this file. You will also need to register your SPI devices. This doesn’t seem to be there either.

You can use the phytec board file as a reference for spi registration. It is here: http://git.lpclinux.com/?p=linux-2.6.27.8-lpc32xx.git;a=blob;f=arch/arm/mach-lpc32xx/board-phy3250.c;h=90d818d42d563665219ede8c2e7f5bc4bbcac7ca;hb=ee7393fba54ad123efaf536e51e139fefd9c85ab

 

The FDI port is in need of a boot loader and kernel update!

 

thanks,

Kevin

 

 

From: Jorge A. Castro [mailto:address@hidden]
Sent: Wednesday, August 25, 2010 10:14 AM
To: Kevin Wells
Cc: address@hidden
Subject: Re: [Ltib] SPI missing

 

Hi Kevin,

Thanks for your answer. I'm able to move to /sys/class/ and actually I found there spi_dev and spitest folders there, but nothing is in them. What can be happening?

address@hidden class]# ls
bdi           mem           ppp           sound         usb_endpoint
i2c-adapter   misc          rtc           spi_master    usb_host
i2c-dev       mmc_host      scsi_device   spidev        vc
input         mtd           scsi_disk     tty           vtconsole
leds          net           scsi_host     usb_device
address@hidden class]# ls spi_master/
address@hidden class]# ls spidev/
address@hidden class]#

Thanks a lot!!!

Best regards.

Jorge Castro




On 08/24/2010 06:16 PM, Kevin Wells wrote:

 

Hi Jorge,

 

<*>  Bitbanging SPI master

You can remove this (unless you’ve added the logic to support GPIO based SPI). There is no default GPIO setup for this in the 32x0.

 

You may need to manually create the device node. I use sysfs to determine the node numbers for the device.

 address@hidden /]# cd /sys/class/spi_master/spi0/device/spi0.0/

address@hidden spi0.0]# ls

bus               modalias          spidev:spidev0.0  uevent

driver            power             subsystem

address@hidden spi0.0]# cat modalias

spidev

address@hidden spi0.0]# cat spidev\:spidev0.0/

spidev:spidev0.0/dev         spidev:spidev0.0/subsystem/

spidev:spidev0.0/device/     spidev:spidev0.0/uevent

spidev:spidev0.0/power/

address@hidden spi0.0]# cat spidev\:spidev0.0/dev

153:0

address@hidden spi0.0]#

 

Then I create the node…

address@hidden spi0.0]# mknod /dev/spi0 c 153 0

address@hidden spi0.0]# cat /dev/spi0

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

 

Maybe I’ll stick this in ./merge

 

thanks,

Kevin

 

 

 

From: address@hidden [mailto:address@hidden] On Behalf Of Jorge A. Castro
Sent: Tuesday, August 24, 2010 12:51 PM
To: address@hidden
Subject: Re: [Ltib] SPI missing

 

Hi everyone,

I apologize for being so insistent, but someone can bring me any idea how to solve this. I'm not able to see any device node related to spi.

Thanks a lot for any idea!

Best regards.


On 08/23/2010 11:32 AM, Jorge A. Castro wrote:

I had enable most of related with SPI in order to try to communicate to an specific module. I'm using Future Designs LPC3250 development kit.

Nevertheless, in the /dev/ I'm not able to see any node related with spi. What can i be missing?

This is what I get in the Configuration and the nodes in /dev.

Thanks for any help in this matter.

Best regards.

--- SPI support
        *** SPI Master Controller Drivers ***
<*>  Bitbanging SPI master
<M> LPC32XX SPI Controller

        *** SPI Protocol Master ***
<*> SPI EEPROMs from most vendors
<*> User mode SPI device driver support
< > Infineon TLE62X0 (for power swithcing)


address@hidden /]# ls dev
XOR                 ppp                 tty38
bus                 ptmx                tty39
console             pts                 tty4
cpu_dma_latency     ram                 tty40
disk                ram0                tty41
fb                  ram1                tty42
fb0                 ram2                tty43
full                ram3                tty44
i2c-0               ramdisk             tty45
i2c-1               random              tty46
i2c-2               sequencer           tty47
input               sequencer2          tty48
kmem                shm                 tty49
kmsg                snd                 tty5
log                 tty                 tty50
loop0               tty0                tty51
loop1               tty1                tty52
loop2               tty10               tty53
loop3               tty11               tty54
loop4               tty12               tty55
loop5               tty13               tty56
loop6               tty14               tty57
loop7               tty15               tty58
mem                 tty16               tty59
mmcblk0             tty17               tty6
mmcblk0p1           tty18               tty60
mtd0                tty19               tty61
mtd0ro              tty2                tty62
mtd1                tty20               tty63
mtd1ro              tty21               tty7
mtd2                tty22               tty8
mtd2ro              tty23               tty9
mtd3                tty24               ttyS0
mtd3ro              tty25               ttyS1
mtd4                tty26               ttyS2
mtd4ro              tty27               ttyS3
mtd5                tty28               ttyTX0
mtd5ro              tty29               urandom
mtdblock0           tty3                usbdev1.1
mtdblock1           tty30               usbdev1.1_ep00
mtdblock2           tty31               usbdev1.1_ep81
mtdblock3           tty32               vcs
mtdblock4           tty33               vcsa
mtdblock5           tty34               watchdog
network_latency     tty35               zero
network_throughput  tty36
null                tty37










-- 
Jorge A. Castro
Canam-Technology, Inc.






-- 
Jorge A. Castro
Canam-Technology, Inc.





-- 
Jorge A. Castro
Canam-Technology, Inc.




-- 
Jorge A. Castro
Canam-Technology, Inc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]