wilc_netdev_cleanup(sdio_get_drvdata(func));
}
-static struct sdio_driver wilc_bus = {
+static struct sdio_driver wilc1000_sdio_driver = {
.name = SDIO_MODALIAS,
.id_table = wilc_sdio_ids,
.probe = linux_sdio_probe,
.remove = linux_sdio_remove,
};
+module_driver(wilc1000_sdio_driver, sdio_register_driver, sdio_unregister_driver);
+MODULE_LICENSE("GPL");
int wilc_sdio_enable_interrupt(struct wilc *dev)
{
static int linux_sdio_set_speed(int speed)
{
struct mmc_ios ios;
+ struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
- sdio_claim_host(wilc_sdio_func);
+ sdio_claim_host(func);
- memcpy((void *)&ios, (void *)&wilc_sdio_func->card->host->ios, sizeof(struct mmc_ios));
- wilc_sdio_func->card->host->ios.clock = speed;
+ memcpy((void *)&ios, (void *)&func->card->host->ios, sizeof(struct mmc_ios));
+ func->card->host->ios.clock = speed;
ios.clock = speed;
- wilc_sdio_func->card->host->ops->set_ios(wilc_sdio_func->card->host, &ios);
- sdio_release_host(wilc_sdio_func);
+ func->card->host->ops->set_ios(func->card->host, &ios);
+ sdio_release_host(func);
PRINT_INFO(INIT_DBG, "@@@@@@@@@@@@ change SDIO speed to %d @@@@@@@@@\n", speed);
return 1;
static int linux_sdio_get_speed(void)
{
- return wilc_sdio_func->card->host->ios.clock;
+ struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
+ return func->card->host->ios.clock;
}
int wilc_sdio_init(void)
return linux_sdio_set_speed(sdio_default_speed);
}
-static int __init init_wilc_sdio_driver(void)
-{
- return sdio_register_driver(&wilc_bus);
-}
-late_initcall(init_wilc_sdio_driver);
-
-static void __exit exit_wilc_sdio_driver(void)
-{
- sdio_unregister_driver(&wilc_bus);
-}
-module_exit(exit_wilc_sdio_driver);
-
MODULE_LICENSE("GPL");
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/spi/spi.h>
+#include <linux/of_gpio.h>
#include "linux_wlan_spi.h"
#include "wilc_wfi_netdevice.h"
static u32 SPEED = MIN_SPEED;
-struct spi_device *wilc_spi_dev;
+static const struct wilc1000_ops wilc1000_spi_ops;
-static int __init wilc_bus_probe(struct spi_device *spi)
+static int wilc_bus_probe(struct spi_device *spi)
{
+ int ret, gpio;
+ struct wilc *wilc;
- PRINT_D(BUS_DBG, "spiModalias: %s\n", spi->modalias);
- PRINT_D(BUS_DBG, "spiMax-Speed: %d\n", spi->max_speed_hz);
- wilc_spi_dev = spi;
+ gpio = of_get_gpio(spi->dev.of_node, 0);
+ if (gpio < 0)
+ gpio = GPIO_NUM;
+
+ ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, GPIO_NUM, &wilc_hif_spi);
+ if (ret)
+ return ret;
+
+ spi_set_drvdata(spi, wilc);
+ wilc->dev = &spi->dev;
- printk("Driver Initializing success\n");
return 0;
}
-static int __exit wilc_bus_remove(struct spi_device *spi)
+static int wilc_bus_remove(struct spi_device *spi)
{
-
+ wilc_netdev_cleanup(spi_get_drvdata(spi));
return 0;
}
-#ifdef CONFIG_OF
static const struct of_device_id wilc1000_of_match[] = {
{ .compatible = "atmel,wilc_spi", },
{}
};
MODULE_DEVICE_TABLE(of, wilc1000_of_match);
-#endif
-static struct spi_driver wilc_bus __refdata = {
+struct spi_driver wilc1000_spi_driver = {
.driver = {
.name = MODALIAS,
-#ifdef CONFIG_OF
.of_match_table = wilc1000_of_match,
-#endif
},
.probe = wilc_bus_probe,
- .remove = __exit_p(wilc_bus_remove),
+ .remove = wilc_bus_remove,
};
+module_spi_driver(wilc1000_spi_driver);
+MODULE_LICENSE("GPL");
int wilc_spi_init(void)
{
- int ret = 1;
- static int called;
-
-
- if (called == 0) {
- called++;
- ret = spi_register_driver(&wilc_bus);
- }
-
- /* change return value to match WILC interface */
- (ret < 0) ? (ret = 0) : (ret = 1);
-
- return ret;
+ return 1;
}
#if defined(PLAT_WMS8304)
int wilc_spi_write(u8 *b, u32 len)
{
+ struct spi_device *spi = to_spi_device(wilc_dev->dev);
int ret;
if (len > 0 && b != NULL) {
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA;
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
#else
int wilc_spi_write(u8 *b, u32 len)
{
-
+ struct spi_device *spi = to_spi_device(wilc_dev->dev);
int ret;
struct spi_message msg;
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
/* [[johnny add */
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA;
/* ]] */
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
int wilc_spi_read(u8 *rb, u32 rlen)
{
+ struct spi_device *spi = to_spi_device(wilc_dev->dev);
int ret;
if (rlen > 0) {
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA;
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
#else
int wilc_spi_read(u8 *rb, u32 rlen)
{
-
+ struct spi_device *spi = to_spi_device(wilc_dev->dev);
int ret;
if (rlen > 0) {
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
/* [[ johnny add */
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA;
/* ]] */
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen)
{
-
+ struct spi_device *spi = to_spi_device(wilc_dev->dev);
int ret;
if (rlen > 0) {
memset(&msg, 0, sizeof(msg));
spi_message_init(&msg);
- msg.spi = wilc_spi_dev;
+ msg.spi = spi;
msg.is_dma_mapped = USE_SPI_DMA;
spi_message_add_tail(&tr, &msg);
- ret = spi_sync(wilc_spi_dev, &msg);
+ ret = spi_sync(spi, &msg);
if (ret < 0) {
PRINT_ER("SPI transaction failed\n");
}
PRINT_INFO(BUS_DBG, "@@@@@@@@@@@@ change SPI speed to %d @@@@@@@@@\n", SPEED);
return 1;
}
-
-static struct wilc *wilc;
-
-static int __init init_wilc_spi_driver(void)
-{
- int ret;
-
- wilc_debugfs_init();
-
- ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, GPIO_NUM, &wilc_hif_spi);
- if (ret) {
- wilc_debugfs_remove();
- return ret;
- }
-
- if (!wilc_spi_init() || !wilc_spi_dev) {
- PRINT_ER("Can't initialize SPI\n");
- wilc_netdev_cleanup(wilc);
- wilc_debugfs_remove();
- return -ENXIO;
- }
- wilc_dev->dev = &wilc_spi_dev->dev;
-
- return ret;
-}
-late_initcall(init_wilc_spi_driver);
-
-static void __exit exit_wilc_spi_driver(void)
-{
- if (wilc)
- wilc_netdev_cleanup(wilc);
- spi_unregister_driver(&wilc_bus);
- wilc_debugfs_remove();
-}
-module_exit(exit_wilc_spi_driver);
-
-MODULE_LICENSE("GPL");