From eb054e3b3d531e311e9a34b902fe29247b00f724 Mon Sep 17 00:00:00 2001 From: Peter Huewe Date: Thu, 20 Aug 2009 22:42:31 +0200 Subject: m68k: vme_scc - __init annotations Trivial patch which adds the __init macro to the module_init function and all of its helper functions of drivers/char/vme_scc.c Signed-off-by: Peter Huewe Signed-off-by: Geert Uytterhoeven --- drivers/char/vme_scc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index 994e1a58b98..8b24729fec8 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c @@ -136,7 +136,7 @@ static const struct tty_port_operations scc_port_ops = { * vme_scc_init() and support functions *---------------------------------------------------------------------------*/ -static int scc_init_drivers(void) +static int __init scc_init_drivers(void) { int error; @@ -172,7 +172,7 @@ static int scc_init_drivers(void) /* ports[] array is indexed by line no (i.e. [0] for ttyS0, [1] for ttyS1). */ -static void scc_init_portstructs(void) +static void __init scc_init_portstructs(void) { struct scc_port *port; int i; @@ -195,7 +195,7 @@ static void scc_init_portstructs(void) #ifdef CONFIG_MVME147_SCC -static int mvme147_scc_init(void) +static int __init mvme147_scc_init(void) { struct scc_port *port; int error; @@ -298,7 +298,7 @@ fail: #ifdef CONFIG_MVME162_SCC -static int mvme162_scc_init(void) +static int __init mvme162_scc_init(void) { struct scc_port *port; int error; @@ -404,7 +404,7 @@ fail: #ifdef CONFIG_BVME6000_SCC -static int bvme6000_scc_init(void) +static int __init bvme6000_scc_init(void) { struct scc_port *port; int error; @@ -503,7 +503,7 @@ fail_free_b_rx: #endif -static int vme_scc_init(void) +static int __init vme_scc_init(void) { int res = -ENODEV; -- cgit v1.2.3-70-g09d2 From 41fb11ca90fe5a115b663340290311c7f5aab0f6 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 11 Dec 2009 17:12:09 +0100 Subject: ataflop: Killl warning about unused variable flags After commit e0c0978699a83f26f2341f7eedc1463b79e31aff ("ataflop: remove buggy/commented-out IRQ disable from do_fd_request()") the `flags' variable became unused: drivers/block/ataflop.c:1473: warning: unused variable 'flags' Hence remove it. Signed-off-by: Geert Uytterhoeven --- drivers/block/ataflop.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index a5af1d6dda8..e35cf59cbfd 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1470,8 +1470,6 @@ repeat: void do_fd_request(struct request_queue * q) { - unsigned long flags; - DPRINT(("do_fd_request for pid %d\n",current->pid)); while( fdc_busy ) sleep_on( &fdc_wait ); fdc_busy = 1; -- cgit v1.2.3-70-g09d2 From 2724daf439d9f4e9f25c9fb8de8602ba61758478 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:39:56 +1100 Subject: mac68k: rework SWIM platform device Adjust the platform device code to conform with the code style used in the rest of this patch series. No need to name resources nor to register devices which are not applicable. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/config.c | 35 ++++++++++++++++------------------- drivers/block/swim.c | 4 ++-- 2 files changed, 18 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index cad55bc087d..e6666a30f24 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -44,10 +44,6 @@ #include #include -/* platform device info */ - -#define SWIM_IO_SIZE 0x2000 /* SWIM IO resource size */ - /* Mac bootinfo struct */ struct mac_booter_data mac_bi_data; @@ -862,23 +858,23 @@ static void mac_get_model(char *str) strcat(str, macintosh_config->name); } -static struct resource swim_resources[1]; +static struct resource swim_rsrc = { .flags = IORESOURCE_MEM }; -static struct platform_device swim_device = { +static struct platform_device swim_pdev = { .name = "swim", .id = -1, - .num_resources = ARRAY_SIZE(swim_resources), - .resource = swim_resources, -}; - -static struct platform_device *mac_platform_devices[] __initdata = { - &swim_device + .num_resources = 1, + .resource = &swim_rsrc, }; int __init mac_platform_init(void) { u8 *swim_base; + /* + * Floppy device + */ + switch (macintosh_config->floppy_type) { case MAC_FLOPPY_SWIM_ADDR1: swim_base = (u8 *)(VIA1_BASE + 0x1E000); @@ -887,16 +883,17 @@ int __init mac_platform_init(void) swim_base = (u8 *)(VIA1_BASE + 0x16000); break; default: - return 0; + swim_base = NULL; + break; } - swim_resources[0].name = "swim-regs"; - swim_resources[0].start = (resource_size_t)swim_base; - swim_resources[0].end = (resource_size_t)(swim_base + SWIM_IO_SIZE); - swim_resources[0].flags = IORESOURCE_MEM; + if (swim_base) { + swim_rsrc.start = (resource_size_t) swim_base, + swim_rsrc.end = (resource_size_t) swim_base + 0x2000, + platform_device_register(&swim_pdev); + } - return platform_add_devices(mac_platform_devices, - ARRAY_SIZE(mac_platform_devices)); + return 0; } arch_initcall(mac_platform_init); diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 8f569e3df89..821c2833f9c 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -864,7 +864,7 @@ static int __devinit swim_probe(struct platform_device *dev) struct swim_priv *swd; int ret; - res = platform_get_resource_byname(dev, IORESOURCE_MEM, "swim-regs"); + res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!res) { ret = -ENODEV; goto out; @@ -942,7 +942,7 @@ static int __devexit swim_remove(struct platform_device *dev) iounmap(swd->base); - res = platform_get_resource_byname(dev, IORESOURCE_MEM, "swim-regs"); + res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (res) release_mem_region(res->start, resource_size(res)); -- cgit v1.2.3-70-g09d2 From 1f7b5fff505232521a7a770a639b63cd17636549 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:40:23 +1100 Subject: pmac-zilog: cleanup Whitespace cleanups and comment typo fix. Signed-off-by: Finn Thain Acked-by: Benjamin Herrenschmidt Signed-off-by: Geert Uytterhoeven --- drivers/serial/pmac_zilog.c | 85 ++++++++++++++++++++++----------------------- drivers/serial/pmac_zilog.h | 20 +++++------ 2 files changed, 51 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c index 3e2ae4807ae..1c8afd98e14 100644 --- a/drivers/serial/pmac_zilog.c +++ b/drivers/serial/pmac_zilog.c @@ -153,8 +153,8 @@ static void pmz_load_zsregs(struct uart_pmac_port *uap, u8 *regs) write_zsreg(uap, R10, regs[R10]); /* Set TX/RX controls sans the enable bits. */ - write_zsreg(uap, R3, regs[R3] & ~RxENABLE); - write_zsreg(uap, R5, regs[R5] & ~TxENABLE); + write_zsreg(uap, R3, regs[R3] & ~RxENABLE); + write_zsreg(uap, R5, regs[R5] & ~TxENABLE); /* now set R7 "prime" on ESCC */ write_zsreg(uap, R15, regs[R15] | EN85C30); @@ -205,7 +205,7 @@ static void pmz_load_zsregs(struct uart_pmac_port *uap, u8 *regs) */ static void pmz_maybe_update_regs(struct uart_pmac_port *uap) { - if (!ZS_REGS_HELD(uap)) { + if (!ZS_REGS_HELD(uap)) { if (ZS_TX_ACTIVE(uap)) { uap->flags |= PMACZILOG_FLAG_REGS_HELD; } else { @@ -281,7 +281,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) spin_lock(&uap->port.lock); if (swallow) goto next_char; - } + } #endif /* CONFIG_MAGIC_SYSRQ && CONFIG_SERIAL_CORE_CONSOLE */ /* A real serial line, record the character and status. */ @@ -317,7 +317,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) if (uap->port.ignore_status_mask == 0xff || (r1 & uap->port.ignore_status_mask) == 0) { - tty_insert_flip_char(tty, ch, flag); + tty_insert_flip_char(tty, ch, flag); } if (r1 & Rx_OVR) tty_insert_flip_char(tty, 0, TTY_OVERRUN); @@ -470,47 +470,47 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) uap_a = pmz_get_port_A(uap); uap_b = uap_a->mate; - - spin_lock(&uap_a->port.lock); + + spin_lock(&uap_a->port.lock); r3 = read_zsreg(uap_a, R3); #ifdef DEBUG_HARD pmz_debug("irq, r3: %x\n", r3); #endif - /* Channel A */ + /* Channel A */ tty = NULL; - if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { + if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { write_zsreg(uap_a, R0, RES_H_IUS); zssync(uap_a); - if (r3 & CHAEXT) - pmz_status_handle(uap_a); + if (r3 & CHAEXT) + pmz_status_handle(uap_a); if (r3 & CHARxIP) tty = pmz_receive_chars(uap_a); - if (r3 & CHATxIP) - pmz_transmit_chars(uap_a); - rc = IRQ_HANDLED; - } - spin_unlock(&uap_a->port.lock); + if (r3 & CHATxIP) + pmz_transmit_chars(uap_a); + rc = IRQ_HANDLED; + } + spin_unlock(&uap_a->port.lock); if (tty != NULL) tty_flip_buffer_push(tty); if (uap_b->node == NULL) goto out; - spin_lock(&uap_b->port.lock); + spin_lock(&uap_b->port.lock); tty = NULL; if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { write_zsreg(uap_b, R0, RES_H_IUS); zssync(uap_b); - if (r3 & CHBEXT) - pmz_status_handle(uap_b); - if (r3 & CHBRxIP) - tty = pmz_receive_chars(uap_b); - if (r3 & CHBTxIP) - pmz_transmit_chars(uap_b); - rc = IRQ_HANDLED; - } - spin_unlock(&uap_b->port.lock); + if (r3 & CHBEXT) + pmz_status_handle(uap_b); + if (r3 & CHBRxIP) + tty = pmz_receive_chars(uap_b); + if (r3 & CHBTxIP) + pmz_transmit_chars(uap_b); + rc = IRQ_HANDLED; + } + spin_unlock(&uap_b->port.lock); if (tty != NULL) tty_flip_buffer_push(tty); @@ -718,7 +718,7 @@ static void pmz_enable_ms(struct uart_port *port) if (ZS_IS_ASLEEP(uap)) return; - /* NOTE: Not subject to 'transmitter active' rule. */ + /* NOTE: Not subject to 'transmitter active' rule. */ write_zsreg(uap, R15, uap->curregs[R15]); } } @@ -748,7 +748,7 @@ static void pmz_break_ctl(struct uart_port *port, int break_state) if (new_reg != uap->curregs[R5]) { uap->curregs[R5] = new_reg; - /* NOTE: Not subject to 'transmitter active' rule. */ + /* NOTE: Not subject to 'transmitter active' rule. */ if (ZS_IS_ASLEEP(uap)) return; write_zsreg(uap, R5, uap->curregs[R5]); @@ -908,7 +908,6 @@ static int __pmz_startup(struct uart_pmac_port *uap) /* Remember status for DCD/CTS changes */ uap->prev_status = read_zsreg(uap, R0); - return pwr_delay; } @@ -983,7 +982,7 @@ static int pmz_startup(struct uart_port *port) if (!ZS_IS_EXTCLK(uap)) uap->curregs[R1] |= EXT_INT_ENAB; write_zsreg(uap, R1, uap->curregs[R1]); - spin_unlock_irqrestore(&port->lock, flags); + spin_unlock_irqrestore(&port->lock, flags); pmz_debug("pmz: startup() done.\n"); @@ -1003,7 +1002,7 @@ static void pmz_shutdown(struct uart_port *port) mutex_lock(&pmz_irq_mutex); /* Release interrupt handler */ - free_irq(uap->port.irq, uap); + free_irq(uap->port.irq, uap); spin_lock_irqsave(&port->lock, flags); @@ -1051,7 +1050,6 @@ static void pmz_convert_to_zs(struct uart_pmac_port *uap, unsigned int cflag, { int brg; - /* Switch to external clocking for IrDA high clock rates. That * code could be re-used for Midi interfaces with different * multipliers @@ -1223,12 +1221,12 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud) uap->curregs[R5] |= DTR; write_zsreg(uap, R5, uap->curregs[R5]); zssync(uap); - mdelay(1); + mdelay(1); /* Switch SCC to 19200 */ pmz_convert_to_zs(uap, CS8, 0, 19200); pmz_load_zsregs(uap, uap->curregs); - mdelay(1); + mdelay(1); /* Write get_version command byte */ write_zsdata(uap, 1); @@ -1463,7 +1461,7 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) return -ENODEV; uap->port.mapbase = r_ports.start; uap->port.membase = ioremap(uap->port.mapbase, 0x1000); - + uap->control_reg = uap->port.membase; uap->data_reg = uap->control_reg + 0x10; @@ -1590,7 +1588,7 @@ static void pmz_dispose_port(struct uart_pmac_port *uap) } /* - * Called upon match with an escc node in the devive-tree. + * Called upon match with an escc node in the device-tree. */ static int pmz_attach(struct macio_dev *mdev, const struct of_device_id *match) { @@ -1812,7 +1810,7 @@ static int __init pmz_probe(void) pmz_ports[count].node = node_a; pmz_ports[count+1].node = node_b; pmz_ports[count].port.line = count; - pmz_ports[count+1].port.line = count+1; + pmz_ports[count+1].port.line = count+1; /* * Setup the ports for real @@ -1899,23 +1897,22 @@ err_out: static struct of_device_id pmz_match[] = { { - .name = "ch-a", + .name = "ch-a", }, { - .name = "ch-b", + .name = "ch-b", }, {}, }; MODULE_DEVICE_TABLE (of, pmz_match); -static struct macio_driver pmz_driver = -{ +static struct macio_driver pmz_driver = { .name = "pmac_zilog", .match_table = pmz_match, .probe = pmz_attach, .remove = pmz_detach, .suspend = pmz_suspend, - .resume = pmz_resume, + .resume = pmz_resume, }; static int __init init_pmz(void) @@ -1952,7 +1949,7 @@ static int __init init_pmz(void) pmz_dispose_port(&pmz_ports[i]); return rc; } - + /* * Then we register the macio driver itself */ @@ -2034,7 +2031,7 @@ static int __init pmz_console_setup(struct console *co, char *options) if (of_machine_is_compatible("RackMac1,1") || of_machine_is_compatible("RackMac1,2") || of_machine_is_compatible("MacRISC4")) - baud = 57600; + baud = 57600; /* * Check whether an invalid uart number has been specified, and diff --git a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h index f6e77f12acd..f18c426324a 100644 --- a/drivers/serial/pmac_zilog.h +++ b/drivers/serial/pmac_zilog.h @@ -1,7 +1,7 @@ #ifndef __PMAC_ZILOG_H__ #define __PMAC_ZILOG_H__ -#define pmz_debug(fmt,arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg) +#define pmz_debug(fmt, arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg) /* * At most 2 ESCCs with 2 ports each @@ -113,7 +113,7 @@ static inline void zssync(struct uart_pmac_port *port) #define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2)) #define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2) -#define ZS_CLOCK 3686400 /* Z8530 RTxC input clock rate */ +#define ZS_CLOCK 3686400 /* Z8530 RTxC input clock rate */ /* The Zilog register set */ @@ -171,7 +171,7 @@ static inline void zssync(struct uart_pmac_port *port) /* Write Register 3 */ -#define RxENABLE 0x1 /* Rx Enable */ +#define RxENABLE 0x1 /* Rx Enable */ #define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */ #define ADD_SM 0x4 /* Address Search Mode (SDLC) */ #define RxCRC_ENAB 0x8 /* Rx CRC Enable */ @@ -185,7 +185,7 @@ static inline void zssync(struct uart_pmac_port *port) /* Write Register 4 */ -#define PAR_ENAB 0x1 /* Parity Enable */ +#define PAR_ENAB 0x1 /* Parity Enable */ #define PAR_EVEN 0x2 /* Parity Even/Odd* */ #define SYNC_ENAB 0 /* Sync Modes Enable */ @@ -210,7 +210,7 @@ static inline void zssync(struct uart_pmac_port *port) #define TxCRC_ENAB 0x1 /* Tx CRC Enable */ #define RTS 0x2 /* RTS */ #define SDLC_CRC 0x4 /* SDLC/CRC-16 */ -#define TxENABLE 0x8 /* Tx Enable */ +#define TxENABLE 0x8 /* Tx Enable */ #define SND_BRK 0x10 /* Send Break */ #define Tx5 0x0 /* Tx 5 bits (or less)/character */ #define Tx7 0x20 /* Tx 7 bits/character */ @@ -372,11 +372,11 @@ static inline void zssync(struct uart_pmac_port *port) #define ZS_TX_ACTIVE(UP) ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE) #define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS) #define ZS_IS_IRDA(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRDA) -#define ZS_IS_INTMODEM(UP) ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM) +#define ZS_IS_INTMODEM(UP) ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM) #define ZS_HAS_DMA(UP) ((UP)->flags & PMACZILOG_FLAG_HAS_DMA) -#define ZS_IS_ASLEEP(UP) ((UP)->flags & PMACZILOG_FLAG_IS_ASLEEP) -#define ZS_IS_OPEN(UP) ((UP)->flags & PMACZILOG_FLAG_IS_OPEN) -#define ZS_IS_IRQ_ON(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRQ_ON) -#define ZS_IS_EXTCLK(UP) ((UP)->flags & PMACZILOG_FLAG_IS_EXTCLK) +#define ZS_IS_ASLEEP(UP) ((UP)->flags & PMACZILOG_FLAG_IS_ASLEEP) +#define ZS_IS_OPEN(UP) ((UP)->flags & PMACZILOG_FLAG_IS_OPEN) +#define ZS_IS_IRQ_ON(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRQ_ON) +#define ZS_IS_EXTCLK(UP) ((UP)->flags & PMACZILOG_FLAG_IS_EXTCLK) #endif /* __PMAC_ZILOG_H__ */ -- cgit v1.2.3-70-g09d2 From ec9cbe09899e36b5f216c3232215520dcf0320ab Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Tue, 17 Nov 2009 20:04:44 +1100 Subject: pmac-zilog: add platform driver Add platform driver support to the pmac-zilog driver, for m68k macs. Place the powermac-specific code inside #ifdef CONFIG_PPC_PMAC. Signed-off-by: Finn Thain Acked-by: Benjamin Herrenschmidt Signed-off-by: Geert Uytterhoeven --- arch/m68k/configs/mac_defconfig | 5 ++ arch/m68k/configs/multi_defconfig | 5 ++ drivers/serial/Kconfig | 12 +-- drivers/serial/pmac_zilog.c | 155 +++++++++++++++++++++++++++++++++----- drivers/serial/pmac_zilog.h | 14 ++++ 5 files changed, 166 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig index 9991b64fea5..3cbbf880a9e 100644 --- a/arch/m68k/configs/mac_defconfig +++ b/arch/m68k/configs/mac_defconfig @@ -701,6 +701,11 @@ CONFIG_VT_HW_CONSOLE_BINDING=y # # Non-8250 serial port support # +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_PMACZILOG=y +CONFIG_SERIAL_PMACZILOG_TTYS=y +CONFIG_SERIAL_PMACZILOG_CONSOLE=y CONFIG_UNIX98_PTYS=y # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set CONFIG_LEGACY_PTYS=y diff --git a/arch/m68k/configs/multi_defconfig b/arch/m68k/configs/multi_defconfig index 69c43e2d8b4..8a2371933be 100644 --- a/arch/m68k/configs/multi_defconfig +++ b/arch/m68k/configs/multi_defconfig @@ -822,6 +822,11 @@ CONFIG_A2232=y # # Non-8250 serial port support # +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_PMACZILOG=y +CONFIG_SERIAL_PMACZILOG_TTYS=y +CONFIG_SERIAL_PMACZILOG_CONSOLE=y CONFIG_UNIX98_PTYS=y # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set CONFIG_LEGACY_PTYS=y diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 9ff47db0b2c..888a0ce91c4 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -1086,12 +1086,12 @@ config SERIAL_68360 default y config SERIAL_PMACZILOG - tristate "PowerMac z85c30 ESCC support" - depends on PPC_OF && PPC_PMAC + tristate "Mac or PowerMac z85c30 ESCC support" + depends on (M68K && MAC) || (PPC_OF && PPC_PMAC) select SERIAL_CORE help This driver supports the Zilog z85C30 serial ports found on - PowerMac machines. + (Power)Mac machines. Say Y or M if you want to be able to these serial ports. config SERIAL_PMACZILOG_TTYS @@ -1116,16 +1116,16 @@ config SERIAL_PMACZILOG_TTYS unable to use the 8250 module for PCMCIA or other 16C550-style UARTs. - Say N unless you need the z85c30 ports on your powermac + Say N unless you need the z85c30 ports on your (Power)Mac to appear as /dev/ttySn. config SERIAL_PMACZILOG_CONSOLE - bool "Console on PowerMac z85c30 serial port" + bool "Console on Mac or PowerMac z85c30 serial port" depends on SERIAL_PMACZILOG=y select SERIAL_CORE_CONSOLE help If you would like to be able to use the z85c30 serial port - on your PowerMac as the console, you can do so by answering + on your (Power)Mac as the console, you can do so by answering Y to this option. config SERIAL_LH7A40X diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c index 1c8afd98e14..f020de1cdd5 100644 --- a/drivers/serial/pmac_zilog.c +++ b/drivers/serial/pmac_zilog.c @@ -63,11 +63,17 @@ #include #include #include + +#ifdef CONFIG_PPC_PMAC #include #include #include #include #include +#else +#include +#define of_machine_is_compatible(x) (0) +#endif #if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) #define SUPPORT_SYSRQ @@ -83,11 +89,9 @@ static char version[] __initdata = "pmac_zilog: 0.6 (Benjamin Herrenschmidt )"; MODULE_AUTHOR("Benjamin Herrenschmidt "); -MODULE_DESCRIPTION("Driver for the PowerMac serial ports."); +MODULE_DESCRIPTION("Driver for the Mac and PowerMac serial ports."); MODULE_LICENSE("GPL"); -#define PWRDBG(fmt, arg...) printk(KERN_DEBUG fmt , ## arg) - #ifdef CONFIG_SERIAL_PMACZILOG_TTYS #define PMACZILOG_MAJOR TTY_MAJOR #define PMACZILOG_MINOR 64 @@ -341,7 +345,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) uap->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK); write_zsreg(uap, R1, uap->curregs[R1]); zssync(uap); - dev_err(&uap->dev->ofdev.dev, "pmz: rx irq flood !\n"); + pmz_error("pmz: rx irq flood !\n"); return tty; } @@ -757,6 +761,8 @@ static void pmz_break_ctl(struct uart_port *port, int break_state) spin_unlock_irqrestore(&port->lock, flags); } +#ifdef CONFIG_PPC_PMAC + /* * Turn power on or off to the SCC and associated stuff * (port drivers, modem, IR port, etc.) @@ -792,6 +798,15 @@ static int pmz_set_scc_power(struct uart_pmac_port *uap, int state) return delay; } +#else + +static int pmz_set_scc_power(struct uart_pmac_port *uap, int state) +{ + return 0; +} + +#endif /* !CONFIG_PPC_PMAC */ + /* * FixZeroBug....Works around a bug in the SCC receving channel. * Inspired from Darwin code, 15 Sept. 2000 -DanM @@ -954,9 +969,9 @@ static int pmz_startup(struct uart_port *port) } pmz_get_port_A(uap)->flags |= PMACZILOG_FLAG_IS_IRQ_ON; - if (request_irq(uap->port.irq, pmz_interrupt, IRQF_SHARED, "PowerMac Zilog", uap)) { - dev_err(&uap->dev->ofdev.dev, - "Unable to register zs interrupt handler.\n"); + if (request_irq(uap->port.irq, pmz_interrupt, IRQF_SHARED, + "SCC", uap)) { + pmz_error("Unable to register zs interrupt handler.\n"); pmz_set_scc_power(uap, 0); mutex_unlock(&pmz_irq_mutex); return -ENXIO; @@ -1196,7 +1211,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud) while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0 || (read_zsreg(uap, R1) & ALL_SNT) == 0) { if (--t <= 0) { - dev_err(&uap->dev->ofdev.dev, "transmitter didn't drain\n"); + pmz_error("transmitter didn't drain\n"); return; } udelay(10); @@ -1212,7 +1227,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud) read_zsdata(uap); mdelay(10); if (--t <= 0) { - dev_err(&uap->dev->ofdev.dev, "receiver didn't drain\n"); + pmz_error("receiver didn't drain\n"); return; } } @@ -1233,8 +1248,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud) t = 5000; while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) { if (--t <= 0) { - dev_err(&uap->dev->ofdev.dev, - "irda_setup timed out on get_version byte\n"); + pmz_error("irda_setup timed out on get_version byte\n"); goto out; } udelay(10); @@ -1242,8 +1256,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud) version = read_zsdata(uap); if (version < 4) { - dev_info(&uap->dev->ofdev.dev, "IrDA: dongle version %d not supported\n", - version); + pmz_info("IrDA: dongle version %d not supported\n", version); goto out; } @@ -1252,18 +1265,16 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud) t = 5000; while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) { if (--t <= 0) { - dev_err(&uap->dev->ofdev.dev, - "irda_setup timed out on speed mode byte\n"); + pmz_error("irda_setup timed out on speed mode byte\n"); goto out; } udelay(10); } t = read_zsdata(uap); if (t != cmdbyte) - dev_err(&uap->dev->ofdev.dev, - "irda_setup speed mode byte = %x (%x)\n", t, cmdbyte); + pmz_error("irda_setup speed mode byte = %x (%x)\n", t, cmdbyte); - dev_info(&uap->dev->ofdev.dev, "IrDA setup for %ld bps, dongle version: %d\n", + pmz_info("IrDA setup for %ld bps, dongle version: %d\n", *baud, version); (void)read_zsdata(uap); @@ -1413,7 +1424,7 @@ static void pmz_poll_put_char(struct uart_port *port, unsigned char c) write_zsdata(uap, c); } -#endif +#endif /* CONFIG_CONSOLE_POLL */ static struct uart_ops pmz_pops = { .tx_empty = pmz_tx_empty, @@ -1438,6 +1449,8 @@ static struct uart_ops pmz_pops = { #endif }; +#ifdef CONFIG_PPC_PMAC + /* * Setup one port structure after probing, HW is down at this point, * Unlike sunzilog, we don't need to pre-init the spinlock as we don't @@ -1834,6 +1847,88 @@ next: return 0; } +#else + +extern struct platform_device scc_a_pdev, scc_b_pdev; + +static int __init pmz_init_port(struct uart_pmac_port *uap) +{ + struct resource *r_ports; + int irq; + + r_ports = platform_get_resource(uap->node, IORESOURCE_MEM, 0); + irq = platform_get_irq(uap->node, 0); + if (!r_ports || !irq) + return -ENODEV; + + uap->port.mapbase = r_ports->start; + uap->port.membase = (unsigned char __iomem *) r_ports->start; + uap->port.iotype = UPIO_MEM; + uap->port.irq = irq; + uap->port.uartclk = ZS_CLOCK; + uap->port.fifosize = 1; + uap->port.ops = &pmz_pops; + uap->port.type = PORT_PMAC_ZILOG; + uap->port.flags = 0; + + uap->control_reg = uap->port.membase; + uap->data_reg = uap->control_reg + 4; + uap->port_type = 0; + + pmz_convert_to_zs(uap, CS8, 0, 9600); + + return 0; +} + +static int __init pmz_probe(void) +{ + int err; + + pmz_ports_count = 0; + + pmz_ports[0].mate = &pmz_ports[1]; + pmz_ports[0].port.line = 0; + pmz_ports[0].flags = PMACZILOG_FLAG_IS_CHANNEL_A; + pmz_ports[0].node = &scc_a_pdev; + err = pmz_init_port(&pmz_ports[0]); + if (err) + return err; + pmz_ports_count++; + + pmz_ports[1].mate = &pmz_ports[0]; + pmz_ports[1].port.line = 1; + pmz_ports[1].flags = 0; + pmz_ports[1].node = &scc_b_pdev; + err = pmz_init_port(&pmz_ports[1]); + if (err) + return err; + pmz_ports_count++; + + return 0; +} + +static void pmz_dispose_port(struct uart_pmac_port *uap) +{ + memset(uap, 0, sizeof(struct uart_pmac_port)); +} + +static int __init pmz_attach(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < pmz_ports_count; i++) + if (pmz_ports[i].node == pdev) + return 0; + return -ENODEV; +} + +static int __exit pmz_detach(struct platform_device *pdev) +{ + return 0; +} + +#endif /* !CONFIG_PPC_PMAC */ + #ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE static void pmz_console_write(struct console *con, const char *s, unsigned int count); @@ -1894,6 +1989,8 @@ err_out: return rc; } +#ifdef CONFIG_PPC_PMAC + static struct of_device_id pmz_match[] = { { @@ -1915,6 +2012,18 @@ static struct macio_driver pmz_driver = { .resume = pmz_resume, }; +#else + +static struct platform_driver pmz_driver = { + .remove = __exit_p(pmz_detach), + .driver = { + .name = "scc", + .owner = THIS_MODULE, + }, +}; + +#endif /* !CONFIG_PPC_PMAC */ + static int __init init_pmz(void) { int rc, i; @@ -1953,15 +2062,23 @@ static int __init init_pmz(void) /* * Then we register the macio driver itself */ +#ifdef CONFIG_PPC_PMAC return macio_register_driver(&pmz_driver); +#else + return platform_driver_probe(&pmz_driver, pmz_attach); +#endif } static void __exit exit_pmz(void) { int i; +#ifdef CONFIG_PPC_PMAC /* Get rid of macio-driver (detach from macio) */ macio_unregister_driver(&pmz_driver); +#else + platform_driver_unregister(&pmz_driver); +#endif for (i = 0; i < pmz_ports_count; i++) { struct uart_pmac_port *uport = &pmz_ports[i]; diff --git a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h index f18c426324a..cbc34fbb1b2 100644 --- a/drivers/serial/pmac_zilog.h +++ b/drivers/serial/pmac_zilog.h @@ -1,7 +1,15 @@ #ifndef __PMAC_ZILOG_H__ #define __PMAC_ZILOG_H__ +#ifdef CONFIG_PPC_PMAC #define pmz_debug(fmt, arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg) +#define pmz_error(fmt, arg...) dev_err(&uap->dev->ofdev.dev, fmt, ## arg) +#define pmz_info(fmt, arg...) dev_info(&uap->dev->ofdev.dev, fmt, ## arg) +#else +#define pmz_debug(fmt, arg...) dev_dbg(&uap->node->dev, fmt, ## arg) +#define pmz_error(fmt, arg...) dev_err(&uap->node->dev, fmt, ## arg) +#define pmz_info(fmt, arg...) dev_info(&uap->node->dev, fmt, ## arg) +#endif /* * At most 2 ESCCs with 2 ports each @@ -17,6 +25,7 @@ struct uart_pmac_port { struct uart_port port; struct uart_pmac_port *mate; +#ifdef CONFIG_PPC_PMAC /* macio_dev for the escc holding this port (maybe be null on * early inited port) */ @@ -25,6 +34,9 @@ struct uart_pmac_port { * of "escc" node (ie. ch-a or ch-b) */ struct device_node *node; +#else + struct platform_device *node; +#endif /* Port type as obtained from device tree (IRDA, modem, ...) */ int port_type; @@ -55,10 +67,12 @@ struct uart_pmac_port { volatile u8 __iomem *control_reg; volatile u8 __iomem *data_reg; +#ifdef CONFIG_PPC_PMAC unsigned int tx_dma_irq; unsigned int rx_dma_irq; volatile struct dbdma_regs __iomem *tx_dma_regs; volatile struct dbdma_regs __iomem *rx_dma_regs; +#endif struct ktermios termios_cache; }; -- cgit v1.2.3-70-g09d2 From cff75f1fb1f28eba3facb7dbe9b40a892912578a Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:41:35 +1100 Subject: mac68k: move mac_esp platform device Move platform device code from the driver to the platform init function. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/config.c | 27 ++++++++++++++++++++++++ drivers/scsi/mac_esp.c | 57 +++++--------------------------------------------- 2 files changed, 32 insertions(+), 52 deletions(-) (limited to 'drivers') diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index c8a4c39cef5..91245ade229 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -911,6 +911,16 @@ static struct platform_device swim_pdev = { .resource = &swim_rsrc, }; +static struct platform_device esp_0_pdev = { + .name = "mac_esp", + .id = 0, +}; + +static struct platform_device esp_1_pdev = { + .name = "mac_esp", + .id = 1, +}; + int __init mac_platform_init(void) { u8 *swim_base; @@ -944,6 +954,23 @@ int __init mac_platform_init(void) platform_device_register(&swim_pdev); } + /* + * SCSI device(s) + */ + + switch (macintosh_config->scsi_type) { + case MAC_SCSI_QUADRA: + case MAC_SCSI_QUADRA3: + platform_device_register(&esp_0_pdev); + break; + case MAC_SCSI_QUADRA2: + platform_device_register(&esp_0_pdev); + if ((macintosh_config->ident == MAC_MODEL_Q900) || + (macintosh_config->ident == MAC_MODEL_Q950)) + platform_device_register(&esp_1_pdev); + break; + } + return 0; } diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c index dd808ae942a..4a90eaf7cb6 100644 --- a/drivers/scsi/mac_esp.c +++ b/drivers/scsi/mac_esp.c @@ -52,7 +52,6 @@ struct mac_esp_priv { void __iomem *pdma_io; int error; }; -static struct platform_device *internal_pdev, *external_pdev; static struct esp *esp_chips[2]; #define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \ @@ -495,29 +494,12 @@ static int __devinit esp_mac_probe(struct platform_device *dev) struct Scsi_Host *host; struct esp *esp; int err; - int chips_present; struct mac_esp_priv *mep; if (!MACH_IS_MAC) return -ENODEV; - switch (macintosh_config->scsi_type) { - case MAC_SCSI_QUADRA: - case MAC_SCSI_QUADRA3: - chips_present = 1; - break; - case MAC_SCSI_QUADRA2: - if ((macintosh_config->ident == MAC_MODEL_Q900) || - (macintosh_config->ident == MAC_MODEL_Q950)) - chips_present = 2; - else - chips_present = 1; - break; - default: - chips_present = 0; - } - - if (dev->id + 1 > chips_present) + if (dev->id > 1) return -ENODEV; host = scsi_host_alloc(tpnt, sizeof(struct esp)); @@ -642,55 +624,26 @@ static struct platform_driver esp_mac_driver = { .probe = esp_mac_probe, .remove = __devexit_p(esp_mac_remove), .driver = { - .name = DRV_MODULE_NAME, + .name = DRV_MODULE_NAME, + .owner = THIS_MODULE, }, }; static int __init mac_esp_init(void) { - int err; - - err = platform_driver_register(&esp_mac_driver); - if (err) - return err; - - internal_pdev = platform_device_alloc(DRV_MODULE_NAME, 0); - if (internal_pdev && platform_device_add(internal_pdev)) { - platform_device_put(internal_pdev); - internal_pdev = NULL; - } - external_pdev = platform_device_alloc(DRV_MODULE_NAME, 1); - if (external_pdev && platform_device_add(external_pdev)) { - platform_device_put(external_pdev); - external_pdev = NULL; - } - - if (internal_pdev || external_pdev) { - return 0; - } else { - platform_driver_unregister(&esp_mac_driver); - return -ENOMEM; - } + return platform_driver_register(&esp_mac_driver); } static void __exit mac_esp_exit(void) { platform_driver_unregister(&esp_mac_driver); - - if (internal_pdev) { - platform_device_unregister(internal_pdev); - internal_pdev = NULL; - } - if (external_pdev) { - platform_device_unregister(external_pdev); - external_pdev = NULL; - } } MODULE_DESCRIPTION("Mac ESP SCSI driver"); MODULE_AUTHOR("Finn Thain "); MODULE_LICENSE("GPL v2"); MODULE_VERSION(DRV_VERSION); +MODULE_ALIAS("platform:" DRV_MODULE_NAME); module_init(mac_esp_init); module_exit(mac_esp_exit); -- cgit v1.2.3-70-g09d2 From eeb9c182a6ad8bc130377adb0a4cd7b95dd15f49 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:42:02 +1100 Subject: mac68k: move macsonic and macmace platform devices Move platform device code from the drivers to the platform init function. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/config.c | 23 +++++++++++++++++++++++ drivers/net/macmace.c | 33 ++++----------------------------- drivers/net/macsonic.c | 33 ++++----------------------------- 3 files changed, 31 insertions(+), 58 deletions(-) (limited to 'drivers') diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 91245ade229..816452b3e50 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -921,6 +921,16 @@ static struct platform_device esp_1_pdev = { .id = 1, }; +static struct platform_device sonic_pdev = { + .name = "macsonic", + .id = -1, +}; + +static struct platform_device mace_pdev = { + .name = "macmace", + .id = -1, +}; + int __init mac_platform_init(void) { u8 *swim_base; @@ -971,6 +981,19 @@ int __init mac_platform_init(void) break; } + /* + * Ethernet device + */ + + switch (macintosh_config->ether_type) { + case MAC_ETHER_SONIC: + platform_device_register(&sonic_pdev); + break; + case MAC_ETHER_MACE: + platform_device_register(&mace_pdev); + break; + } + return 0; } diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c index 44f3c2896f2..79408c37787 100644 --- a/drivers/net/macmace.c +++ b/drivers/net/macmace.c @@ -39,7 +39,6 @@ #include "mace.h" static char mac_mace_string[] = "macmace"; -static struct platform_device *mac_mace_device; #define N_TX_BUFF_ORDER 0 #define N_TX_RING (1 << N_TX_BUFF_ORDER) @@ -752,6 +751,7 @@ static irqreturn_t mace_dma_intr(int irq, void *dev_id) MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Macintosh MACE ethernet driver"); +MODULE_ALIAS("platform:macmace"); static int __devexit mac_mace_device_remove (struct platform_device *pdev) { @@ -777,47 +777,22 @@ static struct platform_driver mac_mace_driver = { .probe = mace_probe, .remove = __devexit_p(mac_mace_device_remove), .driver = { - .name = mac_mace_string, + .name = mac_mace_string, + .owner = THIS_MODULE, }, }; static int __init mac_mace_init_module(void) { - int err; - if (!MACH_IS_MAC) return -ENODEV; - if ((err = platform_driver_register(&mac_mace_driver))) { - printk(KERN_ERR "Driver registration failed\n"); - return err; - } - - mac_mace_device = platform_device_alloc(mac_mace_string, 0); - if (!mac_mace_device) - goto out_unregister; - - if (platform_device_add(mac_mace_device)) { - platform_device_put(mac_mace_device); - mac_mace_device = NULL; - } - - return 0; - -out_unregister: - platform_driver_unregister(&mac_mace_driver); - - return -ENOMEM; + return platform_driver_register(&mac_mace_driver); } static void __exit mac_mace_cleanup_module(void) { platform_driver_unregister(&mac_mace_driver); - - if (mac_mace_device) { - platform_device_unregister(mac_mace_device); - mac_mace_device = NULL; - } } module_init(mac_mace_init_module); diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c index 875d361fb79..24109c28810 100644 --- a/drivers/net/macsonic.c +++ b/drivers/net/macsonic.c @@ -62,7 +62,6 @@ #include static char mac_sonic_string[] = "macsonic"; -static struct platform_device *mac_sonic_device; #include "sonic.h" @@ -607,6 +606,7 @@ out: MODULE_DESCRIPTION("Macintosh SONIC ethernet driver"); module_param(sonic_debug, int, 0); MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); +MODULE_ALIAS("platform:macsonic"); #include "sonic.c" @@ -627,44 +627,19 @@ static struct platform_driver mac_sonic_driver = { .probe = mac_sonic_probe, .remove = __devexit_p(mac_sonic_device_remove), .driver = { - .name = mac_sonic_string, + .name = mac_sonic_string, + .owner = THIS_MODULE, }, }; static int __init mac_sonic_init_module(void) { - int err; - - if ((err = platform_driver_register(&mac_sonic_driver))) { - printk(KERN_ERR "Driver registration failed\n"); - return err; - } - - mac_sonic_device = platform_device_alloc(mac_sonic_string, 0); - if (!mac_sonic_device) - goto out_unregister; - - if (platform_device_add(mac_sonic_device)) { - platform_device_put(mac_sonic_device); - mac_sonic_device = NULL; - } - - return 0; - -out_unregister: - platform_driver_unregister(&mac_sonic_driver); - - return -ENOMEM; + return platform_driver_register(&mac_sonic_driver); } static void __exit mac_sonic_cleanup_module(void) { platform_driver_unregister(&mac_sonic_driver); - - if (mac_sonic_device) { - platform_device_unregister(mac_sonic_device); - mac_sonic_device = NULL; - } } module_init(mac_sonic_init_module); -- cgit v1.2.3-70-g09d2 From d876c11a0fd40993136f5cc1e81371ccc6c21a63 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:43:16 +1100 Subject: fbdev: mac_var_to_mode() fix The valkyriefb driver assumes that this logic holds: mac_vmode_to_var(X, cmode, &var); mac_var_to_vmode(&var, &vmode, &cmode); assert(vmode == X); But it doesn't hold because mac_var_to_vmode() can return a mode with a slower pixel clock, even when a match is available. So we end up with this failure: using video mode 11 and color mode 0. valkyriefb: vmode 12 not valid. valkyriefb: can't set default video mode valkyriefb: vmode 12 not valid. Rather than have mac_var_to_mode() return the first reasonable mode it finds, have it return the mode that is closest to the requested one (or the mode with the closest longer pixel clock period if there is no exact match). Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macmodes.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c index 083f60321ed..3e11f7425ae 100644 --- a/drivers/video/macmodes.c +++ b/drivers/video/macmodes.c @@ -134,7 +134,7 @@ static const struct fb_videomode mac_modedb[] = { * * These MUST be ordered in * - increasing resolution - * - decreasing refresh rate + * - decreasing pixel clock period */ static const struct mode_map { @@ -142,20 +142,20 @@ static const struct mode_map { const struct fb_videomode *mode; } mac_modes[] = { /* 640x480 */ - { VMODE_640_480_67, &mac_modedb[1] }, { VMODE_640_480_60, &mac_modedb[0] }, + { VMODE_640_480_67, &mac_modedb[1] }, /* 800x600 */ + { VMODE_800_600_56, &mac_modedb[2] }, + { VMODE_800_600_60, &mac_modedb[3] }, { VMODE_800_600_75, &mac_modedb[5] }, { VMODE_800_600_72, &mac_modedb[4] }, - { VMODE_800_600_60, &mac_modedb[3] }, - { VMODE_800_600_56, &mac_modedb[2] }, /* 832x624 */ { VMODE_832_624_75, &mac_modedb[6] }, /* 1024x768 */ - { VMODE_1024_768_75, &mac_modedb[10] }, - { VMODE_1024_768_75V, &mac_modedb[9] }, - { VMODE_1024_768_70, &mac_modedb[8] }, { VMODE_1024_768_60, &mac_modedb[7] }, + { VMODE_1024_768_70, &mac_modedb[8] }, + { VMODE_1024_768_75V, &mac_modedb[9] }, + { VMODE_1024_768_75, &mac_modedb[10] }, /* 1152x768 */ { VMODE_1152_768_60, &mac_modedb[14] }, /* 1152x870 */ @@ -299,7 +299,6 @@ EXPORT_SYMBOL(mac_vmode_to_var); int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, int *cmode) { - const struct fb_videomode *mode = NULL; const struct mode_map *map; if (var->bits_per_pixel <= 8) @@ -311,8 +310,13 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, else return -EINVAL; + /* + * Find the mac_mode with a matching resolution or failing that, the + * closest larger resolution. Skip modes with a shorter pixel clock period. + */ for (map = mac_modes; map->vmode != -1; map++) { - mode = map->mode; + const struct fb_videomode *mode = map->mode; + if (var->xres > mode->xres || var->yres > mode->yres) continue; if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres) @@ -322,6 +326,24 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, if ((var->vmode & FB_VMODE_MASK) != mode->vmode) continue; *vmode = map->vmode; + + /* + * Having found a good resolution, find the matching pixel clock + * or failing that, the closest longer pixel clock period. + */ + map++; + while (map->vmode != -1) { + const struct fb_videomode *clk_mode = map->mode; + + if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres) + break; + if (var->pixclock > mode->pixclock) + break; + if (mode->vmode != clk_mode->vmode) + continue; + *vmode = map->vmode; + map++; + } return 0; } return -EINVAL; -- cgit v1.2.3-70-g09d2 From 11e8faca2e501c25d2f98c1b9534776a9a9704c5 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:43:52 +1100 Subject: valkyriefb: various fixes Valkyriefb and macfb will adopt the same card if they get the chance, so remove valkyrie support from macfb. Also fix the "valkyriefb: can't do 832x624x8" problem reported by Raylynn Knight some time ago, by adding vmode 13 support for CONFIG_MAC. Also add vmode 11 since that works too. Make use of the monitor sense lines on 68k Macs too. Also some cleanups. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macfb.c | 53 ++++------------------------------------------ drivers/video/valkyriefb.c | 6 +++--- drivers/video/valkyriefb.h | 31 +++++++++------------------ 3 files changed, 17 insertions(+), 73 deletions(-) (limited to 'drivers') diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index d66887e8cbb..a92322558ec 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -55,9 +55,6 @@ static int (*macfb_setpalette) (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) = NULL; -static int valkyrie_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info); static int dafb_setpalette (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *fb_info); @@ -77,13 +74,6 @@ static int csc_setpalette (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *fb_info); -static struct { - unsigned char addr; - /* Note: word-aligned */ - char pad[3]; - unsigned char lut; -} __iomem *valkyrie_cmap_regs; - static struct { unsigned char addr; unsigned char lut; @@ -172,33 +162,6 @@ static u32 pseudo_palette[16]; static int inverse = 0; static int vidtest = 0; -static int valkyrie_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) -{ - unsigned long flags; - - red >>= 8; - green >>= 8; - blue >>= 8; - - local_irq_save(flags); - - /* tell clut which address to fill */ - nubus_writeb(regno, &valkyrie_cmap_regs->addr); - nop(); - - /* send one color channel at a time */ - nubus_writeb(red, &valkyrie_cmap_regs->lut); - nop(); - nubus_writeb(green, &valkyrie_cmap_regs->lut); - nop(); - nubus_writeb(blue, &valkyrie_cmap_regs->lut); - - local_irq_restore(flags); - return 0; -} - /* Unlike the Valkyrie, the DAFB cannot set individual colormap registers. Therefore, we do what the MacOS driver does (no kidding!) and simply set them one by one until we hit the one we @@ -614,8 +577,6 @@ static void __init macfb_setup(char *options) static void __init iounmap_macfb(void) { - if (valkyrie_cmap_regs) - iounmap(valkyrie_cmap_regs); if (dafb_cmap_regs) iounmap(dafb_cmap_regs); if (v8_brazil_cmap_regs) @@ -642,6 +603,10 @@ static int __init macfb_init(void) if (!MACH_IS_MAC) return -ENODEV; + if (mac_bi_data.id == MAC_MODEL_Q630 || + mac_bi_data.id == MAC_MODEL_P588) + return -ENODEV; /* See valkyriefb.c */ + /* There can only be one internal video controller anyway so we're not too worried about this */ macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF; @@ -784,16 +749,6 @@ static int __init macfb_init(void) if (!video_is_nubus) switch( mac_bi_data.id ) { - /* Valkyrie Quadras */ - case MAC_MODEL_Q630: - /* I'm not sure about this one */ - case MAC_MODEL_P588: - strcpy(macfb_fix.id, "Valkyrie"); - macfb_setpalette = valkyrie_setpalette; - macfb_defined.activate = FB_ACTIVATE_NOW; - valkyrie_cmap_regs = ioremap(DAC_BASE, 0x1000); - break; - /* DAFB Quadras */ /* Note: these first four have the v7 DAFB, which is known to be rather unlike the ones used in the diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c index 4bb9a0b1895..6b52bf65f0b 100644 --- a/drivers/video/valkyriefb.c +++ b/drivers/video/valkyriefb.c @@ -69,7 +69,7 @@ #ifdef CONFIG_MAC /* We don't yet have functions to read the PRAM... perhaps we can adapt them from the PPC code? */ -static int default_vmode = VMODE_640_480_67; +static int default_vmode = VMODE_CHOOSE; static int default_cmode = CMODE_8; #else static int default_vmode = VMODE_NVRAM; @@ -326,11 +326,11 @@ int __init valkyriefb_init(void) #ifdef CONFIG_MAC if (!MACH_IS_MAC) - return 0; + return -ENODEV; if (!(mac_bi_data.id == MAC_MODEL_Q630 /* I'm not sure about this one */ || mac_bi_data.id == MAC_MODEL_P588)) - return 0; + return -ENODEV; /* Hardcoded addresses... welcome to 68k Macintosh country :-) */ frame_buffer_phys = 0xf9000000; diff --git a/drivers/video/valkyriefb.h b/drivers/video/valkyriefb.h index 97aaf7bb641..d787441e5a4 100644 --- a/drivers/video/valkyriefb.h +++ b/drivers/video/valkyriefb.h @@ -134,15 +134,7 @@ static struct valkyrie_regvals valkyrie_reg_init_14 = { { 1024, 0 }, 1024, 768 }; - -/* Register values for 800x600, 72Hz mode (11) */ -static struct valkyrie_regvals valkyrie_reg_init_11 = { - 13, - { 17, 27, 3 }, /* pixel clock = 49.63MHz for V=71.66Hz */ - { 800, 0 }, - 800, 600 -}; -#endif /* CONFIG_MAC */ +#endif /* !defined CONFIG_MAC */ /* Register values for 832x624, 75Hz mode (13) */ static struct valkyrie_regvals valkyrie_reg_init_13 = { @@ -152,6 +144,14 @@ static struct valkyrie_regvals valkyrie_reg_init_13 = { 832, 624 }; +/* Register values for 800x600, 72Hz mode (11) */ +static struct valkyrie_regvals valkyrie_reg_init_11 = { + 13, + { 17, 27, 3 }, /* pixel clock = 49.63MHz for V=71.66Hz */ + { 800, 0 }, + 800, 600 +}; + /* Register values for 800x600, 60Hz mode (10) */ static struct valkyrie_regvals valkyrie_reg_init_10 = { 12, @@ -188,24 +188,13 @@ static struct valkyrie_regvals *valkyrie_reg_init[VMODE_MAX] = { NULL, NULL, &valkyrie_reg_init_10, -#ifdef CONFIG_MAC - NULL, - NULL, - &valkyrie_reg_init_13, - NULL, - NULL, - NULL, - NULL, -#else &valkyrie_reg_init_11, NULL, &valkyrie_reg_init_13, +#ifndef CONFIG_MAC &valkyrie_reg_init_14, &valkyrie_reg_init_15, NULL, &valkyrie_reg_init_17, #endif - NULL, - NULL, - NULL }; -- cgit v1.2.3-70-g09d2 From 18814ee846357509ceb13d4351eec71acd007480 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Tue, 17 Nov 2009 20:03:05 +1100 Subject: mac68k: start CUDA early The valkyriefb driver needs the CUDA to work in order to set the video mode at boot. So initialise the device earlier, and bring the m68k code closer to the powermac code. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/config.c | 6 ++++ drivers/macintosh/adb.c | 6 ++-- drivers/macintosh/via-cuda.c | 74 ++++++++++++++++++++++++-------------------- 3 files changed, 51 insertions(+), 35 deletions(-) (limited to 'drivers') diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 816452b3e50..0356da9bf76 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #define BOOTINFO_COMPAT_1_0 #include @@ -889,6 +891,10 @@ static void __init mac_identify(void) oss_init(); psc_init(); baboon_init(); + +#ifdef CONFIG_ADB_CUDA + find_via_cuda(); +#endif } static void __init mac_report_hardware(void) diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index d840a109f83..1c4ee6e7793 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -317,9 +317,11 @@ static int __init adb_init(void) break; } } - if ((adb_controller == NULL) || adb_controller->init()) { - printk(KERN_WARNING "Warning: no ADB interface detected\n"); + if (adb_controller != NULL && adb_controller->init && + adb_controller->init()) adb_controller = NULL; + if (adb_controller == NULL) { + printk(KERN_WARNING "Warning: no ADB interface detected\n"); } else { #ifdef CONFIG_PPC if (of_machine_is_compatible("AAPL,PowerBook1998") || diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c index 62dd1fdafec..971bc9582a5 100644 --- a/drivers/macintosh/via-cuda.c +++ b/drivers/macintosh/via-cuda.c @@ -89,7 +89,6 @@ static int cuda_fully_inited; #ifdef CONFIG_ADB static int cuda_probe(void); -static int cuda_init(void); static int cuda_send_request(struct adb_request *req, int sync); static int cuda_adb_autopoll(int devs); static int cuda_reset_adb_bus(void); @@ -107,17 +106,42 @@ int cuda_request(struct adb_request *req, #ifdef CONFIG_ADB struct adb_driver via_cuda_driver = { - "CUDA", - cuda_probe, - cuda_init, - cuda_send_request, - cuda_adb_autopoll, - cuda_poll, - cuda_reset_adb_bus + .name = "CUDA", + .probe = cuda_probe, + .send_request = cuda_send_request, + .autopoll = cuda_adb_autopoll, + .poll = cuda_poll, + .reset_bus = cuda_reset_adb_bus, }; #endif /* CONFIG_ADB */ -#ifdef CONFIG_PPC +#ifdef CONFIG_MAC +int __init find_via_cuda(void) +{ + struct adb_request req; + int err; + + if (macintosh_config->adb_type != MAC_ADB_CUDA) + return 0; + + via = via1; + cuda_state = idle; + + err = cuda_init_via(); + if (err) { + printk(KERN_ERR "cuda_init_via() failed\n"); + via = NULL; + return 0; + } + + /* enable autopoll */ + cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1); + while (!req.complete) + cuda_poll(); + + return 1; +} +#else int __init find_via_cuda(void) { struct adb_request req; @@ -175,7 +199,7 @@ int __init find_via_cuda(void) vias = NULL; return 0; } -#endif /* CONFIG_PPC */ +#endif /* !defined CONFIG_MAC */ static int __init via_cuda_start(void) { @@ -184,14 +208,14 @@ static int __init via_cuda_start(void) #ifdef CONFIG_MAC cuda_irq = IRQ_MAC_ADB; -#else /* CONFIG_MAC */ +#else cuda_irq = irq_of_parse_and_map(vias, 0); if (cuda_irq == NO_IRQ) { printk(KERN_ERR "via-cuda: can't map interrupts for %s\n", vias->full_name); return -ENODEV; } -#endif /* CONFIG_MAC */ +#endif if (request_irq(cuda_irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) { printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq); @@ -216,28 +240,10 @@ cuda_probe(void) #else if (macintosh_config->adb_type != MAC_ADB_CUDA) return -ENODEV; - via = via1; #endif - return 0; -} - -static int __init -cuda_init(void) -{ -#ifdef CONFIG_PPC if (via == NULL) return -ENODEV; return 0; -#else - int err = cuda_init_via(); - if (err) { - printk(KERN_ERR "cuda_init_via() failed\n"); - return -ENODEV; - } - out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */ - - return via_cuda_start(); -#endif } #endif /* CONFIG_ADB */ @@ -430,9 +436,11 @@ cuda_poll(void) /* cuda_interrupt only takes a normal lock, we disable * interrupts here to avoid re-entering and thus deadlocking. */ - disable_irq(cuda_irq); + if (cuda_irq) + disable_irq(cuda_irq); cuda_interrupt(0, NULL); - enable_irq(cuda_irq); + if (cuda_irq) + enable_irq(cuda_irq); } static irqreturn_t @@ -446,7 +454,7 @@ cuda_interrupt(int irq, void *arg) spin_lock(&cuda_lock); - /* On powermacs, this handler is registered for the VIA IRQ. But it uses + /* On powermacs, this handler is registered for the VIA IRQ. But they use * just the shift register IRQ -- other VIA interrupt sources are disabled. * On m68k macs, the VIA IRQ sources are dispatched individually. Unless * we are polling, the shift register IRQ flag has already been cleared. -- cgit v1.2.3-70-g09d2 From 1bb63845d122750124807e5aeb733d2276e5fb7d Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:47:02 +1100 Subject: fbdev: add some missing mac modes Add the missing mac video modes for the Portrait and 12" RGB displays. The specs come from the Mac LC III developer note. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macmodes.c | 52 ++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c index 3e11f7425ae..af86c081d2b 100644 --- a/drivers/video/macmodes.c +++ b/drivers/video/macmodes.c @@ -33,6 +33,10 @@ static const struct fb_videomode mac_modedb[] = { { + /* 512x384, 60Hz, Non-Interlaced (15.67 MHz dot clock) */ + "mac2", 60, 512, 384, 63828, 80, 16, 19, 1, 32, 3, + 0, FB_VMODE_NONINTERLACED + }, { /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */ "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2, 0, FB_VMODE_NONINTERLACED @@ -40,6 +44,10 @@ static const struct fb_videomode mac_modedb[] = { /* 640x480, 67Hz, Non-Interlaced (30.0 MHz dotclock) */ "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3, 0, FB_VMODE_NONINTERLACED + }, { + /* 640x870, 75Hz (portrait), Non-Interlaced (57.28 MHz dot clock) */ + "mac7", 75, 640, 870, 17457, 80, 32, 42, 3, 80, 3, + 0, FB_VMODE_NONINTERLACED }, { /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */ "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2, @@ -104,10 +112,6 @@ static const struct fb_videomode mac_modedb[] = { /* VMODE_512_384_60I: 512x384, 60Hz, Interlaced (NTSC) */ "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED - }, { - /* VMODE_512_384_60: 512x384, 60Hz, Non-Interlaced */ - "mac2", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, - sync, FB_VMODE_NONINTERLACED }, { /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */ "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, @@ -116,10 +120,6 @@ static const struct fb_videomode mac_modedb[] = { /* VMODE_640_480_60I: 640x480, 60Hz, Interlaced (NTSC) */ "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED - }, { - /* VMODE_640_870_75P: 640x870, 75Hz (portrait), Non-Interlaced */ - "mac7", 75, 640, 870, pixclock, left, right, upper, lower, hslen, vslen, - sync, FB_VMODE_NONINTERLACED }, { /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */ "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen, @@ -141,31 +141,35 @@ static const struct mode_map { int vmode; const struct fb_videomode *mode; } mac_modes[] = { + /* 512x384 */ + { VMODE_512_384_60, &mac_modedb[0] }, /* 640x480 */ - { VMODE_640_480_60, &mac_modedb[0] }, - { VMODE_640_480_67, &mac_modedb[1] }, + { VMODE_640_480_60, &mac_modedb[1] }, + { VMODE_640_480_67, &mac_modedb[2] }, + /* 640x870 */ + { VMODE_640_870_75P, &mac_modedb[3] }, /* 800x600 */ - { VMODE_800_600_56, &mac_modedb[2] }, - { VMODE_800_600_60, &mac_modedb[3] }, - { VMODE_800_600_75, &mac_modedb[5] }, - { VMODE_800_600_72, &mac_modedb[4] }, + { VMODE_800_600_56, &mac_modedb[4] }, + { VMODE_800_600_60, &mac_modedb[5] }, + { VMODE_800_600_75, &mac_modedb[7] }, + { VMODE_800_600_72, &mac_modedb[6] }, /* 832x624 */ - { VMODE_832_624_75, &mac_modedb[6] }, + { VMODE_832_624_75, &mac_modedb[8] }, /* 1024x768 */ - { VMODE_1024_768_60, &mac_modedb[7] }, - { VMODE_1024_768_70, &mac_modedb[8] }, - { VMODE_1024_768_75V, &mac_modedb[9] }, - { VMODE_1024_768_75, &mac_modedb[10] }, + { VMODE_1024_768_60, &mac_modedb[9] }, + { VMODE_1024_768_70, &mac_modedb[10] }, + { VMODE_1024_768_75V, &mac_modedb[11] }, + { VMODE_1024_768_75, &mac_modedb[12] }, /* 1152x768 */ - { VMODE_1152_768_60, &mac_modedb[14] }, + { VMODE_1152_768_60, &mac_modedb[16] }, /* 1152x870 */ - { VMODE_1152_870_75, &mac_modedb[11] }, + { VMODE_1152_870_75, &mac_modedb[13] }, /* 1280x960 */ - { VMODE_1280_960_75, &mac_modedb[12] }, + { VMODE_1280_960_75, &mac_modedb[14] }, /* 1280x1024 */ - { VMODE_1280_1024_75, &mac_modedb[13] }, + { VMODE_1280_1024_75, &mac_modedb[15] }, /* 1600x1024 */ - { VMODE_1600_1024_60, &mac_modedb[15] }, + { VMODE_1600_1024_60, &mac_modedb[17] }, { -1, NULL } }; -- cgit v1.2.3-70-g09d2 From 34c41d0ab8c2a96bb3db89a209c1dd7e8c44fe13 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:47:28 +1100 Subject: macfb: cleanup Cleanup whitespace and code style. Remove unused #includes and prototypes. Remove obsolete, redundant or misleading comments. Remove dead code and redundant initialisers. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macfb.c | 577 ++++++++++++++++++++++++++------------------------ 1 file changed, 295 insertions(+), 282 deletions(-) (limited to 'drivers') diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index a92322558ec..8b246ee7c06 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -1,29 +1,33 @@ -/* macfb.c: Generic framebuffer for Macs whose colourmaps/modes we - don't know how to set */ - -/* (c) 1999 David Huggins-Daines - - Primarily based on vesafb.c, by Gerd Knorr - (c) 1998 Gerd Knorr - - Also uses information and code from: - - The original macfb.c from Linux/mac68k 2.0, by Alan Cox, Juergen - Mellinger, Mikael Forselius, Michael Schmitz, and others. - - valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan - Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven. - - This code is free software. You may copy, modify, and distribute - it subject to the terms and conditions of the GNU General Public - License, version 2, or any later version, at your convenience. */ +/* + * macfb.c: Generic framebuffer for Macs whose colourmaps/modes we + * don't know how to set. + * + * (c) 1999 David Huggins-Daines + * + * Primarily based on vesafb.c, by Gerd Knorr + * (c) 1998 Gerd Knorr + * + * Also uses information and code from: + * + * The original macfb.c from Linux/mac68k 2.0, by Alan Cox, Juergen + * Mellinger, Mikael Forselius, Michael Schmitz, and others. + * + * valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan + * Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven. + * + * The VideoToolbox "Bugs" web page at + * http://rajsky.psych.nyu.edu/Tips/VideoBugs.html + * + * This code is free software. You may copy, modify, and distribute + * it subject to the terms and conditions of the GNU General Public + * License, version 2, or any later version, at your convenience. + */ #include #include #include #include #include -#include #include #include #include @@ -31,9 +35,6 @@ #include #include -#include -#include -#include #include #include @@ -44,7 +45,7 @@ #define DAFB_BASE 0xf9800200 /* Address for the built-in Civic framebuffer in Quadra AVs */ -#define CIVIC_BASE 0x50f30800 /* Only tested on 660AV! */ +#define CIVIC_BASE 0x50f30800 /* GSC (Gray Scale Controller) base address */ #define GSC_BASE 0x50F20000 @@ -52,27 +53,9 @@ /* CSC (Color Screen Controller) base address */ #define CSC_BASE 0x50F20000 -static int (*macfb_setpalette) (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) = NULL; -static int dafb_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *fb_info); -static int rbv_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *fb_info); -static int mdc_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *fb_info); -static int toby_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *fb_info); -static int civic_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *fb_info); -static int csc_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *fb_info); +static int (*macfb_setpalette)(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info); static struct { unsigned char addr; @@ -106,15 +89,15 @@ static struct { } __iomem *civic_cmap_regs; static struct { - char pad1[0x40]; - unsigned char clut_waddr; /* 0x40 */ - char pad2; - unsigned char clut_data; /* 0x42 */ - char pad3[0x3]; - unsigned char clut_raddr; /* 0x46 */ + char pad1[0x40]; + unsigned char clut_waddr; /* 0x40 */ + char pad2; + unsigned char clut_data; /* 0x42 */ + char pad3[0x3]; + unsigned char clut_raddr; /* 0x46 */ } __iomem *csc_cmap_regs; -/* We will leave these the way they are for the time being */ +/* The registers in these structs are in NuBus slot space */ struct mdc_cmap_regs { char pad1[0x200200]; unsigned char addr; @@ -135,13 +118,12 @@ struct jet_cmap_regs { unsigned char lut; }; -#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ +#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ -/* mode */ static int video_slot = 0; static struct fb_var_screeninfo macfb_defined = { - .bits_per_pixel = 8, + .bits_per_pixel = 8, .activate = FB_ACTIVATE_NOW, .width = -1, .height = -1, @@ -159,19 +141,19 @@ static struct fb_fix_screeninfo macfb_fix = { static struct fb_info fb_info; static u32 pseudo_palette[16]; -static int inverse = 0; -static int vidtest = 0; - -/* Unlike the Valkyrie, the DAFB cannot set individual colormap - registers. Therefore, we do what the MacOS driver does (no - kidding!) and simply set them one by one until we hit the one we - want. */ -static int dafb_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +static int inverse; +static int vidtest; + +/* + * Unlike the Valkyrie, the DAFB cannot set individual colormap + * registers. Therefore, we do what the MacOS driver does (no + * kidding!) and simply set them one by one until we hit the one we + * want. + */ +static int dafb_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { - /* FIXME: really, really need to use ioremap() here, - phys_to_virt() doesn't work anymore */ static int lastreg = -1; unsigned long flags; @@ -180,42 +162,47 @@ static int dafb_setpalette (unsigned int regno, unsigned int red, blue >>= 8; local_irq_save(flags); - - /* fbdev will set an entire colourmap, but X won't. Hopefully - this should accommodate both of them */ - if (regno != lastreg+1) { + + /* + * fbdev will set an entire colourmap, but X won't. Hopefully + * this should accommodate both of them + */ + if (regno != lastreg + 1) { int i; - + /* Stab in the dark trying to reset the CLUT pointer */ nubus_writel(0, &dafb_cmap_regs->reset); nop(); - + /* Loop until we get to the register we want */ for (i = 0; i < regno; i++) { - nubus_writeb(info->cmap.red[i] >> 8, &dafb_cmap_regs->lut); + nubus_writeb(info->cmap.red[i] >> 8, + &dafb_cmap_regs->lut); nop(); - nubus_writeb(info->cmap.green[i] >> 8, &dafb_cmap_regs->lut); + nubus_writeb(info->cmap.green[i] >> 8, + &dafb_cmap_regs->lut); nop(); - nubus_writeb(info->cmap.blue[i] >> 8, &dafb_cmap_regs->lut); + nubus_writeb(info->cmap.blue[i] >> 8, + &dafb_cmap_regs->lut); nop(); } } - + nubus_writeb(red, &dafb_cmap_regs->lut); nop(); nubus_writeb(green, &dafb_cmap_regs->lut); nop(); nubus_writeb(blue, &dafb_cmap_regs->lut); - + local_irq_restore(flags); lastreg = regno; return 0; } /* V8 and Brazil seem to use the same DAC. Sonora does as well. */ -static int v8_brazil_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +static int v8_brazil_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { unsigned int bpp = info->var.bits_per_pixel; unsigned char _red =red>>8; @@ -224,33 +211,36 @@ static int v8_brazil_setpalette (unsigned int regno, unsigned int red, unsigned char _regno; unsigned long flags; - if (bpp > 8) return 1; /* failsafe */ + if (bpp > 8) + return 1; /* failsafe */ local_irq_save(flags); /* On these chips, the CLUT register numbers are spread out - across the register space. Thus: - - In 8bpp, all regnos are valid. - - In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc - - In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff */ - _regno = (regno << (8 - bpp)) | (0xFF >> bpp); - nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); nop(); + * across the register space. Thus: + * In 8bpp, all regnos are valid. + * In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc + * In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff + */ + _regno = (regno << (8 - bpp)) | (0xFF >> bpp); + nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); + nop(); /* send one color channel at a time */ - nubus_writeb(_red, &v8_brazil_cmap_regs->lut); nop(); - nubus_writeb(_green, &v8_brazil_cmap_regs->lut); nop(); + nubus_writeb(_red, &v8_brazil_cmap_regs->lut); + nop(); + nubus_writeb(_green, &v8_brazil_cmap_regs->lut); + nop(); nubus_writeb(_blue, &v8_brazil_cmap_regs->lut); - local_irq_restore(flags); + local_irq_restore(flags); return 0; } -static int rbv_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +/* RAM-Based Video */ +static int rbv_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { /* use MSBs */ unsigned char _red =red>>8; @@ -259,10 +249,11 @@ static int rbv_setpalette (unsigned int regno, unsigned int red, unsigned char _regno; unsigned long flags; - if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ + if (info->var.bits_per_pixel > 8) + return 1; /* failsafe */ local_irq_save(flags); - + /* From the VideoToolbox driver. Seems to be saying that * regno #254 and #255 are the important ones for 1-bit color, * regno #252-255 are the important ones for 2-bit color, etc. @@ -270,21 +261,25 @@ static int rbv_setpalette (unsigned int regno, unsigned int red, _regno = regno + (256-(1 << info->var.bits_per_pixel)); /* reset clut? (VideoToolbox sez "not necessary") */ - nubus_writeb(0xFF, &rbv_cmap_regs->cntl); nop(); - + nubus_writeb(0xFF, &rbv_cmap_regs->cntl); + nop(); + /* tell clut which address to use. */ - nubus_writeb(_regno, &rbv_cmap_regs->addr); nop(); - + nubus_writeb(_regno, &rbv_cmap_regs->addr); + nop(); + /* send one color channel at a time. */ - nubus_writeb(_red, &rbv_cmap_regs->lut); nop(); - nubus_writeb(_green, &rbv_cmap_regs->lut); nop(); - nubus_writeb(_blue, &rbv_cmap_regs->lut); - - local_irq_restore(flags); /* done. */ + nubus_writeb(_red, &rbv_cmap_regs->lut); + nop(); + nubus_writeb(_green, &rbv_cmap_regs->lut); + nop(); + nubus_writeb(_blue, &rbv_cmap_regs->lut); + + local_irq_restore(flags); return 0; } -/* Macintosh Display Card (8x24) */ +/* Macintosh Display Card (8*24) */ static int mdc_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) @@ -299,11 +294,14 @@ static int mdc_setpalette(unsigned int regno, unsigned int red, unsigned long flags; local_irq_save(flags); - + /* the nop's are there to order writes. */ - nubus_writeb(_regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); nop(); + nubus_writeb(_regno, &cmap_regs->addr); + nop(); + nubus_writeb(_red, &cmap_regs->lut); + nop(); + nubus_writeb(_green, &cmap_regs->lut); + nop(); nubus_writeb(_blue, &cmap_regs->lut); local_irq_restore(flags); @@ -313,7 +311,7 @@ static int mdc_setpalette(unsigned int regno, unsigned int red, /* Toby frame buffer */ static int toby_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, - struct fb_info *info) + struct fb_info *info) { volatile struct toby_cmap_regs *cmap_regs = nubus_slot_addr(video_slot); @@ -326,10 +324,13 @@ static int toby_setpalette(unsigned int regno, unsigned int red, unsigned long flags; local_irq_save(flags); - - nubus_writeb(_regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); nop(); + + nubus_writeb(_regno, &cmap_regs->addr); + nop(); + nubus_writeb(_red, &cmap_regs->lut); + nop(); + nubus_writeb(_green, &cmap_regs->lut); + nop(); nubus_writeb(_blue, &cmap_regs->lut); local_irq_restore(flags); @@ -350,10 +351,13 @@ static int jet_setpalette(unsigned int regno, unsigned int red, unsigned long flags; local_irq_save(flags); - - nubus_writeb(regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); nop(); + + nubus_writeb(regno, &cmap_regs->addr); + nop(); + nubus_writeb(_red, &cmap_regs->lut); + nop(); + nubus_writeb(_green, &cmap_regs->lut); + nop(); nubus_writeb(_blue, &cmap_regs->lut); local_irq_restore(flags); @@ -363,53 +367,31 @@ static int jet_setpalette(unsigned int regno, unsigned int red, /* * Civic framebuffer -- Quadra AV built-in video. A chip * called Sebastian holds the actual color palettes, and - * apparently, there are two different banks of 512K RAM + * apparently, there are two different banks of 512K RAM * which can act as separate framebuffers for doing video * input and viewing the screen at the same time! The 840AV - * Can add another 1MB RAM to give the two framebuffers + * Can add another 1MB RAM to give the two framebuffers * 1MB RAM apiece. - * - * FIXME: this doesn't seem to work anymore. */ -static int civic_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +static int civic_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { - static int lastreg = -1; unsigned long flags; int clut_status; - if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ + if (info->var.bits_per_pixel > 8) + return 1; /* failsafe */ red >>= 8; green >>= 8; blue >>= 8; local_irq_save(flags); - - /* - * Set the register address - */ - nubus_writeb(regno, &civic_cmap_regs->addr); nop(); - /* - * Wait for VBL interrupt here; - * They're usually not enabled from Penguin, so we won't check - */ -#if 0 - { -#define CIVIC_VBL_OFFSET 0x120 - volatile unsigned long *vbl = nubus_readl(civic_cmap_regs->vbl_addr + CIVIC_VBL_OFFSET); - /* do interrupt setup stuff here? */ - *vbl = 0L; nop(); /* clear */ - *vbl = 1L; nop(); /* set */ - while (*vbl != 0L) /* wait for next vbl */ - { - usleep(10); /* needed? */ - } - /* do interrupt shutdown stuff here? */ - } -#endif + /* Set the register address */ + nubus_writeb(regno, &civic_cmap_regs->addr); + nop(); /* * Grab a status word and do some checking; @@ -422,39 +404,52 @@ static int civic_setpalette (unsigned int regno, unsigned int red, #if 0 if ((clut_status & 0x000D) != 0) { - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); } #endif - nubus_writeb( red, &civic_cmap_regs->lut); nop(); - nubus_writeb(green, &civic_cmap_regs->lut); nop(); - nubus_writeb( blue, &civic_cmap_regs->lut); nop(); - nubus_writeb( 0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(red, &civic_cmap_regs->lut); + nop(); + nubus_writeb(green, &civic_cmap_regs->lut); + nop(); + nubus_writeb(blue, &civic_cmap_regs->lut); + nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); } else { unsigned char junk; - junk = nubus_readb(&civic_cmap_regs->lut); nop(); - junk = nubus_readb(&civic_cmap_regs->lut); nop(); - junk = nubus_readb(&civic_cmap_regs->lut); nop(); - junk = nubus_readb(&civic_cmap_regs->lut); nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); if ((clut_status & 0x000D) != 0) { - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); } - nubus_writeb( red, &civic_cmap_regs->lut); nop(); - nubus_writeb(green, &civic_cmap_regs->lut); nop(); - nubus_writeb( blue, &civic_cmap_regs->lut); nop(); - nubus_writeb( junk, &civic_cmap_regs->lut); nop(); + nubus_writeb(red, &civic_cmap_regs->lut); + nop(); + nubus_writeb(green, &civic_cmap_regs->lut); + nop(); + nubus_writeb(blue, &civic_cmap_regs->lut); + nop(); + nubus_writeb(junk, &civic_cmap_regs->lut); } local_irq_restore(flags); - lastreg = regno; return 0; } @@ -463,10 +458,9 @@ static int civic_setpalette (unsigned int regno, unsigned int red, * (and the 5300 too, but that's a PowerMac). This function * brought to you in part by the ECSC driver for MkLinux. */ - -static int csc_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +static int csc_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { mdelay(1); nubus_writeb(regno, &csc_cmap_regs->clut_waddr); @@ -481,10 +475,10 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, struct fb_info *fb_info) { /* - * Set a single color register. The values supplied are - * already rounded down to the hardware's capabilities - * (according to the entries in the `var' structure). Return - * != 0 for invalid regno. + * Set a single color register. The values supplied are + * already rounded down to the hardware's capabilities + * (according to the entries in the `var' structure). + * Return non-zero for invalid regno. */ if (regno >= fb_info->cmap.len) @@ -518,28 +512,22 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, } else { /* 0:5:6:5 */ ((u32*) (fb_info->pseudo_palette))[regno] = - ((red & 0xf800) ) | + ((red & 0xf800) >> 0) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); } break; - /* I'm pretty sure that one or the other of these - doesn't exist on 68k Macs */ + /* + * 24-bit colour almost doesn't exist on 68k Macs -- + * http://support.apple.com/kb/TA28634 (Old Article: 10992) + */ case 24: - red >>= 8; - green >>= 8; - blue >>= 8; - ((u32 *)(fb_info->pseudo_palette))[regno] = - (red << fb_info->var.red.offset) | - (green << fb_info->var.green.offset) | - (blue << fb_info->var.blue.offset); - break; case 32: red >>= 8; green >>= 8; blue >>= 8; ((u32 *)(fb_info->pseudo_palette))[regno] = - (red << fb_info->var.red.offset) | + (red << fb_info->var.red.offset) | (green << fb_info->var.green.offset) | (blue << fb_info->var.blue.offset); break; @@ -560,18 +548,19 @@ static struct fb_ops macfb_ops = { static void __init macfb_setup(char *options) { char *this_opt; - + if (!options || !*options) return; - + while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; - - if (! strcmp(this_opt, "inverse")) - inverse=1; - /* This means "turn on experimental CLUT code" */ - else if (!strcmp(this_opt, "vidtest")) - vidtest=1; + if (!*this_opt) + continue; + + if (!strcmp(this_opt, "inverse")) + inverse = 1; + else + if (!strcmp(this_opt, "vidtest")) + vidtest = 1; /* enable experimental CLUT code */ } } @@ -607,48 +596,52 @@ static int __init macfb_init(void) mac_bi_data.id == MAC_MODEL_P588) return -ENODEV; /* See valkyriefb.c */ - /* There can only be one internal video controller anyway so - we're not too worried about this */ macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF; macfb_defined.yres = mac_bi_data.dimensions >> 16; macfb_defined.bits_per_pixel = mac_bi_data.videodepth; + macfb_fix.line_length = mac_bi_data.videorow; - macfb_fix.smem_len = macfb_fix.line_length * macfb_defined.yres; + macfb_fix.smem_len = macfb_fix.line_length * macfb_defined.yres; /* Note: physical address (since 2.1.127) */ - macfb_fix.smem_start = mac_bi_data.videoaddr; - /* This is actually redundant with the initial mappings. - However, there are some non-obvious aspects to the way - those mappings are set up, so this is in fact the safest - way to ensure that this driver will work on every possible - Mac */ + macfb_fix.smem_start = mac_bi_data.videoaddr; + + /* + * This is actually redundant with the initial mappings. + * However, there are some non-obvious aspects to the way + * those mappings are set up, so this is in fact the safest + * way to ensure that this driver will work on every possible Mac + */ fb_info.screen_base = ioremap(mac_bi_data.videoaddr, macfb_fix.smem_len); printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", - macfb_fix.smem_start, fb_info.screen_base, macfb_fix.smem_len/1024); + macfb_fix.smem_start, fb_info.screen_base, + macfb_fix.smem_len / 1024); printk("macfb: mode is %dx%dx%d, linelength=%d\n", - macfb_defined.xres, macfb_defined.yres, macfb_defined.bits_per_pixel, macfb_fix.line_length); - + macfb_defined.xres, macfb_defined.yres, + macfb_defined.bits_per_pixel, macfb_fix.line_length); + /* - * Fill in the available video resolution + * Fill in the available video resolution */ - - macfb_defined.xres_virtual = macfb_defined.xres; - macfb_defined.yres_virtual = macfb_defined.yres; - macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); - macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); + macfb_defined.xres_virtual = macfb_defined.xres; + macfb_defined.yres_virtual = macfb_defined.yres; + macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); + macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); printk("macfb: scrolling: redraw\n"); - macfb_defined.yres_virtual = macfb_defined.yres; /* some dummy values for timing to make fbset happy */ - macfb_defined.pixclock = 10000000 / macfb_defined.xres * 1000 / macfb_defined.yres; + macfb_defined.pixclock = 10000000 / macfb_defined.xres * + 1000 / macfb_defined.yres; macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8; macfb_defined.hsync_len = (macfb_defined.xres / 8) & 0xf8; switch (macfb_defined.bits_per_pixel) { case 1: - /* XXX: I think this will catch any program that tries - to do FBIO_PUTCMAP when the visual is monochrome */ + /* + * XXX: I think this will catch any program that tries + * to do FBIO_PUTCMAP when the visual is monochrome. + */ macfb_defined.red.length = macfb_defined.bits_per_pixel; macfb_defined.green.length = macfb_defined.bits_per_pixel; macfb_defined.blue.length = macfb_defined.bits_per_pixel; @@ -676,14 +669,14 @@ static int __init macfb_init(void) printk("macfb: directcolor: " "size=1:5:5:5, shift=15:10:5:0\n"); video_cmap_len = 16; - /* Should actually be FB_VISUAL_DIRECTCOLOR, but this - works too */ + /* + * Should actually be FB_VISUAL_DIRECTCOLOR, but this + * works too + */ macfb_fix.visual = FB_VISUAL_TRUECOLOR; break; case 24: case 32: - /* XXX: have to test these... can any 68k Macs - actually do this on internal video? */ macfb_defined.red.offset = 16; macfb_defined.red.length = 8; macfb_defined.green.offset = 8; @@ -697,18 +690,19 @@ static int __init macfb_init(void) default: video_cmap_len = 0; macfb_fix.visual = FB_VISUAL_MONO01; - printk("macfb: unknown or unsupported bit depth: %d\n", macfb_defined.bits_per_pixel); + printk("macfb: unknown or unsupported bit depth: %d\n", + macfb_defined.bits_per_pixel); break; } - /* Hardware dependent stuff */ - /* We take a wild guess that if the video physical address is - * in nubus slot space, that the nubus card is driving video. - * Penguin really ought to tell us whether we are using internal - * video or not. + /* + * We take a wild guess that if the video physical address is + * in nubus slot space, that the nubus card is driving video. + * Penguin really ought to tell us whether we are using internal + * video or not. + * Hopefully we only find one of them. Otherwise our NuBus + * code is really broken :-) */ - /* Hopefully we only find one of them. Otherwise our NuBus - code is really broken :-) */ while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, NUBUS_TYPE_VIDEO, ndev)) != NULL) @@ -736,7 +730,7 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "Jet"); macfb_setpalette = jet_setpalette; macfb_defined.activate = FB_ACTIVATE_NOW; - break; + break; default: strcpy(macfb_fix.id, "Generic NuBus"); break; @@ -744,20 +738,19 @@ static int __init macfb_init(void) } /* If it's not a NuBus card, it must be internal video */ - /* FIXME: this function is getting way too big. (this driver - is too...) */ if (!video_is_nubus) - switch( mac_bi_data.id ) - { - /* DAFB Quadras */ - /* Note: these first four have the v7 DAFB, which is - known to be rather unlike the ones used in the - other models */ + switch (mac_bi_data.id) { + /* + * DAFB Quadras + * Note: these first four have the v7 DAFB, which is + * known to be rather unlike the ones used in the + * other models + */ case MAC_MODEL_P475: case MAC_MODEL_P475F: case MAC_MODEL_P575: case MAC_MODEL_Q605: - + case MAC_MODEL_Q800: case MAC_MODEL_Q650: case MAC_MODEL_Q610: @@ -772,17 +765,21 @@ static int __init macfb_init(void) dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000); break; - /* LC II uses the V8 framebuffer */ + /* + * LC II uses the V8 framebuffer + */ case MAC_MODEL_LCII: strcpy(macfb_fix.id, "V8"); macfb_setpalette = v8_brazil_setpalette; macfb_defined.activate = FB_ACTIVATE_NOW; v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - - /* IIvi, IIvx use the "Brazil" framebuffer (which is - very much like the V8, it seems, and probably uses - the same DAC) */ + + /* + * IIvi, IIvx use the "Brazil" framebuffer (which is + * very much like the V8, it seems, and probably uses + * the same DAC) + */ case MAC_MODEL_IIVI: case MAC_MODEL_IIVX: case MAC_MODEL_P600: @@ -791,12 +788,14 @@ static int __init macfb_init(void) macfb_defined.activate = FB_ACTIVATE_NOW; v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - - /* LC III (and friends) use the Sonora framebuffer */ - /* Incidentally this is also used in the non-AV models - of the x100 PowerMacs */ - /* These do in fact seem to use the same DAC interface - as the LC II. */ + + /* + * LC III (and friends) use the Sonora framebuffer + * Incidentally this is also used in the non-AV models + * of the x100 PowerMacs + * These do in fact seem to use the same DAC interface + * as the LC II. + */ case MAC_MODEL_LCIII: case MAC_MODEL_P520: case MAC_MODEL_P550: @@ -807,9 +806,11 @@ static int __init macfb_init(void) v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - /* IIci and IIsi use the infamous RBV chip - (the IIsi is just a rebadged and crippled - IIci in a different case, BTW) */ + /* + * IIci and IIsi use the infamous RBV chip + * (the IIsi is just a rebadged and crippled + * IIci in a different case, BTW) + */ case MAC_MODEL_IICI: case MAC_MODEL_IISI: macfb_setpalette = rbv_setpalette; @@ -818,7 +819,9 @@ static int __init macfb_init(void) rbv_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - /* AVs use the Civic framebuffer */ + /* + * AVs use the Civic framebuffer + */ case MAC_MODEL_Q840: case MAC_MODEL_C660: macfb_setpalette = civic_setpalette; @@ -828,15 +831,10 @@ static int __init macfb_init(void) break; - /* Write a setpalette function for your machine, then - you can add something similar here. These are - grouped by classes of video chipsets. Some of this - information is from the VideoToolbox "Bugs" web - page at - http://rajsky.psych.nyu.edu/Tips/VideoBugs.html */ - - /* Assorted weirdos */ - /* We think this may be like the LC II */ + /* + * Assorted weirdos + * We think this may be like the LC II + */ case MAC_MODEL_LC: if (vidtest) { macfb_setpalette = v8_brazil_setpalette; @@ -846,7 +844,10 @@ static int __init macfb_init(void) } strcpy(macfb_fix.id, "LC"); break; - /* We think this may be like the LC II */ + + /* + * We think this may be like the LC II + */ case MAC_MODEL_CCL: if (vidtest) { macfb_setpalette = v8_brazil_setpalette; @@ -857,23 +858,29 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "Color Classic"); break; - /* And we *do* mean "weirdos" */ + /* + * And we *do* mean "weirdos" + */ case MAC_MODEL_TV: strcpy(macfb_fix.id, "Mac TV"); break; - /* These don't have colour, so no need to worry */ + /* + * These don't have colour, so no need to worry + */ case MAC_MODEL_SE30: case MAC_MODEL_CLII: strcpy(macfb_fix.id, "Monochrome"); break; - /* Powerbooks are particularly difficult. Many of - them have separate framebuffers for external and - internal video, which is admittedly pretty cool, - but will be a bit of a headache to support here. - Also, many of them are grayscale, and we don't - really support that. */ + /* + * Powerbooks are particularly difficult. Many of + * them have separate framebuffers for external and + * internal video, which is admittedly pretty cool, + * but will be a bit of a headache to support here. + * Also, many of them are grayscale, and we don't + * really support that. + */ case MAC_MODEL_PB140: case MAC_MODEL_PB145: @@ -881,7 +888,9 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "DDC"); break; - /* Internal is GSC, External (if present) is ViSC */ + /* + * Internal is GSC, External (if present) is ViSC + */ case MAC_MODEL_PB150: /* no external video */ case MAC_MODEL_PB160: case MAC_MODEL_PB165: @@ -891,13 +900,17 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "GSC"); break; - /* Internal is TIM, External is ViSC */ + /* + * Internal is TIM, External is ViSC + */ case MAC_MODEL_PB165C: case MAC_MODEL_PB180C: strcpy(macfb_fix.id, "TIM"); break; - /* Internal is CSC, External is Keystone+Ariel. */ + /* + * Internal is CSC, External is Keystone+Ariel. + */ case MAC_MODEL_PB190: /* external video is optional */ case MAC_MODEL_PB520: case MAC_MODEL_PB250: @@ -909,7 +922,7 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "CSC"); csc_cmap_regs = ioremap(CSC_BASE, 0x1000); break; - + default: strcpy(macfb_fix.id, "Unknown"); break; @@ -924,7 +937,7 @@ static int __init macfb_init(void) err = fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0); if (err) goto fail_unmap; - + err = register_framebuffer(&fb_info); if (err) goto fail_dealloc; -- cgit v1.2.3-70-g09d2 From 99e11ab20b26b3236490ae687ab309c2601d180b Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 4 Nov 2009 00:51:18 +1100 Subject: macfb: fix 24-bit visual and stuff Lots of changes. Remove volatile keywords. Take the advice in the comments and change video_slot to slot_addr. Factor out fifteen or so "channel >> 8" shifts into three shifts higher up the call graph. Make csc_setpalette() atomic, pass the correct color values. Check for ioremap() failure. Add missing break statement, thus fixing 24 bit console visual (blue background bug). Remove some uninformative printk() noise. Add a description for powerbook 140/170 graphics. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- drivers/video/macfb.c | 144 +++++++++++++++++++++----------------------------- 1 file changed, 60 insertions(+), 84 deletions(-) (limited to 'drivers') diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index 8b246ee7c06..43207cc6cc1 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -120,8 +120,6 @@ struct jet_cmap_regs { #define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ -static int video_slot = 0; - static struct fb_var_screeninfo macfb_defined = { .bits_per_pixel = 8, .activate = FB_ACTIVATE_NOW, @@ -139,6 +137,7 @@ static struct fb_fix_screeninfo macfb_fix = { .accel = FB_ACCEL_NONE, }; +static void *slot_addr; static struct fb_info fb_info; static u32 pseudo_palette[16]; static int inverse; @@ -156,10 +155,6 @@ static int dafb_setpalette(unsigned int regno, unsigned int red, { static int lastreg = -1; unsigned long flags; - - red >>= 8; - green >>= 8; - blue >>= 8; local_irq_save(flags); @@ -205,10 +200,6 @@ static int v8_brazil_setpalette(unsigned int regno, unsigned int red, struct fb_info *info) { unsigned int bpp = info->var.bits_per_pixel; - unsigned char _red =red>>8; - unsigned char _green=green>>8; - unsigned char _blue =blue>>8; - unsigned char _regno; unsigned long flags; if (bpp > 8) @@ -222,16 +213,16 @@ static int v8_brazil_setpalette(unsigned int regno, unsigned int red, * In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc * In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff */ - _regno = (regno << (8 - bpp)) | (0xFF >> bpp); - nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); + regno = (regno << (8 - bpp)) | (0xFF >> bpp); + nubus_writeb(regno, &v8_brazil_cmap_regs->addr); nop(); /* send one color channel at a time */ - nubus_writeb(_red, &v8_brazil_cmap_regs->lut); + nubus_writeb(red, &v8_brazil_cmap_regs->lut); nop(); - nubus_writeb(_green, &v8_brazil_cmap_regs->lut); + nubus_writeb(green, &v8_brazil_cmap_regs->lut); nop(); - nubus_writeb(_blue, &v8_brazil_cmap_regs->lut); + nubus_writeb(blue, &v8_brazil_cmap_regs->lut); local_irq_restore(flags); return 0; @@ -242,11 +233,6 @@ static int rbv_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - /* use MSBs */ - unsigned char _red =red>>8; - unsigned char _green=green>>8; - unsigned char _blue =blue>>8; - unsigned char _regno; unsigned long flags; if (info->var.bits_per_pixel > 8) @@ -258,22 +244,22 @@ static int rbv_setpalette(unsigned int regno, unsigned int red, * regno #254 and #255 are the important ones for 1-bit color, * regno #252-255 are the important ones for 2-bit color, etc. */ - _regno = regno + (256-(1 << info->var.bits_per_pixel)); + regno += 256 - (1 << info->var.bits_per_pixel); /* reset clut? (VideoToolbox sez "not necessary") */ nubus_writeb(0xFF, &rbv_cmap_regs->cntl); nop(); /* tell clut which address to use. */ - nubus_writeb(_regno, &rbv_cmap_regs->addr); + nubus_writeb(regno, &rbv_cmap_regs->addr); nop(); /* send one color channel at a time. */ - nubus_writeb(_red, &rbv_cmap_regs->lut); + nubus_writeb(red, &rbv_cmap_regs->lut); nop(); - nubus_writeb(_green, &rbv_cmap_regs->lut); + nubus_writeb(green, &rbv_cmap_regs->lut); nop(); - nubus_writeb(_blue, &rbv_cmap_regs->lut); + nubus_writeb(blue, &rbv_cmap_regs->lut); local_irq_restore(flags); return 0; @@ -284,25 +270,19 @@ static int mdc_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - volatile struct mdc_cmap_regs *cmap_regs = - nubus_slot_addr(video_slot); - /* use MSBs */ - unsigned char _red =red>>8; - unsigned char _green=green>>8; - unsigned char _blue =blue>>8; - unsigned char _regno=regno; + struct mdc_cmap_regs *cmap_regs = slot_addr; unsigned long flags; local_irq_save(flags); /* the nop's are there to order writes. */ - nubus_writeb(_regno, &cmap_regs->addr); + nubus_writeb(regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); + nubus_writeb(red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); + nubus_writeb(green, &cmap_regs->lut); nop(); - nubus_writeb(_blue, &cmap_regs->lut); + nubus_writeb(blue, &cmap_regs->lut); local_irq_restore(flags); return 0; @@ -313,25 +293,24 @@ static int toby_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - volatile struct toby_cmap_regs *cmap_regs = - nubus_slot_addr(video_slot); + struct toby_cmap_regs *cmap_regs = slot_addr; unsigned int bpp = info->var.bits_per_pixel; - /* use MSBs */ - unsigned char _red =~(red>>8); - unsigned char _green=~(green>>8); - unsigned char _blue =~(blue>>8); - unsigned char _regno = (regno << (8 - bpp)) | (0xFF >> bpp); unsigned long flags; + red = ~red; + green = ~green; + blue = ~blue; + regno = (regno << (8 - bpp)) | (0xFF >> bpp); + local_irq_save(flags); - nubus_writeb(_regno, &cmap_regs->addr); + nubus_writeb(regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); + nubus_writeb(red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); + nubus_writeb(green, &cmap_regs->lut); nop(); - nubus_writeb(_blue, &cmap_regs->lut); + nubus_writeb(blue, &cmap_regs->lut); local_irq_restore(flags); return 0; @@ -342,23 +321,18 @@ static int jet_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - volatile struct jet_cmap_regs *cmap_regs = - nubus_slot_addr(video_slot); - /* use MSBs */ - unsigned char _red = (red>>8); - unsigned char _green = (green>>8); - unsigned char _blue = (blue>>8); + struct jet_cmap_regs *cmap_regs = slot_addr; unsigned long flags; local_irq_save(flags); nubus_writeb(regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); + nubus_writeb(red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); + nubus_writeb(green, &cmap_regs->lut); nop(); - nubus_writeb(_blue, &cmap_regs->lut); + nubus_writeb(blue, &cmap_regs->lut); local_irq_restore(flags); return 0; @@ -383,10 +357,6 @@ static int civic_setpalette(unsigned int regno, unsigned int red, if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ - red >>= 8; - green >>= 8; - blue >>= 8; - local_irq_save(flags); /* Set the register address */ @@ -462,11 +432,17 @@ static int csc_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - mdelay(1); + unsigned long flags; + + local_irq_save(flags); + + udelay(1); /* mklinux on PB 5300 waits for 260 ns */ nubus_writeb(regno, &csc_cmap_regs->clut_waddr); - nubus_writeb(red, &csc_cmap_regs->clut_data); + nubus_writeb(red, &csc_cmap_regs->clut_data); nubus_writeb(green, &csc_cmap_regs->clut_data); - nubus_writeb(blue, &csc_cmap_regs->clut_data); + nubus_writeb(blue, &csc_cmap_regs->clut_data); + + local_irq_restore(flags); return 0; } @@ -493,8 +469,8 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, case 4: case 8: if (macfb_setpalette) - macfb_setpalette(regno, red, green, blue, - fb_info); + macfb_setpalette(regno, red >> 8, green >> 8, + blue >> 8, fb_info); else return 1; break; @@ -611,8 +587,11 @@ static int __init macfb_init(void) * those mappings are set up, so this is in fact the safest * way to ensure that this driver will work on every possible Mac */ - fb_info.screen_base = ioremap(mac_bi_data.videoaddr, macfb_fix.smem_len); - + fb_info.screen_base = ioremap(mac_bi_data.videoaddr, + macfb_fix.smem_len); + if (!fb_info.screen_base) + return -ENODEV; + printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", macfb_fix.smem_start, fb_info.screen_base, macfb_fix.smem_len / 1024); @@ -620,17 +599,13 @@ static int __init macfb_init(void) macfb_defined.xres, macfb_defined.yres, macfb_defined.bits_per_pixel, macfb_fix.line_length); - /* - * Fill in the available video resolution - */ + /* Fill in the available video resolution */ macfb_defined.xres_virtual = macfb_defined.xres; macfb_defined.yres_virtual = macfb_defined.yres; macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); - printk("macfb: scrolling: redraw\n"); - - /* some dummy values for timing to make fbset happy */ + /* Some dummy values for timing to make fbset happy */ macfb_defined.pixclock = 10000000 / macfb_defined.xres * 1000 / macfb_defined.yres; macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8; @@ -666,8 +641,6 @@ static int __init macfb_init(void) macfb_defined.green.length = 5; macfb_defined.blue.offset = 0; macfb_defined.blue.length = 5; - printk("macfb: directcolor: " - "size=1:5:5:5, shift=15:10:5:0\n"); video_cmap_len = 16; /* * Should actually be FB_VISUAL_DIRECTCOLOR, but this @@ -683,10 +656,9 @@ static int __init macfb_init(void) macfb_defined.green.length = 8; macfb_defined.blue.offset = 0; macfb_defined.blue.length = 8; - printk("macfb: truecolor: " - "size=0:8:8:8, shift=0:16:8:0\n"); video_cmap_len = 16; macfb_fix.visual = FB_VISUAL_TRUECOLOR; + break; default: video_cmap_len = 0; macfb_fix.visual = FB_VISUAL_MONO01; @@ -704,16 +676,17 @@ static int __init macfb_init(void) * code is really broken :-) */ - while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, NUBUS_TYPE_VIDEO, ndev)) - != NULL) + while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, + NUBUS_TYPE_VIDEO, ndev))) { - if (!(mac_bi_data.videoaddr >= ndev->board->slot_addr - && (mac_bi_data.videoaddr < - (unsigned long)nubus_slot_addr(ndev->board->slot+1)))) + unsigned long base = ndev->board->slot_addr; + + if (mac_bi_data.videoaddr < base || + mac_bi_data.videoaddr - base > 0xFFFFFF) continue; + video_is_nubus = 1; - /* We should probably just use the slot address... */ - video_slot = ndev->board->slot; + slot_addr = (unsigned char *)base; switch(ndev->dr_hw) { case NUBUS_DRHW_APPLE_MDC: @@ -882,6 +855,9 @@ static int __init macfb_init(void) * really support that. */ + /* + * Slot 0 ROM says TIM. No external video. B&W. + */ case MAC_MODEL_PB140: case MAC_MODEL_PB145: case MAC_MODEL_PB170: -- cgit v1.2.3-70-g09d2