1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
20a84a91cSTero Kristo /*
30a84a91cSTero Kristo * OMAP2+ common Power & Reset Management (PRM) IP block functions
40a84a91cSTero Kristo *
50a84a91cSTero Kristo * Copyright (C) 2011 Texas Instruments, Inc.
60a84a91cSTero Kristo * Tero Kristo <t-kristo@ti.com>
70a84a91cSTero Kristo *
80a84a91cSTero Kristo * For historical purposes, the API used to configure the PRM
90a84a91cSTero Kristo * interrupt handler refers to it as the "PRCM interrupt." The
100a84a91cSTero Kristo * underlying registers are located in the PRM on OMAP3/4.
110a84a91cSTero Kristo *
120a84a91cSTero Kristo * XXX This code should eventually be moved to a PRM driver.
130a84a91cSTero Kristo */
140a84a91cSTero Kristo
150a84a91cSTero Kristo #include <linux/kernel.h>
160a84a91cSTero Kristo #include <linux/module.h>
170a84a91cSTero Kristo #include <linux/init.h>
180a84a91cSTero Kristo #include <linux/io.h>
190a84a91cSTero Kristo #include <linux/irq.h>
200a84a91cSTero Kristo #include <linux/interrupt.h>
210a84a91cSTero Kristo #include <linux/slab.h>
22943a63a4STero Kristo #include <linux/of.h>
23943a63a4STero Kristo #include <linux/of_address.h>
24943a63a4STero Kristo #include <linux/clk-provider.h>
25943a63a4STero Kristo #include <linux/clk/ti.h>
260a84a91cSTero Kristo
2730a69ef7STony Lindgren #include "soc.h"
280a84a91cSTero Kristo #include "prm2xxx_3xxx.h"
292bb2a5d3SPaul Walmsley #include "prm2xxx.h"
302bb2a5d3SPaul Walmsley #include "prm3xxx.h"
31ab7b2ffcSTero Kristo #include "prm33xx.h"
320a84a91cSTero Kristo #include "prm44xx.h"
3348e0c114STero Kristo #include "prm54xx.h"
3448e0c114STero Kristo #include "prm7xx.h"
3548e0c114STero Kristo #include "prcm43xx.h"
36d9a16f9aSPaul Walmsley #include "common.h"
37943a63a4STero Kristo #include "clock.h"
383dbb048bSTero Kristo #include "cm.h"
393dbb048bSTero Kristo #include "control.h"
400a84a91cSTero Kristo
410a84a91cSTero Kristo /*
420a84a91cSTero Kristo * OMAP_PRCM_MAX_NR_PENDING_REG: maximum number of PRM_IRQ*_MPU regs
430a84a91cSTero Kristo * XXX this is technically not needed, since
440a84a91cSTero Kristo * omap_prcm_register_chain_handler() could allocate this based on the
450a84a91cSTero Kristo * actual amount of memory needed for the SoC
460a84a91cSTero Kristo */
470a84a91cSTero Kristo #define OMAP_PRCM_MAX_NR_PENDING_REG 2
480a84a91cSTero Kristo
490a84a91cSTero Kristo /*
500a84a91cSTero Kristo * prcm_irq_chips: an array of all of the "generic IRQ chips" in use
510a84a91cSTero Kristo * by the PRCM interrupt handler code. There will be one 'chip' per
520a84a91cSTero Kristo * PRM_{IRQSTATUS,IRQENABLE}_MPU register pair. (So OMAP3 will have
530a84a91cSTero Kristo * one "chip" and OMAP4 will have two.)
540a84a91cSTero Kristo */
550a84a91cSTero Kristo static struct irq_chip_generic **prcm_irq_chips;
560a84a91cSTero Kristo
570a84a91cSTero Kristo /*
580a84a91cSTero Kristo * prcm_irq_setup: the PRCM IRQ parameters for the hardware the code
590a84a91cSTero Kristo * is currently running on. Defined and passed by initialization code
600a84a91cSTero Kristo * that calls omap_prcm_register_chain_handler().
610a84a91cSTero Kristo */
620a84a91cSTero Kristo static struct omap_prcm_irq_setup *prcm_irq_setup;
630a84a91cSTero Kristo
64d9a16f9aSPaul Walmsley /* prm_base: base virtual address of the PRM IP block */
6590129336STero Kristo struct omap_domain_base prm_base;
66d9a16f9aSPaul Walmsley
672541d15fSTero Kristo u16 prm_features;
682541d15fSTero Kristo
69e24c3573SPaul Walmsley /*
70*6521f6a1SAlexander Sverdlin * Platforms that implement different reboot modes can store the requested
71*6521f6a1SAlexander Sverdlin * mode here.
72*6521f6a1SAlexander Sverdlin */
73*6521f6a1SAlexander Sverdlin enum reboot_mode prm_reboot_mode;
74*6521f6a1SAlexander Sverdlin
75*6521f6a1SAlexander Sverdlin /*
76e24c3573SPaul Walmsley * prm_ll_data: function pointers to SoC-specific implementations of
77e24c3573SPaul Walmsley * common PRM functions
78e24c3573SPaul Walmsley */
79e24c3573SPaul Walmsley static struct prm_ll_data null_prm_ll_data;
80e24c3573SPaul Walmsley static struct prm_ll_data *prm_ll_data = &null_prm_ll_data;
81e24c3573SPaul Walmsley
820a84a91cSTero Kristo /* Private functions */
830a84a91cSTero Kristo
840a84a91cSTero Kristo /*
850a84a91cSTero Kristo * Move priority events from events to priority_events array
860a84a91cSTero Kristo */
omap_prcm_events_filter_priority(unsigned long * events,unsigned long * priority_events)870a84a91cSTero Kristo static void omap_prcm_events_filter_priority(unsigned long *events,
880a84a91cSTero Kristo unsigned long *priority_events)
890a84a91cSTero Kristo {
900a84a91cSTero Kristo int i;
910a84a91cSTero Kristo
920a84a91cSTero Kristo for (i = 0; i < prcm_irq_setup->nr_regs; i++) {
930a84a91cSTero Kristo priority_events[i] =
940a84a91cSTero Kristo events[i] & prcm_irq_setup->priority_mask[i];
950a84a91cSTero Kristo events[i] ^= priority_events[i];
960a84a91cSTero Kristo }
970a84a91cSTero Kristo }
980a84a91cSTero Kristo
990a84a91cSTero Kristo /*
1000a84a91cSTero Kristo * PRCM Interrupt Handler
1010a84a91cSTero Kristo *
1020a84a91cSTero Kristo * This is a common handler for the OMAP PRCM interrupts. Pending
1030a84a91cSTero Kristo * interrupts are detected by a call to prcm_pending_events and
1040a84a91cSTero Kristo * dispatched accordingly. Clearing of the wakeup events should be
1050a84a91cSTero Kristo * done by the SoC specific individual handlers.
1060a84a91cSTero Kristo */
omap_prcm_irq_handler(struct irq_desc * desc)107bd0b9ac4SThomas Gleixner static void omap_prcm_irq_handler(struct irq_desc *desc)
1080a84a91cSTero Kristo {
1090a84a91cSTero Kristo unsigned long pending[OMAP_PRCM_MAX_NR_PENDING_REG];
1100a84a91cSTero Kristo unsigned long priority_pending[OMAP_PRCM_MAX_NR_PENDING_REG];
1110a84a91cSTero Kristo struct irq_chip *chip = irq_desc_get_chip(desc);
1120a84a91cSTero Kristo unsigned int virtirq;
113b56f2cb7SVenkatraman S int nr_irq = prcm_irq_setup->nr_regs * 32;
1140a84a91cSTero Kristo
1150a84a91cSTero Kristo /*
11691285b6fSTero Kristo * If we are suspended, mask all interrupts from PRCM level,
11791285b6fSTero Kristo * this does not ack them, and they will be pending until we
11891285b6fSTero Kristo * re-enable the interrupts, at which point the
11991285b6fSTero Kristo * omap_prcm_irq_handler will be executed again. The
12091285b6fSTero Kristo * _save_and_clear_irqen() function must ensure that the PRM
12191285b6fSTero Kristo * write to disable all IRQs has reached the PRM before
12291285b6fSTero Kristo * returning, or spurious PRCM interrupts may occur during
12391285b6fSTero Kristo * suspend.
12491285b6fSTero Kristo */
12591285b6fSTero Kristo if (prcm_irq_setup->suspended) {
12691285b6fSTero Kristo prcm_irq_setup->save_and_clear_irqen(prcm_irq_setup->saved_mask);
12791285b6fSTero Kristo prcm_irq_setup->suspend_save_flag = true;
12891285b6fSTero Kristo }
12991285b6fSTero Kristo
13091285b6fSTero Kristo /*
1310a84a91cSTero Kristo * Loop until all pending irqs are handled, since
1320a84a91cSTero Kristo * generic_handle_irq() can cause new irqs to come
1330a84a91cSTero Kristo */
13491285b6fSTero Kristo while (!prcm_irq_setup->suspended) {
1350a84a91cSTero Kristo prcm_irq_setup->read_pending_irqs(pending);
1360a84a91cSTero Kristo
1370a84a91cSTero Kristo /* No bit set, then all IRQs are handled */
138b56f2cb7SVenkatraman S if (find_first_bit(pending, nr_irq) >= nr_irq)
1390a84a91cSTero Kristo break;
1400a84a91cSTero Kristo
1410a84a91cSTero Kristo omap_prcm_events_filter_priority(pending, priority_pending);
1420a84a91cSTero Kristo
1430a84a91cSTero Kristo /*
1440a84a91cSTero Kristo * Loop on all currently pending irqs so that new irqs
1450a84a91cSTero Kristo * cannot starve previously pending irqs
1460a84a91cSTero Kristo */
1470a84a91cSTero Kristo
1480a84a91cSTero Kristo /* Serve priority events first */
149b56f2cb7SVenkatraman S for_each_set_bit(virtirq, priority_pending, nr_irq)
1500a84a91cSTero Kristo generic_handle_irq(prcm_irq_setup->base_irq + virtirq);
1510a84a91cSTero Kristo
1520a84a91cSTero Kristo /* Serve normal events next */
153b56f2cb7SVenkatraman S for_each_set_bit(virtirq, pending, nr_irq)
1540a84a91cSTero Kristo generic_handle_irq(prcm_irq_setup->base_irq + virtirq);
1550a84a91cSTero Kristo }
1560a84a91cSTero Kristo if (chip->irq_ack)
1570a84a91cSTero Kristo chip->irq_ack(&desc->irq_data);
1580a84a91cSTero Kristo if (chip->irq_eoi)
1590a84a91cSTero Kristo chip->irq_eoi(&desc->irq_data);
1600a84a91cSTero Kristo chip->irq_unmask(&desc->irq_data);
1610a84a91cSTero Kristo
1620a84a91cSTero Kristo prcm_irq_setup->ocp_barrier(); /* avoid spurious IRQs */
1630a84a91cSTero Kristo }
1640a84a91cSTero Kristo
1650a84a91cSTero Kristo /* Public functions */
1660a84a91cSTero Kristo
1670a84a91cSTero Kristo /**
1680a84a91cSTero Kristo * omap_prcm_event_to_irq - given a PRCM event name, returns the
1690a84a91cSTero Kristo * corresponding IRQ on which the handler should be registered
1700a84a91cSTero Kristo * @name: name of the PRCM interrupt bit to look up - see struct omap_prcm_irq
1710a84a91cSTero Kristo *
1720a84a91cSTero Kristo * Returns the Linux internal IRQ ID corresponding to @name upon success,
1730a84a91cSTero Kristo * or -ENOENT upon failure.
1740a84a91cSTero Kristo */
omap_prcm_event_to_irq(const char * name)1750a84a91cSTero Kristo int omap_prcm_event_to_irq(const char *name)
1760a84a91cSTero Kristo {
1770a84a91cSTero Kristo int i;
1780a84a91cSTero Kristo
1790a84a91cSTero Kristo if (!prcm_irq_setup || !name)
1800a84a91cSTero Kristo return -ENOENT;
1810a84a91cSTero Kristo
1820a84a91cSTero Kristo for (i = 0; i < prcm_irq_setup->nr_irqs; i++)
1830a84a91cSTero Kristo if (!strcmp(prcm_irq_setup->irqs[i].name, name))
1840a84a91cSTero Kristo return prcm_irq_setup->base_irq +
1850a84a91cSTero Kristo prcm_irq_setup->irqs[i].offset;
1860a84a91cSTero Kristo
1870a84a91cSTero Kristo return -ENOENT;
1880a84a91cSTero Kristo }
1890a84a91cSTero Kristo
1900a84a91cSTero Kristo /**
1910a84a91cSTero Kristo * omap_prcm_irq_cleanup - reverses memory allocated and other steps
1920a84a91cSTero Kristo * done by omap_prcm_register_chain_handler()
1930a84a91cSTero Kristo *
1940a84a91cSTero Kristo * No return value.
1950a84a91cSTero Kristo */
omap_prcm_irq_cleanup(void)1966aeb51c1SArnd Bergmann static void omap_prcm_irq_cleanup(void)
1970a84a91cSTero Kristo {
1980fb22a8fSMarc Zyngier unsigned int irq;
1990a84a91cSTero Kristo int i;
2000a84a91cSTero Kristo
2010a84a91cSTero Kristo if (!prcm_irq_setup) {
2020a84a91cSTero Kristo pr_err("PRCM: IRQ handler not initialized; cannot cleanup\n");
2030a84a91cSTero Kristo return;
2040a84a91cSTero Kristo }
2050a84a91cSTero Kristo
2060a84a91cSTero Kristo if (prcm_irq_chips) {
2070a84a91cSTero Kristo for (i = 0; i < prcm_irq_setup->nr_regs; i++) {
2080a84a91cSTero Kristo if (prcm_irq_chips[i])
2090a84a91cSTero Kristo irq_remove_generic_chip(prcm_irq_chips[i],
2100a84a91cSTero Kristo 0xffffffff, 0, 0);
2110a84a91cSTero Kristo prcm_irq_chips[i] = NULL;
2120a84a91cSTero Kristo }
2130a84a91cSTero Kristo kfree(prcm_irq_chips);
2140a84a91cSTero Kristo prcm_irq_chips = NULL;
2150a84a91cSTero Kristo }
2160a84a91cSTero Kristo
21791285b6fSTero Kristo kfree(prcm_irq_setup->saved_mask);
21891285b6fSTero Kristo prcm_irq_setup->saved_mask = NULL;
21991285b6fSTero Kristo
2200a84a91cSTero Kristo kfree(prcm_irq_setup->priority_mask);
2210a84a91cSTero Kristo prcm_irq_setup->priority_mask = NULL;
2220a84a91cSTero Kristo
2230fb22a8fSMarc Zyngier irq = prcm_irq_setup->irq;
2240fb22a8fSMarc Zyngier irq_set_chained_handler(irq, NULL);
2250a84a91cSTero Kristo
2260a84a91cSTero Kristo if (prcm_irq_setup->base_irq > 0)
2270a84a91cSTero Kristo irq_free_descs(prcm_irq_setup->base_irq,
2280a84a91cSTero Kristo prcm_irq_setup->nr_regs * 32);
2290a84a91cSTero Kristo prcm_irq_setup->base_irq = 0;
2300a84a91cSTero Kristo }
2310a84a91cSTero Kristo
omap_prcm_irq_prepare(void)23291285b6fSTero Kristo void omap_prcm_irq_prepare(void)
23391285b6fSTero Kristo {
23491285b6fSTero Kristo prcm_irq_setup->suspended = true;
23591285b6fSTero Kristo }
23691285b6fSTero Kristo
omap_prcm_irq_complete(void)23791285b6fSTero Kristo void omap_prcm_irq_complete(void)
23891285b6fSTero Kristo {
23991285b6fSTero Kristo prcm_irq_setup->suspended = false;
24091285b6fSTero Kristo
24191285b6fSTero Kristo /* If we have not saved the masks, do not attempt to restore */
24291285b6fSTero Kristo if (!prcm_irq_setup->suspend_save_flag)
24391285b6fSTero Kristo return;
24491285b6fSTero Kristo
24591285b6fSTero Kristo prcm_irq_setup->suspend_save_flag = false;
24691285b6fSTero Kristo
24791285b6fSTero Kristo /*
24891285b6fSTero Kristo * Re-enable all masked PRCM irq sources, this causes the PRCM
24991285b6fSTero Kristo * interrupt to fire immediately if the events were masked
25091285b6fSTero Kristo * previously in the chain handler
25191285b6fSTero Kristo */
25291285b6fSTero Kristo prcm_irq_setup->restore_irqen(prcm_irq_setup->saved_mask);
25391285b6fSTero Kristo }
25491285b6fSTero Kristo
2550a84a91cSTero Kristo /**
2560a84a91cSTero Kristo * omap_prcm_register_chain_handler - initializes the prcm chained interrupt
2570a84a91cSTero Kristo * handler based on provided parameters
2580a84a91cSTero Kristo * @irq_setup: hardware data about the underlying PRM/PRCM
2590a84a91cSTero Kristo *
2600a84a91cSTero Kristo * Set up the PRCM chained interrupt handler on the PRCM IRQ. Sets up
2610a84a91cSTero Kristo * one generic IRQ chip per PRM interrupt status/enable register pair.
2620a84a91cSTero Kristo * Returns 0 upon success, -EINVAL if called twice or if invalid
2630a84a91cSTero Kristo * arguments are passed, or -ENOMEM on any other error.
2640a84a91cSTero Kristo */
omap_prcm_register_chain_handler(struct omap_prcm_irq_setup * irq_setup)2650a84a91cSTero Kristo int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
2660a84a91cSTero Kristo {
267eeb3711bSPaul Walmsley int nr_regs;
2680a84a91cSTero Kristo u32 mask[OMAP_PRCM_MAX_NR_PENDING_REG];
2692a26d31bSTony Lindgren int offset, i, irq;
2700a84a91cSTero Kristo struct irq_chip_generic *gc;
2710a84a91cSTero Kristo struct irq_chip_type *ct;
2720a84a91cSTero Kristo
2730a84a91cSTero Kristo if (!irq_setup)
2740a84a91cSTero Kristo return -EINVAL;
2750a84a91cSTero Kristo
276eeb3711bSPaul Walmsley nr_regs = irq_setup->nr_regs;
277eeb3711bSPaul Walmsley
2780a84a91cSTero Kristo if (prcm_irq_setup) {
2790a84a91cSTero Kristo pr_err("PRCM: already initialized; won't reinitialize\n");
2800a84a91cSTero Kristo return -EINVAL;
2810a84a91cSTero Kristo }
2820a84a91cSTero Kristo
2830a84a91cSTero Kristo if (nr_regs > OMAP_PRCM_MAX_NR_PENDING_REG) {
2840a84a91cSTero Kristo pr_err("PRCM: nr_regs too large\n");
2850a84a91cSTero Kristo return -EINVAL;
2860a84a91cSTero Kristo }
2870a84a91cSTero Kristo
2880a84a91cSTero Kristo prcm_irq_setup = irq_setup;
2890a84a91cSTero Kristo
2906396bb22SKees Cook prcm_irq_chips = kcalloc(nr_regs, sizeof(void *), GFP_KERNEL);
2916396bb22SKees Cook prcm_irq_setup->saved_mask = kcalloc(nr_regs, sizeof(u32),
2926396bb22SKees Cook GFP_KERNEL);
2936396bb22SKees Cook prcm_irq_setup->priority_mask = kcalloc(nr_regs, sizeof(u32),
2940a84a91cSTero Kristo GFP_KERNEL);
2950a84a91cSTero Kristo
29691285b6fSTero Kristo if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
2979a6b6f75SMarkus Elfring !prcm_irq_setup->priority_mask)
2980a84a91cSTero Kristo goto err;
2990a84a91cSTero Kristo
3000a84a91cSTero Kristo memset(mask, 0, sizeof(mask));
3010a84a91cSTero Kristo
3020a84a91cSTero Kristo for (i = 0; i < irq_setup->nr_irqs; i++) {
3030a84a91cSTero Kristo offset = irq_setup->irqs[i].offset;
3040a84a91cSTero Kristo mask[offset >> 5] |= 1 << (offset & 0x1f);
3050a84a91cSTero Kristo if (irq_setup->irqs[i].priority)
3060a84a91cSTero Kristo irq_setup->priority_mask[offset >> 5] |=
3070a84a91cSTero Kristo 1 << (offset & 0x1f);
3080a84a91cSTero Kristo }
3090a84a91cSTero Kristo
3100fb22a8fSMarc Zyngier irq = irq_setup->irq;
3110fb22a8fSMarc Zyngier irq_set_chained_handler(irq, omap_prcm_irq_handler);
3120a84a91cSTero Kristo
3130a84a91cSTero Kristo irq_setup->base_irq = irq_alloc_descs(-1, 0, irq_setup->nr_regs * 32,
3140a84a91cSTero Kristo 0);
3150a84a91cSTero Kristo
3160a84a91cSTero Kristo if (irq_setup->base_irq < 0) {
3170a84a91cSTero Kristo pr_err("PRCM: failed to allocate irq descs: %d\n",
3180a84a91cSTero Kristo irq_setup->base_irq);
3190a84a91cSTero Kristo goto err;
3200a84a91cSTero Kristo }
3210a84a91cSTero Kristo
3224ba7c3c3SMing Lei for (i = 0; i < irq_setup->nr_regs; i++) {
3230a84a91cSTero Kristo gc = irq_alloc_generic_chip("PRCM", 1,
32490129336STero Kristo irq_setup->base_irq + i * 32, prm_base.va,
3250a84a91cSTero Kristo handle_level_irq);
3260a84a91cSTero Kristo
3270a84a91cSTero Kristo if (!gc) {
3280a84a91cSTero Kristo pr_err("PRCM: failed to allocate generic chip\n");
3290a84a91cSTero Kristo goto err;
3300a84a91cSTero Kristo }
3310a84a91cSTero Kristo ct = gc->chip_types;
3320a84a91cSTero Kristo ct->chip.irq_ack = irq_gc_ack_set_bit;
3330a84a91cSTero Kristo ct->chip.irq_mask = irq_gc_mask_clr_bit;
3340a84a91cSTero Kristo ct->chip.irq_unmask = irq_gc_mask_set_bit;
3350a84a91cSTero Kristo
3360a84a91cSTero Kristo ct->regs.ack = irq_setup->ack + i * 4;
3370a84a91cSTero Kristo ct->regs.mask = irq_setup->mask + i * 4;
3380a84a91cSTero Kristo
3390a84a91cSTero Kristo irq_setup_generic_chip(gc, mask[i], 0, IRQ_NOREQUEST, 0);
3400a84a91cSTero Kristo prcm_irq_chips[i] = gc;
3410a84a91cSTero Kristo }
3420a84a91cSTero Kristo
3432a26d31bSTony Lindgren irq = omap_prcm_event_to_irq("io");
34481243651STero Kristo omap_pcs_legacy_init(irq, irq_setup->reconfigure_io_chain);
34530a69ef7STony Lindgren
3460a84a91cSTero Kristo return 0;
3470a84a91cSTero Kristo
3480a84a91cSTero Kristo err:
3490a84a91cSTero Kristo omap_prcm_irq_cleanup();
3500a84a91cSTero Kristo return -ENOMEM;
3510a84a91cSTero Kristo }
3523f4990f4SR Sricharan
353e24c3573SPaul Walmsley /**
354e6d3a8b0SRajendra Nayak * prm_was_any_context_lost_old - was device context lost? (old API)
355e6d3a8b0SRajendra Nayak * @part: PRM partition ID (e.g., OMAP4430_PRM_PARTITION)
356e6d3a8b0SRajendra Nayak * @inst: PRM instance offset (e.g., OMAP4430_PRM_MPU_INST)
357e6d3a8b0SRajendra Nayak * @idx: CONTEXT register offset
358e6d3a8b0SRajendra Nayak *
359e6d3a8b0SRajendra Nayak * Return 1 if any bits were set in the *_CONTEXT_* register
360e6d3a8b0SRajendra Nayak * identified by (@part, @inst, @idx), which means that some context
361e6d3a8b0SRajendra Nayak * was lost for that module; otherwise, return 0. XXX Deprecated;
362e6d3a8b0SRajendra Nayak * callers need to use a less-SoC-dependent way to identify hardware
363e6d3a8b0SRajendra Nayak * IP blocks.
364e6d3a8b0SRajendra Nayak */
prm_was_any_context_lost_old(u8 part,s16 inst,u16 idx)365e6d3a8b0SRajendra Nayak bool prm_was_any_context_lost_old(u8 part, s16 inst, u16 idx)
366e6d3a8b0SRajendra Nayak {
367e6d3a8b0SRajendra Nayak bool ret = true;
368e6d3a8b0SRajendra Nayak
369e6d3a8b0SRajendra Nayak if (prm_ll_data->was_any_context_lost_old)
370e6d3a8b0SRajendra Nayak ret = prm_ll_data->was_any_context_lost_old(part, inst, idx);
371e6d3a8b0SRajendra Nayak else
372e6d3a8b0SRajendra Nayak WARN_ONCE(1, "prm: %s: no mapping function defined\n",
373e6d3a8b0SRajendra Nayak __func__);
374e6d3a8b0SRajendra Nayak
375e6d3a8b0SRajendra Nayak return ret;
376e6d3a8b0SRajendra Nayak }
377e6d3a8b0SRajendra Nayak
378e6d3a8b0SRajendra Nayak /**
379f9dbbac9SRandy Dunlap * prm_clear_context_loss_flags_old - clear context loss flags (old API)
380e6d3a8b0SRajendra Nayak * @part: PRM partition ID (e.g., OMAP4430_PRM_PARTITION)
381e6d3a8b0SRajendra Nayak * @inst: PRM instance offset (e.g., OMAP4430_PRM_MPU_INST)
382e6d3a8b0SRajendra Nayak * @idx: CONTEXT register offset
383e6d3a8b0SRajendra Nayak *
384e6d3a8b0SRajendra Nayak * Clear hardware context loss bits for the module identified by
385e6d3a8b0SRajendra Nayak * (@part, @inst, @idx). No return value. XXX Deprecated; callers
386e6d3a8b0SRajendra Nayak * need to use a less-SoC-dependent way to identify hardware IP
387e6d3a8b0SRajendra Nayak * blocks.
388e6d3a8b0SRajendra Nayak */
prm_clear_context_loss_flags_old(u8 part,s16 inst,u16 idx)389e6d3a8b0SRajendra Nayak void prm_clear_context_loss_flags_old(u8 part, s16 inst, u16 idx)
390e6d3a8b0SRajendra Nayak {
391e6d3a8b0SRajendra Nayak if (prm_ll_data->clear_context_loss_flags_old)
392e6d3a8b0SRajendra Nayak prm_ll_data->clear_context_loss_flags_old(part, inst, idx);
393e6d3a8b0SRajendra Nayak else
394e6d3a8b0SRajendra Nayak WARN_ONCE(1, "prm: %s: no mapping function defined\n",
395e6d3a8b0SRajendra Nayak __func__);
396e6d3a8b0SRajendra Nayak }
397e6d3a8b0SRajendra Nayak
398e6d3a8b0SRajendra Nayak /**
399efd44dc3STero Kristo * omap_prm_assert_hardreset - assert hardreset for an IP block
400efd44dc3STero Kristo * @shift: register bit shift corresponding to the reset line
401efd44dc3STero Kristo * @part: PRM partition
402efd44dc3STero Kristo * @prm_mod: PRM submodule base or instance offset
403efd44dc3STero Kristo * @offset: register offset
404efd44dc3STero Kristo *
405efd44dc3STero Kristo * Asserts a hardware reset line for an IP block.
406efd44dc3STero Kristo */
omap_prm_assert_hardreset(u8 shift,u8 part,s16 prm_mod,u16 offset)407efd44dc3STero Kristo int omap_prm_assert_hardreset(u8 shift, u8 part, s16 prm_mod, u16 offset)
408efd44dc3STero Kristo {
409efd44dc3STero Kristo if (!prm_ll_data->assert_hardreset) {
410efd44dc3STero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
411efd44dc3STero Kristo __func__);
412efd44dc3STero Kristo return -EINVAL;
413efd44dc3STero Kristo }
414efd44dc3STero Kristo
415efd44dc3STero Kristo return prm_ll_data->assert_hardreset(shift, part, prm_mod, offset);
416efd44dc3STero Kristo }
417efd44dc3STero Kristo
418efd44dc3STero Kristo /**
41937fb59d7STero Kristo * omap_prm_deassert_hardreset - deassert hardreset for an IP block
42037fb59d7STero Kristo * @shift: register bit shift corresponding to the reset line
42137fb59d7STero Kristo * @st_shift: reset status bit shift corresponding to the reset line
42237fb59d7STero Kristo * @part: PRM partition
42337fb59d7STero Kristo * @prm_mod: PRM submodule base or instance offset
42437fb59d7STero Kristo * @offset: register offset
42537fb59d7STero Kristo * @st_offset: status register offset
42637fb59d7STero Kristo *
42737fb59d7STero Kristo * Deasserts a hardware reset line for an IP block.
42837fb59d7STero Kristo */
omap_prm_deassert_hardreset(u8 shift,u8 st_shift,u8 part,s16 prm_mod,u16 offset,u16 st_offset)42937fb59d7STero Kristo int omap_prm_deassert_hardreset(u8 shift, u8 st_shift, u8 part, s16 prm_mod,
43037fb59d7STero Kristo u16 offset, u16 st_offset)
43137fb59d7STero Kristo {
43237fb59d7STero Kristo if (!prm_ll_data->deassert_hardreset) {
43337fb59d7STero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
43437fb59d7STero Kristo __func__);
43537fb59d7STero Kristo return -EINVAL;
43637fb59d7STero Kristo }
43737fb59d7STero Kristo
43837fb59d7STero Kristo return prm_ll_data->deassert_hardreset(shift, st_shift, part, prm_mod,
43937fb59d7STero Kristo offset, st_offset);
44037fb59d7STero Kristo }
44137fb59d7STero Kristo
44237fb59d7STero Kristo /**
4431bc28b34STero Kristo * omap_prm_is_hardreset_asserted - check the hardreset status for an IP block
4441bc28b34STero Kristo * @shift: register bit shift corresponding to the reset line
4451bc28b34STero Kristo * @part: PRM partition
4461bc28b34STero Kristo * @prm_mod: PRM submodule base or instance offset
4471bc28b34STero Kristo * @offset: register offset
4481bc28b34STero Kristo *
4491bc28b34STero Kristo * Checks if a hardware reset line for an IP block is enabled or not.
4501bc28b34STero Kristo */
omap_prm_is_hardreset_asserted(u8 shift,u8 part,s16 prm_mod,u16 offset)4511bc28b34STero Kristo int omap_prm_is_hardreset_asserted(u8 shift, u8 part, s16 prm_mod, u16 offset)
4521bc28b34STero Kristo {
4531bc28b34STero Kristo if (!prm_ll_data->is_hardreset_asserted) {
4541bc28b34STero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
4551bc28b34STero Kristo __func__);
4561bc28b34STero Kristo return -EINVAL;
4571bc28b34STero Kristo }
4581bc28b34STero Kristo
4591bc28b34STero Kristo return prm_ll_data->is_hardreset_asserted(shift, part, prm_mod, offset);
4601bc28b34STero Kristo }
4611bc28b34STero Kristo
4621bc28b34STero Kristo /**
46361c8621eSTero Kristo * omap_prm_reset_system - trigger global SW reset
46461c8621eSTero Kristo *
46561c8621eSTero Kristo * Triggers SoC specific global warm reset to reboot the device.
46661c8621eSTero Kristo */
omap_prm_reset_system(void)46761c8621eSTero Kristo void omap_prm_reset_system(void)
46861c8621eSTero Kristo {
46961c8621eSTero Kristo if (!prm_ll_data->reset_system) {
47061c8621eSTero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
47161c8621eSTero Kristo __func__);
47261c8621eSTero Kristo return;
47361c8621eSTero Kristo }
47461c8621eSTero Kristo
47561c8621eSTero Kristo prm_ll_data->reset_system();
47661c8621eSTero Kristo
4775388a5b8SRussell King while (1) {
47861c8621eSTero Kristo cpu_relax();
4795388a5b8SRussell King wfe();
4805388a5b8SRussell King }
48161c8621eSTero Kristo }
48261c8621eSTero Kristo
48361c8621eSTero Kristo /**
4849cb6d363STero Kristo * omap_prm_clear_mod_irqs - clear wake-up events from PRCM interrupt
4859cb6d363STero Kristo * @module: PRM module to clear wakeups from
4869cb6d363STero Kristo * @regs: register to clear
4879cb6d363STero Kristo * @wkst_mask: wkst bits to clear
4889cb6d363STero Kristo *
4899cb6d363STero Kristo * Clears any wakeup events for the module and register set defined.
4909cb6d363STero Kristo * Uses SoC specific implementation to do the actual wakeup status
4919cb6d363STero Kristo * clearing.
4929cb6d363STero Kristo */
omap_prm_clear_mod_irqs(s16 module,u8 regs,u32 wkst_mask)4939cb6d363STero Kristo int omap_prm_clear_mod_irqs(s16 module, u8 regs, u32 wkst_mask)
4949cb6d363STero Kristo {
4959cb6d363STero Kristo if (!prm_ll_data->clear_mod_irqs) {
4969cb6d363STero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
4979cb6d363STero Kristo __func__);
4989cb6d363STero Kristo return -EINVAL;
4999cb6d363STero Kristo }
5009cb6d363STero Kristo
5019cb6d363STero Kristo return prm_ll_data->clear_mod_irqs(module, regs, wkst_mask);
5029cb6d363STero Kristo }
5039cb6d363STero Kristo
5049cb6d363STero Kristo /**
505e9f1ddcdSTero Kristo * omap_prm_vp_check_txdone - check voltage processor TX done status
506f9dbbac9SRandy Dunlap * @vp_id: unique VP instance ID
507e9f1ddcdSTero Kristo *
508e9f1ddcdSTero Kristo * Checks if voltage processor transmission has been completed.
509e9f1ddcdSTero Kristo * Returns non-zero if a transmission has completed, 0 otherwise.
510e9f1ddcdSTero Kristo */
omap_prm_vp_check_txdone(u8 vp_id)511e9f1ddcdSTero Kristo u32 omap_prm_vp_check_txdone(u8 vp_id)
512e9f1ddcdSTero Kristo {
513e9f1ddcdSTero Kristo if (!prm_ll_data->vp_check_txdone) {
514e9f1ddcdSTero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
515e9f1ddcdSTero Kristo __func__);
516e9f1ddcdSTero Kristo return 0;
517e9f1ddcdSTero Kristo }
518e9f1ddcdSTero Kristo
519e9f1ddcdSTero Kristo return prm_ll_data->vp_check_txdone(vp_id);
520e9f1ddcdSTero Kristo }
521e9f1ddcdSTero Kristo
522e9f1ddcdSTero Kristo /**
523e9f1ddcdSTero Kristo * omap_prm_vp_clear_txdone - clears voltage processor TX done status
524f9dbbac9SRandy Dunlap * @vp_id: unique VP instance ID
525e9f1ddcdSTero Kristo *
526e9f1ddcdSTero Kristo * Clears the status bit for completed voltage processor transmission
527e9f1ddcdSTero Kristo * returned by prm_vp_check_txdone.
528e9f1ddcdSTero Kristo */
omap_prm_vp_clear_txdone(u8 vp_id)529e9f1ddcdSTero Kristo void omap_prm_vp_clear_txdone(u8 vp_id)
530e9f1ddcdSTero Kristo {
531e9f1ddcdSTero Kristo if (!prm_ll_data->vp_clear_txdone) {
532e9f1ddcdSTero Kristo WARN_ONCE(1, "prm: %s: no mapping function defined\n",
533e9f1ddcdSTero Kristo __func__);
534e9f1ddcdSTero Kristo return;
535e9f1ddcdSTero Kristo }
536e9f1ddcdSTero Kristo
537e9f1ddcdSTero Kristo prm_ll_data->vp_clear_txdone(vp_id);
538e9f1ddcdSTero Kristo }
539e9f1ddcdSTero Kristo
540e9f1ddcdSTero Kristo /**
541e24c3573SPaul Walmsley * prm_register - register per-SoC low-level data with the PRM
542e24c3573SPaul Walmsley * @pld: low-level per-SoC OMAP PRM data & function pointers to register
543e24c3573SPaul Walmsley *
544e24c3573SPaul Walmsley * Register per-SoC low-level OMAP PRM data and function pointers with
545e24c3573SPaul Walmsley * the OMAP PRM common interface. The caller must keep the data
546e24c3573SPaul Walmsley * pointed to by @pld valid until it calls prm_unregister() and
547e24c3573SPaul Walmsley * it returns successfully. Returns 0 upon success, -EINVAL if @pld
548e24c3573SPaul Walmsley * is NULL, or -EEXIST if prm_register() has already been called
549e24c3573SPaul Walmsley * without an intervening prm_unregister().
550e24c3573SPaul Walmsley */
prm_register(struct prm_ll_data * pld)551e24c3573SPaul Walmsley int prm_register(struct prm_ll_data *pld)
552e24c3573SPaul Walmsley {
553e24c3573SPaul Walmsley if (!pld)
554e24c3573SPaul Walmsley return -EINVAL;
555e24c3573SPaul Walmsley
556e24c3573SPaul Walmsley if (prm_ll_data != &null_prm_ll_data)
557e24c3573SPaul Walmsley return -EEXIST;
558e24c3573SPaul Walmsley
559e24c3573SPaul Walmsley prm_ll_data = pld;
560e24c3573SPaul Walmsley
5613f4990f4SR Sricharan return 0;
5623f4990f4SR Sricharan }
5633f4990f4SR Sricharan
564e24c3573SPaul Walmsley /**
565e24c3573SPaul Walmsley * prm_unregister - unregister per-SoC low-level data & function pointers
566e24c3573SPaul Walmsley * @pld: low-level per-SoC OMAP PRM data & function pointers to unregister
567e24c3573SPaul Walmsley *
568e24c3573SPaul Walmsley * Unregister per-SoC low-level OMAP PRM data and function pointers
569e24c3573SPaul Walmsley * that were previously registered with prm_register(). The
570e24c3573SPaul Walmsley * caller may not destroy any of the data pointed to by @pld until
571e24c3573SPaul Walmsley * this function returns successfully. Returns 0 upon success, or
572e24c3573SPaul Walmsley * -EINVAL if @pld is NULL or if @pld does not match the struct
573e24c3573SPaul Walmsley * prm_ll_data * previously registered by prm_register().
574e24c3573SPaul Walmsley */
prm_unregister(struct prm_ll_data * pld)575e24c3573SPaul Walmsley int prm_unregister(struct prm_ll_data *pld)
5763f4990f4SR Sricharan {
577e24c3573SPaul Walmsley if (!pld || prm_ll_data != pld)
578e24c3573SPaul Walmsley return -EINVAL;
5793f4990f4SR Sricharan
580e24c3573SPaul Walmsley prm_ll_data = &null_prm_ll_data;
581e24c3573SPaul Walmsley
5823f4990f4SR Sricharan return 0;
5833f4990f4SR Sricharan }
584943a63a4STero Kristo
585ab7b2ffcSTero Kristo #ifdef CONFIG_ARCH_OMAP2
586ab7b2ffcSTero Kristo static struct omap_prcm_init_data omap2_prm_data __initdata = {
5873a3e1c88STero Kristo .index = TI_CLKM_PRM,
588ab7b2ffcSTero Kristo .init = omap2xxx_prm_init,
5893a3e1c88STero Kristo };
590ab7b2ffcSTero Kristo #endif
5913a3e1c88STero Kristo
592ab7b2ffcSTero Kristo #ifdef CONFIG_ARCH_OMAP3
593ab7b2ffcSTero Kristo static struct omap_prcm_init_data omap3_prm_data __initdata = {
594ae521d4dSTero Kristo .index = TI_CLKM_PRM,
595ab7b2ffcSTero Kristo .init = omap3xxx_prm_init,
596ae521d4dSTero Kristo
597ae521d4dSTero Kristo /*
598ae521d4dSTero Kristo * IVA2 offset is a negative value, must offset the prm_base
599ae521d4dSTero Kristo * address by this to get it to positive
600ae521d4dSTero Kristo */
601ae521d4dSTero Kristo .offset = -OMAP3430_IVA2_MOD,
602ae521d4dSTero Kristo };
603ab7b2ffcSTero Kristo #endif
604ae521d4dSTero Kristo
605ab7b2ffcSTero Kristo #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_TI81XX)
606ab7b2ffcSTero Kristo static struct omap_prcm_init_data am3_prm_data __initdata = {
607ab7b2ffcSTero Kristo .index = TI_CLKM_PRM,
608ab7b2ffcSTero Kristo .init = am33xx_prm_init,
609ab7b2ffcSTero Kristo };
610dbb7e70aSTony Lindgren #endif
6114e34df0cSTony Lindgren
612dbb7e70aSTony Lindgren #ifdef CONFIG_SOC_TI81XX
6134e34df0cSTony Lindgren static struct omap_prcm_init_data dm814_pllss_data __initdata = {
6144e34df0cSTony Lindgren .index = TI_CLKM_PLLSS,
6154e34df0cSTony Lindgren .init = am33xx_prm_init,
6164e34df0cSTony Lindgren };
617ab7b2ffcSTero Kristo #endif
618ab7b2ffcSTero Kristo
61948e0c114STero Kristo #ifdef CONFIG_ARCH_OMAP4
620ab7b2ffcSTero Kristo static struct omap_prcm_init_data omap4_prm_data __initdata = {
621ab7b2ffcSTero Kristo .index = TI_CLKM_PRM,
622ab7b2ffcSTero Kristo .init = omap44xx_prm_init,
62348e0c114STero Kristo .device_inst_offset = OMAP4430_PRM_DEVICE_INST,
6243da52167STony Lindgren .flags = PRM_HAS_IO_WAKEUP | PRM_HAS_VOLTAGE,
62548e0c114STero Kristo };
62648e0c114STero Kristo #endif
62748e0c114STero Kristo
62848e0c114STero Kristo #ifdef CONFIG_SOC_OMAP5
62948e0c114STero Kristo static struct omap_prcm_init_data omap5_prm_data __initdata = {
63048e0c114STero Kristo .index = TI_CLKM_PRM,
63148e0c114STero Kristo .init = omap44xx_prm_init,
63248e0c114STero Kristo .device_inst_offset = OMAP54XX_PRM_DEVICE_INST,
6338b5b9a22STero Kristo .flags = PRM_HAS_IO_WAKEUP | PRM_HAS_VOLTAGE,
63448e0c114STero Kristo };
63548e0c114STero Kristo #endif
63648e0c114STero Kristo
63748e0c114STero Kristo #ifdef CONFIG_SOC_DRA7XX
63848e0c114STero Kristo static struct omap_prcm_init_data dra7_prm_data __initdata = {
63948e0c114STero Kristo .index = TI_CLKM_PRM,
64048e0c114STero Kristo .init = omap44xx_prm_init,
64148e0c114STero Kristo .device_inst_offset = DRA7XX_PRM_DEVICE_INST,
6428b5b9a22STero Kristo .flags = PRM_HAS_IO_WAKEUP,
64348e0c114STero Kristo };
64448e0c114STero Kristo #endif
64548e0c114STero Kristo
64648e0c114STero Kristo #ifdef CONFIG_SOC_AM43XX
64748e0c114STero Kristo static struct omap_prcm_init_data am4_prm_data __initdata = {
64848e0c114STero Kristo .index = TI_CLKM_PRM,
64948e0c114STero Kristo .init = omap44xx_prm_init,
65048e0c114STero Kristo .device_inst_offset = AM43XX_PRM_DEVICE_INST,
6518740a144SKeerthy .flags = PRM_HAS_IO_WAKEUP,
652ab7b2ffcSTero Kristo };
653ab7b2ffcSTero Kristo #endif
654ab7b2ffcSTero Kristo
655ab7b2ffcSTero Kristo #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
656ab7b2ffcSTero Kristo static struct omap_prcm_init_data scrm_data __initdata = {
6573a3e1c88STero Kristo .index = TI_CLKM_SCRM,
6583a3e1c88STero Kristo };
659ab7b2ffcSTero Kristo #endif
6603a3e1c88STero Kristo
6610527873bSArnd Bergmann static const struct of_device_id omap_prcm_dt_match_table[] __initconst = {
662ab7b2ffcSTero Kristo #ifdef CONFIG_SOC_AM33XX
663ab7b2ffcSTero Kristo { .compatible = "ti,am3-prcm", .data = &am3_prm_data },
664ab7b2ffcSTero Kristo #endif
665ab7b2ffcSTero Kristo #ifdef CONFIG_SOC_AM43XX
66648e0c114STero Kristo { .compatible = "ti,am4-prcm", .data = &am4_prm_data },
667ab7b2ffcSTero Kristo #endif
668ab7b2ffcSTero Kristo #ifdef CONFIG_SOC_TI81XX
669ab7b2ffcSTero Kristo { .compatible = "ti,dm814-prcm", .data = &am3_prm_data },
6704e34df0cSTony Lindgren { .compatible = "ti,dm814-pllss", .data = &dm814_pllss_data },
671ab7b2ffcSTero Kristo { .compatible = "ti,dm816-prcm", .data = &am3_prm_data },
672ab7b2ffcSTero Kristo #endif
673ab7b2ffcSTero Kristo #ifdef CONFIG_ARCH_OMAP2
674ab7b2ffcSTero Kristo { .compatible = "ti,omap2-prcm", .data = &omap2_prm_data },
675ab7b2ffcSTero Kristo #endif
676ab7b2ffcSTero Kristo #ifdef CONFIG_ARCH_OMAP3
677ae521d4dSTero Kristo { .compatible = "ti,omap3-prm", .data = &omap3_prm_data },
678ab7b2ffcSTero Kristo #endif
679ab7b2ffcSTero Kristo #ifdef CONFIG_ARCH_OMAP4
680ab7b2ffcSTero Kristo { .compatible = "ti,omap4-prm", .data = &omap4_prm_data },
6813a3e1c88STero Kristo { .compatible = "ti,omap4-scrm", .data = &scrm_data },
682ab7b2ffcSTero Kristo #endif
683ab7b2ffcSTero Kristo #ifdef CONFIG_SOC_OMAP5
68448e0c114STero Kristo { .compatible = "ti,omap5-prm", .data = &omap5_prm_data },
6853a3e1c88STero Kristo { .compatible = "ti,omap5-scrm", .data = &scrm_data },
686ab7b2ffcSTero Kristo #endif
687ab7b2ffcSTero Kristo #ifdef CONFIG_SOC_DRA7XX
68848e0c114STero Kristo { .compatible = "ti,dra7-prm", .data = &dra7_prm_data },
689ab7b2ffcSTero Kristo #endif
690943a63a4STero Kristo { }
691943a63a4STero Kristo };
692943a63a4STero Kristo
6933a1a388eSTero Kristo /**
694ae521d4dSTero Kristo * omap2_prm_base_init - initialize iomappings for the PRM driver
695ae521d4dSTero Kristo *
696ae521d4dSTero Kristo * Detects and initializes the iomappings for the PRM driver, based
697ae521d4dSTero Kristo * on the DT data. Returns 0 in success, negative error value
698ae521d4dSTero Kristo * otherwise.
699ae521d4dSTero Kristo */
omap2_prm_base_init(void)7006aeb51c1SArnd Bergmann static int __init omap2_prm_base_init(void)
701ae521d4dSTero Kristo {
702ae521d4dSTero Kristo struct device_node *np;
703ae521d4dSTero Kristo const struct of_device_id *match;
704ae521d4dSTero Kristo struct omap_prcm_init_data *data;
70590129336STero Kristo struct resource res;
70690129336STero Kristo int ret;
707ae521d4dSTero Kristo
708ae521d4dSTero Kristo for_each_matching_node_and_match(np, omap_prcm_dt_match_table, &match) {
709ae521d4dSTero Kristo data = (struct omap_prcm_init_data *)match->data;
710ae521d4dSTero Kristo
71190129336STero Kristo ret = of_address_to_resource(np, 0, &res);
712883f464cSWang Qing if (ret) {
713883f464cSWang Qing of_node_put(np);
71490129336STero Kristo return ret;
715883f464cSWang Qing }
716ae521d4dSTero Kristo
71790129336STero Kristo data->mem = ioremap(res.start, resource_size(&res));
718ae521d4dSTero Kristo
71990129336STero Kristo if (data->index == TI_CLKM_PRM) {
72090129336STero Kristo prm_base.va = data->mem + data->offset;
72190129336STero Kristo prm_base.pa = res.start + data->offset;
72290129336STero Kristo }
723ab7b2ffcSTero Kristo
724ab7b2ffcSTero Kristo data->np = np;
725ab7b2ffcSTero Kristo
726ab7b2ffcSTero Kristo if (data->init)
727ab7b2ffcSTero Kristo data->init(data);
728ae521d4dSTero Kristo }
729ae521d4dSTero Kristo
730ae521d4dSTero Kristo return 0;
731ae521d4dSTero Kristo }
732ae521d4dSTero Kristo
omap2_prcm_base_init(void)733ab7b2ffcSTero Kristo int __init omap2_prcm_base_init(void)
734ab7b2ffcSTero Kristo {
735425dc8b2STero Kristo int ret;
736425dc8b2STero Kristo
737425dc8b2STero Kristo ret = omap2_prm_base_init();
738425dc8b2STero Kristo if (ret)
739425dc8b2STero Kristo return ret;
740425dc8b2STero Kristo
741425dc8b2STero Kristo return omap2_cm_base_init();
742ab7b2ffcSTero Kristo }
743ab7b2ffcSTero Kristo
744ae521d4dSTero Kristo /**
7453a1a388eSTero Kristo * omap_prcm_init - low level init for the PRCM drivers
7463a1a388eSTero Kristo *
7473a1a388eSTero Kristo * Initializes the low level clock infrastructure for PRCM drivers.
7483a1a388eSTero Kristo * Returns 0 in success, negative error value in failure.
7493a1a388eSTero Kristo */
omap_prcm_init(void)7503a1a388eSTero Kristo int __init omap_prcm_init(void)
751943a63a4STero Kristo {
752943a63a4STero Kristo struct device_node *np;
7533a3e1c88STero Kristo const struct of_device_id *match;
7543a3e1c88STero Kristo const struct omap_prcm_init_data *data;
7559f029b15STero Kristo int ret;
756943a63a4STero Kristo
7573a3e1c88STero Kristo for_each_matching_node_and_match(np, omap_prcm_dt_match_table, &match) {
7583a3e1c88STero Kristo data = match->data;
7593a3e1c88STero Kristo
76080cbb224STero Kristo ret = omap2_clk_provider_init(np, data->index, NULL, data->mem);
761883f464cSWang Qing if (ret) {
762883f464cSWang Qing of_node_put(np);
7639f029b15STero Kristo return ret;
764943a63a4STero Kristo }
765883f464cSWang Qing }
766943a63a4STero Kristo
767fe87414fSTero Kristo omap_cm_init();
768fe87414fSTero Kristo
769943a63a4STero Kristo return 0;
770943a63a4STero Kristo }
771b550e47fSTero Kristo
prm_late_init(void)772b550e47fSTero Kristo static int __init prm_late_init(void)
773b550e47fSTero Kristo {
774b550e47fSTero Kristo if (prm_ll_data->late_init)
775b550e47fSTero Kristo return prm_ll_data->late_init();
776b550e47fSTero Kristo return 0;
777b550e47fSTero Kristo }
778b550e47fSTero Kristo subsys_initcall(prm_late_init);
779