spi: Add support for stacked/parallel memories
Subsystems (5)
v10 cover spi: Add support for stacked/parallel memories
This patch is in the continuation to the discussions which happened on 'commit f89504300e94 ("spi: Stacked/parallel memories bindings")' for adding dt-binding support for stacked/parallel memories.
This patch series updated the spi-nor, spi core and the AMD-Xilinx GQSPI driver to add stacked and parallel memories support.
The first nine patches
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
of the previous series got applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next But the rest of the patches in the series did not get applied as failure was reported for spi driver with GPIO CS, so send the remaining patches in the series after rebasing it on top of for-next branch and fixing the issue.
CS GPIO is not tested due to unavailability of necessary hardware setup.
---
BRANCH: for-next
Changes in v10:
- Rebased patch series on top of latest for-next branch and fixed merge conflicts.
Changes in v9:
- Updated 1/8 patch description to add an high-level overview of parallel(multi-cs) & stacked design.
- Initialized all unused CS to 0xFF.
- Moved CS check from spi_add_device() to __spi_add_device().
- Updated __spi_add_device() to check to make sure that multiple logical CS don't map to the same physical CS and same physical CS doesn't map to different logical CS.
- Updated 1/8, 5/8 & 7/8 to support arbitrary number of flash devices connected in parallel or stacked mode.
- Updated documentation for chip_select.
- Added a new spi-nor structure member nor->num_flash to keep track of the number of flashes connected.
- Added a new patch in the series 4/8 to move write_enable call just before spi_mem ops call in SPI-NOR.
- Added comments in SPI core & SPI-NOR.
- Rebased the patch series on top of the latest for-next branch.
Changes in v8:
- Updated __spi_add_device() and spi_set_cs() to fix spi driver failure with GPIO CS.
- Rebased the patch series on top of latest for-next branch and fixed merge conflicts.
- Updated cover letter description to add information regarding GPIO CS testing and request Stefan to provide his Tested-by tag for 1/7 patch.
- Updated 1/7 patch description.
Changes in v7:
- Updated spi_dev_check() to avoid failures for spi driver GPIO CS and moved the error message from __spi_add_device() to spi_dev_check().
- Resolved code indentation issue in spi_set_cs().
- In spi_set_cs() call spi_delay_exec( ) once if the controller supports multi cs with both the CS backed by GPIO.
- Updated __spi_validate()to add checks for both the GPIO CS.
- Replaced cs_index_mask bit mask with SPI_CS_CNT_MAX.
- Updated struct spi_controller to represent multi CS capability of the spi controller through a flag bit SPI_CONTROLLER_MULTI_CS instead of a boolen structure member "multi_cs_cap".
- Updated 1/7 patch description .
Changes in v6:
- Rebased on top of latest v6.3-rc1 and fixed merge conflicts in spi-mpc512x-psc.c, sfdp.c, spansion.c files and removed spi-omap-100k.c.
- Updated spi_dev_check( ) to reject new devices if any one of the chipselect is used by another device.
Changes in v5:
- Rebased the patches on top of v6.3-rc1 and fixed the merge conflicts.
- Fixed compilation warnings in spi-sh-msiof.c with shmobile_defconfig
Changes in v4:
- Fixed build error in spi-pl022.c file - reported by Mark.
- Fixed build error in spi-sn-f-ospi.c file.
- Added Reviewed-by: Serge Semin <[email protected]> tag.
- Added two more patches to replace spi->chip_select with API calls in mpc832x_rdb.c & cs35l41_hda_spi.c files.
Changes in v3:
- Rebased the patches on top of
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
- Added a patch to convert spi_nor_otp_region_len(nor) & spi_nor_otp_n_regions(nor) macros into inline functions
- Added Reviewed-by & Acked-by tags
Changes in v2:
- Rebased the patches on top of v6.2-rc1
- Created separate patch to add get & set APIs for spi->chip_select & spi->cs_gpiod, and replaced all spi->chip_select and spi->cs_gpiod references with the API calls.
- Created separate patch to add get & set APIs for nor->params.
---
Amit Kumar Mahapatra (8):
spi: Add multi-cs memories support in SPI core
mtd: spi-nor: Convert macros with inline functions
mtd: spi-nor: Add APIs to set/get nor->params
mtd: spi-nor: Move write enable inside specific write & erase APIs
mtd: spi-nor: Add stacked memories support in spi-nor
spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver
mtd: spi-nor: Add parallel memories support in spi-nor
spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver
drivers/mtd/spi-nor/atmel.c | 17 +- drivers/mtd/spi-nor/core.c | 683 +++++++++++++++++++++++++------ drivers/mtd/spi-nor/core.h | 8 + drivers/mtd/spi-nor/debugfs.c | 4 +- drivers/mtd/spi-nor/gigadevice.c | 4 +- drivers/mtd/spi-nor/issi.c | 11 +- drivers/mtd/spi-nor/macronix.c | 10 +- drivers/mtd/spi-nor/micron-st.c | 35 +- drivers/mtd/spi-nor/otp.c | 48 ++- drivers/mtd/spi-nor/sfdp.c | 33 +- drivers/mtd/spi-nor/spansion.c | 57 +-- drivers/mtd/spi-nor/sst.c | 7 +- drivers/mtd/spi-nor/swp.c | 25 +- drivers/mtd/spi-nor/winbond.c | 2 +- drivers/mtd/spi-nor/xilinx.c | 18 +- drivers/spi/spi-zynqmp-gqspi.c | 58 ++- drivers/spi/spi.c | 192 +++++++-- include/linux/mtd/spi-nor.h | 21 +- include/linux/spi/spi.h | 51 ++- 19 files changed, 1016 insertions(+), 268 deletions(-)
Signature · 1 line
2.17.1
PATCH v10 1/8 spi: Add multi-cs memories support in SPI core
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant address bit.
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "chip_select" member in the spi_device structure is now an array that holds all the CS values.
spi_device structure now has a "cs_index_mask" member. This acts as an index to the chip_select array. If nth bit of spi->cs_index_mask is set then the driver would assert spi->chip_select[n].
In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A SPI_CONTROLLER_MULTI_CS flag bit is added in the spi controller flags, through ctlr->flags the spi core will make sure that the controller is capable of handling multiple chip selects at once.
For supporting multiple CS via GPIO the cs_gpiod member of the spi_device structure is now an array that holds the gpio descriptor for each chipselect.
CS GPIO is not tested due to unavailability of necessary hardware setup.
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stacked mode. We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provide your feedback.
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)
drivers/spi/spi.c +150 -42
@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev, void *data) {struct spi_device *spi =to_spi_device (dev);struct spi_device *new_spi = data; - -if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + cs_nw =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { +dev_err (dev,"chipselect %d already in use\n" , cs_nw); +return -EBUSY ; + } + } + } + }return 0 ; }
@@ -629,13 +640,32 @@ static int __spi_add_device(struct spi_device *spi) {struct spi_controller *ctlr = spi->controller;struct device *dev = ctlr->dev.parent; -int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { +dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi, idx), + ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS. +* For example, spi->chip_select[0] != spi->chip_select[1] and so on. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + nw_cs =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) { +dev_err (dev,"chipselect %d already in use\n" , nw_cs); +return -EBUSY ; + } + } }/* Set the bus ID string */
@@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device *spi)* its configuration. */ status =bus_for_each_dev (&spi_bus_type,NULL , spi, spi_dev_check); -if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) &&
@@ -659,8 +686,15 @@ static int __spi_add_device(struct spi_device *spi)return -ENODEV ; } -if (ctlr->cs_gpiods) -spi_set_csgpiod (spi,0 , ctlr->cs_gpiods[spi_get_chipselect (spi,0 )]); +if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) +spi_set_csgpiod (spi, idx, ctlr->cs_gpiods[cs]); + } + }/* * Drivers may modify this initial i/o setup, but will
@@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi)struct spi_controller *ctlr = spi->controller;int status; +/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi);mutex_unlock (&ctlr->add_lock);
@@ -942,32 +979,51 @@ static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes }/*-------------------------------------------------------------------------*/ +static inline bool spi_is_last_cs (struct spi_device *spi) +{ +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { +if (spi->controller->last_cs[idx] ==spi_get_chipselect (spi, idx)) + last = true; + } + } +return last; +} +static void spi_set_cs (struct spi_device *spi,bool enable,bool force) {bool activate = enable; +u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. */ -if (!force && ((enable && spi->controller->last_cs ==spi_get_chipselect (spi,0 )) || - (!enable && spi->controller->last_cs !=spi_get_chipselect (spi,0 ))) && +if (!force && ((enable && spi->controller->last_cs_index_mask == spi->cs_index_mask && +spi_is_last_cs (spi)) || + (!enable && spi->controller->last_cs_index_mask == spi->cs_index_mask && + !spi_is_last_cs (spi))) && (spi->controller->last_cs_mode_high == (spi->mode &SPI_CS_HIGH )))return ;trace_spi_set_cs (spi, activate); - spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ?spi_get_chipselect (spi,0 ) :-1 ; spi->controller->last_cs_mode_high = spi->mode &SPI_CS_HIGH ; -if ((spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) && !activate) -spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable; -if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and
@@ -979,26 +1035,38 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)* ambiguity. That's why we use enable, that takes SPI_CS_HIGH * into account. */ -if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep (spi_get_csgpiod (spi,0 ), !enable); -else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep (spi_get_csgpiod (spi,0 ), activate); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (((spi->cs_index_mask >> idx) &0x01 ) && +spi_get_csgpiod (spi, idx)) { +if (has_acpi_companion (&spi->dev)) +gpiod_set_value_cansleep (spi_get_csgpiod (spi, idx), + !enable); +else +/* Polarity handled by GPIO library */ +gpiod_set_value_cansleep (spi_get_csgpiod (spi, idx), + activate); + +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } + } }/* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags &SPI_CONTROLLER_GPIO_SS ) && spi->controller->set_cs) spi->controller->set_cs (spi, !enable); + +if (!spi->controller->set_cs_timing) { +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }#ifdef CONFIG_HAS_DMA
@@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct device_node *nc,static int of_spi_parse_dt (struct spi_controller *ctlr,struct spi_device *spi,struct device_node *nc) { -u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool (nc,"spi-cpha" ))
@@ -2295,14 +2363,52 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,return 0 ; } +if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { +dev_err (&ctlr->dev,"No. of CS is more than max. no. of supported CS\n" ); +return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any +* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical +* CS can be 0. As a solution to this issue initialize all the CS to 0xFF. +* Now all the unused logical CS will have 0xFF physical CS value & can be +* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc =of_property_read_variable_u32_array (nc,"reg" , &cs[0 ],1 , +SPI_CS_CNT_MAX ); +if (rc <0 ) {dev_err (&ctlr->dev,"%pOF has no valid 'reg' property (%d)\n" , nc, rc);return rc; } -spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { +dev_err (&ctlr->dev,"%pOF has number of CS > ctlr->num_chipselect (%d)\n" , + nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { +dev_err (&ctlr->dev,"SPI controller doesn't support multi CS\n" ); +return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i +* logical CS number is represented by setting the ith bit in spi->cs_index_mask +* So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and +* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS number so, set +* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32 (nc,"spi-max-frequency" , &value))
@@ -3100,6 +3206,7 @@ int spi_register_controller(struct spi_controller *ctlr)struct boardinfo *bi;int first_dynamic;int status; +int idx;if (!dev)return -ENODEV ;
@@ -3164,7 +3271,8 @@ int spi_register_controller(struct spi_controller *ctlr) }/* Setting last_cs to -1 means no chip selected */ - ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )
@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)* cs_change is set for each transfer. */ if ((spi->mode &SPI_CS_WORD ) && (!(ctlr->mode_bits &SPI_CS_WORD ) || -spi_get_csgpiod (spi,0 ))) { +spi_is_csgpiod (spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;
include/linux/spi/spi.h +41 -10
129 lines not on this page · raw message
Signature · 1 line
2.17.1
Mark Brown
maintainerRe: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 2 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
This breaks an x86 allmodconfig build:
/build/stage/linux/sound/pci/hda/cs35l56_hda_spi.c: In function ‘cs35l56_hda_spi _probe’:
/build/stage/linux/sound/pci/hda/cs35l56_hda_spi.c:32:52: error: passing argumen t 2 of ‘cs35l56_hda_common_probe’ makes integer from pointer without a cast [-We rror=int-conversion]
32 | ret = cs35l56_hda_common_probe(cs35l56, spi->chip_select);
| ~~~^~~~~~~~~~~~~
| |
| u8 * {aka unsigned char *}
In file included from /build/stage/linux/sound/pci/hda/cs35l56_hda_spi.c:12:
/build/stage/linux/sound/pci/hda/cs35l56_hda.h:45:63: note: expected ‘int’ but a rgument is of type ‘u8 *’ {aka ‘unsigned char *’}
45 | int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id);
| ~~~~^~
RE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Hello Mark,
Quoted 14 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Monday, November 20, 2023 7:33 PM
To: Mahapatra, Amit Kumar <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 5 lines
Quoted 2 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
This breaks an x86 allmodconfig build:
The cause of this failure are the following patches, which neglects to utilize spi_get_chipselect() for retrieving the CS value. Instead, it directly accesses spi->chip_select.
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
In my upcoming series, I will address these issues.
Regards,
Amit
Quoted 17 lines
/build/stage/linux/sound/pci/hda/cs35l56_hda_spi.c: In function ‘cs35l56_hda_spi
_probe’:
/build/stage/linux/sound/pci/hda/cs35l56_hda_spi.c:32:52: error: passing argumen t 2 of ‘cs35l56_hda_common_probe’ makes integer from pointer without a cast [-We rror=int-conversion]32 | ret = cs35l56_hda_common_probe(cs35l56, spi->chip_select); | ~~~^~~~~~~~~~~~~ | | | u8 * {aka unsigned char *}
In file included from /build/stage/linux/sound/pci/hda/cs35l56_hda_spi.c:12:
/build/stage/linux/sound/pci/hda/cs35l56_hda.h:45:63: note: expected ‘int’ but a rgument is of type ‘u8 *’ {aka ‘unsigned char *’}
45 | intcs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id);
| ~~~~^~
Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
In reply to Amit Kumar MahapatraQuoted 39 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant address bit.
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi->chip_select[n].In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware setup.
Quoted 8 lines
Signed-off-by Amit Kumar Mahapatra <[email protected]>---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stacked mode. We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provide your feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Let me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 463 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c +150
-42@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev, void *data) {struct spi_device *spi =to_spi_device (dev);struct spi_device *new_spi = data; - -if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + cs_nw =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { +dev_err (dev,"chipselect %d already in use\n" , cs_nw); +return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct spi_device *spi) {struct spi_controller *ctlr = spi->controller;struct device *dev = ctlr->dev.parent; -int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { +dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi, idx), + ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS. +* For example, spi->chip_select[0] != spi->chip_select[1] and so on. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + nw_cs =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) { +dev_err (dev,"chipselect %d already in use\n" , nw_cs); +return -EBUSY ; + } + } }/* Set the bus ID string */ @@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device *spi)* its configuration. */ status =bus_for_each_dev (&spi_bus_type,NULL , spi, spi_dev_check); -if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) &&@@ -659,8 +686,15 @@ static int __spi_add_device(struct spi_device *spi)return -ENODEV ; } -if (ctlr->cs_gpiods) -spi_set_csgpiod (spi,0 , ctlr->cs_gpiods[spi_get_chipselect (spi,0 )]); +if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) +spi_set_csgpiod (spi, idx, ctlr->cs_gpiods[cs]); + } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi)struct spi_controller *ctlr = spi->controller;int status; +/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi);mutex_unlock (&ctlr->add_lock);@@ -942,32 +979,51 @@ static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes }/*-------------------------------------------------------------------------*/ +static inline bool spi_is_last_cs (struct spi_device *spi) +{ +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { +if (spi->controller->last_cs[idx] ==spi_get_chipselect (spi, idx)) + last = true; + } + } +return last; +} +static void spi_set_cs (struct spi_device *spi,bool enable,bool force) {bool activate = enable; +u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. */ -if (!force && ((enable && spi->controller->last_cs ==spi_get_chipselect (spi,0 )) || - (!enable && spi->controller->last_cs !=spi_get_chipselect (spi,0 ))) && +if (!force && ((enable && spi->controller->last_cs_index_mask == spi->cs_index_mask && +spi_is_last_cs (spi)) || + (!enable && spi->controller->last_cs_index_mask == spi->cs_index_mask && + !spi_is_last_cs (spi))) && (spi->controller->last_cs_mode_high == (spi->mode &SPI_CS_HIGH )))return ;trace_spi_set_cs (spi, activate); - spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ?spi_get_chipselect (spi,0 ) :-1 ; spi->controller->last_cs_mode_high = spi->mode &SPI_CS_HIGH ; -if ((spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) && !activate) -spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable; -if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and @@ -979,26 +1035,38 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)* ambiguity. That's why we use enable, that takes SPI_CS_HIGH * into account. */ -if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep (spi_get_csgpiod (spi,0 ), !enable); -else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep (spi_get_csgpiod (spi,0 ), activate); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (((spi->cs_index_mask >> idx) &0x01 ) && +spi_get_csgpiod (spi, idx)) { +if (has_acpi_companion (&spi->dev)) +gpiod_set_value_cansleep (spi_get_csgpiod (spi, idx), + !enable); +else +/* Polarity handled by GPIO library */ +gpiod_set_value_cansleep (spi_get_csgpiod (spi, idx), + activate); + +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } + } }/* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags &SPI_CONTROLLER_GPIO_SS ) && spi->controller->set_cs) spi->controller->set_cs (spi, !enable); + +if (!spi->controller->set_cs_timing) { +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }#ifdef CONFIG_HAS_DMA @@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct device_node *nc,static int of_spi_parse_dt (struct spi_controller *ctlr,struct spi_device *spi,struct device_node *nc) { -u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool (nc,"spi-cpha" ))@@ -2295,14 +2363,52 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,return 0 ; } +if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { +dev_err (&ctlr->dev,"No. of CS is more than max. no. of supported CS\n" ); +return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any +* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical +* CS can be 0. As a solution to this issue initialize all the CS to 0xFF. +* Now all the unused logical CS will have 0xFF physical CS value & can be +* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc =of_property_read_variable_u32_array (nc,"reg" , &cs[0 ],1 , +SPI_CS_CNT_MAX ); +if (rc <0 ) {dev_err (&ctlr->dev,"%pOF has no valid 'reg' property (%d)\n" , nc, rc);return rc; } -spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { +dev_err (&ctlr->dev,"%pOF has number of CS > ctlr->num_chipselect (%d)\n" , + nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { +dev_err (&ctlr->dev,"SPI controller doesn't support multi CS\n" ); +return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i +* logical CS number is represented by setting the ith bit in spi->cs_index_mask +* So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and +* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS number so, set +* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32 (nc,"spi-max-frequency" , &value))@@ -3100,6 +3206,7 @@ int spi_register_controller(struct spi_controller *ctlr)struct boardinfo *bi;int first_dynamic;int status; +int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct spi_controller *ctlr) }/* Setting last_cs to -1 means no chip selected */ - ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)* cs_change is set for each transfer. */ if ((spi->mode &SPI_CS_WORD ) && (!(ctlr->mode_bits &SPI_CS_WORD ) || -spi_get_csgpiod (spi,0 ))) { +spi_is_csgpiod (spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h +41
-10@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ +#define SPI_CS_CNT_MAX 4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller. +* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden @@ -157,8 +161,8 @@ extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,* the device will bind to the named driver and only the named driver. * Do not set directly, because core frees it; use driver_set_override() to * set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL when -* not using a GPIO line) +* @cs_gpiod: Array of GPIO descriptors of the corresponding chipselect lines +* (optional, NULL when not using a GPIO line) * @word_delay: delay to be inserted between consecutive * words of a transfer * @cs_setup: delay to be introduced by the controller after CS is asserted @@ -167,6 +171,7 @@ extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,* deasserted. If @cs_change_delay is used from @spi_transfer, then the * two delays will be added up. * @pcpu_statistics: statistics for the spi_device +* @cs_index_mask: Bit mask of the active chipselect(s) in the chipselect array * * A @spi_device is used to interchange data between an SPI slave * (usually a discrete chip) and CPU memory. @@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */ u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ @@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */ +struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select gpio desc */ struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from +* the chipselect array.When the controller is capable to handle +* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how * the controller talks to each chip, like: @@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; }static inline void spi_set_chipselect (struct spi_device *spi,u8 idx,u8 chipselect) { - spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; }static inline struct gpio_desc *spi_get_csgpiod (const struct spi_device *spi,u8 idx) { -return spi->cs_gpiod; +return spi->cs_gpiod[idx]; }static inline void spi_set_csgpiod (struct spi_device *spi,u8 idx,struct gpio_desc *csgpiod) { - spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) +{ +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }/** @@ -399,6 +422,8 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use +* @multi_cs_cap: indicates that the SPI Controller can assert/de-assert +* more than one chip select at once. * @setup: updates the device mode and clocking records used by a * device's SPI controller; protocol code may call this. This * must fail if an unrecognized or unsupported mode is requested. @@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */ #define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must select slave */ #define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently suspended */ +/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)/* Flag indicating if the allocation of this struct is devres-managed */ bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
RE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Hello Stefan,
Quoted 104 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
Quoted 4 lines
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 27 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi->chip_select[n].In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware setup.
Quoted 8 lines
Signed-off-by Amit Kumar Mahapatra <[email protected]>---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stacked mode. We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provideyour feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useLet me know if you need any further testing.
Thanks,
Stefan Binding
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void
Quoted 10 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev, void*data)
Quoted 4 lines
drivers/spi/spi.c +0
-1{struct spi_device *spi =to_spi_device (dev);struct spi_device *new_spi = data; -drivers/spi/spi.c static int spi_dev_check(struct device *dev, void *data)
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void *data) · line 622
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw =spi_get_chipselect (spi, nw_idx);
Thank you for dedicating your time to test my patch. As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
cs_nw = spi_get_chipselect(new_spi, nw_idx);
and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.
Regards,
Amit
Quoted 497 lines
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void · line 623
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs ==
cs_nw) {drivers/spi/spi.c static int spi_dev_check(struct device *dev, void · line 624
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
cs_nw);Quoted 11 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct spi_device *spi) {struct spi_controller *ctlr = spi->controller;drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi) · line 650
Quoted 10 lines
drivers/spi/spi.c +8
-1struct device *dev = ctlr->dev.parent; -int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi)
Quoted 12 lines
drivers/spi/spi.c +6
-5+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi)
Quoted 8 lines
drivers/spi/spi.c +8
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + nw_cs =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) { + dev_err(dev, "chipselect %d already in use\n",
nw_cs);Quoted 9 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }/* Set the bus ID string */ @@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device *spi)* its configuration. */ drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi) · line 684
Quoted 10 lines
drivers/spi/spi.c +1
-4status =bus_for_each_dev (&spi_bus_type,NULL , spi, spi_dev_check); -if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8 +686,15 @@static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)
return-ENODEV;
}drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi,0)]);
drivers/spi/spi.c static void spi_res_release(struct spi_controller
Quoted 23 lines
drivers/spi/spi.c +13
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) +spi_set_csgpiod (spi, idx, ctlr->cs_gpiods[cs]); + } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; +/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi);mutex_unlock (&ctlr->add_lock);@@ -942,32 +979,51 @@ static void spi_res_release(struct spi_controller*ctlr, struct
spi_message*mesdrivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 12 lines
drivers/spi/spi.c +7
-1}/*-------------------------------------------------------------------- -----*/ +static inline bool spi_is_last_cs(struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { +if ((spi->cs_index_mask >> idx) & 0x01) { +if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 7 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} +drivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 10 lines
drivers/spi/spi.c +1
-1static void spi_set_cs (struct spi_device *spi,bool enable,bool force) {bool activate = enable; +u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. */ - if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c static void spi_res_release(struct spi_controller · line 957
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +1
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask == spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask == spi-
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))drivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 8 lines
return;
trace_spi_set_cs(spi, activate);drivers/spi/spi.c +3
-1- spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? spi_get_chipselect(spi,0)
drivers/spi/spi.c
Quoted 4 lines
+: -1;
spi->controller->last_cs_mode_high=spi->mode&SPI_CS_HIGH;drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) &&!activate)
drivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 13 lines
drivers/spi/spi.c +4
-3-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable; -if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and @@
Quoted 1 line
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that takes
SPI_CS_HIGHdrivers/spi/spi.c static void spi_set_cs(struct spi_device *spi, bool enable, bool force) · line 995
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);drivers/spi/spi.c static void spi_set_cs(struct spi_device *spi, bool enable, bool force) · line 995
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c static void spi_set_cs(struct spi_device *spi, bool enable, bool force) · line 1048
Quoted 5 lines
drivers/spi/spi.c +5
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (((spi->cs_index_mask >> idx) &0x01 ) && +spi_get_csgpiod (spi, idx)) { +if (has_acpi_companion (&spi->dev)) +gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct
Quoted 35 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +9
-7+ } + } }/* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags &SPI_CONTROLLER_GPIO_SS ) && spi->controller->set_cs) spi->controller->set_cs (spi, !enable); + +if (!spi->controller->set_cs_timing) { +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }#ifdef CONFIG_HAS_DMA @@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct
device_node*nc,drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct device_node *nc,
Quoted 10 lines
drivers/spi/spi.c +2
-2static int of_spi_parse_dt (struct spi_controller *ctlr,struct spi_device *spi,struct device_node *nc) { -u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14 +2363,52@@
drivers/spi/spi.c
Quoted 6 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,
return 0;
}drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no. ofsupported CS\n");
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 8 lines
drivers/spi/spi.c +8
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any +* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+* CS can be 0. As a solution to this issue initialize all the CS to 0xFF. +* Now all the unused logical CS will have 0xFF physical CS value & can be
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 12 lines
drivers/spi/spi.c +8
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc =of_property_read_variable_u32_array (nc,"reg" , &cs[0 ],1 , +SPI_CS_CNT_MAX ); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 13 lines
nc, rc); return rc; }drivers/spi/spi.c +2
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { + dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't support multiCS\n");
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 6 lines
drivers/spi/spi.c +6
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +1
-0+* logical CS number is represented by setting the ith bit in spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS number so, set
drivers/spi/spi.c int spi_register_controller(struct spi_controller
Quoted 15 lines
drivers/spi/spi.c +4
-1+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) @@ -3100,6 +3206,7 @@ int spi_register_controller(struct spi_controller *ctlr) struct boardinfo *bi;int first_dynamic;int status; +int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct spi_device *spi,
Quoted 10 lines
drivers/spi/spi.c +2
-1}/* Setting last_cs to -1 means no chip selected */ - ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct spi_device *spi, struct spi_message *message)
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||include/linux/spi/spi.h extern void
Quoted 19 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h index renamed from include/linux/spi/spi.h +0
-0
7b4baff63c5c..871d3a6d879b100644include/linux/spi/spi.h +2
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define SPI_CS_CNT_MAX 4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,include/linux/spi/spi.h extern void
Quoted 10 lines
include/linux/spi/spi.h +2
-1* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller. +* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden @@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,include/linux/spi/spi.h extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,
Quoted 6 lines
include/linux/spi/spi.h +1
-2* the device will bind to the named driver and only the named driver. * Do not set directly, because core frees it; use driver_set_override() to * set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL when -* not using a GPIO line) +* @cs_gpiod: Array of GPIO descriptors of the corresponding chipselect lines
Quoted 5 lines
include/linux/spi/spi.h +1
-0+* (optional, NULL when not using a GPIO line) * @word_delay: delay to be inserted between consecutive * words of a transfer * @cs_setup: delay to be introduced by the controller after CS is asserted @@ -167,6 +171,7 @@ extern void
spi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer, then
the
Quoted 17 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +1
-1@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */ u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ include/linux/spi/spi.h struct spi_device { · line 216
Quoted 4 lines
include/linux/spi/spi.h +0
-1@@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select gpio desc */
Quoted 18 lines
include/linux/spi/spi.h +7
-0struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from +* the chipselect array.When the controller is capable to handle +* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how * the controller talks to each chip, like: include/linux/spi/spi.h static inline void *spi_get_drvdata(const struct · line 298
Quoted 9 lines
include/linux/spi/spi.h +1
-1@@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi, u8 idx, u8chipselect)
include/linux/spi/spi.h static inline void *spi_get_drvdata(const struct spi_device *spi)
Quoted 6 lines
include/linux/spi/spi.h +1
-1{ - spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(const struct spi_device *spi,u8 idx)
include/linux/spi/spi.h static inline void *spi_get_drvdata(const struct spi_device *spi)
Quoted 6 lines
include/linux/spi/spi.h +1
-1{ -return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi, u8 idx, struct
gpio_desc*csgpiod)include/linux/spi/spi.h extern struct spi_device
Quoted 17 lines
include/linux/spi/spi.h +11
-1{ - spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }/** @@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chinclude/linux/spi/spi.h struct spi_controller { · line 593
Quoted 12 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode is requested.include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */ #define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must select slave */
include/linux/spi/spi.h struct spi_controller { · line 594
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently suspended */
Quoted 18 lines
include/linux/spi/spi.h +7
-1+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)/* Flag indicating if the allocation of this struct is devres-managed */ bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 112 lines · Amit Kumar
Hello Stefan,
Quoted 103 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
Quoted 4 lines
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 26 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi->chip_select[n].In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware setup.
Quoted 8 lines
Signed-off-by Amit Kumar Mahapatra <[email protected]>---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stacked mode. We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provideyour feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useLet me know if you need any further testing.
Thanks,
Stefan Binding
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void
Quoted 10 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev, void*data)
Quoted 4 lines
drivers/spi/spi.c +0
-1{struct spi_device *spi =to_spi_device (dev);struct spi_device *new_spi = data; -drivers/spi/spi.c static int spi_dev_check(struct device *dev, void *data)
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void *data) · line 622
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw =spi_get_chipselect (spi, nw_idx);Thank you for dedicating your time to test my patch. As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
Quoted 8 lines
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.Regards,
Amit
Hi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Thanks,
Stefan
Quoted 486 lines
Quoted 486 lines
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void · line 623
Quoted 2 lines
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs ==
cs_nw) {drivers/spi/spi.c static int spi_dev_check(struct device *dev, void · line 624
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
cs_nw);Quoted 11 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct spi_device *spi) {struct spi_controller *ctlr = spi->controller;drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi) · line 650
Quoted 10 lines
drivers/spi/spi.c +8
-1struct device *dev = ctlr->dev.parent; -int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi)
Quoted 12 lines
drivers/spi/spi.c +6
-5+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi)
Quoted 8 lines
drivers/spi/spi.c +8
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + nw_cs =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) { + dev_err(dev, "chipselect %d already in use\n",
nw_cs);Quoted 9 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }/* Set the bus ID string */ @@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device *spi)* its configuration. */ drivers/spi/spi.c static int __spi_add_device(struct spi_device *spi) · line 684
Quoted 10 lines
drivers/spi/spi.c +1
-4status =bus_for_each_dev (&spi_bus_type,NULL , spi, spi_dev_check); -if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8 +686,15 @@static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi,0)]);
drivers/spi/spi.c static void spi_res_release(struct spi_controller
Quoted 23 lines
drivers/spi/spi.c +13
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) +spi_set_csgpiod (spi, idx, ctlr->cs_gpiods[cs]); + } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; +/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi);mutex_unlock (&ctlr->add_lock);@@ -942,32 +979,51 @@ static void spi_res_release(struct spi_controller*ctlr, struct
spi_message*mesdrivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 12 lines
drivers/spi/spi.c +7
-1}/*-------------------------------------------------------------------- -----*/ +static inline bool spi_is_last_cs(struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { +if ((spi->cs_index_mask >> idx) & 0x01) { +if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 7 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} +drivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 10 lines
drivers/spi/spi.c +1
-1static void spi_set_cs (struct spi_device *spi,bool enable,bool force) {bool activate = enable; +u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. */ - if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c static void spi_res_release(struct spi_controller · line 957
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +1
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask == spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask == spi-
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))drivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 8 lines
return; trace_spi_set_cs(spi, activate);drivers/spi/spi.c +3
-1- spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? spi_get_chipselect(spi,0)
drivers/spi/spi.c
Quoted 4 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode & SPI_CS_HIGH;drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) &&!activate)
drivers/spi/spi.c static void spi_res_release(struct spi_controller *ctlr, struct spi_message *mes
Quoted 13 lines
drivers/spi/spi.c +4
-3-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable; -if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and @@
Quoted 1 line
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that takes
SPI_CS_HIGHdrivers/spi/spi.c static void spi_set_cs(struct spi_device *spi, bool enable, bool force) · line 995
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);drivers/spi/spi.c static void spi_set_cs(struct spi_device *spi, bool enable, bool force) · line 995
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c static void spi_set_cs(struct spi_device *spi, bool enable, bool force) · line 1048
Quoted 5 lines
drivers/spi/spi.c +5
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (((spi->cs_index_mask >> idx) &0x01 ) && +spi_get_csgpiod (spi, idx)) { +if (has_acpi_companion (&spi->dev)) +gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct
Quoted 35 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +9
-7+ } + } }/* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags &SPI_CONTROLLER_GPIO_SS ) && spi->controller->set_cs) spi->controller->set_cs (spi, !enable); + +if (!spi->controller->set_cs_timing) { +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }#ifdef CONFIG_HAS_DMA @@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct
device_node*nc,drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct device_node *nc,
Quoted 10 lines
drivers/spi/spi.c +2
-2static int of_spi_parse_dt (struct spi_controller *ctlr,struct spi_device *spi,struct device_node *nc) { -u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14 +2363,52@@
drivers/spi/spi.c
Quoted 6 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no. ofsupported CS\n");
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 8 lines
drivers/spi/spi.c +8
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any +* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+* CS can be 0. As a solution to this issue initialize all the CS to 0xFF. +* Now all the unused logical CS will have 0xFF physical CS value & can be
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 12 lines
drivers/spi/spi.c +8
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc =of_property_read_variable_u32_array (nc,"reg" , &cs[0 ],1 , +SPI_CS_CNT_MAX ); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 13 lines
nc, rc); return rc; }drivers/spi/spi.c +2
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { + dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't support multiCS\n");
drivers/spi/spi.c static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
Quoted 6 lines
drivers/spi/spi.c +6
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +1
-0+* logical CS number is represented by setting the ith bit in spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS number so, set
drivers/spi/spi.c int spi_register_controller(struct spi_controller
Quoted 15 lines
drivers/spi/spi.c +4
-1+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) @@ -3100,6 +3206,7 @@ int spi_register_controller(struct spi_controller *ctlr) struct boardinfo *bi;int first_dynamic;int status; +int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct spi_device *spi,
Quoted 10 lines
drivers/spi/spi.c +2
-1}/* Setting last_cs to -1 means no chip selected */ - ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct spi_device *spi, struct spi_message *message)
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||include/linux/spi/spi.h extern void
Quoted 19 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h index renamed from include/linux/spi/spi.h +0
-0
7b4baff63c5c..871d3a6d879b100644include/linux/spi/spi.h +2
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define SPI_CS_CNT_MAX 4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,include/linux/spi/spi.h extern void
Quoted 10 lines
include/linux/spi/spi.h +2
-1* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller. +* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden @@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,include/linux/spi/spi.h extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,
Quoted 6 lines
include/linux/spi/spi.h +1
-2* the device will bind to the named driver and only the named driver. * Do not set directly, because core frees it; use driver_set_override() to * set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL when -* not using a GPIO line) +* @cs_gpiod: Array of GPIO descriptors of the corresponding chipselect lines
Quoted 5 lines
include/linux/spi/spi.h +1
-0+* (optional, NULL when not using a GPIO line) * @word_delay: delay to be inserted between consecutive * words of a transfer * @cs_setup: delay to be introduced by the controller after CS is asserted @@ -167,6 +171,7 @@ extern void
spi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer, then
the
Quoted 17 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +1
-1@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */ u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ include/linux/spi/spi.h struct spi_device { · line 216
Quoted 4 lines
include/linux/spi/spi.h +0
-1@@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select gpio desc */
Quoted 18 lines
include/linux/spi/spi.h +7
-0struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from +* the chipselect array.When the controller is capable to handle +* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how * the controller talks to each chip, like: include/linux/spi/spi.h static inline void *spi_get_drvdata(const struct · line 298
Quoted 9 lines
include/linux/spi/spi.h +1
-1@@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi, u8 idx, u8chipselect)
include/linux/spi/spi.h static inline void *spi_get_drvdata(const struct spi_device *spi)
Quoted 6 lines
include/linux/spi/spi.h +1
-1{ - spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(const struct spi_device *spi,u8 idx)
include/linux/spi/spi.h static inline void *spi_get_drvdata(const struct spi_device *spi)
Quoted 6 lines
include/linux/spi/spi.h +1
-1{ -return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi, u8 idx, struct
gpio_desc*csgpiod)include/linux/spi/spi.h extern struct spi_device
Quoted 17 lines
include/linux/spi/spi.h +11
-1{ - spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }/** @@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chinclude/linux/spi/spi.h struct spi_controller { · line 593
Quoted 12 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode is requested.include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */ #define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must select slave */
include/linux/spi/spi.h struct spi_controller { · line 594
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently suspended */
Quoted 6 lines
include/linux/spi/spi.h +5
-0+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h +0
-0/* Flag indicating if the allocation of this struct is devres-managed */ bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;Quoted 8 lines
include/linux/spi/spi.h struct spi_controller { · line 714
Quoted 8 lines
include/linux/spi/spi.h +2
-1bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
RE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Hello Stefan,
Quoted 140 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 7:28 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 61 lines · Amit Kumar
Hello Stefan,
Quoted 59 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
Quoted 5 lines
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 27 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi->chip_select[n].In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware setup.
Signed-off-by Amit Kumar Mahapatra <amit.kumar-Quoted 62 lines
Quoted 49 lines
Quoted 8 lines
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stacked mode. We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provideyour feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useLet me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 11 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev,void
*data)
Quoted 4 lines
{ struct spi_device *spi = to_spi_device(dev); struct spi_device *new_spi = data;drivers/spi/spi.c +0
-1-drivers/spi/spi.c
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw =spi_get_chipselect (spi, nw_idx);Thank you for dedicating your time to test my patch.
As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.
Quoted 8 lines
Quoted 2 lines
Regards,
AmitHi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Thank you for the quick testing. For further analysis I have incorporated additional debug prints on top of 1/8 patch. The corresponding diff is shared below. Kindly implement the specified changes, rerun your test and share the kernel logs.
drivers/spi/spi.c +8 -1
@@ -618,8 +618,10 @@ static int spi_dev_check(struct device *dev, void *data)if (spi->controller == new_spi->controller) {for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx); +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, __LINE__, idx, cs);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = [%d]\n" , __func__, __LINE__, nw_idx, cs_nw);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) {dev_err (dev,"chipselect %d already in use\n" , cs_nw);return -EBUSY ;
@@ -659,8 +661,10 @@ static int __spi_add_device(struct spi_device *spi)*/ for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx); +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, __LINE__, idx, cs);for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { nw_cs =spi_get_chipselect (spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = [%d]\n" , __func__, __LINE__, nw_idx, nw_cs);if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) {dev_err (dev,"chipselect %d already in use\n" , nw_cs);return -EBUSY ;
@@ -2401,6 +2405,9 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,for (idx =0 ; idx < rc; idx++)spi_set_chipselect (spi, idx, cs[idx]); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, __LINE__, idx,spi_get_chipselect (spi, idx)); +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i * logical CS number is represented by setting the ith bit in spi->cs_index_mask * So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and
Regards,
Amit
Quoted 523 lines
Thanks,
Stefan
Quoted 13 lines
Quoted 13 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs ==
cs_nw) {drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
cs_nw);Quoted 8 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }Quoted 1 line
Quoted 1 line
drivers/spi/spi.c static int __spi_add_device(struct spi_device
Quoted 1 line
drivers/spi/spi.c +0
-0@@ -629,13 +640,32 @@ static int __spi_add_device(struct spi_device*spi)
Quoted 35 lines
Quoted 35 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 650
Quoted 12 lines
drivers/spi/spi.c +8
-1{struct spi_controller *ctlr = spi->controller;struct device *dev = ctlr->dev.parent; -int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 657
Quoted 12 lines
drivers/spi/spi.c +6
-5+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 665
Quoted 8 lines
drivers/spi/spi.c +8
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + nw_cs =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) { + dev_err(dev, "chipselect %d already in use\n",
nw_cs);Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device
Quoted 7 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }/* Set the bus ID string */ @@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device*spi)
Quoted 178 lines
Quoted 178 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 684
Quoted 12 lines
drivers/spi/spi.c +1
-4* its configuration. */ status =bus_for_each_dev (&spi_bus_type,NULL , spi, spi_dev_check); -if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8 +686,15 @@static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi,0)]);
Quoted 23 lines
drivers/spi/spi.c +13
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) +spi_set_csgpiod (spi, idx, ctlr->cs_gpiods[cs]); + } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; +/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi);mutex_unlock (&ctlr->add_lock);@@ -942,32 +979,51 @@ static void spi_res_release(structQuoted 1 line
spi_controller*ctlr, struct
spi_message*mesdrivers/spi/spi.c
Quoted 13 lines
}/*------------------------------------------------------------------ --
-----*/drivers/spi/spi.c +7
-0+static inline bool spi_is_last_cs (struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { + if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 7 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} +drivers/spi/spi.c
Quoted 10 lines
drivers/spi/spi.c +1
-1static void spi_set_cs (struct spi_device *spi,bool enable,bool force) {bool activate = enable; +u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. */ - if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +2
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask == +spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask == spi-
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))drivers/spi/spi.c
Quoted 8 lines
return; trace_spi_set_cs(spi, activate);drivers/spi/spi.c +3
-1- spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? spi_get_chipselect(spi,0)
drivers/spi/spi.c
Quoted 4 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode & SPI_CS_HIGH;drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) &&!activate)
drivers/spi/spi.c
Quoted 13 lines
drivers/spi/spi.c +4
-3-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable; -if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and @@
Quoted 2 lines
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that takes
SPI_CS_HIGHdrivers/spi/spi.c
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +5
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (((spi->cs_index_mask >> idx) &0x01 ) && +spi_get_csgpiod (spi, idx)) { +if (has_acpi_companion (&spi->dev)) +gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
Quoted 33 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +9
-7+ } + } }/* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags &SPI_CONTROLLER_GPIO_SS ) && spi->controller->set_cs) spi->controller->set_cs (spi, !enable); + +if (!spi->controller->set_cs_timing) { +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct
Quoted 2 lines
#ifdef CONFIG_HAS_DMAdrivers/spi/spi.c +0
-0@@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct
device_node*nc,Quoted 1 line
drivers/spi/spi.c +0
-0static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device*spi,
Quoted 138 lines
Quoted 138 lines
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct · line 2297
Quoted 9 lines
drivers/spi/spi.c +2
-2struct device_node *nc) { -u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14 +2363,52@@
drivers/spi/spi.c
Quoted 6 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no. ofsupported CS\n");
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +8
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any +* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* CS can be 0. As a solution to this issue initialize all the CS to 0xFF. +* Now all the unused logical CS will have 0xFF physical CS value +& can be
drivers/spi/spi.c
Quoted 12 lines
drivers/spi/spi.c +8
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc =of_property_read_variable_u32_array (nc,"reg" , &cs[0 ],1 , +SPI_CS_CNT_MAX ); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
drivers/spi/spi.c
Quoted 13 lines
nc, rc); return rc; }drivers/spi/spi.c +2
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { + dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't support multiCS\n");
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for +logical CS i
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +1
-0+* logical CS number is represented by setting the ith bit in spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS number +so, set
Quoted 15 lines
drivers/spi/spi.c +4
-1+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) @@ -3100,6 +3206,7 @@ int spi_register_controller(struct spi_controller *ctlr) struct boardinfo *bi;int first_dynamic;int status; +int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(structQuoted 1 line
spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct spi_device · line 3997
Quoted 11 lines
}/* Setting last_cs to -1 means no chip selected */drivers/spi/spi.c +2
-1- ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct spi_device · line 4000
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||include/linux/spi/spi.h extern void
Quoted 20 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h index renamed from include/linux/spi/spi.h +0
-0
7b4baff63c5c..871d3a6d879b100644include/linux/spi/spi.h +3
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define SPI_CS_CNT_MAX +4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,include/linux/spi/spi.h extern void
Quoted 10 lines
include/linux/spi/spi.h +2
-1* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller. +* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden @@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h extern void · line 160
Quoted 4 lines
include/linux/spi/spi.h +0
-1* the device will bind to the named driver and only the named driver. * Do not set directly, because core frees it; use driver_set_override() to * set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL when
Quoted 99 lines
Quoted 99 lines
include/linux/spi/spi.h extern void · line 165
Quoted 3 lines
include/linux/spi/spi.h +2
-1-* not using a GPIO line) + * @cs_gpiod: Array of GPIO descriptors of the corresponding + chipselectlines
Quoted 5 lines
include/linux/spi/spi.h +1
-0+* (optional, NULL when not using a GPIO line) * @word_delay: delay to be inserted between consecutive * words of a transfer * @cs_setup: delay to be introduced by the controller after CS is asserted @@ -167,6 +171,7 @@ extern void
spi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer, then
the
Quoted 17 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +1
-1@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */ u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ include/linux/spi/spi.h struct spi_device { · line 216
Quoted 4 lines
include/linux/spi/spi.h +0
-1@@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select gpio desc */
Quoted 27 lines
include/linux/spi/spi.h +8
-1struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from +* the chipselect array.When the controller is capable to handle +* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how * the controller talks to each chip, like: @@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi, u8Quoted 1 line
idx, u8
chipselect)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1- spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(const struct
spi_device*spi,u8 idx)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1-return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi, u8idx, struct
gpio_desc*csgpiod)include/linux/spi/spi.h extern struct spi_device
Quoted 17 lines
{include/linux/spi/spi.h +11
-1- spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }/** @@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chQuoted 11 lines
Quoted 11 lines
include/linux/spi/spi.h struct spi_controller { · line 592
Quoted 11 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode is requested.include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_controller { · line 593
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must
Quoted 21 lines
Quoted 21 lines
select slave */
include/linux/spi/spi.h struct spi_controller { · line 594
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently suspended */
Quoted 18 lines
include/linux/spi/spi.h +7
-1+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)/* Flag indicating if the allocation of this struct is devres-managed */ bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 144 lines · Amit Kumar
Hello Stefan,
Quoted 142 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 7:28 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 61 lines · Amit Kumar
Hello Stefan,
Quoted 59 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
Quoted 5 lines
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 27 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi->chip_select[n].In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware setup.
Signed-off-by Amit Kumar Mahapatra <amit.kumar-Quoted 64 lines
Quoted 49 lines
Quoted 8 lines
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stacked mode. We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provideyour feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useLet me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 11 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++--------- include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev,void
*data)
Quoted 4 lines
{ struct spi_device *spi = to_spi_device(dev); struct spi_device *new_spi = data;drivers/spi/spi.c +0
-1-drivers/spi/spi.c
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw =spi_get_chipselect (spi, nw_idx);Thank you for dedicating your time to test my patch.
As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.Regards,
Amit
Hi,
I've attached my log.
I notice that you add a print to of_spi_parse_dt, however since the laptop I am using is an x86 laptop, it uses ACPI rather than OF, and I don't think this function isnt even compiled in.
Thanks,
Stefan
Quoted 560 lines
Quoted 5 lines
Hi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Thank you for the quick testing. For further analysis I have incorporated additional debug prints on top of 1/8 patch. The corresponding diff is shared below. Kindly implement the specified changes, rerun your test and share the kernel logs.
drivers/spi/spi.c +8
-1@@ -618,8 +618,10 @@ static int spi_dev_check(struct device *dev, void *data)if (spi->controller == new_spi->controller) {for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx); +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, __LINE__, idx, cs);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = [%d]\n" , __func__, __LINE__, nw_idx, cs_nw);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) {dev_err (dev,"chipselect %d already in use\n" , cs_nw);return -EBUSY ;@@ -659,8 +661,10 @@ static int __spi_add_device(struct spi_device *spi)*/ for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx); +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, __LINE__, idx, cs);for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { nw_cs =spi_get_chipselect (spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = [%d]\n" , __func__, __LINE__, nw_idx, nw_cs);if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) {dev_err (dev,"chipselect %d already in use\n" , nw_cs);return -EBUSY ;@@ -2401,6 +2405,9 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,for (idx =0 ; idx < rc; idx++)spi_set_chipselect (spi, idx, cs[idx]); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, __LINE__, idx,spi_get_chipselect (spi, idx)); +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i * logical CS number is represented by setting the ith bit in spi->cs_index_mask * So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and Regards,
AmitQuoted 509 lines
Thanks,
Stefan
Quoted 12 lines
Quoted 12 lines
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs ==
cs_nw) {drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
cs_nw);Quoted 8 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }Quoted 1 line
Quoted 1 line
drivers/spi/spi.c static int __spi_add_device(struct spi_device
Quoted 1 line
drivers/spi/spi.c +0
-0@@ -629,13 +640,32 @@ static int __spi_add_device(struct spi_device*spi)
Quoted 35 lines
Quoted 35 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 650
Quoted 12 lines
drivers/spi/spi.c +8
-1{struct spi_controller *ctlr = spi->controller;struct device *dev = ctlr->dev.parent; -int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 657
Quoted 12 lines
drivers/spi/spi.c +6
-5+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 665
Quoted 8 lines
drivers/spi/spi.c +8
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { + nw_cs =spi_get_chipselect (spi, nw_idx); +if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) { + dev_err(dev, "chipselect %d already in use\n",
nw_cs);Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device
Quoted 7 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }/* Set the bus ID string */ @@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device*spi)
Quoted 178 lines
Quoted 178 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 684
Quoted 12 lines
drivers/spi/spi.c +1
-4* its configuration. */ status =bus_for_each_dev (&spi_bus_type,NULL , spi, spi_dev_check); -if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8 +686,15 @@static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi,0)]);
Quoted 23 lines
drivers/spi/spi.c +13
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) +spi_set_csgpiod (spi, idx, ctlr->cs_gpiods[cs]); + } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; +/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi);mutex_unlock (&ctlr->add_lock);@@ -942,32 +979,51 @@ static void spi_res_release(structQuoted 1 line
spi_controller*ctlr, struct
spi_message*mesdrivers/spi/spi.c
Quoted 13 lines
}/*------------------------------------------------------------------ --
-----*/drivers/spi/spi.c +7
-0+static inline bool spi_is_last_cs (struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { + if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 7 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} +drivers/spi/spi.c
Quoted 10 lines
drivers/spi/spi.c +1
-1static void spi_set_cs (struct spi_device *spi,bool enable,bool force) {bool activate = enable; +u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select * isn't actually changing from the last time this was called. */ - if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +2
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask == +spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask == spi-
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))drivers/spi/spi.c
Quoted 8 lines
return; trace_spi_set_cs(spi, activate);drivers/spi/spi.c +3
-1- spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? spi_get_chipselect(spi,0)
drivers/spi/spi.c
Quoted 4 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode & SPI_CS_HIGH;drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) &&!activate)
drivers/spi/spi.c
Quoted 13 lines
drivers/spi/spi.c +4
-3-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable; -if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and @@
Quoted 2 lines
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that takes
SPI_CS_HIGHdrivers/spi/spi.c
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +5
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (((spi->cs_index_mask >> idx) &0x01 ) && +spi_get_csgpiod (spi, idx)) { +if (has_acpi_companion (&spi->dev)) +gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
Quoted 33 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +9
-7+ } + } }/* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags &SPI_CONTROLLER_GPIO_SS ) && spi->controller->set_cs) spi->controller->set_cs (spi, !enable); + +if (!spi->controller->set_cs_timing) { +if (activate) +spi_delay_exec (&spi->cs_setup,NULL ); +else +spi_delay_exec (&spi->cs_inactive,NULL ); + } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct
Quoted 2 lines
#ifdef CONFIG_HAS_DMAdrivers/spi/spi.c +0
-0@@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct
device_node*nc,Quoted 1 line
drivers/spi/spi.c +0
-0static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device*spi,
Quoted 138 lines
Quoted 138 lines
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct · line 2297
Quoted 9 lines
drivers/spi/spi.c +2
-2struct device_node *nc) { -u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14 +2363,52@@
drivers/spi/spi.c
Quoted 6 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no. ofsupported CS\n");
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +8
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any +* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* CS can be 0. As a solution to this issue initialize all the CS to 0xFF. +* Now all the unused logical CS will have 0xFF physical CS value +& can be
drivers/spi/spi.c
Quoted 12 lines
drivers/spi/spi.c +8
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc =of_property_read_variable_u32_array (nc,"reg" , &cs[0 ],1 , +SPI_CS_CNT_MAX ); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
drivers/spi/spi.c
Quoted 13 lines
nc, rc); return rc; }drivers/spi/spi.c +2
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { + dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't support multiCS\n");
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for +logical CS i
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +1
-0+* logical CS number is represented by setting the ith bit in spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS number is 0 and
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS number +so, set
Quoted 15 lines
drivers/spi/spi.c +4
-1+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency", &value)) @@ -3100,6 +3206,7 @@ int spi_register_controller(struct spi_controller *ctlr) struct boardinfo *bi;int first_dynamic;int status; +int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(structQuoted 1 line
spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct spi_device · line 3997
Quoted 11 lines
} /* Setting last_cs to -1 means no chip selected */drivers/spi/spi.c +2
-1- ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct spi_device · line 4000
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||include/linux/spi/spi.h extern void
Quoted 20 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h index renamed from include/linux/spi/spi.h +0
-0
7b4baff63c5c..871d3a6d879b100644include/linux/spi/spi.h +3
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define SPI_CS_CNT_MAX +4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,include/linux/spi/spi.h extern void
Quoted 10 lines
include/linux/spi/spi.h +2
-1* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller. +* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden @@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h extern void · line 160
Quoted 4 lines
include/linux/spi/spi.h +0
-1* the device will bind to the named driver and only the named driver. * Do not set directly, because core frees it; use driver_set_override() to * set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL when
Quoted 99 lines
Quoted 99 lines
include/linux/spi/spi.h extern void · line 165
Quoted 3 lines
include/linux/spi/spi.h +2
-1-* not using a GPIO line) + * @cs_gpiod: Array of GPIO descriptors of the corresponding + chipselectlines
Quoted 5 lines
include/linux/spi/spi.h +1
-0+* (optional, NULL when not using a GPIO line) * @word_delay: delay to be inserted between consecutive * words of a transfer * @cs_setup: delay to be introduced by the controller after CS is asserted @@ -167,6 +171,7 @@ extern void
spi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer, then
the
Quoted 17 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +1
-1@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */ u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ include/linux/spi/spi.h struct spi_device { · line 216
Quoted 4 lines
include/linux/spi/spi.h +0
-1@@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select gpio desc */
Quoted 27 lines
include/linux/spi/spi.h +8
-1struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from +* the chipselect array.When the controller is capable to handle +* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how * the controller talks to each chip, like: @@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi, u8Quoted 1 line
idx, u8
chipselect)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1- spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(const struct
spi_device*spi,u8 idx)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1-return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi, u8idx, struct
gpio_desc*csgpiod)include/linux/spi/spi.h extern struct spi_device
Quoted 17 lines
{include/linux/spi/spi.h +11
-1- spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }/** @@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chQuoted 11 lines
Quoted 11 lines
include/linux/spi/spi.h struct spi_controller { · line 592
Quoted 11 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode is requested.include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_controller { · line 593
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must
Quoted 9 lines
Quoted 9 lines
select slave */
include/linux/spi/spi.h struct spi_controller { · line 594
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently suspended */
Quoted 6 lines
include/linux/spi/spi.h +5
-0+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h +0
-0/* Flag indicating if the allocation of this struct is devres-managed */ bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/spi/spi.h struct spi_controller { · line 714
Quoted 8 lines
include/linux/spi/spi.h +2
-1bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
[ 0.000000] Linux version 6.7.0-rc1-next-20231115+ (sbinding@sbinding-cirrus-dsktp2) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #738 SMP PREEMPT_DYNAMIC Tue Nov 21 17:11:55 GMT 2023 [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-6.7.0-rc1-next-20231115+ root=UUID=061502a9-205e-4b73-8251-1220e770c5d8 ro quiet splash pcie_aspm=off log_buf_len=10M trace_event=gpio:* vt.handoff=7 [ 0.000000] KERNEL supported cpus: [ 0.000000] Intel GenuineIntel [ 0.000000] AMD AuthenticAMD [ 0.000000] Hygon HygonGenuine [ 0.000000] Centaur CentaurHauls [ 0.000000] zhaoxin Shanghai [ 0.000000] x86/split lock detection: #AC: crashing the kernel on kernel split_locks and warning on user-space split_locks [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009efff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009f000-0x00000000000fffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000003b8dcfff] usable [ 0.000000] BIOS-e820: [mem 0x000000003b8dd000-0x0000000041933fff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000041934000-0x0000000041b33fff] ACPI NVS [ 0.000000] BIOS-e820: [mem 0x0000000041b34000-0x0000000041bfefff] ACPI data [ 0.000000] BIOS-e820: [mem 0x0000000041bff000-0x0000000041bfffff] usable [ 0.000000] BIOS-e820: [mem 0x0000000041c00000-0x0000000047ffffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000049400000-0x00000000495fffff] reserved [ 0.000000] BIOS-e820: [mem 0x000000004c000000-0x00000000547fffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000c0000000-0x00000000cfffffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000fed20000-0x00000000fed7ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000008ab7fffff] usable [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] APIC: Static calls initialized [ 0.000000] efi: EFI v2.7 by HP [ 0.000000] efi: ACPI=0x41bfe000 ACPI 2.0=0x41bfe014 TPMFinalLog=0x41a50000 SMBIOS=0x3c04c000 ESRT=0x3c0a8098 MEMATTR=0x2ec52018 MOKvar=0x3c04b000 RNG=0x41b4d018 TPMEventLog=0x2e9c6018 [ 0.000000] random: crng init done [ 0.000000] efi: Remove mem452: MMIO range=[0xc0000000-0xcfffffff] (256MB) from e820 map [ 0.000000] e820: remove [mem 0xc0000000-0xcfffffff] reserved [ 0.000000] efi: Remove mem454: MMIO range=[0xff000000-0xffffffff] (16MB) from e820 map [ 0.000000] e820: remove [mem 0xff000000-0xffffffff] reserved [ 0.000000] SMBIOS 3.4 present. [ 0.000000] DMI: HP HP ZBook Fury 16 G9 Mobile Workstation PC/89C6, BIOS U96 Ver. 92.25.02 09/20/2023 [ 0.000000] tsc: Detected 2400.000 MHz processor [ 0.000000] tsc: Detected 2419.200 MHz TSC [ 0.000003] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000005] e820: remove [mem 0x000a0000-0x000fffff] usable [ 0.000009] last_pfn = 0x8ab800 max_arch_pfn = 0x400000000 [ 0.000013] total RAM covered: 62720M [ 0.000086] Found optimal setting for mtrr clean up [ 0.000087] gran_size: 64K chunk_size: 64K num_reg: 6 lose cover RAM: 0G [ 0.000089] MTRR map: 5 entries (3 fixed + 2 variable; max 23), built from 10 variable MTRRs [ 0.000090] x86/PAT: Configuration [0-7]: WB WC UC- UC WB WP UC- WT [ 0.000538] e820: update [mem 0x50000000-0xffffffff] usable ==> reserved [ 0.000540] last_pfn = 0x41c00 max_arch_pfn = 0x400000000 [ 0.005806] esrt: Reserving ESRT space from 0x000000003c0a8098 to 0x000000003c0a8170. [ 0.005830] Using GB pages for direct mapping [ 0.014923] printk: log_buf_len: 16777216 bytes [ 0.014924] printk: early log buf free: 258720(98%) [ 0.014925] Secure boot disabled [ 0.014925] RAMDISK: [mem 0x26191000-0x2a584fff] [ 0.014929] ACPI: Early table checksum verification disabled [ 0.014932] ACPI: RSDP 0x0000000041BFE014 000024 (v02 HPQOEM) [ 0.014935] ACPI: XSDT 0x0000000041B52228 000194 (v01 HPQOEM SLIC-BPC 00000000 01000013) [ 0.014939] ACPI: FACP 0x0000000041BDB000 000114 (v06 HPQOEM SLIC-BPC 00000000 HP 00000001) [ 0.014943] ACPI: DSDT 0x0000000041B85000 052E09 (v02 HPQOEM 89C6 00000000 INTL 20200717) [ 0.014945] ACPI: FACS 0x0000000041A2D000 000040 [ 0.014947] ACPI: SSDT 0x0000000041BFC000 000FDF (v02 HP PSENWSAR 00001000 INTL 20200717) [ 0.014949] ACPI: RTMA 0x0000000041BFB000 00009E (v01 HP _HBMART_ 00001000 HP 00000001) [ 0.014951] ACPI: SSDT 0x0000000041BF9000 0017B3 (v02 HP UcsiAcpi 00000001 INTL 20200717) [ 0.014952] ACPI: SSDT 0x0000000041BF8000 0000FB (v02 HP UcsiCntr 00000001 INTL 20200717) [ 0.014954] ACPI: SSDT 0x0000000041BF7000 0002D7 (v02 HP NVTEC 00000001 INTL 20200717) [ 0.014956] ACPI: SSDT 0x0000000041BF6000 00013E (v02 HP ShmTable 00000001 INTL 20200717) [ 0.014958] ACPI: SSDT 0x0000000041BF5000 00038C (v02 PmaxDv Pmax_Dev 00000001 INTL 20200717) [ 0.014959] ACPI: SSDT 0x0000000041BEF000 005D34 (v02 CpuRef CpuSsdt 00003000 INTL 20200717) [ 0.014961] ACPI: OEML 0x0000000041BEE000 000028 (v03 HPQOEM ADL 00000002 01000013) [ 0.014963] ACPI: SSDT 0x0000000041BEC000 001D8A (v02 HP LAPTOPPC 00001000 INTL 20200717) [ 0.014965] ACPI: SSDT 0x0000000041BE7000 003256 (v02 INTEL DTbtSsdt 00001000 INTL 20200717) [ 0.014966] ACPI: SSDT 0x0000000041BE6000 0005FB (v02 HPQOEM Tpm2Tabl 00001000 INTL 20200717) [ 0.014968] ACPI: TPM2 0x0000000041BE5000 00004C (v04 HPQOEM ADL 00000002 01000013) [ 0.014970] ACPI: SSDT 0x0000000041BE2000 002B26 (v02 SaSsdt SaSsdt 00003000 INTL 20200717) [ 0.014972] ACPI: SSDT 0x0000000041BDE000 0033C4 (v02 INTEL IgfxSsdt 00003000 INTL 20200717) [ 0.014973] ACPI: MSDM 0x0000000041BDD000 000055 (v03 HPQOEM SLIC-BPC 00000000 HP 00000001) [ 0.014975] ACPI: WSMT 0x0000000041BDC000 000028 (v01 HPQOEM 89C6 00000001 HP 00000001) [ 0.014977] ACPI: HPET 0x0000000041BDA000 000038 (v01 HPQOEM 89C6 00000001 HP 00000001) [ 0.014979] ACPI: APIC 0x0000000041BD9000 0001DC (v05 HPQOEM 89C6 00000001 HP 00000001) [ 0.014980] ACPI: MCFG 0x0000000041BFD000 00003C (v01 HPQOEM 89C6 00000001 HP 00000001) [ 0.014982] ACPI: SSDT 0x0000000041B84000 0009D9 (v02 HPQOEM HP_XHC_P 00000000 INTL 20200717) [ 0.014984] ACPI: SSDT 0x0000000041B7D000 006B06 (v02 DptfTb DptfTabl 00001000 INTL 20200717) [ 0.014986] ACPI: LPIT 0x0000000041B7C000 0000CC (v01 HPQOEM 00000000 00000000) [ 0.014987] ACPI: WSMT 0x0000000041B7B000 000028 (v01 HPQOEM 00000000 00000000) [ 0.014989] ACPI: NHLT 0x0000000041B79000 001B35 (v00 HPQOEM ADL 00000002 01000013) [ 0.014991] ACPI: DMAR 0x0000000041B78000 000088 (v01 INTEL ADL 00000002 INTL 01000013) [ 0.014993] ACPI: FPDT 0x0000000041B77000 000044 (v01 HPQOEM ADL 00000002 01000013) [ 0.014994] ACPI: SSDT 0x0000000041B73000 0039DA (v02 SocGpe SocGpe 00003000 INTL 20200717) [ 0.014996] ACPI: SSDT 0x0000000041B6F000 0039DA (v02 SocCmn SocCmn 00003000 INTL 20200717) [ 0.014998] ACPI: SSDT 0x0000000041B6E000 0002C7 (v02 HP HPNBCONV 00001000 INTL 20200717) [ 0.015000] ACPI: SSDT 0x0000000041B6D000 000435 (v02 HP INTTPL 00001000 INTL 20200717) [ 0.015001] ACPI: SSDT 0x0000000041B64000 008658 (v02 HP HPDTBT 00001000 INTL 20200717) [ 0.015003] ACPI: SSDT 0x0000000041B61000 0024CA (v02 Rtd3 AdlSBTbt 00001000 INTL 20200717) [ 0.015005] ACPI: SSDT 0x0000000041B5C000 00483C (v01 HP NVHG 00001000 INTL 20200717) [ 0.015007] ACPI: SSDT 0x0000000041B5B000 000522 (v01 HP NVPOWERC 00001000 INTL 20200717) [ 0.015008] ACPI: SSDT 0x0000000041B57000 003A4A (v02 HP HPINNBWL 00001000 INTL 20200717) [ 0.015010] ACPI: SSDT 0x0000000041B56000 000032 (v02 HP HPCONDEV 00001000 INTL 20200717) [ 0.015012] ACPI: SSDT 0x0000000041B55000 000116 (v02 HP HPSANIMD 00001000 INTL 20200717) [ 0.015014] ACPI: SSDT 0x0000000041B53000 001027 (v02 HP HPINTELG 00001000 INTL 20200717) [ 0.015015] ACPI: SSDT 0x0000000041BD8000 000069 (v02 HP HPCAHWID 00001000 INTL 20200717) [ 0.015017] ACPI: SSDT 0x0000000041B51000 00004B (v01 HP CAPAHWID 00001000 INTL 20200717) [ 0.015019] ACPI: BGRT 0x0000000041B4F000 000038 (v01 HPQOEM ADL 00000002 01000013) [ 0.015021] ACPI: ASF! 0x0000000041B50000 0000A0 (v32 HPQOEM UYAMIHC 00000002 01000013) [ 0.015022] ACPI: PHAT 0x0000000041B4E000 0004EA (v01 HPQOEM SLIC-BPC 00000005 MSFT 0100000D) [ 0.015024] ACPI: SSDT 0x0000000041BEB000 0002F9 (v02 HP PwrCtlEv 00000001 INTL 20200717) [ 0.015025] ACPI: Reserving FACP table memory at [mem 0x41bdb000-0x41bdb113] [ 0.015026] ACPI: Reserving DSDT table memory at [mem 0x41b85000-0x41bd7e08] [ 0.015027] ACPI: Reserving FACS table memory at [mem 0x41a2d000-0x41a2d03f] [ 0.015027] ACPI: Reserving SSDT table memory at [mem 0x41bfc000-0x41bfcfde] [ 0.015028] ACPI: Reserving RTMA table memory at [mem 0x41bfb000-0x41bfb09d] [ 0.015028] ACPI: Reserving SSDT table memory at [mem 0x41bf9000-0x41bfa7b2] [ 0.015029] ACPI: Reserving SSDT table memory at [mem 0x41bf8000-0x41bf80fa] [ 0.015029] ACPI: Reserving SSDT table memory at [mem 0x41bf7000-0x41bf72d6] [ 0.015030] ACPI: Reserving SSDT table memory at [mem 0x41bf6000-0x41bf613d] [ 0.015030] ACPI: Reserving SSDT table memory at [mem 0x41bf5000-0x41bf538b] [ 0.015030] ACPI: Reserving SSDT table memory at [mem 0x41bef000-0x41bf4d33] [ 0.015031] ACPI: Reserving OEML table memory at [mem 0x41bee000-0x41bee027] [ 0.015031] ACPI: Reserving SSDT table memory at [mem 0x41bec000-0x41bedd89] [ 0.015032] ACPI: Reserving SSDT table memory at [mem 0x41be7000-0x41bea255] [ 0.015032] ACPI: Reserving SSDT table memory at [mem 0x41be6000-0x41be65fa] [ 0.015033] ACPI: Reserving TPM2 table memory at [mem 0x41be5000-0x41be504b] [ 0.015033] ACPI: Reserving SSDT table memory at [mem 0x41be2000-0x41be4b25] [ 0.015033] ACPI: Reserving SSDT table memory at [mem 0x41bde000-0x41be13c3] [ 0.015034] ACPI: Reserving MSDM table memory at [mem 0x41bdd000-0x41bdd054] [ 0.015034] ACPI: Reserving WSMT table memory at [mem 0x41bdc000-0x41bdc027] [ 0.015035] ACPI: Reserving HPET table memory at [mem 0x41bda000-0x41bda037] [ 0.015035] ACPI: Reserving APIC table memory at [mem 0x41bd9000-0x41bd91db] [ 0.015035] ACPI: Reserving MCFG table memory at [mem 0x41bfd000-0x41bfd03b] [ 0.015036] ACPI: Reserving SSDT table memory at [mem 0x41b84000-0x41b849d8] [ 0.015036] ACPI: Reserving SSDT table memory at [mem 0x41b7d000-0x41b83b05] [ 0.015037] ACPI: Reserving LPIT table memory at [mem 0x41b7c000-0x41b7c0cb] [ 0.015037] ACPI: Reserving WSMT table memory at [mem 0x41b7b000-0x41b7b027] [ 0.015038] ACPI: Reserving NHLT table memory at [mem 0x41b79000-0x41b7ab34] [ 0.015038] ACPI: Reserving DMAR table memory at [mem 0x41b78000-0x41b78087] [ 0.015038] ACPI: Reserving FPDT table memory at [mem 0x41b77000-0x41b77043] [ 0.015039] ACPI: Reserving SSDT table memory at [mem 0x41b73000-0x41b769d9] [ 0.015039] ACPI: Reserving SSDT table memory at [mem 0x41b6f000-0x41b729d9] [ 0.015040] ACPI: Reserving SSDT table memory at [mem 0x41b6e000-0x41b6e2c6] [ 0.015040] ACPI: Reserving SSDT table memory at [mem 0x41b6d000-0x41b6d434] [ 0.015040] ACPI: Reserving SSDT table memory at [mem 0x41b64000-0x41b6c657] [ 0.015041] ACPI: Reserving SSDT table memory at [mem 0x41b61000-0x41b634c9] [ 0.015041] ACPI: Reserving SSDT table memory at [mem 0x41b5c000-0x41b6083b] [ 0.015042] ACPI: Reserving SSDT table memory at [mem 0x41b5b000-0x41b5b521] [ 0.015042] ACPI: Reserving SSDT table memory at [mem 0x41b57000-0x41b5aa49] [ 0.015043] ACPI: Reserving SSDT table memory at [mem 0x41b56000-0x41b56031] [ 0.015043] ACPI: Reserving SSDT table memory at [mem 0x41b55000-0x41b55115] [ 0.015043] ACPI: Reserving SSDT table memory at [mem 0x41b53000-0x41b54026] [ 0.015044] ACPI: Reserving SSDT table memory at [mem 0x41bd8000-0x41bd8068] [ 0.015044] ACPI: Reserving SSDT table memory at [mem 0x41b51000-0x41b5104a] [ 0.015045] ACPI: Reserving BGRT table memory at [mem 0x41b4f000-0x41b4f037] [ 0.015045] ACPI: Reserving ASF! table memory at [mem 0x41b50000-0x41b5009f] [ 0.015046] ACPI: Reserving PHAT table memory at [mem 0x41b4e000-0x41b4e4e9] [ 0.015046] ACPI: Reserving SSDT table memory at [mem 0x41beb000-0x41beb2f8] [ 0.015371] No NUMA configuration found [ 0.015372] Faking a node at [mem 0x0000000000000000-0x00000008ab7fffff] [ 0.015376] NODE_DATA(0) allocated [mem 0x8a6fd5000-0x8a6ffffff] [ 0.015500] Zone ranges: [ 0.015500] DMA [mem 0x0000000000001000-0x0000000000ffffff] [ 0.015501] DMA32 [mem 0x0000000001000000-0x00000000ffffffff] [ 0.015502] Normal [mem 0x0000000100000000-0x00000008ab7fffff] [ 0.015503] Device empty [ 0.015504] Movable zone start for each node [ 0.015505] Early memory node ranges [ 0.015505] node 0: [mem 0x0000000000001000-0x000000000009efff] [ 0.015506] node 0: [mem 0x0000000000100000-0x000000003b8dcfff] [ 0.015507] node 0: [mem 0x0000000041bff000-0x0000000041bfffff] [ 0.015507] node 0: [mem 0x0000000100000000-0x00000008ab7fffff] [ 0.015509] Initmem setup node 0 [mem 0x0000000000001000-0x00000008ab7fffff] [ 0.015513] On node 0, zone DMA: 1 pages in unavailable ranges [ 0.015530] On node 0, zone DMA: 97 pages in unavailable ranges [ 0.016723] On node 0, zone DMA32: 25378 pages in unavailable ranges [ 0.050732] On node 0, zone Normal: 25600 pages in unavailable ranges [ 0.050865] On node 0, zone Normal: 18432 pages in unavailable ranges [ 0.050904] Reserving Intel graphics memory at [mem 0x50800000-0x547fffff] [ 0.052574] ACPI: PM-Timer IO Port: 0x1808 [ 0.052581] ACPI: LAPIC_NMI (acpi_id[0x01] high edge lint[0x1]) [ 0.052582] ACPI: LAPIC_NMI (acpi_id[0x02] high edge lint[0x1]) [ 0.052582] ACPI: LAPIC_NMI (acpi_id[0x03] high edge lint[0x1]) [ 0.052583] ACPI: LAPIC_NMI (acpi_id[0x04] high edge lint[0x1]) [ 0.052583] ACPI: LAPIC_NMI (acpi_id[0x05] high edge lint[0x1]) [ 0.052584] ACPI: LAPIC_NMI (acpi_id[0x06] high edge lint[0x1]) [ 0.052584] ACPI: LAPIC_NMI (acpi_id[0x07] high edge lint[0x1]) [ 0.052584] ACPI: LAPIC_NMI (acpi_id[0x08] high edge lint[0x1]) [ 0.052585] ACPI: LAPIC_NMI (acpi_id[0x09] high edge lint[0x1]) [ 0.052585] ACPI: LAPIC_NMI (acpi_id[0x0a] high edge lint[0x1]) [ 0.052586] ACPI: LAPIC_NMI (acpi_id[0x0b] high edge lint[0x1]) [ 0.052586] ACPI: LAPIC_NMI (acpi_id[0x0c] high edge lint[0x1]) [ 0.052586] ACPI: LAPIC_NMI (acpi_id[0x0d] high edge lint[0x1]) [ 0.052587] ACPI: LAPIC_NMI (acpi_id[0x0e] high edge lint[0x1]) [ 0.052587] ACPI: LAPIC_NMI (acpi_id[0x0f] high edge lint[0x1]) [ 0.052588] ACPI: LAPIC_NMI (acpi_id[0x10] high edge lint[0x1]) [ 0.052588] ACPI: LAPIC_NMI (acpi_id[0x11] high edge lint[0x1]) [ 0.052588] ACPI: LAPIC_NMI (acpi_id[0x12] high edge lint[0x1]) [ 0.052589] ACPI: LAPIC_NMI (acpi_id[0x13] high edge lint[0x1]) [ 0.052589] ACPI: LAPIC_NMI (acpi_id[0x14] high edge lint[0x1]) [ 0.052590] ACPI: LAPIC_NMI (acpi_id[0x15] high edge lint[0x1]) [ 0.052590] ACPI: LAPIC_NMI (acpi_id[0x16] high edge lint[0x1]) [ 0.052590] ACPI: LAPIC_NMI (acpi_id[0x17] high edge lint[0x1]) [ 0.052591] ACPI: LAPIC_NMI (acpi_id[0x00] high edge lint[0x1]) [ 0.052627] IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-119 [ 0.052629] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) [ 0.052630] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level) [ 0.052633] ACPI: Using ACPI (MADT) for SMP configuration information [ 0.052633] ACPI: HPET id: 0x8086a201 base: 0xfed00000 [ 0.052642] e820: update [mem 0x2e866000-0x2e8dbfff] usable ==> reserved [ 0.052648] TSC deadline timer available [ 0.052648] smpboot: Allowing 24 CPUs, 0 hotplug CPUs [ 0.052656] PM: hibernation: Registered nosave memory: [mem 0x00000000-0x00000fff] [ 0.052657] PM: hibernation: Registered nosave memory: [mem 0x0009f000-0x000fffff] [ 0.052658] PM: hibernation: Registered nosave memory: [mem 0x2e866000-0x2e8dbfff] [ 0.052659] PM: hibernation: Registered nosave memory: [mem 0x3b8dd000-0x41933fff] [ 0.052660] PM: hibernation: Registered nosave memory: [mem 0x41934000-0x41b33fff] [ 0.052660] PM: hibernation: Registered nosave memory: [mem 0x41b34000-0x41bfefff] [ 0.052661] PM: hibernation: Registered nosave memory: [mem 0x41c00000-0x47ffffff] [ 0.052661] PM: hibernation: Registered nosave memory: [mem 0x48000000-0x493fffff] [ 0.052662] PM: hibernation: Registered nosave memory: [mem 0x49400000-0x495fffff] [ 0.052662] PM: hibernation: Registered nosave memory: [mem 0x49600000-0x4bffffff] [ 0.052662] PM: hibernation: Registered nosave memory: [mem 0x4c000000-0x547fffff] [ 0.052663] PM: hibernation: Registered nosave memory: [mem 0x54800000-0xfed1ffff] [ 0.052663] PM: hibernation: Registered nosave memory: [mem 0xfed20000-0xfed7ffff] [ 0.052663] PM: hibernation: Registered nosave memory: [mem 0xfed80000-0xffffffff] [ 0.052664] [mem 0x54800000-0xfed1ffff] available for PCI devices [ 0.052665] Booting paravirtualized kernel on bare hardware [ 0.052667] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns [ 0.052671] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:24 nr_cpu_ids:24 nr_node_ids:1 [ 0.053391] percpu: Embedded 64 pages/cpu s225280 r8192 d28672 u262144 [ 0.053394] pcpu-alloc: s225280 r8192 d28672 u262144 alloc=1*2097152 [ 0.053396] pcpu-alloc: [0] 00 01 02 03 04 05 06 07 [0] 08 09 10 11 12 13 14 15 [ 0.053401] pcpu-alloc: [0] 16 17 18 19 20 21 22 23 [ 0.053414] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-6.7.0-rc1-next-20231115+ root=UUID=061502a9-205e-4b73-8251-1220e770c5d8 ro quiet splash pcie_aspm=off log_buf_len=10M trace_event=gpio:* vt.handoff=7 [ 0.053454] PCIe ASPM is disabled [ 0.053473] Unknown kernel command line parameters "splash BOOT_IMAGE=/boot/vmlinuz-6.7.0-rc1-next-20231115+", will be passed to user space. [ 0.055688] Dentry cache hash table entries: 4194304 (order: 13, 33554432 bytes, linear) [ 0.056809] Inode-cache hash table entries: 2097152 (order: 12, 16777216 bytes, linear) [ 0.056956] Fallback order for Node 0: 0 [ 0.056958] Built 1 zonelists, mobility grouping on. Total pages: 8156698 [ 0.056959] Policy zone: Normal [ 0.056964] mem auto-init: stack:off, heap alloc:on, heap free:off [ 0.056970] software IO TLB: area num 32. [ 0.105875] Memory: 32103252K/33145328K available (20480K kernel code, 4267K rwdata, 7376K rodata, 4712K init, 5184K bss, 1041820K reserved, 0K cma-reserved) [ 0.106059] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=24, Nodes=1 [ 0.106081] ftrace: allocating 52890 entries in 207 pages [ 0.111619] ftrace: allocated 207 pages with 6 groups [ 0.112284] Dynamic Preempt: voluntary [ 0.112346] rcu: Preemptible hierarchical RCU implementation. [ 0.112346] rcu: RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=24. [ 0.112347] Trampoline variant of Tasks RCU enabled. [ 0.112348] Rude variant of Tasks RCU enabled. [ 0.112348] Tracing variant of Tasks RCU enabled. [ 0.112348] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies. [ 0.112349] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=24 [ 0.113910] NR_IRQS: 524544, nr_irqs: 2248, preallocated irqs: 16 [ 0.114204] rcu: srcu_init: Setting srcu_struct sizes based on contention. [ 0.114418] Console: colour dummy device 80x25 [ 0.114420] printk: legacy console [tty0] enabled [ 0.114452] ACPI: Core revision 20230628 [ 0.114711] hpet: HPET dysfunctional in PC10. Force disabled. [ 0.114711] APIC: Switch to symmetric I/O mode setup [ 0.114713] DMAR: Host address width 39 [ 0.114714] DMAR: DRHD base: 0x000000fed90000 flags: 0x0 [ 0.114717] DMAR: dmar0: reg_base_addr fed90000 ver 4:0 cap 1c0000c40660462 ecap 29a00f0505e [ 0.114719] DMAR: DRHD base: 0x000000fed91000 flags: 0x1 [ 0.114724] DMAR: dmar1: reg_base_addr fed91000 ver 5:0 cap d2008c40660462 ecap f050da [ 0.114726] DMAR: RMRR base: 0x00000050000000 end: 0x000000547fffff [ 0.114727] DMAR-IR: IOAPIC id 2 under DRHD base 0xfed91000 IOMMU 1 [ 0.114728] DMAR-IR: HPET id 0 under DRHD base 0xfed91000 [ 0.114729] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping. [ 0.116288] DMAR-IR: Enabled IRQ remapping in x2apic mode [ 0.116289] x2apic enabled [ 0.116338] APIC: Switched APIC routing to: cluster x2apic [ 0.120722] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x22df1149949, max_idle_ns: 440795312789 ns [ 0.120727] Calibrating delay loop (skipped), value calculated using timer frequency.. 4838.40 BogoMIPS (lpj=9676800) [ 0.120770] x86/tme: not enabled by BIOS [ 0.120776] CPU0: Thermal monitoring enabled (TM1) [ 0.120778] x86/cpu: User Mode Instruction Prevention (UMIP) activated [ 0.120881] process: using mwait in idle threads [ 0.120883] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0 [ 0.120883] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0 [ 0.120885] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization [ 0.120887] Spectre V2 : Mitigation: Enhanced / Automatic IBRS [ 0.120887] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch [ 0.120888] Spectre V2 : Spectre v2 / PBRSB-eIBRS: Retire a single CALL on VMEXIT [ 0.120889] Spectre V2 : mitigation: Enabling conditional Indirect Branch Prediction Barrier [ 0.120890] Speculative Store Bypass: Mitigation: Speculative Store Bypass disabled via prctl [ 0.120898] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers' [ 0.120899] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' [ 0.120899] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' [ 0.120900] x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User registers' [ 0.120900] x86/fpu: Supporting XSAVE feature 0x800: 'Control-flow User registers' [ 0.120901] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256 [ 0.120902] x86/fpu: xstate_offset[9]: 832, xstate_sizes[9]: 8 [ 0.120902] x86/fpu: xstate_offset[11]: 840, xstate_sizes[11]: 16 [ 0.120903] x86/fpu: Enabled xstate features 0xa07, context size is 856 bytes, using 'compacted' format. [ 0.124725] Freeing SMP alternatives memory: 44K [ 0.124725] pid_max: default: 32768 minimum: 301 [ 0.124725] LSM: initializing lsm=lockdown,capability,landlock,yama,apparmor,integrity [ 0.124725] landlock: Up and running. [ 0.124725] Yama: becoming mindful. [ 0.124725] AppArmor: AppArmor initialized [ 0.124725] Mount-cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.124725] Mountpoint-cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.124725] smpboot: CPU0: 12th Gen Intel(R) Core(TM) i7-12850HX (family: 0x6, model: 0x97, stepping: 0x2) [ 0.124725] RCU Tasks: Setting shift to 5 and lim to 1 rcu_task_cb_adjust=1. [ 0.124725] RCU Tasks Rude: Setting shift to 5 and lim to 1 rcu_task_cb_adjust=1. [ 0.124725] RCU Tasks Trace: Setting shift to 5 and lim to 1 rcu_task_cb_adjust=1. [ 0.124725] Performance Events: XSAVE Architectural LBR, PEBS fmt4+-baseline, AnyThread deprecated, Alderlake Hybrid events, 32-deep LBR, full-width counters, Intel PMU driver. [ 0.124725] core: cpu_core PMU driver: [ 0.124725] ... version: 5 [ 0.124725] ... bit width: 48 [ 0.124725] ... generic registers: 8 [ 0.124725] ... value mask: 0000ffffffffffff [ 0.124725] ... max period: 00007fffffffffff [ 0.124725] ... fixed-purpose events: 4 [ 0.124725] ... event mask: 0001000f000000ff [ 0.124725] signal: max sigframe size: 3632 [ 0.124725] Estimated ratio of average max frequency by base frequency (times 1024): 1962 [ 0.124725] rcu: Hierarchical SRCU implementation. [ 0.124725] rcu: Max phase no-delay instances is 1000. [ 0.129797] NMI watchdog: Enabled. Permanently consumes one hw-PMU counter. [ 0.129911] smp: Bringing up secondary CPUs ... [ 0.130100] smpboot: x86: Booting SMP configuration: [ 0.130101] .... node #0, CPUs: #2 #4 #6 #8 #10 #12 #14 #16 #17 #18 #19 #20 #21 #22 #23 [ 0.010343] core: cpu_atom PMU driver: PEBS-via-PT [ 0.010343] ... version: 5 [ 0.010343] ... bit width: 48 [ 0.010343] ... generic registers: 6 [ 0.010343] ... value mask: 0000ffffffffffff [ 0.010343] ... max period: 00007fffffffffff [ 0.010343] ... fixed-purpose events: 3 [ 0.010343] ... event mask: 000000070000003f [ 0.144905] #1 #3 #5 #7 #9 #11 #13 #15 [ 0.164832] smp: Brought up 1 node, 24 CPUs [ 0.164832] smpboot: Max logical packages: 1 [ 0.164832] smpboot: Total of 24 processors activated (116121.60 BogoMIPS) [ 0.169584] devtmpfs: initialized [ 0.169584] x86/mm: Memory block size: 128MB [ 0.170241] ACPI: PM: Registering ACPI NVS region [mem 0x41934000-0x41b33fff] (2097152 bytes) [ 0.170241] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.170241] futex hash table entries: 8192 (order: 7, 524288 bytes, linear) [ 0.170241] pinctrl core: initialized pinctrl subsystem [ 0.170241] PM: RTC time: 17:31:31, date: 2023-11-21 [ 0.170241] NET: Registered PF_NETLINK/PF_ROUTE protocol family [ 0.170241] DMA: preallocated 4096 KiB GFP_KERNEL pool for atomic allocations [ 0.170241] DMA: preallocated 4096 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations [ 0.172936] DMA: preallocated 4096 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations [ 0.172942] audit: initializing netlink subsys (disabled) [ 0.172946] audit: type=2000 audit(1700587891.052:1): state=initialized audit_enabled=0 res=1 [ 0.172946] thermal_sys: Registered thermal governor 'fair_share' [ 0.172946] thermal_sys: Registered thermal governor 'bang_bang' [ 0.172946] thermal_sys: Registered thermal governor 'step_wise' [ 0.172946] thermal_sys: Registered thermal governor 'user_space' [ 0.172946] thermal_sys: Registered thermal governor 'power_allocator' [ 0.172946] EISA bus registered [ 0.172946] cpuidle: using governor ladder [ 0.172946] cpuidle: using governor menu [ 0.172946] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 [ 0.172946] PCI: MMCONFIG for domain 0000 [bus 00-ff] at [mem 0xc0000000-0xcfffffff] (base 0xc0000000) [ 0.172946] PCI: not using MMCONFIG [ 0.172946] PCI: Using configuration type 1 for base access [ 0.173194] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' [ 0.173195] kprobes: kprobe jump-optimization is enabled. All kprobes are optimized if possible. [ 0.173195] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages [ 0.173195] HugeTLB: 16380 KiB vmemmap can be freed for a 1.00 GiB page [ 0.173195] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages [ 0.173195] HugeTLB: 28 KiB vmemmap can be freed for a 2.00 MiB page [ 0.173195] ACPI: Added _OSI(Module Device) [ 0.173195] ACPI: Added _OSI(Processor Device) [ 0.173195] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.173195] ACPI: Added _OSI(Processor Aggregator Device) [ 0.284293] ACPI: 30 ACPI AML tables successfully acquired and loaded [ 0.289118] ACPI: [Firmware Bug]: BIOS _OSI(Linux) query ignored [ 0.368735] ACPI: Dynamic OEM Table Load: [ 0.368735] ACPI: SSDT 0xFFFF8881034D8800 000394 (v02 PmRef Cpu0Cst 00003001 INTL 20200717) [ 0.369073] ACPI: Dynamic OEM Table Load: [ 0.369081] ACPI: SSDT 0xFFFF88810547B000 00053F (v02 PmRef Cpu0Ist 00003000 INTL 20200717) [ 0.370396] ACPI: Dynamic OEM Table Load: [ 0.370404] ACPI: SSDT 0xFFFF888105400A00 0001AB (v02 PmRef Cpu0Psd 00003000 INTL 20200717) [ 0.371626] ACPI: Dynamic OEM Table Load: [ 0.371633] ACPI: SSDT 0xFFFF888105479800 0004BD (v02 PmRef Cpu0Hwp 00003000 INTL 20200717) [ 0.373314] ACPI: Dynamic OEM Table Load: [ 0.373326] ACPI: SSDT 0xFFFF8881034D4000 001BAF (v02 PmRef ApIst 00003000 INTL 20200717) [ 0.375399] ACPI: Dynamic OEM Table Load: [ 0.375408] ACPI: SSDT 0xFFFF888105484000 001038 (v02 PmRef ApHwp 00003000 INTL 20200717) [ 0.377221] ACPI: Dynamic OEM Table Load: [ 0.377232] ACPI: SSDT 0xFFFF888105482000 001349 (v02 PmRef ApPsd 00003000 INTL 20200717) [ 0.379109] ACPI: Dynamic OEM Table Load: [ 0.379118] ACPI: SSDT 0xFFFF8881034E3000 000FBB (v02 PmRef ApCst 00003000 INTL 20200717) [ 0.391168] ACPI: _OSC evaluated successfully for all CPUs [ 0.391218] ACPI: EC: EC started [ 0.391219] ACPI: EC: interrupt blocked [ 0.414702] ACPI: EC: EC_CMD/EC_SC=0x66, EC_DATA=0x62 [ 0.414705] ACPI: \_SB_.PC00.LPCB.EC0_: Boot DSDT EC used to handle transactions [ 0.414706] ACPI: Interpreter enabled [ 0.414774] ACPI: PM: (supports S0 S3 S4 S5) [ 0.414774] ACPI: Using IOAPIC for interrupt routing [ 0.416485] PCI: MMCONFIG for domain 0000 [bus 00-ff] at [mem 0xc0000000-0xcfffffff] (base 0xc0000000) [ 0.417954] PCI: MMCONFIG at [mem 0xc0000000-0xcfffffff] reserved as ACPI motherboard resource [ 0.417963] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug [ 0.417964] PCI: Ignoring E820 reservations for host bridge windows [ 0.418886] ACPI: Enabled 8 GPEs in block 00 to 7F [ 0.425368] ACPI: \_SB_.PC00.PEG1.PXP_: New power resource [ 0.432018] ACPI: \_SB_.PC00.XHCI.RHUB.HS14.BTPR: New power resource [ 0.438525] ACPI: \_SB_.PC00.CNVW.WRST: New power resource [ 0.445011] ACPI: \_SB_.PC00.RP09.PXP_: New power resource [ 0.464813] ACPI: \PIN_: New power resource [ 0.465292] ACPI: PCI Root Bridge [PC00] (domain 0000 [bus 00-fe]) [ 0.465298] acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig Segments MSI EDR HPX-Type3] [ 0.465300] acpi PNP0A08:00: _OSC: not requesting OS control; OS requires [ExtendedConfig ASPM ClockPM MSI] [ 0.470893] PCI host bridge to bus 0000:00 [ 0.470895] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7 window] [ 0.470897] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff window] [ 0.470898] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window] [ 0.470899] pci_bus 0000:00: root bus resource [mem 0x54800000-0xbfffffff window] [ 0.470900] pci_bus 0000:00: root bus resource [mem 0x4000000000-0x7fffffffff window] [ 0.470902] pci_bus 0000:00: root bus resource [bus 00-fe] [ 0.470934] pci 0000:00:00.0: [8086:4637] type 00 class 0x060000 [ 0.471040] pci 0000:00:01.0: [8086:460d] type 01 class 0x060400 [ 0.471086] pci 0000:00:01.0: PME# supported from D0 D3hot D3cold [ 0.471105] pci 0000:00:01.0: PTM enabled (root), 4ns granularity [ 0.471790] pci 0000:00:02.0: [8086:4688] type 00 class 0x030000 [ 0.471797] pci 0000:00:02.0: reg 0x10: [mem 0x645b000000-0x645bffffff 64bit] [ 0.471802] pci 0000:00:02.0: reg 0x18: [mem 0x4000000000-0x400fffffff 64bit pref] [ 0.471805] pci 0000:00:02.0: reg 0x20: [io 0x5000-0x503f] [ 0.471818] pci 0000:00:02.0: BAR 2: assigned to efifb [ 0.471819] pci 0000:00:02.0: DMAR: Skip IOMMU disabling for graphics [ 0.471821] pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff] [ 0.471841] pci 0000:00:02.0: reg 0x344: [mem 0x00000000-0x00ffffff 64bit] [ 0.471842] pci 0000:00:02.0: VF(n) BAR0 space: [mem 0x00000000-0x06ffffff 64bit] (contains BAR0 for 7 VFs) [ 0.471846] pci 0000:00:02.0: reg 0x34c: [mem 0x00000000-0x1fffffff 64bit pref] [ 0.471847] pci 0000:00:02.0: VF(n) BAR2 space: [mem 0x00000000-0xdfffffff 64bit pref] (contains BAR2 for 7 VFs) [ 0.472000] pci 0000:00:04.0: [8086:461d] type 00 class 0x118000 [ 0.472012] pci 0000:00:04.0: reg 0x10: [mem 0x645cb00000-0x645cb1ffff 64bit] [ 0.472338] pci 0000:00:06.0: [8086:464d] type 01 class 0x060400 [ 0.472404] pci 0000:00:06.0: PME# supported from D0 D3hot D3cold [ 0.472427] pci 0000:00:06.0: PTM enabled (root), 4ns granularity [ 0.473172] pci 0000:00:08.0: [8086:464f] type 00 class 0x088000 [ 0.473179] pci 0000:00:08.0: reg 0x10: [mem 0x645cb66000-0x645cb66fff 64bit] [ 0.473267] pci 0000:00:0a.0: [8086:467d] type 00 class 0x118000 [ 0.473274] pci 0000:00:0a.0: reg 0x10: [mem 0x645cb40000-0x645cb47fff 64bit] [ 0.473290] pci 0000:00:0a.0: enabling Extended Tags [ 0.473388] pci 0000:00:12.0: [8086:7af8] type 00 class 0x070000 [ 0.473408] pci 0000:00:12.0: reg 0x10: [mem 0x645cb30000-0x645cb3ffff 64bit] [ 0.473478] pci 0000:00:12.0: PME# supported from D0 D3hot [ 0.474105] pci 0000:00:14.0: [8086:7ae0] type 00 class 0x0c0330 [ 0.474121] pci 0000:00:14.0: reg 0x10: [mem 0x645cb20000-0x645cb2ffff 64bit] [ 0.474183] pci 0000:00:14.0: PME# supported from D3hot D3cold [ 0.474752] pci 0000:00:14.2: [8086:7aa7] type 00 class 0x050000 [ 0.474771] pci 0000:00:14.2: reg 0x10: [mem 0x645cb58000-0x645cb5bfff 64bit] [ 0.474784] pci 0000:00:14.2: reg 0x18: [mem 0x645cb65000-0x645cb65fff 64bit] [ 0.474928] pci 0000:00:14.3: [8086:7af0] type 00 class 0x028000 [ 0.474970] pci 0000:00:14.3: reg 0x10: [mem 0x645cb54000-0x645cb57fff 64bit] [ 0.475090] pci 0000:00:14.3: PME# supported from D0 D3hot D3cold [ 0.475414] pci 0000:00:15.0: [8086:7acc] type 00 class 0x0c8000 [ 0.475482] pci 0000:00:15.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.475972] pci 0000:00:15.1: [8086:7acd] type 00 class 0x0c8000 [ 0.476043] pci 0000:00:15.1: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.476528] pci 0000:00:15.2: [8086:7ace] type 00 class 0x0c8000 [ 0.476595] pci 0000:00:15.2: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.477061] pci 0000:00:16.0: [8086:7ae8] type 00 class 0x078000 [ 0.477082] pci 0000:00:16.0: reg 0x10: [mem 0x645cb61000-0x645cb61fff 64bit] [ 0.477160] pci 0000:00:16.0: PME# supported from D3hot [ 0.477760] pci 0000:00:16.3: [8086:7aeb] type 00 class 0x070002 [ 0.477772] pci 0000:00:16.3: reg 0x10: [io 0x5060-0x5067] [ 0.477779] pci 0000:00:16.3: reg 0x14: [mem 0x88da1000-0x88da1fff] [ 0.477996] pci 0000:00:19.0: [8086:7afc] type 00 class 0x0c8000 [ 0.478022] pci 0000:00:19.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.478309] pci 0000:00:19.2: [8086:7afe] type 00 class 0x078000 [ 0.478338] pci 0000:00:19.2: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.478870] pci 0000:00:1b.0: [8086:7ac4] type 01 class 0x060400 [ 0.479011] pci 0000:00:1b.0: PME# supported from D0 D3hot D3cold [ 0.479058] pci 0000:00:1b.0: PTM enabled (root), 4ns granularity [ 0.479911] pci 0000:00:1c.0: [8086:7abd] type 01 class 0x060400 [ 0.480013] pci 0000:00:1c.0: PME# supported from D0 D3hot D3cold [ 0.480053] pci 0000:00:1c.0: PTM enabled (root), 4ns granularity [ 0.480837] pci 0000:00:1d.0: [8086:7ab0] type 01 class 0x060400 [ 0.480944] pci 0000:00:1d.0: PME# supported from D0 D3hot D3cold [ 0.480985] pci 0000:00:1d.0: PTM enabled (root), 4ns granularity [ 0.481849] pci 0000:00:1e.0: [8086:7aa8] type 00 class 0x078000 [ 0.481918] pci 0000:00:1e.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.482460] pci 0000:00:1e.2: [8086:7aaa] type 00 class 0x0c8000 [ 0.482529] pci 0000:00:1e.2: reg 0x10: [mem 0x00000000-0x00000fff 64bit] [ 0.482943] pci 0000:00:1f.0: [8086:7a8d] type 00 class 0x060100 [ 0.483328] pci 0000:00:1f.3: [8086:7ad0] type 00 class 0x040100 [ 0.483369] pci 0000:00:1f.3: reg 0x10: [mem 0x645cb50000-0x645cb53fff 64bit] [ 0.483421] pci 0000:00:1f.3: reg 0x20: [mem 0x645ca00000-0x645cafffff 64bit] [ 0.483522] pci 0000:00:1f.3: PME# supported from D3hot D3cold [ 0.483618] pci 0000:00:1f.4: [8086:7aa3] type 00 class 0x0c0500 [ 0.483639] pci 0000:00:1f.4: reg 0x10: [mem 0x645cb5c000-0x645cb5c0ff 64bit] [ 0.483660] pci 0000:00:1f.4: reg 0x20: [io 0xefa0-0xefbf] [ 0.483946] pci 0000:00:1f.5: [8086:7aa4] type 00 class 0x0c8000 [ 0.483964] pci 0000:00:1f.5: reg 0x10: [mem 0xfe010000-0xfe010fff] [ 0.484093] pci 0000:00:1f.6: [8086:1a1c] type 00 class 0x020000 [ 0.484118] pci 0000:00:1f.6: reg 0x10: [mem 0x88d80000-0x88d9ffff] [ 0.484237] pci 0000:00:1f.6: PME# supported from D0 D3hot D3cold [ 0.484554] pci 0000:01:00.0: [10de:24b9] type 00 class 0x030000 [ 0.484562] pci 0000:01:00.0: reg 0x10: [mem 0x87000000-0x87ffffff] [ 0.484569] pci 0000:01:00.0: reg 0x14: [mem 0x6000000000-0x63ffffffff 64bit pref] [ 0.484576] pci 0000:01:00.0: reg 0x1c: [mem 0x6400000000-0x6401ffffff 64bit pref] [ 0.484581] pci 0000:01:00.0: reg 0x24: [io 0x4000-0x407f] [ 0.484585] pci 0000:01:00.0: reg 0x30: [mem 0xfff80000-0xffffffff pref] [ 0.484626] pci 0000:01:00.0: PME# supported from D0 D3hot [ 0.484891] pci 0000:01:00.1: [10de:228b] type 00 class 0x040300 [ 0.484898] pci 0000:01:00.1: reg 0x10: [mem 0x88000000-0x88003fff] [ 0.484997] pci 0000:00:01.0: PCI bridge to [bus 01] [ 0.484999] pci 0000:00:01.0: bridge window [io 0x4000-0x4fff] [ 0.485001] pci 0000:00:01.0: bridge window [mem 0x87000000-0x880fffff] [ 0.485004] pci 0000:00:01.0: bridge window [mem 0x6000000000-0x6401ffffff 64bit pref] [ 0.485772] pci 0000:02:00.0: [144d:a80a] type 00 class 0x010802 [ 0.485786] pci 0000:02:00.0: reg 0x10: [mem 0x88c00000-0x88c03fff 64bit] [ 0.485988] pci 0000:00:06.0: PCI bridge to [bus 02] [ 0.485990] pci 0000:00:06.0: bridge window [mem 0x88c00000-0x88cfffff] [ 0.486319] pci 0000:03:00.0: [15b7:5011] type 00 class 0x010802 [ 0.486340] pci 0000:03:00.0: reg 0x10: [mem 0x88b00000-0x88b03fff 64bit] [ 0.486636] pci 0000:00:1b.0: PCI bridge to [bus 03] [ 0.486648] pci 0000:00:1b.0: bridge window [mem 0x88b00000-0x88bfffff] [ 0.486720] pci 0000:04:00.0: [10ec:5261] type 00 class 0xff0000 [ 0.486741] pci 0000:04:00.0: reg 0x10: [mem 0x88100000-0x88100fff] [ 0.486895] pci 0000:04:00.0: supports D1 D2 [ 0.486896] pci 0000:04:00.0: PME# supported from D1 D2 D3hot D3cold [ 0.487075] pci 0000:00:1c.0: PCI bridge to [bus 04] [ 0.487085] pci 0000:00:1c.0: bridge window [io 0x3000-0x3fff] [ 0.487088] pci 0000:00:1c.0: bridge window [mem 0x88100000-0x88afffff] [ 0.487092] pci 0000:00:1c.0: bridge window [mem 0x645c000000-0x645c9fffff 64bit pref] [ 0.487210] pci 0000:05:00.0: [8086:1136] type 01 class 0x060400 [ 0.487272] pci 0000:05:00.0: enabling Extended Tags [ 0.487391] pci 0000:05:00.0: supports D1 D2 [ 0.487392] pci 0000:05:00.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.487509] pci 0000:05:00.0: PTM enabled, 4ns granularity [ 0.487683] pci 0000:00:1d.0: PCI bridge to [bus 05-6e] [ 0.487694] pci 0000:00:1d.0: bridge window [mem 0x58000000-0x860fffff] [ 0.487698] pci 0000:00:1d.0: bridge window [mem 0x6410000000-0x645a0fffff 64bit pref] [ 0.487784] pci 0000:06:00.0: [8086:1136] type 01 class 0x060400 [ 0.487847] pci 0000:06:00.0: enabling Extended Tags [ 0.487964] pci 0000:06:00.0: supports D1 D2 [ 0.487965] pci 0000:06:00.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.488198] pci 0000:06:01.0: [8086:1136] type 01 class 0x060400 [ 0.488261] pci 0000:06:01.0: enabling Extended Tags [ 0.488380] pci 0000:06:01.0: supports D1 D2 [ 0.488381] pci 0000:06:01.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.488604] pci 0000:06:02.0: [8086:1136] type 01 class 0x060400 [ 0.488667] pci 0000:06:02.0: enabling Extended Tags [ 0.488778] pci 0000:06:02.0: supports D1 D2 [ 0.488779] pci 0000:06:02.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.489011] pci 0000:06:03.0: [8086:1136] type 01 class 0x060400 [ 0.489075] pci 0000:06:03.0: enabling Extended Tags [ 0.489194] pci 0000:06:03.0: supports D1 D2 [ 0.489195] pci 0000:06:03.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.489427] pci 0000:05:00.0: PCI bridge to [bus 06-6e] [ 0.489436] pci 0000:05:00.0: bridge window [mem 0x58000000-0x85efffff] [ 0.489442] pci 0000:05:00.0: bridge window [mem 0x6410000000-0x645a0fffff 64bit pref] [ 0.489522] pci 0000:07:00.0: [8086:1137] type 00 class 0x0c0340 [ 0.489548] pci 0000:07:00.0: reg 0x10: [mem 0x645a000000-0x645a03ffff 64bit pref] [ 0.489564] pci 0000:07:00.0: reg 0x18: [mem 0x645a040000-0x645a040fff 64bit pref] [ 0.489600] pci 0000:07:00.0: enabling Extended Tags [ 0.489719] pci 0000:07:00.0: supports D1 D2 [ 0.489719] pci 0000:07:00.0: PME# supported from D0 D1 D2 D3hot D3cold [ 0.489914] pci 0000:06:00.0: PCI bridge to [bus 07] [ 0.489937] pci 0000:06:00.0: bridge window [mem 0x645a000000-0x645a0fffff 64bit pref] [ 0.489984] pci 0000:06:01.0: PCI bridge to [bus 08-3a] [ 0.489994] pci 0000:06:01.0: bridge window [mem 0x6f000000-0x85efffff] [ 0.490000] pci 0000:06:01.0: bridge window [mem 0x6435000000-0x6459ffffff 64bit pref] [ 0.490087] pci 0000:3b:00.0: [8086:1138] type 00 class 0x0c0330 [ 0.490110] pci 0000:3b:00.0: reg 0x10: [mem 0x6ef00000-0x6ef0ffff 64bit] [ 0.490159] pci 0000:3b:00.0: enabling Extended Tags [ 0.490241] pci 0000:3b:00.0: PME# supported from D3hot D3cold [ 0.490348] pci 0000:06:02.0: PCI bridge to [bus 3b] [ 0.490362] pci 0000:06:02.0: bridge window [mem 0x6ef00000-0x6effffff] [ 0.490414] pci 0000:06:03.0: PCI bridge to [bus 3c-6e] [ 0.490423] pci 0000:06:03.0: bridge window [mem 0x58000000-0x6eefffff] [ 0.490430] pci 0000:06:03.0: bridge window [mem 0x6410000000-0x6434ffffff 64bit pref] [ 0.495478] ACPI: EC: interrupt unblocked [ 0.495480] ACPI: EC: event unblocked [ 0.495495] ACPI: EC: EC_CMD/EC_SC=0x66, EC_DATA=0x62 [ 0.495496] ACPI: EC: GPE=0x6e [ 0.495497] ACPI: \_SB_.PC00.LPCB.EC0_: Boot DSDT EC initialization complete [ 0.495498] ACPI: \_SB_.PC00.LPCB.EC0_: EC: Used to handle transactions and events [ 0.495563] iommu: Default domain type: Translated [ 0.495563] iommu: DMA domain TLB invalidation policy: lazy mode [ 0.495563] SCSI subsystem initialized [ 0.495563] libata version 3.00 loaded. [ 0.495563] ACPI: bus type USB registered [ 0.495563] usbcore: registered new interface driver usbfs [ 0.495563] usbcore: registered new interface driver hub [ 0.495563] usbcore: registered new device driver usb [ 0.495563] pps_core: LinuxPPS API ver. 1 registered [ 0.495563] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]> [ 0.495563] PTP clock support registered [ 0.495563] EDAC MC: Ver: 3.0.0 [ 0.496972] efivars: Registered efivars operations [ 0.496972] NetLabel: Initializing [ 0.496972] NetLabel: domain hash size = 128 [ 0.496972] NetLabel: protocols = UNLABELED CIPSOv4 CALIPSO [ 0.496972] NetLabel: unlabeled traffic allowed by default [ 0.496972] mctp: management component transport protocol core [ 0.496972] NET: Registered PF_MCTP protocol family [ 0.496972] PCI: Using ACPI for IRQ routing [ 0.514627] PCI: pci_cache_line_size set to 64 bytes [ 0.515775] pci 0000:00:1f.5: can't claim BAR 0 [mem 0xfe010000-0xfe010fff]: no compatible bridge window [ 0.516708] e820: reserve RAM buffer [mem 0x0009f000-0x0009ffff] [ 0.516709] e820: reserve RAM buffer [mem 0x2e866000-0x2fffffff] [ 0.516710] e820: reserve RAM buffer [mem 0x3b8dd000-0x3bffffff] [ 0.516711] e820: reserve RAM buffer [mem 0x41c00000-0x43ffffff] [ 0.516712] e820: reserve RAM buffer [mem 0x8ab800000-0x8abffffff] [ 0.516737] pci 0000:00:02.0: vgaarb: setting as boot VGA device [ 0.516737] pci 0000:00:02.0: vgaarb: bridge control possible [ 0.516737] pci 0000:00:02.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none [ 0.516738] pci 0000:01:00.0: vgaarb: bridge control possible [ 0.516739] pci 0000:01:00.0: vgaarb: VGA device added: decodes=io+mem,owns=none,locks=none [ 0.516741] vgaarb: loaded [ 0.516834] clocksource: Switched to clocksource tsc-early [ 0.517108] VFS: Disk quotas dquot_6.6.0 [ 0.517120] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes) [ 0.517207] AppArmor: AppArmor Filesystem Enabled [ 0.517235] pnp: PnP ACPI init [ 0.517755] system 00:00: [io 0x0680-0x069f] has been reserved [ 0.517758] system 00:00: [io 0x164e-0x164f] has been reserved [ 0.517907] system 00:01: [io 0x1854-0x1857] has been reserved [ 0.518008] system 00:03: [io 0x0200-0x027f] has been reserved [ 0.518010] system 00:03: [mem 0xfedf0000-0xfedfffff] has been reserved [ 0.518407] pnp 00:04: disabling [mem 0xc0000000-0xcfffffff] because it overlaps 0000:00:02.0 BAR 9 [mem 0x00000000-0xdfffffff 64bit pref] [ 0.518435] system 00:04: [mem 0xfedc0000-0xfedc7fff] has been reserved [ 0.518436] system 00:04: [mem 0xfeda0000-0xfeda0fff] has been reserved [ 0.518437] system 00:04: [mem 0xfeda1000-0xfeda1fff] has been reserved [ 0.518439] system 00:04: [mem 0xfed20000-0xfed7ffff] could not be reserved [ 0.518440] system 00:04: [mem 0xfed90000-0xfed93fff] could not be reserved [ 0.518441] system 00:04: [mem 0xfed45000-0xfed8ffff] could not be reserved [ 0.518442] system 00:04: [mem 0xfee00000-0xfeefffff] has been reserved [ 0.518787] system 00:05: [io 0x2000-0x20fe] has been reserved [ 0.519618] pnp: PnP ACPI: found 7 devices [ 0.525167] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns [ 0.525220] NET: Registered PF_INET protocol family [ 0.525414] IP idents hash table entries: 262144 (order: 9, 2097152 bytes, linear) [ 0.528130] tcp_listen_portaddr_hash hash table entries: 16384 (order: 6, 262144 bytes, linear) [ 0.528171] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.528349] TCP established hash table entries: 262144 (order: 9, 2097152 bytes, linear) [ 0.528706] TCP bind hash table entries: 65536 (order: 9, 2097152 bytes, linear) [ 0.528805] TCP: Hash tables configured (established 262144 bind 65536) [ 0.528963] MPTCP token hash table entries: 32768 (order: 7, 786432 bytes, linear) [ 0.529044] UDP hash table entries: 16384 (order: 7, 524288 bytes, linear) [ 0.529119] UDP-Lite hash table entries: 16384 (order: 7, 524288 bytes, linear) [ 0.529197] NET: Registered PF_UNIX/PF_LOCAL protocol family [ 0.529203] NET: Registered PF_XDP protocol family [ 0.529206] pci 0000:01:00.0: can't claim BAR 6 [mem 0xfff80000-0xffffffff pref]: no compatible bridge window [ 0.529212] pci_bus 0000:00: max bus depth: 3 pci_try_num: 4 [ 0.529226] pci 0000:00:02.0: BAR 9: assigned [mem 0x4020000000-0x40ffffffff 64bit pref] [ 0.529229] pci 0000:00:02.0: BAR 7: assigned [mem 0x4010000000-0x4016ffffff 64bit] [ 0.529231] pci 0000:00:15.0: BAR 0: assigned [mem 0x4017000000-0x4017000fff 64bit] [ 0.529287] pci 0000:00:15.1: BAR 0: assigned [mem 0x4017001000-0x4017001fff 64bit] [ 0.529301] pci 0000:00:15.2: BAR 0: assigned [mem 0x4017002000-0x4017002fff 64bit] [ 0.529314] pci 0000:00:19.0: BAR 0: assigned [mem 0x4017003000-0x4017003fff 64bit] [ 0.529328] pci 0000:00:19.2: BAR 0: assigned [mem 0x4017004000-0x4017004fff 64bit] [ 0.529383] pci 0000:00:1d.0: BAR 13: assigned [io 0x6000-0x8fff] [ 0.529385] pci 0000:00:1e.0: BAR 0: assigned [mem 0x4017005000-0x4017005fff 64bit] [ 0.529439] pci 0000:00:1e.2: BAR 0: assigned [mem 0x4017006000-0x4017006fff 64bit] [ 0.529453] pci 0000:00:1f.5: BAR 0: assigned [mem 0x54800000-0x54800fff] [ 0.529464] pci 0000:01:00.0: BAR 6: assigned [mem 0x88080000-0x880fffff pref] [ 0.529466] pci 0000:00:01.0: PCI bridge to [bus 01] [ 0.529467] pci 0000:00:01.0: bridge window [io 0x4000-0x4fff] [ 0.529470] pci 0000:00:01.0: bridge window [mem 0x87000000-0x880fffff] [ 0.529471] pci 0000:00:01.0: bridge window [mem 0x6000000000-0x6401ffffff 64bit pref] [ 0.529475] pci 0000:00:06.0: PCI bridge to [bus 02] [ 0.529480] pci 0000:00:06.0: bridge window [mem 0x88c00000-0x88cfffff] [ 0.529485] pci 0000:00:1b.0: PCI bridge to [bus 03] [ 0.529554] pci 0000:00:1b.0: bridge window [mem 0x88b00000-0x88bfffff] [ 0.529561] pci 0000:00:1c.0: PCI bridge to [bus 04] [ 0.529563] pci 0000:00:1c.0: bridge window [io 0x3000-0x3fff] [ 0.529566] pci 0000:00:1c.0: bridge window [mem 0x88100000-0x88afffff] [ 0.529569] pci 0000:00:1c.0: bridge window [mem 0x645c000000-0x645c9fffff 64bit pref] [ 0.529574] pci 0000:05:00.0: BAR 13: assigned [io 0x6000-0x7fff] [ 0.529576] pci 0000:06:01.0: BAR 13: assigned [io 0x6000-0x6fff] [ 0.529577] pci 0000:06:03.0: BAR 13: assigned [io 0x7000-0x7fff] [ 0.529578] pci 0000:06:00.0: PCI bridge to [bus 07] [ 0.529586] pci 0000:06:00.0: bridge window [mem 0x645a000000-0x645a0fffff 64bit pref] [ 0.529593] pci 0000:06:01.0: PCI bridge to [bus 08-3a] [ 0.529595] pci 0000:06:01.0: bridge window [io 0x6000-0x6fff] [ 0.529600] pci 0000:06:01.0: bridge window [mem 0x6f000000-0x85efffff] [ 0.529604] pci 0000:06:01.0: bridge window [mem 0x6435000000-0x6459ffffff 64bit pref] [ 0.529610] pci 0000:06:02.0: PCI bridge to [bus 3b] [ 0.529615] pci 0000:06:02.0: bridge window [mem 0x6ef00000-0x6effffff] [ 0.529625] pci 0000:06:03.0: PCI bridge to [bus 3c-6e] [ 0.529627] pci 0000:06:03.0: bridge window [io 0x7000-0x7fff] [ 0.529632] pci 0000:06:03.0: bridge window [mem 0x58000000-0x6eefffff] [ 0.529636] pci 0000:06:03.0: bridge window [mem 0x6410000000-0x6434ffffff 64bit pref] [ 0.529642] pci 0000:05:00.0: PCI bridge to [bus 06-6e] [ 0.529645] pci 0000:05:00.0: bridge window [io 0x6000-0x7fff] [ 0.529650] pci 0000:05:00.0: bridge window [mem 0x58000000-0x85efffff] [ 0.529653] pci 0000:05:00.0: bridge window [mem 0x6410000000-0x645a0fffff 64bit pref] [ 0.529660] pci 0000:00:1d.0: PCI bridge to [bus 05-6e] [ 0.529661] pci 0000:00:1d.0: bridge window [io 0x6000-0x8fff] [ 0.529665] pci 0000:00:1d.0: bridge window [mem 0x58000000-0x860fffff] [ 0.529668] pci 0000:00:1d.0: bridge window [mem 0x6410000000-0x645a0fffff 64bit pref] [ 0.529673] pci_bus 0000:00: resource 4 [io 0x0000-0x0cf7 window] [ 0.529674] pci_bus 0000:00: resource 5 [io 0x0d00-0xffff window] [ 0.529675] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff window] [ 0.529677] pci_bus 0000:00: resource 7 [mem 0x54800000-0xbfffffff window] [ 0.529678] pci_bus 0000:00: resource 8 [mem 0x4000000000-0x7fffffffff window] [ 0.529679] pci_bus 0000:01: resource 0 [io 0x4000-0x4fff] [ 0.529680] pci_bus 0000:01: resource 1 [mem 0x87000000-0x880fffff] [ 0.529681] pci_bus 0000:01: resource 2 [mem 0x6000000000-0x6401ffffff 64bit pref] [ 0.529682] pci_bus 0000:02: resource 1 [mem 0x88c00000-0x88cfffff] [ 0.529683] pci_bus 0000:03: resource 1 [mem 0x88b00000-0x88bfffff] [ 0.529684] pci_bus 0000:04: resource 0 [io 0x3000-0x3fff] [ 0.529685] pci_bus 0000:04: resource 1 [mem 0x88100000-0x88afffff] [ 0.529686] pci_bus 0000:04: resource 2 [mem 0x645c000000-0x645c9fffff 64bit pref] [ 0.529687] pci_bus 0000:05: resource 0 [io 0x6000-0x8fff] [ 0.529688] pci_bus 0000:05: resource 1 [mem 0x58000000-0x860fffff] [ 0.529688] pci_bus 0000:05: resource 2 [mem 0x6410000000-0x645a0fffff 64bit pref] [ 0.529690] pci_bus 0000:06: resource 0 [io 0x6000-0x7fff] [ 0.529690] pci_bus 0000:06: resource 1 [mem 0x58000000-0x85efffff] [ 0.529691] pci_bus 0000:06: resource 2 [mem 0x6410000000-0x645a0fffff 64bit pref] [ 0.529692] pci_bus 0000:07: resource 2 [mem 0x645a000000-0x645a0fffff 64bit pref] [ 0.529693] pci_bus 0000:08: resource 0 [io 0x6000-0x6fff] [ 0.529694] pci_bus 0000:08: resource 1 [mem 0x6f000000-0x85efffff] [ 0.529695] pci_bus 0000:08: resource 2 [mem 0x6435000000-0x6459ffffff 64bit pref] [ 0.529696] pci_bus 0000:3b: resource 1 [mem 0x6ef00000-0x6effffff] [ 0.529697] pci_bus 0000:3c: resource 0 [io 0x7000-0x7fff] [ 0.529698] pci_bus 0000:3c: resource 1 [mem 0x58000000-0x6eefffff] [ 0.529699] pci_bus 0000:3c: resource 2 [mem 0x6410000000-0x6434ffffff 64bit pref] [ 0.529835] pci 0000:00:14.0: enabling device (0000 -> 0002) [ 0.530376] pci 0000:01:00.1: extending delay after power-on from D3hot to 20 msec [ 0.530410] pci 0000:01:00.1: D0 power state depends on 0000:01:00.0 [ 0.531667] pci 0000:3b:00.0: enabling device (0000 -> 0002) [ 0.531703] PCI: CLS 0 bytes, default 64 [ 0.531711] DMAR: Intel-IOMMU force enabled due to platform opt in [ 0.531721] DMAR: No ATSR found [ 0.531722] DMAR: No SATC found [ 0.531723] DMAR: IOMMU feature fl1gp_support inconsistent [ 0.531724] DMAR: IOMMU feature pgsel_inv inconsistent [ 0.531724] DMAR: IOMMU feature nwfs inconsistent [ 0.531725] DMAR: IOMMU feature dit inconsistent [ 0.531725] DMAR: IOMMU feature sc_support inconsistent [ 0.531726] DMAR: IOMMU feature dev_iotlb_support inconsistent [ 0.531726] DMAR: dmar0: Using Queued invalidation [ 0.531729] DMAR: dmar1: Using Queued invalidation [ 0.531789] Trying to unpack rootfs image as initramfs... [ 0.532526] pci 0000:00:02.0: Adding to iommu group 0 [ 0.532565] pci 0000:00:00.0: Adding to iommu group 1 [ 0.532576] pci 0000:00:01.0: Adding to iommu group 2 [ 0.532585] pci 0000:00:04.0: Adding to iommu group 3 [ 0.532600] pci 0000:00:06.0: Adding to iommu group 4 [ 0.532608] pci 0000:00:08.0: Adding to iommu group 5 [ 0.532617] pci 0000:00:0a.0: Adding to iommu group 6 [ 0.532630] pci 0000:00:12.0: Adding to iommu group 7 [ 0.532650] pci 0000:00:14.0: Adding to iommu group 8 [ 0.532659] pci 0000:00:14.2: Adding to iommu group 8 [ 0.532668] pci 0000:00:14.3: Adding to iommu group 9 [ 0.532690] pci 0000:00:15.0: Adding to iommu group 10 [ 0.532700] pci 0000:00:15.1: Adding to iommu group 10 [ 0.532708] pci 0000:00:15.2: Adding to iommu group 10 [ 0.532727] pci 0000:00:16.0: Adding to iommu group 11 [ 0.532736] pci 0000:00:16.3: Adding to iommu group 11 [ 0.532754] pci 0000:00:19.0: Adding to iommu group 12 [ 0.532763] pci 0000:00:19.2: Adding to iommu group 12 [ 0.532780] pci 0000:00:1b.0: Adding to iommu group 13 [ 0.532802] pci 0000:00:1c.0: Adding to iommu group 14 [ 0.532812] pci 0000:00:1d.0: Adding to iommu group 15 [ 0.532830] pci 0000:00:1e.0: Adding to iommu group 16 [ 0.532840] pci 0000:00:1e.2: Adding to iommu group 16 [ 0.532872] pci 0000:00:1f.0: Adding to iommu group 17 [ 0.532882] pci 0000:00:1f.3: Adding to iommu group 17 [ 0.532892] pci 0000:00:1f.4: Adding to iommu group 17 [ 0.532902] pci 0000:00:1f.5: Adding to iommu group 17 [ 0.532912] pci 0000:00:1f.6: Adding to iommu group 17 [ 0.532930] pci 0000:01:00.0: Adding to iommu group 18 [ 0.532941] pci 0000:01:00.1: Adding to iommu group 18 [ 0.532955] pci 0000:02:00.0: Adding to iommu group 19 [ 0.532972] pci 0000:03:00.0: Adding to iommu group 20 [ 0.532982] pci 0000:04:00.0: Adding to iommu group 21 [ 0.532992] pci 0000:05:00.0: Adding to iommu group 22 [ 0.533011] pci 0000:06:00.0: Adding to iommu group 23 [ 0.533022] pci 0000:06:01.0: Adding to iommu group 24 [ 0.533040] pci 0000:06:02.0: Adding to iommu group 25 [ 0.533050] pci 0000:06:03.0: Adding to iommu group 26 [ 0.533072] pci 0000:07:00.0: Adding to iommu group 27 [ 0.533086] pci 0000:3b:00.0: Adding to iommu group 28 [ 0.534362] DMAR: Intel(R) Virtualization Technology for Directed I/O [ 0.534364] PCI-DMA: Using software bounce buffering for IO (SWIOTLB) [ 0.534365] software IO TLB: mapped [mem 0x000000001f8de000-0x00000000238de000] (64MB) [ 0.538769] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x22df1149949, max_idle_ns: 440795312789 ns [ 0.538873] clocksource: Switched to clocksource tsc [ 0.538893] platform rtc_cmos: registered platform RTC device (no PNP device found) [ 0.543156] Initialise system trusted keyrings [ 0.543163] Key type blacklist registered [ 0.543245] workingset: timestamp_bits=36 max_order=23 bucket_order=0 [ 0.543250] zbud: loaded [ 0.543426] squashfs: version 4.0 (2009/01/31) Phillip Lougher [ 0.543483] fuse: init (API version 7.39) [ 0.543596] integrity: Platform Keyring initialized [ 0.543599] integrity: Machine keyring initialized [ 0.552373] Key type asymmetric registered [ 0.552375] Asymmetric key parser 'x509' registered [ 0.552387] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 243) [ 0.552446] io scheduler mq-deadline registered [ 0.554675] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4 [ 0.554724] efifb: probing for efifb [ 0.554739] efifb: showing boot graphics [ 0.556197] efifb: framebuffer at 0x4000000000, using 9000k, total 9000k [ 0.556199] efifb: mode is 1920x1200x32, linelength=7680, pages=1 [ 0.556200] efifb: scrolling: redraw [ 0.556200] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0 [ 0.556232] fbcon: Deferring console take-over [ 0.556233] fb0: EFI VGA frame buffer device [ 0.557443] ACPI: AC: AC Adapter [AC] (on-line) [ 0.557487] input: Sleep Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0E:00/input/input0 [ 0.557501] ACPI: button: Sleep Button [SLPB] [ 0.557521] input: Lid Switch as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/input/input1 [ 0.557533] ACPI: button: Lid Switch [LID] [ 0.557555] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input2 [ 0.557592] ACPI: button: Power Button [PWRF] [ 0.569515] thermal LNXTHERM:00: registered as thermal_zone0 [ 0.569519] ACPI: thermal: Thermal Zone [CPUZ] (46 C) [ 0.576461] thermal LNXTHERM:01: registered as thermal_zone1 [ 0.576464] ACPI: thermal: Thermal Zone [GFXZ] (25 C) [ 0.580600] thermal LNXTHERM:02: registered as thermal_zone2 [ 0.580604] ACPI: thermal: Thermal Zone [EXTZ] (42 C) [ 0.584815] thermal LNXTHERM:03: registered as thermal_zone3 [ 0.584817] ACPI: thermal: Thermal Zone [LOCZ] (37 C) [ 0.591929] thermal LNXTHERM:04: registered as thermal_zone4 [ 0.591932] ACPI: thermal: Thermal Zone [BATZ] (24 C) [ 0.596316] thermal LNXTHERM:05: registered as thermal_zone5 [ 0.596319] ACPI: thermal: Thermal Zone [CHGZ] (30 C) [ 0.600681] thermal LNXTHERM:06: registered as thermal_zone6 [ 0.600684] ACPI: thermal: Thermal Zone [SK1Z] (30 C) [ 0.604841] thermal LNXTHERM:07: registered as thermal_zone7 [ 0.604843] ACPI: thermal: Thermal Zone [SK2Z] (28 C) [ 0.609099] thermal LNXTHERM:08: registered as thermal_zone8 [ 0.609101] ACPI: thermal: Thermal Zone [PCHZ] (0 C) [ 0.609354] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled [ 0.611263] serial 0000:00:12.0: enabling device (0000 -> 0002) [ 0.611537] serial 0000:00:16.3: enabling device (0000 -> 0003) [ 0.632362] 0000:00:16.3: ttyS4 at I/O 0x5060 (irq = 19, base_baud = 115200) is a 16550A [ 0.632706] hpet_acpi_add: no address or irqs in _CRS [ 0.632727] Linux agpgart interface v0.103 [ 0.634469] tpm_tis IFX1521:00: 2.0 TPM (device-id 0x1D, rev-id 54) [ 0.641077] ACPI: battery: Slot [BAT0] (battery present) [ 0.784667] loop: module loaded [ 0.784945] tun: Universal TUN/TAP device driver, 1.6 [ 0.785001] PPP generic driver version 2.4.2 [ 0.785102] i8042: PNP: PS/2 Controller [PNP0303:PS2K] at 0x60,0x64 irq 1 [ 0.785104] i8042: PNP: PS/2 appears to have AUX port disabled, if this is incorrect please boot with i8042.nopnp [ 0.785661] serio: i8042 KBD port at 0x60,0x64 irq 1 [ 0.785740] mousedev: PS/2 mouse device common for all mice [ 0.785830] rtc_cmos rtc_cmos: RTC can wake from S4 [ 0.786725] rtc_cmos rtc_cmos: registered as rtc0 [ 0.786910] rtc_cmos rtc_cmos: setting system clock to 2023-11-21T17:31:32 UTC (1700587892) [ 0.786939] rtc_cmos rtc_cmos: alarms up to one month, y3k, 114 bytes nvram [ 0.786948] i2c_dev: i2c /dev entries driver [ 0.788847] device-mapper: core: CONFIG_IMA_DISABLE_HTABLE is disabled. Duplicate IMA measurements will not be recorded in the IMA log. [ 0.788858] device-mapper: uevent: version 1.0.3 [ 0.788894] device-mapper: ioctl: 4.48.0-ioctl (2023-03-01) initialised: [email protected] [ 0.788912] platform eisa.0: Probing EISA bus 0 [ 0.788914] platform eisa.0: EISA: Cannot allocate resource for mainboard [ 0.788915] platform eisa.0: Cannot allocate resource for EISA slot 1 [ 0.788916] platform eisa.0: Cannot allocate resource for EISA slot 2 [ 0.788917] platform eisa.0: Cannot allocate resource for EISA slot 3 [ 0.788917] platform eisa.0: Cannot allocate resource for EISA slot 4 [ 0.788918] platform eisa.0: Cannot allocate resource for EISA slot 5 [ 0.788919] platform eisa.0: Cannot allocate resource for EISA slot 6 [ 0.788920] platform eisa.0: Cannot allocate resource for EISA slot 7 [ 0.788920] platform eisa.0: Cannot allocate resource for EISA slot 8 [ 0.788921] platform eisa.0: EISA: Detected 0 cards [ 0.788924] intel_pstate: Intel P-state driver initializing [ 0.791276] intel_pstate: HWP enabled [ 0.796606] Freeing initrd memory: 69584K [ 0.796945] ledtrig-cpu: registered to indicate activity on CPUs [ 0.797159] drop_monitor: Initializing network drop monitor service [ 0.797251] NET: Registered PF_INET6 protocol family [ 0.802001] Segment Routing with IPv6 [ 0.802007] In-situ OAM (IOAM) with IPv6 [ 0.802027] NET: Registered PF_PACKET protocol family [ 0.802097] Key type dns_resolver registered [ 0.805587] microcode: Microcode Update Driver: v2.2. [ 0.805605] IPI shorthand broadcast: enabled [ 0.806434] sched_clock: Marking stable (800000795, 6343187)->(902752630, -96408648) [ 0.806976] registered taskstats version 1 [ 0.810155] Loading compiled-in X.509 certificates [ 0.810596] Loaded X.509 cert 'Build time autogenerated kernel key: 6d7be3ee82ad92e828a425da7de4a03b7ee58532' [ 0.811576] Key type .fscrypt registered [ 0.811577] Key type fscrypt-provisioning registered [ 0.811603] Key type trusted registered [ 0.812561] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input3 [ 0.825911] Key type encrypted registered [ 0.825917] AppArmor: AppArmor sha1 policy hashing enabled [ 0.825962] integrity: Loading X.509 certificate: UEFI:db [ 0.825999] integrity: Loaded X.509 cert 'HP Inc.: HP UEFI Secure Boot DB 2017: d9c01b50cfcae89d3b05345c163aa76e5dd589e7' [ 0.826000] integrity: Loading X.509 certificate: UEFI:db [ 0.826028] integrity: Loaded X.509 cert 'Microsoft Windows Production PCA 2011: a92902398e16c49778cd90f99e4f9ae17c55af53' [ 0.826029] integrity: Loading X.509 certificate: UEFI:db [ 0.826053] integrity: Loaded X.509 cert 'Microsoft Corporation UEFI CA 2011: 13adbf4309bd82709c8cd54f316ed522988a1bd4' [ 0.827329] Loading compiled-in module X.509 certificates [ 0.827972] Loaded X.509 cert 'Build time autogenerated kernel key: 6d7be3ee82ad92e828a425da7de4a03b7ee58532' [ 0.827974] ima: Allocated hash algorithm: sha1 [ 0.850824] ima: No architecture policies found [ 0.850860] evm: Initialising EVM extended attributes: [ 0.850861] evm: security.selinux [ 0.850864] evm: security.SMACK64 [ 0.850866] evm: security.SMACK64EXEC [ 0.850867] evm: security.SMACK64TRANSMUTE [ 0.850868] evm: security.SMACK64MMAP [ 0.850869] evm: security.apparmor [ 0.850871] evm: security.ima [ 0.850872] evm: security.capability [ 0.850873] evm: HMAC attrs: 0x1 [ 0.851684] PM: Magic number: 15:889:542 [ 0.851764] platform INTC1046:01: hash matches [ 0.851820] acpi INTC1046:01: hash matches [ 0.852329] RAS: Correctable Errors collector initialized. [ 0.852420] clk: Disabling unused clocks [ 0.861050] Freeing unused decrypted memory: 2028K [ 0.861900] Freeing unused kernel image (initmem) memory: 4712K [ 0.891004] Write protecting the kernel read-only data: 28672k [ 0.892167] Freeing unused kernel image (rodata/data gap) memory: 816K [ 0.909588] x86/mm: Checked W+X mappings: passed, no W+X pages found. [ 0.909593] Run /init as init process [ 0.909594] with arguments: [ 0.909595] /init [ 0.909596] splash [ 0.909597] with environment: [ 0.909597] HOME=/ [ 0.909598] TERM=linux [ 0.909599] BOOT_IMAGE=/boot/vmlinuz-6.7.0-rc1-next-20231115+ [ 0.995542] wmi_bus wmi_bus-PNP0C14:02: WQZZ data block query control method not found [ 0.997744] hid: raw HID events driver (C) Jiri Kosina [ 1.002671] xhci_hcd 0000:00:14.0: xHCI Host Controller [ 1.002683] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 1 [ 1.003783] xhci_hcd 0000:00:14.0: hcc params 0x20007fc1 hci version 0x120 quirks 0x0000000200009810 [ 1.004145] xhci_hcd 0000:00:14.0: xHCI Host Controller [ 1.004149] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 2 [ 1.004152] xhci_hcd 0000:00:14.0: Host supports USB 3.2 Enhanced SuperSpeed [ 1.004271] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.07 [ 1.004274] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1.004275] usb usb1: Product: xHCI Host Controller [ 1.004276] usb usb1: Manufacturer: Linux 6.7.0-rc1-next-20231115+ xhci-hcd [ 1.004277] usb usb1: SerialNumber: 0000:00:14.0 [ 1.004516] hub 1-0:1.0: USB hub found [ 1.004550] hub 1-0:1.0: 16 ports detected [ 1.004948] rtsx_pci 0000:04:00.0: enabling device (0000 -> 0002) [ 1.007016] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.07 [ 1.007018] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1.007019] usb usb2: Product: xHCI Host Controller [ 1.007020] usb usb2: Manufacturer: Linux 6.7.0-rc1-next-20231115+ xhci-hcd [ 1.007021] usb usb2: SerialNumber: 0000:00:14.0 [ 1.007117] hub 2-0:1.0: USB hub found [ 1.007137] hub 2-0:1.0: 10 ports detected [ 1.007580] usb: port power management may be unreliable [ 1.008596] xhci_hcd 0000:3b:00.0: xHCI Host Controller [ 1.008599] xhci_hcd 0000:3b:00.0: new USB bus registered, assigned bus number 3 [ 1.009768] xhci_hcd 0000:3b:00.0: hcc params 0x20007fc1 hci version 0x110 quirks 0x0000000200009810 [ 1.010050] xhci_hcd 0000:3b:00.0: xHCI Host Controller [ 1.010052] xhci_hcd 0000:3b:00.0: new USB bus registered, assigned bus number 4 [ 1.010053] xhci_hcd 0000:3b:00.0: Host supports USB 3.1 Enhanced SuperSpeed [ 1.010074] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.07 [ 1.010076] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1.010077] usb usb3: Product: xHCI Host Controller [ 1.010078] usb usb3: Manufacturer: Linux 6.7.0-rc1-next-20231115+ xhci-hcd [ 1.010078] usb usb3: SerialNumber: 0000:3b:00.0 [ 1.010181] hub 3-0:1.0: USB hub found [ 1.010202] hub 3-0:1.0: 2 ports detected [ 1.010661] usb usb4: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.07 [ 1.010664] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1.010665] usb usb4: Product: xHCI Host Controller [ 1.010666] usb usb4: Manufacturer: Linux 6.7.0-rc1-next-20231115+ xhci-hcd [ 1.010666] usb usb4: SerialNumber: 0000:3b:00.0 [ 1.010788] hub 4-0:1.0: USB hub found [ 1.010811] hub 4-0:1.0: 2 ports detected [ 1.012947] ACPI: bus type drm_connector registered [ 1.016886] ACPI: bus type thunderbolt registered [ 1.016967] thunderbolt 0000:07:00.0: enabling device (0000 -> 0002) [ 1.019087] e1000e: Intel(R) PRO/1000 Network Driver [ 1.019089] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 1.019124] e1000e 0000:00:1f.6: enabling device (0000 -> 0002) [ 1.019295] i801_smbus 0000:00:1f.4: enabling device (0000 -> 0003) [ 1.019327] __spi_add_device() [664] CS[0] = [0] [ 1.019329] __spi_add_device() [667] CS_NEW[1] = [0] [ 1.019330] intel-spi 0000:00:1f.5: chipselect 0 already in use [ 1.019334] fbcon: Taking over console [ 1.019339] nvme 0000:02:00.0: platform quirk: setting simple suspend [ 1.019339] e1000e 0000:00:1f.6: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 1.019383] nvme 0000:03:00.0: platform quirk: setting simple suspend [ 1.019441] i801_smbus 0000:00:1f.4: SPD Write Disable is set [ 1.019474] Console: switching to colour frame buffer device 240x75 [ 1.019484] i801_smbus 0000:00:1f.4: SMBus using PCI interrupt [ 1.019568] nvme nvme0: pci function 0000:02:00.0 [ 1.019621] nvme nvme1: pci function 0000:03:00.0 [ 1.020682] i2c i2c-0: 2/4 memory slots populated (from DMI) [ 1.020685] i2c i2c-0: Memory type 0x22 not supported yet, not instantiating SPD [ 1.029171] intel-lpss 0000:00:15.0: enabling device (0000 -> 0002) [ 1.029462] idma64 idma64.0: Found Intel integrated DMA 64-bit [ 1.032649] nvme nvme0: Shutdown timeout set to 10 seconds [ 1.037214] nvme nvme0: 24/0/0 default/read/poll queues [ 1.040011] nvme0n1: p1 p2 p3 [ 1.045310] intel-lpss 0000:00:15.1: enabling device (0000 -> 0002) [ 1.045552] idma64 idma64.1: Found Intel integrated DMA 64-bit [ 1.054023] nvme nvme1: 24/0/0 default/read/poll queues [ 1.058687] nvme1n1: p1 p2 p3 [ 1.061973] intel-lpss 0000:00:15.2: enabling device (0000 -> 0002) [ 1.062517] idma64 idma64.2: Found Intel integrated DMA 64-bit [ 1.082429] intel-lpss 0000:00:19.0: enabling device (0000 -> 0002) [ 1.083424] idma64 idma64.3: Found Intel integrated DMA 64-bit [ 1.096937] e1000e 0000:00:1f.6 0000:00:1f.6 (uninitialized): registered PHC clock [ 1.105236] intel-lpss 0000:00:19.2: enabling device (0000 -> 0002) [ 1.105809] idma64 idma64.4: Found Intel integrated DMA 64-bit [ 1.118446] intel-lpss 0000:00:1e.0: enabling device (0000 -> 0002) [ 1.119257] idma64 idma64.5: Found Intel integrated DMA 64-bit [ 1.131374] intel-lpss 0000:00:1e.2: enabling device (0000 -> 0002) [ 1.132481] idma64 idma64.6: Found Intel integrated DMA 64-bit [ 1.169673] e1000e 0000:00:1f.6 eth0: (PCI Express:2.5GT/s:Width x1) 38:ca:84:d5:b2:4f [ 1.169678] e1000e 0000:00:1f.6 eth0: Intel(R) PRO/1000 Network Connection [ 1.169790] e1000e 0000:00:1f.6 eth0: MAC: 15, PHY: 12, PBA No: FFFFFF-0FF [ 1.266471] usb 1-8: new high-speed USB device number 2 using xhci_hcd [ 1.324380] i2c_hid_acpi i2c-ELAN2513:00: i2c_hid_get_input: IRQ triggered but there's no data [ 1.325374] input: SYNA30F7:00 06CB:CEC3 Mouse as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-1/i2c-SYNA30F7:00/0018:06CB:CEC3.0001/input/input4 [ 1.325502] input: SYNA30F7:00 06CB:CEC3 Touchpad as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-1/i2c-SYNA30F7:00/0018:06CB:CEC3.0001/input/input5 [ 1.325560] hid-generic 0018:06CB:CEC3.0001: input,hidraw0: I2C HID v1.00 Mouse [SYNA30F7:00 06CB:CEC3] on i2c-SYNA30F7:00 [ 1.325733] input: ELAN2513:00 04F3:2FE0 Touchscreen as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/i2c-ELAN2513:00/0018:04F3:2FE0.0002/input/input7 [ 1.325762] input: ELAN2513:00 04F3:2FE0 as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/i2c-ELAN2513:00/0018:04F3:2FE0.0002/input/input8 [ 1.325786] input: ELAN2513:00 04F3:2FE0 as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/i2c-ELAN2513:00/0018:04F3:2FE0.0002/input/input9 [ 1.325832] hid-generic 0018:04F3:2FE0.0002: input,hidraw1: I2C HID v1.00 Device [ELAN2513:00 04F3:2FE0] on i2c-ELAN2513:00 [ 1.342516] e1000e 0000:00:1f.6 enp0s31f6: renamed from eth0 [ 1.493687] usb 1-8: New USB device found, idVendor=0408, idProduct=545b, bcdDevice= 0.06 [ 1.493703] usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1.493709] usb 1-8: Product: HP 5MP Camera [ 1.493713] usb 1-8: Manufacturer: Quanta [ 1.493717] usb 1-8: SerialNumber: 01.00.00 [ 1.638535] usb 1-14: new full-speed USB device number 3 using xhci_hcd [ 1.695360] ish-hid {33AECD58-B679-4E54-9BD9-A04D34F0C226}: [hid-ish]: enum_devices_done OK, num_hid_devices=2 [ 1.708381] hid-generic 001F:8087:0AC2.0003: hidraw2: SENSOR HUB HID v2.00 Device [hid-ishtp 8087:0AC2] on [ 1.716122] hid-generic 001F:8087:0AC3.0004: hidraw3: SENSOR HUB HID v2.00 Device [hid-ishtp 8087:0AC3] on [ 1.720506] hid-sensor-hub 001F:8087:0AC2.0003: hidraw2: SENSOR HUB HID v2.00 Device [hid-ishtp 8087:0AC2] on [ 1.722175] hid-sensor-hub 001F:8087:0AC3.0004: hidraw3: SENSOR HUB HID v2.00 Device [hid-ishtp 8087:0AC3] on [ 1.789094] usb 1-14: New USB device found, idVendor=8087, idProduct=0033, bcdDevice= 0.00 [ 1.789110] usb 1-14: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 1.890344] raid6: avx2x4 gen() 35214 MB/s [ 1.958344] raid6: avx2x2 gen() 38373 MB/s [ 2.026344] raid6: avx2x1 gen() 35654 MB/s [ 2.026344] raid6: using algorithm avx2x2 gen() 38373 MB/s [ 2.094344] raid6: .... xor() 24914 MB/s, rmw enabled [ 2.094345] raid6: using avx2x2 recovery algorithm [ 2.095866] xor: automatically using best checksumming function avx [ 2.096777] async_tx: api initialized (async) [ 2.161736] Btrfs loaded, zoned=yes, fsverity=yes [ 2.248664] EXT4-fs (nvme0n1p3): mounted filesystem 061502a9-205e-4b73-8251-1220e770c5d8 ro with ordered data mode. Quota mode: none. [ 2.326932] systemd[1]: Inserted module 'autofs4' [ 2.340701] systemd[1]: systemd 249.11-0ubuntu3.9 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified) [ 2.340779] systemd[1]: Detected architecture x86-64. [ 2.340981] systemd[1]: Hostname set to <u-HP-ZBook-Fury-16-G9-Mobile-Workstation-PC>. [ 2.398743] block nvme0n1: the capability attribute has been deprecated. [ 2.477456] systemd[1]: Queued start job for default target Graphical Interface. [ 2.508096] systemd[1]: Created slice Slice /system/modprobe. [ 2.508852] systemd[1]: Created slice Slice /system/systemd-fsck. [ 2.509177] systemd[1]: Created slice User and Session Slice. [ 2.509303] systemd[1]: Started Forward Password Requests to Wall Directory Watch. [ 2.509638] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point. [ 2.509752] systemd[1]: Reached target User and Group Name Lookups. [ 2.509781] systemd[1]: Reached target Remote File Systems. [ 2.509800] systemd[1]: Reached target Slice Units. [ 2.509831] systemd[1]: Reached target Mounting snaps. [ 2.509881] systemd[1]: Reached target Local Verity Protected Volumes. [ 2.510018] systemd[1]: Listening on Device-mapper event daemon FIFOs. [ 2.510201] systemd[1]: Listening on LVM2 poll daemon socket. [ 2.510321] systemd[1]: Listening on Syslog Socket. [ 2.510445] systemd[1]: Listening on fsck to fsckd communication Socket. [ 2.510504] systemd[1]: Listening on initctl Compatibility Named Pipe. [ 2.510754] systemd[1]: Listening on Journal Audit Socket. [ 2.510851] systemd[1]: Listening on Journal Socket (/dev/log). [ 2.510983] systemd[1]: Listening on Journal Socket. [ 2.511253] systemd[1]: Listening on udev Control Socket. [ 2.511347] systemd[1]: Listening on udev Kernel Socket. [ 2.512429] systemd[1]: Mounting Huge Pages File System... [ 2.513492] systemd[1]: Mounting POSIX Message Queue File System... [ 2.514673] systemd[1]: Mounting Kernel Debug File System... [ 2.515596] systemd[1]: Mounting Kernel Trace File System... [ 2.517730] systemd[1]: Starting Journal Service... [ 2.517905] systemd[1]: Finished Availability of block devices. [ 2.518887] systemd[1]: Starting Set the console keyboard layout... [ 2.519749] systemd[1]: Starting Create List of Static Device Nodes... [ 2.520414] systemd[1]: Starting Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling... [ 2.521054] systemd[1]: Starting Load Kernel Module chromeos_pstore... [ 2.521661] systemd[1]: Starting Load Kernel Module configfs... [ 2.522235] systemd[1]: Starting Load Kernel Module drm... [ 2.522835] systemd[1]: Starting Load Kernel Module efi_pstore... [ 2.523366] systemd[1]: Starting Load Kernel Module fuse... [ 2.524133] systemd[1]: Starting Load Kernel Module pstore_blk... [ 2.525228] systemd[1]: Starting Load Kernel Module pstore_zone... [ 2.525603] systemd[1]: Starting Load Kernel Module ramoops... [ 2.526481] systemd[1]: Starting Load Kernel Modules... [ 2.526717] pstore: Using crash dump compression: deflate [ 2.526975] systemd[1]: Starting Remount Root and Kernel File Systems... [ 2.527376] systemd[1]: Starting Coldplug All udev Devices... [ 2.528074] systemd[1]: Mounted Huge Pages File System. [ 2.528112] systemd[1]: Mounted POSIX Message Queue File System. [ 2.528136] systemd[1]: Mounted Kernel Debug File System. [ 2.528157] systemd[1]: Mounted Kernel Trace File System. [ 2.528283] systemd[1]: Finished Create List of Static Device Nodes. [ 2.528373] systemd[1]: [email protected]: Deactivated successfully. [ 2.528469] systemd[1]: Finished Load Kernel Module configfs. [ 2.528574] systemd[1]: [email protected]: Deactivated successfully. [ 2.528692] systemd[1]: Finished Load Kernel Module drm. [ 2.528786] systemd[1]: [email protected]: Deactivated successfully. [ 2.528879] systemd[1]: Finished Load Kernel Module fuse. [ 2.528955] systemd[1]: modprobe@pstore_blk.service: Deactivated successfully. [ 2.529015] pstore: Registered efi_pstore as persistent store backend [ 2.529050] systemd[1]: Finished Load Kernel Module pstore_blk. [ 2.529124] systemd[1]: modprobe@pstore_zone.service: Deactivated successfully. [ 2.529212] systemd[1]: Finished Load Kernel Module pstore_zone. [ 2.529285] systemd[1]: modprobe@efi_pstore.service: Deactivated successfully. [ 2.529452] systemd[1]: Finished Load Kernel Module efi_pstore. [ 2.529652] systemd[1]: [email protected]: Deactivated successfully. [ 2.529882] systemd[1]: Finished Load Kernel Module ramoops. [ 2.530651] systemd[1]: Mounting FUSE Control File System... [ 2.531020] systemd[1]: Mounting Kernel Configuration File System... [ 2.531967] systemd[1]: Mounted FUSE Control File System. [ 2.532245] systemd[1]: Mounted Kernel Configuration File System. [ 2.534239] lp: driver loaded but no devices found [ 2.536191] ppdev: user-space parallel port driver [ 2.537747] parport0: PC-style at 0x278 [PCSPP,EPP] [ 2.548944] systemd[1]: Started Journal Service. [ 2.558697] EXT4-fs (nvme0n1p3): re-mounted 061502a9-205e-4b73-8251-1220e770c5d8 r/w. Quota mode: none. [ 2.562610] systemd-journald[460]: Received client request to flush runtime journal. [ 2.570309] Adding 51783676k swap on /swapfile. Priority:-2 extents:116 across:486625016k SS [ 2.605316] loop0: detected capacity change from 0 to 8 [ 2.605574] loop1: detected capacity change from 0 to 151352 [ 2.606188] loop2: detected capacity change from 0 to 489008 [ 2.606709] loop3: detected capacity change from 0 to 492168 [ 2.607206] loop4: detected capacity change from 0 to 994336 [ 2.607787] loop5: detected capacity change from 0 to 1017816 [ 2.608263] loop6: detected capacity change from 0 to 187776 [ 2.609008] loop7: detected capacity change from 0 to 25240 [ 2.610092] loop8: detected capacity change from 0 to 83648 [ 2.610559] loop9: detected capacity change from 0 to 83672 [ 2.611133] loop10: detected capacity change from 0 to 904 [ 2.644214] lp0: using parport0 (polling). [ 2.645779] input: Intel HID events as /devices/platform/INTC1070:00/input/input11 [ 2.646076] intel-hid INTC1070:00: platform supports 5 button array [ 2.646103] input: Intel HID 5 button array as /devices/platform/INTC1070:00/input/input12 [ 2.651830] Consider using thermal netlink events interface [ 2.681111] __spi_add_device() [664] CS[0] = [0] [ 2.681118] __spi_add_device() [667] CS_NEW[1] = [0] [ 2.681122] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use [ 2.681163] spi_master spi0: error -EBUSY: failed to add SPI device CSC3551:00 from ACPI [ 2.681882] Serial bus multi instantiate pseudo device driver: probe of CSC3551:00 failed with error -16 [ 2.731360] mc: Linux media interface: v0.10 [ 2.742333] hp_wmi: query 0x4 returned error 0x5 [ 2.743004] dw-apb-uart.4: ttyS5 at MMIO 0x4017004000 (irq = 42, base_baud = 6250000) is a 16550A [ 2.756380] cfg80211: Loading compiled-in X.509 certificates for regulatory database [ 2.756591] Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7' [ 2.757031] mei_me 0000:00:16.0: enabling device (0000 -> 0002) [ 2.757187] intel_rapl_msr: PL4 support detected. [ 2.759023] intel_rapl_common: Found RAPL domain package [ 2.759029] intel_rapl_common: Found RAPL domain core [ 2.759031] RAPL PMU: API unit is 2^-32 Joules, 4 fixed counters, 655360 ms ovfl timer [ 2.759032] intel_rapl_common: Found RAPL domain uncore [ 2.759033] RAPL PMU: hw unit of domain pp0-core 2^-14 Joules [ 2.759034] RAPL PMU: hw unit of domain package 2^-14 Joules [ 2.759034] RAPL PMU: hw unit of domain pp1-gpu 2^-14 Joules [ 2.759035] RAPL PMU: hw unit of domain psys 2^-14 Joules [ 2.759035] intel_rapl_common: Found RAPL domain psys [ 2.759455] input: HP WMI hotkeys as /devices/virtual/input/input13 [ 2.761545] dw-apb-uart.5: ttyS6 at MMIO 0x4017005000 (irq = 16, base_baud = 6250000) is a 16550A [ 2.767378] cryptd: max_cpu_qlen set to 1000 [ 2.771724] hid_sensor_als HID-SENSOR-200041.4.auto: failed to setup attributes [ 2.771727] hid_sensor_als: probe of HID-SENSOR-200041.4.auto failed with error -1 [ 2.776216] videodev: Linux video capture interface: v2.00 [ 2.778639] proc_thermal_pci 0000:00:04.0: enabling device (0000 -> 0002) [ 2.778984] AVX2 version of gcm_enc/dec engaged. [ 2.779015] intel_rapl_common: Found RAPL domain package [ 2.779087] AES CTR mode by8 optimization enabled [ 2.780889] Intel(R) Wireless WiFi driver for Linux [ 2.780969] iwlwifi 0000:00:14.3: enabling device (0000 -> 0002) [ 2.783194] iwlwifi 0000:00:14.3: Detected crf-id 0x400410, cnv-id 0x80401 wfpm id 0x80000020 [ 2.783220] iwlwifi 0000:00:14.3: PCI dev 7af0/0090, rev=0x430, rfid=0x2010d000 [ 2.786378] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-86.ucode failed with error -2 [ 2.786551] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-85.ucode failed with error -2 [ 2.786662] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-84.ucode failed with error -2 [ 2.786680] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-83.ucode failed with error -2 [ 2.786696] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-82.ucode failed with error -2 [ 2.786712] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-81.ucode failed with error -2 [ 2.786729] iwlwifi 0000:00:14.3: Direct firmware load for iwlwifi-so-a0-gf-a0-80.ucode failed with error -2 [ 2.792821] iwlwifi 0000:00:14.3: api flags index 2 larger than supported by driver [ 2.792832] iwlwifi 0000:00:14.3: TLV_FW_FSEQ_VERSION: FSEQ Version: 0.0.2.41 [ 2.793094] iwlwifi 0000:00:14.3: loaded firmware version 79.27f1c37b.0 so-a0-gf-a0-79.ucode op_mode iwlmvm [ 2.794047] Bluetooth: Core ver 2.22 [ 2.794063] NET: Registered PF_BLUETOOTH protocol family [ 2.794064] Bluetooth: HCI device and connection manager initialized [ 2.794067] Bluetooth: HCI socket layer initialized [ 2.794068] Bluetooth: L2CAP socket layer initialized [ 2.794071] Bluetooth: SCO socket layer initialized [ 2.801513] usbcore: registered new interface driver btusb [ 2.803103] Bluetooth: hci0: Device revision is 0 [ 2.803107] Bluetooth: hci0: Secure boot is enabled [ 2.803108] Bluetooth: hci0: OTP lock is enabled [ 2.803109] Bluetooth: hci0: API lock is enabled [ 2.803110] Bluetooth: hci0: Debug lock is disabled [ 2.803111] Bluetooth: hci0: Minimum firmware build 1 week 10 2014 [ 2.803112] Bluetooth: hci0: Bootloader timestamp 2019.40 buildtype 1 build 38 [ 2.803164] ACPI Warning: \_SB.PC00.XHCI.RHUB.HS14._DSM: Argument #4 type mismatch - Found [Integer], ACPI requires [Package] (20230628/nsarguments-61) [ 2.803288] Bluetooth: hci0: DSM reset method type: 0x00 [ 2.804409] usb 1-8: Found UVC 1.50 device HP 5MP Camera (0408:545b) [ 2.804545] Bluetooth: hci0: Found device firmware: intel/ibt-1040-0041.sfi [ 2.804554] Bluetooth: hci0: Boot Address: 0x100800 [ 2.804555] Bluetooth: hci0: Firmware Version: 107-51.22 [ 2.813005] audit: type=1400 audit(1700587894.520:2): apparmor="STATUS" operation="profile_load" profile="unconfined" name="libreoffice-senddoc" pid=785 comm="apparmor_parser" [ 2.813071] audit: type=1400 audit(1700587894.520:3): apparmor="STATUS" operation="profile_load" profile="unconfined" name="libreoffice-oosplash" pid=784 comm="apparmor_parser" [ 2.813193] audit: type=1400 audit(1700587894.520:4): apparmor="STATUS" operation="profile_load" profile="unconfined" name="libreoffice-xpdfimport" pid=787 comm="apparmor_parser" [ 2.813277] audit: type=1400 audit(1700587894.520:5): apparmor="STATUS" operation="profile_load" profile="unconfined" name="nvidia_modprobe" pid=778 comm="apparmor_parser" [ 2.813280] audit: type=1400 audit(1700587894.520:6): apparmor="STATUS" operation="profile_load" profile="unconfined" name="nvidia_modprobe//kmod" pid=778 comm="apparmor_parser" [ 2.813312] audit: type=1400 audit(1700587894.520:7): apparmor="STATUS" operation="profile_load" profile="unconfined" name="lsb_release" pid=777 comm="apparmor_parser" [ 2.813456] audit: type=1400 audit(1700587894.520:8): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/bin/man" pid=781 comm="apparmor_parser" [ 2.813465] audit: type=1400 audit(1700587894.520:9): apparmor="STATUS" operation="profile_load" profile="unconfined" name="man_filter" pid=781 comm="apparmor_parser" [ 2.813468] audit: type=1400 audit(1700587894.520:10): apparmor="STATUS" operation="profile_load" profile="unconfined" name="man_groff" pid=781 comm="apparmor_parser" [ 2.882502] usb 1-8: Found UVC 1.50 device HP 5MP Camera (0408:545b) [ 2.900201] usbcore: registered new interface driver uvcvideo [ 3.053718] i915 0000:00:02.0: [drm] VT-d active for gfx access [ 3.053871] Console: switching to colour dummy device 80x25 [ 3.053889] i915 0000:00:02.0: vgaarb: deactivate vga console [ 3.053933] i915 0000:00:02.0: [drm] Using Transparent Hugepages [ 3.054611] i915 0000:00:02.0: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=io+mem [ 3.055546] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/adls_dmc_ver2_01.bin (v2.1) [ 3.060685] iwlwifi 0000:00:14.3: Detected Intel(R) Wi-Fi 6E AX211 160MHz, REV=0x430 [ 3.060770] thermal thermal_zone17: failed to read out thermal zone (-61) [ 3.061231] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_ops [i915]) [ 3.064358] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 3.064377] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 3.064434] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002) [ 3.064534] snd_hda_intel 0000:01:00.1: Disabling MSI [ 3.064539] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client [ 3.068848] iwlwifi 0000:00:14.3: WRT: Invalid buffer destination [ 3.088809] intel_tcc_cooling: TCC Offset locked [ 3.094503] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card0/input14 [ 3.094561] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card0/input15 [ 3.094611] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card0/input16 [ 3.094663] input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card0/input17 [ 3.099580] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 3.102850] sof-audio-pci-intel-tgl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 3.102860] sof-audio-pci-intel-tgl 0000:00:1f.3: enabling device (0000 -> 0002) [ 3.103516] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100 [ 3.105501] input: SYNA30F7:00 06CB:CEC3 Mouse as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-1/i2c-SYNA30F7:00/0018:06CB:CEC3.0001/input/input18 [ 3.105601] input: SYNA30F7:00 06CB:CEC3 Touchpad as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-1/i2c-SYNA30F7:00/0018:06CB:CEC3.0001/input/input19 [ 3.105678] hid-multitouch 0018:06CB:CEC3.0001: input,hidraw0: I2C HID v1.00 Mouse [SYNA30F7:00 06CB:CEC3] on i2c-SYNA30F7:00 [ 3.106994] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 3.108939] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 3.108945] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 3.108951] sof-audio-pci-intel-tgl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 3.109080] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100 [ 3.214992] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 3.214996] Bluetooth: BNEP filters: protocol multicast [ 3.215001] Bluetooth: BNEP socket layer initialized [ 3.230031] iwlwifi 0000:00:14.3: WFPM_UMAC_PD_NOTIFICATION: 0x20 [ 3.230062] iwlwifi 0000:00:14.3: WFPM_LMAC2_PD_NOTIFICATION: 0x1f [ 3.230070] iwlwifi 0000:00:14.3: WFPM_AUTH_KEY_0: 0x90 [ 3.230080] iwlwifi 0000:00:14.3: CNVI_SCU_SEQ_DATA_DW9: 0x0 [ 3.230319] iwlwifi 0000:00:14.3: loaded PNVM version 64acdc51 [ 3.247045] iwlwifi 0000:00:14.3: Detected RF GF, rfid=0x2010d000 [ 3.315329] iwlwifi 0000:00:14.3: base HW address: e0:d0:45:23:d6:c4 [ 3.320910] input: ELAN2513:00 04F3:2FE0 as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/i2c-ELAN2513:00/0018:04F3:2FE0.0002/input/input21 [ 3.320963] input: ELAN2513:00 04F3:2FE0 UNKNOWN as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/i2c-ELAN2513:00/0018:04F3:2FE0.0002/input/input22 [ 3.320986] input: ELAN2513:00 04F3:2FE0 UNKNOWN as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/i2c-ELAN2513:00/0018:04F3:2FE0.0002/input/input23 [ 3.321028] hid-multitouch 0018:04F3:2FE0.0002: input,hidraw1: I2C HID v1.00 Device [ELAN2513:00 04F3:2FE0] on i2c-ELAN2513:00 [ 3.321065] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 3.321087] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 3.321093] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 3.321099] sof-audio-pci-intel-tgl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 3.321301] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100 [ 3.362398] iwlwifi 0000:00:14.3 wlp0s20f3: renamed from wlan0 [ 3.603758] iwlwifi 0000:00:14.3: WRT: Invalid buffer destination [ 3.759693] iwlwifi 0000:00:14.3: WFPM_UMAC_PD_NOTIFICATION: 0x20 [ 3.759726] iwlwifi 0000:00:14.3: WFPM_LMAC2_PD_NOTIFICATION: 0x1f [ 3.759734] iwlwifi 0000:00:14.3: WFPM_AUTH_KEY_0: 0x90 [ 3.759742] iwlwifi 0000:00:14.3: CNVI_SCU_SEQ_DATA_DW9: 0x0 [ 3.847915] iwlwifi 0000:00:14.3: Registered PHC clock: iwlwifi-PTP, with index: 1 [ 3.966252] loop11: detected capacity change from 0 to 8 [ 4.181547] Bluetooth: hci0: Waiting for firmware download to complete [ 4.182068] Bluetooth: hci0: Firmware loaded in 1345235 usecs [ 4.182103] Bluetooth: hci0: Waiting for device to boot [ 4.198070] Bluetooth: hci0: Device booted in 15608 usecs [ 4.198071] Bluetooth: hci0: Malformed MSFT vendor event: 0x02 [ 4.198208] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-1040-0041.ddc [ 4.200072] Bluetooth: hci0: Applying Intel DDC parameters completed [ 4.203095] Bluetooth: hci0: Firmware timestamp 2022.51 buildtype 1 build 56683 [ 4.273146] Bluetooth: MGMT ver 1.22 [ 4.276125] NET: Registered PF_ALG protocol family [ 8.186548] i915 0000:00:02.0: [drm] GT0: GuC firmware i915/tgl_guc_70.bin (70.12.1) is recommended, but only i915/tgl_guc_70.bin (70.5.1) was found [ 8.186554] i915 0000:00:02.0: [drm] GT0: Consider updating your linux-firmware pkg or downloading from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915 [ 8.191286] i915 0000:00:02.0: [drm] GT0: GuC firmware i915/tgl_guc_70.bin version 70.5.1 [ 8.191289] i915 0000:00:02.0: [drm] GT0: HuC firmware i915/tgl_huc.bin version 7.9.3 [ 8.206366] i915 0000:00:02.0: [drm] GT0: HuC: authenticated for all workloads [ 8.206377] i915 0000:00:02.0: [drm] GT0: GUC: submission disabled [ 8.206381] i915 0000:00:02.0: [drm] GT0: GUC: SLPC disabled [ 8.207416] mei_pxp 0000:00:16.0-fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1: bound 0000:00:02.0 (ops i915_pxp_tee_component_ops [i915]) [ 8.207592] i915 0000:00:02.0: [drm] Protected Xe Path (PXP) protected content support initialized [ 8.227022] [drm] Initialized i915 1.6.0 20230929 for 0000:00:02.0 on minor 0 [ 8.228063] ACPI: video: Video Device [PEGP] (multi-head: yes rom: no post: no) [ 8.228218] input: Video Bus as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:03/LNXVIDEO:00/input/input25 [ 8.228301] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 8.228551] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 8.228559] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 8.229233] sof-audio-pci-intel-tgl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 8.229482] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100 [ 8.230266] ACPI: video: Video Device [GFX0] (multi-head: yes rom: no post: no) [ 8.230578] input: Video Bus as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:01/input/input26 [ 8.230628] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 8.230638] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 8.230643] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100 [ 8.230651] sof-audio-pci-intel-tgl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver [ 8.230717] i915 display info: display version: 12 [ 8.230719] i915 display info: cursor_needs_physical: no [ 8.230720] i915 display info: has_cdclk_crawl: no [ 8.230721] i915 display info: has_cdclk_squash: no [ 8.230722] i915 display info: has_ddi: yes [ 8.230723] i915 display info: has_dp_mst: yes [ 8.230724] i915 display info: has_dsb: yes [ 8.230725] i915 display info: has_fpga_dbg: yes [ 8.230726] i915 display info: has_gmch: no [ 8.230727] i915 display info: has_hotplug: yes [ 8.230728] i915 display info: has_hti: yes [ 8.230729] i915 display info: has_ipc: yes [ 8.230729] i915 display info: has_overlay: no [ 8.230730] i915 display info: has_psr: yes [ 8.230731] i915 display info: has_psr_hw_tracking: no [ 8.230732] i915 display info: overlay_needs_physical: no [ 8.230733] i915 display info: supports_tv: no [ 8.230734] i915 display info: has_hdcp: yes [ 8.230735] i915 display info: has_dmc: yes [ 8.230736] i915 display info: has_dsc: yes [ 8.230822] sof-audio-pci-intel-tgl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100 [ 8.233200] fbcon: i915drmfb (fb0) is primary device [ 8.233161] sof-audio-pci-intel-tgl 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915]) [ 8.239720] sof-audio-pci-intel-tgl 0000:00:1f.3: use msi interrupt mode [ 8.241043] Console: switching to colour frame buffer device 240x75 [ 8.258767] i915 0000:00:02.0: [drm] fb0: i915drmfb frame buffer device [ 8.304348] sof-audio-pci-intel-tgl 0000:00:1f.3: hda codecs found, mask 5 [ 8.304352] sof-audio-pci-intel-tgl 0000:00:1f.3: using HDA machine driver skl_hda_dsp_generic now [ 8.304354] sof-audio-pci-intel-tgl 0000:00:1f.3: DMICs detected in NHLT tables: 4 [ 8.305233] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware info: version 2:0:0-b678a [ 8.305235] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware: ABI 3:20:0 Kernel ABI 3:23:0 [ 8.305238] sof-audio-pci-intel-tgl 0000:00:1f.3: unknown sof_ext_man header type 3 size 0x30 [ 8.408869] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware info: version 2:0:0-b678a [ 8.408873] sof-audio-pci-intel-tgl 0000:00:1f.3: Firmware: ABI 3:20:0 Kernel ABI 3:23:0 [ 8.413278] sof-audio-pci-intel-tgl 0000:00:1f.3: Topology: ABI 3:20:0 Kernel ABI 3:23:0 [ 8.413451] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: Parent card not yet available, widget card binding deferred [ 8.432570] snd_hda_codec_realtek ehdaudio0D0: autoconfig for ALC245: line_outs=1 (0x17/0x0/0x0/0x0/0x0) type:speaker [ 8.432575] snd_hda_codec_realtek ehdaudio0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 8.432577] snd_hda_codec_realtek ehdaudio0D0: hp_outs=1 (0x21/0x0/0x0/0x0/0x0) [ 8.432579] snd_hda_codec_realtek ehdaudio0D0: mono: mono_out=0x0 [ 8.432580] snd_hda_codec_realtek ehdaudio0D0: inputs: [ 8.432581] snd_hda_codec_realtek ehdaudio0D0: Mic=0x19 [ 8.480276] snd_hda_codec_realtek ehdaudio0D0: ASoC: sink widget AIF1TX overwritten [ 8.480284] snd_hda_codec_realtek ehdaudio0D0: ASoC: source widget AIF1RX overwritten [ 8.480413] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi3 overwritten [ 8.480418] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi2 overwritten [ 8.480422] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget hifi1 overwritten [ 8.480426] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Codec Output Pin1 overwritten [ 8.480429] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Codec Input Pin1 overwritten [ 8.480434] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Analog Codec Playback overwritten [ 8.480439] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Digital Codec Playback overwritten [ 8.480443] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: sink widget Alt Analog Codec Playback overwritten [ 8.480449] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Analog Codec Capture overwritten [ 8.480453] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Digital Codec Capture overwritten [ 8.480458] skl_hda_dsp_generic skl_hda_dsp_generic: ASoC: source widget Alt Analog Codec Capture overwritten [ 8.480467] skl_hda_dsp_generic skl_hda_dsp_generic: hda_dsp_hdmi_build_controls: no PCM in topology for HDMI converter 3 [ 8.497683] input: sof-hda-dsp Mic as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card1/input27 [ 8.497718] input: sof-hda-dsp Headphone as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card1/input28 [ 8.497741] input: sof-hda-dsp HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card1/input29 [ 8.497769] input: sof-hda-dsp HDMI/DP,pcm=4 as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card1/input30 [ 8.497790] input: sof-hda-dsp HDMI/DP,pcm=5 as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card1/input31 [ 9.779387] e1000e 0000:00:1f.6 enp0s31f6: NIC Link is Up 100 Mbps Full Duplex, Flow Control: Rx/Tx [ 13.607423] kauditd_printk_skb: 38 callbacks suppressed [ 13.607425] audit: type=1400 audit(1700587905.316:49): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1393 comm="snap-confine" capability=12 capname="net_admin" [ 13.607428] audit: type=1400 audit(1700587905.316:50): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1393 comm="snap-confine" capability=38 capname="perfmon" [ 13.630116] Bluetooth: RFCOMM TTY layer initialized [ 13.630122] Bluetooth: RFCOMM socket layer initialized [ 13.630125] Bluetooth: RFCOMM ver 1.11 [ 16.446904] audit: type=1400 audit(1700587908.156:51): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1674 comm="snap-confine" capability=12 capname="net_admin" [ 16.446917] audit: type=1400 audit(1700587908.156:52): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1674 comm="snap-confine" capability=38 capname="perfmon" [ 18.708989] audit: type=1400 audit(1700587910.416:53): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1751 comm="snap-confine" capability=12 capname="net_admin" [ 18.709004] audit: type=1400 audit(1700587910.416:54): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1751 comm="snap-confine" capability=38 capname="perfmon" [ 20.960479] audit: type=1400 audit(1700587912.668:55): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1827 comm="snap-confine" capability=12 capname="net_admin" [ 20.960489] audit: type=1400 audit(1700587912.668:56): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1827 comm="snap-confine" capability=38 capname="perfmon" [ 23.203823] audit: type=1400 audit(1700587914.912:57): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1905 comm="snap-confine" capability=12 capname="net_admin" [ 23.203833] audit: type=1400 audit(1700587914.912:58): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=1905 comm="snap-confine" capability=38 capname="perfmon" [ 24.068686] i915 0000:00:02.0: [drm] *ERROR* Failed to send PXP TEE message [ 24.921292] rfkill: input handler disabled [ 25.304870] audit: type=1400 audit(1700587917.012:59): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=2404 comm="snap-confine" capability=12 capname="net_admin" [ 25.304885] audit: type=1400 audit(1700587917.012:60): apparmor="DENIED" operation="capable" class="cap" profile="/snap/snapd/20290/usr/lib/snapd/snap-confine" pid=2404 comm="snap-confine" capability=38 capname="perfmon" [ 29.270972] mei_pxp 0000:00:16.0-fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1: Trying to reset the channel... [ 29.272071] i915 0000:00:02.0: [drm] *ERROR* Failed to send PXP TEE message [ 29.274686] i915 0000:00:02.0: [drm] *ERROR* Failed to send PXP TEE message [ 29.274696] i915 0000:00:02.0: [drm] *ERROR* Failed to send tee msg for inv-stream-key-15, ret=[28] [ 34.390683] mei_pxp 0000:00:16.0-fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1: Trying to reset the channel... [ 34.391750] i915 0000:00:02.0: [drm] *ERROR* Failed to send PXP TEE message [ 34.391772] i915 0000:00:02.0: [drm] *ERROR* Failed to send tee msg init arb session, ret=[-62] [ 34.391778] i915 0000:00:02.0: [drm] *ERROR* tee cmd for arb session creation failed
RE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Hello Stefan,
Quoted 168 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 11:07 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 57 lines · Amit Kumar
Hello Stefan,
Quoted 55 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 7:28 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 37 lines · Amit Kumar
Hello Stefan,
Quoted 35 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
Quoted 5 lines
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 3 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
Quoted 23 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi-chip_select[n].
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware
setup.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Amit Kumar Mahapatra <amit.kumar-Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stackedmode.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provide
your feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Let me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 2 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++---------
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 9 lines
include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev,void
*data)
Quoted 4 lines
{ struct spi_device *spi = to_spi_device(dev); struct spi_device *new_spi = data;drivers/spi/spi.c +0
-1-drivers/spi/spi.c
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw = spi_get_chipselect(spi,
nw_idx);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Thank you for dedicating your time to test my patch.
As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line withQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.Regards,
Amit
Quoted 6 lines
Hi,
I've attached my log.
I notice that you add a print toof_spi_parse_dt, however since the laptop I am using is an x86 laptop, it uses ACPI rather than OF, and I don't think this function isnt even compiled in.
That’s correct, I missed it.
Upon reviewing the logs, I discovered that in the ACPI flow, I am not initializing the unused CS[] to FF, as I am doing in the OF flow. Consequently, in the ACPI flow, all the unused CS[] are automatically initialized to 0. During the __spi_add_device process, the SPI core faces difficulty distinguishing between a valid CS value of 0 and an unused CS value of 0, leading to a failure in the driver probe.
Incorporating the following modifications should resolve this issue. Kindly apply these changes on top of 1/8 and re-run the test.
drivers/spi/spi.c +13 -1
@@ -619,7 +619,7 @@ static int spi_dev_check(struct device *dev, void *data)for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) {dev_err (dev,"chipselect %d already in use\n" , cs_nw);return -EBUSY ;
@@ -764,6 +764,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, {struct spi_device *proxy;int status; +u8 idx;/* * NOTE: caller did any chip->bus_num checks necessary.
@@ -779,6 +780,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,WARN_ON (strlen (chip->modalias) >=sizeof (proxy->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (proxy, idx,0xFF ); +spi_set_chipselect (proxy,0 , chip->chip_select); proxy->max_speed_hz = chip->max_speed_hz; proxy->mode = chip->mode;
@@ -2514,6 +2518,7 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,struct spi_controller *ctlr = spi->controller;struct spi_device *ancillary;int rc =0 ; +u8 idx;/* Alloc an spi_device */ ancillary =spi_alloc_device (ctlr);
@@ -2524,6 +2529,9 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,strscpy (ancillary->modalias,"dummy" ,sizeof (ancillary->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (ancillary, idx,0xFF ); +/* Use provided chip-select for ancillary device */ spi_set_chipselect (ancillary,0 , chip_select);
@@ -2732,6 +2740,7 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,struct acpi_spi_lookup lookup = {};struct spi_device *spi;int ret; +u8 idx;if (!ctlr && index ==-1 )return ERR_PTR (-EINVAL );
@@ -2767,6 +2776,9 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,return ERR_PTR (-ENOMEM ); } +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +ACPI_COMPANION_SET (&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode;
Regards,
Amit
Quoted 638 lines
Thanks,
Stefan
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void
Quoted 15 lines
Quoted 5 lines
Hi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Thank you for the quick testing. For further analysis I have incorporated additional debug prints on top of 1/8 patch. The corresponding diff is shared below. Kindly implement the specified changes, rerun your test and share the kernel logs.
drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
ff66147ba95f..7f59ea81593d100644drivers/spi/spi.c +0
-0@@ -618,8 +618,10 @@ static int spi_dev_check(struct device *dev, void*data)
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void
Quoted 12 lines
drivers/spi/spi.c +5
-1if (spi->controller == new_spi->controller) {for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx); +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx, cs);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = + [%d]\n", __func__, __LINE__, nw_idx, cs_nw);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselect %d already in use\n",
cs_nw);Quoted 28 lines
return -EBUSY; @@ -659,8 +661,10 @@ static int __spi_add_device(struct spi_device *spi) */ for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { cs = spi_get_chipselect(spi, idx);drivers/spi/spi.c +4
-0+printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx, cs);for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { nw_cs =spi_get_chipselect (spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = [%d]\n" , + __func__, __LINE__, nw_idx, nw_cs);if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) {dev_err (dev,"chipselect %d already in use\n" , nw_cs); return -EBUSY; @@ -2401,6 +2405,9 @@static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,for (idx = 0; idx < rc; idx++) spi_set_chipselect(spi, idx, cs[idx]);drivers/spi/spi.c +4
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx,spi_get_chipselect (spi, idx)); +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i * logical CS number is represented by setting the ith bit in spi-
cs_index_mask
* So, for example, ifspi->cs_index_mask=0x01then logical
CS number is 0 andQuoted 8 lines
Regards,
AmitQuoted 5 lines
Thanks,
Stefan
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs==
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cs_nw) {drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %dalready in
Quoted 38 lines
Quoted 38 lines
Quoted 11 lines
Quoted 11 lines
use\n",
cs_nw);Quoted 10 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct
spi_device*spi)
Quoted 26 lines
Quoted 26 lines
drivers/spi/spi.c
Quoted 12 lines
{ struct spi_controller *ctlr = spi->controller; struct device *dev = ctlr->dev.parent;drivers/spi/spi.c +8
-1-int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),drivers/spi/spi.c
Quoted 12 lines
drivers/spi/spi.c +6
-5+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +4
-0+*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = idx + 1; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ nw_cs =spi_get_chipselect (spi, nw_idx); + if (cs != 0xFF && nw_cs != 0xFF && cs ==
nw_cs) {Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
nw_cs);Quoted 5 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device
Quoted 2 lines
/* Set the bus ID string */drivers/spi/spi.c +0
-0@@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device*spi)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/spi/spi.c +0
-0* its configuration. */ status = bus_for_each_dev(&spi_bus_type, NULL, spi,
spi_dev_check);Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 684
Quoted 9 lines
drivers/spi/spi.c +1
-4-if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8+686,15 @@
Quoted 26 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi,0)]);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) + spi_set_csgpiod(spi, idx, ctlr-cs_gpiods[cs]);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/spi/spi.c +3
-1+ } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
drivers/spi/spi.c +3
-0+/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi); mutex_unlock(&ctlr->add_lock); @@ -942,32 +979,51 @@static
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 1 line
void spi_res_release(struct
spi_controller*ctlr, struct
spi_message*mesQuoted 7 lines
}/*---------------------------------------------------------------- --
--
-----*/drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+static inline bool spi_is_last_cs (struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { + if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 7 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} +Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 7 lines
static void spi_set_cs(struct spi_device *spi, bool enable, bool force) { bool activate = enable;drivers/spi/spi.c +1
-0+u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 3 lines
* isn't actually changing from the last time this was called. */
drivers/spi/spi.c +0
-1- if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask==
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
+spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask== spi-
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 3 lines
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))Quoted 4 lines
return; trace_spi_set_cs(spi, activate);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +4
-1- spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? +spi_get_chipselect(spi,0)
Quoted 2 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode &
SPI_CS_HIGH;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) &&!activate)
Quoted 5 lines
drivers/spi/spi.c +0
-2-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +4
-1-if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
and @@
Quoted 2 lines
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that
takes
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
SPI_CS_HIGHdrivers/spi/spi.c
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + if (((spi->cs_index_mask >> idx) &
0x01) &&Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ spi_get_csgpiod(spi, idx)) { + if (has_acpi_companion(&spi-dev))
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/spi/spi.c
Quoted 11 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +2
-0+ } + } }/* Some SPI masters need both GPIO CS &
slave_select*/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
if ((spi->controller->flags &
SPI_CONTROLLER_GPIO_SS) &&Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
spi->controller->set_cs) spi->controller->set_cs(spi, !enable);drivers/spi/spi.c +4
-0+ +if (!spi->controller->set_cs_timing) { +if (activate) + spi_delay_exec(&spi->cs_setup,NULL);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi->cs_inactive,NULL);
Quoted 26 lines
Quoted 26 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/spi/spi.c +1
-7+ } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct
Quoted 2 lines
#ifdef CONFIG_HAS_DMAdrivers/spi/spi.c +0
-0@@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct
device_node*nc,Quoted 2 lines
drivers/spi/spi.c +0
-0static int of_spi_parse_dt(struct spi_controller *ctlr, struct
spi_device*spi,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
struct
device_node*nc)
{drivers/spi/spi.c +2
-2-u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14+2363,52
@@
Quoted 1 line
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no.of
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
supported CS\n");
drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +5
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* CS can be 0. As a solution to this issue initialize all the CS to
0xFF.Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ * Now all the unused logical CS will have 0xFF physical CS +value & canbe
drivers/spi/spi.c
Quoted 9 lines
drivers/spi/spi.c +6
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc = of_property_read_variable_u32_array(nc, "reg", &cs[0],1,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +2
-0+ SPI_CS_CNT_MAX); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
nc, rc); return rc; }drivers/spi/spi.c +1
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +1
-0+ dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't supportmulti
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
CS\n");
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for +logical CS i
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +2
-0+ * logical CS number is represented by setting the ith bit in +spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
number is 0 and
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS +number so, set
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c +3
-0+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32 (nc,"spi-max-frequency" , &value))@@
-3100,6 +3206,7 @@ int spi_register_controller(structspi_controller*ctlr)
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 9 lines
struct boardinfo *bi; int first_dynamic; int status;drivers/spi/spi.c +1
-0+int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct
spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct spi_device · line 3997
Quoted 11 lines
} /* Setting last_cs to -1 means no chip selected */drivers/spi/spi.c +2
-1- ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct spi_device · line 4000
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||include/linux/spi/spi.h extern void
Quoted 21 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h +4
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define +SPI_CS_CNT_MAX +4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h extern void · line 135
Quoted 4 lines
include/linux/spi/spi.h +0
-1* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/linux/spi/spi.h extern void · line 142
Quoted 5 lines
include/linux/spi/spi.h +2
-0+* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h extern void
Quoted 1 line
include/linux/spi/spi.h +0
-0@@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
include/linux/spi/spi.h +0
-0* the device will bind to the named driver and only the named driver.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h extern void · line 162
Quoted 1 line
include/linux/spi/spi.h +0
-0* Do not set directly, because core frees it; use
driver_set_override()toQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h +0
-1* set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL
when
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
- * not using a GPIO line)
+ * @cs_gpiod: Array of GPIO descriptors of the corresponding
+ chipselectQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lines
Quoted 5 lines
+ * (optional, NULL when not using a GPIO line)
* @word_delay: delay to be inserted between consecutive
* words of a transfer
* @cs_setup: delay to be introduced by the controller after
CS is asserted @@ -167,6 +171,7 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer,
then
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
the
include/linux/spi/spi.h struct spi_device { · line 188
Quoted 10 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +0
-0@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
include/linux/spi/spi.h struct spi_device { · line 216
Quoted 11 lines
include/linux/spi/spi.h +1
-2u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ @@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
gpio desc */
include/linux/spi/spi.h struct spi_device { · line 231
Quoted 8 lines
include/linux/spi/spi.h +1
-0struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_device { · line 232
Quoted 1 line
include/linux/spi/spi.h +1
-0+* the chipselect array.When the controller is capable to handle
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
include/linux/spi/spi.h struct spi_device { · line 239
Quoted 7 lines
include/linux/spi/spi.h +5
-0+* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 11 lines
include/linux/spi/spi.h +1
-1* the controller talks to each chip, like: @@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi,Quoted 1 line
u8 idx, u8
chipselect)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1- spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(const struct
spi_device*spi,u8 idx)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1-return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi, u8idx, struct
gpio_desc*csgpiod)Quoted 15 lines
{include/linux/spi/spi.h +11
-1- spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/spi/spi.h extern struct spi_device
Quoted 2 lines
/**include/linux/spi/spi.h +0
-0@@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chQuoted 5 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode isrequested.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
include/linux/spi/spi.h struct spi_controller { · line 592
Quoted 2 lines
include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_controller { · line 593
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must
Quoted 2 lines
Quoted 2 lines
select slave */
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
suspended */
include/linux/spi/spi.h struct spi_controller { · line 601
Quoted 7 lines
include/linux/spi/spi.h +5
-0+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)/* Flag indicating if the allocation of this struct is devres- managed */
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
include/linux/spi/spi.h +2
-1bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 252 lines · Amit Kumar
Hello Stefan,
Quoted 163 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 11:07 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 57 lines · Amit Kumar
Hello Stefan,
Quoted 55 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 7:28 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 37 lines · Amit Kumar
Hello Stefan,
Quoted 35 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
Quoted 5 lines
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the data. In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 3 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi-chip_select[n].
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chip selects at once.For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware
setup.
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Signed-off-by Amit Kumar Mahapatra <amit.kumar-Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stackedmode.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provide
your feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Let me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 2 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++---------
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 9 lines
include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev,void
*data)
Quoted 4 lines
{ struct spi_device *spi = to_spi_device(dev); struct spi_device *new_spi = data;drivers/spi/spi.c +0
-1-drivers/spi/spi.c
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw = spi_get_chipselect(spi,
nw_idx);Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Thank you for dedicating your time to test my patch.
As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Regards,
AmitHi,
I've attached my log.
I notice that you add a print toof_spi_parse_dt, however since the laptop I am using is an x86 laptop, it uses ACPI rather than OF, and I don't think this function isnt even compiled in.That’s correct, I missed it.
Upon reviewing the logs, I discovered that in the ACPI flow, I am not initializing the unused CS[] to FF, as I am doing in the OF flow. Consequently, in the ACPI flow, all the unused CS[] are automatically initialized to 0. During the__spi_add_deviceprocess, the SPI core faces difficulty distinguishing between a valid CS value of 0 and an unused CS value of 0, leading to a failure in the driver probe.Incorporating the following modifications should resolve this issue. Kindly apply these changes on top of 1/8 and re-run the test.
drivers/spi/spi.c +13
-1@@ -619,7 +619,7 @@ static int spi_dev_check(struct device *dev, void *data)for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) {dev_err (dev,"chipselect %d already in use\n" , cs_nw);return -EBUSY ;@@ -764,6 +764,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, {struct spi_device *proxy;int status; +u8 idx;/* * NOTE: caller did any chip->bus_num checks necessary. @@ -779,6 +780,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,WARN_ON (strlen (chip->modalias) >=sizeof (proxy->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (proxy, idx,0xFF ); +spi_set_chipselect (proxy,0 , chip->chip_select); proxy->max_speed_hz = chip->max_speed_hz; proxy->mode = chip->mode;@@ -2514,6 +2518,7 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,struct spi_controller *ctlr = spi->controller;struct spi_device *ancillary;int rc =0 ; +u8 idx;/* Alloc an spi_device */ ancillary =spi_alloc_device (ctlr);@@ -2524,6 +2529,9 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,strscpy (ancillary->modalias,"dummy" ,sizeof (ancillary->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (ancillary, idx,0xFF ); +/* Use provided chip-select for ancillary device */ spi_set_chipselect (ancillary,0 , chip_select);@@ -2732,6 +2740,7 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,struct acpi_spi_lookup lookup = {};struct spi_device *spi;int ret; +u8 idx;if (!ctlr && index ==-1 )return ERR_PTR (-EINVAL );@@ -2767,6 +2776,9 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,return ERR_PTR (-ENOMEM ); } +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +ACPI_COMPANION_SET (&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode;
Quoted 3 lines
Regards,
Amit
Hi,
I no longer see that error, or any errors printed from SPI, however, all of the transactions are now broken.
Every transaction seems to read back 0x0, on all SPI devices, whether native CS or GPIO CS, and I dont see it toggling the CS GPIO anymore.
Thanks,
Stefan
Quoted 637 lines
Quoted 637 lines
Thanks,
Stefan
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void
Quoted 15 lines
Quoted 5 lines
Hi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Thank you for the quick testing. For further analysis I have incorporated additional debug prints on top of 1/8 patch. The corresponding diff is shared below. Kindly implement the specified changes, rerun your test and share the kernel logs.
drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
ff66147ba95f..7f59ea81593d100644drivers/spi/spi.c +0
-0@@ -618,8 +618,10 @@ static int spi_dev_check(struct device *dev, void*data)
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void *data)
Quoted 12 lines
drivers/spi/spi.c +5
-1if (spi->controller == new_spi->controller) {for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx); +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx, cs);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = + [%d]\n", __func__, __LINE__, nw_idx, cs_nw);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselect %d already in use\n",
cs_nw);Quoted 28 lines
return -EBUSY; @@ -659,8 +661,10 @@ static int __spi_add_device(struct spi_device *spi) */ for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { cs = spi_get_chipselect(spi, idx);drivers/spi/spi.c +4
-0+printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx, cs);for (nw_idx = idx +1 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { nw_cs =spi_get_chipselect (spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = [%d]\n" , + __func__, __LINE__, nw_idx, nw_cs);if (cs !=0xFF && nw_cs !=0xFF && cs == nw_cs) {dev_err (dev,"chipselect %d already in use\n" , nw_cs); return -EBUSY; @@ -2401,6 +2405,9 @@static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,for (idx = 0; idx < rc; idx++) spi_set_chipselect(spi, idx, cs[idx]);drivers/spi/spi.c +4
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx,spi_get_chipselect (spi, idx)); +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i * logical CS number is represented by setting the ith bit in spi-
cs_index_mask
* So, for example, ifspi->cs_index_mask=0x01then logical
CS number is 0 andQuoted 8 lines
Regards,
AmitQuoted 5 lines
Thanks,
Stefan
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs==
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cs_nw) {drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %dalready in
Quoted 38 lines
Quoted 38 lines
Quoted 11 lines
Quoted 11 lines
use\n",
cs_nw);Quoted 10 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct
spi_device*spi)
Quoted 26 lines
Quoted 26 lines
drivers/spi/spi.c
Quoted 12 lines
{ struct spi_controller *ctlr = spi->controller; struct device *dev = ctlr->dev.parent;drivers/spi/spi.c +8
-1-int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),drivers/spi/spi.c
Quoted 12 lines
drivers/spi/spi.c +6
-5+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { -dev_err (dev,"cs%d >= max %d\n" ,spi_get_chipselect (spi,0 ), - ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +4
-0+*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = idx + 1; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ nw_cs =spi_get_chipselect (spi, nw_idx); + if (cs != 0xFF && nw_cs != 0xFF && cs ==
nw_cs) {Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
nw_cs);Quoted 5 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device
Quoted 2 lines
/* Set the bus ID string */drivers/spi/spi.c +0
-0@@ -647,11 +677,8 @@ static int __spi_add_device(struct spi_device*spi)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/spi/spi.c +0
-0* its configuration. */ status = bus_for_each_dev(&spi_bus_type, NULL, spi,
spi_dev_check);Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/spi/spi.c static int __spi_add_device(struct spi_device · line 684
Quoted 9 lines
drivers/spi/spi.c +1
-4-if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8+686,15 @@
Quoted 26 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr->cs_gpiods[spi_get_chipselect(spi,0)]);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) + spi_set_csgpiod(spi, idx, ctlr-cs_gpiods[cs]);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/spi/spi.c +3
-1+ } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
drivers/spi/spi.c +3
-0+/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi); mutex_unlock(&ctlr->add_lock); @@ -942,32 +979,51 @@static
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 1 line
void spi_res_release(struct
spi_controller*ctlr, struct
spi_message*mesQuoted 7 lines
}/*---------------------------------------------------------------- --
--
-----*/drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+static inline bool spi_is_last_cs (struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { + if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 7 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} +Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c struct spi_device *spi_new_device(struct spi_controller *ctlr,
Quoted 7 lines
static void spi_set_cs(struct spi_device *spi, bool enable, bool force) { bool activate = enable;drivers/spi/spi.c +1
-0+u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip select
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 3 lines
* isn't actually changing from the last time this was called. */
drivers/spi/spi.c +0
-1- if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask==
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
+spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask== spi-
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 3 lines
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))Quoted 4 lines
return; trace_spi_set_cs(spi, activate);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +4
-1- spi->controller->last_cs = enable ?spi_get_chipselect (spi,0 ) :-1 ; + spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? +spi_get_chipselect(spi,0)
Quoted 2 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode &
SPI_CS_HIGH;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing) &&!activate)
Quoted 5 lines
drivers/spi/spi.c +0
-2-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +4
-1-if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
and @@
Quoted 2 lines
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that
takes
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
SPI_CS_HIGHdrivers/spi/spi.c
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + if (((spi->cs_index_mask >> idx) &
0x01) &&Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ spi_get_csgpiod(spi, idx)) { + if (has_acpi_companion(&spi-dev))
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/spi/spi.c
Quoted 11 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +2
-0+ } + } }/* Some SPI masters need both GPIO CS &
slave_select*/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
if ((spi->controller->flags &
SPI_CONTROLLER_GPIO_SS) &&Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
spi->controller->set_cs) spi->controller->set_cs(spi, !enable);drivers/spi/spi.c +4
-0+ +if (!spi->controller->set_cs_timing) { +if (activate) + spi_delay_exec(&spi->cs_setup,NULL);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi->cs_inactive,NULL);
Quoted 26 lines
Quoted 26 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/spi/spi.c +1
-7+ } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c static void of_spi_parse_dt_cs_delay(struct
Quoted 2 lines
#ifdef CONFIG_HAS_DMAdrivers/spi/spi.c +0
-0@@ -2222,8 +2290,8 @@ static void of_spi_parse_dt_cs_delay(struct
device_node*nc,Quoted 2 lines
drivers/spi/spi.c +0
-0static int of_spi_parse_dt(struct spi_controller *ctlr, struct
spi_device*spi,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
struct
device_node*nc)
{drivers/spi/spi.c +2
-2-u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14+2363,52
@@
Quoted 1 line
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no.of
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
supported CS\n");
drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +5
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* CS can be 0. As a solution to this issue initialize all the CS to
0xFF.Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ * Now all the unused logical CS will have 0xFF physical CS +value & canbe
drivers/spi/spi.c
Quoted 9 lines
drivers/spi/spi.c +6
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc = of_property_read_variable_u32_array(nc, "reg", &cs[0],1,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +2
-0+ SPI_CS_CNT_MAX); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
nc, rc); return rc; }drivers/spi/spi.c +1
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +1
-0+ dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't supportmulti
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
CS\n");
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for +logical CS i
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +2
-0+ * logical CS number is represented by setting the ith bit in +spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
number is 0 and
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS +number so, set
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c +3
-0+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;/* Device speed */ if (!of_property_read_u32 (nc,"spi-max-frequency" , &value))@@
-3100,6 +3206,7 @@ int spi_register_controller(structspi_controller*ctlr)
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 9 lines
struct boardinfo *bi; int first_dynamic; int status;drivers/spi/spi.c +1
-0+int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct
spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct spi_device · line 3997
Quoted 11 lines
} /* Setting last_cs to -1 means no chip selected */drivers/spi/spi.c +2
-1- ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct spi_device · line 4000
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||include/linux/spi/spi.h extern void
Quoted 21 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h +4
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define +SPI_CS_CNT_MAX +4 +struct dma_chan ;struct software_node ;struct ptp_system_timestamp ;@@ -132,7 +135,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h extern void · line 135
Quoted 4 lines
include/linux/spi/spi.h +0
-1* @max_speed_hz: Maximum clock rate to be used with this chip * (on this board); may be changed by the device's driver. * The spi_transfer.speed_hz can override this for each transfer. -* @chip_select: Chipselect, distinguishing chips handled by @controller.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/linux/spi/spi.h extern void · line 142
Quoted 5 lines
include/linux/spi/spi.h +2
-0+* @chip_select: Array of physical chipselect, spi->chipselect[i] gives +* the corresponding physical CS for logical CS i. * @mode: The spi mode defines how data is clocked out and in. * This may be changed by the device's driver. * The "active low" default for chipselect mode can be overridden
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h extern void
Quoted 1 line
include/linux/spi/spi.h +0
-0@@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
include/linux/spi/spi.h +0
-0* the device will bind to the named driver and only the named driver.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h extern void · line 162
Quoted 1 line
include/linux/spi/spi.h +0
-0* Do not set directly, because core frees it; use
driver_set_override()toQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h +0
-1* set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL
when
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
- * not using a GPIO line)
+ * @cs_gpiod: Array of GPIO descriptors of the corresponding
+ chipselectQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lines
Quoted 5 lines
+ * (optional, NULL when not using a GPIO line)
* @word_delay: delay to be inserted between consecutive
* words of a transfer
* @cs_setup: delay to be introduced by the controller after
CS is asserted @@ -167,6 +171,7 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer,
then
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
the
include/linux/spi/spi.h struct spi_device { · line 188
Quoted 10 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +0
-0@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
include/linux/spi/spi.h struct spi_device { · line 216
Quoted 11 lines
include/linux/spi/spi.h +1
-2u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ @@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor */
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
gpio desc */
include/linux/spi/spi.h struct spi_device { · line 231
Quoted 8 lines
include/linux/spi/spi.h +1
-0struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_device { · line 232
Quoted 1 line
include/linux/spi/spi.h +1
-0+* the chipselect array.When the controller is capable to handle
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
include/linux/spi/spi.h struct spi_device { · line 239
Quoted 7 lines
include/linux/spi/spi.h +5
-0+* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting how
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 11 lines
include/linux/spi/spi.h +1
-1* the controller talks to each chip, like: @@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi)static inline u8 spi_get_chipselect (const struct spi_device *spi,u8 idx) { -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi,Quoted 1 line
u8 idx, u8
chipselect)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1- spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(const struct
spi_device*spi,u8 idx)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1-return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi, u8idx, struct
gpio_desc*csgpiod)Quoted 15 lines
{include/linux/spi/spi.h +11
-1- spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/spi/spi.h extern struct spi_device
Quoted 2 lines
/**include/linux/spi/spi.h +0
-0@@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chQuoted 5 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can assert/de-assert
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode isrequested.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
include/linux/spi/spi.h struct spi_controller { · line 592
Quoted 2 lines
include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx */
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_controller { · line 593
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must
Quoted 2 lines
Quoted 2 lines
select slave */
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
suspended */
include/linux/spi/spi.h struct spi_controller { · line 601
Quoted 7 lines
include/linux/spi/spi.h +5
-0+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)/* Flag indicating if the allocation of this struct is devres- managed */
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
include/linux/spi/spi.h +2
-1bool devm_allocated;@@ -677,7 +707,8 @@ struct spi_controller {bool rt;bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
RE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 291 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Wednesday, November 22, 2023 4:51 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 53 lines · Amit Kumar
Hello Stefan,
Quoted 51 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 11:07 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 33 lines · Amit Kumar
Hello Stefan,
Quoted 31 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 7:28 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 13 lines · Amit Kumar
Hello Stefan,
Quoted 11 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, MichalQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 3 lines · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that allows the controller to consider two flashes as one single device.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
One of these two mode is the parallel mode in which each byte of data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of the
data.
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 3 lines
For supporting both these modes SPI core need to be updated for providing multiple CS for a single SPI device.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. This acts as an index to thechip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi-chip_select[n].
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is added in the spi controller flags, throughctlr->flagsthe spi core will make sure that the controller is capable of handling multiple chipselects at once.
Quoted 29 lines
Quoted 29 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware
setup.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Signed-off-by Amit Kumar Mahapatra <amit.kumar-Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stackedmode.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines
We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provide
your feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Let me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 2 lines
--- drivers/spi/spi.c | 192 +++++++++++++++++++++++++++++++-------
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void
Quoted 64 lines
Quoted 40 lines
--
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
drivers/spi/spi.c static int spi_dev_check(struct device · line 612
Quoted 9 lines
include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(struct device *dev, void*data)
Quoted 4 lines
drivers/spi/spi.c +0
-1{struct spi_device *spi =to_spi_device (dev);struct spi_device *new_spi = data; -drivers/spi/spi.c static int spi_dev_check(struct device · line 622
Quoted 10 lines
drivers/spi/spi.c +7
-3-if (spi->controller == new_spi->controller && -spi_get_chipselect (spi,0 ) ==spi_get_chipselect (new_spi,0 )) -return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c static int spi_dev_check(struct device · line 623
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw = spi_get_chipselect(spi,
nw_idx);Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Thank you for dedicating your time to test my patch.
As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Regards,
AmitHi,
I've attached my log.
I notice that you add a print toof_spi_parse_dt, however since the laptop I am using is an x86 laptop, it uses ACPI rather than OF, and I don't think this function isnt even compiled in.That’s correct, I missed it.
Upon reviewing the logs, I discovered that in the ACPI flow, I am not initializing the unused CS[] to FF, as I am doing in the OF flow. Consequently, in the ACPI flow, all the unused CS[] are automatically initialized to 0. During the__spi_add_deviceprocess, the SPI core faces difficulty distinguishing between a valid CS value of 0 and an unused CS value of 0, leading to a failure in the driver probe.Incorporating the following modifications should resolve this issue. Kindly apply these changes on top of 1/8 and re-run the test.
drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
ff66147ba95f..d0301c17d4f8100644drivers/spi/spi.c +0
-0@@ -619,7 +619,7 @@ static int spi_dev_check(struct device *dev, void*data)
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void · line 625
Quoted 8 lines
drivers/spi/spi.c +2
-1for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, + nw_idx);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselect %d already in use\n",
cs_nw);drivers/spi/spi.c struct spi_device
Quoted 21 lines
drivers/spi/spi.c +5
-0return -EBUSY; @@ -764,6 +764,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, { struct spi_device *proxy; int status; + u8 idx; /* * NOTE: caller did any chip->bus_num checks necessary.@@ -779,6 +780,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,WARN_ON (strlen (chip->modalias) >=sizeof (proxy->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (proxy, idx,0xFF ); +spi_set_chipselect (proxy,0 , chip->chip_select); proxy->max_speed_hz = chip->max_speed_hz;proxy->mode = chip->mode;drivers/spi/spi.c +0
-0@@ -2514,6 +2518,7 @@ struct spi_device*spi_new_ancillary_device(struct
spi_device*spi,drivers/spi/spi.c struct spi_device *acpi_spi_device_alloc(struct
Quoted 19 lines
drivers/spi/spi.c +1
-0struct spi_controller *ctlr = spi->controller;struct spi_device *ancillary;int rc =0 ; +u8 idx;/* Alloc an spi_device */ ancillary = spi_alloc_device(ctlr); @@ -2524,6 +2529,9 @@struct
spi_device*spi_new_ancillary_device(structspi_device*spi,strscpy(ancillary->modalias, "dummy",
sizeof(ancillary->modalias));drivers/spi/spi.c +3
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (ancillary, idx,0xFF ); +/* Use provided chip-select for ancillary device */ spi_set_chipselect (ancillary,0 , chip_select);@@ -2732,6 +2740,7 @@ struct spi_device *acpi_spi_device_alloc(struct
spi_controller*ctlr,Quoted 18 lines
drivers/spi/spi.c +1
-0struct acpi_spi_lookup lookup = {};struct spi_device *spi;int ret; +u8 idx;if (!ctlr && index ==-1 ) return ERR_PTR(-EINVAL); @@ -2767,6 +2776,9 @@ struct
spi_device*acpi_spi_device_alloc(structspi_controller*ctlr,return ERR_PTR(-ENOMEM); }drivers/spi/spi.c +3
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +ACPI_COMPANION_SET (&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode;Quoted 3 lines
Regards,
Amit
Quoted 6 lines
Hi,
I no longer see that error, or any errors printed from SPI, however, all of the transactions are now broken.
Every transaction seems to read back0x0, on all SPI devices, whether native CS or GPIO CS, and I dont see it toggling the CS GPIO anymore.
I believe the issue stems from the fact that in the ACPI patch, spi->cs_index_mask is not set to 0x01. As a result, in spi_set_cs, it fails to meet the condition that governs the CS asset code snippet. In the following code diff, I've included the necessary fix along with the earlier changes on top of 1/8. I've also included a couple of debug prints to aid in further debugging in case my analysis is incorrect. Please apply these changes on top of 1/8 and re-run the test.
drivers/spi/spi.c +19 -1
@@ -619,7 +619,7 @@ static int spi_dev_check(struct device *dev, void *data)for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) {dev_err (dev,"chipselect %d already in use\n" , cs_nw);return -EBUSY ;
@@ -764,6 +764,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, {struct spi_device *proxy;int status; +u8 idx;/* * NOTE: caller did any chip->bus_num checks necessary.
@@ -779,6 +780,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,WARN_ON (strlen (chip->modalias) >=sizeof (proxy->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (proxy, idx,0xFF ); +spi_set_chipselect (proxy,0 , chip->chip_select); proxy->max_speed_hz = chip->max_speed_hz; proxy->mode = chip->mode;
@@ -787,6 +791,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, proxy->dev.platform_data = (void *) chip->platform_data; proxy->controller_data = chip->controller_data; proxy->controller_state =NULL ; + proxy->cs_index_mask =0x01 ;if (chip->swnode) { status =device_add_software_node (&proxy->dev, chip->swnode);
@@ -1024,6 +1029,8 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)if (!spi->controller->set_cs_timing && !activate)spi_delay_exec (&spi->cs_hold,NULL ); +printk ("%s() [%d] spi->cs_index_mask == [%d]\n" ,__func__, __LINE__, spi->cs_index_mask); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity and
@@ -1038,6 +1045,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) {if (((spi->cs_index_mask >> idx) &0x01 ) &&spi_get_csgpiod (spi, idx)) { +printk ("%s() [%d] idx == [%d]\n" ,__func__, __LINE__, idx);if (has_acpi_companion (&spi->dev))gpiod_set_value_cansleep (spi_get_csgpiod (spi, idx), !enable);
@@ -2514,6 +2522,7 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,struct spi_controller *ctlr = spi->controller;struct spi_device *ancillary;int rc =0 ; +u8 idx;/* Alloc an spi_device */ ancillary =spi_alloc_device (ctlr);
@@ -2524,12 +2533,16 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,strscpy (ancillary->modalias,"dummy" ,sizeof (ancillary->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (ancillary, idx,0xFF ); +/* Use provided chip-select for ancillary device */ spi_set_chipselect (ancillary,0 , chip_select);/* Take over SPI mode/speed from SPI main device */ ancillary->max_speed_hz = spi->max_speed_hz; ancillary->mode = spi->mode; + ancillary->cs_index_mask =0x01 ;WARN_ON (!mutex_is_locked (&ctlr->add_lock));
@@ -2732,6 +2745,7 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,struct acpi_spi_lookup lookup = {};struct spi_device *spi;int ret; +u8 idx;if (!ctlr && index ==-1 )return ERR_PTR (-EINVAL );
@@ -2767,12 +2781,16 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr,return ERR_PTR (-ENOMEM ); } +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +ACPI_COMPANION_SET (&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode; spi->irq = lookup.irq; spi->bits_per_word = lookup.bits_per_word;spi_set_chipselect (spi,0 , lookup.chip_select); + spi->cs_index_mask =0x01 ;return spi; }
Regards,
Amit
Quoted 665 lines
Thanks,
Stefan
Quoted 35 lines
Quoted 35 lines
Thanks,
Stefan
Quoted 15 lines
Quoted 5 lines
Hi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in use
Thank you for the quick testing. For further analysis I have incorporated additional debug prints on top of 1/8 patch. The corresponding diff is shared below. Kindly implement the specified changes, rerun your test and share the kernel logs.
drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
ff66147ba95f..7f59ea81593d100644drivers/spi/spi.c +0
-0@@ -618,8 +618,10 @@ static int spi_dev_check(struct device *dev,Quoted 1 line
void
*data)
Quoted 12 lines
if (spi->controller == new_spi->controller) { for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { cs = spi_get_chipselect(spi, idx);drivers/spi/spi.c +5
-1+printk ("%s() [%d] CS[%d] = [%d]\n" , + __func__, __LINE__, idx, cs);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = + [%d]\n", __func__, __LINE__, nw_idx, cs_nw);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselectQuoted 1 line
%d already in use\n",
cs_nw);Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
return -EBUSY; @@ -659,8 +661,10 @@ static int __spi_add_device(struct spi_device *spi) */ for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { cs = spi_get_chipselect(spi, idx);+ printk("%s() [%d] CS[%d] = [%d]\n",
__func__,
+__LINE__, idx, cs);Quoted 8 lines
Quoted 8 lines
for (nw_idx = idx + 1; nw_idx < SPI_CS_CNT_MAX; nw_idx++) { nw_cs = spi_get_chipselect(spi, nw_idx); + printk("%s() [%d] CS_NEW[%d] = [%d]\n", + __func__, __LINE__, nw_idx, nw_cs); if (cs != 0xFF && nw_cs != 0xFF && cs == nw_cs) { dev_err(dev, "chipselect %d already in use\n", nw_cs); return -EBUSY; @@ -2401,6 +2405,9@@ static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
for (idx = 0; idx < rc; idx++) spi_set_chipselect(spi, idx, cs[idx]);drivers/spi/spi.c +4
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx,spi_get_chipselect (spi, idx)); +/* spi->chip_select[i] gives the corresponding physical CS for logical CS i
Quoted 42 lines
Quoted 42 lines
Quoted 5 lines
* logical CS number is represented by setting the ith bit
in spi-cs_index_mask
* So, for example, ifspi->cs_index_mask=0x01then
logical CS number is 0 andQuoted 8 lines
Regards,
AmitQuoted 5 lines
Thanks,
Stefan
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c static int spi_dev_check(struct device · line 624
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF && cs==
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cs_nw) {drivers/spi/spi.c static int spi_dev_check(struct device · line 625
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %dalready in
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
use\n",
cs_nw);Quoted 10 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct
spi_device*spi)
Quoted 13 lines
Quoted 13 lines
drivers/spi/spi.c
Quoted 12 lines
{ struct spi_controller *ctlr = spi->controller; struct device *dev = ctlr->dev.parent;drivers/spi/spi.c +8
-1-int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +4
-3+ ctlr->num_chipselect); +return -EINVAL ; + } + } -/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { - dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, 0),Quoted 92 lines
Quoted 40 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +2
-2- ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same physical CS.
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and so on.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +4
-0+*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = idx + 1; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ nw_cs =spi_get_chipselect (spi, nw_idx); + if (cs != 0xFF && nw_cs != 0xFF && cs ==
nw_cs) {Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %d already inuse\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
nw_cs);Quoted 5 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
/* Set the bus ID string */ @@ -647,11 +677,8 @@ staticint __spi_add_device(struct
spi_device*spi)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
* its configuration.
*/
status = bus_for_each_dev(&spi_bus_type, NULL, spi,
spi_dev_check);Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/spi/spi.c
Quoted 9 lines
drivers/spi/spi.c +1
-4-if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8+686,15 @@
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr-cs_gpiods[spi_get_chipselect(spi,
Quoted 44 lines
Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
0)]);
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) + spi_set_csgpiod(spi, idx, ctlr-cs_gpiods[cs]);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/spi/spi.c +3
-1+ } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
drivers/spi/spi.c +3
-0+/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi); mutex_unlock(&ctlr->add_lock); @@ -942,32 +979,51 @@static
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 1 line
void spi_res_release(struct
spi_controller*ctlr, struct
spi_message*mesQuoted 8 lines
}/*-------------------------------------------------------------- --
--
--
-----*/drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+static inline bool spi_is_last_cs (struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { + if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} + static void spi_set_cs(struct spi_device *spi, bool enable, boolforce)
Quoted 25 lines
Quoted 25 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
{ bool activate = enable;drivers/spi/spi.c +1
-0+u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip
select
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 3 lines
* isn't actually changing from the last time this was called. */
drivers/spi/spi.c +0
-1- if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (!force && ((enable && spi->controller->last_cs_index_mask==
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
+spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller->last_cs_index_mask== spi-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 3 lines
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
return; trace_spi_set_cs(spi, activate);drivers/spi/spi.c +0
-1- spi->controller->last_cs = enable ? spi_get_chipselect(spi, 0) : -1;
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +4
-0+ spi->controller->last_cs_index_mask = spi->cs_index_mask; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? +spi_get_chipselect(spi,0)
Quoted 2 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode &
SPI_CS_HIGH;Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller->set_cs_timing)&&
Quoted 280 lines
Quoted 280 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
!activate)
Quoted 5 lines
drivers/spi/spi.c +0
-2-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +4
-1-if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO polarity
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
and @@
Quoted 2 lines
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable, that
takes
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
SPI_CS_HIGHdrivers/spi/spi.c
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), !enable);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +0
-3-else -/* Polarity handled by GPIO library */ -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + if (((spi->cs_index_mask >> idx) &
0x01) &&Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ spi_get_csgpiod(spi, idx)) { + if (has_acpi_companion(&spi-dev))
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by GPIO
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/spi/spi.c
Quoted 11 lines
drivers/spi/spi.c +3
-0+ +if (activate) + spi_delay_exec(&spi-
cs_setup, NULL);drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive, NULL);drivers/spi/spi.c +2
-0+ } + } }/* Some SPI masters need both GPIO CS &
slave_select*/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
if ((spi->controller->flags &
SPI_CONTROLLER_GPIO_SS) &&Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
spi->controller->set_cs) spi->controller->set_cs(spi, !enable);drivers/spi/spi.c +4
-0+ +if (!spi->controller->set_cs_timing) { +if (activate) + spi_delay_exec(&spi->cs_setup,NULL);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi->cs_inactive,NULL);
Quoted 27 lines
Quoted 27 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/spi/spi.c +1
-7+ } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - -if (spi_get_csgpiod (spi,0 ) || !spi->controller->set_cs_timing) { -if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
#ifdef CONFIG_HAS_DMAdrivers/spi/spi.c +0
-0@@ -2222,8 +2290,8 @@ static voidof_spi_parse_dt_cs_delay(struct
device_node*nc,Quoted 2 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr,
structspi_device*spi,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
struct
device_node*nc)
{drivers/spi/spi.c +2
-2-u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14+2363,52
@@
Quoted 2 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max. no.of
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
supported CS\n");
drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +5
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate +* between a valid physical CS 0 & an unused logical CS whose physical
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ * CS can be 0. As a solution to this issue initialize all the +CS to
0xFF.Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ * Now all the unused logical CS will have 0xFF physical CS +value & canbe
drivers/spi/spi.c
Quoted 9 lines
drivers/spi/spi.c +6
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc = of_property_read_variable_u32_array(nc, "reg", &cs[0],1,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +2
-0+ SPI_CS_CNT_MAX); +if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg' property(%d)\n",
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
nc, rc); return rc; }drivers/spi/spi.c +1
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +1
-0+ dev_err(&ctlr->dev, "%pOF has number of CS > ctlr-
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn't supportmulti
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
CS\n");
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for +logical CS i
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +2
-0+ * logical CS number is represented by setting the ith bit in +spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical CS
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
number is 0 and
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS +number so, set
Quoted 4 lines
drivers/spi/spi.c +3
-0+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency",&value)) @@
-3100,6 +3206,7 @@ int spi_register_controller(structspi_controller*ctlr)
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
Quoted 9 lines
struct boardinfo *bi; int first_dynamic; int status;drivers/spi/spi.c +1
-0+int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct
spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct · line 3997
Quoted 11 lines
} /* Setting last_cs to -1 means no chip selected */drivers/spi/spi.c +2
-1- ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)drivers/spi/spi.c static int __spi_validate(struct · line 4000
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||Quoted 20 lines
drivers/spi/spi.c +1
-1- spi_get_csgpiod(spi, 0))) { + spi_is_csgpiod(spi))) {size_t maxsize =BITS_TO_BYTES (spi->bits_per_word);int ret;include/linux/spi/spi.h +4
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> +/* Max no. of CS supported per spi device */ #define +SPI_CS_CNT_MAX +4 +struct dma_chan ;struct software_node ; struct ptp_system_timestamp; @@ -132,7 +135,8 @@ externQuoted 1 line
void
spi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
* @max_speed_hz: Maximum clock rate to be used with this chip
* (on this board); may be changed by the device's driver.
* The spi_transfer.speed_hz can override this for each transfer.
- * @chip_select: Chipselect, distinguishing chips handled by@controller.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
+ * @chip_select: Array of physical chipselect, spi->chipselect[i] gives
+ * the corresponding physical CS for logical CS i.
* @mode: The spi mode defines how data is clocked out and in.
* This may be changed by the device's driver.
* The "active low" default for chipselect mode can beoverridden
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h extern void
Quoted 1 line
include/linux/spi/spi.h +0
-0@@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
include/linux/spi/spi.h +0
-0* the device will bind to the named driver and only the named driver.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h extern void · line 162
Quoted 1 line
include/linux/spi/spi.h +0
-0* Do not set directly, because core frees it; use
driver_set_override()toQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h +0
-1* set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL
when
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
- * not using a GPIO line)
+ * @cs_gpiod: Array of GPIO descriptors of the corresponding
+ chipselectQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lines
Quoted 5 lines
+ * (optional, NULL when not using a GPIO line)
* @word_delay: delay to be inserted between consecutive
* words of a transfer
* @cs_setup: delay to be introduced by the controller
after CS is asserted @@ -167,6 +171,7 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from @spi_transfer,
then
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
the
include/linux/spi/spi.h struct spi_device { · line 188
Quoted 10 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPI slave
* (usually a discrete chip) and CPU memory.include/linux/spi/spi.h +0
-0@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer */
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
include/linux/spi/spi.h struct spi_device { · line 216
Quoted 11 lines
include/linux/spi/spi.h +1
-2u32 max_speed_hz; -u8 chip_select; +u8 chip_select[SPI_CS_CNT_MAX ];u8 bits_per_word;bool rt;#define SPI_NO_TX BIT(31)/* No transmit wire */ @@ -213,7 +218,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];const char *driver_override; -struct gpio_desc *cs_gpiod;/* Chip select GPIO descriptor
Quoted 24 lines
Quoted 24 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*/
include/linux/spi/spi.h struct spi_device { · line 221
Quoted 1 line
include/linux/spi/spi.h +1
-0+struct gpio_desc *cs_gpiod[SPI_CS_CNT_MAX ];/* Chip select
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
gpio desc */
include/linux/spi/spi.h struct spi_device { · line 231
Quoted 8 lines
include/linux/spi/spi.h +1
-0struct spi_delay word_delay;/* Inter-word delay */ /* CS delays */ struct spi_delay cs_setup;@@ -223,6 +228,13 @@ struct spi_device {/* The statistics */ struct spi_statistics __percpu *pcpu_statistics; +/* Bit mask of the chipselect(s) that the driver need to use from
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_device { · line 232
Quoted 1 line
include/linux/spi/spi.h +1
-0+* the chipselect array.When the controller is capable to handle
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/spi/spi.h +5
-0+* multiple chip selects & memories are connected in parallel +* then more than one bit need to be set in cs_index_mask. +*/ + u32 cs_index_mask : SPI_CS_CNT_MAX; +/* * Likely need more hooks for more protocol options affecting
how
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/linux/spi/spi.h static inline void *spi_get_drvdata(const · line 293
Quoted 5 lines
* the controller talks to each chip, like:
include/linux/spi/spi.h +0
-0@@ -279,22 +291,33 @@ static inline void *spi_get_drvdata(const struct spi_device *spi) static inline u8 spi_get_chipselect(const struct spi_device *spi, u8idx)
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 8 lines
include/linux/spi/spi.h +1
-1{ -return spi->chip_select; +return spi->chip_select[idx]; } static inline void spi_set_chipselect(struct spi_device *spi,u8 idx, u8
chipselect)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1- spi->chip_select = chipselect; + spi->chip_select[idx] = chipselect; } static inline struct gpio_desc *spi_get_csgpiod(conststruct
spi_device*spi,u8 idx)
Quoted 7 lines
{include/linux/spi/spi.h +1
-1-return spi->cs_gpiod; +return spi->cs_gpiod[idx]; } static inline void spi_set_csgpiod(struct spi_device *spi,u8 idx, struct
gpio_desc*csgpiod)include/linux/spi/spi.h extern struct spi_device
Quoted 17 lines
{include/linux/spi/spi.h +11
-1- spi->cs_gpiod = csgpiod; + spi->cs_gpiod[idx] = csgpiod; +} + +static inline bool spi_is_csgpiod (struct spi_device *spi) { +u8 idx; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if (spi_get_csgpiod (spi, idx)) +return true; + } +return false; }/** @@ -399,6 +422,8 @@ extern struct spi_device*spi_new_ancillary_device(struct
spi_device*spi, u8 chQuoted 6 lines
include/linux/spi/spi.h +0
-0* @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use
+ * @multi_cs_cap: indicates that the SPI Controller can
+ assert/de-Quoted 3 lines
Quoted 3 lines
assert
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ * more than one chip select at once.
* @setup: updates the device mode and clocking records used bya
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
* device's SPI controller; protocol code may call this. This
* must fail if an unrecognized or unsupported mode isrequested.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
include/linux/spi/spi.h struct spi_controller { · line 592
Quoted 2 lines
include/linux/spi/spi.h +0
-0@@ -567,6 +592,11 @@ struct spi_controller {#define SPI_CONTROLLER_MUST_TX BIT(4)/* Requires tx
Quoted 26 lines
Quoted 26 lines
Quoted 6 lines
Quoted 6 lines
*/
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h struct spi_controller { · line 593
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_GPIO_SS BIT(5)/* GPIO CS must
Quoted 3 lines
Quoted 3 lines
select slave */
include/linux/spi/spi.h struct spi_controller { · line 594
Quoted 1 line
include/linux/spi/spi.h +0
-0#define SPI_CONTROLLER_SUSPENDED BIT(6)/* Currently suspended */
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/spi/spi.h +5
-0+/* +* The spi-controller has multi chip select capability and can +* assert/de-assert more than one chip select at once. +*/ +#define SPI_CONTROLLER_MULTI_CS BIT(7)/* Flag indicating if the allocation of this struct is devres-
managed */
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
bool devm_allocated;include/linux/spi/spi.h +2
-1@@ -677,7 +707,8 @@ struct spi_controller {bool rt;bool auto_runtime_pm;bool cur_msg_mapped; -char last_cs; +char last_cs[SPI_CS_CNT_MAX ]; +char last_cs_index_mask;bool last_cs_mode_high;bool fallback;struct completion xfer_completion;
Stefan Binding
Tested-byRE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI core
Quoted 339 lines
-----Original Message-----
From: Mahapatra, Amit Kumar <[email protected]>
Sent: Wednesday, November 22, 2023 1:23 PM
To: Stefan Binding <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>; [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 10 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Wednesday, November 22, 2023 4:51 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>;linux-
Quoted 3 lines
[email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPIcore
Quoted 10 lines · Amit Kumar
Quoted 7 lines
Hello Stefan,
Quoted 5 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 11:07 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected];Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
[email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, MichalQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 8 lines
Quoted 8 lines
Quoted 8 lines · Amit Kumar
Quoted 7 lines
Hello Stefan,
Quoted 5 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Tuesday, November 21, 2023 7:28 PM
To: Mahapatra, Amit Kumar <[email protected]>; [email protected]; [email protected];Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
[email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, MichalQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Amit Kumar
Quoted 6 lines
Hello Stefan,
Quoted 4 lines
-----Original Message-----
From: Stefan Binding <[email protected]>
Sent: Monday, November 20, 2023 8:00 PM
To: Mahapatra, Amit Kumar <amit.kumar-Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected]; [email protected];
[email protected]; [email protected];Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
[email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, MichalQuoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
linux- [email protected]; git (AMD-Xilinx) <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v10 1/8] spi: Add multi-cs memories support in SPI coreQuoted 1 line · Amit Kumar Mahapatra
AMD-Xilinx GQSPI controller has two advanced mode that
allows
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the controller to consider two flashes as one single device.
One of these two mode is the parallel mode in which each byte
of
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
data is stored in both devices, the even bits in the lower flash & the odd bits in the upper flash. The byte split is automatically handled by the QSPI controller.
The other mode is the stacked mode in which both the flashes share the same SPI bus but each of the device contain half of
the
Quoted 6 lines
data.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
In this mode, the controller does not follow CS requests but instead internally wires the two CS levels with the value of the most significant
address bit.
Quoted 1 line
For supporting both these modes SPI core need to be updated
for
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
providing multiple CS for a single SPI device.
For adding multi CS support the SPI device need to be aware of all the CS values. So, the "
chip_select" member in thespi_devicestructure is now an array that holds all the CS values.
spi_devicestructure now has a "cs_index_mask" member. Thisacts
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
as an index to the
chip_selectarray. If nth bit ofspi->cs_index_maskis set then the driver would assert spi-chip_select[n].
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
In parallel mode all the chip selects are asserted/de-asserted simultaneously and each byte of data is stored in both devices, the even bits in one, the odd bits in the other. The split is automatically handled by the GQSPI controller. The GQSPI controller supports a maximum of two flashes connected in parallel mode. A
SPI_CONTROLLER_MULTI_CSflag bit is addedin
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
the spi controller flags, through
ctlr->flagsthe spi core will make sure that the controller is capable of handling multiplechip
Quoted 38 lines
selects at once.
Quoted 37 lines
Quoted 37 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
For supporting multiple CS via GPIO the
cs_gpiodmember of thespi_devicestructure is now an array that holds the gpio descriptor for each chipselect.CS GPIO is not tested due to unavailability of necessary hardware
setup.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Signed-off-by Amit Kumar Mahapatra <amit.kumar-Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
---
Hello @Stefen,
We restructured the SPI core implementation, for handling arbitrary number of devices connected in parallel(multi-cs) or stackedmode.
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 4 lines
We have tested this updated patch on native-cs setup but couldn't test cs-gpio due to unavailability of a proper setup. If possible, could you please retest the cs-gpio use case with this updated patch and provide
your feedback.
Hi,
I tested this chain on 2 different systems using GPIOs as chip selects, and see the same error on both:
[ 2.842045] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already inuse
Let me know if you need any further testing.
Thanks,
Stefan Binding
Quoted 2 lines
--- drivers/spi/spi.c | 192+++++++++++++++++++++++++++++++---
Quoted 10 lines
----
Quoted 9 lines
Quoted 9 lines
--
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c static int spi_dev_check(struct
Quoted 8 lines
include/linux/spi/spi.h | 51 ++++++++--- 2 files changed, 191 insertions(+), 52 deletions(-)drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
8ead7acb99f3..ff66147ba95f100644drivers/spi/spi.c +0
-0@@ -612,10 +612,21 @@ static int spi_dev_check(structdevice
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c static int spi_dev_check(struct · line 612
Quoted 1 line
drivers/spi/spi.c +0
-0*dev, void*data)
drivers/spi/spi.c static int spi_dev_check(struct · line 618
Quoted 6 lines
drivers/spi/spi.c +0
-3{struct spi_device *spi =to_spi_device (dev);struct spi_device *new_spi = data; - - if (spi->controller == new_spi->controller && - spi_get_chipselect(spi, 0) ==
spi_get_chipselect(new_spi, 0))Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c static int spi_dev_check(struct · line 622
Quoted 8 lines
drivers/spi/spi.c +7
-1-return -EBUSY ; +int idx, nw_idx; +u8 cs, cs_nw; + +if (spi->controller == new_spi->controller) { +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = 0; nw_idx <
SPI_CS_CNT_MAX;Quoted 31 lines
Quoted 31 lines
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
nw_idx++) {
drivers/spi/spi.c static int spi_dev_check(struct · line 623
Quoted 1 line
drivers/spi/spi.c +1
-0+ cs_nw = spi_get_chipselect(spi,
nw_idx);Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Thank you for dedicating your time to test my patch.
As per my analysis the error is reported from here as we are supplying the former SPI device structure to retrieve the CS value for the new SPI devices.
To fix this, could you kindly substitute the above line with
cs_nw=spi_get_chipselect(new_spi, nw_idx);and rerun your tests?
If it works correctly, I will incorporate this fix into my upcoming series.Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Regards,
AmitHi,
I've attached my log.
I notice that you add a print toof_spi_parse_dt, however since the laptop I am using is an x86 laptop, it uses ACPI rather than OF, and I don't think this function isnt even compiled in.That’s correct, I missed it.
Upon reviewing the logs, I discovered that in the ACPI flow, I am not initializing the unused CS[] to FF, as I am doing in the OF flow. Consequently, in the ACPI flow, all the unused CS[] are automatically initialized to 0. During the__spi_add_deviceprocess, the SPI core faces difficulty distinguishing between a valid CS value of 0 and an unused CS value of 0, leading to a failure in the driver probe.Quoted 8 lines
drivers/spi/spi.c static int spi_dev_check(struct device *dev,
Quoted 8 lines
Incorporating the following modifications should resolve this issue. Kindly apply these changes on top of 1/8 and re-run the test.
drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
ff66147ba95f..d0301c17d4f8100644drivers/spi/spi.c +0
-0@@ -619,7 +619,7 @@ static int spi_dev_check(struct device *dev,void
Quoted 9 lines
*data)
drivers/spi/spi.c static int spi_dev_check(struct device *dev, void *data)
Quoted 8 lines
drivers/spi/spi.c +2
-1for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, + nw_idx);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselect %d already in use\n",Quoted 3 lines
cs_nw);Quoted 2 lines
return -EBUSY; @@ -764,6+764,7 @@ struct
spi_device*spi_new_device(structspi_controller*ctlr,
Quoted 32 lines
drivers/spi/spi.c struct spi_device
Quoted 19 lines
{ struct spi_device *proxy; int status;drivers/spi/spi.c +4
-0+u8 idx;/* * NOTE: caller did any chip->bus_num checks necessary. @@ -779,6 +780,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,WARN_ON (strlen (chip->modalias) >=sizeof (proxy->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (proxy, idx,0xFF ); +spi_set_chipselect (proxy,0 , chip->chip_select); proxy->max_speed_hz = chip->max_speed_hz;proxy->mode = chip->mode;drivers/spi/spi.c +0
-0@@ -2514,6 +2518,7 @@ struct spi_device*spi_new_ancillary_device(struct
spi_device*spi,Quoted 12 lines
drivers/spi/spi.c +1
-0struct spi_controller *ctlr = spi->controller;struct spi_device *ancillary;int rc =0 ; +u8 idx;/* Alloc an spi_device */ ancillary = spi_alloc_device(ctlr); @@ -2524,6 +2529,9 @@struct
spi_device*spi_new_ancillary_device(structspi_device*spi,strscpy(ancillary->modalias, "dummy",
sizeof(ancillary->modalias));Quoted 7 lines
drivers/spi/spi.c struct spi_device
Quoted 7 lines
drivers/spi/spi.c +3
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (ancillary, idx,0xFF ); +/* Use provided chip-select for ancillary device */ spi_set_chipselect (ancillary,0 , chip_select);@@ -2732,6 +2740,7 @@ struct spi_device*acpi_spi_device_alloc(struct
Quoted 19 lines
spi_controller*ctlr,Quoted 18 lines
drivers/spi/spi.c +1
-0struct acpi_spi_lookup lookup = {};struct spi_device *spi;int ret; +u8 idx;if (!ctlr && index ==-1 ) return ERR_PTR(-EINVAL); @@ -2767,6 +2776,9 @@ struct
spi_device*acpi_spi_device_alloc(structspi_controller*ctlr,return ERR_PTR(-ENOMEM); }drivers/spi/spi.c +3
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +ACPI_COMPANION_SET (&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode;Quoted 7 lines
Quoted 3 lines
Regards,
AmitHi,
I no longer see that error, or any errors printed from SPI, however, all of
the
Quoted 2 lines
transactions are now broken.
Every transaction seems to read back0x0, on all SPI devices, whethernative
Quoted 1 line
CS or GPIO CS, and I dont see it toggling the CS GPIO anymore.
Quoted 8 lines
I believe the issue stems from the fact that in the ACPI patch,
spi->cs_index_maskis not set to0x01. As a result, inspi_set_cs, it fails to meet the condition that governs the CS asset code snippet. In the following code diff, I've included the necessary fix along with the earlier changes on top of 1/8. I've also included a couple of debug prints to aid in further debugging in case my analysis is incorrect. Please apply these changes on top of 1/8 and re-run the test.
Hi,
I've tested this on several laptops, and it all seems to work now.
Thanks,
Stefan
Quoted 850 lines
drivers/spi/spi.c +1
-1@@ -619,7 +619,7 @@ static int spi_dev_check(struct device *dev, void *data)for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { cs =spi_get_chipselect (spi, idx);for (nw_idx =0 ; nw_idx <SPI_CS_CNT_MAX ; nw_idx++) { - cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselect %d already in use\n",cs_nw); return -EBUSY;drivers/spi/spi.c +1
-0@@ -764,6 +764,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, {struct spi_device *proxy;int status; +u8 idx;/* * NOTE: caller did any
chip->bus_numchecks necessary.drivers/spi/spi.c +3
-0@@ -779,6 +780,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,WARN_ON (strlen (chip->modalias) >=sizeof (proxy->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (proxy, idx,0xFF ); +spi_set_chipselect (proxy,0 , chip->chip_select); proxy->max_speed_hz = chip->max_speed_hz;proxy->mode = chip->mode;drivers/spi/spi.c +1
-0@@ -787,6 +791,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, proxy->dev.platform_data = (void *) chip->platform_data; proxy->controller_data = chip->controller_data; proxy->controller_state =NULL ; + proxy->cs_index_mask =0x01 ;if (chip->swnode) {status = device_add_software_node(&proxy->dev, chip-Quoted 1 line
swnode);
drivers/spi/spi.c +2
-0@@ -1024,6 +1029,8 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)if (!spi->controller->set_cs_timing && !activate)spi_delay_exec (&spi->cs_hold,NULL ); +printk ("%s() [%d] spi->cs_index_mask == [%d]\n" ,__func__, __LINE__, spi->cs_index_mask); +if (!(spi->mode &SPI_NO_CS )) {/*
* Historically ACPI has no means of the GPIO polarity anddrivers/spi/spi.c +1
-0@@ -1038,6 +1045,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force) for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) {if (((spi->cs_index_mask >> idx) &0x01 ) &&spi_get_csgpiod (spi, idx)) { +printk ("%s() [%d] idx == [%d]\n" ,__func__, __LINE__, idx);if (has_acpi_companion (&spi->dev))gpiod_set_value_cansleep(spi_get_csgpiod(spi,
idx),!enable);drivers/spi/spi.c +1
-0@@ -2514,6 +2522,7 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi, struct spi_controller *ctlr = spi->controller;struct spi_device *ancillary;int rc =0 ; +u8 idx;/* Alloc an spi_device */ ancillary = spi_alloc_device(ctlr);drivers/spi/spi.c +5
-0@@ -2524,12 +2533,16 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi, strscpy(ancillary->modalias, "dummy", sizeof(ancillary->modalias)); +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (ancillary, idx,0xFF ); +/* Use provided chip-select for ancillary device */ spi_set_chipselect (ancillary,0 , chip_select);/* Take over SPI mode/speed from SPI main device */ ancillary->max_speed_hz = spi->max_speed_hz; ancillary->mode = spi->mode; + ancillary->cs_index_mask =0x01 ;WARN_ON (!mutex_is_locked (&ctlr->add_lock));@@ -2732,6 +2745,7 @@ struct spi_device *acpi_spi_device_alloc(structspi_controller *ctlr, struct acpi_spi_lookup lookup = {};struct spi_device *spi;int ret; +u8 idx;if (!ctlr && index ==-1 )return ERR_PTR(-EINVAL);drivers/spi/spi.c +4
-0@@ -2767,12 +2781,16 @@ struct spi_device *acpi_spi_device_alloc(struct spi_controller *ctlr, return ERR_PTR(-ENOMEM); } +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +ACPI_COMPANION_SET (&spi->dev, adev); spi->max_speed_hz = lookup.max_speed_hz; spi->mode |= lookup.mode; spi->irq = lookup.irq; spi->bits_per_word = lookup.bits_per_word;spi_set_chipselect (spi,0 , lookup.chip_select); + spi->cs_index_mask =0x01 ;return spi;}
Regards,
AmitQuoted 32 lines
Thanks,
Stefan
Quoted 27 lines
Quoted 27 lines
Thanks,
Stefan
Quoted 15 lines
Quoted 5 lines
Hi,
I still see the same error:
[ 2.748546] pxa2xx-spi pxa2xx-spi.6: chipselect 0 already in useThank you for the quick testing. For further analysis I have incorporated additional debug prints on top of 1/8 patch. The corresponding diff is shared below. Kindly implement the specified changes, rerun your test and share the kernel logs.
drivers/spi/spi.c index renamed from drivers/spi/spi.c +0
-0
ff66147ba95f..7f59ea81593d100644drivers/spi/spi.c +0
-0@@ -618,8 +618,10 @@ static int spi_dev_check(struct device *dev,Quoted 1 line
void
*data)
Quoted 6 lines
if (spi->controller == new_spi->controller) { for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { cs = spi_get_chipselect(spi, idx); + printk("%s() [%d] CS[%d] = [%d]\n", + __func__, __LINE__, idx, cs); for (nw_idx = 0; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/spi/spi.c +3
-1- cs_nw =spi_get_chipselect (spi, nw_idx); + cs_nw =spi_get_chipselect (new_spi, nw_idx); +printk ("%s() [%d] CS_NEW[%d] = + [%d]\n", __func__, __LINE__, nw_idx, cs_nw);if (cs !=0xFF && cs_nw !=0xFF && cs == cs_nw) { dev_err(dev, "chipselect%d already in use\n",
cs_nw);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
return -EBUSY; @@ -659,8 +661,10 @@ static int __spi_add_device(struct spi_device *spi) */ for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) { cs = spi_get_chipselect(spi, idx); + printk("%s() [%d] CS[%d] = [%d]\n", __func__, + __LINE__, idx, cs); for (nw_idx = idx + 1; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
nw_cs = spi_get_chipselect(spi, nw_idx);+ printk("%s() [%d] CS_NEW[%d] = [%d]\n",
+__func__,__LINE__,nw_idx,nw_cs);
if (cs !=0xFF&&nw_cs!=0xFF&& cs ==nw_cs) {
dev_err(dev, "chipselect %d already in use\n",
nw_cs);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
return -EBUSY; @@ -2401,6 +2405,9@@ static int of_spi_parse_dt(struct
spi_controller*ctlr, struct
spi_deviceQuoted 9 lines
*spi,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
for (idx = 0; idx < rc; idx++) spi_set_chipselect(spi, idx, cs[idx]);drivers/spi/spi.c +4
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +printk ("%s() [%d] CS[%d] = [%d]\n" , __func__, + __LINE__, idx,spi_get_chipselect (spi, idx)); +/* spi->chip_select[i] gives the corresponding physical CS for logical
Quoted 6 lines
CS i
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
* logical CS number is represented by setting the ith bit
in spi-cs_index_mask
* So, for example, ifspi->cs_index_mask=0x01then
logical CS number is 0 andQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Regards,
AmitQuoted 5 lines
Thanks,
Stefan
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c static int spi_dev_check(struct · line 624
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (cs != 0xFF && cs_nw != 0xFF&& cs
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
==
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cs_nw) {drivers/spi/spi.c static int spi_dev_check(struct · line 625
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect%d
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
already in
Quoted 30 lines
Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
use\n",
cs_nw);Quoted 10 lines
drivers/spi/spi.c +5
-0+return -EBUSY ; + } + } + } + }return 0 ; }@@ -629,13 +640,32 @@ static int __spi_add_device(struct
spi_device*spi)
Quoted 18 lines
Quoted 18 lines
drivers/spi/spi.c
Quoted 12 lines
{ struct spi_controller *ctlr = spi->controller; struct device *dev = ctlr->dev.parent;drivers/spi/spi.c +8
-1-int status; +int status, idx, nw_idx; +u8 cs, nw_cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +/* Chipselects are numbered 0..max; validate. */ + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF && cs >= ctlr->num_chipselect) { + dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, idx),Quoted 5 lines
drivers/spi/spi.c +4
-0+ ctlr->num_chipselect); +return -EINVAL ; + } + }Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +0
-3-/* Chipselects are numbered 0..max; validate. */ -if (spi_get_chipselect (spi,0 ) >= ctlr->num_chipselect) { - dev_err(dev, "cs%d >= max %d\n",
spi_get_chipselect(spi, 0),Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +2
-2- ctlr->num_chipselect); -return -EINVAL ; +/* +* Make sure that multiple logical CS doesn't map to the same
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
physical CS.
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* For example, spi->chip_select[0] != spi->chip_select[1] and
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
so on.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +4
-0+*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); + for (nw_idx = idx + 1; nw_idx < SPI_CS_CNT_MAX;nw_idx++) {
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ nw_cs =spi_get_chipselect (spi, nw_idx); + if (cs != 0xFF && nw_cs != 0xFF && cs ==
nw_cs) {Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ dev_err(dev, "chipselect %dalready in
Quoted 51 lines
Quoted 51 lines
Quoted 24 lines
use\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
nw_cs);Quoted 5 lines
drivers/spi/spi.c +3
-0+return -EBUSY ; + } + } }Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
/* Set the bus ID string */ @@ -647,11 +677,8 @@ staticint __spi_add_device(struct
spi_device*spi)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
* its configuration.
*/
status = bus_for_each_dev(&spi_bus_type, NULL, spi,
spi_dev_check);Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/spi/spi.c
Quoted 9 lines
drivers/spi/spi.c +1
-4-if (status) { -dev_err (dev,"chipselect %d already in use\n" , -spi_get_chipselect (spi,0 )); +if (status)return status; - }/* Controller may unregister concurrently */ if (IS_ENABLED(CONFIG_SPI_DYNAMIC) && @@ -659,8+686,15 @@
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
static
drivers/spi/spi.c
Quoted 6 lines
int
__spi_add_device(struct spi_device *spi)return -ENODEV; }drivers/spi/spi.c +0
-2-if (ctlr->cs_gpiods) - spi_set_csgpiod(spi, 0, ctlr-cs_gpiods[spi_get_chipselect(spi,
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
0)]);
drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+if (ctlr->cs_gpiods) { +u8 cs; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { + cs =spi_get_chipselect (spi, idx); +if (cs !=0xFF ) + spi_set_csgpiod(spi, idx, ctlr-cs_gpiods[cs]);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/spi/spi.c +3
-1+ } + }/* * Drivers may modify this initial i/o setup, but will @@ -701,6 +735,9 @@ int spi_add_device(struct spi_device *spi) struct spi_controller *ctlr = spi->controller; int status; Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
drivers/spi/spi.c +3
-0+/* Set the bus ID string */ +spi_dev_set_name (spi); +mutex_lock (&ctlr->add_lock); status =__spi_add_device (spi); mutex_unlock(&ctlr->add_lock); @@ -942,32 +979,51@@
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
static
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 1 line
void spi_res_release(struct
spi_controller*ctlr, struct
spi_message*mesQuoted 8 lines
}/*-------------------------------------------------------------- --
--
--
-----*/drivers/spi/spi.c
Quoted 7 lines
drivers/spi/spi.c +7
-0+static inline bool spi_is_last_cs (struct spi_device *spi) { +u8 idx; +bool last = false; + +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) { +if ((spi->cs_index_mask >> idx) &0x01 ) { + if (spi->controller->last_cs[idx] ==
spi_get_chipselect(spi, idx))Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +6
-0+ last = true; + } + } +return last; +} + static void spi_set_cs(struct spi_device *spi, bool enable,bool
Quoted 10 lines
force)
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
{ bool activate = enable;drivers/spi/spi.c +1
-0+u8 idx;/* * Avoid calling into the driver (or doing delays) if the chip
select
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
* isn't actually changing from the last time this was
called.
Quoted 18 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 2 lines
*/drivers/spi/spi.c +0
-1- if (!force && ((enable && spi->controller->last_cs ==
spi_get_chipselect(spi, 0)) ||drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- (!enable && spi->controller->last_cs !=
spi_get_chipselect(spi, 0))) &&drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (!force && ((enable && spi->controller-
last_cs_index_maskQuoted 5 lines
Quoted 5 lines
==
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 4 lines
+spi-
cs_index_mask&&drivers/spi/spi.c +2
-0+ spi_is_last_cs(spi)) || + (!enable && spi->controller-
last_cs_index_maskQuoted 5 lines
Quoted 5 lines
== spi-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi.c
Quoted 3 lines
cs_index_mask&&drivers/spi/spi.c +1
-0+ !spi_is_last_cs(spi))) && (spi->controller->last_cs_mode_high == (spi->mode &
SPI_CS_HIGH)))Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
return; trace_spi_set_cs(spi, activate);drivers/spi/spi.c +0
-1- spi->controller->last_cs = enable ? spi_get_chipselect(spi,0) : -
Quoted 19 lines
1;
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ spi->controller->last_cs_index_mask = spi-
cs_index_mask;Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + spi->controller->last_cs[idx] = enable ? +spi_get_chipselect(spi,0)
Quoted 2 lines
+: -1; spi->controller->last_cs_mode_high = spi->mode &
SPI_CS_HIGH;Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +0
-1- if ((spi_get_csgpiod(spi, 0) || !spi->controller-
set_cs_timing)
&&Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
!activate)
Quoted 5 lines
drivers/spi/spi.c +0
-2-spi_delay_exec (&spi->cs_hold,NULL ); -if (spi->mode &SPI_CS_HIGH ) enable = !enable;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/spi/spi.c
Quoted 8 lines
drivers/spi/spi.c +4
-1-if (spi_get_csgpiod (spi,0 )) { +if (spi_is_csgpiod (spi)) { +if (!spi->controller->set_cs_timing && !activate) +spi_delay_exec (&spi->cs_hold,NULL ); +if (!(spi->mode &SPI_NO_CS )) {/* * Historically ACPI has no means of the GPIO
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
polarity
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
and @@
Quoted 2 lines
-979,26 +1035,38 @@ static void spi_set_cs(struct
spi_device*spi, boolenable, bool force)
Quoted 1 line
* ambiguity. That's why we use enable,
that
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
takes
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
SPI_CS_HIGHdrivers/spi/spi.c
Quoted 4 lines
* into account.
*/drivers/spi/spi.c +0
-2-if (has_acpi_companion (&spi->dev)) -gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0),
!enable);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +0
-2-else -/* Polarity handled by GPIO library */
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
-
gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0),
activate);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ for (idx = 0; idx < SPI_CS_CNT_MAX;idx++) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+ if (((spi->cs_index_mask >> idx)&
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
0x01) &&Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ spi_get_csgpiod(spi, idx)) { + if(has_acpi_companion(&spi-
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
dev))
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
!enable);
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else +/* Polarity handled by
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
GPIO
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
library */
Quoted 1 line
+
gpiod_set_value_cansleep(spi_get_csgpiod(spi, idx),
Quoted 1 line
+
activate);
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+ +if (activate) +spi_delay_exec(&spi-
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/spi/spi.c
Quoted 3 lines
cs_setup, NULL);drivers/spi/spi.c +2
-0+else +spi_delay_exec(&spi-
Quoted 51 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
cs_inactive, NULL);drivers/spi/spi.c +2
-0+ } + } }/* Some SPI masters need both GPIO CS &
slave_select*/Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
if ((spi->controller->flags &
SPI_CONTROLLER_GPIO_SS) &&Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
spi->controller->set_cs) spi->controller->set_cs(spi, !enable);drivers/spi/spi.c +4
-0+ +if (!spi->controller->set_cs_timing) { +if (activate) + spi_delay_exec(&spi->cs_setup,NULL);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+else + spi_delay_exec(&spi-
cs_inactive,Quoted 7 lines
Quoted 7 lines
NULL);
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi.c
Quoted 6 lines
drivers/spi/spi.c +1
-2+ } }else if (spi->controller->set_cs) { spi->controller->set_cs (spi, !enable); } - - if (spi_get_csgpiod(spi, 0) || !spi->controller-
set_cs_timing) {Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c +0
-5-if (activate) -spi_delay_exec (&spi->cs_setup,NULL ); -else -spi_delay_exec (&spi->cs_inactive,NULL ); - } }Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
#ifdef CONFIG_HAS_DMAdrivers/spi/spi.c +0
-0@@ -2222,8 +2290,8 @@ static voidof_spi_parse_dt_cs_delay(struct
device_node*nc,Quoted 2 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr,
structspi_device*spi,
Quoted 11 lines
Quoted 11 lines
drivers/spi/spi.c
Quoted 10 lines
struct
device_node*nc)
{drivers/spi/spi.c +3
-2-u32 value; -int rc; +u32 value, cs[SPI_CS_CNT_MAX ]; +int rc, idx;/* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) @@ -2295,14 +2363 ,52 @@
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
static int of_spi_parse_dt(struct
spi_controller*ctlr, structspi_device*spi,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c
Quoted 5 lines
return 0; }drivers/spi/spi.c +2
-0+if (ctlr->num_chipselect >SPI_CS_CNT_MAX ) { + dev_err(&ctlr->dev, "No. of CS is more than max.no.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
of
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
supported CS\n");
drivers/spi/spi.c
Quoted 5 lines
drivers/spi/spi.c +5
-0+return -EINVAL ; + } + +/* +* Zero(0) is a valid physical CS value and can be located at any
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+* logical CS in the spi->chip_select[]. If all the physical CS +* are initialized to 0 then It would be difficult to differentiate
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/spi/spi.c
Quoted 1 line
drivers/spi/spi.c +1
-0+* between a valid physical CS 0 & an unused logical CS whose
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
physical
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ * CS can be 0. As a solution to this issue initialize all the +CS to
0xFF.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +2
-0+ * Now all the unused logical CS will have 0xFF physical CS +value & canbe
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/spi/spi.c
Quoted 9 lines
drivers/spi/spi.c +6
-2+* ignore while performing physical CS validity checks. +*/ +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) +spi_set_chipselect (spi, idx,0xFF ); +/* Device address */ - rc =of_property_read_u32 (nc,"reg" , &value); -if (rc) { + rc = of_property_read_variable_u32_array(nc, "reg",&cs[0],
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1,
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
SPI_CS_CNT_MAX);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c
Quoted 2 lines
drivers/spi/spi.c +1
-0+if (rc <0 ) { dev_err(&ctlr->dev, "%pOF has no valid 'reg'property
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(%d)\n",
drivers/spi/spi.c
Quoted 6 lines
nc, rc); return rc; }drivers/spi/spi.c +2
-1-spi_set_chipselect (spi,0 , value); +if (rc > ctlr->num_chipselect) { + dev_err(&ctlr->dev, "%pOF has number of CS >ctlr-
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi.c
Quoted 7 lines
num_chipselect(%d)\n",drivers/spi/spi.c +6
-0+ nc, rc); +return rc; + } +if ((of_property_read_bool (nc,"parallel-memories" )) && + (!(ctlr->flags &SPI_CONTROLLER_MULTI_CS ))) { + dev_err(&ctlr->dev, "SPI controller doesn'tsupport
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
multi
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
CS\n");
drivers/spi/spi.c
Quoted 6 lines
drivers/spi/spi.c +6
-0+return -EINVAL ; + } +for (idx =0 ; idx < rc; idx++) +spi_set_chipselect (spi, idx, cs[idx]); + +/* spi->chip_select[i] gives the corresponding physical CS for
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
+logical CS
i
drivers/spi/spi.c
Quoted 4 lines
drivers/spi/spi.c +2
-0+ * logical CS number is represented by setting the ith bit in +spi-
cs_index_maskdrivers/spi/spi.c +1
-0+* So, for example, if spi->cs_index_mask = 0x01 then logical
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
CS
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
number is 0 and
drivers/spi/spi.c
Quoted 3 lines
drivers/spi/spi.c +3
-0+* spi->chip_select[0] will give the physical CS. +* By default spi->chip_select[0] will hold the physical CS +number so, set
Quoted 4 lines
drivers/spi/spi.c +3
-0+* spi->cs_index_mask as 0x01. +*/ + spi->cs_index_mask =0x01 ;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* Device speed */ if (!of_property_read_u32(nc, "spi-max-frequency",&value)) @@
-3100,6 +3206,7 @@ int spi_register_controller(structspi_controller*ctlr)
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 9 lines
struct boardinfo *bi; int first_dynamic; int status;drivers/spi/spi.c +1
-0+int idx;if (!dev)return -ENODEV ;@@ -3164,7 +3271,8 @@ int spi_register_controller(struct
spi_controller*ctlr)
drivers/spi/spi.c static int __spi_validate(struct · line 3997
Quoted 11 lines
} /* Setting last_cs to -1 means no chip selected */drivers/spi/spi.c +2
-1- ctlr->last_cs =-1 ; +for (idx =0 ; idx <SPI_CS_CNT_MAX ; idx++) + ctlr->last_cs[idx] =-1 ; status =device_add (&ctlr->dev);if (status <0 )@@ -3889,7 +3997,7 @@ static int __spi_validate(struct spi_device *spi,struct
spi_message*message)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/spi/spi.c static int __spi_validate(struct · line 4000
Quoted 3 lines
drivers/spi/spi.c +0
-0* cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits &
SPI_CS_WORD) ||drivers/spi/spi.c static int __spi_validate(struct · line 3893
Quoted 1 line
drivers/spi/spi.c +0
-1- spi_get_csgpiod(spi, 0))){
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/spi/spi.c static int __spi_validate(struct · line 4002
Quoted 2 lines
drivers/spi/spi.c +1
-0+ spi_is_csgpiod(spi))) { size_t maxsize = BITS_TO_BYTES(spi-
bits_per_word);Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/spi/spi.c +0
-0int ret;include/linux/spi/spi.h +0
-0@@ -20,6 +20,9 @@#include <uapi/linux/spi/spi.h> Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
include/linux/spi/spi.h
Quoted 7 lines
include/linux/spi/spi.h +4
-0+/* Max no. of CS supported per spi device */ #define +SPI_CS_CNT_MAX +4 +struct dma_chan ;struct software_node ; struct ptp_system_timestamp; @@ -132,7 +135,8 @@extern
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
void
spi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* @max_speed_hz: Maximum clock rate to be used with this
chip
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
* (on this board); may be changed by the device's driver.
* The spi_transfer.speed_hz can override this for eachtransfer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
- * @chip_select: Chipselect, distinguishing chips handled by
@controller.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ * @chip_select: Array of physical chipselect, spi->chipselect[i]
gives
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ * the corresponding physical CS for logical CS i.
* @mode: The spi mode defines how data is clocked out andin.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
* This may be changed by the device's driver.
* The "active low" default for chipselect mode can beoverridden
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h extern void
Quoted 1 line
include/linux/spi/spi.h +0
-0@@ -157,8 +161,8 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
include/linux/spi/spi.h +0
-0* the device will bind to the named driver and only the named
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
driver.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/linux/spi/spi.h extern void · line 162
Quoted 1 line
include/linux/spi/spi.h +0
-0* Do not set directly, because core frees it; use
driver_set_override()toQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/spi/spi.h +0
-1* set or clear it. -* @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL
when
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
- * not using a GPIO line)
+ * @cs_gpiod: Array of GPIO descriptors of the corresponding
+ chipselectQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lines
Quoted 5 lines
+ * (optional, NULL when not using a GPIO line)
* @word_delay: delay to be inserted between consecutive
* words of a transfer
* @cs_setup: delay to be introduced by the controller
after CS is asserted @@ -167,6 +171,7 @@ extern voidspi_transfer_cs_change_delay_exec(struct
spi_message*msg,Quoted 1 line
* deasserted. If @cs_change_delay is used from
@spi_transfer,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
then
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
the
Quoted 6 lines
* two delays will be added up.
* @pcpu_statistics: statistics for thespi_device
+ * @cs_index_mask: Bit mask of the active chipselect(s) in the
+ chipselect array
*
* A @spi_device is used to interchange data between an SPIslave
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
include/linux/spi/spi.h struct spi_device { · line 188
Quoted 4 lines
* (usually a discrete chip) and CPU memory.
include/linux/spi/spi.h +0
-0@@ -182,7 +187,7 @@ struct spi_device {struct spi_controller *controller;struct spi_controller *master;/* Compatibility layer
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
*/
6 lines not shown · raw message
129 lines not shown · raw message
Quoted 4 lines
4 lines not shown · raw message
3 lines not shown · raw message
Part of this message is not shown here. View the raw message.
PATCH v10 2/8 mtd: spi-nor: Convert macros with inline functions
In reply to Amit Kumar MahapatraIn further patches the nor->params references in spi_nor_otp_region_len(nor) & spi_nor_otp_n_regions(nor) macros will be replaced with spi_nor_get_params() API. To make the transition smoother, first converting the macros into static inline functions.
--- drivers/mtd/spi-nor/otp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/otp.c +21 -2
@@ -11,8 +11,27 @@#include "core.h" -#define spi_nor_otp_region_len (nor) ((nor)->params->otp.org->len) -#define spi_nor_otp_n_regions (nor) ((nor)->params->otp.org->n_regions) +/** +* spi_nor_otp_region_len() - get size of one OTP region in bytes +* @nor: pointer to 'struct spi_nor' +* +* Return: size of one OTP region in bytes +*/ +static inline unsigned int spi_nor_otp_region_len (struct spi_nor *nor) +{ +return nor->params->otp.org->len; +} + +/** +* spi_nor_otp_n_regions() - get number of individual OTP regions +* @nor: pointer to 'struct spi_nor' +* +* Return: number of individual OTP regions +*/ +static inline unsigned int spi_nor_otp_n_regions (struct spi_nor *nor) +{ +return nor->params->otp.org->n_regions; +}/** * spi_nor_otp_read_secr() - read security register
Signature · 1 line
2.17.1
PATCH v10 3/8 mtd: spi-nor: Add APIs to set/get nor->params
In reply to Amit Kumar MahapatraSupporting multi-cs in spi-nor would require the *params member of struct spi_nor to be an array. To make the transition smoother introduced spi_nor_get_params() & spi_nor_set_params() APIs to get & set nor->params, added a new local variable (struct spi_nor_flash_parameter *params) to hold the return value of the spi_nor_get_params() function call and replaced all nor->params references with the "params".
While adding multi-cs support in further patches the *params member of the spi_nor structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., nor->params[idx].
--- drivers/mtd/spi-nor/atmel.c | 17 ++-- drivers/mtd/spi-nor/core.c | 136 ++++++++++++++++++++----------- drivers/mtd/spi-nor/debugfs.c | 4 +- drivers/mtd/spi-nor/gigadevice.c | 4 +- drivers/mtd/spi-nor/issi.c | 11 ++- drivers/mtd/spi-nor/macronix.c | 10 ++- drivers/mtd/spi-nor/micron-st.c | 30 ++++--- drivers/mtd/spi-nor/otp.c | 29 +++++-- drivers/mtd/spi-nor/sfdp.c | 33 ++++---- drivers/mtd/spi-nor/spansion.c | 57 +++++++------ drivers/mtd/spi-nor/sst.c | 7 +- drivers/mtd/spi-nor/swp.c | 25 ++++-- drivers/mtd/spi-nor/winbond.c | 2 +- drivers/mtd/spi-nor/xilinx.c | 18 ++-- include/linux/mtd/spi-nor.h | 10 +++ 15 files changed, 257 insertions(+), 136 deletions(-)
drivers/mtd/spi-nor/atmel.c +12 -5
@@ -23,10 +23,11 @@ static int at25fs_nor_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)static int at25fs_nor_unlock (struct spi_nor *nor,loff_t ofs,uint64_t len) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );int ret;/* We only support unlocking the whole flash array */ -if (ofs || len != nor->params->size) +if (ofs || len != params->size)return -EINVAL ;/* Write 0x00 to the status register to disable write protection */
@@ -50,7 +51,9 @@ static const struct spi_nor_locking_ops at25fs_nor_locking_ops = {static int at25fs_nor_late_init (struct spi_nor *nor) { - nor->params->locking_ops = &at25fs_nor_locking_ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->locking_ops = &at25fs_nor_locking_ops;return 0 ; }
@@ -71,11 +74,12 @@ static const struct spi_nor_fixups at25fs_nor_fixups = {static int atmel_nor_set_global_protection (struct spi_nor *nor,loff_t ofs,uint64_t len,bool is_protect) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );int ret;u8 sr;/* We only support locking the whole flash array */ -if (ofs || len != nor->params->size) +if (ofs || len != params->size)return -EINVAL ; ret =spi_nor_read_sr (nor, nor->bouncebuf);
@@ -133,9 +137,10 @@ static int atmel_nor_global_unprotect(struct spi_nor *nor, loff_t ofs,static int atmel_nor_is_global_protected (struct spi_nor *nor,loff_t ofs,uint64_t len) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );int ret; -if (ofs >= nor->params->size || (ofs + len) > nor->params->size) +if (ofs >= params->size || (ofs + len) > params->size)return -EINVAL ; ret =spi_nor_read_sr (nor, nor->bouncebuf);
@@ -153,7 +158,9 @@ static const struct spi_nor_locking_ops atmel_nor_global_protection_ops = {static int atmel_nor_global_protection_late_init (struct spi_nor *nor) { - nor->params->locking_ops = &atmel_nor_global_protection_ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->locking_ops = &atmel_nor_global_protection_ops;return 0 ; }
drivers/mtd/spi-nor/core.c +88 -48
484 lines not on this page · raw message
drivers/mtd/spi-nor/debugfs.c +2 -2
@@ -76,7 +76,7 @@ static void spi_nor_print_flags(struct seq_file *s, unsigned long flags,static int spi_nor_params_show (struct seq_file *s,void *data) {struct spi_nor *nor = s->private; -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct spi_nor_erase_map *erase_map = ¶ms->erase_map;struct spi_nor_erase_region *region;const struct flash_info *info = nor->info;
@@ -184,7 +184,7 @@ static void spi_nor_print_pp_cmd(struct seq_file *s,static int spi_nor_capabilities_show (struct seq_file *s,void *data) {struct spi_nor *nor = s->private; -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );u32 hwcaps = params->hwcaps.mask;int i, cmd;
drivers/mtd/spi-nor/gigadevice.c +3 -1
@@ -13,6 +13,8 @@ gd25q256_post_bfpt(struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { + struct spi_nor_flash_parameter *params = spi_nor_get_params(nor, 0); +/* * GD25Q256C supports the first version of JESD216 which does not define * the Quad Enable methods. Overwrite the default Quad Enable method.
@@ -24,7 +26,7 @@ gd25q256_post_bfpt(struct spi_nor *nor,*/ if (bfpt_header->major ==SFDP_JESD216_MAJOR && bfpt_header->minor ==SFDP_JESD216_MINOR ) - nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; + params->quad_enable = spi_nor_sr1_bit6_quad_enable;return 0 ; }
drivers/mtd/spi-nor/issi.c +8 -3
@@ -13,6 +13,8 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { + struct spi_nor_flash_parameter *params = spi_nor_get_params(nor, 0); +/* * IS25LP256 supports 4B opcodes, but the BFPT advertises * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY.
@@ -20,7 +22,7 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,*/ if ((bfpt->dwords[SFDP_DWORD (1 )] &BFPT_DWORD1_ADDRESS_BYTES_MASK ) ==BFPT_DWORD1_ADDRESS_BYTES_3_ONLY ) - nor->params->addr_nbytes =4 ; + params->addr_nbytes =4 ;return 0 ; }
@@ -31,7 +33,8 @@ static const struct spi_nor_fixups is25lp256_fixups = {static int pm25lv_nor_late_init (struct spi_nor *nor) { -struct spi_nor_erase_map *map = &nor->params->erase_map; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +struct spi_nor_erase_map *map = ¶ms->erase_map;int i;/* The PM25LV series has a different 4k sector erase opcode */
@@ -131,7 +134,9 @@ static const struct flash_info issi_nor_parts[] = {static void issi_nor_default_init (struct spi_nor *nor) { - nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->quad_enable = spi_nor_sr1_bit6_quad_enable; }static const struct spi_nor_fixups issi_fixups = {
drivers/mtd/spi-nor/macronix.c +7 -3
@@ -187,13 +187,17 @@ static const struct flash_info macronix_nor_parts[] = {static void macronix_nor_default_init (struct spi_nor *nor) { - nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->quad_enable = spi_nor_sr1_bit6_quad_enable; }static int macronix_nor_late_init (struct spi_nor *nor) { -if (!nor->params->set_4byte_addr_mode) - nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_en4b_ex4b; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + +if (!params->set_4byte_addr_mode) + params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_en4b_ex4b;return 0 ; }
drivers/mtd/spi-nor/micron-st.c +19 -11
@@ -49,10 +49,11 @@static int micron_st_nor_octal_dtr_en (struct spi_nor *nor) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct spi_mem_op op;u8 *buf = nor->bouncebuf;int ret; -u8 addr_mode_nbytes = nor->params->addr_mode_nbytes; +u8 addr_mode_nbytes = params->addr_mode_nbytes;/* Use 20 dummy cycles for memory array reads. */ *buf =20 ;
@@ -128,27 +129,31 @@ static int micron_st_nor_set_octal_dtr(struct spi_nor *nor, bool enable)static void mt35xu512aba_default_init (struct spi_nor *nor) { - nor->params->set_octal_dtr = micron_st_nor_set_octal_dtr; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->set_octal_dtr = micron_st_nor_set_octal_dtr; }static int mt35xu512aba_post_sfdp_fixup (struct spi_nor *nor) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +/* Set the Fast Read settings. */ - nor->params->hwcaps.mask |=SNOR_HWCAPS_READ_8_8_8_DTR ; -spi_nor_set_read_settings (&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR ], + params->hwcaps.mask |=SNOR_HWCAPS_READ_8_8_8_DTR ; +spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_8_8_8_DTR ],0 ,20 ,SPINOR_OP_MT_DTR_RD ,SNOR_PROTO_8_8_8_DTR ); nor->cmd_ext_type =SPI_NOR_EXT_REPEAT ; - nor->params->rdsr_dummy =8 ; - nor->params->rdsr_addr_nbytes =0 ; + params->rdsr_dummy =8 ; + params->rdsr_addr_nbytes =0 ;/* * The BFPT quad enable field is set to a reserved value so the quad * enable function is ignored by spi_nor_parse_bfpt(). Make sure we * disable it. */ - nor->params->quad_enable =NULL ; + params->quad_enable =NULL ;return 0 ; }
@@ -457,14 +462,15 @@ static const struct flash_info st_nor_parts[] = {*/ static int micron_st_nor_read_fsr (struct spi_nor *nor,u8 *fsr) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );int ret;if (nor->spimem) {struct spi_mem_op op =MICRON_ST_RDFSR_OP (fsr);if (nor->reg_proto ==SNOR_PROTO_8_8_8_DTR ) { - op.addr.nbytes = nor->params->rdsr_addr_nbytes; - op.dummy.nbytes = nor->params->rdsr_dummy; + op.addr.nbytes = params->rdsr_addr_nbytes; + op.dummy.nbytes = params->rdsr_dummy;/* * We don't want to read only one byte in DTR mode. So, * read 2 and then discard the second byte.
@@ -567,14 +573,16 @@ static int micron_st_nor_ready(struct spi_nor *nor)static void micron_st_nor_default_init (struct spi_nor *nor) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + nor->flags |=SNOR_F_HAS_LOCK ; nor->flags &= ~SNOR_F_HAS_16BIT_SR ; - nor->params->quad_enable =NULL ; + params->quad_enable =NULL ; }static int micron_st_nor_late_init (struct spi_nor *nor) { -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );if (nor->info->mfr_flags &USE_FSR ) params->ready = micron_st_nor_ready;
drivers/mtd/spi-nor/otp.c +20 -9
@@ -19,7 +19,9 @@*/ static inline unsigned int spi_nor_otp_region_len (struct spi_nor *nor) { -return nor->params->otp.org->len; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + +return params->otp.org->len; }/**
@@ -30,7 +32,9 @@ static inline unsigned int spi_nor_otp_region_len(struct spi_nor *nor)*/ static inline unsigned int spi_nor_otp_n_regions (struct spi_nor *nor) { -return nor->params->otp.org->n_regions; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + +return params->otp.org->n_regions; }/**
@@ -241,7 +245,8 @@ int spi_nor_otp_is_locked_sr2(struct spi_nor *nor, unsigned int region)static loff_t spi_nor_otp_region_start (const struct spi_nor *nor,unsigned int region) { -const struct spi_nor_otp_organization *org = nor->params->otp.org; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +const struct spi_nor_otp_organization *org = params->otp.org;return org->base + region * org->offset; }
@@ -266,7 +271,8 @@ static int spi_nor_mtd_otp_info(struct mtd_info *mtd, size_t len, size_t *retlen, struct otp_info *buf) { struct spi_nor *nor = mtd_to_spi_nor(mtd); -const struct spi_nor_otp_ops *ops = nor->params->otp.ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +const struct spi_nor_otp_ops *ops = params->otp.ops;unsigned int n_regions =spi_nor_otp_n_regions (nor);unsigned int i;int ret, locked;
@@ -303,7 +309,8 @@ static int spi_nor_mtd_otp_info(struct mtd_info *mtd, size_t len,static int spi_nor_mtd_otp_range_is_locked (struct spi_nor *nor,loff_t ofs,size_t len) { -const struct spi_nor_otp_ops *ops = nor->params->otp.ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +const struct spi_nor_otp_ops *ops = params->otp.ops;unsigned int region;int locked;
@@ -328,7 +335,8 @@ static int spi_nor_mtd_otp_read_write(struct mtd_info *mtd, loff_t ofs, const u8 *buf, bool is_write) {struct spi_nor *nor =mtd_to_spi_nor (mtd); -const struct spi_nor_otp_ops *ops = nor->params->otp.ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +const struct spi_nor_otp_ops *ops = params->otp.ops;const size_t rlen =spi_nor_otp_region_len (nor);loff_t rstart, rofs;unsigned int region;
@@ -414,7 +422,8 @@ static int spi_nor_mtd_otp_write(struct mtd_info *mtd, loff_t to, size_t len,static int spi_nor_mtd_otp_erase (struct mtd_info *mtd,loff_t from,size_t len) {struct spi_nor *nor =mtd_to_spi_nor (mtd); -const struct spi_nor_otp_ops *ops = nor->params->otp.ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +const struct spi_nor_otp_ops *ops = params->otp.ops;const size_t rlen =spi_nor_otp_region_len (nor);unsigned int region;loff_t rstart;
@@ -467,7 +476,8 @@ static int spi_nor_mtd_otp_erase(struct mtd_info *mtd, loff_t from, size_t len)static int spi_nor_mtd_otp_lock (struct mtd_info *mtd,loff_t from,size_t len) {struct spi_nor *nor =mtd_to_spi_nor (mtd); -const struct spi_nor_otp_ops *ops = nor->params->otp.ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +const struct spi_nor_otp_ops *ops = params->otp.ops;const size_t rlen =spi_nor_otp_region_len (nor);unsigned int region;int ret;
@@ -501,9 +511,10 @@ static int spi_nor_mtd_otp_lock(struct mtd_info *mtd, loff_t from, size_t len)void spi_nor_set_mtd_otp_ops (struct spi_nor *nor) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct mtd_info *mtd = &nor->mtd; -if (!nor->params->otp.ops) +if (!params->otp.ops)return ;if (WARN_ON (!is_power_of_2 (spi_nor_otp_region_len (nor))))
drivers/mtd/spi-nor/sfdp.c +19 -14
@@ -436,7 +436,7 @@ static void spi_nor_regions_sort_erase_types(struct spi_nor_erase_map *map)static int spi_nor_parse_bfpt (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header) { -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct spi_nor_erase_map *map = ¶ms->erase_map;struct spi_nor_erase_type *erase_type = map->erase_type;struct sfdp_bfpt bfpt;
@@ -661,6 +661,8 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,*/ static u8 spi_nor_smpt_addr_nbytes (const struct spi_nor *nor,const u32 settings) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +switch (settings &SMPT_CMD_ADDRESS_LEN_MASK ) {case SMPT_CMD_ADDRESS_LEN_0 :return 0 ;
@@ -670,7 +672,7 @@ static u8 spi_nor_smpt_addr_nbytes(const struct spi_nor *nor, const u32 settingsreturn 4 ;case SMPT_CMD_ADDRESS_LEN_USE_CURRENT :default : -return nor->params->addr_mode_nbytes; +return params->addr_mode_nbytes; } }
@@ -822,7 +824,8 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region,static int spi_nor_init_non_uniform_erase_map (struct spi_nor *nor,const u32 *smpt) { -struct spi_nor_erase_map *map = &nor->params->erase_map; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +struct spi_nor_erase_map *map = ¶ms->erase_map;struct spi_nor_erase_type *erase = map->erase_type;struct spi_nor_erase_region *region;u64 offset;
@@ -910,6 +913,7 @@ static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,static int spi_nor_parse_smpt (struct spi_nor *nor,const struct sfdp_parameter_header *smpt_header) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );const u32 *sector_map;u32 *smpt;size_t len;
@@ -940,7 +944,7 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,if (ret) goto out; -spi_nor_regions_sort_erase_types (&nor->params->erase_map); +spi_nor_regions_sort_erase_types (¶ms->erase_map);/* fall through */ out:kfree (smpt);
@@ -980,7 +984,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, { 0u /* not used */, BIT(11) }, { 0u /* not used */, BIT(12) }, }; -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct spi_nor_pp_command *params_pp = params->page_programs;struct spi_nor_erase_map *map = ¶ms->erase_map;struct spi_nor_erase_type *erase_type = map->erase_type;
@@ -1143,6 +1147,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,static int spi_nor_parse_profile1 (struct spi_nor *nor,const struct sfdp_parameter_header *profile1_header) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );u32 *dwords, addr;size_t len;int ret;
@@ -1165,14 +1170,14 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,/* Set the Read Status Register dummy cycles and dummy address bytes. */ if (dwords[SFDP_DWORD (1 )] &PROFILE1_DWORD1_RDSR_DUMMY ) - nor->params->rdsr_dummy =8 ; + params->rdsr_dummy =8 ;else - nor->params->rdsr_dummy =4 ; + params->rdsr_dummy =4 ;if (dwords[SFDP_DWORD (1 )] &PROFILE1_DWORD1_RDSR_ADDR_BYTES ) - nor->params->rdsr_addr_nbytes =4 ; + params->rdsr_addr_nbytes =4 ;else - nor->params->rdsr_addr_nbytes =0 ; + params->rdsr_addr_nbytes =0 ;/* * We don't know what speed the controller is running at. Find the
@@ -1201,8 +1206,8 @@ static int spi_nor_parse_profile1(struct spi_nor *nor, dummy =round_up (dummy,2 );/* Update the fast read settings. */ - nor->params->hwcaps.mask |=SNOR_HWCAPS_READ_8_8_8_DTR ; -spi_nor_set_read_settings (&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR ], + params->hwcaps.mask |=SNOR_HWCAPS_READ_8_8_8_DTR ; +spi_nor_set_read_settings (¶ms->reads[SNOR_CMD_READ_8_8_8_DTR ],0 , dummy, opcode,SNOR_PROTO_8_8_8_DTR );
@@ -1210,7 +1215,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,* Page Program is "Required Command" in the xSPI Profile 1.0. Update * the params->hwcaps.mask here. */ - nor->params->hwcaps.mask |=SNOR_HWCAPS_PP_8_8_8_DTR ; + params->hwcaps.mask |=SNOR_HWCAPS_PP_8_8_8_DTR ; out:kfree (dwords);
@@ -1231,7 +1236,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,static int spi_nor_parse_sccr (struct spi_nor *nor,const struct sfdp_parameter_header *sccr_header) { -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );u32 *dwords, addr;size_t len;int ret;
@@ -1282,7 +1287,7 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,static int spi_nor_parse_sccr_mc (struct spi_nor *nor,const struct sfdp_parameter_header *sccr_mc_header) { -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );u32 *dwords, addr;u8 i, n_dice;size_t len;
drivers/mtd/spi-nor/spansion.c +34 -23
224 lines not on this page · raw message
drivers/mtd/spi-nor/sst.c +5 -2
@@ -20,10 +20,11 @@ static int sst26vf_nor_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)static int sst26vf_nor_unlock (struct spi_nor *nor,loff_t ofs,uint64_t len) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );int ret;/* We only support unlocking the entire flash array. */ -if (ofs !=0 || len != nor->params->size) +if (ofs !=0 || len != params->size)return -EINVAL ; ret =spi_nor_read_cr (nor, nor->bouncebuf);
@@ -51,7 +52,9 @@ static const struct spi_nor_locking_ops sst26vf_nor_locking_ops = {static int sst26vf_nor_late_init (struct spi_nor *nor) { - nor->params->locking_ops = &sst26vf_nor_locking_ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->locking_ops = &sst26vf_nor_locking_ops;return 0 ; }
drivers/mtd/spi-nor/swp.c +18 -7
@@ -39,7 +39,8 @@ static u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor)* the flash. For now, we need to have that ugly default. */ unsigned int sector_size = nor->info->sector_size ?:SPI_NOR_DEFAULT_SECTOR_SIZE ; -u64 n_sectors =div_u64 (nor->params->size, sector_size); +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +u64 n_sectors =div_u64 (params->size, sector_size);u8 mask =spi_nor_get_sr_bp_mask (nor);/* Reserved one for "protect none" and one for "protect all". */
@@ -350,11 +351,14 @@ static const struct spi_nor_locking_ops spi_nor_sr_locking_ops = {void spi_nor_init_default_locking_ops (struct spi_nor *nor) { - nor->params->locking_ops = &spi_nor_sr_locking_ops; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->locking_ops = &spi_nor_sr_locking_ops; }static int spi_nor_lock (struct mtd_info *mtd,loff_t ofs,uint64_t len) { +struct spi_nor_flash_parameter *params;struct spi_nor *nor =mtd_to_spi_nor (mtd);int ret;
@@ -362,7 +366,8 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)if (ret)return ret; - ret = nor->params->locking_ops->lock (nor, ofs, len); + params =spi_nor_get_params (nor,0 ); + ret = params->locking_ops->lock (nor, ofs, len);spi_nor_unlock_and_unprep (nor);return ret;
@@ -370,6 +375,7 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)static int spi_nor_unlock (struct mtd_info *mtd,loff_t ofs,uint64_t len) { +struct spi_nor_flash_parameter *params;struct spi_nor *nor =mtd_to_spi_nor (mtd);int ret;
@@ -377,7 +383,8 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)if (ret)return ret; - ret = nor->params->locking_ops->unlock (nor, ofs, len); + params =spi_nor_get_params (nor,0 ); + ret = params->locking_ops->unlock (nor, ofs, len);spi_nor_unlock_and_unprep (nor);return ret;
@@ -385,6 +392,7 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)static int spi_nor_is_locked (struct mtd_info *mtd,loff_t ofs,uint64_t len) { +struct spi_nor_flash_parameter *params;struct spi_nor *nor =mtd_to_spi_nor (mtd);int ret;
@@ -392,7 +400,8 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)if (ret)return ret; - ret = nor->params->locking_ops->is_locked (nor, ofs, len); + params =spi_nor_get_params (nor,0 ); + ret = params->locking_ops->is_locked (nor, ofs, len);spi_nor_unlock_and_unprep (nor);return ret;
@@ -412,6 +421,7 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)*/ void spi_nor_try_unlock_all (struct spi_nor *nor) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );int ret;if (!(nor->flags &SNOR_F_HAS_LOCK ))
@@ -419,16 +429,17 @@ void spi_nor_try_unlock_all(struct spi_nor *nor)dev_dbg (nor->dev,"Unprotecting entire flash array\n" ); - ret =spi_nor_unlock (&nor->mtd,0 , nor->params->size); + ret =spi_nor_unlock (&nor->mtd,0 , params->size);if (ret)dev_dbg (nor->dev,"Failed to unlock the entire flash memory array\n" ); }void spi_nor_set_mtd_locking_ops (struct spi_nor *nor) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct mtd_info *mtd = &nor->mtd; -if (!nor->params->locking_ops) +if (!params->locking_ops)return ; mtd->_lock = spi_nor_lock;
drivers/mtd/spi-nor/winbond.c +1 -1
@@ -303,7 +303,7 @@ static const struct spi_nor_otp_ops winbond_nor_otp_ops = {static int winbond_nor_late_init (struct spi_nor *nor) { -struct spi_nor_flash_parameter *params = nor->params; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );if (params->otp.org) params->otp.ops = &winbond_nor_otp_ops;
drivers/mtd/spi-nor/xilinx.c +11 -7
@@ -50,7 +50,8 @@ static const struct flash_info xilinx_nor_parts[] = {*/ static u32 s3an_nor_convert_addr (struct spi_nor *nor,u32 addr) { -u32 page_size = nor->params->page_size; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +u32 page_size = params->page_size;u32 offset, page; offset = addr % page_size;
@@ -110,6 +111,7 @@ static int xilinx_nor_sr_ready(struct spi_nor *nor)static int xilinx_nor_setup (struct spi_nor *nor,const struct spi_nor_hwcaps *hwcaps) { +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );u32 page_size;int ret;
@@ -135,14 +137,14 @@ static int xilinx_nor_setup(struct spi_nor *nor,*/ if (nor->bouncebuf[0 ] &XSR_PAGESIZE ) {/* Flash in Power of 2 mode */ - page_size = (nor->params->page_size ==264 ) ?256 :512 ; - nor->params->page_size = page_size; + page_size = (params->page_size ==264 ) ?256 :512 ; + params->page_size = page_size; nor->mtd.writebufsize = page_size; - nor->params->size = nor->info->size; + params->size = nor->info->size; nor->mtd.erasesize =8 * page_size; }else {/* Flash in Default addressing mode */ - nor->params->convert_addr = s3an_nor_convert_addr; + params->convert_addr = s3an_nor_convert_addr; nor->mtd.erasesize = nor->info->sector_size; }
@@ -151,8 +153,10 @@ static int xilinx_nor_setup(struct spi_nor *nor,static int xilinx_nor_late_init (struct spi_nor *nor) { - nor->params->setup = xilinx_nor_setup; - nor->params->ready = xilinx_nor_sr_ready; +struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); + + params->setup = xilinx_nor_setup; + params->ready = xilinx_nor_sr_ready;return 0 ; }
include/linux/mtd/spi-nor.h +10 -0
@@ -433,6 +433,16 @@ static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)return mtd_get_of_node (&nor->mtd); } +static inline struct spi_nor_flash_parameter *spi_nor_get_params (const struct spi_nor *nor,u8 idx) +{ +return nor->params; +} + +static inline void spi_nor_set_params (struct spi_nor *nor,u8 idx, +struct spi_nor_flash_parameter *params) +{ + nor->params = params; +}/** * spi_nor_scan() - scan the SPI NOR * @nor: the spi_nor structure
Signature · 1 line
2.17.1
PATCH v10 4/8 mtd: spi-nor: Move write enable inside specific write & erase APIs
In reply to Amit Kumar MahapatraIn most of the register write operations the spi_nor_write_enable is called from within that API from where spi_mem APIs are called. Follwoing the same trend move the write enable API from spi_nor_write & spi_nor_erase APIs to the respective write & erase APIs.
--- drivers/mtd/spi-nor/core.c | 40 ++++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/mtd/spi-nor/core.c +15 -25
@@ -301,6 +301,12 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t to,ssize_t spi_nor_write_data (struct spi_nor *nor,loff_t to,size_t len,const u8 *buf) { +int ret; + + ret =spi_nor_write_enable (nor); +if (ret) +return ret; +if (nor->spimem)return spi_nor_spimem_write_data (nor, to, len, buf);
@@ -1074,6 +1080,10 @@ static int spi_nor_erase_chip(struct spi_nor *nor)dev_dbg (nor->dev," %lldKiB\n" , (long long )(nor->mtd.size >>10 )); + ret =spi_nor_write_enable (nor); +if (ret) +return ret; +if (nor->spimem) {struct spi_mem_op op =SPI_NOR_CHIP_ERASE_OP ;
@@ -1481,10 +1491,14 @@ static u32 spi_nor_convert_addr(struct spi_nor *nor, loff_t addr)*/ int spi_nor_erase_sector (struct spi_nor *nor,u32 addr) { -int i; +int i, ret; addr =spi_nor_convert_addr (nor, addr); + ret =spi_nor_write_enable (nor); +if (ret) +return ret; +if (nor->spimem) {struct spi_mem_op op = SPI_NOR_SECTOR_ERASE_OP(nor->erase_opcode,
@@ -1777,12 +1791,6 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)if (ret) goto destroy_erase_cmd_list; - ret =spi_nor_write_enable (nor); -if (ret) { -spi_nor_unlock_device (nor); - goto destroy_erase_cmd_list; - } - ret =spi_nor_erase_sector (nor, addr);spi_nor_unlock_device (nor);if (ret)
@@ -1841,12 +1849,6 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err; - ret =spi_nor_write_enable (nor); -if (ret) { -spi_nor_unlock_device (nor); - goto erase_err; - } - ret =spi_nor_erase_chip (nor);spi_nor_unlock_device (nor);if (ret)
@@ -1877,12 +1879,6 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err; - ret =spi_nor_write_enable (nor); -if (ret) { -spi_nor_unlock_device (nor); - goto erase_err; - } - ret =spi_nor_erase_sector (nor, addr);spi_nor_unlock_device (nor);if (ret)
@@ -2177,12 +2173,6 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,if (ret) goto write_err; - ret =spi_nor_write_enable (nor); -if (ret) { -spi_nor_unlock_device (nor); - goto write_err; - } - ret =spi_nor_write_data (nor, addr, page_remain, buf + i);spi_nor_unlock_device (nor);if (ret <0 )
Signature · 1 line
2.17.1
PATCH v10 5/8 mtd: spi-nor: Add stacked memories support in spi-nor
In reply to Amit Kumar MahapatraEach flash that is connected in stacked mode should have a separate parameter structure. So, the flash parameter member(*params) of the spi_nor structure is changed to an array (*params[2]). The array is used to store the parameters of each flash connected in stacked configuration.
The current implementation assumes that a maximum of two flashes are connected in stacked mode and both the flashes are of same make but can differ in sizes. So, except the sizes all other flash parameters of both the flashes are identical.
SPI-NOR is not aware of the chip_select values, for any incoming request SPI-NOR will decide the flash index with the help of individual flash size and the configuration type (single/stacked). SPI-NOR will pass on the flash index information to the SPI core & SPI driver by setting the appropriate bit in nor->spimem->spi->cs_index_mask. For example, if nth bit of nor->spimem->spi->cs_index_mask is set then the driver would assert/de-assert spi->chip_slect[n].
--- drivers/mtd/spi-nor/core.c | 272 +++++++++++++++++++++++++++++------- drivers/mtd/spi-nor/core.h | 4 + include/linux/mtd/spi-nor.h | 15 +- 3 files changed, 240 insertions(+), 51 deletions(-)
drivers/mtd/spi-nor/core.c +225 -47
@@ -1821,13 +1821,18 @@ static int spi_nor_erase_multi_sectors(struct spi_nor *nor, u64 addr, u32 len)static int spi_nor_erase (struct mtd_info *mtd,struct erase_info *instr) {struct spi_nor *nor =mtd_to_spi_nor (mtd); -u32 addr, len; +struct spi_nor_flash_parameter *params; +u32 addr, len, offset, cur_cs_num =0 ;uint32_t rem;int ret; +u64 sz;dev_dbg (nor->dev,"at 0x%llx, len %lld\n" , (long long )instr->addr, (long long )instr->len); + params =spi_nor_get_params (nor,0 ); + sz = params->size; +if (spi_nor_has_uniform_erase (nor)) {div_u64_rem (instr->len, mtd->erasesize, &rem);if (rem)
@@ -1849,23 +1854,27 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err; - ret =spi_nor_erase_chip (nor); -spi_nor_unlock_device (nor); -if (ret) - goto erase_err; +while (cur_cs_num < nor->num_flash) { + nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; + ret =spi_nor_erase_chip (nor); +spi_nor_unlock_device (nor); +if (ret) + goto erase_err; -/* -* Scale the timeout linearly with the size of the flash, with -* a minimum calibrated to an old 2MB flash. We could try to -* pull these from CFI/SFDP, but these values should be good -* enough for now. -*/ - timeout =max (CHIP_ERASE_2MB_READY_WAIT_JIFFIES , -CHIP_ERASE_2MB_READY_WAIT_JIFFIES * - (unsigned long )(mtd->size /SZ_2M )); - ret =spi_nor_wait_till_ready_with_timeout (nor, timeout); -if (ret) - goto erase_err; +/* +* Scale the timeout linearly with the size of the flash, with +* a minimum calibrated to an old 2MB flash. We could try to +* pull these from CFI/SFDP, but these values should be good +* enough for now. +*/ + timeout =max (CHIP_ERASE_2MB_READY_WAIT_JIFFIES , +CHIP_ERASE_2MB_READY_WAIT_JIFFIES * + (unsigned long )(params->size /SZ_2M )); + ret =spi_nor_wait_till_ready_with_timeout (nor, timeout); +if (ret) + goto erase_err; + cur_cs_num++; + }/* REVISIT in some cases we could speed up erasing large regions * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up
@@ -1874,12 +1883,26 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)/* "sector"-at-a-time erase */ }else if (spi_nor_has_uniform_erase (nor)) { +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < nor->num_flash) && (addr > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } +while (len) { ret =spi_nor_lock_device (nor);if (ret) goto erase_err; - ret =spi_nor_erase_sector (nor, addr); + nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; + offset = addr; +if (nor->flags &SNOR_F_HAS_STACKED ) { + params =spi_nor_get_params (nor, cur_cs_num); + offset -= (sz - params->size); + } + + ret =spi_nor_erase_sector (nor, offset);spi_nor_unlock_device (nor);if (ret) goto erase_err;
@@ -1890,13 +1913,45 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) addr += mtd->erasesize; len -= mtd->erasesize; + +/* +* Flash cross over condition in stacked mode. +*/ +if ((nor->flags &SNOR_F_HAS_STACKED ) && (addr > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } }/* erase multiple sectors */ }else { - ret =spi_nor_erase_multi_sectors (nor, addr, len); -if (ret) - goto erase_err; +u64 erase_len =0 ; + +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < nor->num_flash) && (addr > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } +/* perform multi sector erase onec per Flash*/ +while (len) { + erase_len = (len > (sz - addr)) ? (sz - addr) : len; + offset = addr; + nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; +if (nor->flags &SNOR_F_HAS_STACKED ) { + params =spi_nor_get_params (nor, cur_cs_num); + offset -= (sz - params->size); + } + ret =spi_nor_erase_multi_sectors (nor, offset, erase_len); +if (ret) + goto erase_err; + len -= erase_len; + addr += erase_len; + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } } ret =spi_nor_write_disable (nor);
@@ -2087,9 +2142,11 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { struct spi_nor *nor = mtd_to_spi_nor(mtd); +struct spi_nor_flash_parameter *params; +ssize_t ret, read_len, len_lock = len;loff_t from_lock = from; -size_t len_lock = len; -ssize_t ret; +u32 cur_cs_num =0 ; +u64 sz;dev_dbg (nor->dev,"from 0x%08x, len %zd\n" , (u32 )from, len);
@@ -2097,9 +2154,23 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,if (ret)return ret; + params =spi_nor_get_params (nor,0 ); + sz = params->size; + +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < nor->num_flash) && (from > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + }while (len) {loff_t addr = from; + nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; + read_len = (len > (sz - addr)) ? (sz - addr) : len; + params =spi_nor_get_params (nor, cur_cs_num); + addr -= (sz - params->size); + addr =spi_nor_convert_addr (nor, addr); ret =spi_nor_read_data (nor, addr, len, buf);
@@ -2111,11 +2182,22 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,if (ret <0 ) goto read_err; -WARN_ON (ret > len); +WARN_ON (ret > read_len); *retlen += ret; buf += ret; from += ret; len -= ret; + +/* +* Flash cross over condition in stacked mode. +* +*/ +if ((nor->flags &SNOR_F_HAS_STACKED ) && (from > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } + } ret =0 ;
@@ -2136,8 +2218,9 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,struct spi_nor *nor =mtd_to_spi_nor (mtd);struct spi_nor_flash_parameter *params;size_t page_offset, page_remain, i; +u32 page_size, cur_cs_num =0 ;ssize_t ret; -u32 page_size; +u64 sz;dev_dbg (nor->dev,"to 0x%08x, len %zd\n" , (u32 )to, len);
@@ -2147,6 +2230,14 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, params =spi_nor_get_params (nor,0 ); page_size = params->page_size; + sz = params->size; + +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < nor->num_flash) && (to > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + }for (i =0 ; i < len; ) {ssize_t written;
@@ -2167,6 +2258,10 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,/* the size of data remaining on the first page */ page_remain =min_t (size_t, page_size - page_offset, len - i); + nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; + params =spi_nor_get_params (nor, cur_cs_num); + addr -= (sz - params->size); + addr =spi_nor_convert_addr (nor, addr); ret =spi_nor_lock_device (nor);
@@ -2184,6 +2279,15 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, goto write_err; *retlen += written; i += written; + +/* +* Flash cross over condition in stacked mode. +*/ +if ((nor->flags &SNOR_F_HAS_STACKED ) && ((to + i) > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } } write_err:
@@ -2297,8 +2401,6 @@ int spi_nor_hwcaps_pp2cmd(u32 hwcaps)static int spi_nor_spimem_check_op (struct spi_nor *nor,struct spi_mem_op *op) { -struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); -/* * First test with 4 address bytes. The opcode itself might * be a 3B addressing opcode but we don't care, because
@@ -2307,7 +2409,7 @@ static int spi_nor_spimem_check_op(struct spi_nor *nor,*/ op->addr.nbytes =4 ;if (!spi_mem_supports_op (nor->spimem, op)) { -if (params->size >SZ_16M ) +if (nor->mtd.size >SZ_16M )return -EOPNOTSUPP ;/* If flash size <= 16MB, 3 address bytes are sufficient */
@@ -2905,7 +3007,10 @@ static void spi_nor_init_fixup_flags(struct spi_nor *nor)static int spi_nor_late_init_params (struct spi_nor *nor) {struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); -int ret; +struct device_node *np =spi_nor_get_flash_node (nor); +u64 flash_size[SNOR_FLASH_CNT_MAX ]; +u32 idx =0 ; +int rc, ret;if (nor->manufacturer && nor->manufacturer->fixups && nor->manufacturer->fixups->late_init) {
@@ -2937,6 +3042,44 @@ static int spi_nor_late_init_params(struct spi_nor *nor)if (params->n_banks >1 ) params->bank_size =div64_u64 (params->size, params->n_banks); + nor->num_flash =0 ; + +/* +* The flashes that are connected in stacked mode should be of same make. +* Except the flash size all other properties are identical for all the +* flashes connected in stacked mode. +* The flashes that are connected in parallel mode should be identical. +*/ +while (idx <SNOR_FLASH_CNT_MAX ) { + rc =of_property_read_u64_index (np,"stacked-memories" , idx, &flash_size[idx]); +if (rc) +break ; + idx++; +if (!(nor->flags &SNOR_F_HAS_STACKED )) + nor->flags |=SNOR_F_HAS_STACKED ; + + nor->num_flash++; + } + +/* +* By default one flash device should be connected +* so, nor->num_flash is 1. +*/ +if (!nor->num_flash) + nor->num_flash =1 ; + +if (nor->flags &SNOR_F_HAS_STACKED ) { +for (idx =1 ; idx < nor->num_flash; idx++) { + params =spi_nor_get_params (nor, idx); + params =devm_kzalloc (nor->dev,sizeof (*params),GFP_KERNEL ); +if (params) { +memcpy (params,spi_nor_get_params (nor,0 ),sizeof (*params)); + params->size = flash_size[idx]; +spi_nor_set_params (nor, idx, params); + } + } + } +return 0 ; }
@@ -3145,16 +3288,28 @@ static int spi_nor_set_octal_dtr(struct spi_nor *nor, bool enable)*/ static int spi_nor_quad_enable (struct spi_nor *nor) { -struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 ); +struct spi_nor_flash_parameter *params; +int err, idx; -if (!params->quad_enable) -return 0 ; +for (idx =0 ; idx < nor->num_flash; idx++) { + params =spi_nor_get_params (nor, idx); +if (!params->quad_enable) +return 0 ; -if (!(spi_nor_get_protocol_width (nor->read_proto) ==4 || -spi_nor_get_protocol_width (nor->write_proto) ==4 )) -return 0 ; +if (!(spi_nor_get_protocol_width (nor->read_proto) ==4 || +spi_nor_get_protocol_width (nor->write_proto) ==4 )) +return 0 ; +/* +* Set the appropriate CS index before +* issuing the command. +*/ + nor->spimem->spi->cs_index_mask =0x01 << idx; -return params->quad_enable (nor); + err = params->quad_enable (nor); +if (err) +return err; + } +return err; }/**
@@ -3186,7 +3341,7 @@ int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)static int spi_nor_init (struct spi_nor *nor) { -int err; +int err, idx; err =spi_nor_set_octal_dtr (nor, true);if (err) {
@@ -3227,9 +3382,16 @@ static int spi_nor_init(struct spi_nor *nor)*/ WARN_ONCE (nor->flags &SNOR_F_BROKEN_RESET ,"enabling reset hack; may not recover from unexpected reboots\n" ); - err =spi_nor_set_4byte_addr_mode (nor, true); -if (err) -return err; +for (idx =0 ; idx < nor->num_flash; idx++) { +/* +* Select the appropriate CS index before +* issuing the command. +*/ + nor->spimem->spi->cs_index_mask =0x01 << idx; + err =spi_nor_set_4byte_addr_mode (nor, true); +if (err) +return err; + } }return 0 ;
@@ -3344,18 +3506,28 @@ static void spi_nor_put_device(struct mtd_info *mtd)static void spi_nor_restore (struct spi_nor *nor) {int ret; +int idx;/* restore the addressing mode */ if (nor->addr_nbytes ==4 && !(nor->flags &SNOR_F_4B_OPCODES ) && nor->flags &SNOR_F_BROKEN_RESET ) { - ret =spi_nor_set_4byte_addr_mode (nor, false); -if (ret) +for (idx =0 ; idx < nor->num_flash; idx++) {/* -* Do not stop the execution in the hope that the flash -* will default to the 3-byte address mode after the -* software reset. +* Select the appropriate CS index before +* issuing the command. */ -dev_err (nor->dev,"Failed to exit 4-byte address mode, err = %d\n" , ret); + nor->spimem->spi->cs_index_mask =1 << idx; + ret =spi_nor_set_4byte_addr_mode (nor, false); +if (ret) +/* +* Do not stop the execution in the hope that the flash +* will default to the 3-byte address mode after the +* software reset. +*/ +dev_err (nor->dev, +"Failed to exit 4-byte address mode, err = %d\n" , + ret); + } }if (nor->flags &SNOR_F_SOFT_RESET )
@@ -3422,6 +3594,8 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)struct spi_nor_flash_parameter *params =spi_nor_get_params (nor,0 );struct mtd_info *mtd = &nor->mtd;struct device *dev = nor->dev; +u64 total_sz =0 ; +int idx;spi_nor_set_mtd_locking_ops (nor);spi_nor_set_mtd_otp_ops (nor);
@@ -3440,7 +3614,11 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) mtd->_erase = spi_nor_erase; mtd->writesize = params->writesize; mtd->writebufsize = params->page_size; - mtd->size = params->size; +for (idx =0 ; idx < nor->num_flash; idx++) { + params =spi_nor_get_params (nor, idx); + total_sz += params->size; + } + mtd->size = total_sz; mtd->_read = spi_nor_read;/* Might be already set by some SST flashes. */ if (!mtd->_write)
drivers/mtd/spi-nor/core.h +4 -0
@@ -18,6 +18,9 @@#define SPI_NOR_DEFAULT_N_BANKS 1#define SPI_NOR_DEFAULT_SECTOR_SIZE SZ_64K +/* In single configuration enable CS0 */ +#define SPI_NOR_ENABLE_CS0 BIT(0) +/* Standard SPI NOR flash operations. */ #define SPI_NOR_READID_OP (naddr, ndummy, buf, len) \ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 0), \
@@ -140,6 +143,7 @@ enum spi_nor_option_flags {SNOR_F_RWW =BIT (14 ),SNOR_F_ECC =BIT (15 ),SNOR_F_NO_WP =BIT (16 ), + SNOR_F_HAS_STACKED = BIT(17), }; struct spi_nor_read_command {
include/linux/mtd/spi-nor.h +11 -4
@@ -127,6 +127,12 @@#define SR2_LB3 BIT(5)/* Security Register Lock Bit 3 */ #define SR2_QUAD_EN_BIT7 BIT(7) +/* +* Maximum number of flashes that can be connected +* in stacked/parallel configuration +*/ +#define SNOR_FLASH_CNT_MAX 4 +/* Supported SPI protocols */ #define SNOR_PROTO_INST_MASK GENMASK(23, 16)#define SNOR_PROTO_INST_SHIFT 16
@@ -378,6 +384,7 @@ struct spi_nor_flash_parameter;* hooks, or dynamically when parsing the SFDP tables. * @dirmap: pointers to struct spi_mem_dirmap_desc for reads/writes. * @priv: pointer to the private data +* @num_flash number of flashes connected in parallel or stacked mode */ struct spi_nor {struct mtd_info mtd;
@@ -412,13 +419,13 @@ struct spi_nor {const struct spi_nor_controller_ops *controller_ops; -struct spi_nor_flash_parameter *params; +struct spi_nor_flash_parameter *params[SNOR_FLASH_CNT_MAX ];struct {struct spi_mem_dirmap_desc *rdesc;struct spi_mem_dirmap_desc *wdesc; } dirmap; - +u32 num_flash;void *priv; };
@@ -435,13 +442,13 @@ static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)static inline struct spi_nor_flash_parameter *spi_nor_get_params (const struct spi_nor *nor,u8 idx) { -return nor->params; +return nor->params[idx]; }static inline void spi_nor_set_params (struct spi_nor *nor,u8 idx,struct spi_nor_flash_parameter *params) { - nor->params = params; + nor->params[idx] = params; }/** * spi_nor_scan() - scan the SPI NOR
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v10 6/8 spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver
In reply to Amit Kumar MahapatraGQSPI supports two chip select CS0 & CS1. Update the driver to assert/de-assert the appropriate chip select as per the bits set in qspi->cs_index_mask.
--- drivers/spi/spi-zynqmp-gqspi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/spi/spi-zynqmp-gqspi.c +13 -8
@@ -154,6 +154,9 @@#define GQSPI_FREQ_100MHZ 100000000#define GQSPI_FREQ_150MHZ 150000000 +#define GQSPI_SELECT_LOWER_CS BIT(0) +#define GQSPI_SELECT_UPPER_CS BIT(1) +#define SPI_AUTOSUSPEND_TIMEOUT 3000enum mode_type {GQSPI_MODE_IO ,GQSPI_MODE_DMA };
@@ -465,15 +468,17 @@ static void zynqmp_qspi_chipselect(struct spi_device *qspi, bool is_high) genfifoentry |=GQSPI_GENFIFO_MODE_SPI ; +if (qspi->cs_index_mask &GQSPI_SELECT_UPPER_CS ) { +zynqmp_gqspi_selectslave (xqspi, +GQSPI_SELECT_FLASH_CS_UPPER , +GQSPI_SELECT_FLASH_BUS_LOWER ); + }else if (qspi->cs_index_mask &GQSPI_SELECT_LOWER_CS ) { +zynqmp_gqspi_selectslave (xqspi, +GQSPI_SELECT_FLASH_CS_LOWER , +GQSPI_SELECT_FLASH_BUS_LOWER ); + } + genfifoentry |= xqspi->genfifobus;if (!is_high) { -if (!spi_get_chipselect (qspi,0 )) { - xqspi->genfifobus =GQSPI_GENFIFO_BUS_LOWER ; - xqspi->genfifocs =GQSPI_GENFIFO_CS_LOWER ; - }else { - xqspi->genfifobus =GQSPI_GENFIFO_BUS_UPPER ; - xqspi->genfifocs =GQSPI_GENFIFO_CS_UPPER ; - } - genfifoentry |= xqspi->genfifobus; genfifoentry |= xqspi->genfifocs; genfifoentry |=GQSPI_GENFIFO_CS_SETUP ; }else {
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v10 7/8 mtd: spi-nor: Add parallel memories support in spi-nor
In reply to Amit Kumar MahapatraThe current implementation assumes that a maximum of two flashes are connected in parallel mode. The QSPI controller splits the data evenly between both the flashes so, both the flashes that are connected in parallel mode should be identical.
During each operation SPI-NOR sets 0th bit for CS0 & 1st bit for CS1 in nor->spimem->spi->cs_index_mask. The QSPI driver will then assert/de-assert CS0 & CS1.
Write operation in parallel mode are performed in page size * 2 chunks as each write operation results in writing both the flashes. For doubling the address space each operation is performed at addr/2 flash offset, where addr is the address specified by the user.
--- drivers/mtd/spi-nor/core.c | 409 +++++++++++++++++++++++++------- drivers/mtd/spi-nor/core.h | 4 + drivers/mtd/spi-nor/micron-st.c | 5 + 3 files changed, 333 insertions(+), 85 deletions(-)
drivers/mtd/spi-nor/core.c +324 -85
@@ -470,17 +470,29 @@ int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) op.data.nbytes =2 ; } +if (nor->flags &SNOR_F_HAS_PARALLEL ) + op.data.nbytes =2 ; +spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); ret =spi_mem_exec_op (nor->spimem, &op); }else { - ret =spi_nor_controller_ops_read_reg (nor,SPINOR_OP_RDSR , sr, -1 ); +if (nor->flags &SNOR_F_HAS_PARALLEL ) + ret =spi_nor_controller_ops_read_reg (nor, +SPINOR_OP_RDSR , + sr,2 ); +else + ret =spi_nor_controller_ops_read_reg (nor, +SPINOR_OP_RDSR , + sr,1 ); }if (ret)dev_dbg (nor->dev,"error %d reading SR\n" , ret); +if (nor->flags &SNOR_F_HAS_PARALLEL ) + sr[0 ] |= sr[1 ]; +return ret; }
@@ -1824,6 +1836,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)struct spi_nor_flash_parameter *params;u32 addr, len, offset, cur_cs_num =0 ;uint32_t rem; +u32 n_flash =1 ;int ret;u64 sz;
@@ -1833,6 +1846,9 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) params =spi_nor_get_params (nor,0 ); sz = params->size; +if (nor->num_flash) + n_flash = nor->num_flash; +if (spi_nor_has_uniform_erase (nor)) {div_u64_rem (instr->len, mtd->erasesize, &rem);if (rem)
@@ -1854,53 +1870,82 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)if (ret) goto erase_err; -while (cur_cs_num < nor->num_flash) { - nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; +if (nor->flags &SNOR_F_HAS_PARALLEL ) { + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; ret =spi_nor_erase_chip (nor);spi_nor_unlock_device (nor);if (ret) goto erase_err;/* -* Scale the timeout linearly with the size of the flash, with -* a minimum calibrated to an old 2MB flash. We could try to -* pull these from CFI/SFDP, but these values should be good -* enough for now. -*/ +* Scale the timeout linearly with the size of the flash, with +* a minimum calibrated to an old 2MB flash. We could try to +* pull these from CFI/SFDP, but these values should be good +* enough for now. +*/ timeout =max (CHIP_ERASE_2MB_READY_WAIT_JIFFIES , -CHIP_ERASE_2MB_READY_WAIT_JIFFIES * - (unsigned long )(params->size /SZ_2M )); +CHIP_ERASE_2MB_READY_WAIT_JIFFIES * + (unsigned long )(mtd->size /SZ_2M )); ret =spi_nor_wait_till_ready_with_timeout (nor, timeout);if (ret) goto erase_err; - cur_cs_num++; - } + }else { +while (cur_cs_num < n_flash) { + nor->spimem->spi->cs_index_mask =1 << cur_cs_num; + ret =spi_nor_erase_chip (nor); +spi_nor_unlock_device (nor); +if (ret) + goto erase_err; + +/* +* Scale the timeout linearly with the size of the flash, with +* a minimum calibrated to an old 2MB flash. We could try to +* pull these from CFI/SFDP, but these values should be good +* enough for now. +*/ + timeout =max (CHIP_ERASE_2MB_READY_WAIT_JIFFIES , +CHIP_ERASE_2MB_READY_WAIT_JIFFIES * + (unsigned long )(params->size /SZ_2M )); + ret =spi_nor_wait_till_ready_with_timeout (nor, timeout); +if (ret) + goto erase_err; + + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + } + }/* REVISIT in some cases we could speed up erasing large regions * by using SPINOR_OP_SE instead of SPINOR_OP_BE_4K. We may have set up * to use "small sector erase", but that's not always optimal. */ -/* "sector"-at-a-time erase */ }else if (spi_nor_has_uniform_erase (nor)) { -/* Determine the flash from which the operation need to start */ -while ((cur_cs_num < nor->num_flash) && (addr > sz -1 )) { - cur_cs_num++; - params =spi_nor_get_params (nor, cur_cs_num); - sz += params->size; +if (!(nor->flags &SNOR_F_HAS_PARALLEL )) { +while ((cur_cs_num < n_flash) && (addr > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } } -while (len) { ret =spi_nor_lock_device (nor);if (ret) goto erase_err; - nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; offset = addr;if (nor->flags &SNOR_F_HAS_STACKED ) { params =spi_nor_get_params (nor, cur_cs_num); offset -= (sz - params->size); } + nor->spimem->spi->cs_index_mask =1 << cur_cs_num; +if (nor->flags &SNOR_F_HAS_PARALLEL ) { +u64 aux = offset; + + ret =do_div (aux, n_flash); + offset = aux; + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; + } ret =spi_nor_erase_sector (nor, offset);spi_nor_unlock_device (nor);
@@ -1923,34 +1968,42 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) sz += params->size; } } -/* erase multiple sectors */ }else { -u64 erase_len =0 ; +if (nor->flags &SNOR_F_HAS_PARALLEL ) { +u64 aux = offset; -/* Determine the flash from which the operation need to start */ -while ((cur_cs_num < nor->num_flash) && (addr > sz -1 )) { - cur_cs_num++; - params =spi_nor_get_params (nor, cur_cs_num); - sz += params->size; - } -/* perform multi sector erase onec per Flash*/ -while (len) { - erase_len = (len > (sz - addr)) ? (sz - addr) : len; - offset = addr; - nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; -if (nor->flags &SNOR_F_HAS_STACKED ) { - params =spi_nor_get_params (nor, cur_cs_num); - offset -= (sz - params->size); - } - ret =spi_nor_erase_multi_sectors (nor, offset, erase_len); + ret =do_div (aux, n_flash); + offset = aux; + ret =spi_nor_erase_multi_sectors (nor, addr, len);if (ret) goto erase_err; - len -= erase_len; - addr += erase_len; - cur_cs_num++; - params =spi_nor_get_params (nor, cur_cs_num); - sz += params->size; + }else { +u64 erase_len =0 ; + +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < n_flash) && (addr > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } +/* perform multi sector erase onec per Flash*/ +while (len) { + erase_len = (len > (sz - addr)) ? (sz - addr) : len; + offset = addr; + nor->spimem->spi->cs_index_mask =1 << cur_cs_num; +if (nor->flags &SNOR_F_HAS_STACKED ) { + params =spi_nor_get_params (nor, cur_cs_num); + offset -= (sz - params->size); + } + ret =spi_nor_erase_multi_sectors (nor, offset, erase_len); +if (ret) + goto erase_err; + len -= erase_len; + addr += erase_len; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } } }
@@ -2144,9 +2197,12 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,struct spi_nor *nor =mtd_to_spi_nor (mtd);struct spi_nor_flash_parameter *params;ssize_t ret, read_len, len_lock = len; +bool is_ofst_odd = false;loff_t from_lock = from;u32 cur_cs_num =0 ; -u64 sz; +u_char *readbuf; +u32 n_flash =1 ; +u64 sz =0 ;dev_dbg (nor->dev,"from 0x%08x, len %zd\n" , (u32 )from, len);
@@ -2157,23 +2213,54 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, params =spi_nor_get_params (nor,0 ); sz = params->size; -/* Determine the flash from which the operation need to start */ -while ((cur_cs_num < nor->num_flash) && (from > sz -1 )) { - cur_cs_num++; - params =spi_nor_get_params (nor, cur_cs_num); - sz += params->size; +if (nor->num_flash) + n_flash = nor->num_flash; + +/* +* When even number of flashes are connected in parallel and the +* requested read length is odd then read (len + 1) from offset + 1 +* and ignore offset[0] data. +*/ +if ((nor->flags &SNOR_F_HAS_PARALLEL ) && (!(n_flash %2 )) && (from &0x01 )) { + from = (loff_t)(from -1 ); + len = (size_t )(len +1 ); + is_ofst_odd = true; + readbuf =kmalloc (len,GFP_KERNEL ); +if (!readbuf) +return -ENOMEM ; + }else { + readbuf = buf; } + +if (!(nor->flags &SNOR_F_HAS_PARALLEL )) { +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < n_flash) && (from > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } + } +while (len) {loff_t addr = from; - nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; - read_len = (len > (sz - addr)) ? (sz - addr) : len; - params =spi_nor_get_params (nor, cur_cs_num); - addr -= (sz - params->size); +if (nor->flags &SNOR_F_HAS_PARALLEL ) { +u64 aux = addr; + + ret =do_div (aux, n_flash); + addr = aux; + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; + read_len = len; + }else { + nor->spimem->spi->cs_index_mask =1 << cur_cs_num; + read_len = (len > (sz - addr)) ? (sz - addr) : len; + params =spi_nor_get_params (nor, cur_cs_num); + addr -= (sz - params->size); + } addr =spi_nor_convert_addr (nor, addr); - ret =spi_nor_read_data (nor, addr, len, buf); + ret =spi_nor_read_data (nor, addr, read_len, readbuf);if (ret ==0 ) {/* We shouldn't see 0-length reads */ ret = -EIO ;
@@ -2183,8 +2270,20 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, goto read_err;WARN_ON (ret > read_len); - *retlen += ret; +if (is_ofst_odd) { +/* +* Cannot read from odd offset in parallel mode. +* So read len + 1 from offset + 1 from the flash +* and copy len data from readbuf[1]. +*/ +memcpy (buf, (readbuf +1 ), (len -1 )); + *retlen += (ret -1 ); + }else { + *retlen += ret; + } buf += ret; +if (!is_ofst_odd) + readbuf += ret; from += ret; len -= ret;
@@ -2202,8 +2301,10 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, ret =0 ; read_err: -spi_nor_unlock_and_unprep_rd (nor, from_lock, len_lock); +if (is_ofst_odd) +kfree (readbuf); +spi_nor_unlock_and_unprep_rd (nor, from_lock, len_lock);return ret; }
@@ -2219,6 +2320,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,struct spi_nor_flash_parameter *params;size_t page_offset, page_remain, i;u32 page_size, cur_cs_num =0 ; +u32 n_flash =1 ;ssize_t ret;u64 sz;
@@ -2232,11 +2334,41 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, page_size = params->page_size; sz = params->size; -/* Determine the flash from which the operation need to start */ -while ((cur_cs_num < nor->num_flash) && (to > sz -1 )) { - cur_cs_num++; - params =spi_nor_get_params (nor, cur_cs_num); - sz += params->size; +if (nor->num_flash) + n_flash = nor->num_flash; + +if (nor->flags &SNOR_F_HAS_PARALLEL ) { +/* +* When even number of flashes are connected in parallel and the +* requested write length is odd then first write 2 bytes. +*/ +if ((!(n_flash %2 )) && (to &0x01 )) { +u8 two[2 ] = {0xff , buf[0 ]}; +size_t written_len; + + ret =spi_nor_write (mtd, to & ~1 ,2 , &written_len, two); +if (ret <0 ) +return ret; + *retlen +=1 ;/* We've written only one actual byte */ + ++buf; + --len; + ++to; + } +/* +* Write operation are performed in page size chunks and in +* parallel memories both the flashes are written simultaneously, +* hence increase the page_size in multiple of the number of flash +* connected in parallel. +*/ + page_size *= n_flash; + + }else { +/* Determine the flash from which the operation need to start */ +while ((cur_cs_num < n_flash) && (to > sz -1 )) { + cur_cs_num++; + params =spi_nor_get_params (nor, cur_cs_num); + sz += params->size; + } }for (i =0 ; i < len; ) {
@@ -2258,9 +2390,17 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,/* the size of data remaining on the first page */ page_remain =min_t (size_t, page_size - page_offset, len - i); - nor->spimem->spi->cs_index_mask =0x01 << cur_cs_num; - params =spi_nor_get_params (nor, cur_cs_num); - addr -= (sz - params->size); +if (nor->flags &SNOR_F_HAS_PARALLEL ) { +u64 aux = addr; + + ret =do_div (aux, n_flash); + addr = aux; + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; + }else { + nor->spimem->spi->cs_index_mask =1 << cur_cs_num; + params =spi_nor_get_params (nor, cur_cs_num); + addr -= (sz - params->size); + } addr =spi_nor_convert_addr (nor, addr);
@@ -2701,7 +2841,15 @@ static int spi_nor_select_erase(struct spi_nor *nor)if (!erase)return -EINVAL ; nor->erase_opcode = erase->opcode; - mtd->erasesize = erase->size; +/* +* In parallel-memories the erase operation is +* performed on both the flashes simultaneously +* so, double the erasesize. +*/ +if (nor->flags &SNOR_F_HAS_PARALLEL ) + mtd->erasesize = erase->size *2 ; +else + mtd->erasesize = erase->size;return 0 ; }
@@ -2719,7 +2867,15 @@ static int spi_nor_select_erase(struct spi_nor *nor)if (!erase)return -EINVAL ; - mtd->erasesize = erase->size; +/* +* In parallel-memories the erase operation is +* performed on both the flashes simultaneously +* so, double the erasesize. +*/ +if (nor->flags &SNOR_F_HAS_PARALLEL ) + mtd->erasesize = erase->size *2 ; +else + mtd->erasesize = erase->size;return 0 ; }
@@ -3060,6 +3216,17 @@ static int spi_nor_late_init_params(struct spi_nor *nor) nor->num_flash++; } + idx =0 ; +while (idx <SNOR_FLASH_CNT_MAX ) { + rc =of_property_read_u64_index (np,"parallel-memories" , idx, &flash_size[idx]); +if (rc) +break ; + idx++; +if (!(nor->flags &SNOR_F_HAS_PARALLEL )) + nor->flags |=SNOR_F_HAS_PARALLEL ; + + nor->num_flash++; + }/* * By default one flash device should be connected
@@ -3068,7 +3235,7 @@ static int spi_nor_late_init_params(struct spi_nor *nor)if (!nor->num_flash) nor->num_flash =1 ; -if (nor->flags &SNOR_F_HAS_STACKED ) { +if (nor->flags & (SNOR_F_HAS_STACKED |SNOR_F_HAS_PARALLEL )) {for (idx =1 ; idx < nor->num_flash; idx++) { params =spi_nor_get_params (nor, idx); params =devm_kzalloc (nor->dev,sizeof (*params),GFP_KERNEL );
@@ -3289,10 +3456,14 @@ static int spi_nor_set_octal_dtr(struct spi_nor *nor, bool enable)static int spi_nor_quad_enable (struct spi_nor *nor) {struct spi_nor_flash_parameter *params; +u32 n_flash =1 ;int err, idx; -for (idx =0 ; idx < nor->num_flash; idx++) { - params =spi_nor_get_params (nor, idx); +if (nor->num_flash) + n_flash = nor->num_flash; + +if (nor->flags &SNOR_F_HAS_PARALLEL ) { + params =spi_nor_get_params (nor,0 );if (!params->quad_enable)return 0 ;
@@ -3300,14 +3471,32 @@ static int spi_nor_quad_enable(struct spi_nor *nor) spi_nor_get_protocol_width(nor->write_proto) == 4))return 0 ;/* -* Set the appropriate CS index before -* issuing the command. +* In parallel mode both chip selects i.e., CS0 & +* CS1 need to be asserted simulatneously. */ - nor->spimem->spi->cs_index_mask =0x01 << idx; - + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; err = params->quad_enable (nor);if (err)return err; + }else { +for (idx =0 ; idx < n_flash; idx++) { + params =spi_nor_get_params (nor, idx); +if (!params->quad_enable) +return 0 ; + +if (!(spi_nor_get_protocol_width (nor->read_proto) ==4 || +spi_nor_get_protocol_width (nor->write_proto) ==4 )) +return 0 ; +/* +* Set the appropriate CS index before +* issuing the command. +*/ + nor->spimem->spi->cs_index_mask =1 << idx; + + err = params->quad_enable (nor); +if (err) +return err; + } }return err; }
@@ -3341,8 +3530,12 @@ int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)static int spi_nor_init (struct spi_nor *nor) { +u32 n_flash =1 ;int err, idx; +if (nor->num_flash) + n_flash = nor->num_flash; + err =spi_nor_set_octal_dtr (nor, true);if (err) {dev_dbg (nor->dev,"octal mode not supported\n" );
@@ -3382,15 +3575,26 @@ static int spi_nor_init(struct spi_nor *nor)*/ WARN_ONCE (nor->flags &SNOR_F_BROKEN_RESET ,"enabling reset hack; may not recover from unexpected reboots\n" ); -for (idx =0 ; idx < nor->num_flash; idx++) { +if (nor->flags &SNOR_F_HAS_PARALLEL ) {/* -* Select the appropriate CS index before -* issuing the command. +* In parallel mode both chip selects i.e., CS0 & +* CS1 need to be asserted simulatneously. */ - nor->spimem->spi->cs_index_mask =0x01 << idx; + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; err =spi_nor_set_4byte_addr_mode (nor, true);if (err)return err; + }else { +for (idx =0 ; idx < n_flash; idx++) { +/* +* Select the appropriate CS index before +* issuing the command. +*/ + nor->spimem->spi->cs_index_mask =1 << idx; + err =spi_nor_set_4byte_addr_mode (nor, true); +if (err) +return err; + } } }
@@ -3505,19 +3709,23 @@ static void spi_nor_put_device(struct mtd_info *mtd)static void spi_nor_restore (struct spi_nor *nor) { +u32 n_flash =1 ;int ret;int idx; +if (nor->num_flash) + n_flash = nor->num_flash; +/* restore the addressing mode */ if (nor->addr_nbytes ==4 && !(nor->flags &SNOR_F_4B_OPCODES ) && nor->flags &SNOR_F_BROKEN_RESET ) { -for (idx =0 ; idx < nor->num_flash; idx++) { +if (nor->flags &SNOR_F_HAS_PARALLEL ) {/* -* Select the appropriate CS index before -* issuing the command. +* In parallel mode both chip selects i.e., CS0 & +* CS1 need to be asserted simulatneously. */ - nor->spimem->spi->cs_index_mask =1 << idx; - ret =spi_nor_set_4byte_addr_mode (nor, false); + nor->spimem->spi->cs_index_mask =SPI_NOR_ENABLE_MULTI_CS ; +spi_nor_set_4byte_addr_mode (nor, false);if (ret)/* * Do not stop the execution in the hope that the flash
@@ -3527,6 +3735,24 @@ static void spi_nor_restore(struct spi_nor *nor)dev_err (nor->dev,"Failed to exit 4-byte address mode, err = %d\n" , ret); + }else { +for (idx =0 ; idx < n_flash; idx++) { +/* +* Select the appropriate CS index before +* issuing the command. +*/ + nor->spimem->spi->cs_index_mask =1 << idx; + ret =spi_nor_set_4byte_addr_mode (nor, false); +if (ret) +/* +* Do not stop the execution in the hope that the +* flash will default to the 3-byte address mode +* after the software reset. +*/ +dev_err (nor->dev, +"Failed to exit 4-byte address mode, err = %d\n" , + ret); + } } }
@@ -3595,11 +3821,15 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)struct mtd_info *mtd = &nor->mtd;struct device *dev = nor->dev;u64 total_sz =0 ; +u32 n_flash =1 ;int idx;spi_nor_set_mtd_locking_ops (nor);spi_nor_set_mtd_otp_ops (nor); +if (nor->num_flash) + n_flash = nor->num_flash; + mtd->dev.parent = dev;if (!mtd->name) mtd->name =dev_name (dev);
@@ -3613,8 +3843,17 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)else mtd->_erase = spi_nor_erase; mtd->writesize = params->writesize; - mtd->writebufsize = params->page_size; -for (idx =0 ; idx < nor->num_flash; idx++) { +/* +* In parallel-memories the write operation is +* performed on both the flashes simultaneously +* one page per flash, so double the writebufsize. +*/ +if (nor->flags &SNOR_F_HAS_PARALLEL ) + mtd->writebufsize = params->page_size <<1 ; +else + mtd->writebufsize = params->page_size; + +for (idx =0 ; idx < n_flash; idx++) { params =spi_nor_get_params (nor, idx); total_sz += params->size; }
drivers/mtd/spi-nor/core.h +4 -0
@@ -21,6 +21,9 @@/* In single configuration enable CS0 */ #define SPI_NOR_ENABLE_CS0 BIT(0) +/* In parallel configuration enable multiple CS */ +#define SPI_NOR_ENABLE_MULTI_CS (BIT(0) | BIT(1)) +/* Standard SPI NOR flash operations. */ #define SPI_NOR_READID_OP (naddr, ndummy, buf, len) \ SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 0), \
@@ -144,6 +147,7 @@ enum spi_nor_option_flags {SNOR_F_ECC =BIT (15 ),SNOR_F_NO_WP =BIT (16 ),SNOR_F_HAS_STACKED =BIT (17 ), + SNOR_F_HAS_PARALLEL = BIT(18), }; struct spi_nor_read_command {
drivers/mtd/spi-nor/micron-st.c +5 -0
@@ -478,6 +478,9 @@ static int micron_st_nor_read_fsr(struct spi_nor *nor, u8 *fsr) op.data.nbytes =2 ; } +if (nor->flags &SNOR_F_HAS_PARALLEL ) + op.data.nbytes =2 ; +spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); ret =spi_mem_exec_op (nor->spimem, &op);
@@ -489,6 +492,8 @@ static int micron_st_nor_read_fsr(struct spi_nor *nor, u8 *fsr)if (ret)dev_dbg (nor->dev,"error %d reading FSR\n" , ret); +if (nor->flags &SNOR_F_HAS_PARALLEL ) + fsr[0 ] &= fsr[1 ];return ret; }
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v10 8/8 spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver
In reply to Amit Kumar MahapatraDuring probe GQSPI driver sets SPI_CONTROLLER_MULTI_CS bit in ctlr->flags for notifying SPI core about multi CS capability of the controller. In parallel mode the controller can either split the data between both the flash or can send the same data to both the flashes, this is determined by the STRIPE bit. While sending commands to the flashes the GQSPI driver send the same command to both the flashes by resetting the STRIPE bit, but while writing/reading data to & from the flash the GQSPI driver splits the data evenly between both the flashes by setting the STRIPE bit.
--- drivers/spi/spi-zynqmp-gqspi.c | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/spi/spi-zynqmp-gqspi.c +38 -1
@@ -21,6 +21,7 @@#include <linux/spinlock.h> #include <linux/workqueue.h> #include <linux/spi/spi-mem.h> +#include <linux/mtd/spi-nor.h> /* Generic QSPI register offsets */ #define GQSPI_CONFIG_OFST 0x00000100
@@ -190,6 +191,7 @@ struct qspi_platform_data {* @op_lock: Operational lock * @speed_hz: Current SPI bus clock speed in hz * @has_tapdelay: Used for tapdelay register available in qspi +* @is_parallel: Used for multi CS support */ struct zynqmp_qspi {struct spi_controller *ctlr;
@@ -212,8 +214,33 @@ struct zynqmp_qspi {struct mutex op_lock;u32 speed_hz;bool has_tapdelay; +bool is_parallel; }; +/** +* zynqmp_gqspi_update_stripe - For GQSPI controller data stripe capabilities +* @op: Pointer to mem ops +* Return: Status of the data stripe +* +* Returns true if data stripe need to be enabled, else returns false +*/ +bool zynqmp_gqspi_update_stripe (const struct spi_mem_op *op) +{ +if (op->cmd.opcode ==SPINOR_OP_BE_4K || + op->cmd.opcode ==SPINOR_OP_BE_32K || + op->cmd.opcode ==SPINOR_OP_CHIP_ERASE || + op->cmd.opcode ==SPINOR_OP_SE || + op->cmd.opcode ==SPINOR_OP_BE_32K_4B || + op->cmd.opcode ==SPINOR_OP_SE_4B || + op->cmd.opcode ==SPINOR_OP_BE_4K_4B || + op->cmd.opcode ==SPINOR_OP_WRSR || + op->cmd.opcode ==SPINOR_OP_BRWR || + (op->cmd.opcode ==SPINOR_OP_WRSR2 && !op->addr.nbytes)) +return false; + +return true; +} +/** * zynqmp_gqspi_read - For GQSPI controller read operation * @xqspi: Pointer to the zynqmp_qspi structure
@@ -468,7 +495,14 @@ static void zynqmp_qspi_chipselect(struct spi_device *qspi, bool is_high) genfifoentry |=GQSPI_GENFIFO_MODE_SPI ; -if (qspi->cs_index_mask &GQSPI_SELECT_UPPER_CS ) { +if ((qspi->cs_index_mask &GQSPI_SELECT_LOWER_CS ) && + (qspi->cs_index_mask &GQSPI_SELECT_UPPER_CS )) { +zynqmp_gqspi_selectslave (xqspi, +GQSPI_SELECT_FLASH_CS_BOTH , +GQSPI_SELECT_FLASH_BUS_BOTH ); +if (!xqspi->is_parallel) + xqspi->is_parallel = true; + }else if (qspi->cs_index_mask &GQSPI_SELECT_UPPER_CS ) {zynqmp_gqspi_selectslave (xqspi,GQSPI_SELECT_FLASH_CS_UPPER ,GQSPI_SELECT_FLASH_BUS_LOWER );
@@ -1137,6 +1171,8 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, }if (op->data.nbytes) { +if (xqspi->is_parallel &&zynqmp_gqspi_update_stripe (op)) + genfifoentry |=GQSPI_GENFIFO_STRIPE ;reinit_completion (&xqspi->data_completion);if (op->data.dir ==SPI_MEM_DATA_OUT ) { xqspi->txbuf = (u8 *)op->data.buf.out;
@@ -1332,6 +1368,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ctlr->bits_per_word_mask =SPI_BPW_MASK (8 ); ctlr->dev.of_node = np; ctlr->auto_runtime_pm = true; + ctlr->flags |=SPI_CONTROLLER_MULTI_CS ; ret =devm_spi_register_controller (&pdev->dev, ctlr);if (ret) {
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Mark Brown
maintainerRe: (subset) [PATCH v10 0/8] spi: Add support for stacked/parallel memories
In reply to Amit Kumar MahapatraQuoted 8 lines · Amit Kumar Mahapatra
This patch is in the continuation to the discussions which happened on 'commit
f89504300e94("spi: Stacked/parallel memories bindings")' for adding dt-binding support for stacked/parallel memories.This patch series updated the spi-nor, spi core and the AMD-Xilinx GQSPI driver to add stacked and parallel memories support.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/8] spi: Add multi-cs memories support in SPI core
commit: 4d8ff6b0991d5e86b17b235fc46ec62e9195cb9b
[6/8] spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver
(no commit info)
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