| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/drivers/video/mmp/hw/mmp_ctrl.c |
|---|
| 3 | 4 | * Marvell MMP series Display Controller support |
|---|
| .. | .. |
|---|
| 6 | 7 | * Authors: Guoqing Li <ligq@marvell.com> |
|---|
| 7 | 8 | * Lisa Du <cldu@marvell.com> |
|---|
| 8 | 9 | * 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 | | - * |
|---|
| 23 | 10 | */ |
|---|
| 24 | 11 | #include <linux/module.h> |
|---|
| 25 | 12 | #include <linux/moduleparam.h> |
|---|
| .. | .. |
|---|
| 149 | 136 | mutex_lock(&overlay->access_ok); |
|---|
| 150 | 137 | |
|---|
| 151 | 138 | if (overlay_is_vid(overlay)) { |
|---|
| 152 | | - writel_relaxed(win->pitch[0], ®s->v_pitch_yc); |
|---|
| 153 | | - writel_relaxed(win->pitch[2] << 16 | |
|---|
| 154 | | - win->pitch[1], ®s->v_pitch_uv); |
|---|
| 139 | + writel_relaxed(win->pitch[0], |
|---|
| 140 | + (void __iomem *)®s->v_pitch_yc); |
|---|
| 141 | + writel_relaxed(win->pitch[2] << 16 | win->pitch[1], |
|---|
| 142 | + (void __iomem *)®s->v_pitch_uv); |
|---|
| 155 | 143 | |
|---|
| 156 | | - writel_relaxed((win->ysrc << 16) | win->xsrc, ®s->v_size); |
|---|
| 157 | | - writel_relaxed((win->ydst << 16) | win->xdst, ®s->v_size_z); |
|---|
| 158 | | - writel_relaxed(win->ypos << 16 | win->xpos, ®s->v_start); |
|---|
| 144 | + writel_relaxed((win->ysrc << 16) | win->xsrc, |
|---|
| 145 | + (void __iomem *)®s->v_size); |
|---|
| 146 | + writel_relaxed((win->ydst << 16) | win->xdst, |
|---|
| 147 | + (void __iomem *)®s->v_size_z); |
|---|
| 148 | + writel_relaxed(win->ypos << 16 | win->xpos, |
|---|
| 149 | + (void __iomem *)®s->v_start); |
|---|
| 159 | 150 | } else { |
|---|
| 160 | | - writel_relaxed(win->pitch[0], ®s->g_pitch); |
|---|
| 151 | + writel_relaxed(win->pitch[0], (void __iomem *)®s->g_pitch); |
|---|
| 161 | 152 | |
|---|
| 162 | | - writel_relaxed((win->ysrc << 16) | win->xsrc, ®s->g_size); |
|---|
| 163 | | - writel_relaxed((win->ydst << 16) | win->xdst, ®s->g_size_z); |
|---|
| 164 | | - writel_relaxed(win->ypos << 16 | win->xpos, ®s->g_start); |
|---|
| 153 | + writel_relaxed((win->ysrc << 16) | win->xsrc, |
|---|
| 154 | + (void __iomem *)®s->g_size); |
|---|
| 155 | + writel_relaxed((win->ydst << 16) | win->xdst, |
|---|
| 156 | + (void __iomem *)®s->g_size_z); |
|---|
| 157 | + writel_relaxed(win->ypos << 16 | win->xpos, |
|---|
| 158 | + (void __iomem *)®s->g_start); |
|---|
| 165 | 159 | } |
|---|
| 166 | 160 | |
|---|
| 167 | 161 | dmafetch_set_fmt(overlay); |
|---|
| .. | .. |
|---|
| 246 | 240 | memcpy(&overlay->addr, addr, sizeof(struct mmp_addr)); |
|---|
| 247 | 241 | |
|---|
| 248 | 242 | if (overlay_is_vid(overlay)) { |
|---|
| 249 | | - writel_relaxed(addr->phys[0], ®s->v_y0); |
|---|
| 250 | | - writel_relaxed(addr->phys[1], ®s->v_u0); |
|---|
| 251 | | - writel_relaxed(addr->phys[2], ®s->v_v0); |
|---|
| 243 | + writel_relaxed(addr->phys[0], (void __iomem *)®s->v_y0); |
|---|
| 244 | + writel_relaxed(addr->phys[1], (void __iomem *)®s->v_u0); |
|---|
| 245 | + writel_relaxed(addr->phys[2], (void __iomem *)®s->v_v0); |
|---|
| 252 | 246 | } else |
|---|
| 253 | | - writel_relaxed(addr->phys[0], ®s->g_0); |
|---|
| 247 | + writel_relaxed(addr->phys[0], (void __iomem *)®s->g_0); |
|---|
| 254 | 248 | |
|---|
| 255 | 249 | return overlay->addr.phys[0]; |
|---|
| 256 | 250 | } |
|---|
| .. | .. |
|---|
| 281 | 275 | tmp |= dsi_rbswap & CFG_INTFRBSWAP_MASK; |
|---|
| 282 | 276 | writel_relaxed(tmp, ctrl_regs(path) + intf_rbswap_ctrl(path->id)); |
|---|
| 283 | 277 | |
|---|
| 284 | | - writel_relaxed((mode->yres << 16) | mode->xres, ®s->screen_active); |
|---|
| 278 | + writel_relaxed((mode->yres << 16) | mode->xres, |
|---|
| 279 | + (void __iomem *)®s->screen_active); |
|---|
| 285 | 280 | writel_relaxed((mode->left_margin << 16) | mode->right_margin, |
|---|
| 286 | | - ®s->screen_h_porch); |
|---|
| 281 | + (void __iomem *)®s->screen_h_porch); |
|---|
| 287 | 282 | writel_relaxed((mode->upper_margin << 16) | mode->lower_margin, |
|---|
| 288 | | - ®s->screen_v_porch); |
|---|
| 283 | + (void __iomem *)®s->screen_v_porch); |
|---|
| 289 | 284 | total_x = mode->xres + mode->left_margin + mode->right_margin + |
|---|
| 290 | 285 | mode->hsync_len; |
|---|
| 291 | 286 | total_y = mode->yres + mode->upper_margin + mode->lower_margin + |
|---|
| 292 | 287 | mode->vsync_len; |
|---|
| 293 | | - writel_relaxed((total_y << 16) | total_x, ®s->screen_size); |
|---|
| 288 | + writel_relaxed((total_y << 16) | total_x, |
|---|
| 289 | + (void __iomem *)®s->screen_size); |
|---|
| 294 | 290 | |
|---|
| 295 | 291 | /* vsync ctrl */ |
|---|
| 296 | 292 | if (path->output_type == PATH_OUT_DSI) |
|---|
| .. | .. |
|---|
| 298 | 294 | else |
|---|
| 299 | 295 | vsync_ctrl = ((mode->xres + mode->right_margin) << 16) |
|---|
| 300 | 296 | | (mode->xres + mode->right_margin); |
|---|
| 301 | | - writel_relaxed(vsync_ctrl, ®s->vsync_ctrl); |
|---|
| 297 | + writel_relaxed(vsync_ctrl, (void __iomem *)®s->vsync_ctrl); |
|---|
| 302 | 298 | |
|---|
| 303 | 299 | /* set pixclock div */ |
|---|
| 304 | 300 | sclk_src = clk_get_rate(path_to_ctrl(path)->clk); |
|---|
| .. | .. |
|---|
| 379 | 375 | writel_relaxed(dma_ctrl1, ctrl_regs(path) + dma_ctrl(1, path->id)); |
|---|
| 380 | 376 | |
|---|
| 381 | 377 | /* Configure default register values */ |
|---|
| 382 | | - writel_relaxed(0x00000000, ®s->blank_color); |
|---|
| 383 | | - writel_relaxed(0x00000000, ®s->g_1); |
|---|
| 384 | | - writel_relaxed(0x00000000, ®s->g_start); |
|---|
| 378 | + writel_relaxed(0x00000000, (void __iomem *)®s->blank_color); |
|---|
| 379 | + writel_relaxed(0x00000000, (void __iomem *)®s->g_1); |
|---|
| 380 | + writel_relaxed(0x00000000, (void __iomem *)®s->g_start); |
|---|
| 385 | 381 | |
|---|
| 386 | 382 | /* |
|---|
| 387 | 383 | * 1.enable multiple burst request in DMA AXI |
|---|
| .. | .. |
|---|
| 446 | 442 | { |
|---|
| 447 | 443 | struct mmp_mach_plat_info *mi; |
|---|
| 448 | 444 | struct resource *res; |
|---|
| 449 | | - int ret, i, size, irq; |
|---|
| 445 | + int ret, i, irq; |
|---|
| 450 | 446 | struct mmphw_path_plat *path_plat; |
|---|
| 451 | 447 | struct mmphw_ctrl *ctrl = NULL; |
|---|
| 452 | 448 | |
|---|
| .. | .. |
|---|
| 460 | 456 | |
|---|
| 461 | 457 | irq = platform_get_irq(pdev, 0); |
|---|
| 462 | 458 | if (irq < 0) { |
|---|
| 463 | | - dev_err(&pdev->dev, "%s: no IRQ defined\n", __func__); |
|---|
| 464 | 459 | ret = -ENOENT; |
|---|
| 465 | 460 | goto failed; |
|---|
| 466 | 461 | } |
|---|
| .. | .. |
|---|
| 474 | 469 | } |
|---|
| 475 | 470 | |
|---|
| 476 | 471 | /* 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); |
|---|
| 480 | 475 | if (!ctrl) { |
|---|
| 481 | 476 | ret = -ENOMEM; |
|---|
| 482 | 477 | goto failed; |
|---|
| .. | .. |
|---|
| 498 | 493 | goto failed; |
|---|
| 499 | 494 | } |
|---|
| 500 | 495 | |
|---|
| 501 | | - ctrl->reg_base = devm_ioremap_nocache(ctrl->dev, |
|---|
| 496 | + ctrl->reg_base = devm_ioremap(ctrl->dev, |
|---|
| 502 | 497 | res->start, resource_size(res)); |
|---|
| 503 | 498 | if (ctrl->reg_base == NULL) { |
|---|
| 504 | 499 | dev_err(ctrl->dev, "%s: res %pR map failed\n", __func__, res); |
|---|
| .. | .. |
|---|
| 523 | 518 | ret = -ENOENT; |
|---|
| 524 | 519 | goto failed; |
|---|
| 525 | 520 | } |
|---|
| 526 | | - clk_prepare_enable(ctrl->clk); |
|---|
| 521 | + ret = clk_prepare_enable(ctrl->clk); |
|---|
| 522 | + if (ret) |
|---|
| 523 | + goto failed; |
|---|
| 527 | 524 | |
|---|
| 528 | 525 | /* init global regs */ |
|---|
| 529 | 526 | ctrl_set_default(ctrl); |
|---|