spi-gpio.c (53279f36dccffc26ff536003fd6bb97cc21c3b82) spi-gpio.c (fd4a319bc933ae93e68935b21924a9ca4ba2d060)
1/*
2 * SPI master driver using generic bitbanged GPIO
3 *
4 * Copyright (C) 2006,2008 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 273 unchanged lines hidden (view full) ---

282 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi);
283 unsigned int cs = spi_gpio->cs_gpios[spi->chip_select];
284
285 if (cs != SPI_GPIO_NO_CHIPSELECT)
286 gpio_free(cs);
287 spi_bitbang_cleanup(spi);
288}
289
1/*
2 * SPI master driver using generic bitbanged GPIO
3 *
4 * Copyright (C) 2006,2008 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 273 unchanged lines hidden (view full) ---

282 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi);
283 unsigned int cs = spi_gpio->cs_gpios[spi->chip_select];
284
285 if (cs != SPI_GPIO_NO_CHIPSELECT)
286 gpio_free(cs);
287 spi_bitbang_cleanup(spi);
288}
289
290static int __devinit spi_gpio_alloc(unsigned pin, const char *label, bool is_in)
290static int spi_gpio_alloc(unsigned pin, const char *label, bool is_in)
291{
292 int value;
293
294 value = gpio_request(pin, label);
295 if (value == 0) {
296 if (is_in)
297 value = gpio_direction_input(pin);
298 else
299 value = gpio_direction_output(pin, 0);
300 }
301 return value;
302}
303
291{
292 int value;
293
294 value = gpio_request(pin, label);
295 if (value == 0) {
296 if (is_in)
297 value = gpio_direction_input(pin);
298 else
299 value = gpio_direction_output(pin, 0);
300 }
301 return value;
302}
303
304static int __devinit
305spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label,
306 u16 *res_flags)
304static int spi_gpio_request(struct spi_gpio_platform_data *pdata,
305 const char *label, u16 *res_flags)
307{
308 int value;
309
310 /* NOTE: SPI_*_GPIO symbols may reference "pdata" */
311
312 if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI) {
313 value = spi_gpio_alloc(SPI_MOSI_GPIO, label, false);
314 if (value)

--- 72 unchanged lines hidden (view full) ---

387}
388#else
389static inline int spi_gpio_probe_dt(struct platform_device *pdev)
390{
391 return 0;
392}
393#endif
394
306{
307 int value;
308
309 /* NOTE: SPI_*_GPIO symbols may reference "pdata" */
310
311 if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI) {
312 value = spi_gpio_alloc(SPI_MOSI_GPIO, label, false);
313 if (value)

--- 72 unchanged lines hidden (view full) ---

386}
387#else
388static inline int spi_gpio_probe_dt(struct platform_device *pdev)
389{
390 return 0;
391}
392#endif
393
395static int __devinit spi_gpio_probe(struct platform_device *pdev)
394static int spi_gpio_probe(struct platform_device *pdev)
396{
397 int status;
398 struct spi_master *master;
399 struct spi_gpio *spi_gpio;
400 struct spi_gpio_platform_data *pdata;
401 u16 master_flags = 0;
402 bool use_of = 0;
403

--- 76 unchanged lines hidden (view full) ---

480 gpio_free(SPI_MOSI_GPIO);
481 gpio_free(SPI_SCK_GPIO);
482 spi_master_put(master);
483 }
484
485 return status;
486}
487
395{
396 int status;
397 struct spi_master *master;
398 struct spi_gpio *spi_gpio;
399 struct spi_gpio_platform_data *pdata;
400 u16 master_flags = 0;
401 bool use_of = 0;
402

--- 76 unchanged lines hidden (view full) ---

479 gpio_free(SPI_MOSI_GPIO);
480 gpio_free(SPI_SCK_GPIO);
481 spi_master_put(master);
482 }
483
484 return status;
485}
486
488static int __devexit spi_gpio_remove(struct platform_device *pdev)
487static int spi_gpio_remove(struct platform_device *pdev)
489{
490 struct spi_gpio *spi_gpio;
491 struct spi_gpio_platform_data *pdata;
492 int status;
493
494 spi_gpio = platform_get_drvdata(pdev);
495 pdata = pdev->dev.platform_data;
496

--- 16 unchanged lines hidden (view full) ---

513
514static struct platform_driver spi_gpio_driver = {
515 .driver = {
516 .name = DRIVER_NAME,
517 .owner = THIS_MODULE,
518 .of_match_table = of_match_ptr(spi_gpio_dt_ids),
519 },
520 .probe = spi_gpio_probe,
488{
489 struct spi_gpio *spi_gpio;
490 struct spi_gpio_platform_data *pdata;
491 int status;
492
493 spi_gpio = platform_get_drvdata(pdev);
494 pdata = pdev->dev.platform_data;
495

--- 16 unchanged lines hidden (view full) ---

512
513static struct platform_driver spi_gpio_driver = {
514 .driver = {
515 .name = DRIVER_NAME,
516 .owner = THIS_MODULE,
517 .of_match_table = of_match_ptr(spi_gpio_dt_ids),
518 },
519 .probe = spi_gpio_probe,
521 .remove = __devexit_p(spi_gpio_remove),
520 .remove = spi_gpio_remove,
522};
523module_platform_driver(spi_gpio_driver);
524
525MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO ");
526MODULE_AUTHOR("David Brownell");
527MODULE_LICENSE("GPL");
521};
522module_platform_driver(spi_gpio_driver);
523
524MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO ");
525MODULE_AUTHOR("David Brownell");
526MODULE_LICENSE("GPL");