aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rapoport <mike@compulab.co.il>2009-02-03 02:04:20 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-02-09 15:03:48 -0500
commit0c2bec96945ccfc4a58a88d73531e392972ba6c5 (patch)
treec3bfabe4cc063031e0a647f519499d9053099ec0
parentd43e87868f67c5b52defd8d82bc3f54347ed2408 (diff)
libertas: if_spi: add ability to call board specific setup/teardown methods
In certain cases it is required to perform board specific actions before activating libertas G-SPI interface. These actions may include power up of the chip, GPIOs setup, proper pin-strapping and SPI controller config. This patch adds ability to call board specific setup/teardown methods Signed-off-by: Mike Rapoport <mike@compulab.co.il> Acked-by: Andrey Yurovsky <andrey@cozybit.com> Acked-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/libertas/if_spi.c15
-rw-r--r--include/linux/spi/libertas_spi.h7
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index 7c02ea314fd1..07311e71af92 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -42,6 +42,7 @@ struct if_spi_packet {
42struct if_spi_card { 42struct if_spi_card {
43 struct spi_device *spi; 43 struct spi_device *spi;
44 struct lbs_private *priv; 44 struct lbs_private *priv;
45 struct libertas_spi_platform_data *pdata;
45 46
46 char helper_fw_name[FIRMWARE_NAME_MAX]; 47 char helper_fw_name[FIRMWARE_NAME_MAX];
47 char main_fw_name[FIRMWARE_NAME_MAX]; 48 char main_fw_name[FIRMWARE_NAME_MAX];
@@ -1022,6 +1023,17 @@ static int __devinit if_spi_probe(struct spi_device *spi)
1022 1023
1023 lbs_deb_enter(LBS_DEB_SPI); 1024 lbs_deb_enter(LBS_DEB_SPI);
1024 1025
1026 if (!pdata) {
1027 err = -EINVAL;
1028 goto out;
1029 }
1030
1031 if (pdata->setup) {
1032 err = pdata->setup(spi);
1033 if (err)
1034 goto out;
1035 }
1036
1025 /* Allocate card structure to represent this specific device */ 1037 /* Allocate card structure to represent this specific device */
1026 card = kzalloc(sizeof(struct if_spi_card), GFP_KERNEL); 1038 card = kzalloc(sizeof(struct if_spi_card), GFP_KERNEL);
1027 if (!card) { 1039 if (!card) {
@@ -1029,6 +1041,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
1029 goto out; 1041 goto out;
1030 } 1042 }
1031 spi_set_drvdata(spi, card); 1043 spi_set_drvdata(spi, card);
1044 card->pdata = pdata;
1032 card->spi = spi; 1045 card->spi = spi;
1033 card->gpio_cs = pdata->gpio_cs; 1046 card->gpio_cs = pdata->gpio_cs;
1034 card->prev_xfer_time = jiffies; 1047 card->prev_xfer_time = jiffies;
@@ -1158,6 +1171,8 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
1158 if_spi_terminate_spi_thread(card); 1171 if_spi_terminate_spi_thread(card);
1159 lbs_remove_card(priv); /* will call free_netdev */ 1172 lbs_remove_card(priv); /* will call free_netdev */
1160 gpio_free(card->gpio_cs); 1173 gpio_free(card->gpio_cs);
1174 if (card->pdata->teardown)
1175 card->pdata->teardown(spi);
1161 free_if_spi_card(card); 1176 free_if_spi_card(card);
1162 lbs_deb_leave(LBS_DEB_SPI); 1177 lbs_deb_leave(LBS_DEB_SPI);
1163 return 0; 1178 return 0;
diff --git a/include/linux/spi/libertas_spi.h b/include/linux/spi/libertas_spi.h
index ada71b4f3788..79506f5f9e67 100644
--- a/include/linux/spi/libertas_spi.h
+++ b/include/linux/spi/libertas_spi.h
@@ -10,6 +10,9 @@
10 */ 10 */
11#ifndef _LIBERTAS_SPI_H_ 11#ifndef _LIBERTAS_SPI_H_
12#define _LIBERTAS_SPI_H_ 12#define _LIBERTAS_SPI_H_
13
14struct spi_device;
15
13struct libertas_spi_platform_data { 16struct libertas_spi_platform_data {
14 /* There are two ways to read data from the WLAN module's SPI 17 /* There are two ways to read data from the WLAN module's SPI
15 * interface. Setting 0 or 1 here controls which one is used. 18 * interface. Setting 0 or 1 here controls which one is used.
@@ -21,5 +24,9 @@ struct libertas_spi_platform_data {
21 24
22 /* GPIO number to use as chip select */ 25 /* GPIO number to use as chip select */
23 u16 gpio_cs; 26 u16 gpio_cs;
27
28 /* Board specific setup/teardown */
29 int (*setup)(struct spi_device *spi);
30 int (*teardown)(struct spi_device *spi);
24}; 31};
25#endif 32#endif