spi-pxa2xx.c (527c465a3c8716d93201ae34b7fc52679610596d) spi-pxa2xx.c (34cadd9c1bcbd5ad5a1f379b013526a8046d4aed)
1/*
2 * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
3 * Copyright (C) 2013, Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

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

16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/device.h>
19#include <linux/ioport.h>
20#include <linux/errno.h>
21#include <linux/err.h>
22#include <linux/interrupt.h>
23#include <linux/kernel.h>
1/*
2 * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs
3 * Copyright (C) 2013, Intel Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

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

16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/device.h>
19#include <linux/ioport.h>
20#include <linux/errno.h>
21#include <linux/err.h>
22#include <linux/interrupt.h>
23#include <linux/kernel.h>
24#include <linux/pci.h>
24#include <linux/platform_device.h>
25#include <linux/spi/pxa2xx_spi.h>
26#include <linux/spi/spi.h>
27#include <linux/delay.h>
28#include <linux/gpio.h>
29#include <linux/slab.h>
30#include <linux/clk.h>
31#include <linux/pm_runtime.h>

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

92 .offset = 0x400,
93 .reg_general = 0x08,
94 .reg_ssp = 0x0c,
95 .reg_cs_ctrl = 0x18,
96 .rx_threshold = 64,
97 .tx_threshold_lo = 160,
98 .tx_threshold_hi = 224,
99 },
25#include <linux/platform_device.h>
26#include <linux/spi/pxa2xx_spi.h>
27#include <linux/spi/spi.h>
28#include <linux/delay.h>
29#include <linux/gpio.h>
30#include <linux/slab.h>
31#include <linux/clk.h>
32#include <linux/pm_runtime.h>

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

93 .offset = 0x400,
94 .reg_general = 0x08,
95 .reg_ssp = 0x0c,
96 .reg_cs_ctrl = 0x18,
97 .rx_threshold = 64,
98 .tx_threshold_lo = 160,
99 .tx_threshold_hi = 224,
100 },
101 { /* LPSS_SPT_SSP */
102 .offset = 0x200,
103 .reg_general = -1,
104 .reg_ssp = 0x20,
105 .reg_cs_ctrl = 0x24,
106 .rx_threshold = 1,
107 .tx_threshold_lo = 32,
108 .tx_threshold_hi = 56,
109 },
100};
101
102static inline const struct lpss_config
103*lpss_get_config(const struct driver_data *drv_data)
104{
105 return &lpss_platforms[drv_data->ssp_type - LPSS_LPT_SSP];
106}
107
108static bool is_lpss_ssp(const struct driver_data *drv_data)
109{
110 switch (drv_data->ssp_type) {
111 case LPSS_LPT_SSP:
112 case LPSS_BYT_SSP:
110};
111
112static inline const struct lpss_config
113*lpss_get_config(const struct driver_data *drv_data)
114{
115 return &lpss_platforms[drv_data->ssp_type - LPSS_LPT_SSP];
116}
117
118static bool is_lpss_ssp(const struct driver_data *drv_data)
119{
120 switch (drv_data->ssp_type) {
121 case LPSS_LPT_SSP:
122 case LPSS_BYT_SSP:
123 case LPSS_SPT_SSP:
113 return true;
114 default:
115 return false;
116 }
117}
118
119static bool is_quark_x1000_ssp(const struct driver_data *drv_data)
120{

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

1102 switch (drv_data->ssp_type) {
1103 case QUARK_X1000_SSP:
1104 tx_thres = TX_THRESH_QUARK_X1000_DFLT;
1105 tx_hi_thres = 0;
1106 rx_thres = RX_THRESH_QUARK_X1000_DFLT;
1107 break;
1108 case LPSS_LPT_SSP:
1109 case LPSS_BYT_SSP:
124 return true;
125 default:
126 return false;
127 }
128}
129
130static bool is_quark_x1000_ssp(const struct driver_data *drv_data)
131{

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

1113 switch (drv_data->ssp_type) {
1114 case QUARK_X1000_SSP:
1115 tx_thres = TX_THRESH_QUARK_X1000_DFLT;
1116 tx_hi_thres = 0;
1117 rx_thres = RX_THRESH_QUARK_X1000_DFLT;
1118 break;
1119 case LPSS_LPT_SSP:
1120 case LPSS_BYT_SSP:
1121 case LPSS_SPT_SSP:
1110 config = lpss_get_config(drv_data);
1111 tx_thres = config->tx_threshold_lo;
1112 tx_hi_thres = config->tx_threshold_hi;
1113 rx_thres = config->rx_threshold;
1114 break;
1115 default:
1116 tx_thres = TX_THRESH_DFLT;
1117 tx_hi_thres = 0;

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

1271 { "INT3430", LPSS_LPT_SSP },
1272 { "INT3431", LPSS_LPT_SSP },
1273 { "80860F0E", LPSS_BYT_SSP },
1274 { "8086228E", LPSS_BYT_SSP },
1275 { },
1276};
1277MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
1278
1122 config = lpss_get_config(drv_data);
1123 tx_thres = config->tx_threshold_lo;
1124 tx_hi_thres = config->tx_threshold_hi;
1125 rx_thres = config->rx_threshold;
1126 break;
1127 default:
1128 tx_thres = TX_THRESH_DFLT;
1129 tx_hi_thres = 0;

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

1283 { "INT3430", LPSS_LPT_SSP },
1284 { "INT3431", LPSS_LPT_SSP },
1285 { "80860F0E", LPSS_BYT_SSP },
1286 { "8086228E", LPSS_BYT_SSP },
1287 { },
1288};
1289MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
1290
1291/*
1292 * PCI IDs of compound devices that integrate both host controller and private
1293 * integrated DMA engine. Please note these are not used in module
1294 * autoloading and probing in this module but matching the LPSS SSP type.
1295 */
1296static const struct pci_device_id pxa2xx_spi_pci_compound_match[] = {
1297 /* SPT-LP */
1298 { PCI_VDEVICE(INTEL, 0x9d29), LPSS_SPT_SSP },
1299 { PCI_VDEVICE(INTEL, 0x9d2a), LPSS_SPT_SSP },
1300 /* SPT-H */
1301 { PCI_VDEVICE(INTEL, 0xa129), LPSS_SPT_SSP },
1302 { PCI_VDEVICE(INTEL, 0xa12a), LPSS_SPT_SSP },
1303};
1304
1305static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param)
1306{
1307 struct device *dev = param;
1308
1309 if (dev != chan->device->dev->parent)
1310 return false;
1311
1312 return true;
1313}
1314
1279static struct pxa2xx_spi_master *
1280pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
1281{
1282 struct pxa2xx_spi_master *pdata;
1283 struct acpi_device *adev;
1284 struct ssp_device *ssp;
1285 struct resource *res;
1315static struct pxa2xx_spi_master *
1316pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
1317{
1318 struct pxa2xx_spi_master *pdata;
1319 struct acpi_device *adev;
1320 struct ssp_device *ssp;
1321 struct resource *res;
1286 const struct acpi_device_id *id;
1322 const struct acpi_device_id *adev_id = NULL;
1323 const struct pci_device_id *pcidev_id = NULL;
1287 int devid, type;
1288
1289 if (!ACPI_HANDLE(&pdev->dev) ||
1290 acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev))
1291 return NULL;
1292
1324 int devid, type;
1325
1326 if (!ACPI_HANDLE(&pdev->dev) ||
1327 acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev))
1328 return NULL;
1329
1293 id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
1294 if (id)
1295 type = (int)id->driver_data;
1330 if (dev_is_pci(pdev->dev.parent))
1331 pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match,
1332 to_pci_dev(pdev->dev.parent));
1296 else
1333 else
1334 adev_id = acpi_match_device(pdev->dev.driver->acpi_match_table,
1335 &pdev->dev);
1336
1337 if (adev_id)
1338 type = (int)adev_id->driver_data;
1339 else if (pcidev_id)
1340 type = (int)pcidev_id->driver_data;
1341 else
1297 return NULL;
1298
1299 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1300 if (!pdata)
1301 return NULL;
1302
1303 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1304 if (!res)
1305 return NULL;
1306
1307 ssp = &pdata->ssp;
1308
1309 ssp->phys_base = res->start;
1310 ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res);
1311 if (IS_ERR(ssp->mmio_base))
1312 return NULL;
1313
1342 return NULL;
1343
1344 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1345 if (!pdata)
1346 return NULL;
1347
1348 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1349 if (!res)
1350 return NULL;
1351
1352 ssp = &pdata->ssp;
1353
1354 ssp->phys_base = res->start;
1355 ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res);
1356 if (IS_ERR(ssp->mmio_base))
1357 return NULL;
1358
1359 if (pcidev_id) {
1360 pdata->tx_param = pdev->dev.parent;
1361 pdata->rx_param = pdev->dev.parent;
1362 pdata->dma_filter = pxa2xx_spi_idma_filter;
1363 }
1364
1314 ssp->clk = devm_clk_get(&pdev->dev, NULL);
1315 ssp->irq = platform_get_irq(pdev, 0);
1316 ssp->type = type;
1317 ssp->pdev = pdev;
1318
1319 ssp->port_id = -1;
1320 if (adev->pnp.unique_id && !kstrtoint(adev->pnp.unique_id, 0, &devid))
1321 ssp->port_id = devid;

--- 310 unchanged lines hidden ---
1365 ssp->clk = devm_clk_get(&pdev->dev, NULL);
1366 ssp->irq = platform_get_irq(pdev, 0);
1367 ssp->type = type;
1368 ssp->pdev = pdev;
1369
1370 ssp->port_id = -1;
1371 if (adev->pnp.unique_id && !kstrtoint(adev->pnp.unique_id, 0, &devid))
1372 ssp->port_id = devid;

--- 310 unchanged lines hidden ---