Lines Matching refs:ctx

24 	void (*reg_write)(struct regmap_mmio_context *ctx,
26 unsigned int (*reg_read)(struct regmap_mmio_context *ctx,
72 static void regmap_mmio_write8(struct regmap_mmio_context *ctx, in regmap_mmio_write8() argument
76 writeb(val, ctx->regs + reg); in regmap_mmio_write8()
79 static void regmap_mmio_write8_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_write8_relaxed() argument
83 writeb_relaxed(val, ctx->regs + reg); in regmap_mmio_write8_relaxed()
86 static void regmap_mmio_write16le(struct regmap_mmio_context *ctx, in regmap_mmio_write16le() argument
90 writew(val, ctx->regs + reg); in regmap_mmio_write16le()
93 static void regmap_mmio_write16le_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_write16le_relaxed() argument
97 writew_relaxed(val, ctx->regs + reg); in regmap_mmio_write16le_relaxed()
100 static void regmap_mmio_write16be(struct regmap_mmio_context *ctx, in regmap_mmio_write16be() argument
104 iowrite16be(val, ctx->regs + reg); in regmap_mmio_write16be()
107 static void regmap_mmio_write32le(struct regmap_mmio_context *ctx, in regmap_mmio_write32le() argument
111 writel(val, ctx->regs + reg); in regmap_mmio_write32le()
114 static void regmap_mmio_write32le_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_write32le_relaxed() argument
118 writel_relaxed(val, ctx->regs + reg); in regmap_mmio_write32le_relaxed()
121 static void regmap_mmio_write32be(struct regmap_mmio_context *ctx, in regmap_mmio_write32be() argument
125 iowrite32be(val, ctx->regs + reg); in regmap_mmio_write32be()
129 static void regmap_mmio_write64le(struct regmap_mmio_context *ctx, in regmap_mmio_write64le() argument
133 writeq(val, ctx->regs + reg); in regmap_mmio_write64le()
136 static void regmap_mmio_write64le_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_write64le_relaxed() argument
140 writeq_relaxed(val, ctx->regs + reg); in regmap_mmio_write64le_relaxed()
146 struct regmap_mmio_context *ctx = context; in regmap_mmio_write() local
149 if (!IS_ERR(ctx->clk)) { in regmap_mmio_write()
150 ret = clk_enable(ctx->clk); in regmap_mmio_write()
155 ctx->reg_write(ctx, reg, val); in regmap_mmio_write()
157 if (!IS_ERR(ctx->clk)) in regmap_mmio_write()
158 clk_disable(ctx->clk); in regmap_mmio_write()
163 static unsigned int regmap_mmio_read8(struct regmap_mmio_context *ctx, in regmap_mmio_read8() argument
166 return readb(ctx->regs + reg); in regmap_mmio_read8()
169 static unsigned int regmap_mmio_read8_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_read8_relaxed() argument
172 return readb_relaxed(ctx->regs + reg); in regmap_mmio_read8_relaxed()
175 static unsigned int regmap_mmio_read16le(struct regmap_mmio_context *ctx, in regmap_mmio_read16le() argument
178 return readw(ctx->regs + reg); in regmap_mmio_read16le()
181 static unsigned int regmap_mmio_read16le_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_read16le_relaxed() argument
184 return readw_relaxed(ctx->regs + reg); in regmap_mmio_read16le_relaxed()
187 static unsigned int regmap_mmio_read16be(struct regmap_mmio_context *ctx, in regmap_mmio_read16be() argument
190 return ioread16be(ctx->regs + reg); in regmap_mmio_read16be()
193 static unsigned int regmap_mmio_read32le(struct regmap_mmio_context *ctx, in regmap_mmio_read32le() argument
196 return readl(ctx->regs + reg); in regmap_mmio_read32le()
199 static unsigned int regmap_mmio_read32le_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_read32le_relaxed() argument
202 return readl_relaxed(ctx->regs + reg); in regmap_mmio_read32le_relaxed()
205 static unsigned int regmap_mmio_read32be(struct regmap_mmio_context *ctx, in regmap_mmio_read32be() argument
208 return ioread32be(ctx->regs + reg); in regmap_mmio_read32be()
212 static unsigned int regmap_mmio_read64le(struct regmap_mmio_context *ctx, in regmap_mmio_read64le() argument
215 return readq(ctx->regs + reg); in regmap_mmio_read64le()
218 static unsigned int regmap_mmio_read64le_relaxed(struct regmap_mmio_context *ctx, in regmap_mmio_read64le_relaxed() argument
221 return readq_relaxed(ctx->regs + reg); in regmap_mmio_read64le_relaxed()
227 struct regmap_mmio_context *ctx = context; in regmap_mmio_read() local
230 if (!IS_ERR(ctx->clk)) { in regmap_mmio_read()
231 ret = clk_enable(ctx->clk); in regmap_mmio_read()
236 *val = ctx->reg_read(ctx, reg); in regmap_mmio_read()
238 if (!IS_ERR(ctx->clk)) in regmap_mmio_read()
239 clk_disable(ctx->clk); in regmap_mmio_read()
246 struct regmap_mmio_context *ctx = context; in regmap_mmio_free_context() local
248 if (!IS_ERR(ctx->clk)) { in regmap_mmio_free_context()
249 clk_unprepare(ctx->clk); in regmap_mmio_free_context()
250 if (!ctx->attached_clk) in regmap_mmio_free_context()
251 clk_put(ctx->clk); in regmap_mmio_free_context()
269 struct regmap_mmio_context *ctx; in regmap_mmio_gen_context() local
287 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in regmap_mmio_gen_context()
288 if (!ctx) in regmap_mmio_gen_context()
291 ctx->regs = regs; in regmap_mmio_gen_context()
292 ctx->val_bytes = config->val_bits / 8; in regmap_mmio_gen_context()
293 ctx->relaxed_mmio = config->use_relaxed_mmio; in regmap_mmio_gen_context()
294 ctx->clk = ERR_PTR(-ENODEV); in regmap_mmio_gen_context()
304 if (ctx->relaxed_mmio) { in regmap_mmio_gen_context()
305 ctx->reg_read = regmap_mmio_read8_relaxed; in regmap_mmio_gen_context()
306 ctx->reg_write = regmap_mmio_write8_relaxed; in regmap_mmio_gen_context()
308 ctx->reg_read = regmap_mmio_read8; in regmap_mmio_gen_context()
309 ctx->reg_write = regmap_mmio_write8; in regmap_mmio_gen_context()
313 if (ctx->relaxed_mmio) { in regmap_mmio_gen_context()
314 ctx->reg_read = regmap_mmio_read16le_relaxed; in regmap_mmio_gen_context()
315 ctx->reg_write = regmap_mmio_write16le_relaxed; in regmap_mmio_gen_context()
317 ctx->reg_read = regmap_mmio_read16le; in regmap_mmio_gen_context()
318 ctx->reg_write = regmap_mmio_write16le; in regmap_mmio_gen_context()
322 if (ctx->relaxed_mmio) { in regmap_mmio_gen_context()
323 ctx->reg_read = regmap_mmio_read32le_relaxed; in regmap_mmio_gen_context()
324 ctx->reg_write = regmap_mmio_write32le_relaxed; in regmap_mmio_gen_context()
326 ctx->reg_read = regmap_mmio_read32le; in regmap_mmio_gen_context()
327 ctx->reg_write = regmap_mmio_write32le; in regmap_mmio_gen_context()
332 if (ctx->relaxed_mmio) { in regmap_mmio_gen_context()
333 ctx->reg_read = regmap_mmio_read64le_relaxed; in regmap_mmio_gen_context()
334 ctx->reg_write = regmap_mmio_write64le_relaxed; in regmap_mmio_gen_context()
336 ctx->reg_read = regmap_mmio_read64le; in regmap_mmio_gen_context()
337 ctx->reg_write = regmap_mmio_write64le; in regmap_mmio_gen_context()
352 ctx->reg_read = regmap_mmio_read8; in regmap_mmio_gen_context()
353 ctx->reg_write = regmap_mmio_write8; in regmap_mmio_gen_context()
356 ctx->reg_read = regmap_mmio_read16be; in regmap_mmio_gen_context()
357 ctx->reg_write = regmap_mmio_write16be; in regmap_mmio_gen_context()
360 ctx->reg_read = regmap_mmio_read32be; in regmap_mmio_gen_context()
361 ctx->reg_write = regmap_mmio_write32be; in regmap_mmio_gen_context()
374 return ctx; in regmap_mmio_gen_context()
376 ctx->clk = clk_get(dev, clk_id); in regmap_mmio_gen_context()
377 if (IS_ERR(ctx->clk)) { in regmap_mmio_gen_context()
378 ret = PTR_ERR(ctx->clk); in regmap_mmio_gen_context()
382 ret = clk_prepare(ctx->clk); in regmap_mmio_gen_context()
384 clk_put(ctx->clk); in regmap_mmio_gen_context()
388 return ctx; in regmap_mmio_gen_context()
391 kfree(ctx); in regmap_mmio_gen_context()
402 struct regmap_mmio_context *ctx; in __regmap_init_mmio_clk() local
404 ctx = regmap_mmio_gen_context(dev, clk_id, regs, config); in __regmap_init_mmio_clk()
405 if (IS_ERR(ctx)) in __regmap_init_mmio_clk()
406 return ERR_CAST(ctx); in __regmap_init_mmio_clk()
408 return __regmap_init(dev, &regmap_mmio, ctx, config, in __regmap_init_mmio_clk()
420 struct regmap_mmio_context *ctx; in __devm_regmap_init_mmio_clk() local
422 ctx = regmap_mmio_gen_context(dev, clk_id, regs, config); in __devm_regmap_init_mmio_clk()
423 if (IS_ERR(ctx)) in __devm_regmap_init_mmio_clk()
424 return ERR_CAST(ctx); in __devm_regmap_init_mmio_clk()
426 return __devm_regmap_init(dev, &regmap_mmio, ctx, config, in __devm_regmap_init_mmio_clk()
433 struct regmap_mmio_context *ctx = map->bus_context; in regmap_mmio_attach_clk() local
435 ctx->clk = clk; in regmap_mmio_attach_clk()
436 ctx->attached_clk = true; in regmap_mmio_attach_clk()
438 return clk_prepare(ctx->clk); in regmap_mmio_attach_clk()
444 struct regmap_mmio_context *ctx = map->bus_context; in regmap_mmio_detach_clk() local
446 clk_unprepare(ctx->clk); in regmap_mmio_detach_clk()
448 ctx->attached_clk = false; in regmap_mmio_detach_clk()
449 ctx->clk = NULL; in regmap_mmio_detach_clk()