Skip to content

Commit 77a6cac

Browse files
author
Lucas Tanure
committed
mfd: clsic: Add support for smaller SPI transfers
Change-Id: I090245544b85d440dc8b8db5cbcd4335c74b5408 Signed-off-by: Lucas Tanure <[email protected]>
1 parent 3fa2846 commit 77a6cac

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

Documentation/devicetree/bindings/mfd/clsic.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ Optional properties:
6767
set to a default of 32, this property allows that value to be adjusted to
6868
support different CLSIC devices that may require a pad_bits of 16.
6969

70+
- spi-max-pages : Maximum number of pages (PAGE_SIZE) that can be transferred
71+
at once by spi bus. Without this property the driver will set the maximum
72+
size to be (32 X 1024) bytes.
73+
7074
- MICBIAS1x : Initial data for the MICBIAS regulators, as covered in
7175
Documentation/devicetree/bindings/regulator/regulator.txt.
7276

drivers/mfd/clsic/clsic-core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static void clsic_boot(struct clsic *clsic)
378378

379379
int clsic_dev_init(struct clsic *clsic)
380380
{
381-
int ret = 0;
381+
int ret = 0, max_pg = 0;
382382

383383
trace_clsic_dev_init(clsic_bootonload);
384384

@@ -408,6 +408,13 @@ int clsic_dev_init(struct clsic *clsic)
408408

409409
clsic->volatile_memory = of_property_read_bool(clsic->dev->of_node,
410410
"volatile_memory");
411+
ret = of_property_read_u32(clsic->dev->of_node, "spi-max-pages",
412+
&max_pg);
413+
if (ret == 0 && max_pg > 0)
414+
clsic->spi_max_transfer = min_t(size_t, max_pg * PAGE_SIZE,
415+
CLSIC_FIFO_TRANSACTION_MAX);
416+
else
417+
clsic->spi_max_transfer = CLSIC_FIFO_TRANSACTION_MAX;
411418

412419
INIT_DELAYED_WORK(&clsic->maintenance_handler, clsic_maintenance);
413420

drivers/mfd/clsic/clsic-msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ static int clsic_fifo_read(struct clsic *clsic, uint8_t *dest,
10601060

10611061
while (bytes_left != 0) {
10621062
bytes_thisread = min_t(uint32_t, bytes_left,
1063-
CLSIC_FIFO_TRANSACTION_MAX);
1063+
clsic->spi_max_transfer);
10641064
ret = regmap_raw_read(clsic->regmap, clsic->fifo_tx,
10651065
tmp_dest, bytes_thisread);
10661066
if (ret != 0)
@@ -1088,7 +1088,7 @@ static int clsic_fifo_write(struct clsic *clsic, uint8_t *src,
10881088

10891089
while (bytes_left != 0) {
10901090
bytes_thiswrite = min_t(uint32_t, bytes_left,
1091-
CLSIC_FIFO_TRANSACTION_MAX);
1091+
clsic->spi_max_transfer);
10921092
ret = regmap_raw_write(clsic->regmap,
10931093
TACNA_CPF1_RX_WRDATA,
10941094
tmp_src, bytes_thiswrite);

include/linux/mfd/clsic/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ struct clsic {
178178
* downloaded on every reset or power on.
179179
*/
180180
bool volatile_memory;
181+
size_t spi_max_transfer;
181182

182183
int irq;
183184

0 commit comments

Comments
 (0)