Lines Matching +full:port +full:- +full:config
1 // SPDX-License-Identifier: GPL-2.0-or-later
34 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; variable
43 module_param_hw_array(port, long, ioport, NULL, 0444);
44 MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
46 MODULE_PARM_DESC(wss_port, "WSS port # for " CRD_NAME " driver.");
48 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
50 MODULE_PARM_DESC(fm_port, "FM port # for " CRD_NAME " driver.");
54 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
74 static int dsp_get_byte(void __iomem *port, u8 *val) in dsp_get_byte() argument
78 while (!(ioread8(port + DSP_PORT_DATA_AVAIL) & 0x80)) { in dsp_get_byte()
79 if (!loops--) in dsp_get_byte()
80 return -EIO; in dsp_get_byte()
83 *val = ioread8(port + DSP_PORT_READ); in dsp_get_byte()
87 static int dsp_reset(void __iomem *port) in dsp_reset() argument
91 iowrite8(1, port + DSP_PORT_RESET); in dsp_reset()
93 iowrite8(0, port + DSP_PORT_RESET); in dsp_reset()
95 if (dsp_get_byte(port, &val) < 0 || val != DSP_SIGNATURE) in dsp_reset()
96 return -ENODEV; in dsp_reset()
101 static int dsp_command(void __iomem *port, u8 cmd) in dsp_command() argument
105 while (ioread8(port + DSP_PORT_STATUS) & 0x80) { in dsp_command()
106 if (!loops--) in dsp_command()
107 return -EIO; in dsp_command()
110 iowrite8(cmd, port + DSP_PORT_COMMAND); in dsp_command()
114 static int dsp_get_version(void __iomem *port, u8 *major, u8 *minor) in dsp_get_version() argument
118 err = dsp_command(port, DSP_COMMAND_GET_VERSION); in dsp_get_version()
122 err = dsp_get_byte(port, major); in dsp_get_version()
126 err = dsp_get_byte(port, minor); in dsp_get_version()
154 return -ENODEV; in wss_detect()
182 void __iomem *port; member
185 u32 config; member
191 static u32 config[SNDRV_CARDS]; variable
199 switch (port[n]) { in snd_galaxy_match()
201 dev_err(dev, "please specify port\n"); in snd_galaxy_match()
204 config[n] |= GALAXY_CONFIG_SBA_220; in snd_galaxy_match()
207 config[n] |= GALAXY_CONFIG_SBA_240; in snd_galaxy_match()
210 config[n] |= GALAXY_CONFIG_SBA_260; in snd_galaxy_match()
213 config[n] |= GALAXY_CONFIG_SBA_280; in snd_galaxy_match()
216 dev_err(dev, "invalid port %#lx\n", port[n]); in snd_galaxy_match()
225 config[n] |= GALAXY_CONFIG_WSS_ENABLE | GALAXY_CONFIG_WSSA_530; in snd_galaxy_match()
228 config[n] |= GALAXY_CONFIG_WSS_ENABLE | GALAXY_CONFIG_WSSA_604; in snd_galaxy_match()
231 config[n] |= GALAXY_CONFIG_WSS_ENABLE | GALAXY_CONFIG_WSSA_E80; in snd_galaxy_match()
234 config[n] |= GALAXY_CONFIG_WSS_ENABLE | GALAXY_CONFIG_WSSA_F40; in snd_galaxy_match()
237 dev_err(dev, "invalid WSS port %#lx\n", wss_port[n]); in snd_galaxy_match()
284 dma2[n] = -1; in snd_galaxy_match()
304 dev_warn(dev, "mpu_port not specified; not using MPU-401\n"); in snd_galaxy_match()
305 mpu_port[n] = -1; in snd_galaxy_match()
308 config[n] |= GALAXY_CONFIG_MPU_ENABLE | GALAXY_CONFIG_MPUA_300; in snd_galaxy_match()
311 config[n] |= GALAXY_CONFIG_MPU_ENABLE | GALAXY_CONFIG_MPUA_330; in snd_galaxy_match()
314 dev_err(dev, "invalid MPU port %#lx\n", mpu_port[n]); in snd_galaxy_match()
321 mpu_irq[n] = -1; in snd_galaxy_match()
327 config[n] |= GALAXY_CONFIG_MPUIRQ_2; in snd_galaxy_match()
331 config[n] |= GALAXY_CONFIG_MPUIRQ_3; in snd_galaxy_match()
335 config[n] |= GALAXY_CONFIG_MPUIRQ_5; in snd_galaxy_match()
338 config[n] |= GALAXY_CONFIG_MPUIRQ_7; in snd_galaxy_match()
342 config[n] |= GALAXY_CONFIG_MPUIRQ_10; in snd_galaxy_match()
351 dev_err(dev, "cannot share IRQ between WSS and MPU-401\n"); in snd_galaxy_match()
359 fm_port[n] = -1; in snd_galaxy_match()
364 dev_err(dev, "illegal FM port %#lx\n", fm_port[n]); in snd_galaxy_match()
368 config[n] |= GALAXY_CONFIG_GAME_ENABLE; in snd_galaxy_match()
378 err = dsp_reset(galaxy->port); in galaxy_init()
382 err = dsp_get_version(galaxy->port, &major, &minor); in galaxy_init()
387 return -ENODEV; in galaxy_init()
389 err = dsp_command(galaxy->port, DSP_COMMAND_GALAXY_8); in galaxy_init()
393 err = dsp_command(galaxy->port, GALAXY_COMMAND_GET_TYPE); in galaxy_init()
397 err = dsp_get_byte(galaxy->port, type); in galaxy_init()
408 err = dsp_command(galaxy->port, DSP_COMMAND_GALAXY_9); in galaxy_set_mode()
412 err = dsp_command(galaxy->port, mode); in galaxy_set_mode()
420 err = dsp_reset(galaxy->port); in galaxy_set_mode()
428 static void galaxy_set_config(struct snd_galaxy *galaxy, u32 config) in galaxy_set_config() argument
430 u8 tmp = ioread8(galaxy->config_port + CONFIG_PORT_SET); in galaxy_set_config()
433 iowrite8(tmp | 0x80, galaxy->config_port + CONFIG_PORT_SET); in galaxy_set_config()
435 iowrite8(config, galaxy->config_port + i); in galaxy_set_config()
436 config >>= 8; in galaxy_set_config()
438 iowrite8(tmp & 0x7f, galaxy->config_port + CONFIG_PORT_SET); in galaxy_set_config()
442 static void galaxy_config(struct snd_galaxy *galaxy, u32 config) in galaxy_config() argument
446 for (i = GALAXY_CONFIG_SIZE; i; i--) { in galaxy_config()
447 u8 tmp = ioread8(galaxy->config_port + i - 1); in galaxy_config()
448 galaxy->config = (galaxy->config << 8) | tmp; in galaxy_config()
450 config |= galaxy->config & GALAXY_CONFIG_MASK; in galaxy_config()
451 galaxy_set_config(galaxy, config); in galaxy_config()
458 err = wss_detect(galaxy->wss_port); in galaxy_wss_config()
462 wss_set_config(galaxy->wss_port, wss_config); in galaxy_wss_config()
473 struct snd_galaxy *galaxy = card->private_data; in snd_galaxy_free()
475 if (galaxy->wss_port) in snd_galaxy_free()
476 wss_set_config(galaxy->wss_port, 0); in snd_galaxy_free()
477 if (galaxy->config_port) in snd_galaxy_free()
478 galaxy_set_config(galaxy, galaxy->config); in snd_galaxy_free()
494 card->private_free = snd_galaxy_free; in __snd_galaxy_probe()
495 galaxy = card->private_data; in __snd_galaxy_probe()
497 galaxy->res_port = devm_request_region(dev, port[n], 16, DRV_NAME); in __snd_galaxy_probe()
498 if (!galaxy->res_port) { in __snd_galaxy_probe()
499 dev_err(dev, "could not grab ports %#lx-%#lx\n", port[n], in __snd_galaxy_probe()
500 port[n] + 15); in __snd_galaxy_probe()
501 return -EBUSY; in __snd_galaxy_probe()
503 galaxy->port = devm_ioport_map(dev, port[n], 16); in __snd_galaxy_probe()
504 if (!galaxy->port) in __snd_galaxy_probe()
505 return -ENOMEM; in __snd_galaxy_probe()
509 dev_err(dev, "did not find a Sound Galaxy at %#lx\n", port[n]); in __snd_galaxy_probe()
512 dev_info(dev, "Sound Galaxy (type %d) found at %#lx\n", type, port[n]); in __snd_galaxy_probe()
514 galaxy->res_config_port = in __snd_galaxy_probe()
515 devm_request_region(dev, port[n] + GALAXY_PORT_CONFIG, 16, in __snd_galaxy_probe()
517 if (!galaxy->res_config_port) { in __snd_galaxy_probe()
518 dev_err(dev, "could not grab ports %#lx-%#lx\n", in __snd_galaxy_probe()
519 port[n] + GALAXY_PORT_CONFIG, in __snd_galaxy_probe()
520 port[n] + GALAXY_PORT_CONFIG + 15); in __snd_galaxy_probe()
521 return -EBUSY; in __snd_galaxy_probe()
523 galaxy->config_port = in __snd_galaxy_probe()
524 devm_ioport_map(dev, port[n] + GALAXY_PORT_CONFIG, 16); in __snd_galaxy_probe()
525 if (!galaxy->config_port) in __snd_galaxy_probe()
526 return -ENOMEM; in __snd_galaxy_probe()
527 galaxy_config(galaxy, config[n]); in __snd_galaxy_probe()
529 galaxy->res_wss_port = devm_request_region(dev, wss_port[n], 4, DRV_NAME); in __snd_galaxy_probe()
530 if (!galaxy->res_wss_port) { in __snd_galaxy_probe()
531 dev_err(dev, "could not grab ports %#lx-%#lx\n", wss_port[n], in __snd_galaxy_probe()
533 return -EBUSY; in __snd_galaxy_probe()
535 galaxy->wss_port = devm_ioport_map(dev, wss_port[n], 4); in __snd_galaxy_probe()
536 if (!galaxy->wss_port) in __snd_galaxy_probe()
537 return -ENOMEM; in __snd_galaxy_probe()
545 strcpy(card->driver, DRV_NAME); in __snd_galaxy_probe()
546 strcpy(card->shortname, DRV_NAME); in __snd_galaxy_probe()
547 sprintf(card->longname, "%s at %#lx/%#lx, irq %d, dma %d/%d", in __snd_galaxy_probe()
548 card->shortname, port[n], wss_port[n], irq[n], dma1[n], in __snd_galaxy_probe()
551 err = snd_wss_create(card, wss_port[n] + 4, -1, irq[n], dma1[n], in __snd_galaxy_probe()