Lines Matching refs:sachip

197 static int sa1111_map_irq(struct sa1111 *sachip, irq_hw_number_t hwirq)  in sa1111_map_irq()  argument
199 return irq_create_mapping(sachip->irqdomain, hwirq); in sa1111_map_irq()
210 struct sa1111 *sachip = irq_desc_get_handler_data(desc); in sa1111_irq_handler() local
212 void __iomem *mapbase = sachip->base + SA1111_INTC; in sa1111_irq_handler()
228 irqdomain = sachip->irqdomain; in sa1111_irq_handler()
258 struct sa1111 *sachip = irq_data_get_irq_chip_data(d); in sa1111_mask_irq() local
259 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_mask_irq()
269 struct sa1111 *sachip = irq_data_get_irq_chip_data(d); in sa1111_unmask_irq() local
270 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_unmask_irq()
287 struct sa1111 *sachip = irq_data_get_irq_chip_data(d); in sa1111_retrigger_irq() local
288 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_retrigger_irq()
311 struct sa1111 *sachip = irq_data_get_irq_chip_data(d); in sa1111_type_irq() local
312 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_type_irq()
334 struct sa1111 *sachip = irq_data_get_irq_chip_data(d); in sa1111_wake_irq() local
335 void __iomem *mapbase = sachip->base + SA1111_INTC + sa1111_irqbank(d); in sa1111_wake_irq()
361 struct sa1111 *sachip = d->host_data; in sa1111_irqdomain_map() local
367 irq_set_chip_data(irq, sachip); in sa1111_irqdomain_map()
379 static int sa1111_setup_irq(struct sa1111 *sachip, unsigned irq_base) in sa1111_setup_irq() argument
381 void __iomem *irqbase = sachip->base + SA1111_INTC; in sa1111_setup_irq()
387 request_mem_region(sachip->phys + SA1111_INTC, 512, "irq"); in sa1111_setup_irq()
391 dev_err(sachip->dev, "unable to allocate %u irqs: %d\n", in sa1111_setup_irq()
398 sachip->irq_base = ret; in sa1111_setup_irq()
419 sachip->irqdomain = irq_domain_add_linear(NULL, SA1111_IRQ_NR, in sa1111_setup_irq()
421 sachip); in sa1111_setup_irq()
422 if (!sachip->irqdomain) { in sa1111_setup_irq()
423 irq_free_descs(sachip->irq_base, SA1111_IRQ_NR); in sa1111_setup_irq()
427 irq_domain_associate_many(sachip->irqdomain, in sa1111_setup_irq()
428 sachip->irq_base + IRQ_GPAIN0, in sa1111_setup_irq()
430 irq_domain_associate_many(sachip->irqdomain, in sa1111_setup_irq()
431 sachip->irq_base + AUDXMTDMADONEA, in sa1111_setup_irq()
438 irq_set_irq_type(sachip->irq, IRQ_TYPE_EDGE_RISING); in sa1111_setup_irq()
439 irq_set_chained_handler_and_data(sachip->irq, sa1111_irq_handler, in sa1111_setup_irq()
440 sachip); in sa1111_setup_irq()
442 dev_info(sachip->dev, "Providing IRQ%u-%u\n", in sa1111_setup_irq()
443 sachip->irq_base, sachip->irq_base + SA1111_IRQ_NR - 1); in sa1111_setup_irq()
448 static void sa1111_remove_irq(struct sa1111 *sachip) in sa1111_remove_irq() argument
450 struct irq_domain *domain = sachip->irqdomain; in sa1111_remove_irq()
451 void __iomem *irqbase = sachip->base + SA1111_INTC; in sa1111_remove_irq()
460 irq_set_chained_handler_and_data(sachip->irq, NULL, NULL); in sa1111_remove_irq()
465 release_mem_region(sachip->phys + SA1111_INTC, 512); in sa1111_remove_irq()
481 static void __iomem *sa1111_gpio_map_reg(struct sa1111 *sachip, unsigned offset) in sa1111_gpio_map_reg() argument
483 void __iomem *reg = sachip->base + SA1111_GPIO; in sa1111_gpio_map_reg()
517 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_get_direction() local
518 void __iomem *reg = sa1111_gpio_map_reg(sachip, offset); in sa1111_gpio_get_direction()
526 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_direction_input() local
528 void __iomem *reg = sa1111_gpio_map_reg(sachip, offset); in sa1111_gpio_direction_input()
531 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_direction_input()
534 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_direction_input()
542 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_direction_output() local
544 void __iomem *reg = sa1111_gpio_map_reg(sachip, offset); in sa1111_gpio_direction_output()
547 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_direction_output()
552 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_direction_output()
559 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_get() local
560 void __iomem *reg = sa1111_gpio_map_reg(sachip, offset); in sa1111_gpio_get()
568 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_set() local
570 void __iomem *reg = sa1111_gpio_map_reg(sachip, offset); in sa1111_gpio_set()
573 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_set()
576 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_set()
582 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_set_multiple() local
584 void __iomem *reg = sachip->base + SA1111_GPIO; in sa1111_gpio_set_multiple()
590 spin_lock_irqsave(&sachip->lock, flags); in sa1111_gpio_set_multiple()
597 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_gpio_set_multiple()
602 struct sa1111 *sachip = gc_to_sa1111(gc); in sa1111_gpio_to_irq() local
604 return sa1111_map_irq(sachip, offset); in sa1111_gpio_to_irq()
607 static int sa1111_setup_gpios(struct sa1111 *sachip) in sa1111_setup_gpios() argument
609 sachip->gc.label = "sa1111"; in sa1111_setup_gpios()
610 sachip->gc.parent = sachip->dev; in sa1111_setup_gpios()
611 sachip->gc.owner = THIS_MODULE; in sa1111_setup_gpios()
612 sachip->gc.get_direction = sa1111_gpio_get_direction; in sa1111_setup_gpios()
613 sachip->gc.direction_input = sa1111_gpio_direction_input; in sa1111_setup_gpios()
614 sachip->gc.direction_output = sa1111_gpio_direction_output; in sa1111_setup_gpios()
615 sachip->gc.get = sa1111_gpio_get; in sa1111_setup_gpios()
616 sachip->gc.set = sa1111_gpio_set; in sa1111_setup_gpios()
617 sachip->gc.set_multiple = sa1111_gpio_set_multiple; in sa1111_setup_gpios()
618 sachip->gc.to_irq = sa1111_gpio_to_irq; in sa1111_setup_gpios()
619 sachip->gc.base = -1; in sa1111_setup_gpios()
620 sachip->gc.ngpio = 18; in sa1111_setup_gpios()
622 return devm_gpiochip_add_data(sachip->dev, &sachip->gc, sachip); in sa1111_setup_gpios()
639 static void sa1111_wake(struct sa1111 *sachip) in sa1111_wake() argument
643 spin_lock_irqsave(&sachip->lock, flags); in sa1111_wake()
645 clk_enable(sachip->clk); in sa1111_wake()
650 r = readl_relaxed(sachip->base + SA1111_SKCR); in sa1111_wake()
652 writel_relaxed(r, sachip->base + SA1111_SKCR); in sa1111_wake()
654 writel_relaxed(r, sachip->base + SA1111_SKCR); in sa1111_wake()
666 writel_relaxed(r, sachip->base + SA1111_SKCR); in sa1111_wake()
677 writel_relaxed(0, sachip->base + SA1111_SKPCR); in sa1111_wake()
679 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_wake()
699 sa1111_configure_smc(struct sa1111 *sachip, int sdram, unsigned int drac, in sa1111_configure_smc() argument
707 writel_relaxed(smcr, sachip->base + SA1111_SMCR); in sa1111_configure_smc()
714 if (sachip->dev->dma_mask) in sa1111_configure_smc()
715 *sachip->dev->dma_mask &= sa1111_dma_mask[drac >> 2]; in sa1111_configure_smc()
717 sachip->dev->coherent_dma_mask &= sa1111_dma_mask[drac >> 2]; in sa1111_configure_smc()
729 sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, in sa1111_init_one_child() argument
745 dev->dev.parent = sachip->dev; in sa1111_init_one_child()
748 dev->res.start = sachip->phys + info->offset; in sa1111_init_one_child()
752 dev->mapbase = sachip->base + info->offset; in sa1111_init_one_child()
762 if (info->dma && sachip->dev->dma_mask) { in sa1111_init_one_child()
763 dev->dma_mask = *sachip->dev->dma_mask; in sa1111_init_one_child()
765 dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask; in sa1111_init_one_child()
770 dev_err(sachip->dev, "failed to allocate resource for %s\n", in sa1111_init_one_child()
791 struct sa1111 *sachip; in __sa1111_probe() local
799 sachip = devm_kzalloc(me, sizeof(struct sa1111), GFP_KERNEL); in __sa1111_probe()
800 if (!sachip) in __sa1111_probe()
803 sachip->clk = devm_clk_get(me, "SA1111_CLK"); in __sa1111_probe()
804 if (IS_ERR(sachip->clk)) in __sa1111_probe()
805 return PTR_ERR(sachip->clk); in __sa1111_probe()
807 ret = clk_prepare(sachip->clk); in __sa1111_probe()
811 spin_lock_init(&sachip->lock); in __sa1111_probe()
813 sachip->dev = me; in __sa1111_probe()
814 dev_set_drvdata(sachip->dev, sachip); in __sa1111_probe()
816 sachip->pdata = pd; in __sa1111_probe()
817 sachip->phys = mem->start; in __sa1111_probe()
818 sachip->irq = irq; in __sa1111_probe()
824 sachip->base = ioremap(mem->start, PAGE_SIZE * 2); in __sa1111_probe()
825 if (!sachip->base) { in __sa1111_probe()
833 id = readl_relaxed(sachip->base + SA1111_SKID); in __sa1111_probe()
846 sa1111_wake(sachip); in __sa1111_probe()
852 ret = sa1111_setup_irq(sachip, pd->irq_base); in __sa1111_probe()
857 ret = sa1111_setup_gpios(sachip); in __sa1111_probe()
872 sa1111_configure_smc(sachip, 1, in __sa1111_probe()
881 val = readl_relaxed(sachip->base + SA1111_SKPCR); in __sa1111_probe()
882 writel_relaxed(val | SKPCR_DCLKEN, sachip->base + SA1111_SKPCR); in __sa1111_probe()
891 g_sa1111 = sachip; in __sa1111_probe()
899 sa1111_init_one_child(sachip, mem, &sa1111_devices[i]); in __sa1111_probe()
904 sa1111_remove_irq(sachip); in __sa1111_probe()
906 clk_disable(sachip->clk); in __sa1111_probe()
908 iounmap(sachip->base); in __sa1111_probe()
910 clk_unprepare(sachip->clk); in __sa1111_probe()
925 static void __sa1111_remove(struct sa1111 *sachip) in __sa1111_remove() argument
927 device_for_each_child(sachip->dev, NULL, sa1111_remove_one); in __sa1111_remove()
929 sa1111_remove_irq(sachip); in __sa1111_remove()
931 clk_disable(sachip->clk); in __sa1111_remove()
932 clk_unprepare(sachip->clk); in __sa1111_remove()
934 iounmap(sachip->base); in __sa1111_remove()
962 struct sa1111 *sachip = dev_get_drvdata(dev); in sa1111_suspend_noirq() local
971 sachip->saved_state = save; in sa1111_suspend_noirq()
973 spin_lock_irqsave(&sachip->lock, flags); in sa1111_suspend_noirq()
978 base = sachip->base; in sa1111_suspend_noirq()
986 writel_relaxed(0, sachip->base + SA1111_SKPWM0); in sa1111_suspend_noirq()
987 writel_relaxed(0, sachip->base + SA1111_SKPWM1); in sa1111_suspend_noirq()
989 base = sachip->base + SA1111_INTC; in sa1111_suspend_noirq()
1002 val = readl_relaxed(sachip->base + SA1111_SKCR); in sa1111_suspend_noirq()
1003 writel_relaxed(val | SKCR_SLEEP, sachip->base + SA1111_SKCR); in sa1111_suspend_noirq()
1005 clk_disable(sachip->clk); in sa1111_suspend_noirq()
1007 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_suspend_noirq()
1027 struct sa1111 *sachip = dev_get_drvdata(dev); in sa1111_resume_noirq() local
1032 save = sachip->saved_state; in sa1111_resume_noirq()
1040 id = readl_relaxed(sachip->base + SA1111_SKID); in sa1111_resume_noirq()
1042 __sa1111_remove(sachip); in sa1111_resume_noirq()
1051 sa1111_wake(sachip); in sa1111_resume_noirq()
1062 spin_lock_irqsave(&sachip->lock, flags); in sa1111_resume_noirq()
1064 writel_relaxed(0, sachip->base + SA1111_INTC + SA1111_INTEN0); in sa1111_resume_noirq()
1065 writel_relaxed(0, sachip->base + SA1111_INTC + SA1111_INTEN1); in sa1111_resume_noirq()
1067 base = sachip->base; in sa1111_resume_noirq()
1075 base = sachip->base + SA1111_INTC; in sa1111_resume_noirq()
1085 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_resume_noirq()
1087 sachip->saved_state = NULL; in sa1111_resume_noirq()
1129 struct sa1111 *sachip = platform_get_drvdata(pdev); in sa1111_remove() local
1131 if (sachip) { in sa1111_remove()
1133 kfree(sachip->saved_state); in sa1111_remove()
1134 sachip->saved_state = NULL; in sa1111_remove()
1136 __sa1111_remove(sachip); in sa1111_remove()
1178 static unsigned int __sa1111_pll_clock(struct sa1111 *sachip) in __sa1111_pll_clock() argument
1182 skcdr = readl_relaxed(sachip->base + SA1111_SKCDR); in __sa1111_pll_clock()
1202 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_pll_clock() local
1204 return __sa1111_pll_clock(sachip); in sa1111_pll_clock()
1218 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_select_audio_mode() local
1222 spin_lock_irqsave(&sachip->lock, flags); in sa1111_select_audio_mode()
1224 val = readl_relaxed(sachip->base + SA1111_SKCR); in sa1111_select_audio_mode()
1230 writel_relaxed(val, sachip->base + SA1111_SKCR); in sa1111_select_audio_mode()
1232 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_select_audio_mode()
1243 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_set_audio_rate() local
1249 div = (__sa1111_pll_clock(sachip) / 256 + rate / 2) / rate; in sa1111_set_audio_rate()
1255 writel_relaxed(div - 1, sachip->base + SA1111_SKAUD); in sa1111_set_audio_rate()
1267 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_get_audio_rate() local
1273 div = readl_relaxed(sachip->base + SA1111_SKAUD) + 1; in sa1111_get_audio_rate()
1275 return __sa1111_pll_clock(sachip) / (256 * div); in sa1111_get_audio_rate()
1289 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_enable_device() local
1294 if (sachip->pdata && sachip->pdata->enable) in sa1111_enable_device()
1295 ret = sachip->pdata->enable(sachip->pdata->data, sadev->devid); in sa1111_enable_device()
1298 spin_lock_irqsave(&sachip->lock, flags); in sa1111_enable_device()
1299 val = readl_relaxed(sachip->base + SA1111_SKPCR); in sa1111_enable_device()
1300 writel_relaxed(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR); in sa1111_enable_device()
1301 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_enable_device()
1313 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_disable_device() local
1317 spin_lock_irqsave(&sachip->lock, flags); in sa1111_disable_device()
1318 val = readl_relaxed(sachip->base + SA1111_SKPCR); in sa1111_disable_device()
1319 writel_relaxed(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR); in sa1111_disable_device()
1320 spin_unlock_irqrestore(&sachip->lock, flags); in sa1111_disable_device()
1322 if (sachip->pdata && sachip->pdata->disable) in sa1111_disable_device()
1323 sachip->pdata->disable(sachip->pdata->data, sadev->devid); in sa1111_disable_device()
1329 struct sa1111 *sachip = sa1111_chip_driver(sadev); in sa1111_get_irq() local
1332 return sa1111_map_irq(sachip, sadev->hwirq[num]); in sa1111_get_irq()