139a72345SMasahiro Yamada /*
239a72345SMasahiro Yamada * Keystone: PSC configuration module
339a72345SMasahiro Yamada *
439a72345SMasahiro Yamada * (C) Copyright 2012-2014
539a72345SMasahiro Yamada * Texas Instruments Incorporated, <www.ti.com>
639a72345SMasahiro Yamada *
739a72345SMasahiro Yamada * SPDX-License-Identifier: GPL-2.0+
839a72345SMasahiro Yamada */
939a72345SMasahiro Yamada
1039a72345SMasahiro Yamada #include <common.h>
11*5d97dff0SMasahiro Yamada #include <linux/errno.h>
1239a72345SMasahiro Yamada #include <asm/io.h>
1339a72345SMasahiro Yamada #include <asm/processor.h>
1439a72345SMasahiro Yamada #include <asm/arch/psc_defs.h>
1539a72345SMasahiro Yamada
1682ff21bdSNishanth Menon /**
1782ff21bdSNishanth Menon * psc_delay() - delay for psc
1882ff21bdSNishanth Menon *
1982ff21bdSNishanth Menon * Return: 10
2082ff21bdSNishanth Menon */
psc_delay(void)2139a72345SMasahiro Yamada int psc_delay(void)
2239a72345SMasahiro Yamada {
2339a72345SMasahiro Yamada udelay(10);
2439a72345SMasahiro Yamada return 10;
2539a72345SMasahiro Yamada }
2639a72345SMasahiro Yamada
2782ff21bdSNishanth Menon /**
2882ff21bdSNishanth Menon * psc_wait() - Wait for end of transitional state
2982ff21bdSNishanth Menon * @domain_num: GPSC domain number
3039a72345SMasahiro Yamada *
3182ff21bdSNishanth Menon * Polls pstat for the selected domain and waits for transitions to be complete.
3282ff21bdSNishanth Menon * Since this is boot loader code it is *ASSUMED* that interrupts are disabled
3382ff21bdSNishanth Menon * and no other core is mucking around with the psc at the same time.
3439a72345SMasahiro Yamada *
3582ff21bdSNishanth Menon * Return: 0 when the domain is free. Returns -1 if a timeout occurred waiting
3682ff21bdSNishanth Menon * for the completion.
3739a72345SMasahiro Yamada */
psc_wait(u32 domain_num)3839a72345SMasahiro Yamada int psc_wait(u32 domain_num)
3939a72345SMasahiro Yamada {
4039a72345SMasahiro Yamada u32 retry;
4139a72345SMasahiro Yamada u32 ptstat;
4239a72345SMasahiro Yamada
4339a72345SMasahiro Yamada /*
4439a72345SMasahiro Yamada * Do nothing if the power domain is in transition. This should never
4539a72345SMasahiro Yamada * happen since the boot code is the only software accesses psc.
4639a72345SMasahiro Yamada * It's still remotely possible that the hardware state machines
4739a72345SMasahiro Yamada * initiate transitions.
4839a72345SMasahiro Yamada * Don't trap if the domain (or a module in this domain) is
4939a72345SMasahiro Yamada * stuck in transition.
5039a72345SMasahiro Yamada */
5139a72345SMasahiro Yamada retry = 0;
5239a72345SMasahiro Yamada
5339a72345SMasahiro Yamada do {
5439a72345SMasahiro Yamada ptstat = __raw_readl(KS2_PSC_BASE + PSC_REG_PSTAT);
5539a72345SMasahiro Yamada ptstat = ptstat & (1 << domain_num);
5639a72345SMasahiro Yamada } while ((ptstat != 0) && ((retry += psc_delay()) <
5739a72345SMasahiro Yamada PSC_PTSTAT_TIMEOUT_LIMIT));
5839a72345SMasahiro Yamada
5939a72345SMasahiro Yamada if (retry >= PSC_PTSTAT_TIMEOUT_LIMIT)
6039a72345SMasahiro Yamada return -1;
6139a72345SMasahiro Yamada
6239a72345SMasahiro Yamada return 0;
6339a72345SMasahiro Yamada }
6439a72345SMasahiro Yamada
6582ff21bdSNishanth Menon /**
6682ff21bdSNishanth Menon * psc_get_domain_num() - Get the domain number
6782ff21bdSNishanth Menon * @mod_num: LPSC module number
6882ff21bdSNishanth Menon */
psc_get_domain_num(u32 mod_num)6939a72345SMasahiro Yamada u32 psc_get_domain_num(u32 mod_num)
7039a72345SMasahiro Yamada {
7139a72345SMasahiro Yamada u32 domain_num;
7239a72345SMasahiro Yamada
7339a72345SMasahiro Yamada /* Get the power domain associated with the module number */
7439a72345SMasahiro Yamada domain_num = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCFG(mod_num));
7539a72345SMasahiro Yamada domain_num = PSC_REG_MDCFG_GET_PD(domain_num);
7639a72345SMasahiro Yamada
7739a72345SMasahiro Yamada return domain_num;
7839a72345SMasahiro Yamada }
7939a72345SMasahiro Yamada
8082ff21bdSNishanth Menon /**
8182ff21bdSNishanth Menon * psc_set_state() - powers up/down a module
8282ff21bdSNishanth Menon * @mod_num: LPSC module number
8382ff21bdSNishanth Menon * @state: 1 to enable, 0 to disable.
8439a72345SMasahiro Yamada *
8582ff21bdSNishanth Menon * Powers up/down the requested module and the associated power domain if
8682ff21bdSNishanth Menon * required. No action is taken it the module is already powered up/down.
8782ff21bdSNishanth Menon * This only controls modules. The domain in which the module resides will
8882ff21bdSNishanth Menon * be left in the power on state. Multiple modules can exist in a power
8982ff21bdSNishanth Menon * domain, so powering down the domain based on a single module is not done.
9039a72345SMasahiro Yamada *
9182ff21bdSNishanth Menon * Return: 0 on success, -1 if the module can't be powered up, or if there is a
9282ff21bdSNishanth Menon * timeout waiting for the transition.
9339a72345SMasahiro Yamada */
psc_set_state(u32 mod_num,u32 state)9439a72345SMasahiro Yamada int psc_set_state(u32 mod_num, u32 state)
9539a72345SMasahiro Yamada {
9639a72345SMasahiro Yamada u32 domain_num;
9739a72345SMasahiro Yamada u32 pdctl;
9839a72345SMasahiro Yamada u32 mdctl;
9939a72345SMasahiro Yamada u32 ptcmd;
10039a72345SMasahiro Yamada u32 reset_iso;
10139a72345SMasahiro Yamada u32 v;
10239a72345SMasahiro Yamada
10339a72345SMasahiro Yamada /*
10439a72345SMasahiro Yamada * Get the power domain associated with the module number, and reset
10539a72345SMasahiro Yamada * isolation functionality
10639a72345SMasahiro Yamada */
10739a72345SMasahiro Yamada v = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCFG(mod_num));
10839a72345SMasahiro Yamada domain_num = PSC_REG_MDCFG_GET_PD(v);
10939a72345SMasahiro Yamada reset_iso = PSC_REG_MDCFG_GET_RESET_ISO(v);
11039a72345SMasahiro Yamada
11139a72345SMasahiro Yamada /* Wait for the status of the domain/module to be non-transitional */
11239a72345SMasahiro Yamada if (psc_wait(domain_num) != 0)
11339a72345SMasahiro Yamada return -1;
11439a72345SMasahiro Yamada
11539a72345SMasahiro Yamada /*
11639a72345SMasahiro Yamada * Perform configuration even if the current status matches the
11739a72345SMasahiro Yamada * existing state
11839a72345SMasahiro Yamada *
11939a72345SMasahiro Yamada * Set the next state of the power domain to on. It's OK if the domain
12039a72345SMasahiro Yamada * is always on. This code will not ever power down a domain, so no
12139a72345SMasahiro Yamada * change is made if the new state is power down.
12239a72345SMasahiro Yamada */
12339a72345SMasahiro Yamada if (state == PSC_REG_VAL_MDCTL_NEXT_ON) {
12439a72345SMasahiro Yamada pdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_PDCTL(domain_num));
12539a72345SMasahiro Yamada pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl,
12639a72345SMasahiro Yamada PSC_REG_VAL_PDCTL_NEXT_ON);
12739a72345SMasahiro Yamada __raw_writel(pdctl, KS2_PSC_BASE + PSC_REG_PDCTL(domain_num));
12839a72345SMasahiro Yamada }
12939a72345SMasahiro Yamada
13039a72345SMasahiro Yamada /* Set the next state for the module to enabled/disabled */
13139a72345SMasahiro Yamada mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
13239a72345SMasahiro Yamada mdctl = PSC_REG_MDCTL_SET_NEXT(mdctl, state);
13339a72345SMasahiro Yamada mdctl = PSC_REG_MDCTL_SET_RESET_ISO(mdctl, reset_iso);
13439a72345SMasahiro Yamada __raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
13539a72345SMasahiro Yamada
13639a72345SMasahiro Yamada /* Trigger the enable */
13739a72345SMasahiro Yamada ptcmd = __raw_readl(KS2_PSC_BASE + PSC_REG_PTCMD);
13839a72345SMasahiro Yamada ptcmd |= (u32)(1<<domain_num);
13939a72345SMasahiro Yamada __raw_writel(ptcmd, KS2_PSC_BASE + PSC_REG_PTCMD);
14039a72345SMasahiro Yamada
14139a72345SMasahiro Yamada /* Wait on the complete */
14239a72345SMasahiro Yamada return psc_wait(domain_num);
14339a72345SMasahiro Yamada }
14439a72345SMasahiro Yamada
14582ff21bdSNishanth Menon /**
14682ff21bdSNishanth Menon * psc_enable_module() - power up a module
14782ff21bdSNishanth Menon * @mod_num: LPSC module number
14839a72345SMasahiro Yamada *
14982ff21bdSNishanth Menon * Powers up the requested module and the associated power domain
15082ff21bdSNishanth Menon * if required. No action is taken it the module is already powered up.
15139a72345SMasahiro Yamada *
15282ff21bdSNishanth Menon * Return: 0 on success, -1 if the module can't be powered up, or
15339a72345SMasahiro Yamada * if there is a timeout waiting for the transition.
15482ff21bdSNishanth Menon *
15539a72345SMasahiro Yamada */
psc_enable_module(u32 mod_num)15639a72345SMasahiro Yamada int psc_enable_module(u32 mod_num)
15739a72345SMasahiro Yamada {
15839a72345SMasahiro Yamada u32 mdctl;
15939a72345SMasahiro Yamada
16039a72345SMasahiro Yamada /* Set the bit to apply reset */
16139a72345SMasahiro Yamada mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
16239a72345SMasahiro Yamada if ((mdctl & 0x3f) == PSC_REG_VAL_MDSTAT_STATE_ON)
16339a72345SMasahiro Yamada return 0;
16439a72345SMasahiro Yamada
16539a72345SMasahiro Yamada return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_ON);
16639a72345SMasahiro Yamada }
16739a72345SMasahiro Yamada
16882ff21bdSNishanth Menon /**
16982ff21bdSNishanth Menon * psc_disable_module() - Power down a module
17082ff21bdSNishanth Menon * @mod_num: LPSC module number
17139a72345SMasahiro Yamada *
17282ff21bdSNishanth Menon * Return: 0 on success, -1 on failure or timeout.
17339a72345SMasahiro Yamada */
psc_disable_module(u32 mod_num)17439a72345SMasahiro Yamada int psc_disable_module(u32 mod_num)
17539a72345SMasahiro Yamada {
17639a72345SMasahiro Yamada u32 mdctl;
17739a72345SMasahiro Yamada
17839a72345SMasahiro Yamada /* Set the bit to apply reset */
17939a72345SMasahiro Yamada mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
18039a72345SMasahiro Yamada if ((mdctl & 0x3f) == 0)
18139a72345SMasahiro Yamada return 0;
18239a72345SMasahiro Yamada mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0);
18339a72345SMasahiro Yamada __raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
18439a72345SMasahiro Yamada
18539a72345SMasahiro Yamada return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE);
18639a72345SMasahiro Yamada }
18739a72345SMasahiro Yamada
18882ff21bdSNishanth Menon /**
18982ff21bdSNishanth Menon * psc_set_reset_iso() - Set the reset isolation bit in mdctl
19082ff21bdSNishanth Menon * @mod_num: LPSC module number
19139a72345SMasahiro Yamada *
19282ff21bdSNishanth Menon * The reset isolation enable bit is set. The state of the module is not
19382ff21bdSNishanth Menon * changed.
19482ff21bdSNishanth Menon *
19582ff21bdSNishanth Menon * Return: 0 if the module config showed that reset isolation is supported.
19682ff21bdSNishanth Menon * Returns 1 otherwise. This is not an error, but setting the bit in mdctl
19782ff21bdSNishanth Menon * has no effect.
19839a72345SMasahiro Yamada */
psc_set_reset_iso(u32 mod_num)19939a72345SMasahiro Yamada int psc_set_reset_iso(u32 mod_num)
20039a72345SMasahiro Yamada {
20139a72345SMasahiro Yamada u32 v;
20239a72345SMasahiro Yamada u32 mdctl;
20339a72345SMasahiro Yamada
20439a72345SMasahiro Yamada /* Set the reset isolation bit */
20539a72345SMasahiro Yamada mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
20639a72345SMasahiro Yamada mdctl = PSC_REG_MDCTL_SET_RESET_ISO(mdctl, 1);
20739a72345SMasahiro Yamada __raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
20839a72345SMasahiro Yamada
20939a72345SMasahiro Yamada v = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCFG(mod_num));
21039a72345SMasahiro Yamada if (PSC_REG_MDCFG_GET_RESET_ISO(v) == 1)
21139a72345SMasahiro Yamada return 0;
21239a72345SMasahiro Yamada
21339a72345SMasahiro Yamada return 1;
21439a72345SMasahiro Yamada }
21539a72345SMasahiro Yamada
21682ff21bdSNishanth Menon /**
21782ff21bdSNishanth Menon * psc_disable_domain() - Disable a power domain
21882ff21bdSNishanth Menon * @domain_num: GPSC domain number
21939a72345SMasahiro Yamada */
psc_disable_domain(u32 domain_num)22039a72345SMasahiro Yamada int psc_disable_domain(u32 domain_num)
22139a72345SMasahiro Yamada {
22239a72345SMasahiro Yamada u32 pdctl;
22339a72345SMasahiro Yamada u32 ptcmd;
22439a72345SMasahiro Yamada
22539a72345SMasahiro Yamada pdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_PDCTL(domain_num));
22639a72345SMasahiro Yamada pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl, PSC_REG_VAL_PDCTL_NEXT_OFF);
22739a72345SMasahiro Yamada pdctl = PSC_REG_PDCTL_SET_PDMODE(pdctl, PSC_REG_VAL_PDCTL_PDMODE_SLEEP);
22839a72345SMasahiro Yamada __raw_writel(pdctl, KS2_PSC_BASE + PSC_REG_PDCTL(domain_num));
22939a72345SMasahiro Yamada
23039a72345SMasahiro Yamada ptcmd = __raw_readl(KS2_PSC_BASE + PSC_REG_PTCMD);
23139a72345SMasahiro Yamada ptcmd |= (u32)(1 << domain_num);
23239a72345SMasahiro Yamada __raw_writel(ptcmd, KS2_PSC_BASE + PSC_REG_PTCMD);
23339a72345SMasahiro Yamada
23439a72345SMasahiro Yamada return psc_wait(domain_num);
23539a72345SMasahiro Yamada }
236ec00b2e3SNishanth Menon
237ec00b2e3SNishanth Menon /**
238ec00b2e3SNishanth Menon * psc_module_keep_in_reset_enabled() - Keep module in enabled,in-reset state
239ec00b2e3SNishanth Menon * @mod_num: LPSC module number
240ec00b2e3SNishanth Menon * @gate_clocks: Can the clocks be gated on this module?
241ec00b2e3SNishanth Menon *
242ec00b2e3SNishanth Menon * Enable the module, but do not release the module from local reset. This is
243ec00b2e3SNishanth Menon * necessary for many processor systems on keystone SoCs to allow for system
244ec00b2e3SNishanth Menon * initialization from a master processor prior to releasing the processor
245ec00b2e3SNishanth Menon * from reset.
246ec00b2e3SNishanth Menon */
psc_module_keep_in_reset_enabled(u32 mod_num,bool gate_clocks)247ec00b2e3SNishanth Menon int psc_module_keep_in_reset_enabled(u32 mod_num, bool gate_clocks)
248ec00b2e3SNishanth Menon {
249ec00b2e3SNishanth Menon u32 mdctl, ptcmd, mdstat;
250ec00b2e3SNishanth Menon u32 next_state;
251ec00b2e3SNishanth Menon int domain_num = psc_get_domain_num(mod_num);
252ec00b2e3SNishanth Menon int timeout = 100000;
253ec00b2e3SNishanth Menon
254ec00b2e3SNishanth Menon /* Wait for any previous transitions to complete */
255ec00b2e3SNishanth Menon psc_wait(domain_num);
256ec00b2e3SNishanth Menon mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
257ec00b2e3SNishanth Menon /* Should be set 0 to assert Local reset */
258ec00b2e3SNishanth Menon if ((mdctl & PSC_REG_MDCTL_SET_LRSTZ(mdctl, 1))) {
259ec00b2e3SNishanth Menon mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0);
260ec00b2e3SNishanth Menon __raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
261ec00b2e3SNishanth Menon /* Wait for transition to take place */
262ec00b2e3SNishanth Menon psc_wait(domain_num);
263ec00b2e3SNishanth Menon }
264ec00b2e3SNishanth Menon
265ec00b2e3SNishanth Menon /* Clear Module reset */
266ec00b2e3SNishanth Menon mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
267ec00b2e3SNishanth Menon next_state = gate_clocks ? PSC_REG_VAL_MDCTL_NEXT_OFF :
268ec00b2e3SNishanth Menon PSC_REG_VAL_MDCTL_NEXT_ON;
269ec00b2e3SNishanth Menon mdctl = PSC_REG_MDCTL_SET_NEXT(mdctl, next_state);
270ec00b2e3SNishanth Menon __raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
271ec00b2e3SNishanth Menon /* Trigger PD transition */
272ec00b2e3SNishanth Menon ptcmd = __raw_readl(KS2_PSC_BASE + PSC_REG_PTCMD);
273ec00b2e3SNishanth Menon ptcmd |= (u32)(1 << domain_num);
274ec00b2e3SNishanth Menon __raw_writel(ptcmd, KS2_PSC_BASE + PSC_REG_PTCMD);
275ec00b2e3SNishanth Menon psc_wait(domain_num);
276ec00b2e3SNishanth Menon
277ec00b2e3SNishanth Menon mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
278ec00b2e3SNishanth Menon while (timeout) {
279ec00b2e3SNishanth Menon mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
280ec00b2e3SNishanth Menon
281ec00b2e3SNishanth Menon if (!(PSC_REG_MDSTAT_GET_STATUS(mdstat) & 0x30) &&
282ec00b2e3SNishanth Menon PSC_REG_MDSTAT_GET_MRSTDONE(mdstat) &&
283ec00b2e3SNishanth Menon PSC_REG_MDSTAT_GET_LRSTDONE(mdstat))
284ec00b2e3SNishanth Menon break;
285ec00b2e3SNishanth Menon timeout--;
286ec00b2e3SNishanth Menon }
287ec00b2e3SNishanth Menon
288ec00b2e3SNishanth Menon if (!timeout) {
289ec00b2e3SNishanth Menon printf("%s: Timedout waiting for mdstat(0x%08x) to change\n",
290ec00b2e3SNishanth Menon __func__, mdstat);
291ec00b2e3SNishanth Menon return -ETIMEDOUT;
292ec00b2e3SNishanth Menon }
293ec00b2e3SNishanth Menon return 0;
294ec00b2e3SNishanth Menon }
295ec00b2e3SNishanth Menon
296ec00b2e3SNishanth Menon /**
297ec00b2e3SNishanth Menon * psc_module_release_from_reset() - Release the module from reset
298ec00b2e3SNishanth Menon * @mod_num: LPSC module number
299ec00b2e3SNishanth Menon *
300ec00b2e3SNishanth Menon * This is the follow through for the command 'psc_module_keep_in_reset_enabled'
301ec00b2e3SNishanth Menon * Allowing the module to be released from reset once all required inits are
302ec00b2e3SNishanth Menon * complete for the module. Typically, this allows the processor module to start
303ec00b2e3SNishanth Menon * execution.
304ec00b2e3SNishanth Menon */
psc_module_release_from_reset(u32 mod_num)305ec00b2e3SNishanth Menon int psc_module_release_from_reset(u32 mod_num)
306ec00b2e3SNishanth Menon {
307ec00b2e3SNishanth Menon u32 mdctl, mdstat;
308ec00b2e3SNishanth Menon int domain_num = psc_get_domain_num(mod_num);
309ec00b2e3SNishanth Menon int timeout = 100000;
310ec00b2e3SNishanth Menon
311ec00b2e3SNishanth Menon /* Wait for any previous transitions to complete */
312ec00b2e3SNishanth Menon psc_wait(domain_num);
313ec00b2e3SNishanth Menon mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
314ec00b2e3SNishanth Menon /* Should be set to 1 to de-assert Local reset */
315ec00b2e3SNishanth Menon if ((mdctl & PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0))) {
316ec00b2e3SNishanth Menon mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 1);
317ec00b2e3SNishanth Menon __raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
318ec00b2e3SNishanth Menon /* Wait for transition to take place */
319ec00b2e3SNishanth Menon psc_wait(domain_num);
320ec00b2e3SNishanth Menon }
321ec00b2e3SNishanth Menon mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
322ec00b2e3SNishanth Menon while (timeout) {
323ec00b2e3SNishanth Menon mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
324ec00b2e3SNishanth Menon
325ec00b2e3SNishanth Menon if (!(PSC_REG_MDSTAT_GET_STATUS(mdstat) & 0x30) &&
326ec00b2e3SNishanth Menon PSC_REG_MDSTAT_GET_MRSTDONE(mdstat) &&
327ec00b2e3SNishanth Menon PSC_REG_MDSTAT_GET_LRSTDONE(mdstat))
328ec00b2e3SNishanth Menon break;
329ec00b2e3SNishanth Menon timeout--;
330ec00b2e3SNishanth Menon }
331ec00b2e3SNishanth Menon
332ec00b2e3SNishanth Menon if (!timeout) {
333ec00b2e3SNishanth Menon printf("%s: Timedout waiting for mdstat(0x%08x) to change\n",
334ec00b2e3SNishanth Menon __func__, mdstat);
335ec00b2e3SNishanth Menon return -ETIMEDOUT;
336ec00b2e3SNishanth Menon }
337ec00b2e3SNishanth Menon
338ec00b2e3SNishanth Menon return 0;
339ec00b2e3SNishanth Menon }
340