Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ast: Add I/O helpers without ast device

Implement I/O access in helpers that do not use an ast device
instance, but the raw pointer to the I/O memory. We'll later need
these helpers to detect the device type before allocating the ast
device instance.

v3:
* fix typo in commit message (Sui)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231116100240.22975-5-tzimmermann@suse.de

+56 -17
+56 -17
drivers/gpu/drm/ast/ast_drv.h
··· 273 273 #define IS_AST_GEN6(__ast) __ast_gen_is_eq(__ast, 6) 274 274 #define IS_AST_GEN7(__ast) __ast_gen_is_eq(__ast, 7) 275 275 276 + static inline u8 __ast_read8(const void __iomem *addr, u32 reg) 277 + { 278 + return ioread8(addr + reg); 279 + } 280 + 281 + static inline u32 __ast_read32(const void __iomem *addr, u32 reg) 282 + { 283 + return ioread32(addr + reg); 284 + } 285 + 286 + static inline void __ast_write8(void __iomem *addr, u32 reg, u8 val) 287 + { 288 + iowrite8(val, addr + reg); 289 + } 290 + 291 + static inline void __ast_write32(void __iomem *addr, u32 reg, u32 val) 292 + { 293 + iowrite32(val, addr + reg); 294 + } 295 + 296 + static inline u8 __ast_read8_i(void __iomem *addr, u32 reg, u8 index) 297 + { 298 + __ast_write8(addr, reg, index); 299 + return __ast_read8(addr, reg + 1); 300 + } 301 + 302 + static inline u8 __ast_read8_i_masked(void __iomem *addr, u32 reg, u8 index, u8 read_mask) 303 + { 304 + u8 val = __ast_read8_i(addr, reg, index); 305 + 306 + return val & read_mask; 307 + } 308 + 309 + static inline void __ast_write8_i(void __iomem *addr, u32 reg, u8 index, u8 val) 310 + { 311 + __ast_write8(addr, reg, index); 312 + __ast_write8(addr, reg + 1, val); 313 + } 314 + 315 + static inline void __ast_write8_i_masked(void __iomem *addr, u32 reg, u8 index, u8 read_mask, 316 + u8 val) 317 + { 318 + u8 tmp = __ast_read8_i_masked(addr, reg, index, read_mask); 319 + 320 + tmp |= val; 321 + __ast_write8_i(addr, reg, index, tmp); 322 + } 323 + 276 324 static inline u32 ast_read32(struct ast_device *ast, u32 reg) 277 325 { 278 - return ioread32(ast->regs + reg); 326 + return __ast_read32(ast->regs, reg); 279 327 } 280 328 281 329 static inline void ast_write32(struct ast_device *ast, u32 reg, u32 val) 282 330 { 283 - iowrite32(val, ast->regs + reg); 331 + __ast_write32(ast->regs, reg, val); 284 332 } 285 333 286 334 static inline u8 ast_io_read8(struct ast_device *ast, u32 reg) 287 335 { 288 - return ioread8(ast->ioregs + reg); 336 + return __ast_read8(ast->ioregs, reg); 289 337 } 290 338 291 339 static inline void ast_io_write8(struct ast_device *ast, u32 reg, u8 val) 292 340 { 293 - iowrite8(val, ast->ioregs + reg); 341 + __ast_write8(ast->ioregs, reg, val); 294 342 } 295 343 296 344 static inline u8 ast_get_index_reg(struct ast_device *ast, u32 base, u8 index) 297 345 { 298 - ast_io_write8(ast, base, index); 299 - ++base; 300 - return ast_io_read8(ast, base); 346 + return __ast_read8_i(ast->ioregs, base, index); 301 347 } 302 348 303 349 static inline u8 ast_get_index_reg_mask(struct ast_device *ast, u32 base, u8 index, 304 350 u8 preserve_mask) 305 351 { 306 - u8 val = ast_get_index_reg(ast, base, index); 307 - 308 - return val & preserve_mask; 352 + return __ast_read8_i_masked(ast->ioregs, base, index, preserve_mask); 309 353 } 310 354 311 355 static inline void ast_set_index_reg(struct ast_device *ast, u32 base, u8 index, u8 val) 312 356 { 313 - ast_io_write8(ast, base, index); 314 - ++base; 315 - ast_io_write8(ast, base, val); 357 + __ast_write8_i(ast->ioregs, base, index, val); 316 358 } 317 359 318 360 static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 index, 319 361 u8 preserve_mask, u8 val) 320 362 { 321 - u8 tmp = ast_get_index_reg_mask(ast, base, index, preserve_mask); 322 - 323 - tmp |= val; 324 - ast_set_index_reg(ast, base, index, tmp); 363 + __ast_write8_i_masked(ast->ioregs, base, index, preserve_mask, val); 325 364 } 326 365 327 366 #define AST_VIDMEM_SIZE_8M 0x00800000