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

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-msm/proc_comm.c

Version: ~ [ linux-5.10-rc6 ] ~ [ linux-5.9.12 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.81 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.161 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.210 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.247 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.247 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* arch/arm/mach-msm/proc_comm.c
  2  *
  3  * Copyright (C) 2007-2008 Google, Inc.
  4  * Author: Brian Swetland <swetland@google.com>
  5  *
  6  * This software is licensed under the terms of the GNU General Public
  7  * License version 2, as published by the Free Software Foundation, and
  8  * may be copied, distributed, and modified under those terms.
  9  *
 10  * This program is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU General Public License for more details.
 14  *
 15  */
 16 
 17 #include <linux/delay.h>
 18 #include <linux/errno.h>
 19 #include <linux/io.h>
 20 #include <linux/spinlock.h>
 21 #include <mach/msm_iomap.h>
 22 
 23 #include "proc_comm.h"
 24 
 25 static inline void msm_a2m_int(uint32_t irq)
 26 {
 27 #if defined(CONFIG_ARCH_MSM7X30)
 28         writel(1 << irq, MSM_GCC_BASE + 0x8);
 29 #else
 30         writel(1, MSM_CSR_BASE + 0x400 + (irq * 4));
 31 #endif
 32 }
 33 
 34 static inline void notify_other_proc_comm(void)
 35 {
 36         msm_a2m_int(6);
 37 }
 38 
 39 #define APP_COMMAND 0x00
 40 #define APP_STATUS  0x04
 41 #define APP_DATA1   0x08
 42 #define APP_DATA2   0x0C
 43 
 44 #define MDM_COMMAND 0x10
 45 #define MDM_STATUS  0x14
 46 #define MDM_DATA1   0x18
 47 #define MDM_DATA2   0x1C
 48 
 49 static DEFINE_SPINLOCK(proc_comm_lock);
 50 
 51 /* The higher level SMD support will install this to
 52  * provide a way to check for and handle modem restart.
 53  */
 54 int (*msm_check_for_modem_crash)(void);
 55 
 56 /* Poll for a state change, checking for possible
 57  * modem crashes along the way (so we don't wait
 58  * forever while the ARM9 is blowing up).
 59  *
 60  * Return an error in the event of a modem crash and
 61  * restart so the msm_proc_comm() routine can restart
 62  * the operation from the beginning.
 63  */
 64 static int proc_comm_wait_for(void __iomem *addr, unsigned value)
 65 {
 66         for (;;) {
 67                 if (readl(addr) == value)
 68                         return 0;
 69 
 70                 if (msm_check_for_modem_crash)
 71                         if (msm_check_for_modem_crash())
 72                                 return -EAGAIN;
 73         }
 74 }
 75 
 76 int msm_proc_comm(unsigned cmd, unsigned *data1, unsigned *data2)
 77 {
 78         void __iomem *base = MSM_SHARED_RAM_BASE;
 79         unsigned long flags;
 80         int ret;
 81 
 82         spin_lock_irqsave(&proc_comm_lock, flags);
 83 
 84         for (;;) {
 85                 if (proc_comm_wait_for(base + MDM_STATUS, PCOM_READY))
 86                         continue;
 87 
 88                 writel(cmd, base + APP_COMMAND);
 89                 writel(data1 ? *data1 : 0, base + APP_DATA1);
 90                 writel(data2 ? *data2 : 0, base + APP_DATA2);
 91 
 92                 notify_other_proc_comm();
 93 
 94                 if (proc_comm_wait_for(base + APP_COMMAND, PCOM_CMD_DONE))
 95                         continue;
 96 
 97                 if (readl(base + APP_STATUS) != PCOM_CMD_FAIL) {
 98                         if (data1)
 99                                 *data1 = readl(base + APP_DATA1);
100                         if (data2)
101                                 *data2 = readl(base + APP_DATA2);
102                         ret = 0;
103                 } else {
104                         ret = -EIO;
105                 }
106                 break;
107         }
108 
109         writel(PCOM_CMD_IDLE, base + APP_COMMAND);
110 
111         spin_unlock_irqrestore(&proc_comm_lock, flags);
112 
113         return ret;
114 }
115 
116 /*
117  * We need to wait for the ARM9 to at least partially boot
118  * up before we can continue. Since the ARM9 does resource
119  * allocation, if we dont' wait we could end up crashing or in
120  * and unknown state. This function should be called early to
121  * wait on the ARM9.
122  */
123 void proc_comm_boot_wait(void)
124 {
125         void __iomem *base = MSM_SHARED_RAM_BASE;
126  
127         proc_comm_wait_for(base + MDM_STATUS, PCOM_READY);
128  
129 }
130 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp