Libertas SPI init problem

Amit Hergass A.Hergass at genesysdesign.com.au
Mon Jul 26 02:50:34 EDT 2010


Hi,

 

I am developing the LTIB linux kernel 2.6.34 for  Phythec board phy3250,

At this stage I am integrating the libertas module over the SPI
interface.

I added the code below to the board file phy3250 in order to add a
second SPI interface over SSP1, and connect it to the Libertas wifi
module.

It seems to get to the stage where it probe the driver, and tries to
access the device.

When I measure the voltage on the lines I can see activity onle on the
chip select line.

 

Please look at the dmesg results below, and I will appreciate any
suggestion.

 

Thanks,

Amit

 

#define  INCLUDE_SPI_WIFI

   #define SPI1_CS_GPIO
LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 3) 

#define CONFIG_LIBERTAS_SPI_MODULE

 

   #include <linux/spi/libertas_spi.h>

 

static int lpc32xx_libertas_setup(struct spi_device *spi)

{

   if (gpio_request(LIBERTAS_INT_GPIO, "WiFi Int"))

                                printk(KERN_ERR "Error requesting WiFi
Int gpio %u",

                                                LIBERTAS_INT_GPIO);

                else if (gpio_direction_input(LIBERTAS_INT_GPIO))

                                printk(KERN_ERR "Error setting WiFi Int
gpio %u input",

                                                LIBERTAS_INT_GPIO);

                                                                

   spi->bits_per_word = 16;

   spi_setup(spi);

 

    return 0;

}

 

static int  lpc32xx_libertas_teardown(struct spi_device *spi)

{

   return 0;

}

struct libertas_spi_platform_data libertas_spi_platform_data_info = {

         .use_dummy_writes       = 1,

         .setup                  = lpc32xx_libertas_setup,

         .teardown               = lpc32xx_libertas_teardown,

};

 

 

#ifdef INCLUDE_SPI_WIFI

///AH: WiFi SPI2
Start//////////////////////////////////////////////////////

/*

 * AMBA SSP (SPI1)

 */

static void phy3250_spi1_cs_set(u32 control)

{

   printk(KERN_INFO "spi1_cs_set gpio %u, control %u ",SPI1_CS_GPIO,
control);

                gpio_set_value(SPI1_CS_GPIO, (int) control);

}

 

static struct pl022_config_chip spi1_chip_info = {

                .lbm                                       =
LOOPBACK_DISABLED,

                .com_mode                       = INTERRUPT_TRANSFER,

                .iface                                     =
SSP_INTERFACE_MOTOROLA_SPI,

                .hierarchy                            = SSP_MASTER,

                .slave_tx_disable             = 0,

                .endian_tx                          = SSP_TX_LSB,

                .endian_rx                          = SSP_RX_LSB,

                .data_size                           = SSP_DATA_BITS_16,
//AH: SSP_DATA_BITS_8,

                .rx_lev_trig                         =
SSP_RX_4_OR_MORE_ELEM,

                .tx_lev_trig                         =
SSP_TX_4_OR_MORE_EMPTY_LOC,

                .clk_phase                          =
SSP_CLK_FIRST_EDGE,

                .clk_pol                                =
SSP_CLK_POL_IDLE_LOW,

                .ctrl_len                               = SSP_BITS_8,

                .wait_state                         =
SSP_MWIRE_WAIT_ZERO,

                .duplex                                 =
SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,

                .cs_control                          =
phy3250_spi1_cs_set,

};

 

static struct pl022_ssp_controller lpc32xx_ssp1_data = {

                .bus_id                                 = 1,

                .num_chipselect                              = 1,

                .enable_dma                     = 1,

};

 

static struct amba_device lpc32xx_ssp1_device = {

                .dev
= {

                                .coherent_dma_mask   = ~0,

                                .init_name                          =
"dev:ssp1",

                                .platform_data                 =
&lpc32xx_ssp1_data,

                },

                .res
= {

                                .start
= LPC32XX_SSP1_BASE,

                                .end
= (LPC32XX_SSP1_BASE + SZ_4K - 1),

                                .flags
= IORESOURCE_MEM,

                },

                .dma_mask                                        = ~0,

                .irq
= {IRQ_LPC32XX_SSP1, NO_IRQ},

};

 

///AH: WiFi SPI2
End//////////////////////////////////////////////////////

#endif // INCLUDE_SPI_WIFI

 

/* AT25 driver registration */

static int __init phy3250_spi_board_register(void)

{

 

                static struct spi_board_info info[] = {

                                {

      .

      .

                                },

 

#if defined(CONFIG_LIBERTAS_SPI_MODULE)

                                {

                                .modalias         = "libertas_spi",

                                .max_speed_hz     = 5000000, //
33000000,

                                .bus_num          = 1,

                                .irq              = IRQ_LPC32XX_GPIO_00,
//IRQ_LPC32XX_SSP1, 

                                .chip_select      = 0,

                                .platform_data    =
&libertas_spi_platform_data_info,

                                .controller_data  = &spi1_chip_info,

                                .mode             = SPI_MODE_0,
//SPI_MODE_3,

                                },

 

#endif

};

 

 

static struct amba_device *amba_devs[] __initdata = {

                &lpc32xx_clcd_device,

                &lpc32xx_ssp0_device,

#if defined(INCLUDE_SPI_WIFI)

                &lpc32xx_ssp1_device,

#endif   

 

#if defined(CONFIG_MMC_ARMMMCI)

                &lpc32xx_mmc_device,

#endif

};

 

static void __init phy3250_board_init(void)

{

                u32 tmp;

                int i;

 

                lpc32xx_gpio_init();

                . 

                . 

                .

#if defined(INCLUDE_SPI_WIFI)

/* Register GPIOs used on this board */

                if (gpio_request(SPI1_CS_GPIO, "spi1 cs"))

                                printk(KERN_ERR "Error requesting gpio
%u", SPI1_CS_GPIO);

                else if (gpio_direction_output(SPI1_CS_GPIO, 1))

                                printk(KERN_ERR "Error setting gpio %u
to output",SPI1_CS_GPIO);

 

#endif 

 

#if defined (INCLUDE_SPI_WIFI)

#ifdef CONFIG_SPI_PL022

                tmp = __raw_readl(LPC32XX_CLKPWR_SSP_CLK_CTRL);

                __raw_writel((tmp | LPC32XX_CLKPWR_SSPCTRL_SSPCLK1_EN),

                                LPC32XX_CLKPWR_SSP_CLK_CTRL);

#endif

.

.

}

#endif

 

 

dmesg:

spi_register_driver: libertas_spi

bus: 'spi': add driver libertas_spi

bus: 'spi': driver_probe_device: matched device spi1.0 with driver
libertas_spi

bus: 'spi': really_probe: probing driver libertas_spi with device spi1.0

libertas_spi: if_spi_probe

libertas_spi spi1.0: using user supplied controller_data settings

libertas_spi spi1.0: 9 <= n <= 16 bits per word

libertas_spi spi1.0: DMA mode NOT set in controller state

libertas_spi spi1.0: setup mode 0, 16 bits/w, 5000000 Hz max --> 0

ssp-pl022 dev:ssp1: flush

spi1_cs_set gpio 82, control 0 

ssp-pl022 dev:ssp1: readwriter, rx: (null), rxend: 00000002, tx:
c3c19d76, txend: c3c19d78

ssp-pl022 dev:ssp1: readwriter, rx: (null), rxend: 00000002, tx:
c3c19d78, txend: c3c19d78

ssp-pl022 dev:ssp1: flush

ssp-pl022 dev:ssp1: readwriter, rx: (null), rxend: 00000002, tx:
c3c19da6, txend: c3c19da8

ssp-pl022 dev:ssp1: readwriter, rx: (null), rxend: 00000002, tx:
c3c19da8, txend: c3c19da8

spi1_cs_set gpio 82, control 1 

ssp-pl022 dev:ssp1: flush

spi1_cs_set gpio 82, control 0 

ssp-pl022 dev:ssp1: readwriter, rx: (null), rxend: 00000002, tx:
c3c19d76, txend: c3c19d78

ssp-pl022 dev:ssp1: readwriter, rx: (null), rxend: 00000002, tx:
c3c19d78, txend: c3c19d78

ssp-pl022 dev:ssp1: flush

ssp-pl022 dev:ssp1: readwriter, rx: c3c19da6, rxend: c3c19da8, tx:
(null), txend: 00000002

ssp-pl022 dev:ssp1: readwriter, rx: c3c19da6, rxend: c3c19da8, tx:
00000002, txend: 00000002

spi1_cs_set gpio 82, control 1 

libertas: Can't read bus mode register.

libertas_spi: probe of spi1.0 failed with error -5

device class 'usbmon': registering

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/libertas-dev/attachments/20100726/b33c25ba/attachment-0001.html>


More information about the libertas-dev mailing list