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>
16 #include <linux/module.h>
18 #define DRV_NAME "wrt55agv2-spidevs"
19 #define DRV_DESC "SPI driver for the WRT55AG v2 board"
20 #define DRV_VERSION "0.1.0"
21 #define PFX DRV_NAME ": "
23 #define GPIO_PIN_MISO 1
25 #define GPIO_PIN_CLK 3
26 #define GPIO_PIN_MOSI 4
28 static struct platform_device
*spi_gpio_dev
;
30 static int __init
boardinfo_setup(struct spi_board_info
*bi
,
31 struct spi_master
*master
, void *data
)
34 strlcpy(bi
->modalias
, "spi-ks8995", sizeof(bi
->modalias
));
36 bi
->max_speed_hz
= 5000000 /* Hz */;
37 bi
->bus_num
= master
->bus_num
;
38 bi
->mode
= SPI_MODE_0
;
43 static int __init
wrt55agv2_spidevs_init(void)
45 struct spi_gpio_platform_data pdata
;
48 spi_gpio_dev
= platform_device_alloc("spi-gpio", 0);
50 printk(KERN_ERR PFX
"no memory for spi-gpio device\n");
54 memset(&pdata
, 0, sizeof(pdata
));
55 pdata
.pin_miso
= GPIO_PIN_MISO
;
56 pdata
.pin_cs
= GPIO_PIN_CS
;
57 pdata
.pin_clk
= GPIO_PIN_CLK
;
58 pdata
.pin_mosi
= GPIO_PIN_MOSI
;
59 pdata
.cs_activelow
= 1;
60 pdata
.no_spi_delay
= 1;
61 pdata
.boardinfo_setup
= boardinfo_setup
;
62 pdata
.boardinfo_setup_data
= NULL
;
64 err
= platform_device_add_data(spi_gpio_dev
, &pdata
, sizeof(pdata
));
68 err
= platform_device_register(spi_gpio_dev
);
70 printk(KERN_ERR PFX
"unable to register device\n");
77 kfree(spi_gpio_dev
->dev
.platform_data
);
78 spi_gpio_dev
->dev
.platform_data
= NULL
;
81 platform_device_put(spi_gpio_dev
);
85 static void __exit
wrt55agv2_spidevs_cleanup(void)
90 platform_device_unregister(spi_gpio_dev
);
92 kfree(spi_gpio_dev
->dev
.platform_data
);
93 spi_gpio_dev
->dev
.platform_data
= NULL
;
94 platform_device_put(spi_gpio_dev
);
97 static int __init
wrt55agv2_spidevs_modinit(void)
99 printk(KERN_INFO DRV_DESC
" version " DRV_VERSION
"\n");
100 return wrt55agv2_spidevs_init();
102 module_init(wrt55agv2_spidevs_modinit
);
104 static void __exit
wrt55agv2_spidevs_modexit(void)
106 wrt55agv2_spidevs_cleanup();
108 module_exit(wrt55agv2_spidevs_modexit
);
110 MODULE_DESCRIPTION(DRV_DESC
);
111 MODULE_VERSION(DRV_VERSION
);
112 MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
113 MODULE_LICENSE("GPL v2");