Skip to content

Commit 8b136ba

Browse files
jhnikulabroonie
authored andcommitted
spi: pxa2xx: Detect number of enabled Intel LPSS SPI chip select signals
SPI capabilities register located in private registers space of newer Intel LPSS SPI host controllers tell in register bits 12:9 which chip select signals are enabled. Use that information for detecting the number of chip selects. For simplicity we assume chip selects are enabled one after another without disabled chip selects between. For instance CS0 | CS1 | CS2 but not CS0 | CS1 | CS3. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d0283eb commit 8b136ba

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

drivers/spi/spi-pxa2xx.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* GNU General Public License for more details.
1414
*/
1515

16+
#include <linux/bitops.h>
1617
#include <linux/init.h>
1718
#include <linux/module.h>
1819
#include <linux/device.h>
@@ -66,6 +67,8 @@ MODULE_ALIAS("platform:pxa2xx-spi");
6667
#define LPSS_CS_CONTROL_CS_HIGH BIT(1)
6768
#define LPSS_CS_CONTROL_CS_SEL_SHIFT 8
6869
#define LPSS_CS_CONTROL_CS_SEL_MASK (3 << LPSS_CS_CONTROL_CS_SEL_SHIFT)
70+
#define LPSS_CAPS_CS_EN_SHIFT 9
71+
#define LPSS_CAPS_CS_EN_MASK (0xf << LPSS_CAPS_CS_EN_SHIFT)
6972

7073
struct lpss_config {
7174
/* LPSS offset from drv_data->ioaddr */
@@ -74,6 +77,7 @@ struct lpss_config {
7477
int reg_general;
7578
int reg_ssp;
7679
int reg_cs_ctrl;
80+
int reg_capabilities;
7781
/* FIFO thresholds */
7882
u32 rx_threshold;
7983
u32 tx_threshold_lo;
@@ -87,6 +91,7 @@ static const struct lpss_config lpss_platforms[] = {
8791
.reg_general = 0x08,
8892
.reg_ssp = 0x0c,
8993
.reg_cs_ctrl = 0x18,
94+
.reg_capabilities = -1,
9095
.rx_threshold = 64,
9196
.tx_threshold_lo = 160,
9297
.tx_threshold_hi = 224,
@@ -96,6 +101,7 @@ static const struct lpss_config lpss_platforms[] = {
96101
.reg_general = 0x08,
97102
.reg_ssp = 0x0c,
98103
.reg_cs_ctrl = 0x18,
104+
.reg_capabilities = -1,
99105
.rx_threshold = 64,
100106
.tx_threshold_lo = 160,
101107
.tx_threshold_hi = 224,
@@ -105,6 +111,7 @@ static const struct lpss_config lpss_platforms[] = {
105111
.reg_general = -1,
106112
.reg_ssp = 0x20,
107113
.reg_cs_ctrl = 0x24,
114+
.reg_capabilities = 0xfc,
108115
.rx_threshold = 1,
109116
.tx_threshold_lo = 32,
110117
.tx_threshold_hi = 56,
@@ -1400,6 +1407,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
14001407
struct spi_master *master;
14011408
struct driver_data *drv_data;
14021409
struct ssp_device *ssp;
1410+
const struct lpss_config *config;
14031411
int status;
14041412
u32 tmp;
14051413

@@ -1439,7 +1447,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
14391447
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
14401448

14411449
master->bus_num = ssp->port_id;
1442-
master->num_chipselect = platform_info->num_chipselect;
14431450
master->dma_alignment = DMA_ALIGNMENT;
14441451
master->cleanup = cleanup;
14451452
master->setup = setup;
@@ -1525,6 +1532,19 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
15251532
if (is_lpss_ssp(drv_data))
15261533
lpss_ssp_setup(drv_data);
15271534

1535+
if (is_lpss_ssp(drv_data)) {
1536+
lpss_ssp_setup(drv_data);
1537+
config = lpss_get_config(drv_data);
1538+
if (config->reg_capabilities >= 0) {
1539+
tmp = __lpss_ssp_read_priv(drv_data,
1540+
config->reg_capabilities);
1541+
tmp &= LPSS_CAPS_CS_EN_MASK;
1542+
tmp >>= LPSS_CAPS_CS_EN_SHIFT;
1543+
platform_info->num_chipselect = ffz(tmp);
1544+
}
1545+
}
1546+
master->num_chipselect = platform_info->num_chipselect;
1547+
15281548
tasklet_init(&drv_data->pump_transfers, pump_transfers,
15291549
(unsigned long)drv_data);
15301550

0 commit comments

Comments
 (0)