1 // SPDX-License-Identifier: GPL-2.0-only
3 * Socionext SPI flash controller F_OSPI driver
4 * Copyright (C) 2021 Socionext Inc.
7 #include <linux/bitfield.h>
10 #include <linux/iopoll.h>
11 #include <linux/module.h>
12 #include <linux/mutex.h>
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/spi-mem.h>
19 #define OSPI_PROT_CTL_INDIR 0x00
20 #define OSPI_PROT_MODE_DATA_MASK GENMASK(31, 30)
21 #define OSPI_PROT_MODE_ALT_MASK GENMASK(29, 28)
22 #define OSPI_PROT_MODE_ADDR_MASK GENMASK(27, 26)
23 #define OSPI_PROT_MODE_CODE_MASK GENMASK(25, 24)
24 #define OSPI_PROT_MODE_SINGLE 0
25 #define OSPI_PROT_MODE_DUAL 1
26 #define OSPI_PROT_MODE_QUAD 2
27 #define OSPI_PROT_MODE_OCTAL 3
28 #define OSPI_PROT_DATA_RATE_DATA BIT(23)
29 #define OSPI_PROT_DATA_RATE_ALT BIT(22)
30 #define OSPI_PROT_DATA_RATE_ADDR BIT(21)
31 #define OSPI_PROT_DATA_RATE_CODE BIT(20)
32 #define OSPI_PROT_SDR 0
33 #define OSPI_PROT_DDR 1
34 #define OSPI_PROT_BIT_POS_DATA BIT(19)
35 #define OSPI_PROT_BIT_POS_ALT BIT(18)
36 #define OSPI_PROT_BIT_POS_ADDR BIT(17)
37 #define OSPI_PROT_BIT_POS_CODE BIT(16)
38 #define OSPI_PROT_SAMP_EDGE BIT(12)
39 #define OSPI_PROT_DATA_UNIT_MASK GENMASK(11, 10)
40 #define OSPI_PROT_DATA_UNIT_1B 0
41 #define OSPI_PROT_DATA_UNIT_2B 1
42 #define OSPI_PROT_DATA_UNIT_4B 3
43 #define OSPI_PROT_TRANS_DIR_WRITE BIT(9)
44 #define OSPI_PROT_DATA_EN BIT(8)
45 #define OSPI_PROT_ALT_SIZE_MASK GENMASK(7, 5)
46 #define OSPI_PROT_ADDR_SIZE_MASK GENMASK(4, 2)
47 #define OSPI_PROT_CODE_SIZE_MASK GENMASK(1, 0)
49 #define OSPI_CLK_CTL 0x10
50 #define OSPI_CLK_CTL_BOOT_INT_CLK_EN BIT(16)
51 #define OSPI_CLK_CTL_PHA BIT(12)
52 #define OSPI_CLK_CTL_PHA_180 0
53 #define OSPI_CLK_CTL_PHA_90 1
54 #define OSPI_CLK_CTL_DIV GENMASK(9, 8)
55 #define OSPI_CLK_CTL_DIV_1 0
56 #define OSPI_CLK_CTL_DIV_2 1
57 #define OSPI_CLK_CTL_DIV_4 2
58 #define OSPI_CLK_CTL_DIV_8 3
59 #define OSPI_CLK_CTL_INT_CLK_EN BIT(0)
61 #define OSPI_CS_CTL1 0x14
62 #define OSPI_CS_CTL2 0x18
63 #define OSPI_SSEL 0x20
64 #define OSPI_CMD_IDX_INDIR 0x40
65 #define OSPI_ADDR 0x50
66 #define OSPI_ALT_INDIR 0x60
67 #define OSPI_DMY_INDIR 0x70
69 #define OSPI_DAT_SWP_INDIR 0x90
71 #define OSPI_DAT_SIZE_INDIR 0xA0
72 #define OSPI_DAT_SIZE_EN BIT(15)
73 #define OSPI_DAT_SIZE_MASK GENMASK(10, 0)
74 #define OSPI_DAT_SIZE_MAX (OSPI_DAT_SIZE_MASK + 1)
76 #define OSPI_TRANS_CTL 0xC0
77 #define OSPI_TRANS_CTL_STOP_REQ BIT(1) /* RW1AC */
78 #define OSPI_TRANS_CTL_START_REQ BIT(0) /* RW1AC */
80 #define OSPI_ACC_MODE 0xC4
81 #define OSPI_ACC_MODE_BOOT_DISABLE BIT(0)
83 #define OSPI_SWRST 0xD0
84 #define OSPI_SWRST_INDIR_WRITE_FIFO BIT(9) /* RW1AC */
85 #define OSPI_SWRST_INDIR_READ_FIFO BIT(8) /* RW1AC */
87 #define OSPI_STAT 0xE0
88 #define OSPI_STAT_IS_AXI_WRITING BIT(10)
89 #define OSPI_STAT_IS_AXI_READING BIT(9)
90 #define OSPI_STAT_IS_SPI_INT_CLK_STOP BIT(4)
91 #define OSPI_STAT_IS_SPI_IDLE BIT(3)
94 #define OSPI_IRQ_CS_DEASSERT BIT(8)
95 #define OSPI_IRQ_WRITE_BUF_READY BIT(2)
96 #define OSPI_IRQ_READ_BUF_READY BIT(1)
97 #define OSPI_IRQ_CS_TRANS_COMP BIT(0)
98 #define OSPI_IRQ_ALL \
99 (OSPI_IRQ_CS_DEASSERT | OSPI_IRQ_WRITE_BUF_READY \
100 | OSPI_IRQ_READ_BUF_READY | OSPI_IRQ_CS_TRANS_COMP)
102 #define OSPI_IRQ_STAT_EN 0xF4
103 #define OSPI_IRQ_SIG_EN 0xF8
106 #define OSPI_NUM_CS 4
107 #define OSPI_DUMMY_CYCLE_MAX 255
108 #define OSPI_WAIT_MAX_MSEC 100
117 static u32
f_ospi_get_dummy_cycle(const struct spi_mem_op
*op
)
119 return (op
->dummy
.nbytes
* 8) / op
->dummy
.buswidth
;
122 static void f_ospi_clear_irq(struct f_ospi
*ospi
)
124 writel(OSPI_IRQ_CS_DEASSERT
| OSPI_IRQ_CS_TRANS_COMP
,
125 ospi
->base
+ OSPI_IRQ
);
128 static void f_ospi_enable_irq_status(struct f_ospi
*ospi
, u32 irq_bits
)
132 val
= readl(ospi
->base
+ OSPI_IRQ_STAT_EN
);
134 writel(val
, ospi
->base
+ OSPI_IRQ_STAT_EN
);
137 static void f_ospi_disable_irq_status(struct f_ospi
*ospi
, u32 irq_bits
)
141 val
= readl(ospi
->base
+ OSPI_IRQ_STAT_EN
);
143 writel(val
, ospi
->base
+ OSPI_IRQ_STAT_EN
);
146 static void f_ospi_disable_irq_output(struct f_ospi
*ospi
, u32 irq_bits
)
150 val
= readl(ospi
->base
+ OSPI_IRQ_SIG_EN
);
152 writel(val
, ospi
->base
+ OSPI_IRQ_SIG_EN
);
155 static int f_ospi_prepare_config(struct f_ospi
*ospi
)
157 u32 val
, stat0
, stat1
;
159 /* G4: Disable internal clock */
160 val
= readl(ospi
->base
+ OSPI_CLK_CTL
);
161 val
&= ~(OSPI_CLK_CTL_BOOT_INT_CLK_EN
| OSPI_CLK_CTL_INT_CLK_EN
);
162 writel(val
, ospi
->base
+ OSPI_CLK_CTL
);
164 /* G5: Wait for stop */
165 stat0
= OSPI_STAT_IS_AXI_WRITING
| OSPI_STAT_IS_AXI_READING
;
166 stat1
= OSPI_STAT_IS_SPI_IDLE
| OSPI_STAT_IS_SPI_INT_CLK_STOP
;
168 return readl_poll_timeout(ospi
->base
+ OSPI_STAT
,
169 val
, (val
& (stat0
| stat1
)) == stat1
,
170 0, OSPI_WAIT_MAX_MSEC
);
173 static int f_ospi_unprepare_config(struct f_ospi
*ospi
)
177 /* G11: Enable internal clock */
178 val
= readl(ospi
->base
+ OSPI_CLK_CTL
);
179 val
|= OSPI_CLK_CTL_BOOT_INT_CLK_EN
| OSPI_CLK_CTL_INT_CLK_EN
;
180 writel(val
, ospi
->base
+ OSPI_CLK_CTL
);
182 /* G12: Wait for clock to start */
183 return readl_poll_timeout(ospi
->base
+ OSPI_STAT
,
184 val
, !(val
& OSPI_STAT_IS_SPI_INT_CLK_STOP
),
185 0, OSPI_WAIT_MAX_MSEC
);
188 static void f_ospi_config_clk(struct f_ospi
*ospi
, u32 device_hz
)
190 long rate_hz
= clk_get_rate(ospi
->clk
);
191 u32 div
= DIV_ROUND_UP(rate_hz
, device_hz
);
195 if (rate_hz
< device_hz
) {
196 dev_warn(ospi
->dev
, "Device frequency too large: %d\n",
198 div_reg
= OSPI_CLK_CTL_DIV_1
;
201 div_reg
= OSPI_CLK_CTL_DIV_1
;
202 } else if (div
== 2) {
203 div_reg
= OSPI_CLK_CTL_DIV_2
;
204 } else if (div
<= 4) {
205 div_reg
= OSPI_CLK_CTL_DIV_4
;
206 } else if (div
<= 8) {
207 div_reg
= OSPI_CLK_CTL_DIV_8
;
209 dev_warn(ospi
->dev
, "Device frequency too small: %d\n",
211 div_reg
= OSPI_CLK_CTL_DIV_8
;
217 * clock phase is fixed at 180 degrees and configure edge direction
220 val
= readl(ospi
->base
+ OSPI_CLK_CTL
);
222 val
&= ~(OSPI_CLK_CTL_PHA
| OSPI_CLK_CTL_DIV
);
223 val
|= FIELD_PREP(OSPI_CLK_CTL_PHA
, OSPI_CLK_CTL_PHA_180
)
224 | FIELD_PREP(OSPI_CLK_CTL_DIV
, div_reg
);
226 writel(val
, ospi
->base
+ OSPI_CLK_CTL
);
229 static void f_ospi_config_dll(struct f_ospi
*ospi
)
231 /* G8: Configure DLL, nothing */
234 static u8
f_ospi_get_mode(struct f_ospi
*ospi
, int width
, int data_size
)
236 u8 mode
= OSPI_PROT_MODE_SINGLE
;
240 mode
= OSPI_PROT_MODE_SINGLE
;
243 mode
= OSPI_PROT_MODE_DUAL
;
246 mode
= OSPI_PROT_MODE_QUAD
;
249 mode
= OSPI_PROT_MODE_OCTAL
;
253 dev_err(ospi
->dev
, "Invalid buswidth: %d\n", width
);
260 static void f_ospi_config_indir_protocol(struct f_ospi
*ospi
,
262 const struct spi_mem_op
*op
)
264 struct spi_device
*spi
= mem
->spi
;
269 /* Set one chip select */
270 writel(BIT(spi_get_chipselect(spi
, 0)), ospi
->base
+ OSPI_SSEL
);
272 mode
= f_ospi_get_mode(ospi
, op
->cmd
.buswidth
, 1);
273 prot
|= FIELD_PREP(OSPI_PROT_MODE_CODE_MASK
, mode
);
275 mode
= f_ospi_get_mode(ospi
, op
->addr
.buswidth
, op
->addr
.nbytes
);
276 prot
|= FIELD_PREP(OSPI_PROT_MODE_ADDR_MASK
, mode
);
278 mode
= f_ospi_get_mode(ospi
, op
->data
.buswidth
, op
->data
.nbytes
);
279 prot
|= FIELD_PREP(OSPI_PROT_MODE_DATA_MASK
, mode
);
281 prot
|= FIELD_PREP(OSPI_PROT_DATA_RATE_DATA
, OSPI_PROT_SDR
);
282 prot
|= FIELD_PREP(OSPI_PROT_DATA_RATE_ALT
, OSPI_PROT_SDR
);
283 prot
|= FIELD_PREP(OSPI_PROT_DATA_RATE_ADDR
, OSPI_PROT_SDR
);
284 prot
|= FIELD_PREP(OSPI_PROT_DATA_RATE_CODE
, OSPI_PROT_SDR
);
286 if (spi
->mode
& SPI_LSB_FIRST
)
287 prot
|= OSPI_PROT_BIT_POS_DATA
| OSPI_PROT_BIT_POS_ALT
288 | OSPI_PROT_BIT_POS_ADDR
| OSPI_PROT_BIT_POS_CODE
;
290 if (spi
->mode
& SPI_CPHA
)
291 prot
|= OSPI_PROT_SAMP_EDGE
;
293 /* Examine nbytes % 4 */
294 switch (op
->data
.nbytes
& 0x3) {
296 unit
= OSPI_PROT_DATA_UNIT_4B
;
300 unit
= OSPI_PROT_DATA_UNIT_2B
;
301 val
= OSPI_DAT_SIZE_EN
| (op
->data
.nbytes
- 1);
304 unit
= OSPI_PROT_DATA_UNIT_1B
;
305 val
= OSPI_DAT_SIZE_EN
| (op
->data
.nbytes
- 1);
308 prot
|= FIELD_PREP(OSPI_PROT_DATA_UNIT_MASK
, unit
);
310 switch (op
->data
.dir
) {
311 case SPI_MEM_DATA_IN
:
312 prot
|= OSPI_PROT_DATA_EN
;
315 case SPI_MEM_DATA_OUT
:
316 prot
|= OSPI_PROT_TRANS_DIR_WRITE
| OSPI_PROT_DATA_EN
;
319 case SPI_MEM_NO_DATA
:
320 prot
|= OSPI_PROT_TRANS_DIR_WRITE
;
324 dev_warn(ospi
->dev
, "Unsupported direction");
328 prot
|= FIELD_PREP(OSPI_PROT_ADDR_SIZE_MASK
, op
->addr
.nbytes
);
329 prot
|= FIELD_PREP(OSPI_PROT_CODE_SIZE_MASK
, 1); /* 1byte */
331 writel(prot
, ospi
->base
+ OSPI_PROT_CTL_INDIR
);
332 writel(val
, ospi
->base
+ OSPI_DAT_SIZE_INDIR
);
335 static int f_ospi_indir_prepare_op(struct f_ospi
*ospi
, struct spi_mem
*mem
,
336 const struct spi_mem_op
*op
)
338 struct spi_device
*spi
= mem
->spi
;
342 ret
= f_ospi_prepare_config(ospi
);
346 f_ospi_config_clk(ospi
, spi
->max_speed_hz
);
348 f_ospi_config_indir_protocol(ospi
, mem
, op
);
350 writel(f_ospi_get_dummy_cycle(op
), ospi
->base
+ OSPI_DMY_INDIR
);
351 writel(op
->addr
.val
, ospi
->base
+ OSPI_ADDR
);
352 writel(op
->cmd
.opcode
, ospi
->base
+ OSPI_CMD_IDX_INDIR
);
354 f_ospi_clear_irq(ospi
);
356 switch (op
->data
.dir
) {
357 case SPI_MEM_DATA_IN
:
358 irq_stat_en
= OSPI_IRQ_READ_BUF_READY
| OSPI_IRQ_CS_TRANS_COMP
;
361 case SPI_MEM_DATA_OUT
:
362 irq_stat_en
= OSPI_IRQ_WRITE_BUF_READY
| OSPI_IRQ_CS_TRANS_COMP
;
365 case SPI_MEM_NO_DATA
:
366 irq_stat_en
= OSPI_IRQ_CS_TRANS_COMP
;
370 dev_warn(ospi
->dev
, "Unsupported direction");
374 f_ospi_disable_irq_status(ospi
, ~irq_stat_en
);
375 f_ospi_enable_irq_status(ospi
, irq_stat_en
);
377 return f_ospi_unprepare_config(ospi
);
380 static void f_ospi_indir_start_xfer(struct f_ospi
*ospi
)
382 /* Write only 1, auto cleared */
383 writel(OSPI_TRANS_CTL_START_REQ
, ospi
->base
+ OSPI_TRANS_CTL
);
386 static void f_ospi_indir_stop_xfer(struct f_ospi
*ospi
)
388 /* Write only 1, auto cleared */
389 writel(OSPI_TRANS_CTL_STOP_REQ
, ospi
->base
+ OSPI_TRANS_CTL
);
392 static int f_ospi_indir_wait_xfer_complete(struct f_ospi
*ospi
)
396 return readl_poll_timeout(ospi
->base
+ OSPI_IRQ
, val
,
397 val
& OSPI_IRQ_CS_TRANS_COMP
,
398 0, OSPI_WAIT_MAX_MSEC
);
401 static int f_ospi_indir_read(struct f_ospi
*ospi
, struct spi_mem
*mem
,
402 const struct spi_mem_op
*op
)
404 u8
*buf
= op
->data
.buf
.in
;
408 mutex_lock(&ospi
->mlock
);
410 /* E1-2: Prepare transfer operation */
411 ret
= f_ospi_indir_prepare_op(ospi
, mem
, op
);
415 f_ospi_indir_start_xfer(ospi
);
417 /* E3-4: Wait for ready and read data */
418 for (i
= 0; i
< op
->data
.nbytes
; i
++) {
419 ret
= readl_poll_timeout(ospi
->base
+ OSPI_IRQ
, val
,
420 val
& OSPI_IRQ_READ_BUF_READY
,
421 0, OSPI_WAIT_MAX_MSEC
);
425 buf
[i
] = readl(ospi
->base
+ OSPI_DAT
) & 0xFF;
428 /* E5-6: Stop transfer if data size is nothing */
429 if (!(readl(ospi
->base
+ OSPI_DAT_SIZE_INDIR
) & OSPI_DAT_SIZE_EN
))
430 f_ospi_indir_stop_xfer(ospi
);
432 /* E7-8: Wait for completion and clear */
433 ret
= f_ospi_indir_wait_xfer_complete(ospi
);
437 writel(OSPI_IRQ_CS_TRANS_COMP
, ospi
->base
+ OSPI_IRQ
);
439 /* E9: Do nothing if data size is valid */
440 if (readl(ospi
->base
+ OSPI_DAT_SIZE_INDIR
) & OSPI_DAT_SIZE_EN
)
443 /* E10-11: Reset and check read fifo */
444 writel(OSPI_SWRST_INDIR_READ_FIFO
, ospi
->base
+ OSPI_SWRST
);
446 ret
= readl_poll_timeout(ospi
->base
+ OSPI_SWRST
, val
,
447 !(val
& OSPI_SWRST_INDIR_READ_FIFO
),
448 0, OSPI_WAIT_MAX_MSEC
);
450 mutex_unlock(&ospi
->mlock
);
455 static int f_ospi_indir_write(struct f_ospi
*ospi
, struct spi_mem
*mem
,
456 const struct spi_mem_op
*op
)
458 u8
*buf
= (u8
*)op
->data
.buf
.out
;
462 mutex_lock(&ospi
->mlock
);
464 /* F1-3: Prepare transfer operation */
465 ret
= f_ospi_indir_prepare_op(ospi
, mem
, op
);
469 f_ospi_indir_start_xfer(ospi
);
471 if (!(readl(ospi
->base
+ OSPI_PROT_CTL_INDIR
) & OSPI_PROT_DATA_EN
))
474 /* F4-5: Wait for buffer ready and write data */
475 for (i
= 0; i
< op
->data
.nbytes
; i
++) {
476 ret
= readl_poll_timeout(ospi
->base
+ OSPI_IRQ
, val
,
477 val
& OSPI_IRQ_WRITE_BUF_READY
,
478 0, OSPI_WAIT_MAX_MSEC
);
482 writel(buf
[i
], ospi
->base
+ OSPI_DAT
);
485 /* F6-7: Stop transfer if data size is nothing */
486 if (!(readl(ospi
->base
+ OSPI_DAT_SIZE_INDIR
) & OSPI_DAT_SIZE_EN
))
487 f_ospi_indir_stop_xfer(ospi
);
490 /* F8-9: Wait for completion and clear */
491 ret
= f_ospi_indir_wait_xfer_complete(ospi
);
495 writel(OSPI_IRQ_CS_TRANS_COMP
, ospi
->base
+ OSPI_IRQ
);
497 mutex_unlock(&ospi
->mlock
);
502 static int f_ospi_exec_op(struct spi_mem
*mem
, const struct spi_mem_op
*op
)
504 struct f_ospi
*ospi
= spi_controller_get_devdata(mem
->spi
->controller
);
507 switch (op
->data
.dir
) {
508 case SPI_MEM_DATA_IN
:
509 err
= f_ospi_indir_read(ospi
, mem
, op
);
512 case SPI_MEM_DATA_OUT
:
514 case SPI_MEM_NO_DATA
:
515 err
= f_ospi_indir_write(ospi
, mem
, op
);
519 dev_warn(ospi
->dev
, "Unsupported direction");
526 static bool f_ospi_supports_op_width(struct spi_mem
*mem
,
527 const struct spi_mem_op
*op
)
529 static const u8 width_available
[] = { 0, 1, 2, 4, 8 };
530 u8 width_op
[] = { op
->cmd
.buswidth
, op
->addr
.buswidth
,
531 op
->dummy
.buswidth
, op
->data
.buswidth
};
535 for (i
= 0; i
< ARRAY_SIZE(width_op
); i
++) {
536 is_match_found
= false;
538 for (j
= 0; j
< ARRAY_SIZE(width_available
); j
++) {
539 if (width_op
[i
] == width_available
[j
]) {
540 is_match_found
= true;
552 static bool f_ospi_supports_op(struct spi_mem
*mem
,
553 const struct spi_mem_op
*op
)
555 if (f_ospi_get_dummy_cycle(op
) > OSPI_DUMMY_CYCLE_MAX
)
558 if (op
->addr
.nbytes
> 4)
561 if (!f_ospi_supports_op_width(mem
, op
))
564 return spi_mem_default_supports_op(mem
, op
);
567 static int f_ospi_adjust_op_size(struct spi_mem
*mem
, struct spi_mem_op
*op
)
569 op
->data
.nbytes
= min_t(int, op
->data
.nbytes
, OSPI_DAT_SIZE_MAX
);
574 static const struct spi_controller_mem_ops f_ospi_mem_ops
= {
575 .adjust_op_size
= f_ospi_adjust_op_size
,
576 .supports_op
= f_ospi_supports_op
,
577 .exec_op
= f_ospi_exec_op
,
580 static int f_ospi_init(struct f_ospi
*ospi
)
584 ret
= f_ospi_prepare_config(ospi
);
588 /* Disable boot signal */
589 writel(OSPI_ACC_MODE_BOOT_DISABLE
, ospi
->base
+ OSPI_ACC_MODE
);
591 f_ospi_config_dll(ospi
);
594 f_ospi_clear_irq(ospi
);
595 f_ospi_disable_irq_status(ospi
, OSPI_IRQ_ALL
);
596 f_ospi_disable_irq_output(ospi
, OSPI_IRQ_ALL
);
598 return f_ospi_unprepare_config(ospi
);
601 static int f_ospi_probe(struct platform_device
*pdev
)
603 struct spi_controller
*ctlr
;
604 struct device
*dev
= &pdev
->dev
;
606 u32 num_cs
= OSPI_NUM_CS
;
609 ctlr
= spi_alloc_host(dev
, sizeof(*ospi
));
613 ctlr
->mode_bits
= SPI_TX_DUAL
| SPI_TX_QUAD
| SPI_TX_OCTAL
614 | SPI_RX_DUAL
| SPI_RX_QUAD
| SPI_RX_OCTAL
615 | SPI_MODE_0
| SPI_MODE_1
| SPI_LSB_FIRST
;
616 ctlr
->mem_ops
= &f_ospi_mem_ops
;
618 of_property_read_u32(dev
->of_node
, "num-cs", &num_cs
);
619 if (num_cs
> OSPI_NUM_CS
) {
620 dev_err(dev
, "num-cs too large: %d\n", num_cs
);
623 ctlr
->num_chipselect
= num_cs
;
624 ctlr
->dev
.of_node
= dev
->of_node
;
626 ospi
= spi_controller_get_devdata(ctlr
);
629 platform_set_drvdata(pdev
, ospi
);
631 ospi
->base
= devm_platform_ioremap_resource(pdev
, 0);
632 if (IS_ERR(ospi
->base
)) {
633 ret
= PTR_ERR(ospi
->base
);
637 ospi
->clk
= devm_clk_get_enabled(dev
, NULL
);
638 if (IS_ERR(ospi
->clk
)) {
639 ret
= PTR_ERR(ospi
->clk
);
643 mutex_init(&ospi
->mlock
);
645 ret
= f_ospi_init(ospi
);
647 goto err_destroy_mutex
;
649 ret
= devm_spi_register_controller(dev
, ctlr
);
651 goto err_destroy_mutex
;
656 mutex_destroy(&ospi
->mlock
);
659 spi_controller_put(ctlr
);
664 static void f_ospi_remove(struct platform_device
*pdev
)
666 struct f_ospi
*ospi
= platform_get_drvdata(pdev
);
668 mutex_destroy(&ospi
->mlock
);
671 static const struct of_device_id f_ospi_dt_ids
[] = {
672 { .compatible
= "socionext,f-ospi" },
675 MODULE_DEVICE_TABLE(of
, f_ospi_dt_ids
);
677 static struct platform_driver f_ospi_driver
= {
679 .name
= "socionext,f-ospi",
680 .of_match_table
= f_ospi_dt_ids
,
682 .probe
= f_ospi_probe
,
683 .remove
= f_ospi_remove
,
685 module_platform_driver(f_ospi_driver
);
687 MODULE_DESCRIPTION("Socionext F_OSPI controller driver");
688 MODULE_AUTHOR("Socionext Inc.");
689 MODULE_AUTHOR("Kunihiko Hayashi <hayashi.kunihiko@socionext.com>");
690 MODULE_LICENSE("GPL");