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

media: atomisp: get rid of an iomem abstraction layer

The hive_isp_css_custom_host_hrt.h code, together
with atomisp_helper.h, provides an abstraction layer for
some functions inside atomisp_compat_css20.c and atomisp_cmd.c.

There's no good reason for that. In a matter of fact, after
removing the abstraction, the code looked a lot cleaner
and easier to understand.

So, get rid of them.

While here, get rid also of the udelay(1) abstraction code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

+44 -192
+4 -3
drivers/staging/media/atomisp/pci/atomisp_cmd.c
··· 665 665 void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr, 666 666 unsigned int size) 667 667 { 668 + u32 __iomem *io_virt_addr; 668 669 unsigned int data = 0; 669 670 unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32)); 670 671 ··· 678 677 return; 679 678 } 680 679 addr += SP_DMEM_BASE; 680 + io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 681 681 do { 682 - data = _hrt_master_port_uload_32(addr); 683 - 682 + data = *io_virt_addr; 684 683 dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data); 685 - addr += sizeof(unsigned int); 684 + io_virt_addr += sizeof(u32); 686 685 size32 -= 1; 687 686 } while (size32 > 0); 688 687 }
-10
drivers/staging/media/atomisp/pci/atomisp_cmd.h
··· 65 65 /* ISP2401 */ 66 66 bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe); 67 67 68 - /* TODO:should be here instead of atomisp_helper.h 69 - extern void __iomem *atomisp_io_base; 70 - 71 - static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address) 72 - { 73 - void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF); 74 - return ret; 75 - } 76 - */ 77 - 78 68 /* 79 69 * Interrupt functions 80 70 */
+2
drivers/staging/media/atomisp/pci/atomisp_compat.h
··· 29 29 struct video_device; 30 30 enum atomisp_input_stream_id; 31 31 32 + extern void __iomem *atomisp_io_base; 33 + 32 34 struct atomisp_metadata_buf { 33 35 struct ia_css_metadata *metadata; 34 36 void *md_vptr;
+27 -18
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
··· 69 69 70 70 static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data) 71 71 { 72 + s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 72 73 unsigned long flags; 73 74 74 75 spin_lock_irqsave(&mmio_lock, flags); 75 - _hrt_master_port_store_8(addr, data); 76 + *io_virt_addr = data; 76 77 spin_unlock_irqrestore(&mmio_lock, flags); 77 78 } 78 79 79 80 static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data) 80 81 { 82 + s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 81 83 unsigned long flags; 82 84 83 85 spin_lock_irqsave(&mmio_lock, flags); 84 - _hrt_master_port_store_16(addr, data); 86 + *io_virt_addr = data; 85 87 spin_unlock_irqrestore(&mmio_lock, flags); 86 88 } 87 89 88 90 void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data) 89 91 { 92 + s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 90 93 unsigned long flags; 91 94 92 95 spin_lock_irqsave(&mmio_lock, flags); 93 - _hrt_master_port_store_32(addr, data); 96 + *io_virt_addr = data; 94 97 spin_unlock_irqrestore(&mmio_lock, flags); 95 98 } 96 99 97 100 static uint8_t atomisp_css2_hw_load_8(hrt_address addr) 98 101 { 102 + s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 99 103 unsigned long flags; 100 104 u8 ret; 101 105 102 106 spin_lock_irqsave(&mmio_lock, flags); 103 - ret = _hrt_master_port_load_8(addr); 107 + ret = *io_virt_addr; 104 108 spin_unlock_irqrestore(&mmio_lock, flags); 105 109 return ret; 106 110 } 107 111 108 112 static uint16_t atomisp_css2_hw_load_16(hrt_address addr) 109 113 { 114 + s16 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 110 115 unsigned long flags; 111 116 u16 ret; 112 117 113 118 spin_lock_irqsave(&mmio_lock, flags); 114 - ret = _hrt_master_port_load_16(addr); 119 + ret = *io_virt_addr; 115 120 spin_unlock_irqrestore(&mmio_lock, flags); 116 121 return ret; 117 122 } 118 123 119 124 static uint32_t atomisp_css2_hw_load_32(hrt_address addr) 120 125 { 126 + s32 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 121 127 unsigned long flags; 122 128 u32 ret; 123 129 124 130 spin_lock_irqsave(&mmio_lock, flags); 125 - ret = _hrt_master_port_load_32(addr); 131 + ret = *io_virt_addr; 126 132 spin_unlock_irqrestore(&mmio_lock, flags); 127 133 return ret; 128 134 } ··· 136 130 static void atomisp_css2_hw_store(hrt_address addr, 137 131 const void *from, uint32_t n) 138 132 { 133 + s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 139 134 unsigned long flags; 140 135 unsigned int i; 141 - unsigned int _to = (unsigned int)addr; 142 - const char *_from = (const char *)from; 143 136 144 137 spin_lock_irqsave(&mmio_lock, flags); 145 - for (i = 0; i < n; i++, _to++, _from++) 146 - _hrt_master_port_store_8(_to, *_from); 138 + for (i = 0; i < n; i++, io_virt_addr++, from++) 139 + *io_virt_addr = *(s8 *)from; 147 140 spin_unlock_irqrestore(&mmio_lock, flags); 148 141 } 149 142 150 143 static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n) 151 144 { 145 + s8 __iomem *io_virt_addr = atomisp_io_base + (addr & 0x003FFFFF); 152 146 unsigned long flags; 153 147 unsigned int i; 154 - char *_to = (char *)to; 155 - unsigned int _from = (unsigned int)addr; 156 148 157 149 spin_lock_irqsave(&mmio_lock, flags); 158 - for (i = 0; i < n; i++, _to++, _from++) 159 - *_to = _hrt_master_port_load_8(_from); 150 + for (i = 0; i < n; i++, to++, io_virt_addr++) 151 + *(s8 *)to = *io_virt_addr; 160 152 spin_unlock_irqrestore(&mmio_lock, flags); 161 153 } 162 154 ··· 996 992 int atomisp_css_irq_enable(struct atomisp_device *isp, 997 993 enum ia_css_irq_info info, bool enable) 998 994 { 999 - dev_dbg(isp->dev, "%s: css irq info 0x%08x: %s.\n", 995 + dev_dbg(isp->dev, "%s: css irq info 0x%08x: %s (%d).\n", 1000 996 __func__, info, 1001 - enable ? "enable" : "disable"); 997 + enable ? "enable" : "disable", enable); 1002 998 if (ia_css_irq_enable(info, enable)) { 1003 999 dev_warn(isp->dev, "%s:Invalid irq info: 0x%08x when %s.\n", 1004 1000 __func__, info, ··· 4296 4292 struct atomisp_sub_device *asd = &isp->asd[i]; 4297 4293 /* Loop for each css vc stream */ 4298 4294 for (j = 0; j < ATOMISP_INPUT_STREAM_NUM; j++) { 4299 - if (asd->stream_env[j].stream && 4300 - asd->stream_env[j].stream_config.mode == 4295 + if (!asd->stream_env[j].stream) 4296 + continue; 4297 + 4298 + dev_dbg(isp->dev, 4299 + "stream #%d: mode: %d\n", j, 4300 + asd->stream_env[j].stream_config.mode); 4301 + if (asd->stream_env[j].stream_config.mode == 4301 4302 IA_CSS_INPUT_MODE_BUFFERED_SENSOR) 4302 4303 return false; 4303 4304 }
-29
drivers/staging/media/atomisp/pci/atomisp_helper.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Support for Medifield PNW Camera Imaging ISP subsystem. 4 - * 5 - * Copyright (c) 2010 Intel Corporation. All Rights Reserved. 6 - * 7 - * Copyright (c) 2010 Silicon Hive www.siliconhive.com. 8 - * 9 - * This program is free software; you can redistribute it and/or 10 - * modify it under the terms of the GNU General Public License version 11 - * 2 as published by the Free Software Foundation. 12 - * 13 - * This program is distributed in the hope that it will be useful, 14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 - * GNU General Public License for more details. 17 - * 18 - * 19 - */ 20 - #ifndef _atomisp_helper_h_ 21 - #define _atomisp_helper_h_ 22 - extern void __iomem *atomisp_io_base; 23 - 24 - static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address) 25 - { 26 - void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF); 27 - return ret; 28 - } 29 - #endif
-2
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/irq.c
··· 21 21 #endif 22 22 #include "gp_device.h" /* _REG_GP_IRQ_REQUEST_ADDR */ 23 23 24 - #include "platform_support.h" /* hrt_sleep() */ 25 - 26 24 static inline void irq_wait_for_write_complete( 27 25 const irq_ID_t ID); 28 26
+3 -2
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/isp.c
··· 13 13 * more details. 14 14 */ 15 15 16 + #include <linux/delay.h> 17 + 16 18 #include <system_global.h> 17 19 #include "isp.h" 18 20 ··· 23 21 #endif /* __INLINE_ISP__ */ 24 22 25 23 #include "assert_support.h" 26 - #include "platform_support.h" /* hrt_sleep() */ 27 24 28 25 void cnd_isp_irq_enable( 29 26 const isp_ID_t ID, ··· 126 125 { 127 126 assert(ID < N_ISP_ID); 128 127 isp_ctrl_setbit(ID, ISP_SC_REG, ISP_START_BIT); 129 - hrt_sleep(); 128 + udelay(1); 130 129 }
+2 -3
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/vmem.c
··· 21 21 #include "ia_css_device_access.h" 22 22 #endif 23 23 #include "assert_support.h" 24 - #include "platform_support.h" /* hrt_sleep() */ 25 24 26 25 typedef unsigned long long hive_uedge; 27 26 typedef hive_uedge *hive_wide; ··· 154 155 hive_sim_wide_unpack(data, &elem, ISP_VEC_ELEMBITS, i); 155 156 to[i] = elem; 156 157 } 157 - hrt_sleep(); /* Spend at least 1 cycles per vector */ 158 + udelay(1); /* Spend at least 1 cycles per vector */ 158 159 } 159 160 160 161 static void store_vector( ··· 179 180 //hrt_mem_store (ISP, VMEM, (unsigned)to, &v, siz); /* This will overwrite the next vector as well */ 180 181 hrt_master_port_store(ISP_BAMEM_BASE[ID] + (unsigned long)to, &v, size); 181 182 #endif 182 - hrt_sleep(); /* Spend at least 1 cycles per vector */ 183 + udelay(1); /* Spend at least 1 cycles per vector */ 183 184 } 184 185 185 186 void isp_vmem_load(
-3
drivers/staging/media/atomisp/pci/hive_isp_css_include/platform_support.h
··· 25 25 #include <linux/kernel.h> 26 26 #include <linux/string.h> 27 27 28 - /* For definition of hrt_sleep() */ 29 - #include "hive_isp_css_custom_host_hrt.h" 30 - 31 28 #define UINT16_MAX USHRT_MAX 32 29 #define UINT32_MAX UINT_MAX 33 30 #define UCHAR_MAX (255)
-107
drivers/staging/media/atomisp/pci/hrt/hive_isp_css_custom_host_hrt.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Support for Medifield PNW Camera Imaging ISP subsystem. 4 - * 5 - * Copyright (c) 2010 Intel Corporation. All Rights Reserved. 6 - * 7 - * Copyright (c) 2010 Silicon Hive www.siliconhive.com. 8 - * 9 - * This program is free software; you can redistribute it and/or 10 - * modify it under the terms of the GNU General Public License version 11 - * 2 as published by the Free Software Foundation. 12 - * 13 - * This program is distributed in the hope that it will be useful, 14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 - * GNU General Public License for more details. 17 - * 18 - * 19 - */ 20 - #ifndef _hive_isp_css_custom_host_hrt_h_ 21 - #define _hive_isp_css_custom_host_hrt_h_ 22 - 23 - #include <linux/delay.h> 24 - #include "atomisp_helper.h" 25 - 26 - /* 27 - * _hrt_master_port_store/load/uload -macros using __force attributed 28 - * cast to intentional dereferencing __iomem attributed (noderef) 29 - * pointer from atomisp_get_io_virt_addr 30 - */ 31 - #define _hrt_master_port_store_8(a, d) \ 32 - (*((s8 __force *)atomisp_get_io_virt_addr(a)) = (d)) 33 - 34 - #define _hrt_master_port_store_16(a, d) \ 35 - (*((s16 __force *)atomisp_get_io_virt_addr(a)) = (d)) 36 - 37 - #define _hrt_master_port_store_32(a, d) \ 38 - (*((s32 __force *)atomisp_get_io_virt_addr(a)) = (d)) 39 - 40 - #define _hrt_master_port_load_8(a) \ 41 - (*(s8 __force *)atomisp_get_io_virt_addr(a)) 42 - 43 - #define _hrt_master_port_load_16(a) \ 44 - (*(s16 __force *)atomisp_get_io_virt_addr(a)) 45 - 46 - #define _hrt_master_port_load_32(a) \ 47 - (*(s32 __force *)atomisp_get_io_virt_addr(a)) 48 - 49 - #define _hrt_master_port_uload_8(a) \ 50 - (*(u8 __force *)atomisp_get_io_virt_addr(a)) 51 - 52 - #define _hrt_master_port_uload_16(a) \ 53 - (*(u16 __force *)atomisp_get_io_virt_addr(a)) 54 - 55 - #define _hrt_master_port_uload_32(a) \ 56 - (*(u32 __force *)atomisp_get_io_virt_addr(a)) 57 - 58 - #define _hrt_master_port_store_8_volatile(a, d) _hrt_master_port_store_8(a, d) 59 - #define _hrt_master_port_store_16_volatile(a, d) _hrt_master_port_store_16(a, d) 60 - #define _hrt_master_port_store_32_volatile(a, d) _hrt_master_port_store_32(a, d) 61 - 62 - #define _hrt_master_port_load_8_volatile(a) _hrt_master_port_load_8(a) 63 - #define _hrt_master_port_load_16_volatile(a) _hrt_master_port_load_16(a) 64 - #define _hrt_master_port_load_32_volatile(a) _hrt_master_port_load_32(a) 65 - 66 - #define _hrt_master_port_uload_8_volatile(a) _hrt_master_port_uload_8(a) 67 - #define _hrt_master_port_uload_16_volatile(a) _hrt_master_port_uload_16(a) 68 - #define _hrt_master_port_uload_32_volatile(a) _hrt_master_port_uload_32(a) 69 - 70 - static inline void hrt_sleep(void) 71 - { 72 - udelay(1); 73 - } 74 - 75 - static inline u32 _hrt_mem_store(u32 to, const void *from, size_t n) 76 - { 77 - unsigned int i; 78 - u32 _to = to; 79 - const char *_from = (const char *)from; 80 - 81 - for (i = 0; i < n; i++, _to++, _from++) 82 - _hrt_master_port_store_8(_to, *_from); 83 - return _to; 84 - } 85 - 86 - static inline void *_hrt_mem_load(u32 from, void *to, size_t n) 87 - { 88 - unsigned int i; 89 - char *_to = (char *)to; 90 - u32 _from = from; 91 - 92 - for (i = 0; i < n; i++, _to++, _from++) 93 - *_to = _hrt_master_port_load_8(_from); 94 - return _to; 95 - } 96 - 97 - static inline u32 _hrt_mem_set(u32 to, int c, size_t n) 98 - { 99 - unsigned int i; 100 - u32 _to = to; 101 - 102 - for (i = 0; i < n; i++, _to++) 103 - _hrt_master_port_store_8(_to, c); 104 - return _to; 105 - } 106 - 107 - #endif /* _hive_isp_css_custom_host_hrt_h_ */
-2
drivers/staging/media/atomisp/pci/isp2400_system_local.h
··· 20 20 #ifndef HRT_USE_VIR_ADDRS 21 21 #define HRT_USE_VIR_ADDRS 22 22 #endif 23 - /* This interface is deprecated */ 24 - /*#include "hive_isp_css_custom_host_hrt.h"*/ 25 23 #endif 26 24 27 25 #include "system_global.h"
-2
drivers/staging/media/atomisp/pci/isp2401_system_local.h
··· 20 20 #ifndef HRT_USE_VIR_ADDRS 21 21 #define HRT_USE_VIR_ADDRS 22 22 #endif 23 - /* This interface is deprecated */ 24 - /*#include "hive_isp_css_custom_host_hrt.h"*/ 25 23 #endif 26 24 27 25 #include "system_global.h"
-1
drivers/staging/media/atomisp/pci/runtime/event/src/event.c
··· 31 31 /*#include "sp.h"*/ /* host2sp_enqueue_frame_data() */ 32 32 33 33 #include "assert_support.h" 34 - #include "platform_support.h" /* hrt_sleep() */ 35 34 36 35 #include "ia_css_queue.h" /* host_sp_enqueue_XXX */ 37 36 #include "ia_css_event.h" /* ia_css_event_encode */
+1 -3
drivers/staging/media/atomisp/pci/runtime/eventq/src/eventq.c
··· 20 20 #include "ia_css_event.h" /* ia_css_event_encode() 21 21 ia_css_event_decode() 22 22 */ 23 - #include "platform_support.h" /* hrt_sleep() */ 24 - 25 23 int ia_css_eventq_recv( 26 24 ia_css_queue_t *eventq_handle, 27 25 uint8_t *payload) ··· 70 72 break; 71 73 } 72 74 /* Wait for the queue to be not full and try again*/ 73 - hrt_sleep(); 75 + udelay(1); 74 76 } 75 77 return error; 76 78 }
+1 -1
drivers/staging/media/atomisp/pci/runtime/inputfifo/src/inputfifo.c
··· 104 104 _sh_css_fifo_snd(unsigned int token) 105 105 { 106 106 while (!can_event_send_token(STR2MIPI_EVENT_ID)) 107 - hrt_sleep(); 107 + udelay(1); 108 108 event_send_token(STR2MIPI_EVENT_ID, token); 109 109 return; 110 110 }
+3 -4
drivers/staging/media/atomisp/pci/sh_css.c
··· 76 76 #define __INLINE_GPIO__ 77 77 #include "gpio.h" 78 78 #include "timed_ctrl.h" 79 - #include "platform_support.h" /* hrt_sleep(), inline */ 80 79 #include "ia_css_inputfifo.h" 81 80 #define WITH_PC_MONITORING 0 82 81 ··· 10378 10379 while ((ia_css_spctrl_get_state(SP0_ID) != IA_CSS_SP_SW_INITIALIZED) && timeout) 10379 10380 { 10380 10381 timeout--; 10381 - hrt_sleep(); 10382 + udelay(1); 10382 10383 } 10383 10384 if (timeout == 0) 10384 10385 { ··· 10442 10443 while (!ia_css_spctrl_is_idle(SP0_ID) && timeout) 10443 10444 { 10444 10445 timeout--; 10445 - hrt_sleep(); 10446 + udelay(1); 10446 10447 } 10447 10448 if ((ia_css_spctrl_get_state(SP0_ID) != IA_CSS_SP_SW_TERMINATED)) 10448 10449 IA_CSS_WARNING("SP has not terminated (SW)"); ··· 10456 10457 while (!isp_ctrl_getbit(ISP0_ID, ISP_SC_REG, ISP_IDLE_BIT) && timeout) 10457 10458 { 10458 10459 timeout--; 10459 - hrt_sleep(); 10460 + udelay(1); 10460 10461 } 10461 10462 if (timeout == 0) 10462 10463 {
+1 -1
drivers/staging/media/atomisp/pci/sh_css_hrt.c
··· 79 79 ((irq_reg_load(IRQ0_ID, 80 80 _HRT_IRQ_CONTROLLER_STATUS_REG_IDX) & 81 81 (1U << (irq_id + IRQ_SW_CHANNEL_OFFSET))) == 0)) { 82 - hrt_sleep(); 82 + udelay(1); 83 83 } 84 84 85 85 return 0;
-1
drivers/staging/media/atomisp/pci/sh_css_sp.c
··· 48 48 49 49 50 50 #include "assert_support.h" 51 - #include "platform_support.h" /* hrt_sleep() */ 52 51 53 52 #include "sw_event_global.h" /* Event IDs.*/ 54 53 #include "ia_css_event.h"