Skip to content

Commit 0dd6830

Browse files
ozbenhairlied
authored andcommitted
drm/ast: Try to use MMIO registers when PIO isn't supported
If the PIO resources haven't been assigned, then we have no choice but try to use the MMIO version. This is the case for example on POWER8 which doesn't support PIO at all. Chips rev 0x20 or later have MMIO decoding enabled by default. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 98faa78 commit 0dd6830

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎drivers/gpu/drm/ast/ast_drv.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,18 @@ struct ast_gem_object;
125125

126126
#define AST_IO_AR_PORT_WRITE (0x40)
127127
#define AST_IO_MISC_PORT_WRITE (0x42)
128+
#define AST_IO_VGA_ENABLE_PORT (0x43)
128129
#define AST_IO_SEQ_PORT (0x44)
129-
#define AST_DAC_INDEX_READ (0x3c7)
130+
#define AST_IO_DAC_INDEX_READ (0x47)
130131
#define AST_IO_DAC_INDEX_WRITE (0x48)
131132
#define AST_IO_DAC_DATA (0x49)
132133
#define AST_IO_GR_PORT (0x4E)
133134
#define AST_IO_CRTC_PORT (0x54)
134135
#define AST_IO_INPUT_STATUS1_READ (0x5A)
135136
#define AST_IO_MISC_PORT_READ (0x4C)
136137

138+
#define AST_IO_MM_OFFSET (0x380)
139+
137140
#define __ast_read(x) \
138141
static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \
139142
u##x val = 0;\

‎drivers/gpu/drm/ast/ast_main.c‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,24 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
359359
ret = -EIO;
360360
goto out_free;
361361
}
362-
ast->ioregs = pci_iomap(dev->pdev, 2, 0);
362+
363+
/*
364+
* If we don't have IO space at all, use MMIO now and
365+
* assume the chip has MMIO enabled by default (rev 0x20
366+
* and higher).
367+
*/
368+
if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) {
369+
DRM_INFO("platform has no IO space, trying MMIO\n");
370+
ast->ioregs = ast->regs + AST_IO_MM_OFFSET;
371+
}
372+
373+
/* "map" IO regs if the above hasn't done so already */
363374
if (!ast->ioregs) {
364-
ret = -EIO;
365-
goto out_free;
375+
ast->ioregs = pci_iomap(dev->pdev, 2, 0);
376+
if (!ast->ioregs) {
377+
ret = -EIO;
378+
goto out_free;
379+
}
366380
}
367381

368382
ast_detect_chip(dev);

0 commit comments

Comments
 (0)