summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlek Du <alek.du@intel.com>2009-06-04 15:02:03 +0800
committerPatrick Tjin <pattjin@google.com>2014-07-21 20:22:39 -0700
commita8cef7fc4c8686fd903b444b0d1ac0a071d05f5d (patch)
treee79e1d7b9e82b0e86664de72c7b386e6d06dbb82
parent7cc52cde55aa85061da67d64212e036ac74d9e73 (diff)
downloadbootstub-a8cef7fc4c8686fd903b444b0d1ac0a071d05f5d.tar.gz
add SPI controller selection flag, clean code to 0.7 version
Signed-off-by: Alek Du <alek.du@intel.com>
-rw-r--r--VERSION1
-rw-r--r--bootstub.c2
-rw-r--r--bootstub.h1
-rw-r--r--bootstub.spec3
-rw-r--r--head.S5
-rw-r--r--spi-uart.c42
6 files changed, 26 insertions, 28 deletions
diff --git a/VERSION b/VERSION
index 7b93907..cdec7b6 100644
--- a/VERSION
+++ b/VERSION
@@ -1,3 +1,4 @@
+0.7 build e820 table and add SPI controller selection. June 4, 2009
0.6 optimized spi uart and initrd relocation performance. May 26, 2009
0.5 add arch parameter. March 12, 2009
0.4 spi suppression flag. July 19, 2008
diff --git a/bootstub.c b/bootstub.c
index 74b8753..d05daba 100644
--- a/bootstub.c
+++ b/bootstub.c
@@ -130,7 +130,7 @@ int bootstub(void)
{
setup_idt();
setup_gdt();
- bs_printk("Bootstub Version: 0.6 ...\n");
+ bs_printk("Bootstub Version: 0.7 ...\n");
setup_boot_params((struct boot_params *)BOOT_PARAMS_OFFSET,
(struct setup_header *)SETUP_HEADER_OFFSET);
bs_printk("Jump to kernel 32bit entry ...\n");
diff --git a/bootstub.h b/bootstub.h
index 44af1b2..dbd9dbf 100644
--- a/bootstub.h
+++ b/bootstub.h
@@ -8,6 +8,7 @@
#define BZIMAGE_SIZE_OFFSET 0x1100100
#define INITRD_SIZE_OFFSET 0x1100104
#define SPI_UART_SUPPRESSION 0x1100108
+#define SPI_TYPE 0x110010c /*0:SPI0 1:SPI1*/
#define STACK_OFFSET 0x1101000
#define BZIMAGE_OFFSET 0x1102000
diff --git a/bootstub.spec b/bootstub.spec
index 1bc4543..786cb52 100644
--- a/bootstub.spec
+++ b/bootstub.spec
@@ -28,6 +28,9 @@ install -m 755 bootstub $RPM_BUILD_ROOT/boot/
/boot/bootstub
%changelog
+* Thu Jun 04 2008 Alek Du <alek.du@intel.com> - 0.7
+- build e820 table (by Feng.Tang@intel.com)
+- add SPI controller selection flag
* Tue May 12 2009 Alek Du <alek.du@intel.com> - 0.6
- improved initrd relocation performance
- improved spi uart output performance
diff --git a/head.S b/head.S
index bb51a2c..941c92d 100644
--- a/head.S
+++ b/head.S
@@ -35,7 +35,10 @@
* 0x1101000 +-----------------------+
* | free space |
* | used as stack |
- * +-----------------------+
+ * 0x1100110 +-----------------------+
+ * | SPI0 or SPI1 | MIC need to fill it:
+ * | | 0x0: SPI0, 0x1: SPI1
+ * 0x110010c +-----------------------+
* | boot stub spi uart | MIC need to fill it:
* | suppression flag | 0x1 suppression, 0x0 default
* 0x1100108 +-----------------------+
diff --git a/spi-uart.c b/spi-uart.c
index ca6ec25..b49e11e 100644
--- a/spi-uart.c
+++ b/spi-uart.c
@@ -18,17 +18,26 @@
*/
#include "spi-uart.h"
+#include "bootstub.h"
#define MRST_SPI_TIMEOUT 0x200000
static int spi_inited = 0;
-static struct mrst_spi_reg *pspi = 0;
+static volatile struct mrst_spi_reg *pspi = 0;
static void spi_init()
{
u32 ctrlr0;
- pspi = (struct mrst_spi_reg *)MRST_REGBASE_SPI0;
-
+ switch (*(int *)SPI_TYPE) {
+ case 0:
+ pspi = (struct mrst_spi_reg *)MRST_REGBASE_SPI0;
+ break;
+ case 1:
+ pspi = (struct mrst_spi_reg *)MRST_REGBASE_SPI1;
+ break;
+ default:
+ pspi = (struct mrst_spi_reg *)MRST_REGBASE_SPI0;
+ }
/* disable SPI controller first */
pspi->ssienr = 0x0;
@@ -84,26 +93,12 @@ static int spi_max3110_putc(char c)
{
unsigned int timeout;
u32 sr;
- u32 test;
-
- /* read RX FIFO out if there is any */
- while ((pspi->sr & SR_RF_NOT_EMPT) && pspi->rxflr ) {
- timeout = MRST_SPI_TIMEOUT;
- while (timeout--) {
- if (!(pspi->sr & SR_BUSY))
- break;
- }
-
- if (timeout == 0xffffffff)
- return -1;
- test = pspi->dr[0];
- }
timeout = MRST_SPI_TIMEOUT;
/* early putc need make sure the TX FIFO is not full*/
while (timeout--) {
sr = pspi->sr;
- if ( (sr & SR_BUSY) || !(sr & SR_TF_NOT_FULL))
+ if (!(sr & SR_TF_NOT_FULL))
continue;
else
break;
@@ -117,21 +112,16 @@ static int spi_max3110_putc(char c)
return 0;
}
-
void bs_spi_printk(const char *str)
{
- if (!spi_inited)
+ if (!spi_inited) {
spi_init();
+ max3110_write_config();
+ }
if (!str)
return;
- /*
- * here we assume only 1 write_config is enough,
- * if not will call it for each putc
- */
- max3110_write_config();
-
while (*str) {
if (*str == '\n')
spi_max3110_putc('\r');