diff options
author | Stephen Warren <swarren@nvidia.com> | 2013-02-15 17:03:49 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-04-07 05:07:59 -0400 |
commit | c60fea02141167cc277ff92fd6ee21448f56449f (patch) | |
tree | c66985cbb8265d5635e3d1c3c590dc274d3d5df7 /drivers/spi/spi-tegra20-slink.c | |
parent | e2546959192756f474ef299cbfe070cbfb675ef3 (diff) |
spi/tegra-slink: assume CONFIG_OF, remove platform data
Tegra only supports, and always enables, device tree. Remove all ifdefs
and runtime checks for DT support from the driver. Platform data is
therefore no longer required. Rework the driver to parse the device tree
directly into struct tegra_slink_data.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi-tegra20-slink.c')
-rw-r--r-- | drivers/spi/spi-tegra20-slink.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c index d35315408f64..9c02470fa170 100644 --- a/drivers/spi/spi-tegra20-slink.c +++ b/drivers/spi/spi-tegra20-slink.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/of.h> | 34 | #include <linux/of.h> |
35 | #include <linux/of_device.h> | 35 | #include <linux/of_device.h> |
36 | #include <linux/spi/spi.h> | 36 | #include <linux/spi/spi.h> |
37 | #include <linux/spi/spi-tegra.h> | ||
38 | #include <linux/clk/tegra.h> | 37 | #include <linux/clk/tegra.h> |
39 | 38 | ||
40 | #define SLINK_COMMAND 0x000 | 39 | #define SLINK_COMMAND 0x000 |
@@ -1032,29 +1031,18 @@ static irqreturn_t tegra_slink_isr(int irq, void *context_data) | |||
1032 | return IRQ_WAKE_THREAD; | 1031 | return IRQ_WAKE_THREAD; |
1033 | } | 1032 | } |
1034 | 1033 | ||
1035 | static struct tegra_spi_platform_data *tegra_slink_parse_dt( | 1034 | static void tegra_slink_parse_dt(struct tegra_slink_data *tspi) |
1036 | struct platform_device *pdev) | ||
1037 | { | 1035 | { |
1038 | struct tegra_spi_platform_data *pdata; | 1036 | struct device_node *np = tspi->dev->of_node; |
1039 | const unsigned int *prop; | ||
1040 | struct device_node *np = pdev->dev.of_node; | ||
1041 | u32 of_dma[2]; | 1037 | u32 of_dma[2]; |
1042 | 1038 | ||
1043 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
1044 | if (!pdata) { | ||
1045 | dev_err(&pdev->dev, "Memory alloc for pdata failed\n"); | ||
1046 | return NULL; | ||
1047 | } | ||
1048 | |||
1049 | if (of_property_read_u32_array(np, "nvidia,dma-request-selector", | 1039 | if (of_property_read_u32_array(np, "nvidia,dma-request-selector", |
1050 | of_dma, 2) >= 0) | 1040 | of_dma, 2) >= 0) |
1051 | pdata->dma_req_sel = of_dma[1]; | 1041 | tspi->dma_req_sel = of_dma[1]; |
1052 | 1042 | ||
1053 | prop = of_get_property(np, "spi-max-frequency", NULL); | 1043 | if (of_property_read_u32(np, "spi-max-frequency", |
1054 | if (prop) | 1044 | &tspi->spi_max_frequency)) |
1055 | pdata->spi_max_frequency = be32_to_cpup(prop); | 1045 | tspi->spi_max_frequency = 25000000; /* 25MHz */ |
1056 | |||
1057 | return pdata; | ||
1058 | } | 1046 | } |
1059 | 1047 | ||
1060 | const struct tegra_slink_chip_data tegra30_spi_cdata = { | 1048 | const struct tegra_slink_chip_data tegra30_spi_cdata = { |
@@ -1077,27 +1065,16 @@ static int tegra_slink_probe(struct platform_device *pdev) | |||
1077 | struct spi_master *master; | 1065 | struct spi_master *master; |
1078 | struct tegra_slink_data *tspi; | 1066 | struct tegra_slink_data *tspi; |
1079 | struct resource *r; | 1067 | struct resource *r; |
1080 | struct tegra_spi_platform_data *pdata = pdev->dev.platform_data; | ||
1081 | int ret, spi_irq; | 1068 | int ret, spi_irq; |
1082 | const struct tegra_slink_chip_data *cdata = NULL; | 1069 | const struct tegra_slink_chip_data *cdata = NULL; |
1083 | const struct of_device_id *match; | 1070 | const struct of_device_id *match; |
1084 | 1071 | ||
1085 | match = of_match_device(of_match_ptr(tegra_slink_of_match), &pdev->dev); | 1072 | match = of_match_device(tegra_slink_of_match, &pdev->dev); |
1086 | if (!match) { | 1073 | if (!match) { |
1087 | dev_err(&pdev->dev, "Error: No device match found\n"); | 1074 | dev_err(&pdev->dev, "Error: No device match found\n"); |
1088 | return -ENODEV; | 1075 | return -ENODEV; |
1089 | } | 1076 | } |
1090 | cdata = match->data; | 1077 | cdata = match->data; |
1091 | if (!pdata && pdev->dev.of_node) | ||
1092 | pdata = tegra_slink_parse_dt(pdev); | ||
1093 | |||
1094 | if (!pdata) { | ||
1095 | dev_err(&pdev->dev, "No platform data, exiting\n"); | ||
1096 | return -ENODEV; | ||
1097 | } | ||
1098 | |||
1099 | if (!pdata->spi_max_frequency) | ||
1100 | pdata->spi_max_frequency = 25000000; /* 25MHz */ | ||
1101 | 1078 | ||
1102 | master = spi_alloc_master(&pdev->dev, sizeof(*tspi)); | 1079 | master = spi_alloc_master(&pdev->dev, sizeof(*tspi)); |
1103 | if (!master) { | 1080 | if (!master) { |
@@ -1115,11 +1092,12 @@ static int tegra_slink_probe(struct platform_device *pdev) | |||
1115 | dev_set_drvdata(&pdev->dev, master); | 1092 | dev_set_drvdata(&pdev->dev, master); |
1116 | tspi = spi_master_get_devdata(master); | 1093 | tspi = spi_master_get_devdata(master); |
1117 | tspi->master = master; | 1094 | tspi->master = master; |
1118 | tspi->dma_req_sel = pdata->dma_req_sel; | ||
1119 | tspi->dev = &pdev->dev; | 1095 | tspi->dev = &pdev->dev; |
1120 | tspi->chip_data = cdata; | 1096 | tspi->chip_data = cdata; |
1121 | spin_lock_init(&tspi->lock); | 1097 | spin_lock_init(&tspi->lock); |
1122 | 1098 | ||
1099 | tegra_slink_parse_dt(tspi); | ||
1100 | |||
1123 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1101 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1124 | if (!r) { | 1102 | if (!r) { |
1125 | dev_err(&pdev->dev, "No IO memory resource\n"); | 1103 | dev_err(&pdev->dev, "No IO memory resource\n"); |
@@ -1153,9 +1131,8 @@ static int tegra_slink_probe(struct platform_device *pdev) | |||
1153 | 1131 | ||
1154 | tspi->max_buf_size = SLINK_FIFO_DEPTH << 2; | 1132 | tspi->max_buf_size = SLINK_FIFO_DEPTH << 2; |
1155 | tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; | 1133 | tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; |
1156 | tspi->spi_max_frequency = pdata->spi_max_frequency; | ||
1157 | 1134 | ||
1158 | if (pdata->dma_req_sel) { | 1135 | if (tspi->dma_req_sel) { |
1159 | ret = tegra_slink_init_dma_param(tspi, true); | 1136 | ret = tegra_slink_init_dma_param(tspi, true); |
1160 | if (ret < 0) { | 1137 | if (ret < 0) { |
1161 | dev_err(&pdev->dev, "RxDma Init failed, err %d\n", ret); | 1138 | dev_err(&pdev->dev, "RxDma Init failed, err %d\n", ret); |
@@ -1298,7 +1275,7 @@ static struct platform_driver tegra_slink_driver = { | |||
1298 | .name = "spi-tegra-slink", | 1275 | .name = "spi-tegra-slink", |
1299 | .owner = THIS_MODULE, | 1276 | .owner = THIS_MODULE, |
1300 | .pm = &slink_pm_ops, | 1277 | .pm = &slink_pm_ops, |
1301 | .of_match_table = of_match_ptr(tegra_slink_of_match), | 1278 | .of_match_table = tegra_slink_of_match, |
1302 | }, | 1279 | }, |
1303 | .probe = tegra_slink_probe, | 1280 | .probe = tegra_slink_probe, |
1304 | .remove = tegra_slink_remove, | 1281 | .remove = tegra_slink_remove, |