2 * SPI driver for the Linksys WRT55AG v2 board.
4 * Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
6 * This file was based on the mmc_over_gpio driver:
7 * Copyright 2008 Michael Buesch <mb@bu3sch.de>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi_gpio_old.h>
17 #define DRV_NAME "wrt55agv2-spidevs"
18 #define DRV_DESC "SPI driver for the WRT55AG v2 board"
19 #define DRV_VERSION "0.1.0"
20 #define PFX DRV_NAME ": "
22 #define GPIO_PIN_MISO 1
24 #define GPIO_PIN_CLK 3
25 #define GPIO_PIN_MOSI 4
27 static struct platform_device
*spi_gpio_dev
;
29 static int __init
boardinfo_setup(struct spi_board_info
*bi
,
30 struct spi_master
*master
, void *data
)
33 strlcpy(bi
->modalias
, "spi-ks8995", sizeof(bi
->modalias
));
35 bi
->max_speed_hz
= 5000000 /* Hz */;
36 bi
->bus_num
= master
->bus_num
;
37 bi
->mode
= SPI_MODE_0
;
42 static int __init
wrt55agv2_spidevs_init(void)
44 struct spi_gpio_platform_data pdata
;
47 spi_gpio_dev
= platform_device_alloc("spi-gpio", 0);
49 printk(KERN_ERR PFX
"no memory for spi-gpio device\n");
53 memset(&pdata
, 0, sizeof(pdata
));
54 pdata
.pin_miso
= GPIO_PIN_MISO
;
55 pdata
.pin_cs
= GPIO_PIN_CS
;
56 pdata
.pin_clk
= GPIO_PIN_CLK
;
57 pdata
.pin_mosi
= GPIO_PIN_MOSI
;
58 pdata
.cs_activelow
= 1;
59 pdata
.no_spi_delay
= 1;
60 pdata
.boardinfo_setup
= boardinfo_setup
;
61 pdata
.boardinfo_setup_data
= NULL
;
63 err
= platform_device_add_data(spi_gpio_dev
, &pdata
, sizeof(pdata
));
67 err
= platform_device_register(spi_gpio_dev
);
69 printk(KERN_ERR PFX
"unable to register device\n");
76 kfree(spi_gpio_dev
->dev
.platform_data
);
77 spi_gpio_dev
->dev
.platform_data
= NULL
;
80 platform_device_put(spi_gpio_dev
);
84 static void __exit
wrt55agv2_spidevs_cleanup(void)
89 platform_device_unregister(spi_gpio_dev
);
91 kfree(spi_gpio_dev
->dev
.platform_data
);
92 spi_gpio_dev
->dev
.platform_data
= NULL
;
93 platform_device_put(spi_gpio_dev
);
96 static int __init
wrt55agv2_spidevs_modinit(void)
98 printk(KERN_INFO DRV_DESC
" version " DRV_VERSION
"\n");
99 return wrt55agv2_spidevs_init();
101 module_init(wrt55agv2_spidevs_modinit
);
103 static void __exit
wrt55agv2_spidevs_modexit(void)
105 wrt55agv2_spidevs_cleanup();
107 module_exit(wrt55agv2_spidevs_modexit
);
109 MODULE_DESCRIPTION(DRV_DESC
);
110 MODULE_VERSION(DRV_VERSION
);
111 MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
112 MODULE_LICENSE("GPL v2");