Commit 1da14d57 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Implement register helpers in ast_drv.h

There are already a number of register I/O functions in ast_drv.h.
For consistency, move the remaining functions there as well. No
functional changes.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarSui Jingfeng <suijingfeng@loongson.cn>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Tested-by: Jocelyn Falempe <jfalempe@redhat.com> # AST2600
Link: https://patchwork.freedesktop.org/patch/msgid/20230621130032.3568-4-tzimmermann@suse.de
parent 30fe33f2
...@@ -257,22 +257,36 @@ static inline void ast_io_write8(struct ast_device *ast, u32 reg, u8 val) ...@@ -257,22 +257,36 @@ static inline void ast_io_write8(struct ast_device *ast, u32 reg, u8 val)
iowrite8(val, ast->ioregs + reg); iowrite8(val, ast->ioregs + reg);
} }
static inline void ast_set_index_reg(struct ast_device *ast, static inline u8 ast_get_index_reg(struct ast_device *ast, u32 base, u8 index)
uint32_t base, uint8_t index, {
uint8_t val) ast_io_write8(ast, base, index);
++base;
return ast_io_read8(ast, base);
}
static inline u8 ast_get_index_reg_mask(struct ast_device *ast, u32 base, u8 index,
u8 preserve_mask)
{
u8 val = ast_get_index_reg(ast, base, index);
return val & preserve_mask;
}
static inline void ast_set_index_reg(struct ast_device *ast, u32 base, u8 index, u8 val)
{ {
ast_io_write8(ast, base, index); ast_io_write8(ast, base, index);
++base; ++base;
ast_io_write8(ast, base, val); ast_io_write8(ast, base, val);
} }
void ast_set_index_reg_mask(struct ast_device *ast, static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 index,
uint32_t base, uint8_t index, u8 preserve_mask, u8 val)
uint8_t mask, uint8_t val); {
uint8_t ast_get_index_reg(struct ast_device *ast, u8 tmp = ast_get_index_reg_mask(ast, base, index, preserve_mask);
uint32_t base, uint8_t index);
uint8_t ast_get_index_reg_mask(struct ast_device *ast, tmp |= val;
uint32_t base, uint8_t index, uint8_t mask); ast_set_index_reg(ast, base, index, tmp);
}
static inline void ast_open_key(struct ast_device *ast) static inline void ast_open_key(struct ast_device *ast)
{ {
......
...@@ -35,34 +35,6 @@ ...@@ -35,34 +35,6 @@
#include "ast_drv.h" #include "ast_drv.h"
void ast_set_index_reg_mask(struct ast_device *ast,
uint32_t base, uint8_t index,
uint8_t mask, uint8_t val)
{
u8 tmp;
ast_io_write8(ast, base, index);
tmp = (ast_io_read8(ast, base + 1) & mask) | val;
ast_set_index_reg(ast, base, index, tmp);
}
uint8_t ast_get_index_reg(struct ast_device *ast,
uint32_t base, uint8_t index)
{
uint8_t ret;
ast_io_write8(ast, base, index);
ret = ast_io_read8(ast, base + 1);
return ret;
}
uint8_t ast_get_index_reg_mask(struct ast_device *ast,
uint32_t base, uint8_t index, uint8_t mask)
{
uint8_t ret;
ast_io_write8(ast, base, index);
ret = ast_io_read8(ast, base + 1) & mask;
return ret;
}
static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev) static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev)
{ {
struct device_node *np = dev->dev->of_node; struct device_node *np = dev->dev->of_node;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment