aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMike Rapoport <mike@compulab.co.il>2009-08-03 05:07:52 -0400
committerEric Miao <eric.y.miao@gmail.com>2009-09-10 06:49:34 -0400
commita2099e49f4f8728b0c0301a4e3eb650644ee9206 (patch)
treed9ca520b2af24d523fe1031faca538b6738c8d0b /arch
parent100a1d250d3806caa97b08d04cb558372c8e8097 (diff)
[ARM] pxa/cm-x270: add libertas device registration
v2 changes: - use gpio_to_irq instead of IRQ_GPIO - check gpio_direction_output return value to be on the safe side :) Signed-off-by: Mike Rapoport <mike@compulab.co.il> Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-pxa/cm-x270.c110
1 files changed, 108 insertions, 2 deletions
diff --git a/arch/arm/mach-pxa/cm-x270.c b/arch/arm/mach-pxa/cm-x270.c
index 59292181088c..eea78b6c2bc5 100644
--- a/arch/arm/mach-pxa/cm-x270.c
+++ b/arch/arm/mach-pxa/cm-x270.c
@@ -13,13 +13,18 @@
13#include <linux/sysdev.h> 13#include <linux/sysdev.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16#include <linux/delay.h>
16 17
17#include <linux/rtc-v3020.h> 18#include <linux/rtc-v3020.h>
18#include <video/mbxfb.h> 19#include <video/mbxfb.h>
19 20
21#include <linux/spi/spi.h>
22#include <linux/spi/libertas_spi.h>
23
20#include <mach/pxa27x.h> 24#include <mach/pxa27x.h>
21#include <mach/ohci.h> 25#include <mach/ohci.h>
22#include <mach/mmc.h> 26#include <mach/mmc.h>
27#include <mach/pxa2xx_spi.h>
23 28
24#include "generic.h" 29#include "generic.h"
25 30
@@ -34,6 +39,10 @@
34/* MMC power enable */ 39/* MMC power enable */
35#define GPIO105_MMC_POWER (105) 40#define GPIO105_MMC_POWER (105)
36 41
42/* WLAN GPIOS */
43#define GPIO19_WLAN_STRAP (19)
44#define GPIO102_WLAN_RST (102)
45
37static unsigned long cmx270_pin_config[] = { 46static unsigned long cmx270_pin_config[] = {
38 /* AC'97 */ 47 /* AC'97 */
39 GPIO28_AC97_BITCLK, 48 GPIO28_AC97_BITCLK,
@@ -94,8 +103,8 @@ static unsigned long cmx270_pin_config[] = {
94 GPIO26_SSP1_RXD, 103 GPIO26_SSP1_RXD,
95 104
96 /* SSP2 */ 105 /* SSP2 */
97 GPIO19_SSP2_SCLK, 106 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
98 GPIO14_SSP2_SFRM, 107 GPIO14_GPIO,
99 GPIO87_SSP2_TXD, 108 GPIO87_SSP2_TXD,
100 GPIO88_SSP2_RXD, 109 GPIO88_SSP2_RXD,
101 110
@@ -123,6 +132,7 @@ static unsigned long cmx270_pin_config[] = {
123 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, 132 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH,
124 GPIO105_GPIO | MFP_LPM_DRIVE_HIGH, /* MMC/SD power */ 133 GPIO105_GPIO | MFP_LPM_DRIVE_HIGH, /* MMC/SD power */
125 GPIO53_GPIO, /* PC card reset */ 134 GPIO53_GPIO, /* PC card reset */
135 GPIO102_GPIO, /* WLAN reset */
126 136
127 /* NAND controls */ 137 /* NAND controls */
128 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */ 138 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
@@ -131,6 +141,7 @@ static unsigned long cmx270_pin_config[] = {
131 /* interrupts */ 141 /* interrupts */
132 GPIO10_GPIO, /* DM9000 interrupt */ 142 GPIO10_GPIO, /* DM9000 interrupt */
133 GPIO83_GPIO, /* MMC card detect */ 143 GPIO83_GPIO, /* MMC card detect */
144 GPIO95_GPIO, /* WLAN interrupt */
134}; 145};
135 146
136/* V3020 RTC */ 147/* V3020 RTC */
@@ -287,6 +298,100 @@ static void __init cmx270_init_mmc(void)
287static inline void cmx270_init_mmc(void) {} 298static inline void cmx270_init_mmc(void) {}
288#endif 299#endif
289 300
301#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
302static struct pxa2xx_spi_master cm_x270_spi_info = {
303 .num_chipselect = 1,
304 .enable_dma = 1,
305};
306
307static struct pxa2xx_spi_chip cm_x270_libertas_chip = {
308 .rx_threshold = 1,
309 .tx_threshold = 1,
310 .timeout = 1000,
311 .gpio_cs = 14,
312};
313
314static unsigned long cm_x270_libertas_pin_config[] = {
315 /* SSP2 */
316 GPIO19_SSP2_SCLK,
317 GPIO14_GPIO,
318 GPIO87_SSP2_TXD,
319 GPIO88_SSP2_RXD,
320
321};
322
323static int cm_x270_libertas_setup(struct spi_device *spi)
324{
325 int err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
326 if (err)
327 return err;
328
329 err = gpio_request(GPIO102_WLAN_RST, "WLAN RST");
330 if (err)
331 goto err_free_strap;
332
333 err = gpio_direction_output(GPIO102_WLAN_RST, 0);
334 if (err)
335 goto err_free_strap;
336 msleep(100);
337
338 err = gpio_direction_output(GPIO19_WLAN_STRAP, 1);
339 if (err)
340 goto err_free_strap;
341 msleep(100);
342
343 pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config));
344
345 gpio_set_value(GPIO102_WLAN_RST, 1);
346 msleep(100);
347
348 spi->bits_per_word = 16;
349 spi_setup(spi);
350
351 return 0;
352
353err_free_strap:
354 gpio_free(GPIO19_WLAN_STRAP);
355
356 return err;
357}
358
359static int cm_x270_libertas_teardown(struct spi_device *spi)
360{
361 gpio_set_value(GPIO102_WLAN_RST, 0);
362 gpio_free(GPIO102_WLAN_RST);
363 gpio_free(GPIO19_WLAN_STRAP);
364
365 return 0;
366}
367
368struct libertas_spi_platform_data cm_x270_libertas_pdata = {
369 .use_dummy_writes = 1,
370 .setup = cm_x270_libertas_setup,
371 .teardown = cm_x270_libertas_teardown,
372};
373
374static struct spi_board_info cm_x270_spi_devices[] __initdata = {
375 {
376 .modalias = "libertas_spi",
377 .max_speed_hz = 13000000,
378 .bus_num = 2,
379 .irq = gpio_to_irq(95),
380 .chip_select = 0,
381 .controller_data = &cm_x270_libertas_chip,
382 .platform_data = &cm_x270_libertas_pdata,
383 },
384};
385
386static void __init cmx270_init_spi(void)
387{
388 pxa2xx_set_spi_info(2, &cm_x270_spi_info);
389 spi_register_board_info(ARRAY_AND_SIZE(cm_x270_spi_devices));
390}
391#else
392static inline void cmx270_init_spi(void) {}
393#endif
394
290void __init cmx270_init(void) 395void __init cmx270_init(void)
291{ 396{
292 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config)); 397 pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
@@ -299,4 +404,5 @@ void __init cmx270_init(void)
299 cmx270_init_mmc(); 404 cmx270_init_mmc();
300 cmx270_init_ohci(); 405 cmx270_init_ohci();
301 cmx270_init_2700G(); 406 cmx270_init_2700G();
407 cmx270_init_spi();
302} 408}