1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
296f60e37SRussell King /*
396f60e37SRussell King * Copyright (C) 2012 Russell King
496f60e37SRussell King * Rewritten from the dovefb driver, and Armada510 manuals.
596f60e37SRussell King */
625e28ef2SSam Ravnborg
796f60e37SRussell King #include <linux/clk.h>
8d8c96083SRussell King #include <linux/component.h>
925e28ef2SSam Ravnborg #include <linux/module.h>
10*e1704914SRob Herring #include <linux/of.h>
11d8c96083SRussell King #include <linux/platform_device.h>
12*e1704914SRob Herring #include <linux/property.h>
1325e28ef2SSam Ravnborg
14de503ddfSRussell King #include <drm/drm_atomic.h>
15bcd21a47SDave Airlie #include <drm/drm_atomic_helper.h>
1625e28ef2SSam Ravnborg #include <drm/drm_probe_helper.h>
1725e28ef2SSam Ravnborg #include <drm/drm_vblank.h>
1825e28ef2SSam Ravnborg
1996f60e37SRussell King #include "armada_crtc.h"
2096f60e37SRussell King #include "armada_drm.h"
2196f60e37SRussell King #include "armada_fb.h"
2296f60e37SRussell King #include "armada_gem.h"
2396f60e37SRussell King #include "armada_hw.h"
24d40af7b1SRussell King #include "armada_plane.h"
25c8a220c6SRussell King #include "armada_trace.h"
2696f60e37SRussell King
2796f60e37SRussell King /*
2896f60e37SRussell King * A note about interlacing. Let's consider HDMI 1920x1080i.
2996f60e37SRussell King * The timing parameters we have from X are:
3096f60e37SRussell King * Hact HsyA HsyI Htot Vact VsyA VsyI Vtot
3196f60e37SRussell King * 1920 2448 2492 2640 1080 1084 1094 1125
3296f60e37SRussell King * Which get translated to:
3396f60e37SRussell King * Hact HsyA HsyI Htot Vact VsyA VsyI Vtot
3496f60e37SRussell King * 1920 2448 2492 2640 540 542 547 562
3596f60e37SRussell King *
3696f60e37SRussell King * This is how it is defined by CEA-861-D - line and pixel numbers are
3796f60e37SRussell King * referenced to the rising edge of VSYNC and HSYNC. Total clocks per
3896f60e37SRussell King * line: 2640. The odd frame, the first active line is at line 21, and
3996f60e37SRussell King * the even frame, the first active line is 584.
4096f60e37SRussell King *
4196f60e37SRussell King * LN: 560 561 562 563 567 568 569
4296f60e37SRussell King * DE: ~~~|____________________________//__________________________
4396f60e37SRussell King * HSYNC: ____|~|_____|~|_____|~|_____|~|_//__|~|_____|~|_____|~|_____
4496f60e37SRussell King * VSYNC: _________________________|~~~~~~//~~~~~~~~~~~~~~~|__________
4596f60e37SRussell King * 22 blanking lines. VSYNC at 1320 (referenced to the HSYNC rising edge).
4696f60e37SRussell King *
4796f60e37SRussell King * LN: 1123 1124 1125 1 5 6 7
4896f60e37SRussell King * DE: ~~~|____________________________//__________________________
4996f60e37SRussell King * HSYNC: ____|~|_____|~|_____|~|_____|~|_//__|~|_____|~|_____|~|_____
5096f60e37SRussell King * VSYNC: ____________________|~~~~~~~~~~~//~~~~~~~~~~|_______________
5196f60e37SRussell King * 23 blanking lines
5296f60e37SRussell King *
5396f60e37SRussell King * The Armada LCD Controller line and pixel numbers are, like X timings,
5496f60e37SRussell King * referenced to the top left of the active frame.
5596f60e37SRussell King *
5696f60e37SRussell King * So, translating these to our LCD controller:
5796f60e37SRussell King * Odd frame, 563 total lines, VSYNC at line 543-548, pixel 1128.
5896f60e37SRussell King * Even frame, 562 total lines, VSYNC at line 542-547, pixel 2448.
5996f60e37SRussell King * Note: Vsync front porch remains constant!
6096f60e37SRussell King *
6196f60e37SRussell King * if (odd_frame) {
6296f60e37SRussell King * vtotal = mode->crtc_vtotal + 1;
6396f60e37SRussell King * vbackporch = mode->crtc_vsync_start - mode->crtc_vdisplay + 1;
6496f60e37SRussell King * vhorizpos = mode->crtc_hsync_start - mode->crtc_htotal / 2
6596f60e37SRussell King * } else {
6696f60e37SRussell King * vtotal = mode->crtc_vtotal;
6796f60e37SRussell King * vbackporch = mode->crtc_vsync_start - mode->crtc_vdisplay;
6896f60e37SRussell King * vhorizpos = mode->crtc_hsync_start;
6996f60e37SRussell King * }
7096f60e37SRussell King * vfrontporch = mode->crtc_vtotal - mode->crtc_vsync_end;
7196f60e37SRussell King *
7296f60e37SRussell King * So, we need to reprogram these registers on each vsync event:
7396f60e37SRussell King * LCD_SPU_V_PORCH, LCD_SPU_ADV_REG, LCD_SPUT_V_H_TOTAL
7496f60e37SRussell King *
7596f60e37SRussell King * Note: we do not use the frame done interrupts because these appear
7696f60e37SRussell King * to happen too early, and lead to jitter on the display (presumably
7796f60e37SRussell King * they occur at the end of the last active line, before the vsync back
7896f60e37SRussell King * porch, which we're reprogramming.)
7996f60e37SRussell King */
8096f60e37SRussell King
8196f60e37SRussell King void
armada_drm_crtc_update_regs(struct armada_crtc * dcrtc,struct armada_regs * regs)8296f60e37SRussell King armada_drm_crtc_update_regs(struct armada_crtc *dcrtc, struct armada_regs *regs)
8396f60e37SRussell King {
8496f60e37SRussell King while (regs->offset != ~0) {
8596f60e37SRussell King void __iomem *reg = dcrtc->base + regs->offset;
8696f60e37SRussell King uint32_t val;
8796f60e37SRussell King
8896f60e37SRussell King val = regs->mask;
8996f60e37SRussell King if (val != 0)
9096f60e37SRussell King val &= readl_relaxed(reg);
9196f60e37SRussell King writel_relaxed(val | regs->val, reg);
9296f60e37SRussell King ++regs;
9396f60e37SRussell King }
9496f60e37SRussell King }
9596f60e37SRussell King
armada_drm_crtc_update(struct armada_crtc * dcrtc,bool enable)96a0f75d24SRussell King static void armada_drm_crtc_update(struct armada_crtc *dcrtc, bool enable)
9796f60e37SRussell King {
9896f60e37SRussell King uint32_t dumb_ctrl;
9996f60e37SRussell King
10096f60e37SRussell King dumb_ctrl = dcrtc->cfg_dumb_ctrl;
10196f60e37SRussell King
102a0f75d24SRussell King if (enable)
10396f60e37SRussell King dumb_ctrl |= CFG_DUMB_ENA;
10496f60e37SRussell King
10596f60e37SRussell King /*
10696f60e37SRussell King * When the dumb interface isn't in DUMB24_RGB888_0 mode, it might
10796f60e37SRussell King * be using SPI or GPIO. If we set this to DUMB_BLANK, we will
10896f60e37SRussell King * force LCD_D[23:0] to output blank color, overriding the GPIO or
10996f60e37SRussell King * SPI usage. So leave it as-is unless in DUMB24_RGB888_0 mode.
11096f60e37SRussell King */
111a0f75d24SRussell King if (!enable && (dumb_ctrl & DUMB_MASK) == DUMB24_RGB888_0) {
11296f60e37SRussell King dumb_ctrl &= ~DUMB_MASK;
11396f60e37SRussell King dumb_ctrl |= DUMB_BLANK;
11496f60e37SRussell King }
11596f60e37SRussell King
116155b8290SRussell King armada_updatel(dumb_ctrl,
117155b8290SRussell King ~(CFG_INV_CSYNC | CFG_INV_HSYNC | CFG_INV_VSYNC),
118155b8290SRussell King dcrtc->base + LCD_SPU_DUMB_CTRL);
11996f60e37SRussell King }
12096f60e37SRussell King
armada_drm_crtc_queue_state_event(struct drm_crtc * crtc)121dbb4ca8aSRussell King static void armada_drm_crtc_queue_state_event(struct drm_crtc *crtc)
122dbb4ca8aSRussell King {
123dbb4ca8aSRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
124dbb4ca8aSRussell King struct drm_pending_vblank_event *event;
125dbb4ca8aSRussell King
126dbb4ca8aSRussell King /* If we have an event, we need vblank events enabled */
127dbb4ca8aSRussell King event = xchg(&crtc->state->event, NULL);
128dbb4ca8aSRussell King if (event) {
129dbb4ca8aSRussell King WARN_ON(drm_crtc_vblank_get(crtc) != 0);
130dbb4ca8aSRussell King dcrtc->event = event;
131dbb4ca8aSRussell King }
132dbb4ca8aSRussell King }
133dbb4ca8aSRussell King
armada_drm_update_gamma(struct drm_crtc * crtc)134d0d765deSRussell King static void armada_drm_update_gamma(struct drm_crtc *crtc)
135d0d765deSRussell King {
136d0d765deSRussell King struct drm_property_blob *blob = crtc->state->gamma_lut;
137d0d765deSRussell King void __iomem *base = drm_to_armada_crtc(crtc)->base;
138d0d765deSRussell King int i;
139d0d765deSRussell King
140d0d765deSRussell King if (blob) {
141d0d765deSRussell King struct drm_color_lut *lut = blob->data;
142d0d765deSRussell King
143d0d765deSRussell King armada_updatel(CFG_CSB_256x8, CFG_CSB_256x8 | CFG_PDWN256x8,
144d0d765deSRussell King base + LCD_SPU_SRAM_PARA1);
145d0d765deSRussell King
146d0d765deSRussell King for (i = 0; i < 256; i++) {
147d0d765deSRussell King writel_relaxed(drm_color_lut_extract(lut[i].red, 8),
148d0d765deSRussell King base + LCD_SPU_SRAM_WRDAT);
149d0d765deSRussell King writel_relaxed(i | SRAM_WRITE | SRAM_GAMMA_YR,
150d0d765deSRussell King base + LCD_SPU_SRAM_CTRL);
151d0d765deSRussell King readl_relaxed(base + LCD_SPU_HWC_OVSA_HPXL_VLN);
152d0d765deSRussell King writel_relaxed(drm_color_lut_extract(lut[i].green, 8),
153d0d765deSRussell King base + LCD_SPU_SRAM_WRDAT);
154d0d765deSRussell King writel_relaxed(i | SRAM_WRITE | SRAM_GAMMA_UG,
155d0d765deSRussell King base + LCD_SPU_SRAM_CTRL);
156d0d765deSRussell King readl_relaxed(base + LCD_SPU_HWC_OVSA_HPXL_VLN);
157d0d765deSRussell King writel_relaxed(drm_color_lut_extract(lut[i].blue, 8),
158d0d765deSRussell King base + LCD_SPU_SRAM_WRDAT);
159d0d765deSRussell King writel_relaxed(i | SRAM_WRITE | SRAM_GAMMA_VB,
160d0d765deSRussell King base + LCD_SPU_SRAM_CTRL);
161d0d765deSRussell King readl_relaxed(base + LCD_SPU_HWC_OVSA_HPXL_VLN);
162d0d765deSRussell King }
163d0d765deSRussell King armada_updatel(CFG_GAMMA_ENA, CFG_GAMMA_ENA,
164d0d765deSRussell King base + LCD_SPU_DMA_CTRL0);
165d0d765deSRussell King } else {
166d0d765deSRussell King armada_updatel(0, CFG_GAMMA_ENA, base + LCD_SPU_DMA_CTRL0);
167d0d765deSRussell King armada_updatel(CFG_PDWN256x8, CFG_CSB_256x8 | CFG_PDWN256x8,
168d0d765deSRussell King base + LCD_SPU_SRAM_PARA1);
169d0d765deSRussell King }
170d0d765deSRussell King }
171d0d765deSRussell King
armada_drm_crtc_mode_valid(struct drm_crtc * crtc,const struct drm_display_mode * mode)1727f07ce0fSRussell King static enum drm_mode_status armada_drm_crtc_mode_valid(struct drm_crtc *crtc,
1737f07ce0fSRussell King const struct drm_display_mode *mode)
1747f07ce0fSRussell King {
175d880fa66SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
176d880fa66SRussell King
1777f07ce0fSRussell King if (mode->vscan > 1)
1787f07ce0fSRussell King return MODE_NO_VSCAN;
1797f07ce0fSRussell King
1807f07ce0fSRussell King if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1817f07ce0fSRussell King return MODE_NO_DBLESCAN;
1827f07ce0fSRussell King
1837f07ce0fSRussell King if (mode->flags & DRM_MODE_FLAG_HSKEW)
1847f07ce0fSRussell King return MODE_H_ILLEGAL;
1857f07ce0fSRussell King
186d880fa66SRussell King /* We can't do interlaced modes if we don't have the SPU_ADV_REG */
187d880fa66SRussell King if (!dcrtc->variant->has_spu_adv_reg &&
188d880fa66SRussell King mode->flags & DRM_MODE_FLAG_INTERLACE)
189d880fa66SRussell King return MODE_NO_INTERLACE;
190d880fa66SRussell King
1917f07ce0fSRussell King if (mode->flags & (DRM_MODE_FLAG_BCAST | DRM_MODE_FLAG_PIXMUX |
1927f07ce0fSRussell King DRM_MODE_FLAG_CLKDIV2))
1937f07ce0fSRussell King return MODE_BAD;
1947f07ce0fSRussell King
1957f07ce0fSRussell King return MODE_OK;
1967f07ce0fSRussell King }
1977f07ce0fSRussell King
19896f60e37SRussell King /* The mode_config.mutex will be held for this call */
armada_drm_crtc_mode_fixup(struct drm_crtc * crtc,const struct drm_display_mode * mode,struct drm_display_mode * adj)19996f60e37SRussell King static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc,
20096f60e37SRussell King const struct drm_display_mode *mode, struct drm_display_mode *adj)
20196f60e37SRussell King {
20296f60e37SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
20396f60e37SRussell King int ret;
20496f60e37SRussell King
205f79d7c95SRussell King /*
206f79d7c95SRussell King * Set CRTC modesetting parameters for the adjusted mode. This is
207f79d7c95SRussell King * applied after the connectors, bridges, and encoders have fixed up
208f79d7c95SRussell King * this mode, as described above drm_atomic_helper_check_modeset().
209f79d7c95SRussell King */
210f79d7c95SRussell King drm_mode_set_crtcinfo(adj, CRTC_INTERLACE_HALVE_V);
211f79d7c95SRussell King
212d880fa66SRussell King /*
213d880fa66SRussell King * Validate the adjusted mode in case an encoder/bridge has set
214d880fa66SRussell King * something we don't support.
215d880fa66SRussell King */
216d880fa66SRussell King if (armada_drm_crtc_mode_valid(crtc, adj) != MODE_OK)
21796f60e37SRussell King return false;
21896f60e37SRussell King
21996f60e37SRussell King /* Check whether the display mode is possible */
22042e62ba7SRussell King ret = dcrtc->variant->compute_clock(dcrtc, adj, NULL);
22196f60e37SRussell King if (ret)
22296f60e37SRussell King return false;
22396f60e37SRussell King
22496f60e37SRussell King return true;
22596f60e37SRussell King }
22696f60e37SRussell King
2275922a7d0SShawn Guo /* These are locked by dev->vbl_lock */
armada_drm_crtc_disable_irq(struct armada_crtc * dcrtc,u32 mask)2285922a7d0SShawn Guo static void armada_drm_crtc_disable_irq(struct armada_crtc *dcrtc, u32 mask)
2295922a7d0SShawn Guo {
2305922a7d0SShawn Guo if (dcrtc->irq_ena & mask) {
2315922a7d0SShawn Guo dcrtc->irq_ena &= ~mask;
2325922a7d0SShawn Guo writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
2335922a7d0SShawn Guo }
2345922a7d0SShawn Guo }
2355922a7d0SShawn Guo
armada_drm_crtc_enable_irq(struct armada_crtc * dcrtc,u32 mask)2365922a7d0SShawn Guo static void armada_drm_crtc_enable_irq(struct armada_crtc *dcrtc, u32 mask)
2375922a7d0SShawn Guo {
2385922a7d0SShawn Guo if ((dcrtc->irq_ena & mask) != mask) {
2395922a7d0SShawn Guo dcrtc->irq_ena |= mask;
2405922a7d0SShawn Guo writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
2415922a7d0SShawn Guo if (readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR) & mask)
2425922a7d0SShawn Guo writel(0, dcrtc->base + LCD_SPU_IRQ_ISR);
2435922a7d0SShawn Guo }
2445922a7d0SShawn Guo }
2455922a7d0SShawn Guo
armada_drm_crtc_irq(struct armada_crtc * dcrtc,u32 stat)246e5d9ddfbSRussell King static void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
24796f60e37SRussell King {
248dbb4ca8aSRussell King struct drm_pending_vblank_event *event;
24996f60e37SRussell King void __iomem *base = dcrtc->base;
25096f60e37SRussell King
25196f60e37SRussell King if (stat & DMA_FF_UNDERFLOW)
25296f60e37SRussell King DRM_ERROR("video underflow on crtc %u\n", dcrtc->num);
25396f60e37SRussell King if (stat & GRA_FF_UNDERFLOW)
25496f60e37SRussell King DRM_ERROR("graphics underflow on crtc %u\n", dcrtc->num);
25596f60e37SRussell King
25696f60e37SRussell King if (stat & VSYNC_IRQ)
2570ac28c57SGustavo Padovan drm_crtc_handle_vblank(&dcrtc->crtc);
25896f60e37SRussell King
259a3f6a18fSRussell King spin_lock(&dcrtc->irq_lock);
26096f60e37SRussell King if (stat & GRA_FRAME_IRQ && dcrtc->interlaced) {
26196f60e37SRussell King int i = stat & GRA_FRAME_IRQ0 ? 0 : 1;
26296f60e37SRussell King uint32_t val;
26396f60e37SRussell King
26496f60e37SRussell King writel_relaxed(dcrtc->v[i].spu_v_porch, base + LCD_SPU_V_PORCH);
26596f60e37SRussell King writel_relaxed(dcrtc->v[i].spu_v_h_total,
26696f60e37SRussell King base + LCD_SPUT_V_H_TOTAL);
26796f60e37SRussell King
26896f60e37SRussell King val = readl_relaxed(base + LCD_SPU_ADV_REG);
26996f60e37SRussell King val &= ~(ADV_VSYNC_L_OFF | ADV_VSYNC_H_OFF | ADV_VSYNCOFFEN);
27096f60e37SRussell King val |= dcrtc->v[i].spu_adv_reg;
271662af0d8SRussell King writel_relaxed(val, base + LCD_SPU_ADV_REG);
27296f60e37SRussell King }
273662af0d8SRussell King
2743cb13ac9SRussell King if (stat & dcrtc->irq_ena & DUMB_FRAMEDONE) {
2753cb13ac9SRussell King if (dcrtc->update_pending) {
2763cb13ac9SRussell King armada_drm_crtc_update_regs(dcrtc, dcrtc->regs);
2773cb13ac9SRussell King dcrtc->update_pending = false;
2783cb13ac9SRussell King }
2793cb13ac9SRussell King if (dcrtc->cursor_update) {
280662af0d8SRussell King writel_relaxed(dcrtc->cursor_hw_pos,
281662af0d8SRussell King base + LCD_SPU_HWC_OVSA_HPXL_VLN);
282662af0d8SRussell King writel_relaxed(dcrtc->cursor_hw_sz,
283662af0d8SRussell King base + LCD_SPU_HWC_HPXL_VLN);
284662af0d8SRussell King armada_updatel(CFG_HWC_ENA,
2853cb13ac9SRussell King CFG_HWC_ENA | CFG_HWC_1BITMOD |
2863cb13ac9SRussell King CFG_HWC_1BITENA,
287662af0d8SRussell King base + LCD_SPU_DMA_CTRL0);
288662af0d8SRussell King dcrtc->cursor_update = false;
2893cb13ac9SRussell King }
290662af0d8SRussell King armada_drm_crtc_disable_irq(dcrtc, DUMB_FRAMEDONE_ENA);
291662af0d8SRussell King }
29296f60e37SRussell King spin_unlock(&dcrtc->irq_lock);
29396f60e37SRussell King
2943cb13ac9SRussell King if (stat & VSYNC_IRQ && !dcrtc->update_pending) {
295dbb4ca8aSRussell King event = xchg(&dcrtc->event, NULL);
296dbb4ca8aSRussell King if (event) {
297dbb4ca8aSRussell King spin_lock(&dcrtc->crtc.dev->event_lock);
298dbb4ca8aSRussell King drm_crtc_send_vblank_event(&dcrtc->crtc, event);
299dbb4ca8aSRussell King spin_unlock(&dcrtc->crtc.dev->event_lock);
300dbb4ca8aSRussell King drm_crtc_vblank_put(&dcrtc->crtc);
301dbb4ca8aSRussell King }
302dbb4ca8aSRussell King }
30396f60e37SRussell King }
30496f60e37SRussell King
armada_drm_irq(int irq,void * arg)305e5d9ddfbSRussell King static irqreturn_t armada_drm_irq(int irq, void *arg)
306e5d9ddfbSRussell King {
307e5d9ddfbSRussell King struct armada_crtc *dcrtc = arg;
308e5d9ddfbSRussell King u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
309e5d9ddfbSRussell King
310e5d9ddfbSRussell King /*
31192298c1cSRussell King * Reading the ISR appears to clear bits provided CLEAN_SPU_IRQ_ISR
31292298c1cSRussell King * is set. Writing has some other effect to acknowledge the IRQ -
31392298c1cSRussell King * without this, we only get a single IRQ.
314e5d9ddfbSRussell King */
315e5d9ddfbSRussell King writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
316e5d9ddfbSRussell King
317c8a220c6SRussell King trace_armada_drm_irq(&dcrtc->crtc, stat);
318c8a220c6SRussell King
319e5d9ddfbSRussell King /* Mask out those interrupts we haven't enabled */
320e5d9ddfbSRussell King v = stat & dcrtc->irq_ena;
321e5d9ddfbSRussell King
322e5d9ddfbSRussell King if (v & (VSYNC_IRQ|GRA_FRAME_IRQ|DUMB_FRAMEDONE)) {
323e5d9ddfbSRussell King armada_drm_crtc_irq(dcrtc, stat);
324e5d9ddfbSRussell King return IRQ_HANDLED;
325e5d9ddfbSRussell King }
326e5d9ddfbSRussell King return IRQ_NONE;
327e5d9ddfbSRussell King }
328e5d9ddfbSRussell King
32996f60e37SRussell King /* The mode_config.mutex will be held for this call */
armada_drm_crtc_mode_set_nofb(struct drm_crtc * crtc)330c36045e1SRussell King static void armada_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
33196f60e37SRussell King {
332c36045e1SRussell King struct drm_display_mode *adj = &crtc->state->adjusted_mode;
33396f60e37SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
33496f60e37SRussell King struct armada_regs regs[17];
33596f60e37SRussell King uint32_t lm, rm, tm, bm, val, sclk;
33696f60e37SRussell King unsigned long flags;
33796f60e37SRussell King unsigned i;
338c36045e1SRussell King bool interlaced = !!(adj->flags & DRM_MODE_FLAG_INTERLACE);
33996f60e37SRussell King
34037af35c7SRussell King i = 0;
34196f60e37SRussell King rm = adj->crtc_hsync_start - adj->crtc_hdisplay;
34296f60e37SRussell King lm = adj->crtc_htotal - adj->crtc_hsync_end;
34396f60e37SRussell King bm = adj->crtc_vsync_start - adj->crtc_vdisplay;
34496f60e37SRussell King tm = adj->crtc_vtotal - adj->crtc_vsync_end;
34596f60e37SRussell King
346a61c3922SRussell King DRM_DEBUG_KMS("[CRTC:%d:%s] mode " DRM_MODE_FMT "\n",
3470ed833baSShayenne Moura crtc->base.id, crtc->name, DRM_MODE_ARG(adj));
348a61c3922SRussell King DRM_DEBUG_KMS("lm %d rm %d tm %d bm %d\n", lm, rm, tm, bm);
34996f60e37SRussell King
35096f60e37SRussell King /* Now compute the divider for real */
35142e62ba7SRussell King dcrtc->variant->compute_clock(dcrtc, adj, &sclk);
35296f60e37SRussell King
35396f60e37SRussell King armada_reg_queue_set(regs, i, sclk, LCD_CFG_SCLK_DIV);
35496f60e37SRussell King
35596f60e37SRussell King spin_lock_irqsave(&dcrtc->irq_lock, flags);
35696f60e37SRussell King
357768f719aSRussell King dcrtc->interlaced = interlaced;
35896f60e37SRussell King /* Even interlaced/progressive frame */
35996f60e37SRussell King dcrtc->v[1].spu_v_h_total = adj->crtc_vtotal << 16 |
36096f60e37SRussell King adj->crtc_htotal;
36196f60e37SRussell King dcrtc->v[1].spu_v_porch = tm << 16 | bm;
36296f60e37SRussell King val = adj->crtc_hsync_start;
3634e4b3563SRussell King dcrtc->v[1].spu_adv_reg = val << 20 | val | ADV_VSYNCOFFEN;
36496f60e37SRussell King
36596f60e37SRussell King if (interlaced) {
36696f60e37SRussell King /* Odd interlaced frame */
3674e4b3563SRussell King val -= adj->crtc_htotal / 2;
3684e4b3563SRussell King dcrtc->v[0].spu_adv_reg = val << 20 | val | ADV_VSYNCOFFEN;
36996f60e37SRussell King dcrtc->v[0].spu_v_h_total = dcrtc->v[1].spu_v_h_total +
37096f60e37SRussell King (1 << 16);
37196f60e37SRussell King dcrtc->v[0].spu_v_porch = dcrtc->v[1].spu_v_porch + 1;
37296f60e37SRussell King } else {
37396f60e37SRussell King dcrtc->v[0] = dcrtc->v[1];
37496f60e37SRussell King }
37596f60e37SRussell King
37696f60e37SRussell King val = adj->crtc_vdisplay << 16 | adj->crtc_hdisplay;
37796f60e37SRussell King
37896f60e37SRussell King armada_reg_queue_set(regs, i, val, LCD_SPU_V_H_ACTIVE);
37996f60e37SRussell King armada_reg_queue_set(regs, i, (lm << 16) | rm, LCD_SPU_H_PORCH);
38096f60e37SRussell King armada_reg_queue_set(regs, i, dcrtc->v[0].spu_v_porch, LCD_SPU_V_PORCH);
38196f60e37SRussell King armada_reg_queue_set(regs, i, dcrtc->v[0].spu_v_h_total,
38296f60e37SRussell King LCD_SPUT_V_H_TOTAL);
38396f60e37SRussell King
3844e4b3563SRussell King if (dcrtc->variant->has_spu_adv_reg)
38596f60e37SRussell King armada_reg_queue_mod(regs, i, dcrtc->v[0].spu_adv_reg,
38696f60e37SRussell King ADV_VSYNC_L_OFF | ADV_VSYNC_H_OFF |
38796f60e37SRussell King ADV_VSYNCOFFEN, LCD_SPU_ADV_REG);
38896f60e37SRussell King
38996f60e37SRussell King val = adj->flags & DRM_MODE_FLAG_NVSYNC ? CFG_VSYNC_INV : 0;
39096f60e37SRussell King armada_reg_queue_mod(regs, i, val, CFG_VSYNC_INV, LCD_SPU_DMA_CTRL1);
391155b8290SRussell King
392155b8290SRussell King /*
393155b8290SRussell King * The documentation doesn't indicate what the normal state of
394155b8290SRussell King * the sync signals are. Sebastian Hesselbart kindly probed
395155b8290SRussell King * these signals on his board to determine their state.
396155b8290SRussell King *
397155b8290SRussell King * The non-inverted state of the sync signals is active high.
398155b8290SRussell King * Setting these bits makes the appropriate signal active low.
399155b8290SRussell King */
400155b8290SRussell King val = 0;
401155b8290SRussell King if (adj->flags & DRM_MODE_FLAG_NCSYNC)
402155b8290SRussell King val |= CFG_INV_CSYNC;
403155b8290SRussell King if (adj->flags & DRM_MODE_FLAG_NHSYNC)
404155b8290SRussell King val |= CFG_INV_HSYNC;
405155b8290SRussell King if (adj->flags & DRM_MODE_FLAG_NVSYNC)
406155b8290SRussell King val |= CFG_INV_VSYNC;
407155b8290SRussell King armada_reg_queue_mod(regs, i, val, CFG_INV_CSYNC | CFG_INV_HSYNC |
408155b8290SRussell King CFG_INV_VSYNC, LCD_SPU_DUMB_CTRL);
40996f60e37SRussell King armada_reg_queue_end(regs, i);
41096f60e37SRussell King
41196f60e37SRussell King armada_drm_crtc_update_regs(dcrtc, regs);
41296f60e37SRussell King spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
41396f60e37SRussell King }
41496f60e37SRussell King
armada_drm_crtc_atomic_check(struct drm_crtc * crtc,struct drm_atomic_state * state)415d0d765deSRussell King static int armada_drm_crtc_atomic_check(struct drm_crtc *crtc,
41629b77ad7SMaxime Ripard struct drm_atomic_state *state)
417d0d765deSRussell King {
41829b77ad7SMaxime Ripard struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
41929b77ad7SMaxime Ripard crtc);
420d0d765deSRussell King DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
421d0d765deSRussell King
42229b77ad7SMaxime Ripard if (crtc_state->gamma_lut && drm_color_lut_size(crtc_state->gamma_lut) != 256)
423d0d765deSRussell King return -EINVAL;
424d0d765deSRussell King
42529b77ad7SMaxime Ripard if (crtc_state->color_mgmt_changed)
42629b77ad7SMaxime Ripard crtc_state->planes_changed = true;
427d0d765deSRussell King
428d0d765deSRussell King return 0;
429d0d765deSRussell King }
430d0d765deSRussell King
armada_drm_crtc_atomic_begin(struct drm_crtc * crtc,struct drm_atomic_state * state)431c36045e1SRussell King static void armada_drm_crtc_atomic_begin(struct drm_crtc *crtc,
432f6ebe9f9SMaxime Ripard struct drm_atomic_state *state)
433c36045e1SRussell King {
434253f28b6SMaxime Ripard struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
435253f28b6SMaxime Ripard crtc);
436c36045e1SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
437c36045e1SRussell King
438c36045e1SRussell King DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
439c36045e1SRussell King
440253f28b6SMaxime Ripard if (crtc_state->color_mgmt_changed)
441d0d765deSRussell King armada_drm_update_gamma(crtc);
442d0d765deSRussell King
443c36045e1SRussell King dcrtc->regs_idx = 0;
444c36045e1SRussell King dcrtc->regs = dcrtc->atomic_regs;
445c36045e1SRussell King }
446c36045e1SRussell King
armada_drm_crtc_atomic_flush(struct drm_crtc * crtc,struct drm_atomic_state * state)447c36045e1SRussell King static void armada_drm_crtc_atomic_flush(struct drm_crtc *crtc,
448f6ebe9f9SMaxime Ripard struct drm_atomic_state *state)
449c36045e1SRussell King {
450253f28b6SMaxime Ripard struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
451253f28b6SMaxime Ripard crtc);
452c36045e1SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
453c36045e1SRussell King
454c36045e1SRussell King DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
455c36045e1SRussell King
456c36045e1SRussell King armada_reg_queue_end(dcrtc->regs, dcrtc->regs_idx);
457c36045e1SRussell King
458dbb4ca8aSRussell King /*
459dbb4ca8aSRussell King * If we aren't doing a full modeset, then we need to queue
460dbb4ca8aSRussell King * the event here.
461dbb4ca8aSRussell King */
462253f28b6SMaxime Ripard if (!drm_atomic_crtc_needs_modeset(crtc_state)) {
4633cb13ac9SRussell King dcrtc->update_pending = true;
464dbb4ca8aSRussell King armada_drm_crtc_queue_state_event(crtc);
4653cb13ac9SRussell King spin_lock_irq(&dcrtc->irq_lock);
4663cb13ac9SRussell King armada_drm_crtc_enable_irq(dcrtc, DUMB_FRAMEDONE_ENA);
4673cb13ac9SRussell King spin_unlock_irq(&dcrtc->irq_lock);
4683cb13ac9SRussell King } else {
4693cb13ac9SRussell King spin_lock_irq(&dcrtc->irq_lock);
4703cb13ac9SRussell King armada_drm_crtc_update_regs(dcrtc, dcrtc->regs);
4713cb13ac9SRussell King spin_unlock_irq(&dcrtc->irq_lock);
4723cb13ac9SRussell King }
473c36045e1SRussell King }
474c36045e1SRussell King
armada_drm_crtc_atomic_disable(struct drm_crtc * crtc,struct drm_atomic_state * state)47534e25ed6SRussell King static void armada_drm_crtc_atomic_disable(struct drm_crtc *crtc,
476351f950dSMaxime Ripard struct drm_atomic_state *state)
47734e25ed6SRussell King {
478351f950dSMaxime Ripard struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
479351f950dSMaxime Ripard crtc);
48034e25ed6SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
48134e25ed6SRussell King struct drm_pending_vblank_event *event;
48234e25ed6SRussell King
48334e25ed6SRussell King DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
48434e25ed6SRussell King
485768f719aSRussell King if (old_state->adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
486768f719aSRussell King drm_crtc_vblank_put(crtc);
487768f719aSRussell King
48834e25ed6SRussell King drm_crtc_vblank_off(crtc);
48934e25ed6SRussell King armada_drm_crtc_update(dcrtc, false);
49034e25ed6SRussell King
49134e25ed6SRussell King if (!crtc->state->active) {
49234e25ed6SRussell King /*
49334e25ed6SRussell King * This modeset will be leaving the CRTC disabled, so
49434e25ed6SRussell King * call the backend to disable upstream clocks etc.
49534e25ed6SRussell King */
49634e25ed6SRussell King if (dcrtc->variant->disable)
49734e25ed6SRussell King dcrtc->variant->disable(dcrtc);
49834e25ed6SRussell King
49934e25ed6SRussell King /*
50034e25ed6SRussell King * We will not receive any further vblank events.
50134e25ed6SRussell King * Send the flip_done event manually.
50234e25ed6SRussell King */
50334e25ed6SRussell King event = crtc->state->event;
50434e25ed6SRussell King crtc->state->event = NULL;
50534e25ed6SRussell King if (event) {
50634e25ed6SRussell King spin_lock_irq(&crtc->dev->event_lock);
50734e25ed6SRussell King drm_crtc_send_vblank_event(crtc, event);
50834e25ed6SRussell King spin_unlock_irq(&crtc->dev->event_lock);
50934e25ed6SRussell King }
51034e25ed6SRussell King }
51134e25ed6SRussell King }
51234e25ed6SRussell King
armada_drm_crtc_atomic_enable(struct drm_crtc * crtc,struct drm_atomic_state * state)51334e25ed6SRussell King static void armada_drm_crtc_atomic_enable(struct drm_crtc *crtc,
514351f950dSMaxime Ripard struct drm_atomic_state *state)
51534e25ed6SRussell King {
516351f950dSMaxime Ripard struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state,
517351f950dSMaxime Ripard crtc);
51834e25ed6SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
51934e25ed6SRussell King
52034e25ed6SRussell King DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
52134e25ed6SRussell King
52234e25ed6SRussell King if (!old_state->active) {
52334e25ed6SRussell King /*
52434e25ed6SRussell King * This modeset is enabling the CRTC after it having
52534e25ed6SRussell King * been disabled. Reverse the call to ->disable in
52634e25ed6SRussell King * the atomic_disable().
52734e25ed6SRussell King */
52834e25ed6SRussell King if (dcrtc->variant->enable)
52934e25ed6SRussell King dcrtc->variant->enable(dcrtc, &crtc->state->adjusted_mode);
53034e25ed6SRussell King }
53134e25ed6SRussell King armada_drm_crtc_update(dcrtc, true);
53234e25ed6SRussell King drm_crtc_vblank_on(crtc);
53334e25ed6SRussell King
534768f719aSRussell King if (crtc->state->adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE)
535768f719aSRussell King WARN_ON(drm_crtc_vblank_get(crtc));
536768f719aSRussell King
53734e25ed6SRussell King armada_drm_crtc_queue_state_event(crtc);
53834e25ed6SRussell King }
53934e25ed6SRussell King
54096f60e37SRussell King static const struct drm_crtc_helper_funcs armada_crtc_helper_funcs = {
5417f07ce0fSRussell King .mode_valid = armada_drm_crtc_mode_valid,
54296f60e37SRussell King .mode_fixup = armada_drm_crtc_mode_fixup,
543c36045e1SRussell King .mode_set_nofb = armada_drm_crtc_mode_set_nofb,
544d0d765deSRussell King .atomic_check = armada_drm_crtc_atomic_check,
545c36045e1SRussell King .atomic_begin = armada_drm_crtc_atomic_begin,
546c36045e1SRussell King .atomic_flush = armada_drm_crtc_atomic_flush,
54734e25ed6SRussell King .atomic_disable = armada_drm_crtc_atomic_disable,
54834e25ed6SRussell King .atomic_enable = armada_drm_crtc_atomic_enable,
54996f60e37SRussell King };
55096f60e37SRussell King
armada_load_cursor_argb(void __iomem * base,uint32_t * pix,unsigned stride,unsigned width,unsigned height)551662af0d8SRussell King static void armada_load_cursor_argb(void __iomem *base, uint32_t *pix,
552662af0d8SRussell King unsigned stride, unsigned width, unsigned height)
553662af0d8SRussell King {
554662af0d8SRussell King uint32_t addr;
555662af0d8SRussell King unsigned y;
556662af0d8SRussell King
557662af0d8SRussell King addr = SRAM_HWC32_RAM1;
558662af0d8SRussell King for (y = 0; y < height; y++) {
559662af0d8SRussell King uint32_t *p = &pix[y * stride];
560662af0d8SRussell King unsigned x;
561662af0d8SRussell King
562662af0d8SRussell King for (x = 0; x < width; x++, p++) {
563662af0d8SRussell King uint32_t val = *p;
564662af0d8SRussell King
5655d32b660SRussell King /*
5665d32b660SRussell King * In "ARGB888" (HWC32) mode, writing to the SRAM
5675d32b660SRussell King * requires these bits to contain:
5685d32b660SRussell King * 31:24 = alpha 23:16 = blue 15:8 = green 7:0 = red
5695d32b660SRussell King * So, it's actually ABGR8888. This is independent
5705d32b660SRussell King * of the SWAPRB bits in DMA control register 0.
5715d32b660SRussell King */
572662af0d8SRussell King val = (val & 0xff00ff00) |
573662af0d8SRussell King (val & 0x000000ff) << 16 |
574662af0d8SRussell King (val & 0x00ff0000) >> 16;
575662af0d8SRussell King
576662af0d8SRussell King writel_relaxed(val,
577662af0d8SRussell King base + LCD_SPU_SRAM_WRDAT);
578662af0d8SRussell King writel_relaxed(addr | SRAM_WRITE,
579662af0d8SRussell King base + LCD_SPU_SRAM_CTRL);
580c39b0695SRussell King readl_relaxed(base + LCD_SPU_HWC_OVSA_HPXL_VLN);
581662af0d8SRussell King addr += 1;
582662af0d8SRussell King if ((addr & 0x00ff) == 0)
583662af0d8SRussell King addr += 0xf00;
584662af0d8SRussell King if ((addr & 0x30ff) == 0)
585662af0d8SRussell King addr = SRAM_HWC32_RAM2;
586662af0d8SRussell King }
587662af0d8SRussell King }
588662af0d8SRussell King }
589662af0d8SRussell King
armada_drm_crtc_cursor_tran(void __iomem * base)590662af0d8SRussell King static void armada_drm_crtc_cursor_tran(void __iomem *base)
591662af0d8SRussell King {
592662af0d8SRussell King unsigned addr;
593662af0d8SRussell King
594662af0d8SRussell King for (addr = 0; addr < 256; addr++) {
595662af0d8SRussell King /* write the default value */
596662af0d8SRussell King writel_relaxed(0x55555555, base + LCD_SPU_SRAM_WRDAT);
597662af0d8SRussell King writel_relaxed(addr | SRAM_WRITE | SRAM_HWC32_TRAN,
598662af0d8SRussell King base + LCD_SPU_SRAM_CTRL);
599662af0d8SRussell King }
600662af0d8SRussell King }
601662af0d8SRussell King
armada_drm_crtc_cursor_update(struct armada_crtc * dcrtc,bool reload)602662af0d8SRussell King static int armada_drm_crtc_cursor_update(struct armada_crtc *dcrtc, bool reload)
603662af0d8SRussell King {
604662af0d8SRussell King uint32_t xoff, xscr, w = dcrtc->cursor_w, s;
605662af0d8SRussell King uint32_t yoff, yscr, h = dcrtc->cursor_h;
606662af0d8SRussell King uint32_t para1;
607662af0d8SRussell King
608662af0d8SRussell King /*
609662af0d8SRussell King * Calculate the visible width and height of the cursor,
610662af0d8SRussell King * screen position, and the position in the cursor bitmap.
611662af0d8SRussell King */
612662af0d8SRussell King if (dcrtc->cursor_x < 0) {
613662af0d8SRussell King xoff = -dcrtc->cursor_x;
614662af0d8SRussell King xscr = 0;
615662af0d8SRussell King w -= min(xoff, w);
616662af0d8SRussell King } else if (dcrtc->cursor_x + w > dcrtc->crtc.mode.hdisplay) {
617662af0d8SRussell King xoff = 0;
618662af0d8SRussell King xscr = dcrtc->cursor_x;
619662af0d8SRussell King w = max_t(int, dcrtc->crtc.mode.hdisplay - dcrtc->cursor_x, 0);
620662af0d8SRussell King } else {
621662af0d8SRussell King xoff = 0;
622662af0d8SRussell King xscr = dcrtc->cursor_x;
623662af0d8SRussell King }
624662af0d8SRussell King
625662af0d8SRussell King if (dcrtc->cursor_y < 0) {
626662af0d8SRussell King yoff = -dcrtc->cursor_y;
627662af0d8SRussell King yscr = 0;
628662af0d8SRussell King h -= min(yoff, h);
629662af0d8SRussell King } else if (dcrtc->cursor_y + h > dcrtc->crtc.mode.vdisplay) {
630662af0d8SRussell King yoff = 0;
631662af0d8SRussell King yscr = dcrtc->cursor_y;
632662af0d8SRussell King h = max_t(int, dcrtc->crtc.mode.vdisplay - dcrtc->cursor_y, 0);
633662af0d8SRussell King } else {
634662af0d8SRussell King yoff = 0;
635662af0d8SRussell King yscr = dcrtc->cursor_y;
636662af0d8SRussell King }
637662af0d8SRussell King
638662af0d8SRussell King /* On interlaced modes, the vertical cursor size must be halved */
639662af0d8SRussell King s = dcrtc->cursor_w;
640662af0d8SRussell King if (dcrtc->interlaced) {
641662af0d8SRussell King s *= 2;
642662af0d8SRussell King yscr /= 2;
643662af0d8SRussell King h /= 2;
644662af0d8SRussell King }
645662af0d8SRussell King
646662af0d8SRussell King if (!dcrtc->cursor_obj || !h || !w) {
647662af0d8SRussell King spin_lock_irq(&dcrtc->irq_lock);
648662af0d8SRussell King dcrtc->cursor_update = false;
649662af0d8SRussell King armada_updatel(0, CFG_HWC_ENA, dcrtc->base + LCD_SPU_DMA_CTRL0);
650662af0d8SRussell King spin_unlock_irq(&dcrtc->irq_lock);
651662af0d8SRussell King return 0;
652662af0d8SRussell King }
653662af0d8SRussell King
654214612f9SRussell King spin_lock_irq(&dcrtc->irq_lock);
655662af0d8SRussell King para1 = readl_relaxed(dcrtc->base + LCD_SPU_SRAM_PARA1);
656662af0d8SRussell King armada_updatel(CFG_CSB_256x32, CFG_CSB_256x32 | CFG_PDWN256x32,
657662af0d8SRussell King dcrtc->base + LCD_SPU_SRAM_PARA1);
658214612f9SRussell King spin_unlock_irq(&dcrtc->irq_lock);
659662af0d8SRussell King
660662af0d8SRussell King /*
661662af0d8SRussell King * Initialize the transparency if the SRAM was powered down.
662662af0d8SRussell King * We must also reload the cursor data as well.
663662af0d8SRussell King */
664662af0d8SRussell King if (!(para1 & CFG_CSB_256x32)) {
665662af0d8SRussell King armada_drm_crtc_cursor_tran(dcrtc->base);
666662af0d8SRussell King reload = true;
667662af0d8SRussell King }
668662af0d8SRussell King
669662af0d8SRussell King if (dcrtc->cursor_hw_sz != (h << 16 | w)) {
670662af0d8SRussell King spin_lock_irq(&dcrtc->irq_lock);
671662af0d8SRussell King dcrtc->cursor_update = false;
672662af0d8SRussell King armada_updatel(0, CFG_HWC_ENA, dcrtc->base + LCD_SPU_DMA_CTRL0);
673662af0d8SRussell King spin_unlock_irq(&dcrtc->irq_lock);
674662af0d8SRussell King reload = true;
675662af0d8SRussell King }
676662af0d8SRussell King if (reload) {
677662af0d8SRussell King struct armada_gem_object *obj = dcrtc->cursor_obj;
678662af0d8SRussell King uint32_t *pix;
679662af0d8SRussell King /* Set the top-left corner of the cursor image */
680662af0d8SRussell King pix = obj->addr;
681662af0d8SRussell King pix += yoff * s + xoff;
682662af0d8SRussell King armada_load_cursor_argb(dcrtc->base, pix, s, w, h);
683662af0d8SRussell King }
684662af0d8SRussell King
685662af0d8SRussell King /* Reload the cursor position, size and enable in the IRQ handler */
686662af0d8SRussell King spin_lock_irq(&dcrtc->irq_lock);
687662af0d8SRussell King dcrtc->cursor_hw_pos = yscr << 16 | xscr;
688662af0d8SRussell King dcrtc->cursor_hw_sz = h << 16 | w;
689662af0d8SRussell King dcrtc->cursor_update = true;
690662af0d8SRussell King armada_drm_crtc_enable_irq(dcrtc, DUMB_FRAMEDONE_ENA);
691662af0d8SRussell King spin_unlock_irq(&dcrtc->irq_lock);
692662af0d8SRussell King
693662af0d8SRussell King return 0;
694662af0d8SRussell King }
695662af0d8SRussell King
cursor_update(void * data)696662af0d8SRussell King static void cursor_update(void *data)
697662af0d8SRussell King {
698662af0d8SRussell King armada_drm_crtc_cursor_update(data, true);
699662af0d8SRussell King }
700662af0d8SRussell King
armada_drm_crtc_cursor_set(struct drm_crtc * crtc,struct drm_file * file,uint32_t handle,uint32_t w,uint32_t h)701662af0d8SRussell King static int armada_drm_crtc_cursor_set(struct drm_crtc *crtc,
702662af0d8SRussell King struct drm_file *file, uint32_t handle, uint32_t w, uint32_t h)
703662af0d8SRussell King {
704662af0d8SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
705662af0d8SRussell King struct armada_gem_object *obj = NULL;
706662af0d8SRussell King int ret;
707662af0d8SRussell King
708662af0d8SRussell King /* If no cursor support, replicate drm's return value */
70942e62ba7SRussell King if (!dcrtc->variant->has_spu_adv_reg)
710662af0d8SRussell King return -ENXIO;
711662af0d8SRussell King
712662af0d8SRussell King if (handle && w > 0 && h > 0) {
713662af0d8SRussell King /* maximum size is 64x32 or 32x64 */
714662af0d8SRussell King if (w > 64 || h > 64 || (w > 32 && h > 32))
715662af0d8SRussell King return -ENOMEM;
716662af0d8SRussell King
717a8ad0bd8SChris Wilson obj = armada_gem_object_lookup(file, handle);
718662af0d8SRussell King if (!obj)
719662af0d8SRussell King return -ENOENT;
720662af0d8SRussell King
721662af0d8SRussell King /* Must be a kernel-mapped object */
722662af0d8SRussell King if (!obj->addr) {
723dda156cfSEmil Velikov drm_gem_object_put(&obj->obj);
724662af0d8SRussell King return -EINVAL;
725662af0d8SRussell King }
726662af0d8SRussell King
727662af0d8SRussell King if (obj->obj.size < w * h * 4) {
728662af0d8SRussell King DRM_ERROR("buffer is too small\n");
729dda156cfSEmil Velikov drm_gem_object_put(&obj->obj);
730662af0d8SRussell King return -ENOMEM;
731662af0d8SRussell King }
732662af0d8SRussell King }
733662af0d8SRussell King
734662af0d8SRussell King if (dcrtc->cursor_obj) {
735662af0d8SRussell King dcrtc->cursor_obj->update = NULL;
736662af0d8SRussell King dcrtc->cursor_obj->update_data = NULL;
737dda156cfSEmil Velikov drm_gem_object_put(&dcrtc->cursor_obj->obj);
738662af0d8SRussell King }
739662af0d8SRussell King dcrtc->cursor_obj = obj;
740662af0d8SRussell King dcrtc->cursor_w = w;
741662af0d8SRussell King dcrtc->cursor_h = h;
742662af0d8SRussell King ret = armada_drm_crtc_cursor_update(dcrtc, true);
743662af0d8SRussell King if (obj) {
744662af0d8SRussell King obj->update_data = dcrtc;
745662af0d8SRussell King obj->update = cursor_update;
746662af0d8SRussell King }
747662af0d8SRussell King
748662af0d8SRussell King return ret;
749662af0d8SRussell King }
750662af0d8SRussell King
armada_drm_crtc_cursor_move(struct drm_crtc * crtc,int x,int y)751662af0d8SRussell King static int armada_drm_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
752662af0d8SRussell King {
753662af0d8SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
754662af0d8SRussell King int ret;
755662af0d8SRussell King
756662af0d8SRussell King /* If no cursor support, replicate drm's return value */
75742e62ba7SRussell King if (!dcrtc->variant->has_spu_adv_reg)
758662af0d8SRussell King return -EFAULT;
759662af0d8SRussell King
760662af0d8SRussell King dcrtc->cursor_x = x;
761662af0d8SRussell King dcrtc->cursor_y = y;
762662af0d8SRussell King ret = armada_drm_crtc_cursor_update(dcrtc, false);
763662af0d8SRussell King
764662af0d8SRussell King return ret;
765662af0d8SRussell King }
766662af0d8SRussell King
armada_drm_crtc_destroy(struct drm_crtc * crtc)76796f60e37SRussell King static void armada_drm_crtc_destroy(struct drm_crtc *crtc)
76896f60e37SRussell King {
76996f60e37SRussell King struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
770dad75a52SDaniel Vetter struct armada_private *priv = drm_to_armada_dev(crtc->dev);
77196f60e37SRussell King
772662af0d8SRussell King if (dcrtc->cursor_obj)
773dda156cfSEmil Velikov drm_gem_object_put(&dcrtc->cursor_obj->obj);
774662af0d8SRussell King
77596f60e37SRussell King priv->dcrtc[dcrtc->num] = NULL;
77696f60e37SRussell King drm_crtc_cleanup(&dcrtc->crtc);
77796f60e37SRussell King
778a0fbb35eSRussell King if (dcrtc->variant->disable)
779a0fbb35eSRussell King dcrtc->variant->disable(dcrtc);
78096f60e37SRussell King
781e5d9ddfbSRussell King writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ENA);
782e5d9ddfbSRussell King
7839611cb93SRussell King of_node_put(dcrtc->crtc.port);
7849611cb93SRussell King
78596f60e37SRussell King kfree(dcrtc);
78696f60e37SRussell King }
78796f60e37SRussell King
armada_drm_crtc_late_register(struct drm_crtc * crtc)78806734cb0SRussell King static int armada_drm_crtc_late_register(struct drm_crtc *crtc)
78906734cb0SRussell King {
79006734cb0SRussell King if (IS_ENABLED(CONFIG_DEBUG_FS))
79106734cb0SRussell King armada_drm_crtc_debugfs_init(drm_to_armada_crtc(crtc));
79206734cb0SRussell King
79306734cb0SRussell King return 0;
79406734cb0SRussell King }
79506734cb0SRussell King
7965922a7d0SShawn Guo /* These are called under the vbl_lock. */
armada_drm_crtc_enable_vblank(struct drm_crtc * crtc)7975922a7d0SShawn Guo static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
7985922a7d0SShawn Guo {
7995922a7d0SShawn Guo struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
80092298c1cSRussell King unsigned long flags;
8015922a7d0SShawn Guo
80292298c1cSRussell King spin_lock_irqsave(&dcrtc->irq_lock, flags);
8035922a7d0SShawn Guo armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
80492298c1cSRussell King spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
8055922a7d0SShawn Guo return 0;
8065922a7d0SShawn Guo }
8075922a7d0SShawn Guo
armada_drm_crtc_disable_vblank(struct drm_crtc * crtc)8085922a7d0SShawn Guo static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
8095922a7d0SShawn Guo {
8105922a7d0SShawn Guo struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
81192298c1cSRussell King unsigned long flags;
8125922a7d0SShawn Guo
81392298c1cSRussell King spin_lock_irqsave(&dcrtc->irq_lock, flags);
8145922a7d0SShawn Guo armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
81592298c1cSRussell King spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
8165922a7d0SShawn Guo }
8175922a7d0SShawn Guo
818a02fb90aSVille Syrjälä static const struct drm_crtc_funcs armada_crtc_funcs = {
819c36045e1SRussell King .reset = drm_atomic_helper_crtc_reset,
820662af0d8SRussell King .cursor_set = armada_drm_crtc_cursor_set,
821662af0d8SRussell King .cursor_move = armada_drm_crtc_cursor_move,
82296f60e37SRussell King .destroy = armada_drm_crtc_destroy,
8236d2f864fSRussell King .set_config = drm_atomic_helper_set_config,
82413c94d53SRussell King .page_flip = drm_atomic_helper_page_flip,
825c36045e1SRussell King .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
826c36045e1SRussell King .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
82706734cb0SRussell King .late_register = armada_drm_crtc_late_register,
8285922a7d0SShawn Guo .enable_vblank = armada_drm_crtc_enable_vblank,
8295922a7d0SShawn Guo .disable_vblank = armada_drm_crtc_disable_vblank,
83096f60e37SRussell King };
83196f60e37SRussell King
armada_crtc_select_clock(struct armada_crtc * dcrtc,struct armada_clk_result * res,const struct armada_clocking_params * params,struct clk * clks[],size_t num_clks,unsigned long desired_khz)8321ba246f2SRussell King int armada_crtc_select_clock(struct armada_crtc *dcrtc,
8331ba246f2SRussell King struct armada_clk_result *res,
8341ba246f2SRussell King const struct armada_clocking_params *params,
8351ba246f2SRussell King struct clk *clks[], size_t num_clks,
8361ba246f2SRussell King unsigned long desired_khz)
8371ba246f2SRussell King {
8381ba246f2SRussell King unsigned long desired_hz = desired_khz * 1000;
8391ba246f2SRussell King unsigned long desired_clk_hz; // requested clk input
8401ba246f2SRussell King unsigned long real_clk_hz; // actual clk input
8411ba246f2SRussell King unsigned long real_hz; // actual pixel clk
8421ba246f2SRussell King unsigned long permillage;
8431ba246f2SRussell King struct clk *clk;
8441ba246f2SRussell King u32 div;
8451ba246f2SRussell King int i;
8461ba246f2SRussell King
8471ba246f2SRussell King DRM_DEBUG_KMS("[CRTC:%u:%s] desired clock=%luHz\n",
8481ba246f2SRussell King dcrtc->crtc.base.id, dcrtc->crtc.name, desired_hz);
8491ba246f2SRussell King
8501ba246f2SRussell King for (i = 0; i < num_clks; i++) {
8511ba246f2SRussell King clk = clks[i];
8521ba246f2SRussell King if (!clk)
8531ba246f2SRussell King continue;
8541ba246f2SRussell King
8551ba246f2SRussell King if (params->settable & BIT(i)) {
8561ba246f2SRussell King real_clk_hz = clk_round_rate(clk, desired_hz);
8571ba246f2SRussell King desired_clk_hz = desired_hz;
8581ba246f2SRussell King } else {
8591ba246f2SRussell King real_clk_hz = clk_get_rate(clk);
8601ba246f2SRussell King desired_clk_hz = real_clk_hz;
8611ba246f2SRussell King }
8621ba246f2SRussell King
8631ba246f2SRussell King /* If the clock can do exactly the desired rate, we're done */
8641ba246f2SRussell King if (real_clk_hz == desired_hz) {
8651ba246f2SRussell King real_hz = real_clk_hz;
8661ba246f2SRussell King div = 1;
8671ba246f2SRussell King goto found;
8681ba246f2SRussell King }
8691ba246f2SRussell King
8701ba246f2SRussell King /* Calculate the divider - if invalid, we can't do this rate */
8711ba246f2SRussell King div = DIV_ROUND_CLOSEST(real_clk_hz, desired_hz);
8721ba246f2SRussell King if (div == 0 || div > params->div_max)
8731ba246f2SRussell King continue;
8741ba246f2SRussell King
8751ba246f2SRussell King /* Calculate the actual rate - HDMI requires -0.6%..+0.5% */
8761ba246f2SRussell King real_hz = DIV_ROUND_CLOSEST(real_clk_hz, div);
8771ba246f2SRussell King
8781ba246f2SRussell King DRM_DEBUG_KMS("[CRTC:%u:%s] clk=%u %luHz div=%u real=%luHz\n",
8791ba246f2SRussell King dcrtc->crtc.base.id, dcrtc->crtc.name,
8801ba246f2SRussell King i, real_clk_hz, div, real_hz);
8811ba246f2SRussell King
8821ba246f2SRussell King /* Avoid repeated division */
8831ba246f2SRussell King if (real_hz < desired_hz) {
8841ba246f2SRussell King permillage = real_hz / desired_khz;
8851ba246f2SRussell King if (permillage < params->permillage_min)
8861ba246f2SRussell King continue;
8871ba246f2SRussell King } else {
8881ba246f2SRussell King permillage = DIV_ROUND_UP(real_hz, desired_khz);
8891ba246f2SRussell King if (permillage > params->permillage_max)
8901ba246f2SRussell King continue;
8911ba246f2SRussell King }
8921ba246f2SRussell King goto found;
8931ba246f2SRussell King }
8941ba246f2SRussell King
8951ba246f2SRussell King return -ERANGE;
8961ba246f2SRussell King
8971ba246f2SRussell King found:
8981ba246f2SRussell King DRM_DEBUG_KMS("[CRTC:%u:%s] selected clk=%u %luHz div=%u real=%luHz\n",
8991ba246f2SRussell King dcrtc->crtc.base.id, dcrtc->crtc.name,
9001ba246f2SRussell King i, real_clk_hz, div, real_hz);
9011ba246f2SRussell King
9021ba246f2SRussell King res->desired_clk_hz = desired_clk_hz;
9031ba246f2SRussell King res->clk = clk;
9041ba246f2SRussell King res->div = div;
9051ba246f2SRussell King
9061ba246f2SRussell King return i;
9071ba246f2SRussell King }
9081ba246f2SRussell King
armada_drm_crtc_create(struct drm_device * drm,struct device * dev,struct resource * res,int irq,const struct armada_variant * variant,struct device_node * port)9090fb2970bSRussell King static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
9109611cb93SRussell King struct resource *res, int irq, const struct armada_variant *variant,
9119611cb93SRussell King struct device_node *port)
91296f60e37SRussell King {
913dad75a52SDaniel Vetter struct armada_private *priv = drm_to_armada_dev(drm);
91496f60e37SRussell King struct armada_crtc *dcrtc;
91582c702cbSRussell King struct drm_plane *primary;
91696f60e37SRussell King void __iomem *base;
91796f60e37SRussell King int ret;
91896f60e37SRussell King
919a7d7a143SLinus Torvalds base = devm_ioremap_resource(dev, res);
920c9d53c0fSJingoo Han if (IS_ERR(base))
921c9d53c0fSJingoo Han return PTR_ERR(base);
92296f60e37SRussell King
92396f60e37SRussell King dcrtc = kzalloc(sizeof(*dcrtc), GFP_KERNEL);
92496f60e37SRussell King if (!dcrtc) {
92596f60e37SRussell King DRM_ERROR("failed to allocate Armada crtc\n");
92696f60e37SRussell King return -ENOMEM;
92796f60e37SRussell King }
92896f60e37SRussell King
929d8c96083SRussell King if (dev != drm->dev)
930d8c96083SRussell King dev_set_drvdata(dev, dcrtc);
931d8c96083SRussell King
93242e62ba7SRussell King dcrtc->variant = variant;
93396f60e37SRussell King dcrtc->base = base;
934d8c96083SRussell King dcrtc->num = drm->mode_config.num_crtc;
93596f60e37SRussell King dcrtc->cfg_dumb_ctrl = DUMB24_RGB888_0;
93696f60e37SRussell King dcrtc->spu_iopad_ctrl = CFG_VSCALE_LN_EN | CFG_IOPAD_DUMB24;
93796f60e37SRussell King spin_lock_init(&dcrtc->irq_lock);
93896f60e37SRussell King dcrtc->irq_ena = CLEAN_SPU_IRQ_ISR;
93996f60e37SRussell King
94096f60e37SRussell King /* Initialize some registers which we don't otherwise set */
94196f60e37SRussell King writel_relaxed(0x00000001, dcrtc->base + LCD_CFG_SCLK_DIV);
94296f60e37SRussell King writel_relaxed(0x00000000, dcrtc->base + LCD_SPU_BLANKCOLOR);
94396f60e37SRussell King writel_relaxed(dcrtc->spu_iopad_ctrl,
94496f60e37SRussell King dcrtc->base + LCD_SPU_IOPAD_CONTROL);
94596f60e37SRussell King writel_relaxed(0x00000000, dcrtc->base + LCD_SPU_SRAM_PARA0);
94696f60e37SRussell King writel_relaxed(CFG_PDWN256x32 | CFG_PDWN256x24 | CFG_PDWN256x8 |
94796f60e37SRussell King CFG_PDWN32x32 | CFG_PDWN16x66 | CFG_PDWN32x66 |
94896f60e37SRussell King CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);
94996f60e37SRussell King writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1);
950e5d9ddfbSRussell King writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
95192298c1cSRussell King readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
952e5d9ddfbSRussell King writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
95396f60e37SRussell King
954e5d9ddfbSRussell King ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
955e5d9ddfbSRussell King dcrtc);
95633cd3c07SRussell King if (ret < 0)
95733cd3c07SRussell King goto err_crtc;
95896f60e37SRussell King
95942e62ba7SRussell King if (dcrtc->variant->init) {
960d8c96083SRussell King ret = dcrtc->variant->init(dcrtc, dev);
96133cd3c07SRussell King if (ret)
96233cd3c07SRussell King goto err_crtc;
96396f60e37SRussell King }
96496f60e37SRussell King
96596f60e37SRussell King /* Ensure AXI pipeline is enabled */
96696f60e37SRussell King armada_updatel(CFG_ARBFAST_ENA, 0, dcrtc->base + LCD_SPU_DMA_CTRL0);
96796f60e37SRussell King
96896f60e37SRussell King priv->dcrtc[dcrtc->num] = dcrtc;
96996f60e37SRussell King
9709611cb93SRussell King dcrtc->crtc.port = port;
9711c914cecSRussell King
972de32301bSRussell King primary = kzalloc(sizeof(*primary), GFP_KERNEL);
97333cd3c07SRussell King if (!primary) {
97433cd3c07SRussell King ret = -ENOMEM;
97533cd3c07SRussell King goto err_crtc;
97633cd3c07SRussell King }
9771c914cecSRussell King
978d40af7b1SRussell King ret = armada_drm_primary_plane_init(drm, primary);
979de32301bSRussell King if (ret) {
980de32301bSRussell King kfree(primary);
98133cd3c07SRussell King goto err_crtc;
982de32301bSRussell King }
983de32301bSRussell King
98482c702cbSRussell King ret = drm_crtc_init_with_planes(drm, &dcrtc->crtc, primary, NULL,
985f9882876SVille Syrjälä &armada_crtc_funcs, NULL);
9861c914cecSRussell King if (ret)
9871c914cecSRussell King goto err_crtc_init;
9881c914cecSRussell King
98996f60e37SRussell King drm_crtc_helper_add(&dcrtc->crtc, &armada_crtc_helper_funcs);
99096f60e37SRussell King
991d0d765deSRussell King ret = drm_mode_crtc_set_gamma_size(&dcrtc->crtc, 256);
992d0d765deSRussell King if (ret)
993d0d765deSRussell King return ret;
994d0d765deSRussell King
995d0d765deSRussell King drm_crtc_enable_color_mgmt(&dcrtc->crtc, 0, false, 256);
996d0d765deSRussell King
997d8c96083SRussell King return armada_overlay_plane_create(drm, 1 << dcrtc->num);
9981c914cecSRussell King
9991c914cecSRussell King err_crtc_init:
100082c702cbSRussell King primary->funcs->destroy(primary);
100133cd3c07SRussell King err_crtc:
100233cd3c07SRussell King kfree(dcrtc);
100333cd3c07SRussell King
10041c914cecSRussell King return ret;
100596f60e37SRussell King }
1006d8c96083SRussell King
1007d8c96083SRussell King static int
armada_lcd_bind(struct device * dev,struct device * master,void * data)1008d8c96083SRussell King armada_lcd_bind(struct device *dev, struct device *master, void *data)
1009d8c96083SRussell King {
1010d8c96083SRussell King struct platform_device *pdev = to_platform_device(dev);
1011d8c96083SRussell King struct drm_device *drm = data;
1012d8c96083SRussell King struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1013d8c96083SRussell King int irq = platform_get_irq(pdev, 0);
1014d8c96083SRussell King const struct armada_variant *variant;
10159611cb93SRussell King struct device_node *port = NULL;
1016*e1704914SRob Herring struct device_node *np, *parent = dev->of_node;
1017d8c96083SRussell King
1018d8c96083SRussell King if (irq < 0)
1019d8c96083SRussell King return irq;
1020d8c96083SRussell King
1021d8c96083SRussell King
1022*e1704914SRob Herring variant = device_get_match_data(dev);
1023*e1704914SRob Herring if (!variant)
1024d8c96083SRussell King return -ENXIO;
1025d8c96083SRussell King
1026*e1704914SRob Herring if (parent) {
10279611cb93SRussell King np = of_get_child_by_name(parent, "ports");
10289611cb93SRussell King if (np)
10299611cb93SRussell King parent = np;
10309611cb93SRussell King port = of_get_child_by_name(parent, "port");
10319611cb93SRussell King of_node_put(np);
10329611cb93SRussell King if (!port) {
10334bf99144SRob Herring dev_err(dev, "no port node found in %pOF\n", parent);
10349611cb93SRussell King return -ENXIO;
10359611cb93SRussell King }
1036d8c96083SRussell King }
1037d8c96083SRussell King
10389611cb93SRussell King return armada_drm_crtc_create(drm, dev, res, irq, variant, port);
1039d8c96083SRussell King }
1040d8c96083SRussell King
1041d8c96083SRussell King static void
armada_lcd_unbind(struct device * dev,struct device * master,void * data)1042d8c96083SRussell King armada_lcd_unbind(struct device *dev, struct device *master, void *data)
1043d8c96083SRussell King {
1044d8c96083SRussell King struct armada_crtc *dcrtc = dev_get_drvdata(dev);
1045d8c96083SRussell King
1046d8c96083SRussell King armada_drm_crtc_destroy(&dcrtc->crtc);
1047d8c96083SRussell King }
1048d8c96083SRussell King
1049d8c96083SRussell King static const struct component_ops armada_lcd_ops = {
1050d8c96083SRussell King .bind = armada_lcd_bind,
1051d8c96083SRussell King .unbind = armada_lcd_unbind,
1052d8c96083SRussell King };
1053d8c96083SRussell King
armada_lcd_probe(struct platform_device * pdev)1054d8c96083SRussell King static int armada_lcd_probe(struct platform_device *pdev)
1055d8c96083SRussell King {
1056d8c96083SRussell King return component_add(&pdev->dev, &armada_lcd_ops);
1057d8c96083SRussell King }
1058d8c96083SRussell King
armada_lcd_remove(struct platform_device * pdev)1059b4791474SUwe Kleine-König static void armada_lcd_remove(struct platform_device *pdev)
1060d8c96083SRussell King {
1061d8c96083SRussell King component_del(&pdev->dev, &armada_lcd_ops);
1062d8c96083SRussell King }
1063d8c96083SRussell King
106485909716SArvind Yadav static const struct of_device_id armada_lcd_of_match[] = {
1065d8c96083SRussell King {
1066d8c96083SRussell King .compatible = "marvell,dove-lcd",
1067d8c96083SRussell King .data = &armada510_ops,
1068d8c96083SRussell King },
1069d8c96083SRussell King {}
1070d8c96083SRussell King };
1071d8c96083SRussell King MODULE_DEVICE_TABLE(of, armada_lcd_of_match);
1072d8c96083SRussell King
1073d8c96083SRussell King static const struct platform_device_id armada_lcd_platform_ids[] = {
1074d8c96083SRussell King {
1075d8c96083SRussell King .name = "armada-lcd",
1076d8c96083SRussell King .driver_data = (unsigned long)&armada510_ops,
1077d8c96083SRussell King }, {
1078d8c96083SRussell King .name = "armada-510-lcd",
1079d8c96083SRussell King .driver_data = (unsigned long)&armada510_ops,
1080d8c96083SRussell King },
1081d8c96083SRussell King { },
1082d8c96083SRussell King };
1083d8c96083SRussell King MODULE_DEVICE_TABLE(platform, armada_lcd_platform_ids);
1084d8c96083SRussell King
1085d8c96083SRussell King struct platform_driver armada_lcd_platform_driver = {
1086d8c96083SRussell King .probe = armada_lcd_probe,
1087b4791474SUwe Kleine-König .remove_new = armada_lcd_remove,
1088d8c96083SRussell King .driver = {
1089d8c96083SRussell King .name = "armada-lcd",
1090d8c96083SRussell King .owner = THIS_MODULE,
1091d8c96083SRussell King .of_match_table = armada_lcd_of_match,
1092d8c96083SRussell King },
1093d8c96083SRussell King .id_table = armada_lcd_platform_ids,
1094d8c96083SRussell King };
1095