<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">Hi, all<div>Now I am going to port libertas driver into my mainboard, I suffered some difficuties.</div><div>Mainborad platform is Mini2440 using samsung S3C2440. Wireless unit consists of &nbsp;marvell 88W8686 connected with S3C2440 by GSPI interface. Linux kernel version is linux-2.6.32.2.</div><div>&nbsp;I use GPG5_6_7 as SPIMISO1, SPIMOSI1,SPICLK1 and GPG3 as nSS1.</div><div>The problem is that when I insmod libertas.ko and insmod libertas_spi.ko, print message is following:</div><div>libertas_spi: Libertas SPI driver</div><div><div>libertas: Can't read bus mode register.</div><div>libertas_spi: probe of spi1.0 failed with error -5</div></div><div><br></div><div>However, I short circuit&nbsp;SPIMISO1 and SPIMOSI1 then execute spi_test. I can read bus mode and receive data correctly.</div><div><br></div><div>What I do for driving 88W8686 is following:</div><div>/arch/arm/mach-s3c2440/mach-mini2440.c</div><div><div>/* SPI1 Marvell8686 */</div><div>static int libertas_spi_setup(struct spi_device *spi)</div><div>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>void __iomem *base_addr;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>spi-&gt;bits_per_word = 16;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>base_addr = ioremap(0x560000d0, 0x0c);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>if(base_addr == NULL) {</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>printk(KERN_ERR "map error\n");</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>return -ENOMEM;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>}</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr)&amp;(~(0x3&lt;&lt;4))|(0x1&lt;&lt;4), base_addr);//config GPJ2 output</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr+0x4)|(0x1&lt;&lt;2), base_addr+0x4);<span class="Apple-tab-span" style="white-space: pre; ">        </span>// GPJ2 HIGH</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr)&amp;(~(0x3&lt;&lt;20))|(0x1&lt;&lt;20), base_addr);//config GPJ10 output</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr+0x4)|(0x1&lt;&lt;10), base_addr+0x4);<span class="Apple-tab-span" style="white-space: pre; ">        </span>//GPJ10 HIGH</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr)&amp;(~(0x3&lt;&lt;22))|(0x1&lt;&lt;22), base_addr);//config GPJ11 output</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr+0x4)&amp;(~(0x1&lt;&lt;11)), base_addr+0x4);<span class="Apple-tab-span" style="white-space: pre; ">        </span>// GPJ11 LOW</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c2410_gpio_cfgpin(S3C2410_GPG(12), S3C2410_GPIO_IRQ);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>set_irq_type(IRQ_EINT20, IRQ_TYPE_EDGE_FALLING);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iounmap(base_addr);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>return 0;</div><div>}</div><div><br></div><div>static int libertas_spi_teardown(struct spi_device *spi)</div><div>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>void __iomem *base_addr;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>base_addr = ioremap(0x560000d0, 0x0c);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>if(base_addr == NULL) {</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>printk(KERN_ERR "map error\n");</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>return -ENOMEM;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>}</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr)&amp;(~(0x3&lt;&lt;4))|(0x1&lt;&lt;4), base_addr);//config GPJ2 output</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iowrite32(ioread32(base_addr+0x4)&amp;(~(0x1&lt;&lt;2)), base_addr+0x4);<span class="Apple-tab-span" style="white-space: pre; ">        </span>// GPJ2 LOW</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>iounmap(base_addr);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>return 0;</div><div>}</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span></div><div>static struct libertas_spi_platform_data libertas_spi_info = {</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.use_dummy_writes = 0,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.setup = libertas_spi_setup,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.teardown = libertas_spi_teardown,</div><div>};</div><div>&nbsp;</div><div>static struct spi_board_info libertas_spi_device[] __initdata = {</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>[0] = {</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.modalias = "libertas_spi",</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.platform_data = &amp;libertas_spi_info,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.irq = IRQ_EINT20,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.max_speed_hz = 1*1000*1000,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.bus_num = 1,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.chip_select = 0,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.mode = SPI_MODE_0,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>},</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>[1] = {</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.modalias = "spidev",</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.bus_num = 1,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.chip_select = 1,</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>.max_speed_hz = 500 * 1000,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>},<span class="Apple-tab-span" style="white-space: pre; ">                </span></div><div>};</div><div><br></div><div>/* init s3c2410_spi_info */<span class="Apple-tab-span" style="white-space: pre; ">        </span></div><div>static struct s3c2410_spi_info mini2440_spi1_info = {</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.pin_cs = S3C2410_GPG(3),</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.num_cs = 2,<span class="Apple-tab-span" style="white-space: pre; ">                        </span>//0--Marvell 8686 &nbsp; &nbsp;1--spidev</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.bus_num = 1,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>.gpio_setup = s3c24xx_spi_gpiocfg_bus1_gpg5_6_7,</div><div>};</div><div><br></div><div>static struct platform_device *mini2440_devices[] __initdata = {</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_usb,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_rtc,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_lcd,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_wdt,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_i2c0,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_iis,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;mini2440_device_eth,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c24xx_uda134x,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_nand,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_sdi,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_usbgadget,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>//&amp;s3c_device_spi0,</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>&amp;s3c_device_spi1,</div><div>};</div><div><br></div><div>static void __init mini2440_map_io(void)</div><div>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c24xx_init_clocks(12000000);</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span></div><div>}</div><div><br></div><div>static void __init mini2440_machine_init(void)</div><div>{</div><div>#if defined (LCD_WIDTH)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c24xx_fb_set_platdata(&amp;mini2440_fb_info);</div><div>#endif</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c_i2c0_set_platdata(NULL);</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c2410_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND);</div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c_device_nand.dev.platform_data = &amp;friendly_arm_nand_info;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c_device_sdi.dev.platform_data = &amp;mini2440_mmc_cfg;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c_device_spi1.dev.platform_data = &amp;mini2440_spi1_info;</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span><span style="color: rgb(0, 0, 0); ">spi_register_board_info(libertas_spi_device, ARRAY_SIZE(libertas_spi_device));</span></div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>s3c_pm_init();</div><div>}</div></div>
</div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>