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

media: rcar-fcp: Add rcar_fcp_soft_reset()

Add a function to perform soft reset of the FCP.

It is intended to support the correct stop procedure of the VSPX-FCPVX
and VSPD-FCPD pairs according to section "62.3.7.3 Reset Operation" of
the R-Car Hardware Manual at revision 1.20.

Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20250616-vspx-reset-v2-1-6cc12ed7e9bb@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Jacopo Mondi and committed by
Hans Verkuil
6c1dedf8 d883f2e7

+41
+36
drivers/media/platform/renesas/rcar-fcp.c
··· 9 9 10 10 #include <linux/device.h> 11 11 #include <linux/dma-mapping.h> 12 + #include <linux/io.h> 13 + #include <linux/iopoll.h> 12 14 #include <linux/list.h> 13 15 #include <linux/module.h> 14 16 #include <linux/mod_devicetable.h> ··· 21 19 22 20 #include <media/rcar-fcp.h> 23 21 22 + #define RCAR_FCP_REG_RST 0x0010 23 + #define RCAR_FCP_REG_RST_SOFTRST BIT(0) 24 + #define RCAR_FCP_REG_STA 0x0018 25 + #define RCAR_FCP_REG_STA_ACT BIT(0) 26 + 24 27 struct rcar_fcp_device { 25 28 struct list_head list; 26 29 struct device *dev; 30 + void __iomem *base; 27 31 }; 28 32 29 33 static LIST_HEAD(fcp_devices); 30 34 static DEFINE_MUTEX(fcp_lock); 35 + 36 + static inline void rcar_fcp_write(struct rcar_fcp_device *fcp, u32 reg, u32 val) 37 + { 38 + iowrite32(val, fcp->base + reg); 39 + } 31 40 32 41 /* ----------------------------------------------------------------------------- 33 42 * Public API ··· 130 117 } 131 118 EXPORT_SYMBOL_GPL(rcar_fcp_disable); 132 119 120 + int rcar_fcp_soft_reset(struct rcar_fcp_device *fcp) 121 + { 122 + u32 value; 123 + int ret; 124 + 125 + if (!fcp) 126 + return 0; 127 + 128 + rcar_fcp_write(fcp, RCAR_FCP_REG_RST, RCAR_FCP_REG_RST_SOFTRST); 129 + ret = readl_poll_timeout(fcp->base + RCAR_FCP_REG_STA, 130 + value, !(value & RCAR_FCP_REG_STA_ACT), 131 + 1, 100); 132 + if (ret) 133 + dev_err(fcp->dev, "Failed to soft-reset\n"); 134 + 135 + return ret; 136 + } 137 + EXPORT_SYMBOL_GPL(rcar_fcp_soft_reset); 138 + 133 139 /* ----------------------------------------------------------------------------- 134 140 * Platform Driver 135 141 */ ··· 162 130 return -ENOMEM; 163 131 164 132 fcp->dev = &pdev->dev; 133 + 134 + fcp->base = devm_platform_ioremap_resource(pdev, 0); 135 + if (IS_ERR(fcp->base)) 136 + return PTR_ERR(fcp->base); 165 137 166 138 dma_set_max_seg_size(fcp->dev, UINT_MAX); 167 139
+5
include/media/rcar-fcp.h
··· 18 18 struct device *rcar_fcp_get_device(struct rcar_fcp_device *fcp); 19 19 int rcar_fcp_enable(struct rcar_fcp_device *fcp); 20 20 void rcar_fcp_disable(struct rcar_fcp_device *fcp); 21 + int rcar_fcp_soft_reset(struct rcar_fcp_device *fcp); 21 22 #else 22 23 static inline struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np) 23 24 { ··· 34 33 return 0; 35 34 } 36 35 static inline void rcar_fcp_disable(struct rcar_fcp_device *fcp) { } 36 + static inline int rcar_fcp_soft_reset(struct rcar_fcp_device *fcp) 37 + { 38 + return 0; 39 + } 37 40 #endif 38 41 39 42 #endif /* __MEDIA_RCAR_FCP_H__ */