Lines Matching +full:ac +full:- +full:detect +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
25 #include <linux/dma-map-ops.h>
31 #include <asm/mach-types.h>
104 int irq_base; /* base for cascaded on-chip IRQs */
196 return irq_create_mapping(sachip->irqdomain, hwirq); in sa1111_map_irq()
217 void __iomem *mapbase = sachip->base + SA1111_INTC; in sa1111_irq_handler()
224 desc->irq_data.chip->irq_ack(&desc->irq_data); in sa1111_irq_handler()
233 irqdomain = sachip->irqdomain; in sa1111_irq_handler()
243 /* For level-based interrupts */ in sa1111_irq_handler()
244 desc->irq_data.chip->irq_unmask(&desc->irq_data); in sa1111_irq_handler()
264 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_mask_irq()
275 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_unmask_irq()
284 * Attempt to re-trigger the interrupt. The SA1111 contains a register
288 * INTSET to re-trigger the interrupt.
293 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_retrigger_irq()
306 pr_err("Danger Will Robinson: failed to re-trigger IRQ%d\n", in sa1111_retrigger_irq()
307 d->irq); in sa1111_retrigger_irq()
317 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_type_irq()
324 return -EINVAL; in sa1111_type_irq()
340 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_wake_irq()
366 struct sa1111 *sachip = d->host_data; in sa1111_irqdomain_map()
370 return -EINVAL; in sa1111_irqdomain_map()
386 void __iomem *irqbase = sachip->base + SA1111_INTC; in sa1111_setup_irq()
392 request_mem_region(sachip->phys + SA1111_INTC, 512, "irq"); in sa1111_setup_irq()
394 ret = irq_alloc_descs(-1, irq_base, SA1111_IRQ_NR, -1); in sa1111_setup_irq()
396 dev_err(sachip->dev, "unable to allocate %u irqs: %d\n", in sa1111_setup_irq()
399 ret = -EINVAL; in sa1111_setup_irq()
403 sachip->irq_base = ret; in sa1111_setup_irq()
412 * detect on rising edge. Note: Feb 2001 Errata for SA1111 in sa1111_setup_irq()
424 sachip->irqdomain = irq_domain_add_linear(NULL, SA1111_IRQ_NR, in sa1111_setup_irq()
427 if (!sachip->irqdomain) { in sa1111_setup_irq()
428 irq_free_descs(sachip->irq_base, SA1111_IRQ_NR); in sa1111_setup_irq()
429 return -ENOMEM; in sa1111_setup_irq()
432 irq_domain_associate_many(sachip->irqdomain, in sa1111_setup_irq()
433 sachip->irq_base + IRQ_GPAIN0, in sa1111_setup_irq()
434 IRQ_GPAIN0, SSPROR + 1 - IRQ_GPAIN0); in sa1111_setup_irq()
435 irq_domain_associate_many(sachip->irqdomain, in sa1111_setup_irq()
436 sachip->irq_base + AUDXMTDMADONEA, in sa1111_setup_irq()
438 IRQ_S1_BVD1_STSCHG + 1 - AUDXMTDMADONEA); in sa1111_setup_irq()
443 irq_set_irq_type(sachip->irq, IRQ_TYPE_EDGE_RISING); in sa1111_setup_irq()
444 irq_set_chained_handler_and_data(sachip->irq, sa1111_irq_handler, in sa1111_setup_irq()
447 dev_info(sachip->dev, "Providing IRQ%u-%u\n", in sa1111_setup_irq()
448 sachip->irq_base, sachip->irq_base + SA1111_IRQ_NR - 1); in sa1111_setup_irq()
455 struct irq_domain *domain = sachip->irqdomain; in sa1111_remove_irq()
456 void __iomem *irqbase = sachip->base + SA1111_INTC; in sa1111_remove_irq()
465 irq_set_chained_handler_and_data(sachip->irq, NULL, NULL); in sa1111_remove_irq()
470 release_mem_region(sachip->phys + SA1111_INTC, 512); in sa1111_remove_irq()
474 SA1111_GPIO_PXDDR = (SA1111_GPIO_PADDR - SA1111_GPIO_PADDR),
475 SA1111_GPIO_PXDRR = (SA1111_GPIO_PADRR - SA1111_GPIO_PADDR),
476 SA1111_GPIO_PXDWR = (SA1111_GPIO_PADWR - SA1111_GPIO_PADDR),
477 SA1111_GPIO_PXSDR = (SA1111_GPIO_PASDR - SA1111_GPIO_PADDR),
478 SA1111_GPIO_PXSSR = (SA1111_GPIO_PASSR - SA1111_GPIO_PADDR),
488 void __iomem *reg = sachip->base + SA1111_GPIO; in sa1111_gpio_map_reg()
504 return BIT(offset - 4); in sa1111_gpio_map_bit()
506 return BIT(offset - 10); in sa1111_gpio_map_bit()
536 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_direction_input()
539 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_direction_input()
552 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_direction_output()
557 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_direction_output()
578 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_set()
581 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_set()
589 void __iomem *reg = sachip->base + SA1111_GPIO; in sa1111_gpio_set_multiple()
595 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_set_multiple()
602 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_set_multiple()
614 sachip->gc.label = "sa1111"; in sa1111_setup_gpios()
615 sachip->gc.parent = sachip->dev; in sa1111_setup_gpios()
616 sachip->gc.owner = THIS_MODULE; in sa1111_setup_gpios()
617 sachip->gc.get_direction = sa1111_gpio_get_direction; in sa1111_setup_gpios()
618 sachip->gc.direction_input = sa1111_gpio_direction_input; in sa1111_setup_gpios()
619 sachip->gc.direction_output = sa1111_gpio_direction_output; in sa1111_setup_gpios()
620 sachip->gc.get = sa1111_gpio_get; in sa1111_setup_gpios()
621 sachip->gc.set = sa1111_gpio_set; in sa1111_setup_gpios()
622 sachip->gc.set_multiple = sa1111_gpio_set_multiple; in sa1111_setup_gpios()
623 sachip->gc.to_irq = sa1111_gpio_to_irq; in sa1111_setup_gpios()
624 sachip->gc.base = -1; in sa1111_setup_gpios()
625 sachip->gc.ngpio = 18; in sa1111_setup_gpios()
627 return devm_gpiochip_add_data(sachip->dev, &sachip->gc, sachip); in sa1111_setup_gpios()
648 spin_lock_irqsave(&sachip->lock, flags); in sa1111_wake()
650 clk_enable(sachip->clk); in sa1111_wake()
655 r = readl_relaxed(sachip->base + SA1111_SKCR); in sa1111_wake()
657 writel_relaxed(r, sachip->base + SA1111_SKCR); in sa1111_wake()
659 writel_relaxed(r, sachip->base + SA1111_SKCR); in sa1111_wake()
671 writel_relaxed(r, sachip->base + SA1111_SKCR); in sa1111_wake()
682 writel_relaxed(0, sachip->base + SA1111_SKPCR); in sa1111_wake()
684 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_wake()
712 writel_relaxed(smcr, sachip->base + SA1111_SMCR); in sa1111_configure_smc()
716 * DMA erratum (Intel StrongARM SA-1111 Microprocessor Companion in sa1111_configure_smc()
719 if (sachip->dev->dma_mask) in sa1111_configure_smc()
720 *sachip->dev->dma_mask &= sa1111_dma_mask[drac >> 2]; in sa1111_configure_smc()
722 sachip->dev->coherent_dma_mask &= sa1111_dma_mask[drac >> 2]; in sa1111_configure_smc()
743 ret = -ENOMEM; in sa1111_init_one_child()
747 device_initialize(&dev->dev); in sa1111_init_one_child()
748 dev_set_name(&dev->dev, "%4.4lx", info->offset); in sa1111_init_one_child()
749 dev->devid = info->devid; in sa1111_init_one_child()
750 dev->dev.parent = sachip->dev; in sa1111_init_one_child()
751 dev->dev.bus = &sa1111_bus_type; in sa1111_init_one_child()
752 dev->dev.release = sa1111_dev_release; in sa1111_init_one_child()
753 dev->res.start = sachip->phys + info->offset; in sa1111_init_one_child()
754 dev->res.end = dev->res.start + 511; in sa1111_init_one_child()
755 dev->res.name = dev_name(&dev->dev); in sa1111_init_one_child()
756 dev->res.flags = IORESOURCE_MEM; in sa1111_init_one_child()
757 dev->mapbase = sachip->base + info->offset; in sa1111_init_one_child()
758 dev->skpcr_mask = info->skpcr_mask; in sa1111_init_one_child()
760 for (i = 0; i < ARRAY_SIZE(info->hwirq); i++) in sa1111_init_one_child()
761 dev->hwirq[i] = info->hwirq[i]; in sa1111_init_one_child()
767 if (info->dma && sachip->dev->dma_mask) { in sa1111_init_one_child()
768 dev->dma_mask = *sachip->dev->dma_mask; in sa1111_init_one_child()
769 dev->dev.dma_mask = &dev->dma_mask; in sa1111_init_one_child()
770 dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask; in sa1111_init_one_child()
773 ret = request_resource(parent, &dev->res); in sa1111_init_one_child()
775 dev_err(sachip->dev, "failed to allocate resource for %s\n", in sa1111_init_one_child()
776 dev->res.name); in sa1111_init_one_child()
780 ret = device_add(&dev->dev); in sa1111_init_one_child()
786 release_resource(&dev->res); in sa1111_init_one_child()
788 put_device(&dev->dev); in sa1111_init_one_child()
794 * sa1111_probe - probe for a single SA1111 chip.
798 * before any other SA1111-specific code.
801 * %-ENODEV device not found.
802 * %-EBUSY physical address already marked in-use.
803 * %-EINVAL no platform data passed
808 struct sa1111_platform_data *pd = me->platform_data; in __sa1111_probe()
812 int i, ret = -ENODEV; in __sa1111_probe()
815 return -EINVAL; in __sa1111_probe()
819 return -ENOMEM; in __sa1111_probe()
821 sachip->clk = devm_clk_get(me, "SA1111_CLK"); in __sa1111_probe()
822 if (IS_ERR(sachip->clk)) in __sa1111_probe()
823 return PTR_ERR(sachip->clk); in __sa1111_probe()
825 ret = clk_prepare(sachip->clk); in __sa1111_probe()
829 spin_lock_init(&sachip->lock); in __sa1111_probe()
831 sachip->dev = me; in __sa1111_probe()
832 dev_set_drvdata(sachip->dev, sachip); in __sa1111_probe()
834 sachip->pdata = pd; in __sa1111_probe()
835 sachip->phys = mem->start; in __sa1111_probe()
836 sachip->irq = irq; in __sa1111_probe()
842 sachip->base = ioremap(mem->start, PAGE_SIZE * 2); in __sa1111_probe()
843 if (!sachip->base) { in __sa1111_probe()
844 ret = -ENOMEM; in __sa1111_probe()
851 id = readl_relaxed(sachip->base + SA1111_SKID); in __sa1111_probe()
854 ret = -ENODEV; in __sa1111_probe()
870 ret = sa1111_setup_irq(sachip, pd->irq_base); in __sa1111_probe()
874 /* Setup the GPIOs - should really be done after the IRQ setup */ in __sa1111_probe()
899 val = readl_relaxed(sachip->base + SA1111_SKPCR); in __sa1111_probe()
900 writel_relaxed(val | SKPCR_DCLKEN, sachip->base + SA1111_SKPCR); in __sa1111_probe()
913 has_devs &= ~pd->disable_devs; in __sa1111_probe()
924 clk_disable(sachip->clk); in __sa1111_probe()
926 iounmap(sachip->base); in __sa1111_probe()
928 clk_unprepare(sachip->clk); in __sa1111_probe()
935 if (dev->bus != &sa1111_bus_type) in sa1111_remove_one()
937 device_del(&sadev->dev); in sa1111_remove_one()
938 release_resource(&sadev->res); in sa1111_remove_one()
939 put_device(&sadev->dev); in sa1111_remove_one()
945 device_for_each_child(sachip->dev, NULL, sa1111_remove_one); in __sa1111_remove()
949 clk_disable(sachip->clk); in __sa1111_remove()
950 clk_unprepare(sachip->clk); in __sa1111_remove()
952 iounmap(sachip->base); in __sa1111_remove()
988 return -ENOMEM; in sa1111_suspend_noirq()
989 sachip->saved_state = save; in sa1111_suspend_noirq()
991 spin_lock_irqsave(&sachip->lock, flags); in sa1111_suspend_noirq()
996 base = sachip->base; in sa1111_suspend_noirq()
997 save->skcr = readl_relaxed(base + SA1111_SKCR); in sa1111_suspend_noirq()
998 save->skpcr = readl_relaxed(base + SA1111_SKPCR); in sa1111_suspend_noirq()
999 save->skcdr = readl_relaxed(base + SA1111_SKCDR); in sa1111_suspend_noirq()
1000 save->skaud = readl_relaxed(base + SA1111_SKAUD); in sa1111_suspend_noirq()
1001 save->skpwm0 = readl_relaxed(base + SA1111_SKPWM0); in sa1111_suspend_noirq()
1002 save->skpwm1 = readl_relaxed(base + SA1111_SKPWM1); in sa1111_suspend_noirq()
1004 writel_relaxed(0, sachip->base + SA1111_SKPWM0); in sa1111_suspend_noirq()
1005 writel_relaxed(0, sachip->base + SA1111_SKPWM1); in sa1111_suspend_noirq()
1007 base = sachip->base + SA1111_INTC; in sa1111_suspend_noirq()
1008 save->intpol0 = readl_relaxed(base + SA1111_INTPOL0); in sa1111_suspend_noirq()
1009 save->intpol1 = readl_relaxed(base + SA1111_INTPOL1); in sa1111_suspend_noirq()
1010 save->inten0 = readl_relaxed(base + SA1111_INTEN0); in sa1111_suspend_noirq()
1011 save->inten1 = readl_relaxed(base + SA1111_INTEN1); in sa1111_suspend_noirq()
1012 save->wakepol0 = readl_relaxed(base + SA1111_WAKEPOL0); in sa1111_suspend_noirq()
1013 save->wakepol1 = readl_relaxed(base + SA1111_WAKEPOL1); in sa1111_suspend_noirq()
1014 save->wakeen0 = readl_relaxed(base + SA1111_WAKEEN0); in sa1111_suspend_noirq()
1015 save->wakeen1 = readl_relaxed(base + SA1111_WAKEEN1); in sa1111_suspend_noirq()
1020 val = readl_relaxed(sachip->base + SA1111_SKCR); in sa1111_suspend_noirq()
1021 writel_relaxed(val | SKCR_SLEEP, sachip->base + SA1111_SKCR); in sa1111_suspend_noirq()
1023 clk_disable(sachip->clk); in sa1111_suspend_noirq()
1025 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_suspend_noirq()
1035 * sa1111_resume - Restore the SA1111 device state.
1050 save = sachip->saved_state; in sa1111_resume_noirq()
1058 id = readl_relaxed(sachip->base + SA1111_SKID); in sa1111_resume_noirq()
1080 spin_lock_irqsave(&sachip->lock, flags); in sa1111_resume_noirq()
1082 writel_relaxed(0, sachip->base + SA1111_INTC + SA1111_INTEN0); in sa1111_resume_noirq()
1083 writel_relaxed(0, sachip->base + SA1111_INTC + SA1111_INTEN1); in sa1111_resume_noirq()
1085 base = sachip->base; in sa1111_resume_noirq()
1086 writel_relaxed(save->skcr, base + SA1111_SKCR); in sa1111_resume_noirq()
1087 writel_relaxed(save->skpcr, base + SA1111_SKPCR); in sa1111_resume_noirq()
1088 writel_relaxed(save->skcdr, base + SA1111_SKCDR); in sa1111_resume_noirq()
1089 writel_relaxed(save->skaud, base + SA1111_SKAUD); in sa1111_resume_noirq()
1090 writel_relaxed(save->skpwm0, base + SA1111_SKPWM0); in sa1111_resume_noirq()
1091 writel_relaxed(save->skpwm1, base + SA1111_SKPWM1); in sa1111_resume_noirq()
1093 base = sachip->base + SA1111_INTC; in sa1111_resume_noirq()
1094 writel_relaxed(save->intpol0, base + SA1111_INTPOL0); in sa1111_resume_noirq()
1095 writel_relaxed(save->intpol1, base + SA1111_INTPOL1); in sa1111_resume_noirq()
1096 writel_relaxed(save->inten0, base + SA1111_INTEN0); in sa1111_resume_noirq()
1097 writel_relaxed(save->inten1, base + SA1111_INTEN1); in sa1111_resume_noirq()
1098 writel_relaxed(save->wakepol0, base + SA1111_WAKEPOL0); in sa1111_resume_noirq()
1099 writel_relaxed(save->wakepol1, base + SA1111_WAKEPOL1); in sa1111_resume_noirq()
1100 writel_relaxed(save->wakeen0, base + SA1111_WAKEEN0); in sa1111_resume_noirq()
1101 writel_relaxed(save->wakeen1, base + SA1111_WAKEEN1); in sa1111_resume_noirq()
1103 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_resume_noirq()
1105 sachip->saved_state = NULL; in sa1111_resume_noirq()
1123 return -EINVAL; in sa1111_probe()
1128 return __sa1111_probe(&pdev->dev, mem, irq); in sa1111_probe()
1137 kfree(sachip->saved_state); in sa1111_remove()
1138 sachip->saved_state = NULL; in sa1111_remove()
1155 * the per-machine level, and then have this driver pick
1176 return (struct sa1111 *)dev_get_drvdata(sadev->dev.parent); in sa1111_chip_driver()
1180 * The bits in the opdiv field are non-linear.
1188 skcdr = readl_relaxed(sachip->base + SA1111_SKCDR); in __sa1111_pll_clock()
1198 * sa1111_pll_clock - return the current PLL clock frequency.
1215 * sa1111_select_audio_mode - select I2S or AC link mode
1219 * Frob the SKCR to select AC Link mode or I2S mode for
1228 spin_lock_irqsave(&sachip->lock, flags); in sa1111_select_audio_mode()
1230 val = readl_relaxed(sachip->base + SA1111_SKCR); in sa1111_select_audio_mode()
1236 writel_relaxed(val, sachip->base + SA1111_SKCR); in sa1111_select_audio_mode()
1238 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_select_audio_mode()
1243 * sa1111_set_audio_rate - set the audio sample rate
1252 if (sadev->devid != SA1111_DEVID_SAC) in sa1111_set_audio_rate()
1253 return -EINVAL; in sa1111_set_audio_rate()
1261 writel_relaxed(div - 1, sachip->base + SA1111_SKAUD); in sa1111_set_audio_rate()
1268 * sa1111_get_audio_rate - get the audio sample rate
1276 if (sadev->devid != SA1111_DEVID_SAC) in sa1111_get_audio_rate()
1277 return -EINVAL; in sa1111_get_audio_rate()
1279 div = readl_relaxed(sachip->base + SA1111_SKAUD) + 1; in sa1111_get_audio_rate()
1290 * sa1111_enable_device - enable an on-chip SA1111 function block
1300 if (sachip->pdata && sachip->pdata->enable) in sa1111_enable_device()
1301 ret = sachip->pdata->enable(sachip->pdata->data, sadev->devid); in sa1111_enable_device()
1304 spin_lock_irqsave(&sachip->lock, flags); in sa1111_enable_device()
1305 val = readl_relaxed(sachip->base + SA1111_SKPCR); in sa1111_enable_device()
1306 writel_relaxed(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR); in sa1111_enable_device()
1307 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_enable_device()
1314 * sa1111_disable_device - disable an on-chip SA1111 function block
1323 spin_lock_irqsave(&sachip->lock, flags); in sa1111_disable_device()
1324 val = readl_relaxed(sachip->base + SA1111_SKPCR); in sa1111_disable_device()
1325 writel_relaxed(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR); in sa1111_disable_device()
1326 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_disable_device()
1328 if (sachip->pdata && sachip->pdata->disable) in sa1111_disable_device()
1329 sachip->pdata->disable(sachip->pdata->data, sadev->devid); in sa1111_disable_device()
1336 if (num >= ARRAY_SIZE(sadev->hwirq)) in sa1111_get_irq()
1337 return -EINVAL; in sa1111_get_irq()
1338 return sa1111_map_irq(sachip, sadev->hwirq[num]); in sa1111_get_irq()
1353 return !!(dev->devid & drv->devid); in sa1111_match()
1359 struct sa1111_driver *drv = SA1111_DRV(dev->driver); in sa1111_bus_probe()
1360 int ret = -ENODEV; in sa1111_bus_probe()
1362 if (drv->probe) in sa1111_bus_probe()
1363 ret = drv->probe(sadev); in sa1111_bus_probe()
1370 struct sa1111_driver *drv = SA1111_DRV(dev->driver); in sa1111_bus_remove()
1373 if (drv->remove) in sa1111_bus_remove()
1374 ret = drv->remove(sadev); in sa1111_bus_remove()
1379 .name = "sa1111-rab",
1388 driver->drv.bus = &sa1111_bus_type; in sa1111_driver_register()
1389 return driver_register(&driver->drv); in sa1111_driver_register()
1395 driver_unregister(&driver->drv); in sa1111_driver_unregister()
1401 * According to the "Intel StrongARM SA-1111 Microprocessor Companion
1407 * of several different (processor-relative) address bits.
1418 * Section 4.6 of the "Intel StrongARM SA-1111 Development Module in sa1111_needs_bounce()
1420 * target of SA-1111 DMA (either SDRAM bank 0 on Assabet, or in sa1111_needs_bounce()
1435 if (dev->dev.dma_mask && dev->dma_mask < 0xffffffffUL) { in sa1111_notifier_call()
1436 int ret = dmabounce_register_dev(&dev->dev, 1024, 4096, in sa1111_notifier_call()
1439 dev_err(&dev->dev, "failed to register with dmabounce: %d\n", ret); in sa1111_notifier_call()
1444 if (dev->dev.dma_mask && dev->dma_mask < 0xffffffffUL) in sa1111_notifier_call()
1445 dmabounce_unregister_dev(&dev->dev); in sa1111_notifier_call()