hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/video/fbdev/mmp/hw/mmp_ctrl.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * linux/drivers/video/mmp/hw/mmp_ctrl.c
34 * Marvell MMP series Display Controller support
....@@ -6,20 +7,6 @@
67 * Authors: Guoqing Li <ligq@marvell.com>
78 * Lisa Du <cldu@marvell.com>
89 * Zhou Zhu <zzhu3@marvell.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of the GNU General Public License as published by the
12
- * Free Software Foundation; either version 2 of the License, or (at your
13
- * option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful, but WITHOUT
16
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18
- * more details.
19
- *
20
- * You should have received a copy of the GNU General Public License along with
21
- * this program. If not, see <http://www.gnu.org/licenses/>.
22
- *
2310 */
2411 #include <linux/module.h>
2512 #include <linux/moduleparam.h>
....@@ -149,19 +136,26 @@
149136 mutex_lock(&overlay->access_ok);
150137
151138 if (overlay_is_vid(overlay)) {
152
- writel_relaxed(win->pitch[0], &regs->v_pitch_yc);
153
- writel_relaxed(win->pitch[2] << 16 |
154
- win->pitch[1], &regs->v_pitch_uv);
139
+ writel_relaxed(win->pitch[0],
140
+ (void __iomem *)&regs->v_pitch_yc);
141
+ writel_relaxed(win->pitch[2] << 16 | win->pitch[1],
142
+ (void __iomem *)&regs->v_pitch_uv);
155143
156
- writel_relaxed((win->ysrc << 16) | win->xsrc, &regs->v_size);
157
- writel_relaxed((win->ydst << 16) | win->xdst, &regs->v_size_z);
158
- writel_relaxed(win->ypos << 16 | win->xpos, &regs->v_start);
144
+ writel_relaxed((win->ysrc << 16) | win->xsrc,
145
+ (void __iomem *)&regs->v_size);
146
+ writel_relaxed((win->ydst << 16) | win->xdst,
147
+ (void __iomem *)&regs->v_size_z);
148
+ writel_relaxed(win->ypos << 16 | win->xpos,
149
+ (void __iomem *)&regs->v_start);
159150 } else {
160
- writel_relaxed(win->pitch[0], &regs->g_pitch);
151
+ writel_relaxed(win->pitch[0], (void __iomem *)&regs->g_pitch);
161152
162
- writel_relaxed((win->ysrc << 16) | win->xsrc, &regs->g_size);
163
- writel_relaxed((win->ydst << 16) | win->xdst, &regs->g_size_z);
164
- writel_relaxed(win->ypos << 16 | win->xpos, &regs->g_start);
153
+ writel_relaxed((win->ysrc << 16) | win->xsrc,
154
+ (void __iomem *)&regs->g_size);
155
+ writel_relaxed((win->ydst << 16) | win->xdst,
156
+ (void __iomem *)&regs->g_size_z);
157
+ writel_relaxed(win->ypos << 16 | win->xpos,
158
+ (void __iomem *)&regs->g_start);
165159 }
166160
167161 dmafetch_set_fmt(overlay);
....@@ -246,11 +240,11 @@
246240 memcpy(&overlay->addr, addr, sizeof(struct mmp_addr));
247241
248242 if (overlay_is_vid(overlay)) {
249
- writel_relaxed(addr->phys[0], &regs->v_y0);
250
- writel_relaxed(addr->phys[1], &regs->v_u0);
251
- writel_relaxed(addr->phys[2], &regs->v_v0);
243
+ writel_relaxed(addr->phys[0], (void __iomem *)&regs->v_y0);
244
+ writel_relaxed(addr->phys[1], (void __iomem *)&regs->v_u0);
245
+ writel_relaxed(addr->phys[2], (void __iomem *)&regs->v_v0);
252246 } else
253
- writel_relaxed(addr->phys[0], &regs->g_0);
247
+ writel_relaxed(addr->phys[0], (void __iomem *)&regs->g_0);
254248
255249 return overlay->addr.phys[0];
256250 }
....@@ -281,16 +275,18 @@
281275 tmp |= dsi_rbswap & CFG_INTFRBSWAP_MASK;
282276 writel_relaxed(tmp, ctrl_regs(path) + intf_rbswap_ctrl(path->id));
283277
284
- writel_relaxed((mode->yres << 16) | mode->xres, &regs->screen_active);
278
+ writel_relaxed((mode->yres << 16) | mode->xres,
279
+ (void __iomem *)&regs->screen_active);
285280 writel_relaxed((mode->left_margin << 16) | mode->right_margin,
286
- &regs->screen_h_porch);
281
+ (void __iomem *)&regs->screen_h_porch);
287282 writel_relaxed((mode->upper_margin << 16) | mode->lower_margin,
288
- &regs->screen_v_porch);
283
+ (void __iomem *)&regs->screen_v_porch);
289284 total_x = mode->xres + mode->left_margin + mode->right_margin +
290285 mode->hsync_len;
291286 total_y = mode->yres + mode->upper_margin + mode->lower_margin +
292287 mode->vsync_len;
293
- writel_relaxed((total_y << 16) | total_x, &regs->screen_size);
288
+ writel_relaxed((total_y << 16) | total_x,
289
+ (void __iomem *)&regs->screen_size);
294290
295291 /* vsync ctrl */
296292 if (path->output_type == PATH_OUT_DSI)
....@@ -298,7 +294,7 @@
298294 else
299295 vsync_ctrl = ((mode->xres + mode->right_margin) << 16)
300296 | (mode->xres + mode->right_margin);
301
- writel_relaxed(vsync_ctrl, &regs->vsync_ctrl);
297
+ writel_relaxed(vsync_ctrl, (void __iomem *)&regs->vsync_ctrl);
302298
303299 /* set pixclock div */
304300 sclk_src = clk_get_rate(path_to_ctrl(path)->clk);
....@@ -379,9 +375,9 @@
379375 writel_relaxed(dma_ctrl1, ctrl_regs(path) + dma_ctrl(1, path->id));
380376
381377 /* Configure default register values */
382
- writel_relaxed(0x00000000, &regs->blank_color);
383
- writel_relaxed(0x00000000, &regs->g_1);
384
- writel_relaxed(0x00000000, &regs->g_start);
378
+ writel_relaxed(0x00000000, (void __iomem *)&regs->blank_color);
379
+ writel_relaxed(0x00000000, (void __iomem *)&regs->g_1);
380
+ writel_relaxed(0x00000000, (void __iomem *)&regs->g_start);
385381
386382 /*
387383 * 1.enable multiple burst request in DMA AXI
....@@ -446,7 +442,7 @@
446442 {
447443 struct mmp_mach_plat_info *mi;
448444 struct resource *res;
449
- int ret, i, size, irq;
445
+ int ret, i, irq;
450446 struct mmphw_path_plat *path_plat;
451447 struct mmphw_ctrl *ctrl = NULL;
452448
....@@ -460,7 +456,6 @@
460456
461457 irq = platform_get_irq(pdev, 0);
462458 if (irq < 0) {
463
- dev_err(&pdev->dev, "%s: no IRQ defined\n", __func__);
464459 ret = -ENOENT;
465460 goto failed;
466461 }
....@@ -474,9 +469,9 @@
474469 }
475470
476471 /* allocate */
477
- size = sizeof(struct mmphw_ctrl) + sizeof(struct mmphw_path_plat) *
478
- mi->path_num;
479
- ctrl = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
472
+ ctrl = devm_kzalloc(&pdev->dev,
473
+ struct_size(ctrl, path_plats, mi->path_num),
474
+ GFP_KERNEL);
480475 if (!ctrl) {
481476 ret = -ENOMEM;
482477 goto failed;
....@@ -498,7 +493,7 @@
498493 goto failed;
499494 }
500495
501
- ctrl->reg_base = devm_ioremap_nocache(ctrl->dev,
496
+ ctrl->reg_base = devm_ioremap(ctrl->dev,
502497 res->start, resource_size(res));
503498 if (ctrl->reg_base == NULL) {
504499 dev_err(ctrl->dev, "%s: res %pR map failed\n", __func__, res);
....@@ -523,7 +518,9 @@
523518 ret = -ENOENT;
524519 goto failed;
525520 }
526
- clk_prepare_enable(ctrl->clk);
521
+ ret = clk_prepare_enable(ctrl->clk);
522
+ if (ret)
523
+ goto failed;
527524
528525 /* init global regs */
529526 ctrl_set_default(ctrl);