~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/stmp_device.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * Copyright (C) 1999 ARM Limited
  4  * Copyright (C) 2000 Deep Blue Solutions Ltd
  5  * Copyright 2006-2007,2010 Freescale Semiconductor, Inc. All Rights Reserved.
  6  * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
  7  * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok@emcraft.com
  8  * Copyright (C) 2011 Wolfram Sang, Pengutronix e.K.
  9  */
 10 
 11 #include <linux/io.h>
 12 #include <linux/errno.h>
 13 #include <linux/delay.h>
 14 #include <linux/compiler.h>
 15 #include <linux/export.h>
 16 #include <linux/stmp_device.h>
 17 
 18 #define STMP_MODULE_CLKGATE     (1 << 30)
 19 #define STMP_MODULE_SFTRST      (1 << 31)
 20 
 21 /*
 22  * Clear the bit and poll it cleared.  This is usually called with
 23  * a reset address and mask being either SFTRST(bit 31) or CLKGATE
 24  * (bit 30).
 25  */
 26 static int stmp_clear_poll_bit(void __iomem *addr, u32 mask)
 27 {
 28         int timeout = 0x400;
 29 
 30         writel(mask, addr + STMP_OFFSET_REG_CLR);
 31         udelay(1);
 32         while ((readl(addr) & mask) && --timeout)
 33                 /* nothing */;
 34 
 35         return !timeout;
 36 }
 37 
 38 int stmp_reset_block(void __iomem *reset_addr)
 39 {
 40         int ret;
 41         int timeout = 0x400;
 42 
 43         /* clear and poll SFTRST */
 44         ret = stmp_clear_poll_bit(reset_addr, STMP_MODULE_SFTRST);
 45         if (unlikely(ret))
 46                 goto error;
 47 
 48         /* clear CLKGATE */
 49         writel(STMP_MODULE_CLKGATE, reset_addr + STMP_OFFSET_REG_CLR);
 50 
 51         /* set SFTRST to reset the block */
 52         writel(STMP_MODULE_SFTRST, reset_addr + STMP_OFFSET_REG_SET);
 53         udelay(1);
 54 
 55         /* poll CLKGATE becoming set */
 56         while ((!(readl(reset_addr) & STMP_MODULE_CLKGATE)) && --timeout)
 57                 /* nothing */;
 58         if (unlikely(!timeout))
 59                 goto error;
 60 
 61         /* clear and poll SFTRST */
 62         ret = stmp_clear_poll_bit(reset_addr, STMP_MODULE_SFTRST);
 63         if (unlikely(ret))
 64                 goto error;
 65 
 66         /* clear and poll CLKGATE */
 67         ret = stmp_clear_poll_bit(reset_addr, STMP_MODULE_CLKGATE);
 68         if (unlikely(ret))
 69                 goto error;
 70 
 71         return 0;
 72 
 73 error:
 74         pr_err("%s(%p): module reset timeout\n", __func__, reset_addr);
 75         return -ETIMEDOUT;
 76 }
 77 EXPORT_SYMBOL(stmp_reset_block);
 78 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php