diff options
author | Angelo Dureghello <angelo@sysam.it> | 2017-10-27 18:23:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-11-03 07:53:16 -0400 |
commit | ec7ed7708e009e046d1e16ed53ba4d6048748d07 (patch) | |
tree | 4e9b8c2cc69ee6974101e1d73f713531ac4774b5 | |
parent | 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e (diff) |
spi: spi-fsl-dspi: enabling Coldfire mcf5441x dspi
Signed-off-by: Angelo Dureghello <angelo@sysam.it>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/Kconfig | 2 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-dspi.c | 66 | ||||
-rw-r--r-- | include/linux/spi/spi-fsl-dspi.h | 31 |
3 files changed, 77 insertions, 22 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index a75f2a2cf780..a8b761979673 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -379,7 +379,7 @@ config SPI_FSL_DSPI | |||
379 | tristate "Freescale DSPI controller" | 379 | tristate "Freescale DSPI controller" |
380 | select REGMAP_MMIO | 380 | select REGMAP_MMIO |
381 | depends on HAS_DMA | 381 | depends on HAS_DMA |
382 | depends on SOC_VF610 || SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST | 382 | depends on SOC_VF610 || SOC_LS1021A || ARCH_LAYERSCAPE || M5441x || COMPILE_TEST |
383 | help | 383 | help |
384 | This enables support for the Freescale DSPI controller in master | 384 | This enables support for the Freescale DSPI controller in master |
385 | mode. VF610 platform uses the controller. | 385 | mode. VF610 platform uses the controller. |
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index d89127f4a46d..f652f70cb8db 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/regmap.h> | 32 | #include <linux/regmap.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/spi/spi.h> | 34 | #include <linux/spi/spi.h> |
35 | #include <linux/spi/spi-fsl-dspi.h> | ||
35 | #include <linux/spi/spi_bitbang.h> | 36 | #include <linux/spi/spi_bitbang.h> |
36 | #include <linux/time.h> | 37 | #include <linux/time.h> |
37 | 38 | ||
@@ -151,6 +152,11 @@ static const struct fsl_dspi_devtype_data ls2085a_data = { | |||
151 | .max_clock_factor = 8, | 152 | .max_clock_factor = 8, |
152 | }; | 153 | }; |
153 | 154 | ||
155 | static const struct fsl_dspi_devtype_data coldfire_data = { | ||
156 | .trans_mode = DSPI_EOQ_MODE, | ||
157 | .max_clock_factor = 8, | ||
158 | }; | ||
159 | |||
154 | struct fsl_dspi_dma { | 160 | struct fsl_dspi_dma { |
155 | /* Length of transfer in words of DSPI_FIFO_SIZE */ | 161 | /* Length of transfer in words of DSPI_FIFO_SIZE */ |
156 | u32 curr_xfer_len; | 162 | u32 curr_xfer_len; |
@@ -741,6 +747,7 @@ static int dspi_setup(struct spi_device *spi) | |||
741 | { | 747 | { |
742 | struct chip_data *chip; | 748 | struct chip_data *chip; |
743 | struct fsl_dspi *dspi = spi_master_get_devdata(spi->master); | 749 | struct fsl_dspi *dspi = spi_master_get_devdata(spi->master); |
750 | struct fsl_dspi_platform_data *pdata; | ||
744 | u32 cs_sck_delay = 0, sck_cs_delay = 0; | 751 | u32 cs_sck_delay = 0, sck_cs_delay = 0; |
745 | unsigned char br = 0, pbr = 0, pcssck = 0, cssck = 0; | 752 | unsigned char br = 0, pbr = 0, pcssck = 0, cssck = 0; |
746 | unsigned char pasc = 0, asc = 0, fmsz = 0; | 753 | unsigned char pasc = 0, asc = 0, fmsz = 0; |
@@ -761,11 +768,18 @@ static int dspi_setup(struct spi_device *spi) | |||
761 | return -ENOMEM; | 768 | return -ENOMEM; |
762 | } | 769 | } |
763 | 770 | ||
764 | of_property_read_u32(spi->dev.of_node, "fsl,spi-cs-sck-delay", | 771 | pdata = dev_get_platdata(&dspi->pdev->dev); |
765 | &cs_sck_delay); | ||
766 | 772 | ||
767 | of_property_read_u32(spi->dev.of_node, "fsl,spi-sck-cs-delay", | 773 | if (!pdata) { |
768 | &sck_cs_delay); | 774 | of_property_read_u32(spi->dev.of_node, "fsl,spi-cs-sck-delay", |
775 | &cs_sck_delay); | ||
776 | |||
777 | of_property_read_u32(spi->dev.of_node, "fsl,spi-sck-cs-delay", | ||
778 | &sck_cs_delay); | ||
779 | } else { | ||
780 | cs_sck_delay = pdata->cs_sck_delay; | ||
781 | sck_cs_delay = pdata->sck_cs_delay; | ||
782 | } | ||
769 | 783 | ||
770 | chip->mcr_val = SPI_MCR_MASTER | SPI_MCR_PCSIS | | 784 | chip->mcr_val = SPI_MCR_MASTER | SPI_MCR_PCSIS | |
771 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF; | 785 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF; |
@@ -949,6 +963,7 @@ static int dspi_probe(struct platform_device *pdev) | |||
949 | struct fsl_dspi *dspi; | 963 | struct fsl_dspi *dspi; |
950 | struct resource *res; | 964 | struct resource *res; |
951 | void __iomem *base; | 965 | void __iomem *base; |
966 | struct fsl_dspi_platform_data *pdata; | ||
952 | int ret = 0, cs_num, bus_num; | 967 | int ret = 0, cs_num, bus_num; |
953 | 968 | ||
954 | master = spi_alloc_master(&pdev->dev, sizeof(struct fsl_dspi)); | 969 | master = spi_alloc_master(&pdev->dev, sizeof(struct fsl_dspi)); |
@@ -969,25 +984,34 @@ static int dspi_probe(struct platform_device *pdev) | |||
969 | master->bits_per_word_mask = SPI_BPW_MASK(4) | SPI_BPW_MASK(8) | | 984 | master->bits_per_word_mask = SPI_BPW_MASK(4) | SPI_BPW_MASK(8) | |
970 | SPI_BPW_MASK(16); | 985 | SPI_BPW_MASK(16); |
971 | 986 | ||
972 | ret = of_property_read_u32(np, "spi-num-chipselects", &cs_num); | 987 | pdata = dev_get_platdata(&pdev->dev); |
973 | if (ret < 0) { | 988 | if (pdata) { |
974 | dev_err(&pdev->dev, "can't get spi-num-chipselects\n"); | 989 | master->num_chipselect = pdata->cs_num; |
975 | goto out_master_put; | 990 | master->bus_num = pdata->bus_num; |
976 | } | ||
977 | master->num_chipselect = cs_num; | ||
978 | 991 | ||
979 | ret = of_property_read_u32(np, "bus-num", &bus_num); | 992 | dspi->devtype_data = &coldfire_data; |
980 | if (ret < 0) { | 993 | } else { |
981 | dev_err(&pdev->dev, "can't get bus-num\n"); | ||
982 | goto out_master_put; | ||
983 | } | ||
984 | master->bus_num = bus_num; | ||
985 | 994 | ||
986 | dspi->devtype_data = of_device_get_match_data(&pdev->dev); | 995 | ret = of_property_read_u32(np, "spi-num-chipselects", &cs_num); |
987 | if (!dspi->devtype_data) { | 996 | if (ret < 0) { |
988 | dev_err(&pdev->dev, "can't get devtype_data\n"); | 997 | dev_err(&pdev->dev, "can't get spi-num-chipselects\n"); |
989 | ret = -EFAULT; | 998 | goto out_master_put; |
990 | goto out_master_put; | 999 | } |
1000 | master->num_chipselect = cs_num; | ||
1001 | |||
1002 | ret = of_property_read_u32(np, "bus-num", &bus_num); | ||
1003 | if (ret < 0) { | ||
1004 | dev_err(&pdev->dev, "can't get bus-num\n"); | ||
1005 | goto out_master_put; | ||
1006 | } | ||
1007 | master->bus_num = bus_num; | ||
1008 | |||
1009 | dspi->devtype_data = of_device_get_match_data(&pdev->dev); | ||
1010 | if (!dspi->devtype_data) { | ||
1011 | dev_err(&pdev->dev, "can't get devtype_data\n"); | ||
1012 | ret = -EFAULT; | ||
1013 | goto out_master_put; | ||
1014 | } | ||
991 | } | 1015 | } |
992 | 1016 | ||
993 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1017 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/include/linux/spi/spi-fsl-dspi.h b/include/linux/spi/spi-fsl-dspi.h new file mode 100644 index 000000000000..74c9bae20bf2 --- /dev/null +++ b/include/linux/spi/spi-fsl-dspi.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Freescale DSPI controller driver | ||
3 | * | ||
4 | * Copyright (c) 2017 Angelo Dureghello <angelo@sysam.it> | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #ifndef SPI_FSL_DSPI_HEADER_H | ||
17 | #define SPI_FSL_DSPI_HEADER_H | ||
18 | |||
19 | /** | ||
20 | * struct fsl_dspi_platform_data - platform data for the Freescale DSPI driver | ||
21 | * @bus_num: board specific identifier for this DSPI driver. | ||
22 | * @cs_num: number of chip selects supported by this DSPI driver. | ||
23 | */ | ||
24 | struct fsl_dspi_platform_data { | ||
25 | u32 cs_num; | ||
26 | u32 bus_num; | ||
27 | u32 sck_cs_delay; | ||
28 | u32 cs_sck_delay; | ||
29 | }; | ||
30 | |||
31 | #endif /* SPI_FSL_DSPI_HEADER_H */ | ||