spi: pxa2xx: Chip select fixes for Intel Baytrail and Braswell
Subsystems (4)
v2 cover spi: pxa2xx: Chip select fixes for Intel Baytrail and Braswell
It turns out that in Windows SPI drivers are responsible for handling ACPI DeviceSelection field themselves. Furthermore there has been separate drivers for big core and atom SPI host controllers. For atom (including Baytrail and Braswell) the driver starts DeviceSelection from 1 instead of 0 as expected by the Linux SPI core.
As an example Microsoft Surface 3 has touch screen connected to SPI bus described in ACPI DSDT like this:
Scope (_SB.PCI0.SPI1)
{
Device (NTRG)
{
Name (_HID, "MSHW0037") // _HID: Hardware ID
...
Name (CRS1, ResourceTemplate ()
{
SpiSerialBus (0x0001, // SPI DeviceSelection
PolarityLow, FourWireMode, 0x10,
ControllerInitiated, 0x007A1200, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.PCI0.SPI1",
0x00, ResourceConsumer, ,
)This fails to enumerate because ACPI DeviceSelection of 1 is greater than number of chip selects the driver supports [1].
This series adds a new hook to struct spi_master ->fw_translate_cs() that allows a driver to translate the chip select number from firmware to the numbering scheme expected by the Linux SPI core and implement that for both Baytrail and Braswell.
In addition to that we add support for the second chip select found on Braswell.
This is a second revision of the series. Changes to the v1:
- Added Jarkko's Reviewed-by
- Use runtime ACPI check in pxa2xx_spi_fw_translate_cs() to prevent build breakage found by kbuild test robot.
[1] https://bugzilla.kernel.org/show_bug.cgi?id=104291
Mika Westerberg (4):
spi: Let drivers translate ACPI DeviceSelection to suitable Linux chip select
spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip select on Baytrail
spi: pxa2xx: Move chip select control bits into lpss_config structure
spi: pxa2xx: Add support for both chip selects on Intel Braswell
drivers/spi/spi-pxa2xx.c | 108 ++++++++++++++++++++++++++++++++++----------- drivers/spi/spi.c | 19 +++++++- include/linux/pxa2xx_ssp.h | 1 + include/linux/spi/spi.h | 5 +++ 4 files changed, 107 insertions(+), 26 deletions(-)
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/4 spi: Let drivers translate ACPI DeviceSelection to suitable Linux chip select
In Windows it is up to the SPI host controller driver to handle the ACPI DeviceSelection as it likes. The SPI core does not take any part in it. This is different in Linux because we always expect to have chip select in range of 0 .. master->num_chipselect - 1.
In order to support this in Linux we need a way to allow the driver to translate between ACPI DeviceSelection field and Linux chip select number so provide a new optional hook ->fw_translate_cs() that can be used by a driver to handle translation and call this hook if set during SPI slave ACPI enumeration.
--- drivers/spi/spi.c | 19 ++++++++++++++++++- include/linux/spi/spi.h | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/spi/spi.c +18 -1
@@ -1581,13 +1581,30 @@ static void of_register_spi_devices(struct spi_master *master) { }static int acpi_spi_add_resource (struct acpi_resource *ares,void *data) {struct spi_device *spi = data; +struct spi_master *master = spi->master;if (ares->type ==ACPI_RESOURCE_TYPE_SERIAL_BUS ) {struct acpi_resource_spi_serialbus *sb; sb = &ares->data.spi_serial_bus;if (sb->type ==ACPI_RESOURCE_SERIAL_TYPE_SPI ) { - spi->chip_select = sb->device_selection; +/* +* ACPI DeviceSelection numbering is handled by the +* host controller driver in Windows and can vary +* from driver to driver. In Linux we always expect +* 0 .. max - 1 so we need to ask the driver to +* translate between the two schemes. +*/ +if (master->fw_translate_cs) { +int cs = master->fw_translate_cs (master, + sb->device_selection); +if (cs <0 ) +return cs; + spi->chip_select = cs; + }else { + spi->chip_select = sb->device_selection; + } + spi->max_speed_hz = sb->connection_speed;if (sb->clock_phase ==ACPI_SPI_SECOND_PHASE )
include/linux/spi/spi.h +5 -0
@@ -369,6 +369,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)* @dma_rx: DMA receive channel * @dummy_rx: dummy receive buffer for full-duplex devices * @dummy_tx: dummy transmit buffer for full-duplex devices +* @fw_translate_cs: If the boot firmware uses different numbering scheme +* what Linux expects, this optional hook can be used to translate +* between the two. * * Each SPI master controller can communicate with one or more @spi_device * children. These make a small bus, sharing MOSI, MISO and SCK signals
@@ -537,6 +540,8 @@ struct spi_master {/* dummy data for full duplex devices */ void *dummy_rx;void *dummy_tx; + +int (*fw_translate_cs)(struct spi_master *master,unsigned cs); };static inline void *spi_master_get_devdata (struct spi_master *master)
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/4 spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip select on Baytrail
In reply to Mika WesterbergThe Windows Baytrail SPI host controller driver uses 1 as the first (and only) value for ACPI DeviceSelection like can be seen in DSDT taken from Lenovo Thinkpad 10:
Device (FPNT)
{
...
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
{
Name (UBUF, ResourceTemplate ()
{
SpiSerialBus (0x0001, // DeviceSelection
PolarityLow, FourWireMode, 0x08,
ControllerInitiated, 0x007A1200, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.SPI1",
0x00, ResourceConsumer,,)This will fail to enumerate in Linux with following error:
[ 0.241296] pxa2xx-spi 80860F0E:00: cs1 >= max 1 [ 0.241312] spi_master spi32766: failed to add SPI device VFSI6101:00 from ACPI
To make the Linux SPI core successfully enumerate the device we provide a custom version of ->fw_translate_cs() that translates DeviceSelection correctly.
--- drivers/spi/spi-pxa2xx.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/spi/spi-pxa2xx.c +23 -0
@@ -1438,6 +1438,28 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) }#endif +static int pxa2xx_spi_fw_translate_cs (struct spi_master *master,unsigned cs) +{ +struct driver_data *drv_data =spi_master_get_devdata (master); + +if (has_acpi_companion (&drv_data->pdev->dev)) { +switch (drv_data->ssp_type) { +/* +* For Atoms the ACPI DeviceSelection used by the Windows +* driver starts from 1 instead of 0 so translate it here +* to match what Linux expects. +*/ +case LPSS_BYT_SSP : +return cs -1 ; + +default : +break ; + } + } + +return cs; +} +static int pxa2xx_spi_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -1490,6 +1512,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) master->setup = setup; master->transfer_one_message = pxa2xx_spi_transfer_one_message; master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer; + master->fw_translate_cs = pxa2xx_spi_fw_translate_cs; master->auto_runtime_pm = true; drv_data->ssp_type = ssp->type;
Signature · 1 line
2.7.0
A message that is not in the archive (sent off-list or not yet received): 1454944471-50119-3-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]
Applied "spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip select on Baytrail" to the spi tree
The patch
spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip select on Baytrail
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
0c27d9cf7245d832d3d34f289c1bcd4f7f3fbd30Mon Sep 17 00:00:00 2001
From: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Mon, 8 Feb 2016 17:14:29 +0200
Subject: [PATCH] spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip
select on Baytrail
The Windows Baytrail SPI host controller driver uses 1 as the first (and only) value for ACPI DeviceSelection like can be seen in DSDT taken from Lenovo Thinkpad 10:
Device (FPNT)
{
...
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
{
Name (UBUF, ResourceTemplate ()
{
SpiSerialBus (0x0001, // DeviceSelection
PolarityLow, FourWireMode, 0x08,
ControllerInitiated, 0x007A1200, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.SPI1",
0x00, ResourceConsumer,,)This will fail to enumerate in Linux with following error:
[ 0.241296] pxa2xx-spi 80860F0E:00: cs1 >= max 1 [ 0.241312] spi_master spi32766: failed to add SPI device VFSI6101:00 from ACPI
To make the Linux SPI core successfully enumerate the device we provide a custom version of ->fw_translate_cs() that translates DeviceSelection correctly.
--- drivers/spi/spi-pxa2xx.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/spi/spi-pxa2xx.c +23 -0
@@ -1445,6 +1445,28 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) }#endif +static int pxa2xx_spi_fw_translate_cs (struct spi_master *master,unsigned cs) +{ +struct driver_data *drv_data =spi_master_get_devdata (master); + +if (has_acpi_companion (&drv_data->pdev->dev)) { +switch (drv_data->ssp_type) { +/* +* For Atoms the ACPI DeviceSelection used by the Windows +* driver starts from 1 instead of 0 so translate it here +* to match what Linux expects. +*/ +case LPSS_BYT_SSP : +return cs -1 ; + +default : +break ; + } + } + +return cs; +} +static int pxa2xx_spi_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -1497,6 +1519,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) master->setup = setup; master->transfer_one_message = pxa2xx_spi_transfer_one_message; master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer; + master->fw_translate_cs = pxa2xx_spi_fw_translate_cs; master->auto_runtime_pm = true; drv_data->ssp_type = ssp->type;
Signature · 6 lines
2.7.0.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/4 spi: pxa2xx: Move chip select control bits into lpss_config structure
In reply to Mika WesterbergSome Intel LPSS SPI controllers, like the one in Braswell has these bits in a different location so move these bits to be part of the LPSS configuration.
Since not all LPSS SPI controllers support multiple native chip selects we refactor selecting chip select to its own function and check control->cs_sel_mask before switching to another chip select.
--- drivers/spi/spi-pxa2xx.c | 64 ++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 24 deletions(-)
drivers/spi/spi-pxa2xx.c +40 -24
@@ -65,8 +65,6 @@ MODULE_ALIAS("platform:pxa2xx-spi");#define LPSS_GENERAL_REG_RXTO_HOLDOFF_DISABLE BIT(24)#define LPSS_CS_CONTROL_SW_MODE BIT(0)#define LPSS_CS_CONTROL_CS_HIGH BIT(1) -#define LPSS_CS_CONTROL_CS_SEL_SHIFT 8 -#define LPSS_CS_CONTROL_CS_SEL_MASK (3 << LPSS_CS_CONTROL_CS_SEL_SHIFT)#define LPSS_CAPS_CS_EN_SHIFT 9#define LPSS_CAPS_CS_EN_MASK (0xf << LPSS_CAPS_CS_EN_SHIFT)
@@ -82,6 +80,9 @@ struct lpss_config {u32 rx_threshold;u32 tx_threshold_lo;u32 tx_threshold_hi; +/* Chip select control */ +unsigned cs_sel_shift; +unsigned cs_sel_mask; };/* Keep these sorted with enum pxa_ssp_type */
@@ -125,6 +126,8 @@ static const struct lpss_config lpss_platforms[] = { .rx_threshold = 1, .tx_threshold_lo = 16, .tx_threshold_hi = 48, + .cs_sel_shift = 8, + .cs_sel_mask = 3 << 8, }, };
@@ -288,37 +291,50 @@ static void lpss_ssp_setup(struct driver_data *drv_data) } } +static void lpss_ssp_select_cs (struct driver_data *drv_data, +const struct lpss_config *config) +{ +u32 value, cs; + +if (!config->cs_sel_mask) +return ; + + value =__lpss_ssp_read_priv (drv_data, config->reg_cs_ctrl); + + cs = drv_data->cur_msg->spi->chip_select; + cs <<= config->cs_sel_shift; +if (cs != (value & config->cs_sel_mask)) { +/* +* When switching another chip select output active the +* output must be selected first and wait 2 ssp_clk cycles +* before changing state to active. Otherwise a short +* glitch will occur on the previous chip select since +* output select is latched but state control is not. +*/ + value &= ~config->cs_sel_mask; + value |= cs; +__lpss_ssp_write_priv (drv_data, + config->reg_cs_ctrl, value); +ndelay (1000000000 / + (drv_data->master->max_speed_hz /2 )); + } +} +static void lpss_ssp_cs_control (struct driver_data *drv_data,bool enable) {const struct lpss_config *config; -u32 value, cs; +u32 value; config =lpss_get_config (drv_data); +if (enable) +lpss_ssp_select_cs (drv_data, config); + value =__lpss_ssp_read_priv (drv_data, config->reg_cs_ctrl); -if (enable) { - cs = drv_data->cur_msg->spi->chip_select; - cs <<=LPSS_CS_CONTROL_CS_SEL_SHIFT ; -if (cs != (value &LPSS_CS_CONTROL_CS_SEL_MASK )) { -/* -* When switching another chip select output active -* the output must be selected first and wait 2 ssp_clk -* cycles before changing state to active. Otherwise -* a short glitch will occur on the previous chip -* select since output select is latched but state -* control is not. -*/ - value &= ~LPSS_CS_CONTROL_CS_SEL_MASK ; - value |= cs; -__lpss_ssp_write_priv (drv_data, - config->reg_cs_ctrl, value); -ndelay (1000000000 / - (drv_data->master->max_speed_hz /2 )); - } +if (enable) value &= ~LPSS_CS_CONTROL_CS_HIGH ; - }else { +else value |=LPSS_CS_CONTROL_CS_HIGH ; - }__lpss_ssp_write_priv (drv_data, config->reg_cs_ctrl, value); }
Signature · 1 line
2.7.0
A message that is not in the archive (sent off-list or not yet received): 1454944471-50119-4-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]
Applied "spi: pxa2xx: Move chip select control bits into lpss_config structure" to the spi tree
The patch
spi: pxa2xx: Move chip select control bits into lpss_config structure
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
c1e4a53c6b8161ded3a44e3352ef38206d0967eaMon Sep 17 00:00:00 2001
From: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Mon, 8 Feb 2016 17:14:30 +0200
Subject: [PATCH] spi: pxa2xx: Move chip select control bits into lpss_config
structure
Some Intel LPSS SPI controllers, like the one in Braswell has these bits in a different location so move these bits to be part of the LPSS configuration.
Since not all LPSS SPI controllers support multiple native chip selects we refactor selecting chip select to its own function and check control->cs_sel_mask before switching to another chip select.
--- drivers/spi/spi-pxa2xx.c | 64 ++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 24 deletions(-)
drivers/spi/spi-pxa2xx.c +40 -24
@@ -65,8 +65,6 @@ MODULE_ALIAS("platform:pxa2xx-spi");#define LPSS_GENERAL_REG_RXTO_HOLDOFF_DISABLE BIT(24)#define LPSS_CS_CONTROL_SW_MODE BIT(0)#define LPSS_CS_CONTROL_CS_HIGH BIT(1) -#define LPSS_CS_CONTROL_CS_SEL_SHIFT 8 -#define LPSS_CS_CONTROL_CS_SEL_MASK (3 << LPSS_CS_CONTROL_CS_SEL_SHIFT)#define LPSS_CAPS_CS_EN_SHIFT 9#define LPSS_CAPS_CS_EN_MASK (0xf << LPSS_CAPS_CS_EN_SHIFT)
@@ -82,6 +80,9 @@ struct lpss_config {u32 rx_threshold;u32 tx_threshold_lo;u32 tx_threshold_hi; +/* Chip select control */ +unsigned cs_sel_shift; +unsigned cs_sel_mask; };/* Keep these sorted with enum pxa_ssp_type */
@@ -125,6 +126,8 @@ static const struct lpss_config lpss_platforms[] = { .rx_threshold = 1, .tx_threshold_lo = 16, .tx_threshold_hi = 48, + .cs_sel_shift = 8, + .cs_sel_mask = 3 << 8, }, };
@@ -288,37 +291,50 @@ static void lpss_ssp_setup(struct driver_data *drv_data) } } +static void lpss_ssp_select_cs (struct driver_data *drv_data, +const struct lpss_config *config) +{ +u32 value, cs; + +if (!config->cs_sel_mask) +return ; + + value =__lpss_ssp_read_priv (drv_data, config->reg_cs_ctrl); + + cs = drv_data->cur_msg->spi->chip_select; + cs <<= config->cs_sel_shift; +if (cs != (value & config->cs_sel_mask)) { +/* +* When switching another chip select output active the +* output must be selected first and wait 2 ssp_clk cycles +* before changing state to active. Otherwise a short +* glitch will occur on the previous chip select since +* output select is latched but state control is not. +*/ + value &= ~config->cs_sel_mask; + value |= cs; +__lpss_ssp_write_priv (drv_data, + config->reg_cs_ctrl, value); +ndelay (1000000000 / + (drv_data->master->max_speed_hz /2 )); + } +} +static void lpss_ssp_cs_control (struct driver_data *drv_data,bool enable) {const struct lpss_config *config; -u32 value, cs; +u32 value; config =lpss_get_config (drv_data); +if (enable) +lpss_ssp_select_cs (drv_data, config); + value =__lpss_ssp_read_priv (drv_data, config->reg_cs_ctrl); -if (enable) { - cs = drv_data->cur_msg->spi->chip_select; - cs <<=LPSS_CS_CONTROL_CS_SEL_SHIFT ; -if (cs != (value &LPSS_CS_CONTROL_CS_SEL_MASK )) { -/* -* When switching another chip select output active -* the output must be selected first and wait 2 ssp_clk -* cycles before changing state to active. Otherwise -* a short glitch will occur on the previous chip -* select since output select is latched but state -* control is not. -*/ - value &= ~LPSS_CS_CONTROL_CS_SEL_MASK ; - value |= cs; -__lpss_ssp_write_priv (drv_data, - config->reg_cs_ctrl, value); -ndelay (1000000000 / - (drv_data->master->max_speed_hz /2 )); - } +if (enable) value &= ~LPSS_CS_CONTROL_CS_HIGH ; - }else { +else value |=LPSS_CS_CONTROL_CS_HIGH ; - }__lpss_ssp_write_priv (drv_data, config->reg_cs_ctrl, value); }
Signature · 6 lines
2.7.0.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 4/4 spi: pxa2xx: Add support for both chip selects on Intel Braswell
In reply to Mika WesterbergIntel Braswell LPSS SPI controller actually has two chip selects and there is no capabilities register where this could be found out. These two chip selects are controlled by bits which are in slightly differrent location than Broxton has.
Braswell Windows driver also starts chip select (ACPI DeviceSelection) numbering from 1 so translate it to be suitable for Linux as well.
--- drivers/spi/spi-pxa2xx.c | 21 ++++++++++++++++++++- include/linux/pxa2xx_ssp.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/spi/spi-pxa2xx.c +20 -1
@@ -83,6 +83,7 @@ struct lpss_config {/* Chip select control */ unsigned cs_sel_shift;unsigned cs_sel_mask; +unsigned cs_num; };/* Keep these sorted with enum pxa_ssp_type */
@@ -107,6 +108,19 @@ static const struct lpss_config lpss_platforms[] = { .tx_threshold_lo = 160, .tx_threshold_hi = 224, }, + {/* LPSS_BSW_SSP */ + .offset = 0x400, + .reg_general = 0x08, + .reg_ssp = 0x0c, + .reg_cs_ctrl = 0x18, + .reg_capabilities = -1, + .rx_threshold = 64, + .tx_threshold_lo = 160, + .tx_threshold_hi = 224, + .cs_sel_shift = 2, + .cs_sel_mask = 1 << 2, + .cs_num = 2, + }, { /* LPSS_SPT_SSP */ .offset = 0x200, .reg_general = -1,
@@ -142,6 +156,7 @@ static bool is_lpss_ssp(const struct driver_data *drv_data)switch (drv_data->ssp_type) {case LPSS_LPT_SSP :case LPSS_BYT_SSP : +case LPSS_BSW_SSP :case LPSS_SPT_SSP :case LPSS_BXT_SSP :return true;
@@ -1182,6 +1197,7 @@ static int setup(struct spi_device *spi)break ;case LPSS_LPT_SSP :case LPSS_BYT_SSP : +case LPSS_BSW_SSP :case LPSS_SPT_SSP :case LPSS_BXT_SSP : config =lpss_get_config (drv_data);
@@ -1329,7 +1345,7 @@ static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { { "INT3430", LPSS_LPT_SSP }, { "INT3431", LPSS_LPT_SSP }, { "80860F0E", LPSS_BYT_SSP }, - { "8086228E", LPSS_BYT_SSP }, + { "8086228E", LPSS_BSW_SSP }, { }, };MODULE_DEVICE_TABLE (acpi, pxa2xx_spi_acpi_match);
@@ -1466,6 +1482,7 @@ static int pxa2xx_spi_fw_translate_cs(struct spi_master *master, unsigned cs)* to match what Linux expects. */ case LPSS_BYT_SSP : +case LPSS_BSW_SSP :return cs -1 ;default :
@@ -1615,6 +1632,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) tmp &=LPSS_CAPS_CS_EN_MASK ; tmp >>=LPSS_CAPS_CS_EN_SHIFT ; platform_info->num_chipselect =ffz (tmp); + }else if (config->cs_num) { + platform_info->num_chipselect = config->cs_num; } } master->num_chipselect = platform_info->num_chipselect;
include/linux/pxa2xx_ssp.h +1 -0
@@ -197,6 +197,7 @@ enum pxa_ssp_type {QUARK_X1000_SSP ,LPSS_LPT_SSP ,/* Keep LPSS types sorted with lpss_platforms[] */ LPSS_BYT_SSP , +LPSS_BSW_SSP ,LPSS_SPT_SSP , LPSS_BXT_SSP, };
Signature · 6 lines
2.7.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1454944471-50119-5-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]
Applied "spi: pxa2xx: Add support for both chip selects on Intel Braswell" to the spi tree
The patch
spi: pxa2xx: Add support for both chip selects on Intel Braswell
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
30f3a6ab44d8d06bb3d94f6320e4aa76df59d025Mon Sep 17 00:00:00 2001
From: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Mon, 8 Feb 2016 17:14:31 +0200
Subject: [PATCH] spi: pxa2xx: Add support for both chip selects on Intel
Braswell
Intel Braswell LPSS SPI controller actually has two chip selects and there is no capabilities register where this could be found out. These two chip selects are controlled by bits which are in slightly differrent location than Broxton has.
Braswell Windows driver also starts chip select (ACPI DeviceSelection) numbering from 1 so translate it to be suitable for Linux as well.
--- drivers/spi/spi-pxa2xx.c | 21 ++++++++++++++++++++- include/linux/pxa2xx_ssp.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/spi/spi-pxa2xx.c +20 -1
@@ -83,6 +83,7 @@ struct lpss_config {/* Chip select control */ unsigned cs_sel_shift;unsigned cs_sel_mask; +unsigned cs_num; };/* Keep these sorted with enum pxa_ssp_type */
@@ -107,6 +108,19 @@ static const struct lpss_config lpss_platforms[] = { .tx_threshold_lo = 160, .tx_threshold_hi = 224, }, + {/* LPSS_BSW_SSP */ + .offset = 0x400, + .reg_general = 0x08, + .reg_ssp = 0x0c, + .reg_cs_ctrl = 0x18, + .reg_capabilities = -1, + .rx_threshold = 64, + .tx_threshold_lo = 160, + .tx_threshold_hi = 224, + .cs_sel_shift = 2, + .cs_sel_mask = 1 << 2, + .cs_num = 2, + }, { /* LPSS_SPT_SSP */ .offset = 0x200, .reg_general = -1,
@@ -142,6 +156,7 @@ static bool is_lpss_ssp(const struct driver_data *drv_data)switch (drv_data->ssp_type) {case LPSS_LPT_SSP :case LPSS_BYT_SSP : +case LPSS_BSW_SSP :case LPSS_SPT_SSP :case LPSS_BXT_SSP :return true;
@@ -1189,6 +1204,7 @@ static int setup(struct spi_device *spi)break ;case LPSS_LPT_SSP :case LPSS_BYT_SSP : +case LPSS_BSW_SSP :case LPSS_SPT_SSP :case LPSS_BXT_SSP : config =lpss_get_config (drv_data);
@@ -1336,7 +1352,7 @@ static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { { "INT3430", LPSS_LPT_SSP }, { "INT3431", LPSS_LPT_SSP }, { "80860F0E", LPSS_BYT_SSP }, - { "8086228E", LPSS_BYT_SSP }, + { "8086228E", LPSS_BSW_SSP }, { }, };MODULE_DEVICE_TABLE (acpi, pxa2xx_spi_acpi_match);
@@ -1473,6 +1489,7 @@ static int pxa2xx_spi_fw_translate_cs(struct spi_master *master, unsigned cs)* to match what Linux expects. */ case LPSS_BYT_SSP : +case LPSS_BSW_SSP :return cs -1 ;default :
@@ -1622,6 +1639,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) tmp &=LPSS_CAPS_CS_EN_MASK ; tmp >>=LPSS_CAPS_CS_EN_SHIFT ; platform_info->num_chipselect =ffz (tmp); + }else if (config->cs_num) { + platform_info->num_chipselect = config->cs_num; } } master->num_chipselect = platform_info->num_chipselect;
include/linux/pxa2xx_ssp.h +1 -0
@@ -197,6 +197,7 @@ enum pxa_ssp_type {QUARK_X1000_SSP ,LPSS_LPT_SSP ,/* Keep LPSS types sorted with lpss_platforms[] */ LPSS_BYT_SSP , +LPSS_BSW_SSP ,LPSS_SPT_SSP , LPSS_BXT_SSP, };
Signature · 6 lines
2.7.0.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 27 lines · Mika Westerberg
It turns out that in Windows SPI drivers are responsible for handling ACPI DeviceSelection field themselves. Furthermore there has been separate drivers for big core and atom SPI host controllers. For atom (including Baytrail and Braswell) the driver starts DeviceSelection from 1 instead of 0 as expected by the Linux SPI core.
As an example Microsoft Surface 3 has touch screen connected to SPI bus described in ACPI DSDT like this:
Scope (_SB.PCI0.SPI1) { Device (NTRG) { Name (_HID, "MSHW0037") // _HID: Hardware ID ... Name (CRS1, ResourceTemplate () { SpiSerialBus (0x0001, // SPI DeviceSelection PolarityLow, FourWireMode, 0x10, ControllerInitiated, 0x007A1200, ClockPolarityLow, ClockPhaseFirst, "\\_SB.PCI0.SPI1", 0x00, ResourceConsumer, , )This fails to enumerate because ACPI DeviceSelection of 1 is greater than number of chip selects the driver supports [1].
Quoted 8 lines
This series adds a new hook to struct
spi_master->fw_translate_cs() that allows a driver to translate the chip select number from firmware to the numbering scheme expected by the Linux SPI core and implement that for both Baytrail and Braswell.In addition to that we add support for the second chip select found on Braswell.
Quoted 27 lines
This is a second revision of the series. Changes to the v1:
- Added Jarkko's Reviewed-by
- Use runtime ACPI check inpxa2xx_spi_fw_translate_cs()to prevent build breakage found by kbuild test robot.[1] https://bugzilla.kernel.org/show_bug.cgi?id=104291
Mika Westerberg (4):
spi: Let drivers translate ACPI DeviceSelection to suitable Linux chip select
spi: pxa2xx: Translate ACPI DeviceSelection to Linux chip select on Baytrail
spi: pxa2xx: Move chip select control bits intolpss_configstructure
spi: pxa2xx: Add support for both chip selects on Intel Braswelldrivers/spi/spi-pxa2xx.c | 108 ++++++++++++++++++++++++++++++++++----------- drivers/spi/spi.c | 19 +++++++- include/linux/pxa2xx_ssp.h | 1 + include/linux/spi/spi.h | 5 +++ 4 files changed, 107 insertions(+), 26 deletions(-)--
2.7.0--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
With Best Regards, Andy Shevchenko