1 // SPDX-License-Identifier: GPL-2.0
3 * DFL device driver for Nios private feature on Intel PAC (Programmable
4 * Acceleration Card) N3000
6 * Copyright (C) 2019-2020 Intel Corporation, Inc.
9 * Wu Hao <hao.wu@intel.com>
10 * Xu Yilun <yilun.xu@intel.com>
12 #include <linux/bitfield.h>
13 #include <linux/dfl.h>
14 #include <linux/errno.h>
16 #include <linux/io-64-nonatomic-lo-hi.h>
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/regmap.h>
21 #include <linux/stddef.h>
22 #include <linux/spi/altera.h>
23 #include <linux/spi/spi.h>
24 #include <linux/types.h>
27 * N3000 Nios private feature registers, named as NIOS_SPI_XX on spec.
28 * NS is the abbreviation of NIOS_SPI.
30 #define N3000_NS_PARAM 0x8
31 #define N3000_NS_PARAM_SHIFT_MODE_MSK BIT_ULL(1)
32 #define N3000_NS_PARAM_SHIFT_MODE_MSB 0
33 #define N3000_NS_PARAM_SHIFT_MODE_LSB 1
34 #define N3000_NS_PARAM_DATA_WIDTH GENMASK_ULL(7, 2)
35 #define N3000_NS_PARAM_NUM_CS GENMASK_ULL(13, 8)
36 #define N3000_NS_PARAM_CLK_POL BIT_ULL(14)
37 #define N3000_NS_PARAM_CLK_PHASE BIT_ULL(15)
38 #define N3000_NS_PARAM_PERIPHERAL_ID GENMASK_ULL(47, 32)
40 #define N3000_NS_CTRL 0x10
41 #define N3000_NS_CTRL_WR_DATA GENMASK_ULL(31, 0)
42 #define N3000_NS_CTRL_ADDR GENMASK_ULL(44, 32)
43 #define N3000_NS_CTRL_CMD_MSK GENMASK_ULL(63, 62)
44 #define N3000_NS_CTRL_CMD_NOP 0
45 #define N3000_NS_CTRL_CMD_RD 1
46 #define N3000_NS_CTRL_CMD_WR 2
48 #define N3000_NS_STAT 0x18
49 #define N3000_NS_STAT_RD_DATA GENMASK_ULL(31, 0)
50 #define N3000_NS_STAT_RW_VAL BIT_ULL(32)
52 /* Nios handshake registers, indirect access */
53 #define N3000_NIOS_INIT 0x1000
54 #define N3000_NIOS_INIT_DONE BIT(0)
55 #define N3000_NIOS_INIT_START BIT(1)
56 /* Mode for retimer A, link 0, the same below */
57 #define N3000_NIOS_INIT_REQ_FEC_MODE_A0_MSK GENMASK(9, 8)
58 #define N3000_NIOS_INIT_REQ_FEC_MODE_A1_MSK GENMASK(11, 10)
59 #define N3000_NIOS_INIT_REQ_FEC_MODE_A2_MSK GENMASK(13, 12)
60 #define N3000_NIOS_INIT_REQ_FEC_MODE_A3_MSK GENMASK(15, 14)
61 #define N3000_NIOS_INIT_REQ_FEC_MODE_B0_MSK GENMASK(17, 16)
62 #define N3000_NIOS_INIT_REQ_FEC_MODE_B1_MSK GENMASK(19, 18)
63 #define N3000_NIOS_INIT_REQ_FEC_MODE_B2_MSK GENMASK(21, 20)
64 #define N3000_NIOS_INIT_REQ_FEC_MODE_B3_MSK GENMASK(23, 22)
65 #define N3000_NIOS_INIT_REQ_FEC_MODE_NO 0x0
66 #define N3000_NIOS_INIT_REQ_FEC_MODE_KR 0x1
67 #define N3000_NIOS_INIT_REQ_FEC_MODE_RS 0x2
69 #define N3000_NIOS_FW_VERSION 0x1004
70 #define N3000_NIOS_FW_VERSION_PATCH GENMASK(23, 20)
71 #define N3000_NIOS_FW_VERSION_MINOR GENMASK(27, 24)
72 #define N3000_NIOS_FW_VERSION_MAJOR GENMASK(31, 28)
74 /* The retimers we use on Intel PAC N3000 is Parkvale, abbreviated to PKVL */
75 #define N3000_NIOS_PKVL_A_MODE_STS 0x1020
76 #define N3000_NIOS_PKVL_B_MODE_STS 0x1024
77 #define N3000_NIOS_PKVL_MODE_STS_GROUP_MSK GENMASK(15, 8)
78 #define N3000_NIOS_PKVL_MODE_STS_GROUP_OK 0x0
79 #define N3000_NIOS_PKVL_MODE_STS_ID_MSK GENMASK(7, 0)
80 /* When GROUP MASK field == GROUP_OK */
81 #define N3000_NIOS_PKVL_MODE_ID_RESET 0x0
82 #define N3000_NIOS_PKVL_MODE_ID_4X10G 0x1
83 #define N3000_NIOS_PKVL_MODE_ID_4X25G 0x2
84 #define N3000_NIOS_PKVL_MODE_ID_2X25G 0x3
85 #define N3000_NIOS_PKVL_MODE_ID_2X25G_2X10G 0x4
86 #define N3000_NIOS_PKVL_MODE_ID_1X25G 0x5
88 #define N3000_NIOS_REGBUS_RETRY_COUNT 10000 /* loop count */
90 #define N3000_NIOS_INIT_TIMEOUT 10000000 /* usec */
91 #define N3000_NIOS_INIT_TIME_INTV 100000 /* usec */
93 #define N3000_NIOS_INIT_REQ_FEC_MODE_MSK_ALL \
94 (N3000_NIOS_INIT_REQ_FEC_MODE_A0_MSK | \
95 N3000_NIOS_INIT_REQ_FEC_MODE_A1_MSK | \
96 N3000_NIOS_INIT_REQ_FEC_MODE_A2_MSK | \
97 N3000_NIOS_INIT_REQ_FEC_MODE_A3_MSK | \
98 N3000_NIOS_INIT_REQ_FEC_MODE_B0_MSK | \
99 N3000_NIOS_INIT_REQ_FEC_MODE_B1_MSK | \
100 N3000_NIOS_INIT_REQ_FEC_MODE_B2_MSK | \
101 N3000_NIOS_INIT_REQ_FEC_MODE_B3_MSK)
103 #define N3000_NIOS_INIT_REQ_FEC_MODE_NO_ALL \
104 (FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A0_MSK, \
105 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
106 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A1_MSK, \
107 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
108 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A2_MSK, \
109 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
110 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A3_MSK, \
111 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
112 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B0_MSK, \
113 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
114 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B1_MSK, \
115 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
116 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B2_MSK, \
117 N3000_NIOS_INIT_REQ_FEC_MODE_NO) | \
118 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B3_MSK, \
119 N3000_NIOS_INIT_REQ_FEC_MODE_NO))
121 #define N3000_NIOS_INIT_REQ_FEC_MODE_KR_ALL \
122 (FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A0_MSK, \
123 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
124 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A1_MSK, \
125 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
126 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A2_MSK, \
127 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
128 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A3_MSK, \
129 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
130 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B0_MSK, \
131 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
132 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B1_MSK, \
133 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
134 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B2_MSK, \
135 N3000_NIOS_INIT_REQ_FEC_MODE_KR) | \
136 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B3_MSK, \
137 N3000_NIOS_INIT_REQ_FEC_MODE_KR))
139 #define N3000_NIOS_INIT_REQ_FEC_MODE_RS_ALL \
140 (FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A0_MSK, \
141 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
142 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A1_MSK, \
143 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
144 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A2_MSK, \
145 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
146 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_A3_MSK, \
147 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
148 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B0_MSK, \
149 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
150 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B1_MSK, \
151 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
152 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B2_MSK, \
153 N3000_NIOS_INIT_REQ_FEC_MODE_RS) | \
154 FIELD_PREP(N3000_NIOS_INIT_REQ_FEC_MODE_B3_MSK, \
155 N3000_NIOS_INIT_REQ_FEC_MODE_RS))
159 struct regmap
*regmap
;
161 struct platform_device
*altera_spi
;
164 static ssize_t
nios_fw_version_show(struct device
*dev
,
165 struct device_attribute
*attr
, char *buf
)
167 struct n3000_nios
*nn
= dev_get_drvdata(dev
);
171 ret
= regmap_read(nn
->regmap
, N3000_NIOS_FW_VERSION
, &val
);
175 return sysfs_emit(buf
, "%x.%x.%x\n",
176 (u8
)FIELD_GET(N3000_NIOS_FW_VERSION_MAJOR
, val
),
177 (u8
)FIELD_GET(N3000_NIOS_FW_VERSION_MINOR
, val
),
178 (u8
)FIELD_GET(N3000_NIOS_FW_VERSION_PATCH
, val
));
180 static DEVICE_ATTR_RO(nios_fw_version
);
182 #define IS_MODE_STATUS_OK(mode_stat) \
183 (FIELD_GET(N3000_NIOS_PKVL_MODE_STS_GROUP_MSK, (mode_stat)) == \
184 N3000_NIOS_PKVL_MODE_STS_GROUP_OK)
186 #define IS_RETIMER_FEC_SUPPORTED(retimer_mode) \
187 ((retimer_mode) != N3000_NIOS_PKVL_MODE_ID_RESET && \
188 (retimer_mode) != N3000_NIOS_PKVL_MODE_ID_4X10G)
190 static int get_retimer_mode(struct n3000_nios
*nn
, unsigned int mode_stat_reg
,
191 unsigned int *retimer_mode
)
196 ret
= regmap_read(nn
->regmap
, mode_stat_reg
, &val
);
200 if (!IS_MODE_STATUS_OK(val
))
203 *retimer_mode
= FIELD_GET(N3000_NIOS_PKVL_MODE_STS_ID_MSK
, val
);
208 static ssize_t
retimer_A_mode_show(struct device
*dev
,
209 struct device_attribute
*attr
, char *buf
)
211 struct n3000_nios
*nn
= dev_get_drvdata(dev
);
215 ret
= get_retimer_mode(nn
, N3000_NIOS_PKVL_A_MODE_STS
, &mode
);
219 return sysfs_emit(buf
, "0x%x\n", mode
);
221 static DEVICE_ATTR_RO(retimer_A_mode
);
223 static ssize_t
retimer_B_mode_show(struct device
*dev
,
224 struct device_attribute
*attr
, char *buf
)
226 struct n3000_nios
*nn
= dev_get_drvdata(dev
);
230 ret
= get_retimer_mode(nn
, N3000_NIOS_PKVL_B_MODE_STS
, &mode
);
234 return sysfs_emit(buf
, "0x%x\n", mode
);
236 static DEVICE_ATTR_RO(retimer_B_mode
);
238 static ssize_t
fec_mode_show(struct device
*dev
,
239 struct device_attribute
*attr
, char *buf
)
241 unsigned int val
, retimer_a_mode
, retimer_b_mode
, fec_modes
;
242 struct n3000_nios
*nn
= dev_get_drvdata(dev
);
245 /* FEC mode setting is not supported in early FW versions */
246 ret
= regmap_read(nn
->regmap
, N3000_NIOS_FW_VERSION
, &val
);
250 if (FIELD_GET(N3000_NIOS_FW_VERSION_MAJOR
, val
) < 3)
251 return sysfs_emit(buf
, "not supported\n");
253 /* If no 25G links, FEC mode setting is not supported either */
254 ret
= get_retimer_mode(nn
, N3000_NIOS_PKVL_A_MODE_STS
, &retimer_a_mode
);
258 ret
= get_retimer_mode(nn
, N3000_NIOS_PKVL_B_MODE_STS
, &retimer_b_mode
);
262 if (!IS_RETIMER_FEC_SUPPORTED(retimer_a_mode
) &&
263 !IS_RETIMER_FEC_SUPPORTED(retimer_b_mode
))
264 return sysfs_emit(buf
, "not supported\n");
266 /* get the valid FEC mode for 25G links */
267 ret
= regmap_read(nn
->regmap
, N3000_NIOS_INIT
, &val
);
272 * FEC mode should always be the same for all links, as we set them
275 fec_modes
= (val
& N3000_NIOS_INIT_REQ_FEC_MODE_MSK_ALL
);
276 if (fec_modes
== N3000_NIOS_INIT_REQ_FEC_MODE_NO_ALL
)
277 return sysfs_emit(buf
, "no\n");
278 else if (fec_modes
== N3000_NIOS_INIT_REQ_FEC_MODE_KR_ALL
)
279 return sysfs_emit(buf
, "kr\n");
280 else if (fec_modes
== N3000_NIOS_INIT_REQ_FEC_MODE_RS_ALL
)
281 return sysfs_emit(buf
, "rs\n");
285 static DEVICE_ATTR_RO(fec_mode
);
287 static struct attribute
*n3000_nios_attrs
[] = {
288 &dev_attr_nios_fw_version
.attr
,
289 &dev_attr_retimer_A_mode
.attr
,
290 &dev_attr_retimer_B_mode
.attr
,
291 &dev_attr_fec_mode
.attr
,
294 ATTRIBUTE_GROUPS(n3000_nios
);
296 static int n3000_nios_init_done_check(struct n3000_nios
*nn
)
298 unsigned int val
, state_a
, state_b
;
299 struct device
*dev
= nn
->dev
;
303 * The SPI is shared by the Nios core inside the FPGA, Nios will use
304 * this SPI master to do some one time initialization after power up,
305 * and then release the control to OS. The driver needs to poll on
306 * INIT_DONE to see when driver could take the control.
308 * Please note that after Nios firmware version 3.0.0, INIT_START is
309 * introduced, so driver needs to trigger START firstly and then check
313 ret
= regmap_read(nn
->regmap
, N3000_NIOS_FW_VERSION
, &val
);
318 * If Nios version register is totally uninitialized(== 0x0), then the
319 * Nios firmware is missing. So host could take control of SPI master
320 * safely, but initialization work for Nios is not done. To restore the
321 * card, we need to reprogram a new Nios firmware via the BMC chip on
322 * SPI bus. So the driver doesn't error out, it continues to create the
323 * spi controller device and spi_board_info for BMC.
326 dev_err(dev
, "Nios version reg = 0x%x, skip INIT_DONE check, but the retimer may be uninitialized\n",
331 if (FIELD_GET(N3000_NIOS_FW_VERSION_MAJOR
, val
) >= 3) {
332 /* read NIOS_INIT to check if retimer initialization is done */
333 ret
= regmap_read(nn
->regmap
, N3000_NIOS_INIT
, &val
);
337 /* check if retimers are initialized already */
338 if (val
& (N3000_NIOS_INIT_DONE
| N3000_NIOS_INIT_START
))
341 /* configure FEC mode per module param */
342 val
= N3000_NIOS_INIT_START
;
345 * When the retimer is to be set to 10G mode, there is no FEC
346 * mode setting, so the REQ_FEC_MODE field will be ignored by
347 * Nios firmware in this case. But we should still fill the FEC
348 * mode field cause host could not get the retimer working mode
349 * until the Nios init is done.
351 * For now the driver doesn't support the retimer FEC mode
352 * switching per user's request. It is always set to Reed
355 * The driver will set the same FEC mode for all links.
357 val
|= N3000_NIOS_INIT_REQ_FEC_MODE_RS_ALL
;
359 ret
= regmap_write(nn
->regmap
, N3000_NIOS_INIT
, val
);
365 /* polls on NIOS_INIT_DONE */
366 ret
= regmap_read_poll_timeout(nn
->regmap
, N3000_NIOS_INIT
, val
,
367 val
& N3000_NIOS_INIT_DONE
,
368 N3000_NIOS_INIT_TIME_INTV
,
369 N3000_NIOS_INIT_TIMEOUT
);
371 dev_err(dev
, "NIOS_INIT_DONE %s\n",
372 (ret
== -ETIMEDOUT
) ? "timed out" : "check error");
374 ret2
= regmap_read(nn
->regmap
, N3000_NIOS_PKVL_A_MODE_STS
, &state_a
);
378 ret2
= regmap_read(nn
->regmap
, N3000_NIOS_PKVL_B_MODE_STS
, &state_b
);
384 * After INIT_DONE is detected, it still needs to check if the
385 * Nios firmware reports any error during the retimer
388 if (IS_MODE_STATUS_OK(state_a
) && IS_MODE_STATUS_OK(state_b
))
392 * If the retimer configuration is failed, the Nios firmware
393 * will still release the spi controller for host to
394 * communicate with the BMC. It makes possible for people to
395 * reprogram a new Nios firmware and restore the card. So the
396 * driver doesn't error out, it continues to create the spi
397 * controller device and spi_board_info for BMC.
399 dev_err(dev
, "NIOS_INIT_DONE OK, but err on retimer init\n");
402 dev_err(nn
->dev
, "PKVL_A_MODE_STS 0x%x\n", state_a
);
403 dev_err(nn
->dev
, "PKVL_B_MODE_STS 0x%x\n", state_b
);
408 static struct spi_board_info m10_n3000_info
= {
409 .modalias
= "m10-n3000",
410 .max_speed_hz
= 12500000,
415 static int create_altera_spi_controller(struct n3000_nios
*nn
)
417 struct altera_spi_platform_data pdata
= { 0 };
418 struct platform_device_info pdevinfo
= { 0 };
419 void __iomem
*base
= nn
->base
;
422 v
= readq(base
+ N3000_NS_PARAM
);
424 pdata
.mode_bits
= SPI_CS_HIGH
;
425 if (FIELD_GET(N3000_NS_PARAM_CLK_POL
, v
))
426 pdata
.mode_bits
|= SPI_CPOL
;
427 if (FIELD_GET(N3000_NS_PARAM_CLK_PHASE
, v
))
428 pdata
.mode_bits
|= SPI_CPHA
;
430 pdata
.num_chipselect
= FIELD_GET(N3000_NS_PARAM_NUM_CS
, v
);
431 pdata
.bits_per_word_mask
=
432 SPI_BPW_RANGE_MASK(1, FIELD_GET(N3000_NS_PARAM_DATA_WIDTH
, v
));
434 pdata
.num_devices
= 1;
435 pdata
.devices
= &m10_n3000_info
;
437 dev_dbg(nn
->dev
, "%s cs %u bpm 0x%x mode 0x%x\n", __func__
,
438 pdata
.num_chipselect
, pdata
.bits_per_word_mask
,
441 pdevinfo
.name
= "subdev_spi_altera";
442 pdevinfo
.id
= PLATFORM_DEVID_AUTO
;
443 pdevinfo
.parent
= nn
->dev
;
444 pdevinfo
.data
= &pdata
;
445 pdevinfo
.size_data
= sizeof(pdata
);
447 nn
->altera_spi
= platform_device_register_full(&pdevinfo
);
448 return PTR_ERR_OR_ZERO(nn
->altera_spi
);
451 static void destroy_altera_spi_controller(struct n3000_nios
*nn
)
453 platform_device_unregister(nn
->altera_spi
);
456 static int n3000_nios_poll_stat_timeout(void __iomem
*base
, u64
*v
)
461 * We don't use the time based timeout here for performance.
463 * The regbus read/write is on the critical path of Intel PAC N3000
464 * image programming. The time based timeout checking will add too much
465 * overhead on it. Usually the state changes in 1 or 2 loops on the
466 * test server, and we set 10000 times loop here for safety.
468 for (loops
= N3000_NIOS_REGBUS_RETRY_COUNT
; loops
> 0 ; loops
--) {
469 *v
= readq(base
+ N3000_NS_STAT
);
470 if (*v
& N3000_NS_STAT_RW_VAL
)
475 return (loops
> 0) ? 0 : -ETIMEDOUT
;
478 static int n3000_nios_reg_write(void *context
, unsigned int reg
, unsigned int val
)
480 struct n3000_nios
*nn
= context
;
484 v
= FIELD_PREP(N3000_NS_CTRL_CMD_MSK
, N3000_NS_CTRL_CMD_WR
) |
485 FIELD_PREP(N3000_NS_CTRL_ADDR
, reg
) |
486 FIELD_PREP(N3000_NS_CTRL_WR_DATA
, val
);
487 writeq(v
, nn
->base
+ N3000_NS_CTRL
);
489 ret
= n3000_nios_poll_stat_timeout(nn
->base
, &v
);
491 dev_err(nn
->dev
, "fail to write reg 0x%x val 0x%x: %d\n",
497 static int n3000_nios_reg_read(void *context
, unsigned int reg
, unsigned int *val
)
499 struct n3000_nios
*nn
= context
;
503 v
= FIELD_PREP(N3000_NS_CTRL_CMD_MSK
, N3000_NS_CTRL_CMD_RD
) |
504 FIELD_PREP(N3000_NS_CTRL_ADDR
, reg
);
505 writeq(v
, nn
->base
+ N3000_NS_CTRL
);
507 ret
= n3000_nios_poll_stat_timeout(nn
->base
, &v
);
509 dev_err(nn
->dev
, "fail to read reg 0x%x: %d\n", reg
, ret
);
511 *val
= FIELD_GET(N3000_NS_STAT_RD_DATA
, v
);
516 static const struct regmap_config n3000_nios_regbus_cfg
= {
522 .reg_write
= n3000_nios_reg_write
,
523 .reg_read
= n3000_nios_reg_read
,
526 static int n3000_nios_probe(struct dfl_device
*ddev
)
528 struct device
*dev
= &ddev
->dev
;
529 struct n3000_nios
*nn
;
532 nn
= devm_kzalloc(dev
, sizeof(*nn
), GFP_KERNEL
);
536 dev_set_drvdata(&ddev
->dev
, nn
);
540 nn
->base
= devm_ioremap_resource(&ddev
->dev
, &ddev
->mmio_res
);
541 if (IS_ERR(nn
->base
))
542 return PTR_ERR(nn
->base
);
544 nn
->regmap
= devm_regmap_init(dev
, NULL
, nn
, &n3000_nios_regbus_cfg
);
545 if (IS_ERR(nn
->regmap
))
546 return PTR_ERR(nn
->regmap
);
548 ret
= n3000_nios_init_done_check(nn
);
552 ret
= create_altera_spi_controller(nn
);
554 dev_err(dev
, "altera spi controller create failed: %d\n", ret
);
559 static void n3000_nios_remove(struct dfl_device
*ddev
)
561 struct n3000_nios
*nn
= dev_get_drvdata(&ddev
->dev
);
563 destroy_altera_spi_controller(nn
);
566 #define FME_FEATURE_ID_N3000_NIOS 0xd
568 static const struct dfl_device_id n3000_nios_ids
[] = {
569 { FME_ID
, FME_FEATURE_ID_N3000_NIOS
},
572 MODULE_DEVICE_TABLE(dfl
, n3000_nios_ids
);
574 static struct dfl_driver n3000_nios_driver
= {
576 .name
= "dfl-n3000-nios",
577 .dev_groups
= n3000_nios_groups
,
579 .id_table
= n3000_nios_ids
,
580 .probe
= n3000_nios_probe
,
581 .remove
= n3000_nios_remove
,
584 module_dfl_driver(n3000_nios_driver
);
586 MODULE_DESCRIPTION("Driver for Nios private feature on Intel PAC N3000");
587 MODULE_AUTHOR("Intel Corporation");
588 MODULE_LICENSE("GPL v2");