1# 2# Copyright (c) 2011 The Chromium OS Authors. 3# 4# See file CREDITS for list of people who contributed to this 5# project. 6# 7# This program is free software; you can redistribute it and/or 8# modify it under the terms of the GNU General Public License as 9# published by the Free Software Foundation; either version 2 of 10# the License, or (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program; if not, write to the Free Software 19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20# MA 02111-1307 USA 21# 22 23import os 24import tempfile 25import unittest 26 27import checkpatch 28import gitutil 29import patchstream 30import series 31 32 33class TestPatch(unittest.TestCase): 34 """Test this program 35 36 TODO: Write tests for the rest of the functionality 37 """ 38 39 def testBasic(self): 40 """Test basic filter operation""" 41 data=''' 42 43From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001 44From: Simon Glass <sjg@chromium.org> 45Date: Thu, 28 Apr 2011 09:58:51 -0700 46Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support 47 48This adds functions to enable/disable clocks and reset to on-chip peripherals. 49 50BUG=chromium-os:13875 51TEST=build U-Boot for Seaboard, boot 52 53Change-Id: I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413 54 55Review URL: http://codereview.chromium.org/6900006 56 57Signed-off-by: Simon Glass <sjg@chromium.org> 58--- 59 arch/arm/cpu/armv7/tegra2/Makefile | 2 +- 60 arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++---- 61 arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++ 62''' 63 expected=''' 64 65From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001 66From: Simon Glass <sjg@chromium.org> 67Date: Thu, 28 Apr 2011 09:58:51 -0700 68Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support 69 70This adds functions to enable/disable clocks and reset to on-chip peripherals. 71 72Signed-off-by: Simon Glass <sjg@chromium.org> 73--- 74 arch/arm/cpu/armv7/tegra2/Makefile | 2 +- 75 arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++---- 76 arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++ 77''' 78 out = '' 79 inhandle, inname = tempfile.mkstemp() 80 infd = os.fdopen(inhandle, 'w') 81 infd.write(data) 82 infd.close() 83 84 exphandle, expname = tempfile.mkstemp() 85 expfd = os.fdopen(exphandle, 'w') 86 expfd.write(expected) 87 expfd.close() 88 89 patchstream.FixPatch(None, inname, series.Series(), None) 90 rc = os.system('diff -u %s %s' % (inname, expname)) 91 self.assertEqual(rc, 0) 92 93 os.remove(inname) 94 os.remove(expname) 95 96 def GetData(self, data_type): 97 data=''' 98From 4924887af52713cabea78420eff03badea8f0035 Mon Sep 17 00:00:00 2001 99From: Simon Glass <sjg@chromium.org> 100Date: Thu, 7 Apr 2011 10:14:41 -0700 101Subject: [PATCH 1/4] Add microsecond boot time measurement 102 103This defines the basics of a new boot time measurement feature. This allows 104logging of very accurate time measurements as the boot proceeds, by using 105an available microsecond counter. 106 107%s 108--- 109 README | 11 ++++++++ 110 common/bootstage.c | 50 ++++++++++++++++++++++++++++++++++++ 111 include/bootstage.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 112 include/common.h | 8 ++++++ 113 5 files changed, 141 insertions(+), 0 deletions(-) 114 create mode 100644 common/bootstage.c 115 create mode 100644 include/bootstage.h 116 117diff --git a/README b/README 118index 6f3748d..f9e4e65 100644 119--- a/README 120+++ b/README 121@@ -2026,6 +2026,17 @@ The following options need to be configured: 122 example, some LED's) on your board. At the moment, 123 the following checkpoints are implemented: 124 125+- Time boot progress 126+ CONFIG_BOOTSTAGE 127+ 128+ Define this option to enable microsecond boot stage timing 129+ on supported platforms. For this to work your platform 130+ needs to define a function timer_get_us() which returns the 131+ number of microseconds since reset. This would normally 132+ be done in your SOC or board timer.c file. 133+ 134+ You can add calls to bootstage_mark() to set time markers. 135+ 136 - Standalone program support: 137 CONFIG_STANDALONE_LOAD_ADDR 138 139diff --git a/common/bootstage.c b/common/bootstage.c 140new file mode 100644 141index 0000000..2234c87 142--- /dev/null 143+++ b/common/bootstage.c 144@@ -0,0 +1,50 @@ 145+/* 146+ * Copyright (c) 2011, Google Inc. All rights reserved. 147+ * 148+ * See file CREDITS for list of people who contributed to this 149+ * project. 150+ * 151+ * This program is free software; you can redistribute it and/or 152+ * modify it under the terms of the GNU General Public License as 153+ * published by the Free Software Foundation; either version 2 of 154+ * the License, or (at your option) any later version. 155+ * 156+ * This program is distributed in the hope that it will be useful, 157+ * but WITHOUT ANY WARRANTY; without even the implied warranty of 158+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 159+ * GNU General Public License for more details. 160+ * 161+ * You should have received a copy of the GNU General Public License 162+ * along with this program; if not, write to the Free Software 163+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 164+ * MA 02111-1307 USA 165+ */ 166+ 167+ 168+/* 169+ * This module records the progress of boot and arbitrary commands, and 170+ * permits accurate timestamping of each. The records can optionally be 171+ * passed to kernel in the ATAGs 172+ */ 173+ 174+#include <common.h> 175+ 176+ 177+struct bootstage_record { 178+ uint32_t time_us; 179+ const char *name; 180+}; 181+ 182+static struct bootstage_record record[BOOTSTAGE_COUNT]; 183+ 184+uint32_t bootstage_mark(enum bootstage_id id, const char *name) 185+{ 186+ struct bootstage_record *rec = &record[id]; 187+ 188+ /* Only record the first event for each */ 189+%sif (!rec->name) { 190+ rec->time_us = (uint32_t)timer_get_us(); 191+ rec->name = name; 192+ } 193+%sreturn rec->time_us; 194+} 195-- 1961.7.3.1 197''' 198 signoff = 'Signed-off-by: Simon Glass <sjg@chromium.org>\n' 199 tab = ' ' 200 if data_type == 'good': 201 pass 202 elif data_type == 'no-signoff': 203 signoff = '' 204 elif data_type == 'spaces': 205 tab = ' ' 206 else: 207 print 'not implemented' 208 return data % (signoff, tab, tab) 209 210 def SetupData(self, data_type): 211 inhandle, inname = tempfile.mkstemp() 212 infd = os.fdopen(inhandle, 'w') 213 data = self.GetData(data_type) 214 infd.write(data) 215 infd.close() 216 return inname 217 218 def testCheckpatch(self): 219 """Test checkpatch operation""" 220 inf = self.SetupData('good') 221 result, problems, err, warn, lines, stdout = checkpatch.CheckPatch(inf) 222 self.assertEqual(result, True) 223 self.assertEqual(problems, []) 224 self.assertEqual(err, 0) 225 self.assertEqual(warn, 0) 226 self.assertEqual(lines, 67) 227 os.remove(inf) 228 229 inf = self.SetupData('no-signoff') 230 result, problems, err, warn, lines, stdout = checkpatch.CheckPatch(inf) 231 self.assertEqual(result, False) 232 self.assertEqual(len(problems), 1) 233 self.assertEqual(err, 1) 234 self.assertEqual(warn, 0) 235 self.assertEqual(lines, 67) 236 os.remove(inf) 237 238 inf = self.SetupData('spaces') 239 result, problems, err, warn, lines, stdout = checkpatch.CheckPatch(inf) 240 self.assertEqual(result, False) 241 self.assertEqual(len(problems), 2) 242 self.assertEqual(err, 0) 243 self.assertEqual(warn, 2) 244 self.assertEqual(lines, 67) 245 os.remove(inf) 246 247 248if __name__ == "__main__": 249 unittest.main() 250 gitutil.RunTests() 251