Andy Shevchenko | e81e11b | 2016-07-05 03:14:50 +0300 | [diff] [blame] | 1 | /* |
| 2 | * spidev platform data initilization file |
| 3 | * |
| 4 | * (C) Copyright 2014, 2016 Intel Corporation |
| 5 | * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
| 6 | * Dan O'Donovan <dan@emutex.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * as published by the Free Software Foundation; version 2 |
| 11 | * of the License. |
| 12 | */ |
| 13 | |
Andy Shevchenko | efa2252 | 2017-01-02 11:24:50 +0200 | [diff] [blame] | 14 | #include <linux/err.h> |
Andy Shevchenko | e81e11b | 2016-07-05 03:14:50 +0300 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/sfi.h> |
| 17 | #include <linux/spi/pxa2xx_spi.h> |
| 18 | #include <linux/spi/spi.h> |
| 19 | |
| 20 | #include <asm/intel-mid.h> |
| 21 | |
| 22 | #define MRFLD_SPI_DEFAULT_DMA_BURST 8 |
| 23 | #define MRFLD_SPI_DEFAULT_TIMEOUT 500 |
| 24 | |
| 25 | /* GPIO pin for spidev chipselect */ |
| 26 | #define MRFLD_SPIDEV_GPIO_CS 111 |
| 27 | |
| 28 | static struct pxa2xx_spi_chip spidev_spi_chip = { |
| 29 | .dma_burst_size = MRFLD_SPI_DEFAULT_DMA_BURST, |
| 30 | .timeout = MRFLD_SPI_DEFAULT_TIMEOUT, |
| 31 | .gpio_cs = MRFLD_SPIDEV_GPIO_CS, |
| 32 | }; |
| 33 | |
| 34 | static void __init *spidev_platform_data(void *info) |
| 35 | { |
| 36 | struct spi_board_info *spi_info = info; |
| 37 | |
Andy Shevchenko | efa2252 | 2017-01-02 11:24:50 +0200 | [diff] [blame] | 38 | if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER) |
| 39 | return ERR_PTR(-ENODEV); |
| 40 | |
Andy Shevchenko | e81e11b | 2016-07-05 03:14:50 +0300 | [diff] [blame] | 41 | spi_info->mode = SPI_MODE_0; |
| 42 | spi_info->controller_data = &spidev_spi_chip; |
| 43 | |
| 44 | return NULL; |
| 45 | } |
| 46 | |
| 47 | static const struct devs_id spidev_dev_id __initconst = { |
| 48 | .name = "spidev", |
| 49 | .type = SFI_DEV_TYPE_SPI, |
| 50 | .delay = 0, |
| 51 | .get_platform_data = &spidev_platform_data, |
| 52 | }; |
| 53 | |
| 54 | sfi_device(spidev_dev_id); |