Lines Matching +full:data +full:- +full:shift
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Author: Boris Brezillon <boris.brezillon@free-electrons.com>
11 #include <linux/mfd/syscon/atmel-smc.h>
15 * atmel_smc_cs_conf_init - initialize a SMC CS conf
27 * atmel_smc_cs_encode_ncycles - encode a number of MCK clk cycles in the
40 * If the @ncycles value is too big to be encoded, -ERANGE is returned and
49 unsigned int lsbmask = GENMASK(msbpos - 1, 0); in atmel_smc_cs_encode_ncycles()
50 unsigned int msbmask = GENMASK(msbwidth - 1, 0); in atmel_smc_cs_encode_ncycles()
65 * We still return -ERANGE in case the caller cares. in atmel_smc_cs_encode_ncycles()
70 ret = -ERANGE; in atmel_smc_cs_encode_ncycles()
79 * atmel_smc_cs_conf_set_timing - set the SMC CS conf Txx parameter to a
82 * @shift: the position of the Txx field in the TIMINGS register
88 * @conf->timings field at @shift position.
90 * Returns -EINVAL if shift is invalid, -ERANGE if ncycles does not fit in
94 unsigned int shift, unsigned int ncycles) in atmel_smc_cs_conf_set_timing() argument
99 if (shift != ATMEL_HSMC_TIMINGS_TCLR_SHIFT && in atmel_smc_cs_conf_set_timing()
100 shift != ATMEL_HSMC_TIMINGS_TADL_SHIFT && in atmel_smc_cs_conf_set_timing()
101 shift != ATMEL_HSMC_TIMINGS_TAR_SHIFT && in atmel_smc_cs_conf_set_timing()
102 shift != ATMEL_HSMC_TIMINGS_TRR_SHIFT && in atmel_smc_cs_conf_set_timing()
103 shift != ATMEL_HSMC_TIMINGS_TWB_SHIFT) in atmel_smc_cs_conf_set_timing()
104 return -EINVAL; in atmel_smc_cs_conf_set_timing()
113 conf->timings &= ~GENMASK(shift + 3, shift); in atmel_smc_cs_conf_set_timing()
114 conf->timings |= val << shift; in atmel_smc_cs_conf_set_timing()
121 * atmel_smc_cs_conf_set_setup - set the SMC CS conf xx_SETUP parameter to a
124 * @shift: the position of the xx_SETUP field in the SETUP register
130 * @conf->setup field at @shift position.
132 * Returns -EINVAL if @shift is invalid, -ERANGE if @ncycles does not fit in
136 unsigned int shift, unsigned int ncycles) in atmel_smc_cs_conf_set_setup() argument
141 if (shift != ATMEL_SMC_NWE_SHIFT && shift != ATMEL_SMC_NCS_WR_SHIFT && in atmel_smc_cs_conf_set_setup()
142 shift != ATMEL_SMC_NRD_SHIFT && shift != ATMEL_SMC_NCS_RD_SHIFT) in atmel_smc_cs_conf_set_setup()
143 return -EINVAL; in atmel_smc_cs_conf_set_setup()
152 conf->setup &= ~GENMASK(shift + 7, shift); in atmel_smc_cs_conf_set_setup()
153 conf->setup |= val << shift; in atmel_smc_cs_conf_set_setup()
160 * atmel_smc_cs_conf_set_pulse - set the SMC CS conf xx_PULSE parameter to a
163 * @shift: the position of the xx_PULSE field in the PULSE register
169 * @conf->setup field at @shift position.
171 * Returns -EINVAL if @shift is invalid, -ERANGE if @ncycles does not fit in
175 unsigned int shift, unsigned int ncycles) in atmel_smc_cs_conf_set_pulse() argument
180 if (shift != ATMEL_SMC_NWE_SHIFT && shift != ATMEL_SMC_NCS_WR_SHIFT && in atmel_smc_cs_conf_set_pulse()
181 shift != ATMEL_SMC_NRD_SHIFT && shift != ATMEL_SMC_NCS_RD_SHIFT) in atmel_smc_cs_conf_set_pulse()
182 return -EINVAL; in atmel_smc_cs_conf_set_pulse()
191 conf->pulse &= ~GENMASK(shift + 7, shift); in atmel_smc_cs_conf_set_pulse()
192 conf->pulse |= val << shift; in atmel_smc_cs_conf_set_pulse()
199 * atmel_smc_cs_conf_set_cycle - set the SMC CS conf xx_CYCLE parameter to a
202 * @shift: the position of the xx_CYCLE field in the CYCLE register
208 * @conf->setup field at @shift position.
210 * Returns -EINVAL if @shift is invalid, -ERANGE if @ncycles does not fit in
214 unsigned int shift, unsigned int ncycles) in atmel_smc_cs_conf_set_cycle() argument
219 if (shift != ATMEL_SMC_NWE_SHIFT && shift != ATMEL_SMC_NRD_SHIFT) in atmel_smc_cs_conf_set_cycle()
220 return -EINVAL; in atmel_smc_cs_conf_set_cycle()
229 conf->cycle &= ~GENMASK(shift + 15, shift); in atmel_smc_cs_conf_set_cycle()
230 conf->cycle |= val << shift; in atmel_smc_cs_conf_set_cycle()
237 * atmel_smc_cs_conf_apply - apply an SMC CS conf
248 regmap_write(regmap, ATMEL_SMC_SETUP(cs), conf->setup); in atmel_smc_cs_conf_apply()
249 regmap_write(regmap, ATMEL_SMC_PULSE(cs), conf->pulse); in atmel_smc_cs_conf_apply()
250 regmap_write(regmap, ATMEL_SMC_CYCLE(cs), conf->cycle); in atmel_smc_cs_conf_apply()
251 regmap_write(regmap, ATMEL_SMC_MODE(cs), conf->mode); in atmel_smc_cs_conf_apply()
256 * atmel_hsmc_cs_conf_apply - apply an SMC CS conf
263 * Only valid on post-sama5 SoCs.
269 regmap_write(regmap, ATMEL_HSMC_SETUP(layout, cs), conf->setup); in atmel_hsmc_cs_conf_apply()
270 regmap_write(regmap, ATMEL_HSMC_PULSE(layout, cs), conf->pulse); in atmel_hsmc_cs_conf_apply()
271 regmap_write(regmap, ATMEL_HSMC_CYCLE(layout, cs), conf->cycle); in atmel_hsmc_cs_conf_apply()
272 regmap_write(regmap, ATMEL_HSMC_TIMINGS(layout, cs), conf->timings); in atmel_hsmc_cs_conf_apply()
273 regmap_write(regmap, ATMEL_HSMC_MODE(layout, cs), conf->mode); in atmel_hsmc_cs_conf_apply()
278 * atmel_smc_cs_conf_get - retrieve the current SMC CS conf
289 regmap_read(regmap, ATMEL_SMC_SETUP(cs), &conf->setup); in atmel_smc_cs_conf_get()
290 regmap_read(regmap, ATMEL_SMC_PULSE(cs), &conf->pulse); in atmel_smc_cs_conf_get()
291 regmap_read(regmap, ATMEL_SMC_CYCLE(cs), &conf->cycle); in atmel_smc_cs_conf_get()
292 regmap_read(regmap, ATMEL_SMC_MODE(cs), &conf->mode); in atmel_smc_cs_conf_get()
297 * atmel_hsmc_cs_conf_get - retrieve the current SMC CS conf
304 * Only valid on post-sama5 SoCs.
310 regmap_read(regmap, ATMEL_HSMC_SETUP(layout, cs), &conf->setup); in atmel_hsmc_cs_conf_get()
311 regmap_read(regmap, ATMEL_HSMC_PULSE(layout, cs), &conf->pulse); in atmel_hsmc_cs_conf_get()
312 regmap_read(regmap, ATMEL_HSMC_CYCLE(layout, cs), &conf->cycle); in atmel_hsmc_cs_conf_get()
313 regmap_read(regmap, ATMEL_HSMC_TIMINGS(layout, cs), &conf->timings); in atmel_hsmc_cs_conf_get()
314 regmap_read(regmap, ATMEL_HSMC_MODE(layout, cs), &conf->mode); in atmel_hsmc_cs_conf_get()
327 { .compatible = "atmel,at91sam9260-smc", .data = NULL },
328 { .compatible = "atmel,sama5d3-smc", .data = &sama5d3_reg_layout },
329 { .compatible = "atmel,sama5d2-smc", .data = &sama5d2_reg_layout },
334 * atmel_hsmc_get_reg_layout - retrieve the layout of HSMC registers
340 * in HSMC case, otherwise ERR_PTR(-EINVAL).
349 return match ? match->data : ERR_PTR(-EINVAL); in atmel_hsmc_get_reg_layout()